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