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