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