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