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