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