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