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