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