Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1 | /* <auto_header> |
| 2 | * <FILENAME> |
| 3 | * |
| 4 | * INTEL CONFIDENTIAL |
| 5 | * Copyright © 2011 Intel |
| 6 | * Corporation All Rights Reserved. |
| 7 | * |
| 8 | * The source code contained or described herein and all documents related to |
| 9 | * the source code ("Material") are owned by Intel Corporation or its suppliers |
| 10 | * or licensors. Title to the Material remains with Intel Corporation or its |
| 11 | * suppliers and licensors. The Material contains trade secrets and proprietary |
| 12 | * and confidential information of Intel or its suppliers and licensors. The |
| 13 | * Material is protected by worldwide copyright and trade secret laws and |
| 14 | * treaty provisions. No part of the Material may be used, copied, reproduced, |
| 15 | * modified, published, uploaded, posted, transmitted, distributed, or |
| 16 | * disclosed in any way without Intel’s prior express written permission. |
| 17 | * |
| 18 | * No license under any patent, copyright, trade secret or other intellectual |
| 19 | * property right is granted to or conferred upon you by disclosure or delivery |
| 20 | * of the Materials, either expressly, by implication, inducement, estoppel or |
| 21 | * otherwise. Any license under such intellectual property rights must be |
| 22 | * express and approved by Intel in writing. |
| 23 | * |
| 24 | * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com) |
| 25 | * CREATED: 2011-06-01 |
| 26 | * UPDATED: 2011-07-27 |
| 27 | * |
| 28 | * |
| 29 | * </auto_header> |
| 30 | */ |
| 31 | #include "ParameterMgr.h" |
| 32 | #include "XmlParser.h" |
| 33 | #include "XmlParameterSerializingContext.h" |
| 34 | #include "XmlElementSerializingContext.h" |
| 35 | #include "SystemClass.h" |
| 36 | #include "ElementLibrarySet.h" |
| 37 | #include "SubsystemLibrary.h" |
| 38 | #include "NamedElementBuilderTemplate.h" |
| 39 | #include "KindElementBuilderTemplate.h" |
| 40 | #include "ElementBuilderTemplate.h" |
| 41 | #include "SelectionCriterionType.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 42 | #include "SubsystemElementBuilder.h" |
| 43 | #include "SelectionCriteria.h" |
| 44 | #include "ComponentType.h" |
| 45 | #include "ComponentInstance.h" |
| 46 | #include "ParameterBlockType.h" |
| 47 | #include "BooleanParameterType.h" |
| 48 | #include "IntegerParameterType.h" |
| 49 | #include "FixedPointParameterType.h" |
| 50 | #include "ParameterBlackboard.h" |
| 51 | #include "Parameter.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 52 | #include "ParameterBlackboard.h" |
| 53 | #include "ParameterAccessContext.h" |
| 54 | #include "XmlFileIncluderElement.h" |
| 55 | #include "ParameterFrameworkConfiguration.h" |
| 56 | #include "FrameworkConfigurationGroup.h" |
| 57 | #include "FrameworkConfigurationLocation.h" |
| 58 | #include "SystemClassConfiguration.h" |
| 59 | #include "ConfigurableDomains.h" |
| 60 | #include "ConfigurableDomain.h" |
| 61 | #include "DomainConfiguration.h" |
| 62 | #include "XmlComposer.h" |
| 63 | #include "XmlDomainSerializingContext.h" |
| 64 | #include "BitParameterBlockType.h" |
| 65 | #include "BitParameterType.h" |
Patrick Benavoli | 1352ae5 | 2011-10-21 16:48:04 +0200 | [diff] [blame] | 66 | #include "StringParameterType.h" |
Patrick Benavoli | 9fc3c0d | 2011-10-27 14:27:27 +0200 | [diff] [blame] | 67 | #include "EnumParameterType.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 68 | #include "RemoteProcessorServerInterface.h" |
| 69 | #include "ElementLocator.h" |
| 70 | #include "AutoLog.h" |
| 71 | #include "CompoundRule.h" |
| 72 | #include "SelectionCriterionRule.h" |
| 73 | #include "SimulatedBackSynchronizer.h" |
| 74 | #include "HardwareBackSynchronizer.h" |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 75 | #include "AutoLock.h" |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 76 | #include <strings.h> |
| 77 | #include <dlfcn.h> |
| 78 | #include <assert.h> |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 79 | |
| 80 | #define base CElement |
| 81 | |
| 82 | // Used for remote processor server creation |
| 83 | typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler); |
| 84 | |
| 85 | // Global configuration file name (fixed) |
| 86 | const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml"; |
| 87 | const char* gacSystemSchemasSubFolder = "Schemas"; |
| 88 | |
| 89 | // Config File System looks normally like this: |
| 90 | // --------------------------------------------- |
| 91 | //├── ParameterFrameworkConfiguration.xml |
| 92 | //├── Schemas |
| 93 | //│ └── *.xsd |
| 94 | //├── Settings |
| 95 | //│ └── <SystemClassName folder>* |
| 96 | //│ ├── <ConfigurableDomains>.xml |
| 97 | //│ └── <Settings>.bin? |
| 98 | //└── Structure |
| 99 | // └── <SystemClassName folder>* |
| 100 | // ├── <SystemClassName>Class.xml |
| 101 | // └── <Subsystem>.xml* |
| 102 | // -------------------------------------------- |
| 103 | |
| 104 | |
| 105 | // Remote command parser array |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 106 | const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = { |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 107 | /// Version |
| 108 | { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 109 | /// Status |
| 110 | { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" }, |
| 111 | /// Tuning Mode |
| 112 | { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" }, |
| 113 | { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" }, |
| 114 | /// Value Space |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 115 | { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 116 | { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" }, |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 117 | /// Output Raw Format |
| 118 | { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" }, |
| 119 | { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 120 | /// Sync |
| 121 | { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" }, |
| 122 | { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" }, |
| 123 | { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" }, |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 124 | /// Criteria |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 125 | { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 126 | /// Domains |
| 127 | { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" }, |
| 128 | { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" }, |
| 129 | { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" }, |
| 130 | { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" }, |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 131 | { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" }, |
| 132 | { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 133 | { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" }, |
| 134 | { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" }, |
| 135 | { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" }, |
| 136 | { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" }, |
| 137 | /// Configurations |
| 138 | { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" }, |
| 139 | { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" }, |
| 140 | { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" }, |
| 141 | { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" }, |
| 142 | { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" }, |
| 143 | { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" }, |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 144 | { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 2, "<domain> <configuration> <elem path list>", "Set element application order for configuration" }, |
| 145 | { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 146 | /// Elements/Parameters |
| 147 | { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" }, |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 148 | { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 149 | { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" }, |
| 150 | { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" }, |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 151 | { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" }, |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 152 | { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" }, |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 153 | { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" }, |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 154 | { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" }, |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 155 | { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" }, |
| 156 | /// Browse |
| 157 | { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" }, |
| 158 | { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" }, |
| 159 | { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" }, |
| 160 | /// Settings Import/Export |
| 161 | { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" }, |
| 162 | { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" }, |
| 163 | { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" }, |
| 164 | { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" }, |
| 165 | { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" }, |
| 166 | { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" } |
| 167 | }; |
| 168 | // Remote command parsers array Size |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 169 | const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 170 | |
| 171 | CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName) : |
| 172 | _bTuningModeIsOn(false), |
| 173 | _bValueSpaceIsRaw(false), |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 174 | _bOutputRawFormatIsHex(false), |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 175 | _bAutoSyncOn(true), |
| 176 | _pMainParameterBlackboard(new CParameterBlackboard), |
| 177 | _pElementLibrarySet(new CElementLibrarySet), |
| 178 | _strParameterFrameworkConfigurationFolderPath(strParameterFrameworkConfigurationFolderPath), |
| 179 | _strSchemaFolderLocation(strParameterFrameworkConfigurationFolderPath + "/" + gacSystemSchemasSubFolder), |
| 180 | _pSystemClassConfiguration(NULL), |
| 181 | _uiStructureChecksum(0), |
| 182 | _pRemoteProcessorServer(NULL), |
| 183 | _uiMaxCommandUsageLength(0), |
| 184 | _pLogger(NULL), |
| 185 | _uiLogDepth(0) |
| 186 | { |
| 187 | // Tuning Mode Mutex |
| 188 | bzero(&_tuningModeMutex, sizeof(_tuningModeMutex)); |
| 189 | pthread_mutex_init(&_tuningModeMutex, NULL); |
| 190 | |
| 191 | // Deal with children |
| 192 | addChild(new CParameterFrameworkConfiguration); |
| 193 | addChild(new CSelectionCriteria); |
| 194 | addChild(new CSystemClass(strSystemClassName)); |
| 195 | addChild(new CConfigurableDomains(strSystemClassName)); |
| 196 | |
| 197 | // Feed element library |
| 198 | feedElementLibraries(); |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 199 | |
| 200 | _pCommandHandler = new CCommandHandler(this); |
| 201 | |
| 202 | // Add command parsers |
| 203 | uint32_t uiRemoteCommandParserItem; |
| 204 | |
| 205 | for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) { |
| 206 | |
| 207 | const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem]; |
| 208 | |
| 209 | _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName, |
| 210 | pRemoteCommandParserItem->_pfnParser, |
| 211 | pRemoteCommandParserItem->_uiMinArgumentCount, |
| 212 | pRemoteCommandParserItem->_pcHelp, |
| 213 | pRemoteCommandParserItem->_pcDescription); |
| 214 | } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | CParameterMgr::~CParameterMgr() |
| 218 | { |
| 219 | // Children |
| 220 | delete _pRemoteProcessorServer; |
| 221 | delete _pMainParameterBlackboard; |
| 222 | delete _pElementLibrarySet; |
| 223 | |
| 224 | // Tuning Mode Mutex |
| 225 | pthread_mutex_destroy(&_tuningModeMutex); |
| 226 | } |
| 227 | |
| 228 | string CParameterMgr::getKind() const |
| 229 | { |
| 230 | return "ParameterMgr"; |
| 231 | } |
| 232 | |
| 233 | // Logging |
| 234 | void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger) |
| 235 | { |
| 236 | _pLogger = pLogger; |
| 237 | } |
| 238 | |
| 239 | // Logging |
| 240 | void CParameterMgr::doLog(const string& strLog) const |
| 241 | { |
| 242 | if (_pLogger) { |
| 243 | |
| 244 | // Nest |
| 245 | string strIndent; |
| 246 | |
| 247 | // Level |
| 248 | uint32_t uiNbIndents = _uiLogDepth; |
| 249 | |
| 250 | while (uiNbIndents--) { |
| 251 | |
| 252 | strIndent += " "; |
| 253 | } |
| 254 | |
| 255 | // Log |
| 256 | _pLogger->log(strIndent + strLog); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | void CParameterMgr::nestLog() const |
| 261 | { |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 262 | _uiLogDepth++; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | void CParameterMgr::unnestLog() const |
| 266 | { |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 267 | _uiLogDepth--; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 268 | } |
| 269 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 270 | // Version |
| 271 | string CParameterMgr::getVersion() const |
| 272 | { |
| 273 | string strVersion; |
| 274 | |
| 275 | // Major |
| 276 | strVersion = toString(guiEditionMajor) + "."; |
| 277 | // Minor |
| 278 | strVersion += toString(guiEditionMinor) + "."; |
| 279 | // Revision |
| 280 | strVersion += toString(guiRevision); |
| 281 | |
| 282 | return strVersion; |
| 283 | } |
| 284 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 285 | bool CParameterMgr::load(string& strError) |
| 286 | { |
| 287 | CAutoLog autoLog(this, "Loading"); |
| 288 | |
| 289 | // Load Framework configuration |
| 290 | if (!loadFrameworkConfiguration(strError)) { |
| 291 | |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | // Load subsystems |
| 296 | if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) { |
| 297 | |
| 298 | return false; |
| 299 | } |
| 300 | |
| 301 | // Load structure |
| 302 | if (!loadStructure(strError)) { |
| 303 | |
| 304 | return false; |
| 305 | } |
| 306 | |
| 307 | // Load settings |
| 308 | if (!loadSettings(strError)) { |
| 309 | |
| 310 | return false; |
| 311 | } |
| 312 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 313 | // Back synchronization for areas in parameter blackboard not covered by any domain |
| 314 | CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 315 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 316 | log("Main blackboard back synchronization"); |
| 317 | |
| 318 | // Back-synchronize |
| 319 | if (!pBackSynchronizer->sync()) { |
| 320 | // Get rid of back synchronizer |
| 321 | delete pBackSynchronizer; |
| 322 | |
| 323 | strError = "Main blackboard back synchronization failed: " + strError; |
| 324 | |
| 325 | return false; |
| 326 | } |
| 327 | // Get rif of back synchronizer |
| 328 | delete pBackSynchronizer; |
| 329 | |
| 330 | // We're done loading the settings and back synchronizing |
| 331 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 332 | |
| 333 | // We need to ensure all domains are valid |
| 334 | pConfigurableDomains->validate(_pMainParameterBlackboard); |
| 335 | |
| 336 | // Ensure application of currently selected configurations |
| 337 | // Force-apply configurations |
| 338 | if (!pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 339 | |
| 340 | return false; |
| 341 | } |
| 342 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 343 | // Start remote processor server if appropriate |
| 344 | return handleRemoteProcessingInterface(strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | bool CParameterMgr::loadFrameworkConfiguration(string& strError) |
| 348 | { |
| 349 | CAutoLog autoLog(this, "Loading framework configuration"); |
| 350 | |
| 351 | // Get Xml config file name |
| 352 | string strXmlConfigurationFilePath = _strParameterFrameworkConfigurationFolderPath + "/" + gacParameterFrameworkConfigurationFileName; |
| 353 | |
| 354 | // Parse Structure XML file |
| 355 | CXmlElementSerializingContext elementSerializingContext(strError); |
| 356 | |
| 357 | if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), strXmlConfigurationFilePath, _strParameterFrameworkConfigurationFolderPath, EFrameworkConfigurationLibrary)) { |
| 358 | |
| 359 | return false; |
| 360 | } |
| 361 | // Get subsystem plugins folders element |
| 362 | const CFrameworkConfigurationGroup* pSubsystemPluginFolders= static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders")); |
| 363 | |
| 364 | if (!pSubsystemPluginFolders) { |
| 365 | |
| 366 | strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element"; |
| 367 | |
| 368 | return false; |
| 369 | } |
| 370 | // Get plugin locations |
| 371 | uint32_t uiPluginFolderLocation; |
| 372 | uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren(); |
| 373 | |
| 374 | if (!uiNbPluginFolderLocations) { |
| 375 | |
| 376 | strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element"; |
| 377 | |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) { |
| 382 | |
| 383 | const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation)); |
| 384 | |
| 385 | _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath)); |
| 386 | } |
| 387 | |
| 388 | // Get configuration for current system class |
| 389 | const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("ParameterConfiguration")); |
| 390 | |
| 391 | if (!pParameterConfigurationGroup) { |
| 392 | |
| 393 | strError = "Parameter Framework Configuration: couldn't find ParameterConfiguration element"; |
| 394 | |
| 395 | return false; |
| 396 | } |
| 397 | _pSystemClassConfiguration = static_cast<const CSystemClassConfiguration*>(pParameterConfigurationGroup->findChild(getSystemClass()->getName())); |
| 398 | |
| 399 | if (!_pSystemClassConfiguration) { |
| 400 | |
| 401 | strError = "No framework configuration found for SystemClass " + getSystemClass()->getName(); |
| 402 | |
| 403 | return false; |
| 404 | } |
| 405 | // Log tuning availability |
| 406 | log("Tuning %s", _pSystemClassConfiguration->isTuningAllowed() ? "allowed" : "prohibited"); |
| 407 | |
| 408 | return true; |
| 409 | } |
| 410 | |
| 411 | bool CParameterMgr::loadStructure(string& strError) |
| 412 | { |
| 413 | // Retrieve system to load structure to |
| 414 | CSystemClass* pSystemClass = getSystemClass(); |
| 415 | |
| 416 | CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure"); |
| 417 | |
| 418 | // Get structure description element |
| 419 | const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(_pSystemClassConfiguration->findChildOfKind("StructureDescriptionFileLocation")); |
| 420 | |
| 421 | if (!pStructureDescriptionFileLocation) { |
| 422 | |
| 423 | strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName(); |
| 424 | |
| 425 | return false; |
| 426 | } |
| 427 | |
| 428 | // Get Xml structure folder |
| 429 | string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath); |
| 430 | |
| 431 | // Get Xml structure file name |
| 432 | string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath); |
| 433 | |
| 434 | // Parse Structure XML file |
| 435 | CXmlParameterSerializingContext parameterBuildContext(strError); |
| 436 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 437 | log("Importing system structure from file %s", strXmlStructureFilePath.c_str()); |
| 438 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 439 | if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) { |
| 440 | |
| 441 | return false; |
| 442 | } |
| 443 | |
| 444 | // Initialize offsets |
| 445 | pSystemClass->setOffset(0); |
| 446 | |
| 447 | // Initialize main blackboard's size |
| 448 | _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint()); |
| 449 | |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | bool CParameterMgr::loadSettings(string& strError) |
| 454 | { |
| 455 | CAutoLog autoLog(this, "Loading settings"); |
| 456 | |
| 457 | // Get settings configuration element |
| 458 | const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(_pSystemClassConfiguration->findChildOfKind("SettingsConfiguration")); |
| 459 | |
| 460 | if (!pParameterConfigurationGroup) { |
| 461 | |
| 462 | // No settings to load |
| 463 | |
| 464 | return true; |
| 465 | } |
| 466 | // Get binary settings file location |
| 467 | const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation")); |
| 468 | |
| 469 | string strXmlBinarySettingsFilePath; |
| 470 | |
| 471 | if (pBinarySettingsFileLocation) { |
| 472 | |
| 473 | // Get Xml binary settings file name |
| 474 | strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath); |
| 475 | } |
| 476 | |
| 477 | // Get configurable domains element |
| 478 | const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation")); |
| 479 | |
| 480 | if (!pConfigurableDomainsFileLocation) { |
| 481 | |
| 482 | strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName(); |
| 483 | |
| 484 | return false; |
| 485 | } |
| 486 | // Get destination root element |
| 487 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 488 | |
| 489 | // Get Xml configuration domains file name |
| 490 | string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath); |
| 491 | |
| 492 | // Get Xml configuration domains folder |
| 493 | string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath); |
| 494 | |
| 495 | // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary) |
| 496 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation); |
| 497 | |
| 498 | // Selection criteria definition for rule creation |
| 499 | xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); |
| 500 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 501 | // Auto validation of configurations if no binary settings provided |
| 502 | xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation); |
| 503 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 504 | log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with"); |
| 505 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 506 | // Do parse |
| 507 | if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) { |
| 508 | |
| 509 | return false; |
| 510 | } |
| 511 | // We have loaded the whole system structure, compute checksum |
| 512 | const CSystemClass* pSystemClass = getConstSystemClass(); |
| 513 | _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum(); |
| 514 | |
| 515 | // Load binary settings if any provided |
| 516 | if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) { |
| 517 | |
| 518 | return false; |
| 519 | } |
| 520 | |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 521 | return true; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | // XML parsing |
| 525 | bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName) |
| 526 | { |
| 527 | // Init serializing context |
| 528 | elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation); |
| 529 | |
| 530 | // Get Schema file associated to root element |
| 531 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd"; |
| 532 | |
| 533 | // Parse Structure XML file |
| 534 | CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext); |
| 535 | |
| 536 | if (!parser.open()) { |
| 537 | |
| 538 | return false; |
| 539 | } |
| 540 | |
| 541 | // Check Root element name attribute (if any) |
| 542 | string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName); |
| 543 | |
| 544 | if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) { |
| 545 | |
| 546 | elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath); |
| 547 | elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName()); |
| 548 | |
| 549 | return false; |
| 550 | } |
| 551 | |
| 552 | // Start clean |
| 553 | pRootElement->clean(); |
| 554 | |
| 555 | // Parse |
| 556 | if (!parser.parse(pRootElement)) { |
| 557 | |
| 558 | // Cleanup |
| 559 | pRootElement->clean(); |
| 560 | |
| 561 | return false; |
| 562 | } |
| 563 | |
| 564 | // Close parser |
| 565 | if (!parser.close()) { |
| 566 | |
| 567 | return false; |
| 568 | } |
| 569 | |
| 570 | return true; |
| 571 | } |
| 572 | |
| 573 | // Init |
| 574 | bool CParameterMgr::init(string& strError) |
| 575 | { |
| 576 | return base::init(strError); |
| 577 | } |
| 578 | |
| 579 | // Selection criteria interface |
| 580 | CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive) |
| 581 | { |
| 582 | // Propagate |
| 583 | return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive); |
| 584 | } |
| 585 | |
| 586 | CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType) |
| 587 | { |
| 588 | // Propagate |
| 589 | return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType); |
| 590 | } |
| 591 | |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 592 | // Selection criterion retrieval |
| 593 | CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 594 | { |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 595 | // Propagate |
| 596 | return getSelectionCriteria()->getSelectionCriterion(strName); |
| 597 | } |
| 598 | |
| 599 | // Selection criteria changed event |
| 600 | bool CParameterMgr::applyConfigurations(string& strError) |
| 601 | { |
| 602 | CAutoLog autoLog(this, "Configuration application request"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 603 | |
| 604 | // Lock state |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 605 | CAutoLock autoLock(&_tuningModeMutex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 606 | |
| 607 | if (!_bTuningModeIsOn) { |
| 608 | |
| 609 | // Apply configuration(s) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 610 | if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) { |
| 611 | |
| 612 | log("Failed to apply configurations!"); |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 613 | |
| 614 | return false; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 615 | } |
| 616 | } |
Patrick Benavoli | b71ccf7 | 2011-09-13 14:15:52 +0200 | [diff] [blame] | 617 | |
| 618 | return true; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 619 | } |
| 620 | |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 621 | // Dynamic parameter handling |
| 622 | bool CParameterMgr::setValue(const string& strPath, const string& strValue, bool bRawValueSpace, string& strError) |
| 623 | { |
| 624 | // Delegate to low level functionality |
| 625 | return doSetValue(strPath, strValue, bRawValueSpace, true, strError); |
| 626 | } |
| 627 | |
| 628 | bool CParameterMgr::getValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, string& strError) const |
| 629 | { |
| 630 | // Delegate to low level functionality |
| 631 | return doGetValue(strPath, strValue, bRawValueSpace, bHexOutputRawFormat, true, strError); |
| 632 | } |
| 633 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 634 | /////////////////// Remote command parsers |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 635 | /// Version |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 636 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 637 | { |
| 638 | (void)remoteCommand; |
| 639 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 640 | // Show version |
| 641 | strResult = getVersion(); |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 642 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 643 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 644 | } |
| 645 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 646 | /// Status |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 647 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 648 | { |
| 649 | (void)remoteCommand; |
| 650 | // System class |
| 651 | const CSystemClass* pSystemClass = getSystemClass(); |
| 652 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 653 | // Show status |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 654 | /// General section |
| 655 | appendTitle(strResult, "General:"); |
| 656 | // System class |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 657 | strResult += "System Class: "; |
| 658 | strResult += pSystemClass->getName(); |
| 659 | strResult += "\n"; |
| 660 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 661 | // Tuning mode |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 662 | strResult += "Tuning Mode: "; |
| 663 | strResult += tuningModeOn() ? "on" : "off"; |
| 664 | strResult += "\n"; |
| 665 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 666 | // Value space |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 667 | strResult += "Value Space: "; |
| 668 | strResult += valueSpaceIsRaw() ? "raw" : "real"; |
| 669 | strResult += "\n"; |
| 670 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 671 | // Output raw format |
| 672 | strResult += "Output Raw Format: "; |
| 673 | strResult += outputRawFormatIsHex() ? "hex" : "dec"; |
| 674 | strResult += "\n"; |
| 675 | |
| 676 | // Auto Sync |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 677 | strResult += "Auto Sync: "; |
| 678 | strResult += autoSyncOn() ? "on" : "off"; |
| 679 | strResult += "\n"; |
| 680 | |
| 681 | /// Subsystem list |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 682 | appendTitle(strResult, "Subsystems:"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 683 | string strSubsystemList; |
| 684 | pSystemClass->listChildrenPaths(strSubsystemList); |
| 685 | strResult += strSubsystemList; |
| 686 | |
| 687 | /// Last applied configurations |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 688 | appendTitle(strResult, "Last applied configurations:"); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 689 | string strLastAppliedConfigurations; |
| 690 | getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations); |
| 691 | strResult += strLastAppliedConfigurations; |
| 692 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 693 | /// Criteria states |
| 694 | appendTitle(strResult, "Selection criteria:"); |
| 695 | string strSelectionCriteria; |
| 696 | getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false); |
| 697 | strResult += strSelectionCriteria; |
| 698 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 699 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | /// Tuning Mode |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 703 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 704 | { |
| 705 | if (remoteCommand.getArgument(0) == "on") { |
| 706 | |
| 707 | if (setTuningMode(true, strResult)) { |
| 708 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 709 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 710 | } |
| 711 | } else if (remoteCommand.getArgument(0) == "off") { |
| 712 | |
| 713 | if (setTuningMode(false, strResult)) { |
| 714 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 715 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 716 | } |
| 717 | } else { |
| 718 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 719 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 720 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 721 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 722 | } |
| 723 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 724 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 725 | { |
| 726 | (void)remoteCommand; |
| 727 | |
| 728 | strResult = tuningModeOn() ? "on" : "off"; |
| 729 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 730 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | /// Value Space |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 734 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 735 | { |
| 736 | (void)strResult; |
| 737 | |
| 738 | if (remoteCommand.getArgument(0) == "raw") { |
| 739 | |
| 740 | setValueSpace(true); |
| 741 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 742 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 743 | |
| 744 | } else if (remoteCommand.getArgument(0) == "real") { |
| 745 | |
| 746 | setValueSpace(false); |
| 747 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 748 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 749 | |
| 750 | } else { |
| 751 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 752 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 753 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 754 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 755 | } |
| 756 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 757 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 758 | { |
| 759 | (void)remoteCommand; |
| 760 | |
| 761 | strResult = valueSpaceIsRaw() ? "raw" : "real"; |
| 762 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 763 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 764 | } |
| 765 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 766 | /// Output Raw Format |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 767 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 768 | { |
| 769 | (void)strResult; |
| 770 | |
| 771 | if (remoteCommand.getArgument(0) == "hex") { |
| 772 | |
| 773 | setOutputRawFormat(true); |
| 774 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 775 | return CCommandHandler::EDone; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 776 | |
| 777 | } else if (remoteCommand.getArgument(0) == "dec") { |
| 778 | |
| 779 | setOutputRawFormat(false); |
| 780 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 781 | return CCommandHandler::EDone; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 782 | |
| 783 | } else { |
| 784 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 785 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 786 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 787 | return CCommandHandler::EFailed; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 788 | } |
| 789 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 790 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 791 | { |
| 792 | (void)remoteCommand; |
| 793 | |
| 794 | strResult = outputRawFormatIsHex() ? "hex" : "dec"; |
| 795 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 796 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 797 | } |
| 798 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 799 | /// Sync |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 800 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 801 | { |
| 802 | if (remoteCommand.getArgument(0) == "on") { |
| 803 | |
| 804 | if (setAutoSync(true, strResult)) { |
| 805 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 806 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 807 | } |
| 808 | } else if (remoteCommand.getArgument(0) == "off") { |
| 809 | |
| 810 | if (setAutoSync(false, strResult)) { |
| 811 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 812 | return CCommandHandler::EDone; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 813 | } |
| 814 | } else { |
| 815 | // Show usage |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 816 | return CCommandHandler::EShowUsage; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 817 | } |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 818 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 819 | } |
| 820 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 821 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 822 | { |
| 823 | (void)remoteCommand; |
| 824 | |
| 825 | strResult = autoSyncOn() ? "on" : "off"; |
| 826 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 827 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 828 | } |
| 829 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 830 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 831 | { |
| 832 | (void)remoteCommand; |
| 833 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 834 | return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 835 | } |
| 836 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 837 | /// Criteria |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 838 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 839 | { |
| 840 | (void)remoteCommand; |
| 841 | |
| 842 | getSelectionCriteria()->listSelectionCriteria(strResult, true); |
| 843 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 844 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 845 | } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 846 | |
| 847 | /// Domains |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 848 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 849 | { |
| 850 | (void)remoteCommand; |
| 851 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 852 | getConfigurableDomains()->listDomains(strResult); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 853 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 854 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 855 | } |
| 856 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 857 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 858 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 859 | return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 860 | } |
| 861 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 862 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 863 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 864 | return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 865 | } |
| 866 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 867 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 868 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 869 | 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] | 870 | } |
| 871 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 872 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 873 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 874 | // Check tuning mode |
| 875 | if (!checkTuningModeOn(strResult)) { |
| 876 | |
| 877 | return CCommandHandler::EFailed; |
| 878 | } |
| 879 | |
| 880 | // Set property |
| 881 | bool bSequenceAware; |
| 882 | |
| 883 | if (remoteCommand.getArgument(1) == "true") { |
| 884 | |
| 885 | bSequenceAware = true; |
| 886 | |
| 887 | } else if (remoteCommand.getArgument(1) == "false") { |
| 888 | |
| 889 | bSequenceAware = false; |
| 890 | |
| 891 | } else { |
| 892 | // Show usage |
| 893 | return CCommandHandler::EShowUsage; |
| 894 | } |
| 895 | |
| 896 | return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 897 | } |
| 898 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 899 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 900 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 901 | // Get property |
| 902 | bool bSequenceAware; |
| 903 | |
| 904 | if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) { |
| 905 | |
| 906 | return CCommandHandler::EFailed; |
| 907 | } |
| 908 | |
| 909 | strResult = bSequenceAware ? "true" : "false"; |
| 910 | |
| 911 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 912 | } |
| 913 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 914 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 915 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 916 | return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 917 | } |
| 918 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 919 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 920 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 921 | return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 922 | } |
| 923 | |
| 924 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 925 | { |
| 926 | return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 927 | } |
| 928 | |
| 929 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 930 | { |
| 931 | 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] | 932 | } |
| 933 | |
| 934 | /// Configurations |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 935 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 936 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 937 | return getConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 938 | } |
| 939 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 940 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 941 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 942 | 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] | 943 | } |
| 944 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 945 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 946 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 947 | 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] | 948 | } |
| 949 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 950 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 951 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 952 | 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] | 953 | } |
| 954 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 955 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 956 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 957 | 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] | 958 | } |
| 959 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 960 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 961 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 962 | return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 963 | } |
| 964 | |
| 965 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 966 | { |
| 967 | // Check tuning mode |
| 968 | if (!checkTuningModeOn(strResult)) { |
| 969 | |
| 970 | return CCommandHandler::EFailed; |
| 971 | } |
| 972 | |
| 973 | // Build configurable element path list |
| 974 | vector<string> astrNewElementSequence; |
| 975 | |
| 976 | uint32_t uiArgument; |
| 977 | |
| 978 | for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) { |
| 979 | |
| 980 | astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument)); |
| 981 | } |
| 982 | |
| 983 | // Delegate to configurable domains |
| 984 | return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
| 985 | } |
| 986 | |
| 987 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
| 988 | { |
| 989 | // Delegate to configurable domains |
| 990 | 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] | 991 | } |
| 992 | |
| 993 | /// Elements/Parameters |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 994 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 995 | { |
| 996 | CElementLocator elementLocator(getSystemClass(), false); |
| 997 | |
| 998 | CElement* pLocatedElement = NULL; |
| 999 | |
| 1000 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1001 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1002 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | strResult = string("\n"); |
| 1006 | |
| 1007 | if (!pLocatedElement) { |
| 1008 | |
| 1009 | // List from root folder |
| 1010 | |
| 1011 | // Return system class qualified name |
| 1012 | pLocatedElement = getSystemClass(); |
| 1013 | } |
| 1014 | |
| 1015 | // Return sub-elements |
| 1016 | strResult += pLocatedElement->listQualifiedPaths(false); |
| 1017 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1018 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | /// Elements/Parameters |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1022 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1023 | { |
| 1024 | CElementLocator elementLocator(getSystemClass(), false); |
| 1025 | |
| 1026 | CElement* pLocatedElement = NULL; |
| 1027 | |
| 1028 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1029 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1030 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | strResult = string("\n"); |
| 1034 | |
| 1035 | if (!pLocatedElement) { |
| 1036 | |
| 1037 | // List from root folder |
| 1038 | |
| 1039 | // Return system class qualified name |
| 1040 | pLocatedElement = getSystemClass(); |
| 1041 | } |
| 1042 | |
| 1043 | // Return sub-elements |
| 1044 | strResult += pLocatedElement->listQualifiedPaths(true); |
| 1045 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1046 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1047 | } |
| 1048 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1049 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1050 | { |
| 1051 | CElementLocator elementLocator(getSystemClass()); |
| 1052 | |
| 1053 | CElement* pLocatedElement = NULL; |
| 1054 | |
| 1055 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1056 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1057 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | string strError; |
| 1061 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1062 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1063 | |
| 1064 | // Dump elements |
| 1065 | pLocatedElement->dumpContent(strResult, parameterAccessContext); |
| 1066 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1067 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1068 | } |
| 1069 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1070 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1071 | { |
| 1072 | CElementLocator elementLocator(getSystemClass()); |
| 1073 | |
| 1074 | CElement* pLocatedElement = NULL; |
| 1075 | |
| 1076 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1077 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1078 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | // Converted to actual sizable element |
| 1082 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1083 | |
| 1084 | // Get size as string |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1085 | strResult = pConfigurableElement->getFootprintAsString(); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1086 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1087 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1088 | } |
| 1089 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1090 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1091 | { |
| 1092 | CElementLocator elementLocator(getSystemClass()); |
| 1093 | |
| 1094 | CElement* pLocatedElement = NULL; |
| 1095 | |
| 1096 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1097 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1098 | return CCommandHandler::EFailed; |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | // Convert element |
| 1102 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1103 | |
| 1104 | // Return element properties |
| 1105 | pConfigurableElement->showProperties(strResult); |
| 1106 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1107 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 2ecf900 | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1108 | } |
| 1109 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1110 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1111 | { |
| 1112 | string strValue; |
| 1113 | |
| 1114 | if (!getValue(remoteCommand.getArgument(0), strValue, strResult)) { |
| 1115 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1116 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1117 | } |
| 1118 | // Succeeded |
| 1119 | strResult = strValue; |
| 1120 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1121 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1122 | } |
| 1123 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1124 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1125 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1126 | return setValue(remoteCommand.getArgument(0), remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1127 | } |
| 1128 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1129 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1130 | { |
| 1131 | CElementLocator elementLocator(getSystemClass()); |
| 1132 | |
| 1133 | CElement* pLocatedElement = NULL; |
| 1134 | |
| 1135 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1136 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1137 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | // Convert element |
| 1141 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1142 | |
| 1143 | // Return element belonging domains |
| 1144 | pConfigurableElement->listBelongingDomains(strResult); |
| 1145 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1146 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1147 | } |
| 1148 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1149 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1150 | { |
| 1151 | CElementLocator elementLocator(getSystemClass()); |
| 1152 | |
| 1153 | CElement* pLocatedElement = NULL; |
| 1154 | |
| 1155 | if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) { |
| 1156 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1157 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | // Convert element |
| 1161 | const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1162 | |
| 1163 | // Return element belonging domains |
| 1164 | pConfigurableElement->listAssociatedDomains(strResult); |
| 1165 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1166 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1167 | } |
| 1168 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1169 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1170 | { |
| 1171 | (void)remoteCommand; |
| 1172 | |
| 1173 | getConfigurableDomains()->listAssociatedElements(strResult); |
| 1174 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1175 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1176 | } |
| 1177 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1178 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1179 | { |
| 1180 | (void)remoteCommand; |
| 1181 | |
| 1182 | getConfigurableDomains()->listConflictingElements(strResult); |
| 1183 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1184 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1185 | } |
| 1186 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1187 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1188 | { |
| 1189 | (void)remoteCommand; |
| 1190 | |
| 1191 | getSystemClass()->listRogueElements(strResult); |
| 1192 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1193 | return CCommandHandler::ESucceeded; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | /// Settings Import/Export |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1197 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1198 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1199 | return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1200 | } |
| 1201 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1202 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1203 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1204 | return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1205 | } |
| 1206 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1207 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1208 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1209 | return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1210 | } |
| 1211 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1212 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1213 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1214 | return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1215 | } |
| 1216 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1217 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1218 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1219 | return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1220 | } |
| 1221 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1222 | CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult) |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1223 | { |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1224 | return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | // User set/get parameters |
| 1228 | bool CParameterMgr::setValue(const string& strPath, const string& strValue, string& strError) |
| 1229 | { |
| 1230 | // Check tuning mode |
| 1231 | if (!checkTuningModeOn(strError)) { |
| 1232 | |
| 1233 | return false; |
| 1234 | } |
| 1235 | |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1236 | // Delegate to low level functionality |
| 1237 | return doSetValue(strPath, strValue, _bValueSpaceIsRaw, false, strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | bool CParameterMgr::getValue(const string& strPath, string& strValue, string& strError) const |
| 1241 | { |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1242 | // Delegate to low level functionality |
| 1243 | return doGetValue(strPath, strValue, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, false, strError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1244 | } |
| 1245 | |
| 1246 | // Tuning mode |
| 1247 | bool CParameterMgr::setTuningMode(bool bOn, string& strError) |
| 1248 | { |
| 1249 | // Tuning allowed? |
| 1250 | if (bOn && !_pSystemClassConfiguration->isTuningAllowed()) { |
| 1251 | |
| 1252 | strError = "Tuning prohibited"; |
| 1253 | |
| 1254 | return false; |
| 1255 | } |
| 1256 | // Lock state |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1257 | CAutoLock autoLock(&_tuningModeMutex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1258 | |
| 1259 | // Warn domains about exiting tuning mode |
| 1260 | if (!bOn && _bTuningModeIsOn) { |
| 1261 | |
| 1262 | // Ensure application of currently selected configurations |
Patrick Benavoli | 1387bda | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1263 | // Force-apply configurations |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1264 | if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) { |
| 1265 | |
| 1266 | return false; |
| 1267 | } |
| 1268 | // Turn auto sync back on |
| 1269 | _bAutoSyncOn = true; |
| 1270 | } |
| 1271 | |
| 1272 | // Store |
| 1273 | _bTuningModeIsOn = bOn; |
| 1274 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1275 | return true; |
| 1276 | } |
| 1277 | |
| 1278 | bool CParameterMgr::tuningModeOn() const |
| 1279 | { |
| 1280 | return _bTuningModeIsOn; |
| 1281 | } |
| 1282 | |
| 1283 | // Current value space for user set/get value interpretation |
| 1284 | void CParameterMgr::setValueSpace(bool bIsRaw) |
| 1285 | { |
| 1286 | _bValueSpaceIsRaw = bIsRaw; |
| 1287 | } |
| 1288 | |
| 1289 | bool CParameterMgr::valueSpaceIsRaw() |
| 1290 | { |
| 1291 | return _bValueSpaceIsRaw; |
| 1292 | } |
| 1293 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1294 | // Current Output Raw Format for user get value interpretation |
| 1295 | void CParameterMgr::setOutputRawFormat(bool bIsHex) |
| 1296 | { |
| 1297 | _bOutputRawFormatIsHex = bIsHex; |
| 1298 | } |
| 1299 | |
| 1300 | bool CParameterMgr::outputRawFormatIsHex() |
| 1301 | { |
| 1302 | return _bOutputRawFormatIsHex; |
| 1303 | } |
| 1304 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1305 | /// Sync |
| 1306 | // Automatic hardware synchronization control (during tuning session) |
| 1307 | bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError) |
| 1308 | { |
| 1309 | // Check tuning mode |
| 1310 | if (!checkTuningModeOn(strError)) { |
| 1311 | |
| 1312 | return false; |
| 1313 | } |
| 1314 | // Warn domains about turning auto sync back on |
| 1315 | if (bAutoSyncOn && !_bAutoSyncOn) { |
| 1316 | |
Patrick Benavoli | 592ae56 | 2011-09-05 16:53:58 +0200 | [diff] [blame] | 1317 | // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters) |
| 1318 | if (!sync(strError)) { |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1319 | |
| 1320 | return false; |
| 1321 | } |
| 1322 | } |
| 1323 | |
| 1324 | // Set Auto sync |
| 1325 | _bAutoSyncOn = bAutoSyncOn; |
| 1326 | |
| 1327 | return true; |
| 1328 | } |
| 1329 | |
| 1330 | bool CParameterMgr::autoSyncOn() const |
| 1331 | { |
| 1332 | return _bAutoSyncOn; |
| 1333 | } |
| 1334 | |
| 1335 | // Manual hardware synchronization control (during tuning session) |
| 1336 | bool CParameterMgr::sync(string& strError) |
| 1337 | { |
| 1338 | // Check tuning mode |
| 1339 | if (!checkTuningModeOn(strError)) { |
| 1340 | |
| 1341 | return false; |
| 1342 | } |
| 1343 | // Warn domains about turning auto sync back on |
| 1344 | if (_bAutoSyncOn) { |
| 1345 | |
| 1346 | strError = "Feature unavailable when Auto Sync is on"; |
| 1347 | |
| 1348 | return false; |
| 1349 | } |
| 1350 | |
| 1351 | // Get syncer set |
| 1352 | CSyncerSet syncerSet; |
| 1353 | // ... from system class |
| 1354 | getConstSystemClass()->fillSyncerSet(syncerSet); |
| 1355 | // Sync |
| 1356 | return syncerSet.sync(*_pMainParameterBlackboard, false, strError); |
| 1357 | } |
| 1358 | |
| 1359 | // Content dump |
| 1360 | void CParameterMgr::logStructureContent(string& strContent) const |
| 1361 | { |
| 1362 | string strError; |
| 1363 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1364 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1365 | |
| 1366 | dumpContent(strContent, parameterAccessContext); |
| 1367 | } |
| 1368 | |
| 1369 | // Configuration/Domains handling |
| 1370 | bool CParameterMgr::createDomain(const string& strName, string& strError) |
| 1371 | { |
| 1372 | // Check tuning mode |
| 1373 | if (!checkTuningModeOn(strError)) { |
| 1374 | |
| 1375 | return false; |
| 1376 | } |
| 1377 | |
| 1378 | // Delegate to configurable domains |
| 1379 | return getConfigurableDomains()->createDomain(strName, strError); |
| 1380 | } |
| 1381 | |
| 1382 | bool CParameterMgr::deleteDomain(const string& strName, string& strError) |
| 1383 | { |
| 1384 | // Check tuning mode |
| 1385 | if (!checkTuningModeOn(strError)) { |
| 1386 | |
| 1387 | return false; |
| 1388 | } |
| 1389 | |
| 1390 | // Delegate to configurable domains |
| 1391 | return getConfigurableDomains()->deleteDomain(strName, strError); |
| 1392 | } |
| 1393 | |
| 1394 | bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1395 | { |
| 1396 | // Check tuning mode |
| 1397 | if (!checkTuningModeOn(strError)) { |
| 1398 | |
| 1399 | return false; |
| 1400 | } |
| 1401 | |
| 1402 | // Delegate to configurable domains |
| 1403 | return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); |
| 1404 | } |
| 1405 | |
| 1406 | bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1407 | { |
| 1408 | // Check tuning mode |
| 1409 | if (!checkTuningModeOn(strError)) { |
| 1410 | |
| 1411 | return false; |
| 1412 | } |
| 1413 | |
| 1414 | // Delegate to configurable domains |
| 1415 | return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError); |
| 1416 | } |
| 1417 | |
| 1418 | bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1419 | { |
| 1420 | // Check tuning mode |
| 1421 | if (!checkTuningModeOn(strError)) { |
| 1422 | |
| 1423 | return false; |
| 1424 | } |
| 1425 | |
| 1426 | // Delegate to configurable domains |
| 1427 | return getConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError); |
| 1428 | } |
| 1429 | |
| 1430 | bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError) |
| 1431 | { |
| 1432 | // Check tuning mode |
| 1433 | if (!checkTuningModeOn(strError)) { |
| 1434 | |
| 1435 | return false; |
| 1436 | } |
| 1437 | |
| 1438 | // Delegate to configurable domains |
| 1439 | return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError); |
| 1440 | } |
| 1441 | |
| 1442 | // Configurable element - domain association |
| 1443 | bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1444 | { |
| 1445 | // Check tuning mode |
| 1446 | if (!checkTuningModeOn(strError)) { |
| 1447 | |
| 1448 | return false; |
| 1449 | } |
| 1450 | |
| 1451 | CElementLocator elementLocator(getSystemClass()); |
| 1452 | |
| 1453 | CElement* pLocatedElement = NULL; |
| 1454 | |
| 1455 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1456 | |
| 1457 | return false; |
| 1458 | } |
| 1459 | |
| 1460 | // Convert element |
| 1461 | CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1462 | |
| 1463 | // Delegate |
| 1464 | return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError); |
| 1465 | } |
| 1466 | |
| 1467 | bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1468 | { |
| 1469 | // Check tuning mode |
| 1470 | if (!checkTuningModeOn(strError)) { |
| 1471 | |
| 1472 | return false; |
| 1473 | } |
| 1474 | |
| 1475 | CElementLocator elementLocator(getSystemClass()); |
| 1476 | |
| 1477 | CElement* pLocatedElement = NULL; |
| 1478 | |
| 1479 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1480 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1481 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1482 | } |
| 1483 | |
| 1484 | // Convert element |
| 1485 | CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1486 | |
| 1487 | // Delegate |
| 1488 | return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError); |
| 1489 | } |
| 1490 | |
| 1491 | bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError) |
| 1492 | { |
| 1493 | // Check tuning mode |
| 1494 | if (!checkTuningModeOn(strError)) { |
| 1495 | |
| 1496 | return false; |
| 1497 | } |
| 1498 | |
| 1499 | CElementLocator elementLocator(getSystemClass()); |
| 1500 | |
| 1501 | CElement* pLocatedElement = NULL; |
| 1502 | |
| 1503 | if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) { |
| 1504 | |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1505 | return CCommandHandler::EFailed; |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1506 | } |
| 1507 | |
| 1508 | // Convert element |
| 1509 | CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement); |
| 1510 | |
| 1511 | // Delegate |
| 1512 | return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError); |
| 1513 | } |
| 1514 | |
| 1515 | // XML Import/Export |
| 1516 | bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError) |
| 1517 | { |
| 1518 | // Check tuning mode |
| 1519 | if (!checkTuningModeOn(strError)) { |
| 1520 | |
| 1521 | return false; |
| 1522 | } |
| 1523 | |
| 1524 | // check path is absolute |
| 1525 | if (strFileName[0] != '/') { |
| 1526 | |
| 1527 | strError = "Please provide absolute path"; |
| 1528 | |
| 1529 | return false; |
| 1530 | } |
| 1531 | // Root element |
| 1532 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 1533 | |
| 1534 | // Context |
| 1535 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); |
| 1536 | |
| 1537 | // Secltion criteria definition for rule creation |
| 1538 | xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition()); |
| 1539 | |
| 1540 | // Parse |
| 1541 | if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) { |
| 1542 | |
| 1543 | return false; |
| 1544 | } |
| 1545 | |
| 1546 | // Validate domains after XML import |
| 1547 | pConfigurableDomains->validate(_pMainParameterBlackboard); |
| 1548 | |
| 1549 | return true; |
| 1550 | } |
| 1551 | |
| 1552 | bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const |
| 1553 | { |
| 1554 | // check path is absolute |
| 1555 | if (strFileName[0] != '/') { |
| 1556 | |
| 1557 | strError = "Please provide absolute path"; |
| 1558 | |
| 1559 | return false; |
| 1560 | } |
| 1561 | |
| 1562 | // Root element |
| 1563 | const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains(); |
| 1564 | |
| 1565 | // Get Schema file associated to root element |
| 1566 | string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd"; |
| 1567 | |
| 1568 | // Context |
| 1569 | CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings); |
| 1570 | |
| 1571 | // Value space |
| 1572 | xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw); |
| 1573 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1574 | // Output raw format |
| 1575 | xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex); |
| 1576 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1577 | // Instantiate composer |
| 1578 | CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext); |
| 1579 | |
| 1580 | // Open composer |
| 1581 | if (!xmlComposer.open()) { |
| 1582 | |
| 1583 | return false; |
| 1584 | } |
| 1585 | |
| 1586 | // Compose |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1587 | xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion()); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1588 | |
| 1589 | // Close composer |
| 1590 | if (!xmlComposer.close()) { |
| 1591 | |
| 1592 | return false; |
| 1593 | } |
| 1594 | |
| 1595 | return true; |
| 1596 | } |
| 1597 | |
| 1598 | // Binary Import/Export |
| 1599 | bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError) |
| 1600 | { |
| 1601 | // Check tuning mode |
| 1602 | if (!checkTuningModeOn(strError)) { |
| 1603 | |
| 1604 | return false; |
| 1605 | } |
| 1606 | // check path is absolute |
| 1607 | if (strFileName[0] != '/') { |
| 1608 | |
| 1609 | strError = "Please provide absolute path"; |
| 1610 | |
| 1611 | return false; |
| 1612 | } |
| 1613 | // Root element |
| 1614 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 1615 | |
| 1616 | // Serialize in |
| 1617 | return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError); |
| 1618 | } |
| 1619 | |
| 1620 | bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError) |
| 1621 | { |
| 1622 | // check path is absolute |
| 1623 | if (strFileName[0] != '/') { |
| 1624 | |
| 1625 | strError = "Please provide absolute path"; |
| 1626 | |
| 1627 | return false; |
| 1628 | } |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1629 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1630 | // Root element |
| 1631 | CConfigurableDomains* pConfigurableDomains = getConfigurableDomains(); |
| 1632 | |
| 1633 | // Serialize out |
| 1634 | return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError); |
| 1635 | } |
| 1636 | |
| 1637 | // For tuning, check we're in tuning mode |
| 1638 | bool CParameterMgr::checkTuningModeOn(string& strError) const |
| 1639 | { |
| 1640 | // Tuning Mode on? |
| 1641 | if (!_bTuningModeIsOn) { |
| 1642 | |
| 1643 | strError = "Tuning Mode must be on"; |
| 1644 | |
| 1645 | return false; |
| 1646 | } |
| 1647 | return true; |
| 1648 | } |
| 1649 | |
Patrick Benavoli | 4bed921 | 2011-10-27 14:18:00 +0200 | [diff] [blame] | 1650 | // Parameter access |
| 1651 | bool CParameterMgr::doSetValue(const string& strPath, const string& strValue, bool bRawValueSpace, bool bDynamicAccess, string& strError) |
| 1652 | { |
| 1653 | CPathNavigator pathNavigator(strPath); |
| 1654 | |
| 1655 | if (!pathNavigator.isPathValid()) { |
| 1656 | |
| 1657 | strError = "Path not well formed"; |
| 1658 | |
| 1659 | return false; |
| 1660 | } |
| 1661 | |
| 1662 | string* pStrChildName = pathNavigator.next(); |
| 1663 | |
| 1664 | if (!pStrChildName) { |
| 1665 | |
| 1666 | strError = "Non settable element"; |
| 1667 | |
| 1668 | return false; |
| 1669 | } |
| 1670 | |
| 1671 | if (*pStrChildName != getSystemClass()->getName()) { |
| 1672 | |
| 1673 | strError = "Path not found"; |
| 1674 | |
| 1675 | return false; |
| 1676 | } |
| 1677 | |
| 1678 | // Define context |
| 1679 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, false); |
| 1680 | |
| 1681 | // Set auto sync |
| 1682 | parameterAccessContext.setAutoSync(_bAutoSyncOn); |
| 1683 | |
| 1684 | // Set dynamic access |
| 1685 | parameterAccessContext.setDynamicAccess(bDynamicAccess); |
| 1686 | |
| 1687 | // Do the set |
| 1688 | return getSystemClass()->setValue(pathNavigator, strValue, parameterAccessContext); |
| 1689 | } |
| 1690 | |
| 1691 | bool CParameterMgr::doGetValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, string& strError) const |
| 1692 | { |
| 1693 | CPathNavigator pathNavigator(strPath); |
| 1694 | |
| 1695 | if (!pathNavigator.isPathValid()) { |
| 1696 | |
| 1697 | strError = "Path not well formed"; |
| 1698 | |
| 1699 | return false; |
| 1700 | } |
| 1701 | |
| 1702 | string* pStrChildName = pathNavigator.next(); |
| 1703 | |
| 1704 | if (!pStrChildName) { |
| 1705 | |
| 1706 | strError = "Non settable element"; |
| 1707 | |
| 1708 | return false; |
| 1709 | } |
| 1710 | |
| 1711 | if (*pStrChildName != getConstSystemClass()->getName()) { |
| 1712 | |
| 1713 | strError = "Path not found"; |
| 1714 | |
| 1715 | return false; |
| 1716 | } |
| 1717 | |
| 1718 | // Define context |
| 1719 | CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, bHexOutputRawFormat); |
| 1720 | |
| 1721 | // Set dynamic access |
| 1722 | parameterAccessContext.setDynamicAccess(bDynamicAccess); |
| 1723 | |
| 1724 | // Do the get |
| 1725 | return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext); |
| 1726 | } |
| 1727 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1728 | // Dynamic creation library feeding |
| 1729 | void CParameterMgr::feedElementLibraries() |
| 1730 | { |
| 1731 | // Global Configuration handling |
| 1732 | CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary; |
| 1733 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1734 | pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration")); |
| 1735 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders")); |
| 1736 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation")); |
| 1737 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("ParameterConfiguration")); |
| 1738 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSystemClassConfiguration>("SystemClassConfiguration")); |
| 1739 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation")); |
| 1740 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration")); |
| 1741 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation")); |
| 1742 | pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1743 | |
| 1744 | _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary); |
| 1745 | |
| 1746 | // Parameter creation |
| 1747 | CElementLibrary* pParameterCreationLibrary = new CElementLibrary; |
| 1748 | |
| 1749 | pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary())); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1750 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType")); |
| 1751 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component")); |
| 1752 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter")); |
| 1753 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock")); |
Patrick Benavoli | 1352ae5 | 2011-10-21 16:48:04 +0200 | [diff] [blame] | 1754 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter")); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1755 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock")); |
| 1756 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter")); |
| 1757 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter")); |
Patrick Benavoli | 9fc3c0d | 2011-10-27 14:27:27 +0200 | [diff] [blame] | 1758 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter")); |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1759 | pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter")); |
| 1760 | pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1761 | |
| 1762 | _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary); |
| 1763 | |
| 1764 | // Parameter Configuration Domains creation |
| 1765 | CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary; |
| 1766 | |
Patrick Benavoli | 6ba361d | 2011-08-31 11:23:24 +0200 | [diff] [blame] | 1767 | pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain")); |
| 1768 | pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration")); |
| 1769 | pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule")); |
| 1770 | pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule")); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1771 | |
| 1772 | _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary); |
| 1773 | } |
| 1774 | |
| 1775 | // Remote Processor Server connection handling |
| 1776 | bool CParameterMgr::handleRemoteProcessingInterface(string& strError) |
| 1777 | { |
| 1778 | CAutoLog autoLog(this, "Handling remote processing interface"); |
| 1779 | |
| 1780 | // Start server if tuning allowed |
| 1781 | if (_pSystemClassConfiguration->isTuningAllowed()) { |
| 1782 | |
| 1783 | log("Loading remote processor library"); |
| 1784 | |
| 1785 | // Load library |
| 1786 | void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW); |
| 1787 | |
| 1788 | if (!lib_handle) { |
| 1789 | |
| 1790 | // Return error |
| 1791 | const char* pcError = dlerror(); |
| 1792 | |
| 1793 | if (pcError) { |
| 1794 | |
| 1795 | strError = pcError; |
| 1796 | } else { |
| 1797 | |
| 1798 | strError = "Unable to load libremote-processor.so library"; |
| 1799 | } |
| 1800 | |
| 1801 | return false; |
| 1802 | } |
| 1803 | |
| 1804 | CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer"); |
| 1805 | |
| 1806 | if (!pfnCreateRemoteProcessorServer) { |
| 1807 | |
| 1808 | strError = "libremote-process.so does not contain createRemoteProcessorServer symbol."; |
| 1809 | |
| 1810 | return false; |
| 1811 | } |
| 1812 | |
| 1813 | // Create server |
Patrick Benavoli | 63499d4 | 2011-10-24 18:50:03 +0200 | [diff] [blame] | 1814 | _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(_pSystemClassConfiguration->getServerPort(), _pCommandHandler); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 1815 | |
| 1816 | log("Starting remote processor server on port %d", _pSystemClassConfiguration->getServerPort()); |
| 1817 | // Start |
| 1818 | if (!_pRemoteProcessorServer->start()) { |
| 1819 | |
| 1820 | strError = "Unable to start remote processor server"; |
| 1821 | |
| 1822 | return false; |
| 1823 | } |
| 1824 | } |
| 1825 | |
| 1826 | return true; |
| 1827 | } |
| 1828 | |
| 1829 | // Back synchronization |
| 1830 | CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const |
| 1831 | { |
| 1832 | #ifdef SIMULATION |
| 1833 | // In simulation, back synchronization of the blackboard won't probably work |
| 1834 | // We need to ensure though the blackboard is initialized with valid data |
| 1835 | return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard); |
| 1836 | #else |
| 1837 | // Real back synchronizer from subsystems |
| 1838 | return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard); |
| 1839 | #endif |
| 1840 | } |
| 1841 | |
| 1842 | // Children typwise access |
| 1843 | CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration() |
| 1844 | { |
| 1845 | return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration)); |
| 1846 | } |
| 1847 | |
| 1848 | const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration() |
| 1849 | { |
| 1850 | return getFrameworkConfiguration(); |
| 1851 | } |
| 1852 | |
| 1853 | CSelectionCriteria* CParameterMgr::getSelectionCriteria() |
| 1854 | { |
| 1855 | return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria)); |
| 1856 | } |
| 1857 | |
| 1858 | const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria() |
| 1859 | { |
| 1860 | return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria)); |
| 1861 | } |
| 1862 | |
| 1863 | CSystemClass* CParameterMgr::getSystemClass() |
| 1864 | { |
| 1865 | return static_cast<CSystemClass*>(getChild(ESystemClass)); |
| 1866 | } |
| 1867 | |
| 1868 | const CSystemClass* CParameterMgr::getConstSystemClass() const |
| 1869 | { |
| 1870 | return static_cast<const CSystemClass*>(getChild(ESystemClass)); |
| 1871 | } |
| 1872 | |
| 1873 | // Configurable Domains |
| 1874 | CConfigurableDomains* CParameterMgr::getConfigurableDomains() |
| 1875 | { |
| 1876 | return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 1877 | } |
| 1878 | |
| 1879 | const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() |
| 1880 | { |
| 1881 | return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 1882 | } |
| 1883 | |
| 1884 | const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const |
| 1885 | { |
| 1886 | return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains)); |
| 1887 | } |