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