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