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