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