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