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