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