| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 1 | /* |
| David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 2 | * Copyright (c) 2011-2014, Intel Corporation |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without modification, |
| 6 | * are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | * list of conditions and the following disclaimer. |
| 10 | * |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation and/or |
| 13 | * other materials provided with the distribution. |
| 14 | * |
| 15 | * 3. Neither the name of the copyright holder nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this software without |
| 17 | * specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 29 | */ |
| 30 | #include "ParameterMgr.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 31 | #include "XmlParameterSerializingContext.h" |
| 32 | #include "XmlElementSerializingContext.h" |
| 33 | #include "SystemClass.h" |
| 34 | #include "ElementLibrarySet.h" |
| 35 | #include "SubsystemLibrary.h" |
| 36 | #include "NamedElementBuilderTemplate.h" |
| 37 | #include "KindElementBuilderTemplate.h" |
| 38 | #include "ElementBuilderTemplate.h" |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 39 | #include "XmlFileIncluderElement.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 40 | #include "SelectionCriterionType.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 41 | #include "SubsystemElementBuilder.h" |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 42 | #include "FileIncluderElementBuilder.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 43 | #include "SelectionCriteria.h" |
| 44 | #include "ComponentType.h" |
| 45 | #include "ComponentInstance.h" |
| 46 | #include "ParameterBlockType.h" |
| 47 | #include "BooleanParameterType.h" |
| 48 | #include "IntegerParameterType.h" |
| 49 | #include "FixedPointParameterType.h" |
| 50 | #include "ParameterBlackboard.h" |
| 51 | #include "Parameter.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 52 | #include "ParameterAccessContext.h" |
| 53 | #include "XmlFileIncluderElement.h" |
| 54 | #include "ParameterFrameworkConfiguration.h" |
| 55 | #include "FrameworkConfigurationGroup.h" |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 56 | #include "PluginLocation.h" |
| 57 | #include "SubsystemPlugins.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 58 | #include "FrameworkConfigurationLocation.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 59 | #include "ConfigurableDomains.h" |
| 60 | #include "ConfigurableDomain.h" |
| 61 | #include "DomainConfiguration.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 62 | #include "XmlDomainSerializingContext.h" |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 63 | #include "XmlDomainExportContext.h" |
| 64 | #include "XmlDomainImportContext.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 65 | #include "BitParameterBlockType.h" |
| 66 | #include "BitParameterType.h" |
| Patrick Benavoli | 1352ae5 | 2011-10-21 16:48:04 +0200 | [diff] [blame] | 67 | #include "StringParameterType.h" |
| Patrick Benavoli | 9fc3c0d | 2011-10-27 14:27:27 +0200 | [diff] [blame] | 68 | #include "EnumParameterType.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 69 | #include "RemoteProcessorServerInterface.h" |
| 70 | #include "ElementLocator.h" |
| 71 | #include "AutoLog.h" |
| 72 | #include "CompoundRule.h" |
| 73 | #include "SelectionCriterionRule.h" |
| 74 | #include "SimulatedBackSynchronizer.h" |
| 75 | #include "HardwareBackSynchronizer.h" |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 76 | #include "AutoLock.h" |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 77 | #include <strings.h> |
| 78 | #include <dlfcn.h> |
| 79 | #include <assert.h> |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 80 | #include "ParameterHandle.h" |
| Patrick Benavoli | ee65e6d | 2011-11-20 18:52:24 +0100 | [diff] [blame] | 81 | #include "LinearParameterAdaptation.h" |
| Patrick Benavoli | 68808c6 | 2012-02-02 17:12:41 +0100 | [diff] [blame] | 82 | #include "EnumValuePair.h" |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 83 | #include "Subsystem.h" |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 84 | #include "XmlFileDocSink.h" |
| 85 | #include "XmlFileDocSource.h" |
| 86 | #include "XmlStringDocSink.h" |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 87 | #include "XmlStringDocSource.h" |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 88 | #include "XmlMemoryDocSink.h" |
| 89 | #include "XmlMemoryDocSource.h" |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 90 | #include "Utility.h" |
| Frédéric Boisnard | 6c55e9a | 2014-01-10 18:46:33 +0100 | [diff] [blame] | 91 | #include <sstream> |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 92 | |
| 93 | #define base CElement |
| 94 | |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 95 | using std::string; |
| 96 | using std::list; |
| 97 | using std::vector; |
| 98 | using std::ostringstream; |
| 99 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 100 | // Used for remote processor server creation |
| 101 | typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler); |
| 102 | |
| 103 | // Global configuration file name (fixed) |
| 104 | const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml"; |
| 105 | const char* gacSystemSchemasSubFolder = "Schemas"; |
| 106 | |
| 107 | // Config File System looks normally like this: |
| 108 | // --------------------------------------------- |
| Kevin Rocard | 03b7384 | 2014-10-01 18:20:41 +0200 | [diff] [blame] | 109 | //|-- <ParameterFrameworkConfiguration>.xml |
| 110 | //|-- Schemas |
| 111 | //| `-- *.xsd |
| 112 | //|-- Settings |
| 113 | //| `-- <SystemClassName folder>* |
| 114 | //| |-- <ConfigurableDomains>.xml |
| 115 | //| `-- <Settings>.bin? |
| 116 | //`-- Structure |
| 117 | // `-- <SystemClassName folder>* |
| 118 | // |-- <SystemClassName>Class.xml |
| 119 | // `-- <Subsystem>.xml* |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 120 | // -------------------------------------------- |
| 121 | |
| 122 | |
| 123 | // Remote command parser array |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 124 | const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = { |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 125 | |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 126 | /// Version |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 127 | { "version", &CParameterMgr::versionCommandProcess, 0, |
| 128 | "", "Show version" }, |
| 129 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 130 | /// Status |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 131 | { "status", &CParameterMgr::statusCommandProcess, 0, "", |
| 132 | "Show current status" }, |
| 133 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 134 | /// Tuning Mode |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 135 | { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, |
| 136 | "on|off*", "Turn on or off Tuning Mode" }, |
| 137 | { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, |
| 138 | "", "Show Tuning Mode" }, |
| 139 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 140 | /// Value Space |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 141 | { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, |
| 142 | "raw|real*", "Assigns Value Space used for parameter value interpretation" }, |
| 143 | { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, |
| 144 | "", "Show Value Space" }, |
| 145 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 146 | /// Output Raw Format |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 147 | { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, |
| 148 | "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" }, |
| 149 | { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, |
| 150 | "", "Show Output Raw Format" }, |
| 151 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 152 | /// Sync |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 153 | { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, |
| 154 | "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" }, |
| 155 | { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, |
| 156 | "", "Show Auto Sync state" }, |
| 157 | { "sync", &CParameterMgr::syncCommmandProcess, 0, |
| 158 | "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" }, |
| 159 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 160 | /// Criteria |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 161 | { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, |
| 162 | "[csv]", "List selection criteria" }, |
| 163 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 164 | /// Domains |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 165 | { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, |
| 166 | "", "List configurable domains" }, |
| 167 | { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0, |
| 168 | "", "Show all domains and configurations, including applicability conditions" }, |
| 169 | { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, |
| 170 | "<domain>", "Create new configurable domain" }, |
| 171 | { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, |
| 172 | "<domain>", "Delete configurable domain" }, |
| 173 | { "deleteAllDomains", &CParameterMgr::deleteAllDomainsCommmandProcess, 0, |
| 174 | "", "Delete all configurable domains" }, |
| 175 | { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, |
| 176 | "<domain> <new name>", "Rename configurable domain" }, |
| 177 | { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, |
| 178 | "<domain> true|false*", "Set configurable domain sequence awareness" }, |
| 179 | { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, |
| 180 | "<domain>", "Get configurable domain sequence awareness" }, |
| 181 | { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, |
| 182 | "<domain>", "List elements associated to configurable domain" }, |
| 183 | { "addElement", &CParameterMgr::addElementCommmandProcess, 2, |
| 184 | "<domain> <elem path>", "Associate element at given path to configurable domain" }, |
| 185 | { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, |
| 186 | "<domain> <elem path>", "Dissociate element at given path from configurable domain" }, |
| 187 | { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, |
| 188 | "<domain> <elem path>", "Split configurable domain at given associated element path" }, |
| 189 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 190 | /// Configurations |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 191 | { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, |
| 192 | "<domain>", "List domain configurations" }, |
| 193 | { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, |
| 194 | "<domain> <configuration>", "Create new domain configuration" }, |
| 195 | { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, |
| 196 | "<domain> <configuration>", "Delete domain configuration" }, |
| 197 | { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, |
| 198 | "<domain> <configuration> <new name>", "Rename domain configuration" }, |
| 199 | { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, |
| 200 | "<domain> <configuration>", "Save current settings into configuration" }, |
| 201 | { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, |
| 202 | "<domain> <configuration>", "Restore current settings from configuration" }, |
| 203 | { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3, |
| 204 | "<domain> <configuration> <elem path list>", |
| 205 | "Set element application order for configuration" }, |
| 206 | { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, |
| 207 | "<domain> <configuration>", "Get element application order for configuration" }, |
| 208 | { "setRule", &CParameterMgr::setRuleCommmandProcess, 3, |
| 209 | "<domain> <configuration> <rule>", "Set configuration application rule" }, |
| 210 | { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2, |
| 211 | "<domain> <configuration>", "Clear configuration application rule" }, |
| 212 | { "getRule", &CParameterMgr::getRuleCommmandProcess, 2, |
| 213 | "<domain> <configuration>", "Get configuration application rule" }, |
| 214 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 215 | /// Elements/Parameters |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 216 | { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, |
| 217 | "<elem path>|/", "List elements under element at given path or root" }, |
| 218 | { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, |
| 219 | "<elem path>|/", "List parameters under element at given path or root" }, |
| 220 | { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, |
| 221 | "<elem path>", "Dump structure and content of element at given path" }, |
| 222 | { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, |
| 223 | "<elem path>", "Show size of element at given path" }, |
| 224 | { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, |
| 225 | "<elem path>", "Show properties of element at given path" }, |
| 226 | { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, |
| 227 | "<param path>", "Get value for parameter at given path" }, |
| 228 | { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, |
| 229 | "<param path> <value>", "Set value for parameter at given path" }, |
| 230 | { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, |
| 231 | "<elem path>", "List domain(s) element at given path belongs to" }, |
| 232 | { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, |
| 233 | "<elem path>", "List domain(s) element at given path is associated to" }, |
| 234 | { "getConfigurationParameter", &CParameterMgr::getConfigurationParameterCommmandProcess, 3, |
| 235 | "<domain> <configuration> <param path>", |
| 236 | "Get value for parameter at given path from configuration" }, |
| 237 | { "setConfigurationParameter", &CParameterMgr::setConfigurationParameterCommmandProcess, 4, |
| 238 | "<domain> <configuration> <param path> <value>", |
| 239 | "Set value for parameter at given path to configuration" }, |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 240 | { "showMapping", &CParameterMgr::showMappingCommmandProcess, 1, |
| 241 | "<elem path>", "Show mapping for an element at given path" }, |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 242 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 243 | /// Browse |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 244 | { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, |
| 245 | "", "List element sub-trees associated to at least one configurable domain" }, |
| 246 | { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, |
| 247 | "", "List element sub-trees contained in more than one configurable domain" }, |
| 248 | { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, |
| 249 | "", "List element sub-trees owned by no configurable domain" }, |
| 250 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 251 | /// Settings Import/Export |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 252 | { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, |
| 253 | "<file path> ", "Export domains to XML file" }, |
| 254 | { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, |
| 255 | "<file path>", "Import domains from XML file" }, |
| 256 | { "exportDomainsWithSettingsXML", |
| 257 | &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, |
| 258 | "<file path> ", "Export domains including settings to XML file" }, |
| 259 | { "importDomainsWithSettingsXML", |
| 260 | &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, |
| 261 | "<file path>", "Import domains including settings from XML file" }, |
| 262 | { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, |
| 263 | "<file path>", "Export settings to binary file" }, |
| 264 | { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, |
| 265 | "<file path>", "Import settings from binary file" }, |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 266 | { "getDomainsWithSettingsXML", |
| 267 | &CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess, 0, |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 268 | "", "Print domains including settings as XML" }, |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 269 | { "setDomainsWithSettingsXML", |
| 270 | &CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess, 1, |
| 271 | "<xml configurable domains>", "Import domains including settings from XML string" }, |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 272 | /// Structure Export |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 273 | { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 , |
| Kevin Rocard | c021157 | 2013-06-18 11:34:53 +0200 | [diff] [blame] | 274 | "", "Print parameter structure as XML" }, |
| 275 | /// Deprecated Commands |
| 276 | { "getDomainsXML", |
| 277 | &CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess, 0, |
| 278 | "", "DEPRECATED COMMAND, please use getDomainsWithSettingsXML" }, |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 279 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 280 | }; |
| Kevin Rocard | 3949b34 | 2013-05-24 18:43:53 +0200 | [diff] [blame] | 281 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 282 | // Remote command parsers array Size |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 283 | const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 284 | |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 285 | CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) : |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 286 | _bTuningModeIsOn(false), |
| 287 | _bValueSpaceIsRaw(false), |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 288 | _bOutputRawFormatIsHex(false), |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 289 | _bAutoSyncOn(true), |
| 290 | _pMainParameterBlackboard(new CParameterBlackboard), |
| 291 | _pElementLibrarySet(new CElementLibrarySet), |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 292 | _strXmlConfigurationFilePath(strConfigurationFilePath), |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 293 | _pSubsystemPlugins(NULL), |
| Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 294 | _handleLibRemoteProcessor(NULL), |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 295 | _uiStructureChecksum(0), |
| 296 | _pRemoteProcessorServer(NULL), |
| 297 | _uiMaxCommandUsageLength(0), |
| 298 | _pLogger(NULL), |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 299 | _uiLogDepth(0), |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 300 | _bFailOnMissingSubsystem(true), |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 301 | _bFailOnFailedSettingsLoad(true), |
| 302 | _bValidateSchemasOnStart(false) |
| 303 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 304 | { |
| 305 | // Tuning Mode Mutex |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 306 | bzero(&_blackboardMutex, sizeof(_blackboardMutex)); |
| 307 | pthread_mutex_init(&_blackboardMutex, NULL); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 308 | |
| 309 | // Deal with children |
| 310 | addChild(new CParameterFrameworkConfiguration); |
| 311 | addChild(new CSelectionCriteria); |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 312 | addChild(new CSystemClass); |
| 313 | addChild(new CConfigurableDomains); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 314 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 315 | _pCommandHandler = new CCommandHandler(this); |
| 316 | |
| 317 | // Add command parsers |
| 318 | uint32_t uiRemoteCommandParserItem; |
| 319 | |
| 320 | for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { |
| 321 | |
| 322 | const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; |
| 323 | |
| 324 | _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName, |
| 325 | pRemoteCommandParserItem->_pfnParser, |
| 326 | pRemoteCommandParserItem->_uiMinArgumentCount, |
| 327 | pRemoteCommandParserItem->_pcHelp, |
| 328 | pRemoteCommandParserItem->_pcDescription); |
| 329 | } |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 330 | |
| 331 | // Configuration file folder |
| 332 | uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1); |
| 333 | |
| 334 | assert(uiSlashPos != (uint32_t)-1); |
| 335 | |
| 336 | _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos); |
| 337 | |
| 338 | // Schema absolute folder location |
| 339 | _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | CParameterMgr::~CParameterMgr() |
| 343 | { |
| 344 | // Children |
| 345 | delete _pRemoteProcessorServer; |
| Frederic Boisnard | 3124230 | 2012-04-26 17:07:34 +0200 | [diff] [blame] | 346 | delete _pCommandHandler; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 347 | delete _pMainParameterBlackboard; |
| 348 | delete _pElementLibrarySet; |
| 349 | |
| Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 350 | // Close remote processor library |
| 351 | if (_handleLibRemoteProcessor != NULL) { |
| 352 | dlclose(_handleLibRemoteProcessor); |
| 353 | } |
| 354 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 355 | // Tuning Mode Mutex |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 356 | pthread_mutex_destroy(&_blackboardMutex); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | string CParameterMgr::getKind() const |
| 360 | { |
| 361 | return "ParameterMgr"; |
| 362 | } |
| 363 | |
| 364 | // Logging |
| 365 | void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger) |
| 366 | { |
| 367 | _pLogger = pLogger; |
| 368 | } |
| 369 | |
| 370 | // Logging |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 371 | void CParameterMgr::doLog(bool bIsWarning, const string& strLog) const |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 372 | { |
| 373 | if (_pLogger) { |
| 374 | |
| 375 | // Nest |
| 376 | string strIndent; |
| 377 | |
| 378 | // Level |
| 379 | uint32_t uiNbIndents = _uiLogDepth; |
| 380 | |
| 381 | while (uiNbIndents--) { |
| 382 | |
| 383 | strIndent += " "; |
| 384 | } |
| 385 | |
| 386 | // Log |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 387 | _pLogger->log(bIsWarning, strIndent + strLog); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
| 391 | void CParameterMgr::nestLog() const |
| 392 | { |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 393 | _uiLogDepth++; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | void CParameterMgr::unnestLog() const |
| 397 | { |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 398 | _uiLogDepth--; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 399 | } |
| 400 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 401 | // Version |
| 402 | string CParameterMgr::getVersion() const |
| 403 | { |
| 404 | string strVersion; |
| 405 | |
| 406 | // Major |
| 407 | strVersion = toString(guiEditionMajor) + "."; |
| 408 | // Minor |
| 409 | strVersion += toString(guiEditionMinor) + "."; |
| 410 | // Revision |
| 411 | strVersion += toString(guiRevision); |
| 412 | |
| 413 | return strVersion; |
| 414 | } |
| 415 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 416 | bool CParameterMgr::load(string& strError) |
| 417 | { |
| 418 | CAutoLog autoLog(this, "Loading"); |
| 419 | |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 420 | feedElementLibraries(); |
| 421 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 422 | // Load Framework configuration |
| 423 | if (!loadFrameworkConfiguration(strError)) { |
| 424 | |
| 425 | return false; |
| 426 | } |
| 427 | |
| 428 | // Load subsystems |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 429 | if (!getSystemClass()->loadSubsystems(strError, |
| 430 | _pSubsystemPlugins, !_bFailOnMissingSubsystem)) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 431 | |
| 432 | return false; |
| 433 | } |
| 434 | |
| 435 | // Load structure |
| 436 | if (!loadStructure(strError)) { |
| 437 | |
| 438 | return false; |
| 439 | } |
| 440 | |
| 441 | // Load settings |
| 442 | if (!loadSettings(strError)) { |
| 443 | |
| 444 | return false; |
| 445 | } |
| 446 | |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 447 | // Back synchronization for areas in parameter blackboard not covered by any domain |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 448 | CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 449 | |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 450 | // Back-synchronize |
| Kevin Rocard | 57096bd | 2012-11-30 11:24:20 +0100 | [diff] [blame] | 451 | { |
| 452 | CAutoLog autoLog(this, "Main blackboard back synchronization"); |
| 453 | |
| Kevin Rocard | 5d6e05a | 2013-01-21 15:57:45 +0100 | [diff] [blame] | 454 | pBackSynchronizer->sync(); |
| Kevin Rocard | 57096bd | 2012-11-30 11:24:20 +0100 | [diff] [blame] | 455 | |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 456 | // Get rid of back synchronizer |
| 457 | delete pBackSynchronizer; |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 458 | } |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 459 | |
| 460 | // We're done loading the settings and back synchronizing |
| 461 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 462 | |
| 463 | // We need to ensure all domains are valid |
| 464 | pConfigurableDomains->validate(_pMainParameterBlackboard); |
| 465 | |
| Kevin Rocard | 7f26582 | 2012-12-07 18:51:22 +0100 | [diff] [blame] | 466 | // Log selection criterion states |
| 467 | { |
| 468 | CAutoLog autoLog(this, "Criterion states"); |
| 469 | |
| 470 | const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria(); |
| 471 | |
| 472 | list<string> lstrSelectionCriteron; |
| 473 | selectionCriteria->listSelectionCriteria(lstrSelectionCriteron, true, false); |
| 474 | |
| Kevin Rocard | 3629936 | 2013-02-04 14:57:47 +0100 | [diff] [blame] | 475 | log_table(false, lstrSelectionCriteron); |
| Kevin Rocard | 7f26582 | 2012-12-07 18:51:22 +0100 | [diff] [blame] | 476 | } |
| 477 | |
| Kevin Rocard | 2fbe6e8 | 2013-03-26 17:09:29 +0100 | [diff] [blame] | 478 | // Subsystem can not ask for resync as they have not been synced yet |
| 479 | getSystemClass()->cleanSubsystemsNeedToResync(); |
| 480 | |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 481 | // At initialization, check subsystems that need resync |
| 482 | doApplyConfigurations(true); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 483 | |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 484 | // Start remote processor server if appropriate |
| 485 | return handleRemoteProcessingInterface(strError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | bool CParameterMgr::loadFrameworkConfiguration(string& strError) |
| 489 | { |
| 490 | CAutoLog autoLog(this, "Loading framework configuration"); |
| 491 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 492 | // Parse Structure XML file |
| 493 | CXmlElementSerializingContext elementSerializingContext(strError); |
| 494 | |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 495 | if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 496 | |
| 497 | return false; |
| 498 | } |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 499 | // Set class name to system class and configurable domains |
| 500 | getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName()); |
| 501 | getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName()); |
| 502 | |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 503 | // Get subsystem plugins elements |
| 504 | _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins")); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 505 | |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 506 | if (!_pSubsystemPlugins) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 507 | |
| Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 508 | strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element"; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 509 | |
| 510 | return false; |
| 511 | } |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 512 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 513 | // Log tuning availability |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 514 | log_info("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 515 | |
| 516 | return true; |
| 517 | } |
| 518 | |
| 519 | bool CParameterMgr::loadStructure(string& strError) |
| 520 | { |
| 521 | // Retrieve system to load structure to |
| 522 | CSystemClass* pSystemClass = getSystemClass(); |
| 523 | |
| Kevin Rocard | e25ee79 | 2013-04-22 17:46:28 +0200 | [diff] [blame] | 524 | log_info("Loading " + pSystemClass->getName() + " system class structure"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 525 | |
| 526 | // Get structure description element |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 527 | const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation")); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 528 | |
| 529 | if (!pStructureDescriptionFileLocation) { |
| 530 | |
| 531 | strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName(); |
| 532 | |
| 533 | return false; |
| 534 | } |
| 535 | |
| 536 | // Get Xml structure folder |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 537 | string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 538 | |
| 539 | // Get Xml structure file name |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 540 | string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 541 | |
| 542 | // Parse Structure XML file |
| 543 | CXmlParameterSerializingContext parameterBuildContext(strError); |
| 544 | |
| Kevin Rocard | 57096bd | 2012-11-30 11:24:20 +0100 | [diff] [blame] | 545 | CAutoLog autolog(pSystemClass, "Importing system structure from file " + strXmlStructureFilePath); |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 546 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 547 | if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { |
| 548 | |
| 549 | return false; |
| 550 | } |
| 551 | |
| 552 | // Initialize offsets |
| 553 | pSystemClass->setOffset(0); |
| 554 | |
| 555 | // Initialize main blackboard's size |
| 556 | _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint()); |
| 557 | |
| 558 | return true; |
| 559 | } |
| 560 | |
| 561 | bool CParameterMgr::loadSettings(string& strError) |
| 562 | { |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 563 | string strLoadError; |
| 564 | bool success = loadSettingsFromConfigFile(strLoadError); |
| 565 | |
| 566 | if (!success && !_bFailOnFailedSettingsLoad) { |
| 567 | // Load can not fail, ie continue but log the load errors |
| 568 | log_info(strLoadError); |
| 569 | log_info("Failed to load settings, continue without domains."); |
| 570 | success = true; |
| 571 | } |
| 572 | |
| 573 | if (!success) { |
| 574 | // Propagate the litteral error only if the function fails |
| 575 | strError = strLoadError; |
| 576 | return false; |
| 577 | } |
| 578 | |
| 579 | return true; |
| 580 | } |
| 581 | |
| 582 | bool CParameterMgr::loadSettingsFromConfigFile(string& strError) |
| 583 | { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 584 | CAutoLog autoLog(this, "Loading settings"); |
| 585 | |
| 586 | // Get settings configuration element |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 587 | const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration")); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 588 | |
| 589 | if (!pParameterConfigurationGroup) { |
| 590 | |
| 591 | // No settings to load |
| 592 | |
| 593 | return true; |
| 594 | } |
| 595 | // Get binary settings file location |
| 596 | const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation")); |
| 597 | |
| 598 | string strXmlBinarySettingsFilePath; |
| 599 | |
| 600 | if (pBinarySettingsFileLocation) { |
| 601 | |
| 602 | // Get Xml binary settings file name |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 603 | strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | // Get configurable domains element |
| 607 | const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation")); |
| 608 | |
| 609 | if (!pConfigurableDomainsFileLocation) { |
| 610 | |
| 611 | strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName(); |
| 612 | |
| 613 | return false; |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 614 | } |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 615 | // Get destination root element |
| 616 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 617 | |
| 618 | // Get Xml configuration domains file name |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 619 | string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 620 | |
| 621 | // Get Xml configuration domains folder |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 622 | string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 623 | |
| 624 | // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary) |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 625 | CXmlDomainImportContext xmlDomainImportContext(strError, !pBinarySettingsFileLocation); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 626 | |
| 627 | // Selection criteria definition for rule creation |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 628 | xmlDomainImportContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 629 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 630 | // Auto validation of configurations if no binary settings provided |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 631 | xmlDomainImportContext.setAutoValidationRequired(!pBinarySettingsFileLocation); |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 632 | |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 633 | log_info("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with"); |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 634 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 635 | // Do parse |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 636 | if (!xmlParse(xmlDomainImportContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 637 | |
| 638 | return false; |
| 639 | } |
| 640 | // We have loaded the whole system structure, compute checksum |
| 641 | const CSystemClass* pSystemClass = getConstSystemClass(); |
| 642 | _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum(); |
| 643 | |
| 644 | // Load binary settings if any provided |
| 645 | if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { |
| 646 | |
| 647 | return false; |
| 648 | } |
| 649 | |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 650 | return true; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | // XML parsing |
| 654 | bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName) |
| 655 | { |
| 656 | // Init serializing context |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 657 | elementSerializingContext.set(_pElementLibrarySet->getElementLibrary( |
| 658 | eElementLibrary), strXmlFolder, _strSchemaFolderLocation); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 659 | |
| 660 | // Get Schema file associated to root element |
| 661 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd"; |
| 662 | |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 663 | CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, |
| 664 | pRootElement->getKind(), |
| 665 | pRootElement->getName(), strNameAttrituteName, |
| 666 | _bValidateSchemasOnStart); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 667 | |
| 668 | // Start clean |
| 669 | pRootElement->clean(); |
| 670 | |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 671 | CXmlMemoryDocSink memorySink(pRootElement); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 672 | |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 673 | if (!memorySink.process(fileDocSource, elementSerializingContext)) { |
| 674 | //Cleanup |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 675 | pRootElement->clean(); |
| 676 | |
| 677 | return false; |
| 678 | } |
| 679 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 680 | return true; |
| 681 | } |
| 682 | |
| 683 | // Init |
| 684 | bool CParameterMgr::init(string& strError) |
| 685 | { |
| 686 | return base::init(strError); |
| 687 | } |
| 688 | |
| 689 | // Selection criteria interface |
| 690 | CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive) |
| 691 | { |
| 692 | // Propagate |
| 693 | return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive); |
| 694 | } |
| 695 | |
| 696 | CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) |
| 697 | { |
| 698 | // Propagate |
| 699 | return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType); |
| 700 | } |
| 701 | |
| Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 702 | // Selection criterion retrieval |
| 703 | CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 704 | { |
| Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 705 | // Propagate |
| 706 | return getSelectionCriteria()->getSelectionCriterion(strName); |
| 707 | } |
| 708 | |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 709 | // Configuration application |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 710 | void CParameterMgr::applyConfigurations() |
| Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 711 | { |
| 712 | CAutoLog autoLog(this, "Configuration application request"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 713 | |
| 714 | // Lock state |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 715 | CAutoLock autoLock(&_blackboardMutex); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 716 | |
| 717 | if (!_bTuningModeIsOn) { |
| 718 | |
| 719 | // Apply configuration(s) |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 720 | doApplyConfigurations(false); |
| Frédéric Boisnard | daaa63c | 2012-08-27 15:48:15 +0200 | [diff] [blame] | 721 | } else { |
| 722 | |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 723 | log_warning("Configurations were not applied because the TuningMode is on"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 724 | } |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 725 | } |
| 726 | |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 727 | // Get the configurableElement corresponding to the given path |
| 728 | const CConfigurableElement* CParameterMgr::getConfigurableElement(const string& strPath, |
| 729 | string& strError) const |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 730 | { |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 731 | CPathNavigator pathNavigator(strPath); |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 732 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 733 | // Nagivate through system class |
| 734 | if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) { |
| 735 | |
| Patrick Benavoli | 79f16cc | 2011-11-25 22:36:41 +0100 | [diff] [blame] | 736 | return NULL; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | // Find element |
| 740 | const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator); |
| 741 | |
| 742 | if (!pElement) { |
| 743 | |
| Kevin Rocard | 4c3f8d8 | 2013-11-21 12:16:28 +0100 | [diff] [blame] | 744 | strError = "Path not found: " + strPath; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 745 | |
| Patrick Benavoli | 79f16cc | 2011-11-25 22:36:41 +0100 | [diff] [blame] | 746 | return NULL; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | // Check found element is a parameter |
| 750 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement); |
| 751 | |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 752 | return pConfigurableElement; |
| 753 | } |
| 754 | |
| 755 | // Dynamic parameter handling |
| 756 | CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError) |
| 757 | { |
| 758 | const CConfigurableElement* pConfigurableElement = getConfigurableElement(strPath, strError); |
| 759 | |
| 760 | if (!pConfigurableElement) { |
| 761 | |
| 762 | // Element not found |
| Kevin Rocard | 4c3f8d8 | 2013-11-21 12:16:28 +0100 | [diff] [blame] | 763 | strError = "Element not found: " + strPath; |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 764 | return NULL; |
| 765 | } |
| 766 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 767 | if (!pConfigurableElement->isParameter()) { |
| 768 | |
| 769 | // Element is not parameter |
| Kevin Rocard | 4c3f8d8 | 2013-11-21 12:16:28 +0100 | [diff] [blame] | 770 | strError = "Not a parameter: " + strPath; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 771 | |
| Patrick Benavoli | 79f16cc | 2011-11-25 22:36:41 +0100 | [diff] [blame] | 772 | return NULL; |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | // Convert as parameter and return new handle |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 776 | return new CParameterHandle(static_cast<const CBaseParameter*>(pConfigurableElement), this); |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 777 | } |
| 778 | |
| Kevin Rocard | ecf9310 | 2013-07-10 18:28:10 +0200 | [diff] [blame] | 779 | void CParameterMgr::setFailureOnMissingSubsystem(bool bFail) |
| 780 | { |
| 781 | _bFailOnMissingSubsystem = bFail; |
| 782 | } |
| 783 | |
| 784 | bool CParameterMgr::getFailureOnMissingSubsystem() const |
| 785 | { |
| 786 | return _bFailOnMissingSubsystem; |
| 787 | } |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 788 | |
| 789 | void CParameterMgr::setFailureOnFailedSettingsLoad(bool bFail) |
| 790 | { |
| 791 | _bFailOnFailedSettingsLoad = bFail; |
| 792 | } |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 793 | |
| Kevin Rocard | d6909eb | 2013-07-18 09:13:51 +0200 | [diff] [blame] | 794 | bool CParameterMgr::getFailureOnFailedSettingsLoad() |
| 795 | { |
| 796 | return _bFailOnFailedSettingsLoad; |
| 797 | } |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 798 | |
| 799 | void CParameterMgr::setValidateSchemasOnStart(bool bValidate) |
| 800 | { |
| 801 | _bValidateSchemasOnStart = bValidate; |
| 802 | } |
| 803 | |
| 804 | bool CParameterMgr::getValidateSchemasOnStart() const |
| 805 | { |
| 806 | return _bValidateSchemasOnStart; |
| 807 | } |
| 808 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 809 | /////////////////// Remote command parsers |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 810 | /// Version |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 811 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 812 | { |
| 813 | (void)remoteCommand; |
| 814 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 815 | // Show version |
| 816 | strResult = getVersion(); |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 817 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 818 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 819 | } |
| 820 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 821 | /// Status |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 822 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 823 | { |
| 824 | (void)remoteCommand; |
| 825 | // System class |
| 826 | const CSystemClass* pSystemClass = getSystemClass(); |
| 827 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 828 | // Show status |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 829 | /// General section |
| 830 | appendTitle(strResult, "General:"); |
| 831 | // System class |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 832 | strResult += "System Class: "; |
| 833 | strResult += pSystemClass->getName(); |
| 834 | strResult += "\n"; |
| 835 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 836 | // Tuning mode |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 837 | strResult += "Tuning Mode: "; |
| 838 | strResult += tuningModeOn() ? "on" : "off"; |
| 839 | strResult += "\n"; |
| 840 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 841 | // Value space |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 842 | strResult += "Value Space: "; |
| 843 | strResult += valueSpaceIsRaw() ? "raw" : "real"; |
| 844 | strResult += "\n"; |
| 845 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 846 | // Output raw format |
| 847 | strResult += "Output Raw Format: "; |
| 848 | strResult += outputRawFormatIsHex() ? "hex" : "dec"; |
| 849 | strResult += "\n"; |
| 850 | |
| 851 | // Auto Sync |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 852 | strResult += "Auto Sync: "; |
| 853 | strResult += autoSyncOn() ? "on" : "off"; |
| 854 | strResult += "\n"; |
| 855 | |
| 856 | /// Subsystem list |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 857 | appendTitle(strResult, "Subsystems:"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 858 | string strSubsystemList; |
| 859 | pSystemClass->listChildrenPaths(strSubsystemList); |
| 860 | strResult += strSubsystemList; |
| 861 | |
| 862 | /// Last applied configurations |
| Frédéric Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 863 | appendTitle(strResult, "Last Applied [Pending] Configurations:"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 864 | string strLastAppliedConfigurations; |
| 865 | getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); |
| 866 | strResult += strLastAppliedConfigurations; |
| 867 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 868 | /// Criteria states |
| Frédéric Boisnard | 8b243f5 | 2012-09-06 18:03:20 +0200 | [diff] [blame] | 869 | appendTitle(strResult, "Selection Criteria:"); |
| Kevin Rocard | 7f26582 | 2012-12-07 18:51:22 +0100 | [diff] [blame] | 870 | list<string> lstrSelectionCriteria; |
| 871 | getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true); |
| 872 | // Concatenate the criterion list as the command result |
| Frederic Boisnard | 390b36d | 2013-05-23 15:28:31 +0200 | [diff] [blame] | 873 | string strCriteriaStates; |
| 874 | CUtility::asString(lstrSelectionCriteria, strCriteriaStates); |
| 875 | strResult += strCriteriaStates; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 876 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 877 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | /// Tuning Mode |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 881 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 882 | { |
| 883 | if (remoteCommand.getArgument(0) == "on") { |
| 884 | |
| 885 | if (setTuningMode(true, strResult)) { |
| 886 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 887 | return CCommandHandler::EDone; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 888 | } |
| 889 | } else if (remoteCommand.getArgument(0) == "off") { |
| 890 | |
| 891 | if (setTuningMode(false, strResult)) { |
| 892 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 893 | return CCommandHandler::EDone; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 894 | } |
| 895 | } else { |
| 896 | // Show usage |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 897 | return CCommandHandler::EShowUsage; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 898 | } |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 899 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 900 | } |
| 901 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 902 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 903 | { |
| 904 | (void)remoteCommand; |
| 905 | |
| 906 | strResult = tuningModeOn() ? "on" : "off"; |
| 907 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 908 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | /// Value Space |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 912 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 913 | { |
| 914 | (void)strResult; |
| 915 | |
| 916 | if (remoteCommand.getArgument(0) == "raw") { |
| 917 | |
| 918 | setValueSpace(true); |
| 919 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 920 | return CCommandHandler::EDone; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 921 | |
| 922 | } else if (remoteCommand.getArgument(0) == "real") { |
| 923 | |
| 924 | setValueSpace(false); |
| 925 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 926 | return CCommandHandler::EDone; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 927 | |
| 928 | } else { |
| 929 | // Show usage |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 930 | return CCommandHandler::EShowUsage; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 931 | } |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 932 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 933 | } |
| 934 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 935 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 936 | { |
| 937 | (void)remoteCommand; |
| 938 | |
| 939 | strResult = valueSpaceIsRaw() ? "raw" : "real"; |
| 940 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 941 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 942 | } |
| 943 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 944 | /// Output Raw Format |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 945 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 946 | { |
| 947 | (void)strResult; |
| 948 | |
| 949 | if (remoteCommand.getArgument(0) == "hex") { |
| 950 | |
| 951 | setOutputRawFormat(true); |
| 952 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 953 | return CCommandHandler::EDone; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 954 | |
| 955 | } else if (remoteCommand.getArgument(0) == "dec") { |
| 956 | |
| 957 | setOutputRawFormat(false); |
| 958 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 959 | return CCommandHandler::EDone; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 960 | |
| 961 | } else { |
| 962 | // Show usage |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 963 | return CCommandHandler::EShowUsage; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 964 | } |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 965 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 966 | } |
| 967 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 968 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 969 | { |
| 970 | (void)remoteCommand; |
| 971 | |
| 972 | strResult = outputRawFormatIsHex() ? "hex" : "dec"; |
| 973 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 974 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 975 | } |
| 976 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 977 | /// Sync |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 978 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 979 | { |
| 980 | if (remoteCommand.getArgument(0) == "on") { |
| 981 | |
| 982 | if (setAutoSync(true, strResult)) { |
| 983 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 984 | return CCommandHandler::EDone; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 985 | } |
| 986 | } else if (remoteCommand.getArgument(0) == "off") { |
| 987 | |
| 988 | if (setAutoSync(false, strResult)) { |
| 989 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 990 | return CCommandHandler::EDone; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 991 | } |
| 992 | } else { |
| 993 | // Show usage |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 994 | return CCommandHandler::EShowUsage; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 995 | } |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 996 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 997 | } |
| 998 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 999 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1000 | { |
| 1001 | (void)remoteCommand; |
| 1002 | |
| 1003 | strResult = autoSyncOn() ? "on" : "off"; |
| 1004 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1005 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1006 | } |
| 1007 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1008 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1009 | { |
| 1010 | (void)remoteCommand; |
| 1011 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1012 | return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1013 | } |
| 1014 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1015 | /// Criteria |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1016 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1017 | { |
| 1018 | (void)remoteCommand; |
| 1019 | |
| Kevin Rocard | 4eae827 | 2013-04-18 19:12:46 +0200 | [diff] [blame] | 1020 | bool humanReadable = true; |
| Kevin Rocard | 7f26582 | 2012-12-07 18:51:22 +0100 | [diff] [blame] | 1021 | |
| Kevin Rocard | 4eae827 | 2013-04-18 19:12:46 +0200 | [diff] [blame] | 1022 | // Look for optional arguments |
| 1023 | if (remoteCommand.getArgumentCount() >= 1) { |
| 1024 | |
| 1025 | // If csv is provided, format the criterion list in Commas Separated Value pairs |
| 1026 | if (remoteCommand.getArgument(0) == "csv") { |
| 1027 | humanReadable = false; |
| 1028 | } else { |
| 1029 | return CCommandHandler::EShowUsage; |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | list<string> lstrResult; |
| 1034 | getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable); |
| Kevin Rocard | 7f26582 | 2012-12-07 18:51:22 +0100 | [diff] [blame] | 1035 | |
| 1036 | // Concatenate the criterion list as the command result |
| Frederic Boisnard | 390b36d | 2013-05-23 15:28:31 +0200 | [diff] [blame] | 1037 | CUtility::asString(lstrResult, strResult); |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1038 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1039 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1040 | } |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1041 | |
| 1042 | /// Domains |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1043 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1044 | { |
| 1045 | (void)remoteCommand; |
| 1046 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1047 | getConfigurableDomains()->listDomains(strResult); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1048 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1049 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1050 | } |
| 1051 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1052 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1053 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1054 | return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1055 | } |
| 1056 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1057 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1058 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1059 | return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1060 | } |
| 1061 | |
| Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 1062 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1063 | { |
| 1064 | (void)remoteCommand; |
| 1065 | |
| 1066 | return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1067 | } |
| 1068 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1069 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1070 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1071 | return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1072 | } |
| 1073 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1074 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1075 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1076 | // Check tuning mode |
| 1077 | if (!checkTuningModeOn(strResult)) { |
| 1078 | |
| 1079 | return CCommandHandler::EFailed; |
| 1080 | } |
| 1081 | |
| 1082 | // Set property |
| 1083 | bool bSequenceAware; |
| 1084 | |
| 1085 | if (remoteCommand.getArgument(1) == "true") { |
| 1086 | |
| 1087 | bSequenceAware = true; |
| 1088 | |
| 1089 | } else if (remoteCommand.getArgument(1) == "false") { |
| 1090 | |
| 1091 | bSequenceAware = false; |
| 1092 | |
| 1093 | } else { |
| 1094 | // Show usage |
| 1095 | return CCommandHandler::EShowUsage; |
| 1096 | } |
| 1097 | |
| 1098 | return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1099 | } |
| 1100 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1101 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1102 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1103 | // Get property |
| 1104 | bool bSequenceAware; |
| 1105 | |
| 1106 | if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) { |
| 1107 | |
| 1108 | return CCommandHandler::EFailed; |
| 1109 | } |
| 1110 | |
| 1111 | strResult = bSequenceAware ? "true" : "false"; |
| 1112 | |
| 1113 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1114 | } |
| 1115 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1116 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1117 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1118 | return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1119 | } |
| 1120 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1121 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1122 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1123 | return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1124 | } |
| 1125 | |
| 1126 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1127 | { |
| 1128 | return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1129 | } |
| 1130 | |
| 1131 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1132 | { |
| 1133 | return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | /// Configurations |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1137 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1138 | { |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 1139 | return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
| 1140 | } |
| 1141 | |
| 1142 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1143 | { |
| 1144 | (void)remoteCommand; |
| 1145 | |
| 1146 | // Dummy error context |
| 1147 | string strError; |
| 1148 | CErrorContext errorContext(strError); |
| 1149 | |
| 1150 | // Dump |
| 1151 | getConstConfigurableDomains()->dumpContent(strResult, errorContext); |
| 1152 | |
| 1153 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1154 | } |
| 1155 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1156 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1157 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1158 | return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1159 | } |
| 1160 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1161 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1162 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1163 | return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1164 | } |
| 1165 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1166 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1167 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1168 | return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1169 | } |
| 1170 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1171 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1172 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1173 | return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1174 | } |
| 1175 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1176 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1177 | { |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1178 | list<string> lstrResult; |
| 1179 | if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) { |
| 1180 | //Concatenate the error list as the command result |
| Frederic Boisnard | 390b36d | 2013-05-23 15:28:31 +0200 | [diff] [blame] | 1181 | CUtility::asString(lstrResult, strResult); |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1182 | |
| 1183 | return CCommandHandler::EFailed; |
| 1184 | } |
| 1185 | return CCommandHandler::EDone; |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1189 | { |
| 1190 | // Check tuning mode |
| 1191 | if (!checkTuningModeOn(strResult)) { |
| 1192 | |
| 1193 | return CCommandHandler::EFailed; |
| 1194 | } |
| 1195 | |
| 1196 | // Build configurable element path list |
| Sebastien Gonzalve | d952649 | 2014-02-20 22:28:03 +0100 | [diff] [blame] | 1197 | std::vector<string> astrNewElementSequence; |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1198 | |
| 1199 | uint32_t uiArgument; |
| 1200 | |
| 1201 | for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) { |
| 1202 | |
| 1203 | astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument)); |
| 1204 | } |
| 1205 | |
| 1206 | // Delegate to configurable domains |
| 1207 | return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1208 | } |
| 1209 | |
| 1210 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1211 | { |
| 1212 | // Delegate to configurable domains |
| 1213 | return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1214 | } |
| 1215 | |
| Patrick Benavoli | 0bd5054 | 2011-11-29 11:10:27 +0100 | [diff] [blame] | 1216 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1217 | { |
| 1218 | // Delegate to configurable domains |
| 1219 | return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1220 | } |
| 1221 | |
| 1222 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1223 | { |
| 1224 | // Delegate to configurable domains |
| 1225 | return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1226 | } |
| 1227 | |
| 1228 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1229 | { |
| 1230 | // Delegate to configurable domains |
| 1231 | return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
| 1232 | } |
| 1233 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1234 | /// Elements/Parameters |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1235 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1236 | { |
| 1237 | CElementLocator elementLocator(getSystemClass(), false); |
| 1238 | |
| 1239 | CElement* pLocatedElement = NULL; |
| 1240 | |
| 1241 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1242 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1243 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | strResult = string("\n"); |
| 1247 | |
| 1248 | if (!pLocatedElement) { |
| 1249 | |
| 1250 | // List from root folder |
| 1251 | |
| 1252 | // Return system class qualified name |
| 1253 | pLocatedElement = getSystemClass(); |
| 1254 | } |
| 1255 | |
| 1256 | // Return sub-elements |
| 1257 | strResult += pLocatedElement->listQualifiedPaths(false); |
| 1258 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1259 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | /// Elements/Parameters |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1263 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1264 | { |
| 1265 | CElementLocator elementLocator(getSystemClass(), false); |
| 1266 | |
| 1267 | CElement* pLocatedElement = NULL; |
| 1268 | |
| 1269 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1270 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1271 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | strResult = string("\n"); |
| 1275 | |
| 1276 | if (!pLocatedElement) { |
| 1277 | |
| 1278 | // List from root folder |
| 1279 | |
| 1280 | // Return system class qualified name |
| 1281 | pLocatedElement = getSystemClass(); |
| 1282 | } |
| 1283 | |
| 1284 | // Return sub-elements |
| 1285 | strResult += pLocatedElement->listQualifiedPaths(true); |
| 1286 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1287 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1288 | } |
| 1289 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1290 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1291 | { |
| 1292 | CElementLocator elementLocator(getSystemClass()); |
| 1293 | |
| 1294 | CElement* pLocatedElement = NULL; |
| 1295 | |
| 1296 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1297 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1298 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | string strError; |
| 1302 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1303 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1304 | |
| 1305 | // Dump elements |
| 1306 | pLocatedElement->dumpContent(strResult, parameterAccessContext); |
| 1307 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1308 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1309 | } |
| 1310 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1311 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1312 | { |
| 1313 | CElementLocator elementLocator(getSystemClass()); |
| 1314 | |
| 1315 | CElement* pLocatedElement = NULL; |
| 1316 | |
| 1317 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1318 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1319 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1320 | } |
| 1321 | |
| 1322 | // Converted to actual sizable element |
| 1323 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1324 | |
| 1325 | // Get size as string |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1326 | strResult = pConfigurableElement->getFootprintAsString(); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1327 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1328 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1329 | } |
| 1330 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1331 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1332 | { |
| 1333 | CElementLocator elementLocator(getSystemClass()); |
| 1334 | |
| 1335 | CElement* pLocatedElement = NULL; |
| 1336 | |
| 1337 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1338 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1339 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1340 | } |
| 1341 | |
| 1342 | // Convert element |
| 1343 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1344 | |
| 1345 | // Return element properties |
| 1346 | pConfigurableElement->showProperties(strResult); |
| 1347 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1348 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1349 | } |
| 1350 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1351 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1352 | { |
| 1353 | string strValue; |
| 1354 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1355 | if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1356 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1357 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1358 | } |
| 1359 | // Succeeded |
| 1360 | strResult = strValue; |
| 1361 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1362 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1363 | } |
| 1364 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1365 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1366 | { |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1367 | // Check tuning mode |
| 1368 | if (!checkTuningModeOn(strResult)) { |
| 1369 | |
| 1370 | return CCommandHandler::EFailed; |
| 1371 | } |
| 1372 | // Get value to set |
| 1373 | string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1); |
| 1374 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1375 | return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1376 | } |
| 1377 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1378 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1379 | { |
| 1380 | CElementLocator elementLocator(getSystemClass()); |
| 1381 | |
| 1382 | CElement* pLocatedElement = NULL; |
| 1383 | |
| 1384 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1385 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1386 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1387 | } |
| 1388 | |
| 1389 | // Convert element |
| 1390 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1391 | |
| 1392 | // Return element belonging domains |
| 1393 | pConfigurableElement->listBelongingDomains(strResult); |
| 1394 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1395 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1396 | } |
| 1397 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1398 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1399 | { |
| 1400 | CElementLocator elementLocator(getSystemClass()); |
| 1401 | |
| 1402 | CElement* pLocatedElement = NULL; |
| 1403 | |
| 1404 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1405 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1406 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1407 | } |
| 1408 | |
| 1409 | // Convert element |
| 1410 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1411 | |
| 1412 | // Return element belonging domains |
| 1413 | pConfigurableElement->listAssociatedDomains(strResult); |
| 1414 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1415 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1416 | } |
| 1417 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1418 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1419 | { |
| 1420 | (void)remoteCommand; |
| 1421 | |
| 1422 | getConfigurableDomains()->listAssociatedElements(strResult); |
| 1423 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1424 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1425 | } |
| 1426 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1427 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1428 | { |
| 1429 | (void)remoteCommand; |
| 1430 | |
| 1431 | getConfigurableDomains()->listConflictingElements(strResult); |
| 1432 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1433 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1434 | } |
| 1435 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1436 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1437 | { |
| 1438 | (void)remoteCommand; |
| 1439 | |
| 1440 | getSystemClass()->listRogueElements(strResult); |
| 1441 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1442 | return CCommandHandler::ESucceeded; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1443 | } |
| 1444 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1445 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1446 | { |
| 1447 | string strOutputValue; |
| 1448 | string strError; |
| 1449 | |
| 1450 | if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) { |
| 1451 | |
| 1452 | strResult = strError; |
| 1453 | return CCommandHandler::EFailed; |
| 1454 | } |
| 1455 | // Succeeded |
| 1456 | strResult = strOutputValue; |
| 1457 | |
| 1458 | return CCommandHandler::ESucceeded; |
| 1459 | } |
| 1460 | |
| 1461 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 1462 | { |
| 1463 | // Get value to set |
| 1464 | string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3); |
| 1465 | |
| 1466 | bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0), |
| 1467 | remoteCommand.getArgument(1), |
| 1468 | remoteCommand.getArgument(2), |
| 1469 | strValue, true, strResult); |
| 1470 | |
| 1471 | return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1472 | } |
| 1473 | |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 1474 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showMappingCommmandProcess( |
| 1475 | const IRemoteCommand& remoteCommand, |
| 1476 | string& strResult) |
| 1477 | { |
| 1478 | if (!getParameterMapping(remoteCommand.getArgument(0), strResult)) { |
| 1479 | |
| 1480 | return CCommandHandler::EFailed; |
| 1481 | } |
| 1482 | |
| 1483 | return CCommandHandler::ESucceeded; |
| 1484 | } |
| 1485 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1486 | /// Settings Import/Export |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1487 | CParameterMgr::CCommandHandler::CommandStatus |
| 1488 | CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess( |
| 1489 | const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1490 | { |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1491 | string strFileName = remoteCommand.getArgument(0); |
| 1492 | return exportDomainsXml(strFileName, false, true, strResult) ? |
| 1493 | CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1494 | } |
| 1495 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1496 | CParameterMgr::CCommandHandler::CommandStatus |
| 1497 | CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess( |
| 1498 | const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1499 | { |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1500 | return importDomainsXml(remoteCommand.getArgument(0), false, true, strResult) ? |
| 1501 | CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1502 | } |
| 1503 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1504 | CParameterMgr::CCommandHandler::CommandStatus |
| 1505 | CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess( |
| 1506 | const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1507 | { |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1508 | string strFileName = remoteCommand.getArgument(0); |
| 1509 | return exportDomainsXml(strFileName, true, true, strResult) ? |
| 1510 | CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1511 | } |
| 1512 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1513 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1514 | { |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1515 | return importDomainsXml(remoteCommand.getArgument(0), true, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1516 | } |
| 1517 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1518 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1519 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1520 | return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1521 | } |
| 1522 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1523 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1524 | { |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1525 | return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1526 | } |
| 1527 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1528 | CParameterMgr::CCommandHandler::CommandStatus |
| 1529 | CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess( |
| 1530 | const IRemoteCommand& remoteCommand, string& strResult) |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1531 | { |
| 1532 | (void)remoteCommand; |
| 1533 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1534 | if (!exportDomainsXml(strResult, true, false, strResult)) { |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1535 | |
| 1536 | return CCommandHandler::EFailed; |
| 1537 | } |
| 1538 | // Succeeded |
| 1539 | return CCommandHandler::ESucceeded; |
| 1540 | } |
| 1541 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1542 | CParameterMgr::CCommandHandler::CommandStatus |
| 1543 | CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess( |
| 1544 | const IRemoteCommand& remoteCommand, string& strResult) |
| 1545 | { |
| 1546 | return importDomainsXml(remoteCommand.getArgument(0), true, false, strResult) ? |
| 1547 | CCommandHandler::EDone : CCommandHandler::EFailed; |
| 1548 | } |
| 1549 | |
| 1550 | CParameterMgr::CCommandHandler::CommandStatus |
| 1551 | CParameterMgr::getSystemClassXMLCommmandProcess( |
| 1552 | const IRemoteCommand& remoteCommand, string& strResult) |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1553 | { |
| 1554 | (void)remoteCommand; |
| 1555 | |
| 1556 | if (!getSystemClassXMLString(strResult)) { |
| 1557 | |
| 1558 | return CCommandHandler::EFailed; |
| 1559 | } |
| 1560 | // Succeeded |
| 1561 | return CCommandHandler::ESucceeded; |
| 1562 | } |
| 1563 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1564 | // User set/get parameters in main BlackBoard |
| 1565 | bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError) |
| 1566 | { |
| 1567 | // Define context |
| 1568 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
| 1569 | |
| Frédéric Boisnard | 150407c | 2013-03-15 14:46:23 +0100 | [diff] [blame] | 1570 | // Activate the auto synchronization with the hardware |
| 1571 | if (bSet) { |
| 1572 | |
| 1573 | parameterAccessContext.setAutoSync(_bAutoSyncOn); |
| 1574 | } |
| 1575 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1576 | return accessValue(parameterAccessContext, strPath, strValue, bSet, strError); |
| 1577 | } |
| 1578 | |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 1579 | // User get parameter mapping |
| 1580 | bool CParameterMgr::getParameterMapping(const string& strPath, string& strResult) const |
| 1581 | { |
| 1582 | CPathNavigator pathNavigator(strPath); |
| 1583 | |
| 1584 | // Nagivate through system class |
| 1585 | if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strResult)) { |
| 1586 | |
| 1587 | return false; |
| 1588 | } |
| 1589 | |
| 1590 | // Get the ConfigurableElement corresponding to strPath |
| 1591 | const CConfigurableElement* pConfigurableElement = getConfigurableElement(strPath, strResult); |
| 1592 | if (!pConfigurableElement) { |
| 1593 | |
| 1594 | return false; |
| 1595 | } |
| 1596 | |
| 1597 | // Find the list of the ancestors of the current ConfigurableElement that have a mapping |
| 1598 | list<const CConfigurableElement*> configurableElementPath; |
| 1599 | pConfigurableElement->getListOfElementsWithMapping(configurableElementPath); |
| 1600 | |
| 1601 | // Get the Subsystem containing the ConfigurableElement |
| 1602 | const CSubsystem* pSubsystem = pConfigurableElement->getBelongingSubsystem(); |
| 1603 | if (!pSubsystem) { |
| 1604 | |
| 1605 | strResult = "Unable to find the Subsystem containing the parameter"; |
| 1606 | return false; |
| 1607 | } |
| 1608 | |
| 1609 | // Fetch the mapping corresponding to the ConfigurableElement |
| 1610 | strResult = pSubsystem->getMapping(configurableElementPath); |
| 1611 | |
| 1612 | return true; |
| 1613 | } |
| 1614 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1615 | // User set/get parameters in specific Configuration BlackBoard |
| 1616 | bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError) |
| 1617 | { |
| 1618 | CElementLocator elementLocator(getSystemClass()); |
| 1619 | |
| 1620 | CElement* pLocatedElement = NULL; |
| 1621 | |
| 1622 | if (!elementLocator.locate(strPath, &pLocatedElement, strError)) { |
| 1623 | |
| 1624 | return false; |
| 1625 | } |
| 1626 | |
| 1627 | // Convert element |
| 1628 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1629 | |
| 1630 | // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard |
| 1631 | uint32_t uiBaseOffset; |
| 1632 | bool bIsLastApplied; |
| 1633 | |
| 1634 | CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError); |
| 1635 | |
| 1636 | if (!pConfigurationBlackboard) { |
| 1637 | |
| 1638 | return false; |
| 1639 | } |
| 1640 | |
| 1641 | log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset); |
| 1642 | |
| 1643 | /// Update the Configuration Blackboard |
| 1644 | |
| Frédéric Boisnard | 150407c | 2013-03-15 14:46:23 +0100 | [diff] [blame] | 1645 | // Define Configuration context using Base Offset and keep Auto Sync off to prevent access to HW |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1646 | CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset); |
| 1647 | |
| Frédéric Boisnard | da8298c | 2014-05-23 19:05:31 +0200 | [diff] [blame] | 1648 | // Deactivate the auto synchronization with the hardware during the Configuration Blackboard |
| 1649 | // access (only Main Blackboard shall be synchronized, Configurations Blackboards are copied |
| 1650 | // into the Main Blackboard each time a configuration is restored but they are not synchronized |
| 1651 | // directly). |
| 1652 | if (bSet) { |
| 1653 | |
| 1654 | parameterAccessContext.setAutoSync(false); |
| 1655 | } |
| 1656 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1657 | // Access Value in the Configuration Blackboard |
| 1658 | if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) { |
| 1659 | |
| 1660 | return false; |
| 1661 | } |
| 1662 | |
| 1663 | /// If the Configuration is the last one applied, update the Main Blackboard as well |
| 1664 | |
| 1665 | if (bIsLastApplied) { |
| 1666 | |
| 1667 | // Define Main context |
| 1668 | parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard); |
| 1669 | |
| Frédéric Boisnard | 150407c | 2013-03-15 14:46:23 +0100 | [diff] [blame] | 1670 | // Activate the auto synchronization with the hardware |
| 1671 | if (bSet) { |
| 1672 | |
| 1673 | parameterAccessContext.setAutoSync(_bAutoSyncOn); |
| 1674 | } |
| 1675 | |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1676 | // Access Value in the Main Blackboard |
| 1677 | return accessValue(parameterAccessContext, strPath, strValue, bSet, strError); |
| 1678 | } |
| 1679 | |
| 1680 | return true; |
| 1681 | } |
| 1682 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1683 | // User set/get parameters |
| Frédéric Boisnard | e42dacd | 2013-02-25 15:56:56 +0100 | [diff] [blame] | 1684 | bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1685 | { |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1686 | // Lock state |
| 1687 | CAutoLock autoLock(&_blackboardMutex); |
| 1688 | |
| 1689 | CPathNavigator pathNavigator(strPath); |
| 1690 | |
| 1691 | // Nagivate through system class |
| 1692 | if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1693 | |
| Frederic Boisnard | 6cae0ec | 2013-05-23 18:48:58 +0200 | [diff] [blame] | 1694 | parameterAccessContext.setError(strError); |
| 1695 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1696 | return false; |
| 1697 | } |
| 1698 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1699 | // Do the get |
| 1700 | return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1701 | } |
| 1702 | |
| 1703 | // Tuning mode |
| 1704 | bool CParameterMgr::setTuningMode(bool bOn, string& strError) |
| 1705 | { |
| 1706 | // Tuning allowed? |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 1707 | if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1708 | |
| 1709 | strError = "Tuning prohibited"; |
| 1710 | |
| 1711 | return false; |
| 1712 | } |
| 1713 | // Lock state |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 1714 | CAutoLock autoLock(&_blackboardMutex); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1715 | |
| 1716 | // Warn domains about exiting tuning mode |
| 1717 | if (!bOn && _bTuningModeIsOn) { |
| 1718 | |
| 1719 | // Ensure application of currently selected configurations |
| Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1720 | // Force-apply configurations |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 1721 | doApplyConfigurations(true); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1722 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1723 | // Turn auto sync back on |
| 1724 | _bAutoSyncOn = true; |
| 1725 | } |
| 1726 | |
| 1727 | // Store |
| 1728 | _bTuningModeIsOn = bOn; |
| 1729 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1730 | return true; |
| 1731 | } |
| 1732 | |
| 1733 | bool CParameterMgr::tuningModeOn() const |
| 1734 | { |
| 1735 | return _bTuningModeIsOn; |
| 1736 | } |
| 1737 | |
| 1738 | // Current value space for user set/get value interpretation |
| 1739 | void CParameterMgr::setValueSpace(bool bIsRaw) |
| 1740 | { |
| 1741 | _bValueSpaceIsRaw = bIsRaw; |
| 1742 | } |
| 1743 | |
| 1744 | bool CParameterMgr::valueSpaceIsRaw() |
| 1745 | { |
| 1746 | return _bValueSpaceIsRaw; |
| 1747 | } |
| 1748 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1749 | // Current Output Raw Format for user get value interpretation |
| 1750 | void CParameterMgr::setOutputRawFormat(bool bIsHex) |
| 1751 | { |
| 1752 | _bOutputRawFormatIsHex = bIsHex; |
| 1753 | } |
| 1754 | |
| 1755 | bool CParameterMgr::outputRawFormatIsHex() |
| 1756 | { |
| 1757 | return _bOutputRawFormatIsHex; |
| 1758 | } |
| 1759 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1760 | /// Sync |
| 1761 | // Automatic hardware synchronization control (during tuning session) |
| 1762 | bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError) |
| 1763 | { |
| 1764 | // Check tuning mode |
| 1765 | if (!checkTuningModeOn(strError)) { |
| 1766 | |
| 1767 | return false; |
| 1768 | } |
| 1769 | // Warn domains about turning auto sync back on |
| 1770 | if (bAutoSyncOn && !_bAutoSyncOn) { |
| 1771 | |
| Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 1772 | // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters) |
| 1773 | if (!sync(strError)) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1774 | |
| 1775 | return false; |
| 1776 | } |
| 1777 | } |
| 1778 | |
| 1779 | // Set Auto sync |
| 1780 | _bAutoSyncOn = bAutoSyncOn; |
| 1781 | |
| 1782 | return true; |
| 1783 | } |
| 1784 | |
| 1785 | bool CParameterMgr::autoSyncOn() const |
| 1786 | { |
| 1787 | return _bAutoSyncOn; |
| 1788 | } |
| 1789 | |
| 1790 | // Manual hardware synchronization control (during tuning session) |
| 1791 | bool CParameterMgr::sync(string& strError) |
| 1792 | { |
| 1793 | // Check tuning mode |
| 1794 | if (!checkTuningModeOn(strError)) { |
| 1795 | |
| 1796 | return false; |
| 1797 | } |
| 1798 | // Warn domains about turning auto sync back on |
| 1799 | if (_bAutoSyncOn) { |
| 1800 | |
| 1801 | strError = "Feature unavailable when Auto Sync is on"; |
| 1802 | |
| 1803 | return false; |
| 1804 | } |
| 1805 | |
| 1806 | // Get syncer set |
| 1807 | CSyncerSet syncerSet; |
| 1808 | // ... from system class |
| 1809 | getConstSystemClass()->fillSyncerSet(syncerSet); |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1810 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1811 | // Sync |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1812 | list<string> lstrError; |
| 1813 | if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){ |
| 1814 | |
| Frederic Boisnard | 390b36d | 2013-05-23 15:28:31 +0200 | [diff] [blame] | 1815 | CUtility::asString(lstrError, strError); |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1816 | return false; |
| 1817 | }; |
| 1818 | |
| 1819 | return true; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1820 | } |
| 1821 | |
| 1822 | // Content dump |
| 1823 | void CParameterMgr::logStructureContent(string& strContent) const |
| 1824 | { |
| 1825 | string strError; |
| 1826 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1827 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1828 | |
| 1829 | dumpContent(strContent, parameterAccessContext); |
| 1830 | } |
| 1831 | |
| 1832 | // Configuration/Domains handling |
| 1833 | bool CParameterMgr::createDomain(const string& strName, string& strError) |
| 1834 | { |
| 1835 | // Check tuning mode |
| 1836 | if (!checkTuningModeOn(strError)) { |
| 1837 | |
| 1838 | return false; |
| 1839 | } |
| 1840 | |
| 1841 | // Delegate to configurable domains |
| 1842 | return getConfigurableDomains()->createDomain(strName, strError); |
| 1843 | } |
| 1844 | |
| 1845 | bool CParameterMgr::deleteDomain(const string& strName, string& strError) |
| 1846 | { |
| 1847 | // Check tuning mode |
| 1848 | if (!checkTuningModeOn(strError)) { |
| 1849 | |
| 1850 | return false; |
| 1851 | } |
| 1852 | |
| 1853 | // Delegate to configurable domains |
| 1854 | return getConfigurableDomains()->deleteDomain(strName, strError); |
| 1855 | } |
| 1856 | |
| Kevin Rocard | 170f0a4 | 2012-06-18 13:56:05 +0200 | [diff] [blame] | 1857 | bool CParameterMgr::deleteAllDomains(string& strError) |
| 1858 | { |
| 1859 | // Check tuning mode |
| 1860 | if (!checkTuningModeOn(strError)) { |
| 1861 | |
| 1862 | return false; |
| 1863 | } |
| 1864 | |
| 1865 | // Delegate to configurable domains |
| 1866 | getConfigurableDomains()->deleteAllDomains(); |
| 1867 | |
| 1868 | return true; |
| 1869 | } |
| 1870 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1871 | bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1872 | { |
| 1873 | // Check tuning mode |
| 1874 | if (!checkTuningModeOn(strError)) { |
| 1875 | |
| 1876 | return false; |
| 1877 | } |
| 1878 | |
| 1879 | // Delegate to configurable domains |
| 1880 | return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); |
| 1881 | } |
| 1882 | |
| 1883 | bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1884 | { |
| 1885 | // Check tuning mode |
| 1886 | if (!checkTuningModeOn(strError)) { |
| 1887 | |
| 1888 | return false; |
| 1889 | } |
| 1890 | |
| 1891 | // Delegate to configurable domains |
| 1892 | return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError); |
| 1893 | } |
| 1894 | |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1895 | bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& lstrError) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1896 | { |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1897 | string strError; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1898 | // Check tuning mode |
| 1899 | if (!checkTuningModeOn(strError)) { |
| 1900 | |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1901 | lstrError.push_back(strError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1902 | return false; |
| 1903 | } |
| 1904 | |
| 1905 | // Delegate to configurable domains |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 1906 | return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, lstrError); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1907 | } |
| 1908 | |
| 1909 | bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1910 | { |
| 1911 | // Check tuning mode |
| 1912 | if (!checkTuningModeOn(strError)) { |
| 1913 | |
| 1914 | return false; |
| 1915 | } |
| 1916 | |
| 1917 | // Delegate to configurable domains |
| 1918 | return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); |
| 1919 | } |
| 1920 | |
| 1921 | // Configurable element - domain association |
| 1922 | bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1923 | { |
| 1924 | // Check tuning mode |
| 1925 | if (!checkTuningModeOn(strError)) { |
| 1926 | |
| 1927 | return false; |
| 1928 | } |
| 1929 | |
| 1930 | CElementLocator elementLocator(getSystemClass()); |
| 1931 | |
| 1932 | CElement* pLocatedElement = NULL; |
| 1933 | |
| 1934 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1935 | |
| 1936 | return false; |
| 1937 | } |
| 1938 | |
| 1939 | // Convert element |
| Pavel Chupin | 85413ff | 2012-04-24 10:55:48 +0400 | [diff] [blame] | 1940 | CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1941 | |
| 1942 | // Delegate |
| 1943 | return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError); |
| 1944 | } |
| 1945 | |
| 1946 | bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1947 | { |
| 1948 | // Check tuning mode |
| 1949 | if (!checkTuningModeOn(strError)) { |
| 1950 | |
| 1951 | return false; |
| 1952 | } |
| 1953 | |
| 1954 | CElementLocator elementLocator(getSystemClass()); |
| 1955 | |
| 1956 | CElement* pLocatedElement = NULL; |
| 1957 | |
| 1958 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1959 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1960 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1961 | } |
| 1962 | |
| 1963 | // Convert element |
| Pavel Chupin | 85413ff | 2012-04-24 10:55:48 +0400 | [diff] [blame] | 1964 | CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1965 | |
| 1966 | // Delegate |
| 1967 | return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError); |
| 1968 | } |
| 1969 | |
| 1970 | bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1971 | { |
| 1972 | // Check tuning mode |
| 1973 | if (!checkTuningModeOn(strError)) { |
| 1974 | |
| 1975 | return false; |
| 1976 | } |
| 1977 | |
| 1978 | CElementLocator elementLocator(getSystemClass()); |
| 1979 | |
| 1980 | CElement* pLocatedElement = NULL; |
| 1981 | |
| 1982 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1983 | |
| Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1984 | return CCommandHandler::EFailed; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1985 | } |
| 1986 | |
| 1987 | // Convert element |
| Pavel Chupin | 85413ff | 2012-04-24 10:55:48 +0400 | [diff] [blame] | 1988 | CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1989 | |
| 1990 | // Delegate |
| 1991 | return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError); |
| 1992 | } |
| 1993 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 1994 | bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSettings, |
| 1995 | bool bFromFile, string& strError) |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1996 | { |
| 1997 | // Check tuning mode |
| 1998 | if (!checkTuningModeOn(strError)) { |
| 1999 | |
| 2000 | return false; |
| 2001 | } |
| 2002 | |
| 2003 | // check path is absolute |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2004 | if (bFromFile && strXmlSource[0] != '/') { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2005 | |
| 2006 | strError = "Please provide absolute path"; |
| 2007 | |
| 2008 | return false; |
| 2009 | } |
| 2010 | // Root element |
| 2011 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 2012 | |
| 2013 | // Context |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2014 | CXmlDomainImportContext xmlDomainImportContext(strError, bWithSettings); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2015 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2016 | // Selection criteria definition for rule creation |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2017 | xmlDomainImportContext.setSelectionCriteriaDefinition( |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2018 | getConstSelectionCriteria()->getSelectionCriteriaDefinition()); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2019 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2020 | // Init serializing context |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2021 | xmlDomainImportContext.set( |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2022 | _pElementLibrarySet->getElementLibrary(EParameterConfigurationLibrary), |
| 2023 | "", _strSchemaFolderLocation); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2024 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2025 | // Get Schema file associated to root element |
| 2026 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + |
| 2027 | pConfigurableDomains->getKind() + ".xsd"; |
| 2028 | |
| 2029 | // Xml Source |
| 2030 | CXmlDocSource* pSource; |
| 2031 | |
| 2032 | if (bFromFile) { |
| 2033 | |
| 2034 | // when importing from a file strXmlSource is the file name |
| 2035 | pSource = new CXmlFileDocSource(strXmlSource, strXmlSchemaFilePath, |
| 2036 | pConfigurableDomains->getKind(), |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 2037 | pConfigurableDomains->getName(), "SystemClassName", |
| 2038 | _bValidateSchemasOnStart); |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2039 | |
| 2040 | } else { |
| 2041 | |
| 2042 | // when importing from an xml string, strXmlSource contains the string |
| 2043 | pSource = new CXmlStringDocSource(strXmlSource, strXmlSchemaFilePath, |
| 2044 | pConfigurableDomains->getKind(), |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 2045 | pConfigurableDomains->getName(), "SystemClassName", |
| 2046 | _bValidateSchemasOnStart); |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2047 | |
| 2048 | } |
| 2049 | // Start clean |
| 2050 | pConfigurableDomains->clean(); |
| 2051 | |
| 2052 | // Use a doc sink that instantiate Configurable Domains from the given doc source |
| 2053 | CXmlMemoryDocSink memorySink(pConfigurableDomains); |
| 2054 | |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2055 | bool bProcessSuccess = memorySink.process(*pSource, xmlDomainImportContext); |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2056 | |
| 2057 | if (!bProcessSuccess) { |
| 2058 | |
| 2059 | //Cleanup |
| 2060 | pConfigurableDomains->clean(); |
| 2061 | |
| 2062 | } else { |
| 2063 | |
| 2064 | // Validate domains after XML import |
| 2065 | pConfigurableDomains->validate(_pMainParameterBlackboard); |
| 2066 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2067 | } |
| 2068 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2069 | delete pSource; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2070 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2071 | return bProcessSuccess; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2072 | } |
| 2073 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2074 | bool CParameterMgr::exportDomainsXml(string& strXmlDest, bool bWithSettings, bool bToFile, |
| 2075 | string& strError) const |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2076 | { |
| 2077 | // check path is absolute |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2078 | if (bToFile && strXmlDest[0] != '/') { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2079 | |
| 2080 | strError = "Please provide absolute path"; |
| 2081 | |
| 2082 | return false; |
| 2083 | } |
| 2084 | |
| 2085 | // Root element |
| 2086 | const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); |
| 2087 | |
| 2088 | // Get Schema file associated to root element |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2089 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + |
| 2090 | pConfigurableDomains->getKind() + ".xsd"; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2091 | |
| 2092 | // Context |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2093 | CXmlDomainExportContext xmlDomainExportContext(strError, bWithSettings); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2094 | |
| 2095 | // Value space |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2096 | xmlDomainExportContext.setValueSpaceRaw(_bValueSpaceIsRaw); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2097 | |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 2098 | // Output raw format |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2099 | xmlDomainExportContext.setOutputRawFormat(_bOutputRawFormatIsHex); |
| Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 2100 | |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2101 | // Use a doc source by loading data from instantiated Configurable Domains |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2102 | CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(), |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 2103 | strXmlSchemaFilePath, "parameter-framework", |
| 2104 | getVersion(), _bValidateSchemasOnStart); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2105 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2106 | // Xml Sink |
| 2107 | CXmlDocSink* pSink; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2108 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2109 | if (bToFile) { |
| 2110 | |
| 2111 | // Use a doc sink to write the doc data in a file |
| 2112 | pSink = new CXmlFileDocSink(strXmlDest); |
| 2113 | |
| 2114 | } else { |
| 2115 | |
| 2116 | // Use a doc sink to write the doc data in a string |
| 2117 | pSink = new CXmlStringDocSink(strXmlDest); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2118 | } |
| 2119 | |
| David Wagner | 29fa61f | 2014-12-19 11:15:02 +0100 | [diff] [blame^] | 2120 | bool bProcessSuccess = pSink->process(memorySource, xmlDomainExportContext); |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2121 | |
| 2122 | delete pSink; |
| 2123 | return bProcessSuccess; |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2124 | } |
| 2125 | |
| 2126 | // Binary Import/Export |
| 2127 | bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError) |
| 2128 | { |
| 2129 | // Check tuning mode |
| 2130 | if (!checkTuningModeOn(strError)) { |
| 2131 | |
| 2132 | return false; |
| 2133 | } |
| 2134 | // check path is absolute |
| 2135 | if (strFileName[0] != '/') { |
| 2136 | |
| 2137 | strError = "Please provide absolute path"; |
| 2138 | |
| 2139 | return false; |
| 2140 | } |
| 2141 | // Root element |
| 2142 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 2143 | |
| 2144 | // Serialize in |
| 2145 | return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError); |
| 2146 | } |
| 2147 | |
| 2148 | bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError) |
| 2149 | { |
| 2150 | // check path is absolute |
| 2151 | if (strFileName[0] != '/') { |
| 2152 | |
| 2153 | strError = "Please provide absolute path"; |
| 2154 | |
| 2155 | return false; |
| 2156 | } |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2157 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2158 | // Root element |
| 2159 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 2160 | |
| 2161 | // Serialize out |
| 2162 | return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError); |
| 2163 | } |
| 2164 | |
| 2165 | // For tuning, check we're in tuning mode |
| 2166 | bool CParameterMgr::checkTuningModeOn(string& strError) const |
| 2167 | { |
| 2168 | // Tuning Mode on? |
| 2169 | if (!_bTuningModeIsOn) { |
| 2170 | |
| 2171 | strError = "Tuning Mode must be on"; |
| 2172 | |
| 2173 | return false; |
| 2174 | } |
| 2175 | return true; |
| 2176 | } |
| 2177 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 2178 | // Tuning mutex dynamic parameter handling |
| 2179 | pthread_mutex_t* CParameterMgr::getBlackboardMutex() |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 2180 | { |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 2181 | return &_blackboardMutex; |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 2182 | } |
| 2183 | |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 2184 | // Blackboard reference (dynamic parameter handling) |
| 2185 | CParameterBlackboard* CParameterMgr::getParameterBlackboard() |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 2186 | { |
| Patrick Benavoli | 065264a | 2011-11-20 15:46:41 +0100 | [diff] [blame] | 2187 | return _pMainParameterBlackboard; |
| Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 2188 | } |
| 2189 | |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2190 | // Dynamic creation library feeding |
| 2191 | void CParameterMgr::feedElementLibraries() |
| 2192 | { |
| 2193 | // Global Configuration handling |
| 2194 | CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary; |
| 2195 | |
| Kevin Rocard | a7b6960 | 2013-08-07 16:15:33 +0200 | [diff] [blame] | 2196 | pFrameworkConfigurationLibrary->addElementBuilder("ParameterFrameworkConfiguration", new TElementBuilderTemplate<CParameterFrameworkConfiguration>()); |
| 2197 | pFrameworkConfigurationLibrary->addElementBuilder("SubsystemPlugins", new TKindElementBuilderTemplate<CSubsystemPlugins>()); |
| 2198 | pFrameworkConfigurationLibrary->addElementBuilder("Location", new TKindElementBuilderTemplate<CPluginLocation>()); |
| 2199 | pFrameworkConfigurationLibrary->addElementBuilder("StructureDescriptionFileLocation", new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>()); |
| 2200 | pFrameworkConfigurationLibrary->addElementBuilder("SettingsConfiguration", new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>()); |
| 2201 | pFrameworkConfigurationLibrary->addElementBuilder("ConfigurableDomainsFileLocation", new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>()); |
| 2202 | pFrameworkConfigurationLibrary->addElementBuilder("BinarySettingsFileLocation", new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>()); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2203 | |
| 2204 | _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary); |
| 2205 | |
| 2206 | // Parameter creation |
| 2207 | CElementLibrary* pParameterCreationLibrary = new CElementLibrary; |
| 2208 | |
| Kevin Rocard | a7b6960 | 2013-08-07 16:15:33 +0200 | [diff] [blame] | 2209 | pParameterCreationLibrary->addElementBuilder("Subsystem", new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary())); |
| 2210 | pParameterCreationLibrary->addElementBuilder("ComponentType", new TNamedElementBuilderTemplate<CComponentType>()); |
| 2211 | pParameterCreationLibrary->addElementBuilder("Component", new TNamedElementBuilderTemplate<CComponentInstance>()); |
| 2212 | pParameterCreationLibrary->addElementBuilder("BitParameter", new TNamedElementBuilderTemplate<CBitParameterType>()); |
| 2213 | pParameterCreationLibrary->addElementBuilder("BitParameterBlock", new TNamedElementBuilderTemplate<CBitParameterBlockType>()); |
| 2214 | pParameterCreationLibrary->addElementBuilder("StringParameter", new TNamedElementBuilderTemplate<CStringParameterType>()); |
| 2215 | pParameterCreationLibrary->addElementBuilder("ParameterBlock", new TNamedElementBuilderTemplate<CParameterBlockType>()); |
| 2216 | pParameterCreationLibrary->addElementBuilder("BooleanParameter", new TNamedElementBuilderTemplate<CBooleanParameterType>()); |
| 2217 | pParameterCreationLibrary->addElementBuilder("IntegerParameter", new TNamedElementBuilderTemplate<CIntegerParameterType>()); |
| 2218 | pParameterCreationLibrary->addElementBuilder("LinearAdaptation", new TElementBuilderTemplate<CLinearParameterAdaptation>()); |
| 2219 | pParameterCreationLibrary->addElementBuilder("EnumParameter", new TNamedElementBuilderTemplate<CEnumParameterType>()); |
| 2220 | pParameterCreationLibrary->addElementBuilder("ValuePair", new TElementBuilderTemplate<CEnumValuePair>()); |
| 2221 | pParameterCreationLibrary->addElementBuilder("FixedPointParameter", new TNamedElementBuilderTemplate<CFixedPointParameterType>()); |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 2222 | pParameterCreationLibrary->addElementBuilder("SubsystemInclude", new CFileIncluderElementBuilder(_bValidateSchemasOnStart)); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2223 | |
| 2224 | _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary); |
| 2225 | |
| 2226 | // Parameter Configuration Domains creation |
| 2227 | CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary; |
| 2228 | |
| Kevin Rocard | a7b6960 | 2013-08-07 16:15:33 +0200 | [diff] [blame] | 2229 | pParameterConfigurationLibrary->addElementBuilder("ConfigurableDomain", new TNamedElementBuilderTemplate<CConfigurableDomain>()); |
| 2230 | pParameterConfigurationLibrary->addElementBuilder("Configuration", new TNamedElementBuilderTemplate<CDomainConfiguration>()); |
| 2231 | pParameterConfigurationLibrary->addElementBuilder("CompoundRule", new TElementBuilderTemplate<CCompoundRule>()); |
| 2232 | pParameterConfigurationLibrary->addElementBuilder("SelectionCriterionRule", new TElementBuilderTemplate<CSelectionCriterionRule>()); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2233 | |
| 2234 | _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary); |
| 2235 | } |
| 2236 | |
| 2237 | // Remote Processor Server connection handling |
| 2238 | bool CParameterMgr::handleRemoteProcessingInterface(string& strError) |
| 2239 | { |
| 2240 | CAutoLog autoLog(this, "Handling remote processing interface"); |
| 2241 | |
| 2242 | // Start server if tuning allowed |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 2243 | if (getConstFrameworkConfiguration()->isTuningAllowed()) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2244 | |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 2245 | log_info("Loading remote processor library"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2246 | |
| 2247 | // Load library |
| Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 2248 | _handleLibRemoteProcessor = dlopen("libremote-processor.so", RTLD_NOW); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2249 | |
| Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 2250 | if (!_handleLibRemoteProcessor) { |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2251 | |
| 2252 | // Return error |
| 2253 | const char* pcError = dlerror(); |
| 2254 | |
| 2255 | if (pcError) { |
| 2256 | |
| 2257 | strError = pcError; |
| 2258 | } else { |
| 2259 | |
| 2260 | strError = "Unable to load libremote-processor.so library"; |
| 2261 | } |
| 2262 | |
| 2263 | return false; |
| 2264 | } |
| 2265 | |
| Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 2266 | CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(_handleLibRemoteProcessor, "createRemoteProcessorServer"); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2267 | |
| 2268 | if (!pfnCreateRemoteProcessorServer) { |
| 2269 | |
| 2270 | strError = "libremote-process.so does not contain createRemoteProcessorServer symbol."; |
| 2271 | |
| 2272 | return false; |
| 2273 | } |
| 2274 | |
| 2275 | // Create server |
| Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 2276 | _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2277 | |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 2278 | log_info("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort()); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2279 | // Start |
| 2280 | if (!_pRemoteProcessorServer->start()) { |
| 2281 | |
| Frédéric Boisnard | 6c55e9a | 2014-01-10 18:46:33 +0100 | [diff] [blame] | 2282 | ostringstream oss; |
| 2283 | oss << "ParameterMgr: Unable to start remote processor server on port " |
| 2284 | << getConstFrameworkConfiguration()->getServerPort(); |
| 2285 | strError = oss.str(); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2286 | |
| 2287 | return false; |
| 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | return true; |
| 2292 | } |
| 2293 | |
| 2294 | // Back synchronization |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 2295 | CBackSynchronizer* CParameterMgr::createBackSynchronizer() const |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2296 | { |
| 2297 | #ifdef SIMULATION |
| 2298 | // In simulation, back synchronization of the blackboard won't probably work |
| 2299 | // We need to ensure though the blackboard is initialized with valid data |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 2300 | return new CSimulatedBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2301 | #else |
| 2302 | // Real back synchronizer from subsystems |
| Kevin Rocard | ace81f8 | 2012-12-11 16:19:17 +0100 | [diff] [blame] | 2303 | return new CHardwareBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard); |
| Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 2304 | #endif |
| 2305 | } |
| 2306 | |
| 2307 | // Children typwise access |
| 2308 | CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration() |
| 2309 | { |
| 2310 | return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration)); |
| 2311 | } |
| 2312 | |
| 2313 | const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration() |
| 2314 | { |
| 2315 | return getFrameworkConfiguration(); |
| 2316 | } |
| 2317 | |
| 2318 | CSelectionCriteria* CParameterMgr::getSelectionCriteria() |
| 2319 | { |
| 2320 | return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria)); |
| 2321 | } |
| 2322 | |
| 2323 | const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria() |
| 2324 | { |
| 2325 | return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria)); |
| 2326 | } |
| 2327 | |
| 2328 | CSystemClass* CParameterMgr::getSystemClass() |
| 2329 | { |
| 2330 | return static_cast<CSystemClass*>(getChild(ESystemClass)); |
| 2331 | } |
| 2332 | |
| 2333 | const CSystemClass* CParameterMgr::getConstSystemClass() const |
| 2334 | { |
| 2335 | return static_cast<const CSystemClass*>(getChild(ESystemClass)); |
| 2336 | } |
| 2337 | |
| 2338 | // Configurable Domains |
| 2339 | CConfigurableDomains* CParameterMgr::getConfigurableDomains() |
| 2340 | { |
| 2341 | return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 2342 | } |
| 2343 | |
| 2344 | const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() |
| 2345 | { |
| 2346 | return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 2347 | } |
| 2348 | |
| 2349 | const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const |
| 2350 | { |
| 2351 | return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 2352 | } |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2353 | |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 2354 | // Apply configurations |
| 2355 | void CParameterMgr::doApplyConfigurations(bool bForce) |
| 2356 | { |
| 2357 | CSyncerSet syncerSet; |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2358 | |
| Guillaume Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 2359 | // Check subsystems that need resync |
| 2360 | getSystemClass()->checkForSubsystemsToResync(syncerSet); |
| 2361 | |
| 2362 | // Ensure application of currently selected configurations |
| 2363 | getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce); |
| 2364 | |
| 2365 | // Reset the modified status of the current criteria to indicate that a new configuration has been applied |
| 2366 | getSelectionCriteria()->resetModifiedStatus(); |
| 2367 | } |
| 2368 | |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2369 | bool CParameterMgr::getSystemClassXMLString(string& strResult) |
| 2370 | { |
| 2371 | // Root element |
| 2372 | const CSystemClass* pSystemClass = getSystemClass(); |
| 2373 | |
| 2374 | string strError; |
| 2375 | |
| 2376 | CXmlSerializingContext xmlSerializingContext(strError); |
| 2377 | |
| 2378 | // Use a doc source by loading data from instantiated Configurable Domains |
| Mattijs Korpershoek | cce85f6 | 2014-04-08 14:10:03 +0200 | [diff] [blame] | 2379 | CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind(), |
| 2380 | _bValidateSchemasOnStart); |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2381 | |
| 2382 | // Use a doc sink that write the doc data in a string |
| 2383 | CXmlStringDocSink stringSink(strResult); |
| 2384 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2385 | bool bProcessSuccess = stringSink.process(memorySource, xmlSerializingContext); |
| 2386 | |
| 2387 | if (!bProcessSuccess) { |
| 2388 | |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2389 | strResult = strError; |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2390 | |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2391 | } |
| 2392 | |
| Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame] | 2393 | return bProcessSuccess; |
| Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 2394 | } |