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