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