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