blob: 88270c585d38a9a6393863cdbc8a9d79d7a91ad3 [file] [log] [blame]
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +02001 /*
Patrick Benavoli68a91282011-08-31 11:23:23 +02002 * INTEL CONFIDENTIAL
3 * Copyright © 2011 Intel
4 * Corporation All Rights Reserved.
5 *
6 * The source code contained or described herein and all documents related to
7 * the source code ("Material") are owned by Intel Corporation or its suppliers
8 * or licensors. Title to the Material remains with Intel Corporation or its
9 * suppliers and licensors. The Material contains trade secrets and proprietary
10 * and confidential information of Intel or its suppliers and licensors. The
11 * Material is protected by worldwide copyright and trade secret laws and
12 * treaty provisions. No part of the Material may be used, copied, reproduced,
13 * modified, published, uploaded, posted, transmitted, distributed, or
14 * disclosed in any way without Intel’s prior express written permission.
15 *
16 * No license under any patent, copyright, trade secret or other intellectual
17 * property right is granted to or conferred upon you by disclosure or delivery
18 * of the Materials, either expressly, by implication, inducement, estoppel or
19 * otherwise. Any license under such intellectual property rights must be
20 * express and approved by Intel in writing.
21 *
Patrick Benavoli68a91282011-08-31 11:23:23 +020022 * CREATED: 2011-06-01
23 * UPDATED: 2011-07-27
Patrick Benavoli68a91282011-08-31 11:23:23 +020024 */
25#include "ParameterMgr.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020026#include "XmlParameterSerializingContext.h"
27#include "XmlElementSerializingContext.h"
28#include "SystemClass.h"
29#include "ElementLibrarySet.h"
30#include "SubsystemLibrary.h"
31#include "NamedElementBuilderTemplate.h"
32#include "KindElementBuilderTemplate.h"
33#include "ElementBuilderTemplate.h"
34#include "SelectionCriterionType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020035#include "SubsystemElementBuilder.h"
36#include "SelectionCriteria.h"
37#include "ComponentType.h"
38#include "ComponentInstance.h"
39#include "ParameterBlockType.h"
40#include "BooleanParameterType.h"
41#include "IntegerParameterType.h"
42#include "FixedPointParameterType.h"
43#include "ParameterBlackboard.h"
44#include "Parameter.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020045#include "ParameterAccessContext.h"
46#include "XmlFileIncluderElement.h"
47#include "ParameterFrameworkConfiguration.h"
48#include "FrameworkConfigurationGroup.h"
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +010049#include "PluginLocation.h"
50#include "SubsystemPlugins.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020051#include "FrameworkConfigurationLocation.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020052#include "ConfigurableDomains.h"
53#include "ConfigurableDomain.h"
54#include "DomainConfiguration.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020055#include "XmlDomainSerializingContext.h"
56#include "BitParameterBlockType.h"
57#include "BitParameterType.h"
Patrick Benavoli1352ae52011-10-21 16:48:04 +020058#include "StringParameterType.h"
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +020059#include "EnumParameterType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020060#include "RemoteProcessorServerInterface.h"
61#include "ElementLocator.h"
62#include "AutoLog.h"
63#include "CompoundRule.h"
64#include "SelectionCriterionRule.h"
65#include "SimulatedBackSynchronizer.h"
66#include "HardwareBackSynchronizer.h"
Patrick Benavoli1387bda2011-08-31 11:23:24 +020067#include "AutoLock.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020068#include <strings.h>
69#include <dlfcn.h>
70#include <assert.h>
Patrick Benavoli065264a2011-11-20 15:46:41 +010071#include "ParameterHandle.h"
Patrick Benavoliee65e6d2011-11-20 18:52:24 +010072#include "LinearParameterAdaptation.h"
Patrick Benavoli68808c62012-02-02 17:12:41 +010073#include "EnumValuePair.h"
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +020074#include "Subsystem.h"
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020075#include "XmlFileDocSink.h"
76#include "XmlFileDocSource.h"
77#include "XmlStringDocSink.h"
Georges-Henri Baroncec86c12012-09-04 17:30:28 +020078#include "XmlStringDocSource.h"
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020079#include "XmlMemoryDocSink.h"
80#include "XmlMemoryDocSource.h"
Kevin Rocardace81f82012-12-11 16:19:17 +010081#include "Utility.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020082
83#define base CElement
84
85// Used for remote processor server creation
86typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler);
87
88// Global configuration file name (fixed)
89const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml";
90const char* gacSystemSchemasSubFolder = "Schemas";
91
92// Config File System looks normally like this:
93// ---------------------------------------------
Patrick Benavoli95ac0342011-11-07 20:32:51 +010094//├── <ParameterFrameworkConfiguration>.xml
Patrick Benavoli68a91282011-08-31 11:23:23 +020095//├── Schemas
96//│ └── *.xsd
97//├── Settings
98//│ └── <SystemClassName folder>*
99//│ ├── <ConfigurableDomains>.xml
100//│ └── <Settings>.bin?
101//└── Structure
102// └── <SystemClassName folder>*
103// ├── <SystemClassName>Class.xml
104// └── <Subsystem>.xml*
105// --------------------------------------------
106
107
108// Remote command parser array
Patrick Benavoli592ae562011-09-05 16:53:58 +0200109const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
Kevin Rocard3949b342013-05-24 18:43:53 +0200110
Patrick Benavoli592ae562011-09-05 16:53:58 +0200111 /// Version
Kevin Rocard3949b342013-05-24 18:43:53 +0200112 { "version", &CParameterMgr::versionCommandProcess, 0,
113 "", "Show version" },
114
Patrick Benavoli68a91282011-08-31 11:23:23 +0200115 /// Status
Kevin Rocard3949b342013-05-24 18:43:53 +0200116 { "status", &CParameterMgr::statusCommandProcess, 0, "",
117 "Show current status" },
118
Patrick Benavoli68a91282011-08-31 11:23:23 +0200119 /// Tuning Mode
Kevin Rocard3949b342013-05-24 18:43:53 +0200120 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1,
121 "on|off*", "Turn on or off Tuning Mode" },
122 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0,
123 "", "Show Tuning Mode" },
124
Patrick Benavoli68a91282011-08-31 11:23:23 +0200125 /// Value Space
Kevin Rocard3949b342013-05-24 18:43:53 +0200126 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1,
127 "raw|real*", "Assigns Value Space used for parameter value interpretation" },
128 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0,
129 "", "Show Value Space" },
130
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200131 /// Output Raw Format
Kevin Rocard3949b342013-05-24 18:43:53 +0200132 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1,
133 "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
134 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0,
135 "", "Show Output Raw Format" },
136
Patrick Benavoli68a91282011-08-31 11:23:23 +0200137 /// Sync
Kevin Rocard3949b342013-05-24 18:43:53 +0200138 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1,
139 "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
140 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0,
141 "", "Show Auto Sync state" },
142 { "sync", &CParameterMgr::syncCommmandProcess, 0,
143 "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
144
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200145 /// Criteria
Kevin Rocard3949b342013-05-24 18:43:53 +0200146 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0,
147 "[csv]", "List selection criteria" },
148
Patrick Benavoli68a91282011-08-31 11:23:23 +0200149 /// Domains
Kevin Rocard3949b342013-05-24 18:43:53 +0200150 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0,
151 "", "List configurable domains" },
152 { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0,
153 "", "Show all domains and configurations, including applicability conditions" },
154 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1,
155 "<domain>", "Create new configurable domain" },
156 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1,
157 "<domain>", "Delete configurable domain" },
158 { "deleteAllDomains", &CParameterMgr::deleteAllDomainsCommmandProcess, 0,
159 "", "Delete all configurable domains" },
160 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2,
161 "<domain> <new name>", "Rename configurable domain" },
162 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1,
163 "<domain> true|false*", "Set configurable domain sequence awareness" },
164 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1,
165 "<domain>", "Get configurable domain sequence awareness" },
166 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1,
167 "<domain>", "List elements associated to configurable domain" },
168 { "addElement", &CParameterMgr::addElementCommmandProcess, 2,
169 "<domain> <elem path>", "Associate element at given path to configurable domain" },
170 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2,
171 "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
172 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2,
173 "<domain> <elem path>", "Split configurable domain at given associated element path" },
174
Patrick Benavoli68a91282011-08-31 11:23:23 +0200175 /// Configurations
Kevin Rocard3949b342013-05-24 18:43:53 +0200176 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1,
177 "<domain>", "List domain configurations" },
178 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2,
179 "<domain> <configuration>", "Create new domain configuration" },
180 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2,
181 "<domain> <configuration>", "Delete domain configuration" },
182 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3,
183 "<domain> <configuration> <new name>", "Rename domain configuration" },
184 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2,
185 "<domain> <configuration>", "Save current settings into configuration" },
186 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2,
187 "<domain> <configuration>", "Restore current settings from configuration" },
188 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3,
189 "<domain> <configuration> <elem path list>",
190 "Set element application order for configuration" },
191 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2,
192 "<domain> <configuration>", "Get element application order for configuration" },
193 { "setRule", &CParameterMgr::setRuleCommmandProcess, 3,
194 "<domain> <configuration> <rule>", "Set configuration application rule" },
195 { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2,
196 "<domain> <configuration>", "Clear configuration application rule" },
197 { "getRule", &CParameterMgr::getRuleCommmandProcess, 2,
198 "<domain> <configuration>", "Get configuration application rule" },
199
Patrick Benavoli68a91282011-08-31 11:23:23 +0200200 /// Elements/Parameters
Kevin Rocard3949b342013-05-24 18:43:53 +0200201 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1,
202 "<elem path>|/", "List elements under element at given path or root" },
203 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1,
204 "<elem path>|/", "List parameters under element at given path or root" },
205 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1,
206 "<elem path>", "Dump structure and content of element at given path" },
207 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1,
208 "<elem path>", "Show size of element at given path" },
209 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1,
210 "<elem path>", "Show properties of element at given path" },
211 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1,
212 "<param path>", "Get value for parameter at given path" },
213 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2,
214 "<param path> <value>", "Set value for parameter at given path" },
215 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1,
216 "<elem path>", "List domain(s) element at given path belongs to" },
217 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1,
218 "<elem path>", "List domain(s) element at given path is associated to" },
219 { "getConfigurationParameter", &CParameterMgr::getConfigurationParameterCommmandProcess, 3,
220 "<domain> <configuration> <param path>",
221 "Get value for parameter at given path from configuration" },
222 { "setConfigurationParameter", &CParameterMgr::setConfigurationParameterCommmandProcess, 4,
223 "<domain> <configuration> <param path> <value>",
224 "Set value for parameter at given path to configuration" },
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200225 { "showMapping", &CParameterMgr::showMappingCommmandProcess, 1,
226 "<elem path>", "Show mapping for an element at given path" },
Kevin Rocard3949b342013-05-24 18:43:53 +0200227
Patrick Benavoli68a91282011-08-31 11:23:23 +0200228 /// Browse
Kevin Rocard3949b342013-05-24 18:43:53 +0200229 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0,
230 "", "List element sub-trees associated to at least one configurable domain" },
231 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0,
232 "", "List element sub-trees contained in more than one configurable domain" },
233 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0,
234 "", "List element sub-trees owned by no configurable domain" },
235
Patrick Benavoli68a91282011-08-31 11:23:23 +0200236 /// Settings Import/Export
Kevin Rocard3949b342013-05-24 18:43:53 +0200237 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1,
238 "<file path> ", "Export domains to XML file" },
239 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1,
240 "<file path>", "Import domains from XML file" },
241 { "exportDomainsWithSettingsXML",
242 &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1,
243 "<file path> ", "Export domains including settings to XML file" },
244 { "importDomainsWithSettingsXML",
245 &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1,
246 "<file path>", "Import domains including settings from XML file" },
247 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1,
248 "<file path>", "Export settings to binary file" },
249 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1,
250 "<file path>", "Import settings from binary file" },
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200251 { "getDomainsWithSettingsXML",
252 &CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess, 0,
Kevin Rocard3949b342013-05-24 18:43:53 +0200253 "", "Print domains including settings as XML" },
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200254 { "setDomainsWithSettingsXML",
255 &CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess, 1,
256 "<xml configurable domains>", "Import domains including settings from XML string" },
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200257 /// Structure Export
Kevin Rocard3949b342013-05-24 18:43:53 +0200258 { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 ,
Kevin Rocardc0211572013-06-18 11:34:53 +0200259 "", "Print parameter structure as XML" },
260 /// Deprecated Commands
261 { "getDomainsXML",
262 &CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess, 0,
263 "", "DEPRECATED COMMAND, please use getDomainsWithSettingsXML" },
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200264
Patrick Benavoli68a91282011-08-31 11:23:23 +0200265};
Kevin Rocard3949b342013-05-24 18:43:53 +0200266
Patrick Benavoli68a91282011-08-31 11:23:23 +0200267// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200268const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200269
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100270CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200271 _bTuningModeIsOn(false),
272 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200273 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200274 _bAutoSyncOn(true),
275 _pMainParameterBlackboard(new CParameterBlackboard),
276 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100277 _strXmlConfigurationFilePath(strConfigurationFilePath),
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100278 _pSubsystemPlugins(NULL),
Renaud de Chivre1b8b3ca2013-12-13 15:09:44 +0100279 _handleLibRemoteProcessor(NULL),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200280 _uiStructureChecksum(0),
281 _pRemoteProcessorServer(NULL),
282 _uiMaxCommandUsageLength(0),
283 _pLogger(NULL),
Kevin Rocardecf93102013-07-10 18:28:10 +0200284 _uiLogDepth(0),
Kevin Rocardd6909eb2013-07-18 09:13:51 +0200285 _bFailOnMissingSubsystem(true),
286 _bFailOnFailedSettingsLoad(true)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200287{
288 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100289 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
290 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200291
292 // Deal with children
293 addChild(new CParameterFrameworkConfiguration);
294 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100295 addChild(new CSystemClass);
296 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200297
298 // Feed element library
299 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200300
301 _pCommandHandler = new CCommandHandler(this);
302
303 // Add command parsers
304 uint32_t uiRemoteCommandParserItem;
305
306 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
307
308 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
309
310 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
311 pRemoteCommandParserItem->_pfnParser,
312 pRemoteCommandParserItem->_uiMinArgumentCount,
313 pRemoteCommandParserItem->_pcHelp,
314 pRemoteCommandParserItem->_pcDescription);
315 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100316
317 // Configuration file folder
318 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
319
320 assert(uiSlashPos != (uint32_t)-1);
321
322 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
323
324 // Schema absolute folder location
325 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200326}
327
328CParameterMgr::~CParameterMgr()
329{
330 // Children
331 delete _pRemoteProcessorServer;
Frederic Boisnard31242302012-04-26 17:07:34 +0200332 delete _pCommandHandler;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200333 delete _pMainParameterBlackboard;
334 delete _pElementLibrarySet;
335
Renaud de Chivre1b8b3ca2013-12-13 15:09:44 +0100336 // Close remote processor library
337 if (_handleLibRemoteProcessor != NULL) {
338 dlclose(_handleLibRemoteProcessor);
339 }
340
Patrick Benavoli68a91282011-08-31 11:23:23 +0200341 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100342 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200343}
344
345string CParameterMgr::getKind() const
346{
347 return "ParameterMgr";
348}
349
350// Logging
351void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
352{
353 _pLogger = pLogger;
354}
355
356// Logging
Kevin Rocardace81f82012-12-11 16:19:17 +0100357void CParameterMgr::doLog(bool bIsWarning, const string& strLog) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200358{
359 if (_pLogger) {
360
361 // Nest
362 string strIndent;
363
364 // Level
365 uint32_t uiNbIndents = _uiLogDepth;
366
367 while (uiNbIndents--) {
368
369 strIndent += " ";
370 }
371
372 // Log
Kevin Rocardace81f82012-12-11 16:19:17 +0100373 _pLogger->log(bIsWarning, strIndent + strLog);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200374 }
375}
376
377void CParameterMgr::nestLog() const
378{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200379 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200380}
381
382void CParameterMgr::unnestLog() const
383{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200384 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200385}
386
Patrick Benavoli63499d42011-10-24 18:50:03 +0200387// Version
388string CParameterMgr::getVersion() const
389{
390 string strVersion;
391
392 // Major
393 strVersion = toString(guiEditionMajor) + ".";
394 // Minor
395 strVersion += toString(guiEditionMinor) + ".";
396 // Revision
397 strVersion += toString(guiRevision);
398
399 return strVersion;
400}
401
Patrick Benavoli68a91282011-08-31 11:23:23 +0200402bool CParameterMgr::load(string& strError)
403{
404 CAutoLog autoLog(this, "Loading");
405
406 // Load Framework configuration
407 if (!loadFrameworkConfiguration(strError)) {
408
409 return false;
410 }
411
412 // Load subsystems
Kevin Rocardecf93102013-07-10 18:28:10 +0200413 if (!getSystemClass()->loadSubsystems(strError,
414 _pSubsystemPlugins, !_bFailOnMissingSubsystem)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200415
416 return false;
417 }
418
419 // Load structure
420 if (!loadStructure(strError)) {
421
422 return false;
423 }
424
425 // Load settings
426 if (!loadSettings(strError)) {
427
428 return false;
429 }
430
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200431 // Back synchronization for areas in parameter blackboard not covered by any domain
Kevin Rocardace81f82012-12-11 16:19:17 +0100432 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer();
Patrick Benavoli68a91282011-08-31 11:23:23 +0200433
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200434 // Back-synchronize
Kevin Rocard57096bd2012-11-30 11:24:20 +0100435 {
436 CAutoLog autoLog(this, "Main blackboard back synchronization");
437
Kevin Rocard5d6e05a2013-01-21 15:57:45 +0100438 pBackSynchronizer->sync();
Kevin Rocard57096bd2012-11-30 11:24:20 +0100439
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200440 // Get rid of back synchronizer
441 delete pBackSynchronizer;
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200442 }
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200443
444 // We're done loading the settings and back synchronizing
445 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
446
447 // We need to ensure all domains are valid
448 pConfigurableDomains->validate(_pMainParameterBlackboard);
449
Kevin Rocard7f265822012-12-07 18:51:22 +0100450 // Log selection criterion states
451 {
452 CAutoLog autoLog(this, "Criterion states");
453
454 const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria();
455
456 list<string> lstrSelectionCriteron;
457 selectionCriteria->listSelectionCriteria(lstrSelectionCriteron, true, false);
458
Kevin Rocard36299362013-02-04 14:57:47 +0100459 log_table(false, lstrSelectionCriteron);
Kevin Rocard7f265822012-12-07 18:51:22 +0100460 }
461
Kevin Rocard2fbe6e82013-03-26 17:09:29 +0100462 // Subsystem can not ask for resync as they have not been synced yet
463 getSystemClass()->cleanSubsystemsNeedToResync();
464
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100465 // At initialization, check subsystems that need resync
466 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200467
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200468 // Start remote processor server if appropriate
469 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200470}
471
472bool CParameterMgr::loadFrameworkConfiguration(string& strError)
473{
474 CAutoLog autoLog(this, "Loading framework configuration");
475
Patrick Benavoli68a91282011-08-31 11:23:23 +0200476 // Parse Structure XML file
477 CXmlElementSerializingContext elementSerializingContext(strError);
478
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100479 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200480
481 return false;
482 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100483 // Set class name to system class and configurable domains
484 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
485 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
486
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100487 // Get subsystem plugins elements
488 _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200489
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100490 if (!_pSubsystemPlugins) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200491
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100492 strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element";
Patrick Benavoli68a91282011-08-31 11:23:23 +0200493
494 return false;
495 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200496
Patrick Benavoli68a91282011-08-31 11:23:23 +0200497 // Log tuning availability
Kevin Rocardace81f82012-12-11 16:19:17 +0100498 log_info("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200499
500 return true;
501}
502
503bool CParameterMgr::loadStructure(string& strError)
504{
505 // Retrieve system to load structure to
506 CSystemClass* pSystemClass = getSystemClass();
507
Kevin Rocarde25ee792013-04-22 17:46:28 +0200508 log_info("Loading " + pSystemClass->getName() + " system class structure");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200509
510 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100511 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200512
513 if (!pStructureDescriptionFileLocation) {
514
515 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
516
517 return false;
518 }
519
520 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100521 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200522
523 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100524 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200525
526 // Parse Structure XML file
527 CXmlParameterSerializingContext parameterBuildContext(strError);
528
Kevin Rocard57096bd2012-11-30 11:24:20 +0100529 CAutoLog autolog(pSystemClass, "Importing system structure from file " + strXmlStructureFilePath);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200530
Patrick Benavoli68a91282011-08-31 11:23:23 +0200531 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
532
533 return false;
534 }
535
536 // Initialize offsets
537 pSystemClass->setOffset(0);
538
539 // Initialize main blackboard's size
540 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
541
542 return true;
543}
544
545bool CParameterMgr::loadSettings(string& strError)
546{
Kevin Rocardd6909eb2013-07-18 09:13:51 +0200547 string strLoadError;
548 bool success = loadSettingsFromConfigFile(strLoadError);
549
550 if (!success && !_bFailOnFailedSettingsLoad) {
551 // Load can not fail, ie continue but log the load errors
552 log_info(strLoadError);
553 log_info("Failed to load settings, continue without domains.");
554 success = true;
555 }
556
557 if (!success) {
558 // Propagate the litteral error only if the function fails
559 strError = strLoadError;
560 return false;
561 }
562
563 return true;
564}
565
566bool CParameterMgr::loadSettingsFromConfigFile(string& strError)
567{
Patrick Benavoli68a91282011-08-31 11:23:23 +0200568 CAutoLog autoLog(this, "Loading settings");
569
570 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100571 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200572
573 if (!pParameterConfigurationGroup) {
574
575 // No settings to load
576
577 return true;
578 }
579 // Get binary settings file location
580 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
581
582 string strXmlBinarySettingsFilePath;
583
584 if (pBinarySettingsFileLocation) {
585
586 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100587 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200588 }
589
590 // Get configurable domains element
591 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
592
593 if (!pConfigurableDomainsFileLocation) {
594
595 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
596
597 return false;
Kevin Rocardd6909eb2013-07-18 09:13:51 +0200598 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200599 // Get destination root element
600 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
601
602 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100603 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200604
605 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100606 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200607
608 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
609 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
610
611 // Selection criteria definition for rule creation
612 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
613
Patrick Benavoli63499d42011-10-24 18:50:03 +0200614 // Auto validation of configurations if no binary settings provided
615 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
616
Kevin Rocardace81f82012-12-11 16:19:17 +0100617 log_info("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200618
Patrick Benavoli68a91282011-08-31 11:23:23 +0200619 // Do parse
620 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
621
622 return false;
623 }
624 // We have loaded the whole system structure, compute checksum
625 const CSystemClass* pSystemClass = getConstSystemClass();
626 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
627
628 // Load binary settings if any provided
629 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
630
631 return false;
632 }
633
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200634 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200635}
636
637// XML parsing
638bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
639{
640 // Init serializing context
641 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
642
643 // Get Schema file associated to root element
644 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
645
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200646 CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200647
648 // Start clean
649 pRootElement->clean();
650
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200651 CXmlMemoryDocSink memorySink(pRootElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200652
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200653 if (!memorySink.process(fileDocSource, elementSerializingContext)) {
654 //Cleanup
Patrick Benavoli68a91282011-08-31 11:23:23 +0200655 pRootElement->clean();
656
657 return false;
658 }
659
Patrick Benavoli68a91282011-08-31 11:23:23 +0200660 return true;
661}
662
663// Init
664bool CParameterMgr::init(string& strError)
665{
666 return base::init(strError);
667}
668
669// Selection criteria interface
670CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
671{
672 // Propagate
673 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
674}
675
676CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
677{
678 // Propagate
679 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
680}
681
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200682// Selection criterion retrieval
683CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200684{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200685 // Propagate
686 return getSelectionCriteria()->getSelectionCriterion(strName);
687}
688
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100689// Configuration application
Kevin Rocardace81f82012-12-11 16:19:17 +0100690void CParameterMgr::applyConfigurations()
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200691{
692 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200693
694 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100695 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200696
697 if (!_bTuningModeIsOn) {
698
699 // Apply configuration(s)
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100700 doApplyConfigurations(false);
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +0200701 } else {
702
Kevin Rocardace81f82012-12-11 16:19:17 +0100703 log_warning("Configurations were not applied because the TuningMode is on");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200704 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200705}
706
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200707// Get the configurableElement corresponding to the given path
708const CConfigurableElement* CParameterMgr::getConfigurableElement(const string& strPath,
709 string& strError) const
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200710{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100711 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200712
Patrick Benavoli065264a2011-11-20 15:46:41 +0100713 // Nagivate through system class
714 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
715
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100716 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100717 }
718
719 // Find element
720 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
721
722 if (!pElement) {
723
Kevin Rocard4c3f8d82013-11-21 12:16:28 +0100724 strError = "Path not found: " + strPath;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100725
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100726 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100727 }
728
729 // Check found element is a parameter
730 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
731
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200732 return pConfigurableElement;
733}
734
735// Dynamic parameter handling
736CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
737{
738 const CConfigurableElement* pConfigurableElement = getConfigurableElement(strPath, strError);
739
740 if (!pConfigurableElement) {
741
742 // Element not found
Kevin Rocard4c3f8d82013-11-21 12:16:28 +0100743 strError = "Element not found: " + strPath;
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200744 return NULL;
745 }
746
Patrick Benavoli065264a2011-11-20 15:46:41 +0100747 if (!pConfigurableElement->isParameter()) {
748
749 // Element is not parameter
Kevin Rocard4c3f8d82013-11-21 12:16:28 +0100750 strError = "Not a parameter: " + strPath;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100751
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100752 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100753 }
754
755 // Convert as parameter and return new handle
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +0200756 return new CParameterHandle(static_cast<const CBaseParameter*>(pConfigurableElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200757}
758
Kevin Rocardecf93102013-07-10 18:28:10 +0200759void CParameterMgr::setFailureOnMissingSubsystem(bool bFail)
760{
761 _bFailOnMissingSubsystem = bFail;
762}
763
764bool CParameterMgr::getFailureOnMissingSubsystem() const
765{
766 return _bFailOnMissingSubsystem;
767}
Kevin Rocardd6909eb2013-07-18 09:13:51 +0200768
769void CParameterMgr::setFailureOnFailedSettingsLoad(bool bFail)
770{
771 _bFailOnFailedSettingsLoad = bFail;
772}
773bool CParameterMgr::getFailureOnFailedSettingsLoad()
774{
775 return _bFailOnFailedSettingsLoad;
776}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200777/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200778/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200779CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200780{
781 (void)remoteCommand;
782
Patrick Benavoli63499d42011-10-24 18:50:03 +0200783 // Show version
784 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200785
Patrick Benavoli63499d42011-10-24 18:50:03 +0200786 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200787}
788
Patrick Benavoli68a91282011-08-31 11:23:23 +0200789/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200790CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200791{
792 (void)remoteCommand;
793 // System class
794 const CSystemClass* pSystemClass = getSystemClass();
795
Patrick Benavoli68a91282011-08-31 11:23:23 +0200796 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200797 /// General section
798 appendTitle(strResult, "General:");
799 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200800 strResult += "System Class: ";
801 strResult += pSystemClass->getName();
802 strResult += "\n";
803
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200804 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200805 strResult += "Tuning Mode: ";
806 strResult += tuningModeOn() ? "on" : "off";
807 strResult += "\n";
808
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200809 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200810 strResult += "Value Space: ";
811 strResult += valueSpaceIsRaw() ? "raw" : "real";
812 strResult += "\n";
813
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200814 // Output raw format
815 strResult += "Output Raw Format: ";
816 strResult += outputRawFormatIsHex() ? "hex" : "dec";
817 strResult += "\n";
818
819 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200820 strResult += "Auto Sync: ";
821 strResult += autoSyncOn() ? "on" : "off";
822 strResult += "\n";
823
824 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200825 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200826 string strSubsystemList;
827 pSystemClass->listChildrenPaths(strSubsystemList);
828 strResult += strSubsystemList;
829
830 /// Last applied configurations
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200831 appendTitle(strResult, "Last Applied [Pending] Configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200832 string strLastAppliedConfigurations;
833 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
834 strResult += strLastAppliedConfigurations;
835
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200836 /// Criteria states
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200837 appendTitle(strResult, "Selection Criteria:");
Kevin Rocard7f265822012-12-07 18:51:22 +0100838 list<string> lstrSelectionCriteria;
839 getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true);
840 // Concatenate the criterion list as the command result
Frederic Boisnard390b36d2013-05-23 15:28:31 +0200841 string strCriteriaStates;
842 CUtility::asString(lstrSelectionCriteria, strCriteriaStates);
843 strResult += strCriteriaStates;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200844
Patrick Benavoli63499d42011-10-24 18:50:03 +0200845 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200846}
847
848/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200849CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200850{
851 if (remoteCommand.getArgument(0) == "on") {
852
853 if (setTuningMode(true, strResult)) {
854
Patrick Benavoli63499d42011-10-24 18:50:03 +0200855 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200856 }
857 } else if (remoteCommand.getArgument(0) == "off") {
858
859 if (setTuningMode(false, strResult)) {
860
Patrick Benavoli63499d42011-10-24 18:50:03 +0200861 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200862 }
863 } else {
864 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200865 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200866 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200867 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200868}
869
Patrick Benavoli63499d42011-10-24 18:50:03 +0200870CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200871{
872 (void)remoteCommand;
873
874 strResult = tuningModeOn() ? "on" : "off";
875
Patrick Benavoli63499d42011-10-24 18:50:03 +0200876 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200877}
878
879/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200880CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200881{
882 (void)strResult;
883
884 if (remoteCommand.getArgument(0) == "raw") {
885
886 setValueSpace(true);
887
Patrick Benavoli63499d42011-10-24 18:50:03 +0200888 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200889
890 } else if (remoteCommand.getArgument(0) == "real") {
891
892 setValueSpace(false);
893
Patrick Benavoli63499d42011-10-24 18:50:03 +0200894 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200895
896 } else {
897 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200898 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200899 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200900 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200901}
902
Patrick Benavoli63499d42011-10-24 18:50:03 +0200903CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200904{
905 (void)remoteCommand;
906
907 strResult = valueSpaceIsRaw() ? "raw" : "real";
908
Patrick Benavoli63499d42011-10-24 18:50:03 +0200909 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200910}
911
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200912/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200913CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200914{
915 (void)strResult;
916
917 if (remoteCommand.getArgument(0) == "hex") {
918
919 setOutputRawFormat(true);
920
Patrick Benavoli63499d42011-10-24 18:50:03 +0200921 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200922
923 } else if (remoteCommand.getArgument(0) == "dec") {
924
925 setOutputRawFormat(false);
926
Patrick Benavoli63499d42011-10-24 18:50:03 +0200927 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200928
929 } else {
930 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200931 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200932 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200933 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200934}
935
Patrick Benavoli63499d42011-10-24 18:50:03 +0200936CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200937{
938 (void)remoteCommand;
939
940 strResult = outputRawFormatIsHex() ? "hex" : "dec";
941
Patrick Benavoli63499d42011-10-24 18:50:03 +0200942 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200943}
944
Patrick Benavoli68a91282011-08-31 11:23:23 +0200945/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200946CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200947{
948 if (remoteCommand.getArgument(0) == "on") {
949
950 if (setAutoSync(true, strResult)) {
951
Patrick Benavoli63499d42011-10-24 18:50:03 +0200952 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200953 }
954 } else if (remoteCommand.getArgument(0) == "off") {
955
956 if (setAutoSync(false, strResult)) {
957
Patrick Benavoli63499d42011-10-24 18:50:03 +0200958 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200959 }
960 } else {
961 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200962 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200963 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200964 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200965}
966
Patrick Benavoli63499d42011-10-24 18:50:03 +0200967CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200968{
969 (void)remoteCommand;
970
971 strResult = autoSyncOn() ? "on" : "off";
972
Patrick Benavoli63499d42011-10-24 18:50:03 +0200973 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200974}
975
Patrick Benavoli63499d42011-10-24 18:50:03 +0200976CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200977{
978 (void)remoteCommand;
979
Patrick Benavoli63499d42011-10-24 18:50:03 +0200980 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200981}
982
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200983/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200984CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200985{
986 (void)remoteCommand;
987
Kevin Rocard4eae8272013-04-18 19:12:46 +0200988 bool humanReadable = true;
Kevin Rocard7f265822012-12-07 18:51:22 +0100989
Kevin Rocard4eae8272013-04-18 19:12:46 +0200990 // Look for optional arguments
991 if (remoteCommand.getArgumentCount() >= 1) {
992
993 // If csv is provided, format the criterion list in Commas Separated Value pairs
994 if (remoteCommand.getArgument(0) == "csv") {
995 humanReadable = false;
996 } else {
997 return CCommandHandler::EShowUsage;
998 }
999 }
1000
1001 list<string> lstrResult;
1002 getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
Kevin Rocard7f265822012-12-07 18:51:22 +01001003
1004 // Concatenate the criterion list as the command result
Frederic Boisnard390b36d2013-05-23 15:28:31 +02001005 CUtility::asString(lstrResult, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001006
Patrick Benavoli63499d42011-10-24 18:50:03 +02001007 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001008}
Patrick Benavoli68a91282011-08-31 11:23:23 +02001009
1010/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +02001011CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001012{
1013 (void)remoteCommand;
1014
Patrick Benavoli63499d42011-10-24 18:50:03 +02001015 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001016
Patrick Benavoli63499d42011-10-24 18:50:03 +02001017 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001018}
1019
Patrick Benavoli63499d42011-10-24 18:50:03 +02001020CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001021{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001022 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001023}
1024
Patrick Benavoli63499d42011-10-24 18:50:03 +02001025CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001026{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001027 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001028}
1029
Kevin Rocard170f0a42012-06-18 13:56:05 +02001030CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1031{
1032 (void)remoteCommand;
1033
1034 return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1035}
1036
Patrick Benavoli63499d42011-10-24 18:50:03 +02001037CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001038{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001039 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001040}
1041
Patrick Benavoli63499d42011-10-24 18:50:03 +02001042CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001043{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001044 // Check tuning mode
1045 if (!checkTuningModeOn(strResult)) {
1046
1047 return CCommandHandler::EFailed;
1048 }
1049
1050 // Set property
1051 bool bSequenceAware;
1052
1053 if (remoteCommand.getArgument(1) == "true") {
1054
1055 bSequenceAware = true;
1056
1057 } else if (remoteCommand.getArgument(1) == "false") {
1058
1059 bSequenceAware = false;
1060
1061 } else {
1062 // Show usage
1063 return CCommandHandler::EShowUsage;
1064 }
1065
1066 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001067}
1068
Patrick Benavoli63499d42011-10-24 18:50:03 +02001069CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001070{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001071 // Get property
1072 bool bSequenceAware;
1073
1074 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
1075
1076 return CCommandHandler::EFailed;
1077 }
1078
1079 strResult = bSequenceAware ? "true" : "false";
1080
1081 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001082}
1083
Patrick Benavoli63499d42011-10-24 18:50:03 +02001084CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001085{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001086 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001087}
1088
Patrick Benavoli63499d42011-10-24 18:50:03 +02001089CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001090{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001091 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1092}
1093
1094CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1095{
1096 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1097}
1098
1099CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1100{
1101 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001102}
1103
1104/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +02001105CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001106{
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001107 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1108}
1109
1110CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1111{
1112 (void)remoteCommand;
1113
1114 // Dummy error context
1115 string strError;
1116 CErrorContext errorContext(strError);
1117
1118 // Dump
1119 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
1120
1121 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001122}
1123
Patrick Benavoli63499d42011-10-24 18:50:03 +02001124CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001125{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001126 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001127}
1128
Patrick Benavoli63499d42011-10-24 18:50:03 +02001129CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001130{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001131 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001132}
1133
Patrick Benavoli63499d42011-10-24 18:50:03 +02001134CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001135{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001136 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001137}
1138
Patrick Benavoli63499d42011-10-24 18:50:03 +02001139CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001140{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001141 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001142}
1143
Patrick Benavoli63499d42011-10-24 18:50:03 +02001144CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001145{
Kevin Rocardace81f82012-12-11 16:19:17 +01001146 list<string> lstrResult;
1147 if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) {
1148 //Concatenate the error list as the command result
Frederic Boisnard390b36d2013-05-23 15:28:31 +02001149 CUtility::asString(lstrResult, strResult);
Kevin Rocardace81f82012-12-11 16:19:17 +01001150
1151 return CCommandHandler::EFailed;
1152 }
1153 return CCommandHandler::EDone;
Patrick Benavoli63499d42011-10-24 18:50:03 +02001154}
1155
1156CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1157{
1158 // Check tuning mode
1159 if (!checkTuningModeOn(strResult)) {
1160
1161 return CCommandHandler::EFailed;
1162 }
1163
1164 // Build configurable element path list
1165 vector<string> astrNewElementSequence;
1166
1167 uint32_t uiArgument;
1168
1169 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1170
1171 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1172 }
1173
1174 // Delegate to configurable domains
1175 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1176}
1177
1178CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1179{
1180 // Delegate to configurable domains
1181 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001182}
1183
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001184CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1185{
1186 // Delegate to configurable domains
1187 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1188}
1189
1190CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1191{
1192 // Delegate to configurable domains
1193 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1194}
1195
1196CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1197{
1198 // Delegate to configurable domains
1199 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1200}
1201
Patrick Benavoli68a91282011-08-31 11:23:23 +02001202/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001203CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001204{
1205 CElementLocator elementLocator(getSystemClass(), false);
1206
1207 CElement* pLocatedElement = NULL;
1208
1209 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1210
Patrick Benavoli63499d42011-10-24 18:50:03 +02001211 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001212 }
1213
1214 strResult = string("\n");
1215
1216 if (!pLocatedElement) {
1217
1218 // List from root folder
1219
1220 // Return system class qualified name
1221 pLocatedElement = getSystemClass();
1222 }
1223
1224 // Return sub-elements
1225 strResult += pLocatedElement->listQualifiedPaths(false);
1226
Patrick Benavoli63499d42011-10-24 18:50:03 +02001227 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001228}
1229
1230/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001231CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001232{
1233 CElementLocator elementLocator(getSystemClass(), false);
1234
1235 CElement* pLocatedElement = NULL;
1236
1237 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1238
Patrick Benavoli63499d42011-10-24 18:50:03 +02001239 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001240 }
1241
1242 strResult = string("\n");
1243
1244 if (!pLocatedElement) {
1245
1246 // List from root folder
1247
1248 // Return system class qualified name
1249 pLocatedElement = getSystemClass();
1250 }
1251
1252 // Return sub-elements
1253 strResult += pLocatedElement->listQualifiedPaths(true);
1254
Patrick Benavoli63499d42011-10-24 18:50:03 +02001255 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001256}
1257
Patrick Benavoli63499d42011-10-24 18:50:03 +02001258CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001259{
1260 CElementLocator elementLocator(getSystemClass());
1261
1262 CElement* pLocatedElement = NULL;
1263
1264 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1265
Patrick Benavoli63499d42011-10-24 18:50:03 +02001266 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001267 }
1268
1269 string strError;
1270
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001271 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001272
1273 // Dump elements
1274 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1275
Patrick Benavoli63499d42011-10-24 18:50:03 +02001276 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001277}
1278
Patrick Benavoli63499d42011-10-24 18:50:03 +02001279CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001280{
1281 CElementLocator elementLocator(getSystemClass());
1282
1283 CElement* pLocatedElement = NULL;
1284
1285 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1286
Patrick Benavoli63499d42011-10-24 18:50:03 +02001287 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001288 }
1289
1290 // Converted to actual sizable element
1291 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1292
1293 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001294 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001295
Patrick Benavoli63499d42011-10-24 18:50:03 +02001296 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001297}
1298
Patrick Benavoli63499d42011-10-24 18:50:03 +02001299CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001300{
1301 CElementLocator elementLocator(getSystemClass());
1302
1303 CElement* pLocatedElement = NULL;
1304
1305 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1306
Patrick Benavoli63499d42011-10-24 18:50:03 +02001307 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001308 }
1309
1310 // Convert element
1311 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1312
1313 // Return element properties
1314 pConfigurableElement->showProperties(strResult);
1315
Patrick Benavoli63499d42011-10-24 18:50:03 +02001316 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001317}
1318
Patrick Benavoli63499d42011-10-24 18:50:03 +02001319CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001320{
1321 string strValue;
1322
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001323 if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001324
Patrick Benavoli63499d42011-10-24 18:50:03 +02001325 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001326 }
1327 // Succeeded
1328 strResult = strValue;
1329
Patrick Benavoli63499d42011-10-24 18:50:03 +02001330 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001331}
1332
Patrick Benavoli63499d42011-10-24 18:50:03 +02001333CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001334{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001335 // Check tuning mode
1336 if (!checkTuningModeOn(strResult)) {
1337
1338 return CCommandHandler::EFailed;
1339 }
1340 // Get value to set
1341 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1342
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001343 return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001344}
1345
Patrick Benavoli63499d42011-10-24 18:50:03 +02001346CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001347{
1348 CElementLocator elementLocator(getSystemClass());
1349
1350 CElement* pLocatedElement = NULL;
1351
1352 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1353
Patrick Benavoli63499d42011-10-24 18:50:03 +02001354 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001355 }
1356
1357 // Convert element
1358 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1359
1360 // Return element belonging domains
1361 pConfigurableElement->listBelongingDomains(strResult);
1362
Patrick Benavoli63499d42011-10-24 18:50:03 +02001363 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001364}
1365
Patrick Benavoli63499d42011-10-24 18:50:03 +02001366CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001367{
1368 CElementLocator elementLocator(getSystemClass());
1369
1370 CElement* pLocatedElement = NULL;
1371
1372 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1373
Patrick Benavoli63499d42011-10-24 18:50:03 +02001374 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001375 }
1376
1377 // Convert element
1378 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1379
1380 // Return element belonging domains
1381 pConfigurableElement->listAssociatedDomains(strResult);
1382
Patrick Benavoli63499d42011-10-24 18:50:03 +02001383 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001384}
1385
Patrick Benavoli63499d42011-10-24 18:50:03 +02001386CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001387{
1388 (void)remoteCommand;
1389
1390 getConfigurableDomains()->listAssociatedElements(strResult);
1391
Patrick Benavoli63499d42011-10-24 18:50:03 +02001392 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001393}
1394
Patrick Benavoli63499d42011-10-24 18:50:03 +02001395CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001396{
1397 (void)remoteCommand;
1398
1399 getConfigurableDomains()->listConflictingElements(strResult);
1400
Patrick Benavoli63499d42011-10-24 18:50:03 +02001401 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001402}
1403
Patrick Benavoli63499d42011-10-24 18:50:03 +02001404CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001405{
1406 (void)remoteCommand;
1407
1408 getSystemClass()->listRogueElements(strResult);
1409
Patrick Benavoli63499d42011-10-24 18:50:03 +02001410 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001411}
1412
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001413CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1414{
1415 string strOutputValue;
1416 string strError;
1417
1418 if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) {
1419
1420 strResult = strError;
1421 return CCommandHandler::EFailed;
1422 }
1423 // Succeeded
1424 strResult = strOutputValue;
1425
1426 return CCommandHandler::ESucceeded;
1427}
1428
1429CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1430{
1431 // Get value to set
1432 string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3);
1433
1434 bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0),
1435 remoteCommand.getArgument(1),
1436 remoteCommand.getArgument(2),
1437 strValue, true, strResult);
1438
1439 return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed;
1440}
1441
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +02001442CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showMappingCommmandProcess(
1443 const IRemoteCommand& remoteCommand,
1444 string& strResult)
1445{
1446 if (!getParameterMapping(remoteCommand.getArgument(0), strResult)) {
1447
1448 return CCommandHandler::EFailed;
1449 }
1450
1451 return CCommandHandler::ESucceeded;
1452}
1453
Patrick Benavoli68a91282011-08-31 11:23:23 +02001454/// Settings Import/Export
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001455CParameterMgr::CCommandHandler::CommandStatus
1456 CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(
1457 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001458{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001459 string strFileName = remoteCommand.getArgument(0);
1460 return exportDomainsXml(strFileName, false, true, strResult) ?
1461 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001462}
1463
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001464CParameterMgr::CCommandHandler::CommandStatus
1465 CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(
1466 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001467{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001468 return importDomainsXml(remoteCommand.getArgument(0), false, true, strResult) ?
1469 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001470}
1471
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001472CParameterMgr::CCommandHandler::CommandStatus
1473 CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(
1474 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001475{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001476 string strFileName = remoteCommand.getArgument(0);
1477 return exportDomainsXml(strFileName, true, true, strResult) ?
1478 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001479}
1480
Patrick Benavoli63499d42011-10-24 18:50:03 +02001481CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001482{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001483 return importDomainsXml(remoteCommand.getArgument(0), true, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001484}
1485
Patrick Benavoli63499d42011-10-24 18:50:03 +02001486CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001487{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001488 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001489}
1490
Patrick Benavoli63499d42011-10-24 18:50:03 +02001491CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001492{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001493 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001494}
1495
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001496CParameterMgr::CCommandHandler::CommandStatus
1497 CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess(
1498 const IRemoteCommand& remoteCommand, string& strResult)
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001499{
1500 (void)remoteCommand;
1501
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001502 if (!exportDomainsXml(strResult, true, false, strResult)) {
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001503
1504 return CCommandHandler::EFailed;
1505 }
1506 // Succeeded
1507 return CCommandHandler::ESucceeded;
1508}
1509
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001510CParameterMgr::CCommandHandler::CommandStatus
1511 CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess(
1512 const IRemoteCommand& remoteCommand, string& strResult)
1513{
1514 return importDomainsXml(remoteCommand.getArgument(0), true, false, strResult) ?
1515 CCommandHandler::EDone : CCommandHandler::EFailed;
1516}
1517
1518CParameterMgr::CCommandHandler::CommandStatus
1519 CParameterMgr::getSystemClassXMLCommmandProcess(
1520 const IRemoteCommand& remoteCommand, string& strResult)
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001521{
1522 (void)remoteCommand;
1523
1524 if (!getSystemClassXMLString(strResult)) {
1525
1526 return CCommandHandler::EFailed;
1527 }
1528 // Succeeded
1529 return CCommandHandler::ESucceeded;
1530}
1531
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001532// User set/get parameters in main BlackBoard
1533bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError)
1534{
1535 // Define context
1536 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
1537
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001538 // Activate the auto synchronization with the hardware
1539 if (bSet) {
1540
1541 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1542 }
1543
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001544 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1545}
1546
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +02001547// User get parameter mapping
1548bool CParameterMgr::getParameterMapping(const string& strPath, string& strResult) const
1549{
1550 CPathNavigator pathNavigator(strPath);
1551
1552 // Nagivate through system class
1553 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strResult)) {
1554
1555 return false;
1556 }
1557
1558 // Get the ConfigurableElement corresponding to strPath
1559 const CConfigurableElement* pConfigurableElement = getConfigurableElement(strPath, strResult);
1560 if (!pConfigurableElement) {
1561
1562 return false;
1563 }
1564
1565 // Find the list of the ancestors of the current ConfigurableElement that have a mapping
1566 list<const CConfigurableElement*> configurableElementPath;
1567 pConfigurableElement->getListOfElementsWithMapping(configurableElementPath);
1568
1569 // Get the Subsystem containing the ConfigurableElement
1570 const CSubsystem* pSubsystem = pConfigurableElement->getBelongingSubsystem();
1571 if (!pSubsystem) {
1572
1573 strResult = "Unable to find the Subsystem containing the parameter";
1574 return false;
1575 }
1576
1577 // Fetch the mapping corresponding to the ConfigurableElement
1578 strResult = pSubsystem->getMapping(configurableElementPath);
1579
1580 return true;
1581}
1582
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001583// User set/get parameters in specific Configuration BlackBoard
1584bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError)
1585{
1586 CElementLocator elementLocator(getSystemClass());
1587
1588 CElement* pLocatedElement = NULL;
1589
1590 if (!elementLocator.locate(strPath, &pLocatedElement, strError)) {
1591
1592 return false;
1593 }
1594
1595 // Convert element
1596 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1597
1598 // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard
1599 uint32_t uiBaseOffset;
1600 bool bIsLastApplied;
1601
1602 CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
1603
1604 if (!pConfigurationBlackboard) {
1605
1606 return false;
1607 }
1608
1609 log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset);
1610
1611 /// Update the Configuration Blackboard
1612
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001613 // Define Configuration context using Base Offset and keep Auto Sync off to prevent access to HW
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001614 CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
1615
1616 // Access Value in the Configuration Blackboard
1617 if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) {
1618
1619 return false;
1620 }
1621
1622 /// If the Configuration is the last one applied, update the Main Blackboard as well
1623
1624 if (bIsLastApplied) {
1625
1626 // Define Main context
1627 parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
1628
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001629 // Activate the auto synchronization with the hardware
1630 if (bSet) {
1631
1632 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1633 }
1634
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001635 // Access Value in the Main Blackboard
1636 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1637 }
1638
1639 return true;
1640}
1641
Patrick Benavoli68a91282011-08-31 11:23:23 +02001642// User set/get parameters
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001643bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001644{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001645 // Lock state
1646 CAutoLock autoLock(&_blackboardMutex);
1647
1648 CPathNavigator pathNavigator(strPath);
1649
1650 // Nagivate through system class
1651 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001652
Frederic Boisnard6cae0ec2013-05-23 18:48:58 +02001653 parameterAccessContext.setError(strError);
1654
Patrick Benavoli68a91282011-08-31 11:23:23 +02001655 return false;
1656 }
1657
Patrick Benavoli065264a2011-11-20 15:46:41 +01001658 // Do the get
1659 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001660}
1661
1662// Tuning mode
1663bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1664{
1665 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001666 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001667
1668 strError = "Tuning prohibited";
1669
1670 return false;
1671 }
1672 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001673 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001674
1675 // Warn domains about exiting tuning mode
1676 if (!bOn && _bTuningModeIsOn) {
1677
1678 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001679 // Force-apply configurations
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01001680 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001681
Patrick Benavoli68a91282011-08-31 11:23:23 +02001682 // Turn auto sync back on
1683 _bAutoSyncOn = true;
1684 }
1685
1686 // Store
1687 _bTuningModeIsOn = bOn;
1688
Patrick Benavoli68a91282011-08-31 11:23:23 +02001689 return true;
1690}
1691
1692bool CParameterMgr::tuningModeOn() const
1693{
1694 return _bTuningModeIsOn;
1695}
1696
1697// Current value space for user set/get value interpretation
1698void CParameterMgr::setValueSpace(bool bIsRaw)
1699{
1700 _bValueSpaceIsRaw = bIsRaw;
1701}
1702
1703bool CParameterMgr::valueSpaceIsRaw()
1704{
1705 return _bValueSpaceIsRaw;
1706}
1707
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001708// Current Output Raw Format for user get value interpretation
1709void CParameterMgr::setOutputRawFormat(bool bIsHex)
1710{
1711 _bOutputRawFormatIsHex = bIsHex;
1712}
1713
1714bool CParameterMgr::outputRawFormatIsHex()
1715{
1716 return _bOutputRawFormatIsHex;
1717}
1718
Patrick Benavoli68a91282011-08-31 11:23:23 +02001719/// Sync
1720// Automatic hardware synchronization control (during tuning session)
1721bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1722{
1723 // Check tuning mode
1724 if (!checkTuningModeOn(strError)) {
1725
1726 return false;
1727 }
1728 // Warn domains about turning auto sync back on
1729 if (bAutoSyncOn && !_bAutoSyncOn) {
1730
Patrick Benavoli592ae562011-09-05 16:53:58 +02001731 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1732 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001733
1734 return false;
1735 }
1736 }
1737
1738 // Set Auto sync
1739 _bAutoSyncOn = bAutoSyncOn;
1740
1741 return true;
1742}
1743
1744bool CParameterMgr::autoSyncOn() const
1745{
1746 return _bAutoSyncOn;
1747}
1748
1749// Manual hardware synchronization control (during tuning session)
1750bool CParameterMgr::sync(string& strError)
1751{
1752 // Check tuning mode
1753 if (!checkTuningModeOn(strError)) {
1754
1755 return false;
1756 }
1757 // Warn domains about turning auto sync back on
1758 if (_bAutoSyncOn) {
1759
1760 strError = "Feature unavailable when Auto Sync is on";
1761
1762 return false;
1763 }
1764
1765 // Get syncer set
1766 CSyncerSet syncerSet;
1767 // ... from system class
1768 getConstSystemClass()->fillSyncerSet(syncerSet);
Kevin Rocardace81f82012-12-11 16:19:17 +01001769
Patrick Benavoli68a91282011-08-31 11:23:23 +02001770 // Sync
Kevin Rocardace81f82012-12-11 16:19:17 +01001771 list<string> lstrError;
1772 if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){
1773
Frederic Boisnard390b36d2013-05-23 15:28:31 +02001774 CUtility::asString(lstrError, strError);
Kevin Rocardace81f82012-12-11 16:19:17 +01001775 return false;
1776 };
1777
1778 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001779}
1780
1781// Content dump
1782void CParameterMgr::logStructureContent(string& strContent) const
1783{
1784 string strError;
1785
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001786 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001787
1788 dumpContent(strContent, parameterAccessContext);
1789}
1790
1791// Configuration/Domains handling
1792bool CParameterMgr::createDomain(const string& strName, string& strError)
1793{
1794 // Check tuning mode
1795 if (!checkTuningModeOn(strError)) {
1796
1797 return false;
1798 }
1799
1800 // Delegate to configurable domains
1801 return getConfigurableDomains()->createDomain(strName, strError);
1802}
1803
1804bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1805{
1806 // Check tuning mode
1807 if (!checkTuningModeOn(strError)) {
1808
1809 return false;
1810 }
1811
1812 // Delegate to configurable domains
1813 return getConfigurableDomains()->deleteDomain(strName, strError);
1814}
1815
Kevin Rocard170f0a42012-06-18 13:56:05 +02001816bool CParameterMgr::deleteAllDomains(string& strError)
1817{
1818 // Check tuning mode
1819 if (!checkTuningModeOn(strError)) {
1820
1821 return false;
1822 }
1823
1824 // Delegate to configurable domains
1825 getConfigurableDomains()->deleteAllDomains();
1826
1827 return true;
1828}
1829
Patrick Benavoli68a91282011-08-31 11:23:23 +02001830bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1831{
1832 // Check tuning mode
1833 if (!checkTuningModeOn(strError)) {
1834
1835 return false;
1836 }
1837
1838 // Delegate to configurable domains
1839 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1840}
1841
1842bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1843{
1844 // Check tuning mode
1845 if (!checkTuningModeOn(strError)) {
1846
1847 return false;
1848 }
1849
1850 // Delegate to configurable domains
1851 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1852}
1853
Kevin Rocardace81f82012-12-11 16:19:17 +01001854bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& lstrError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001855{
Kevin Rocardace81f82012-12-11 16:19:17 +01001856 string strError;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001857 // Check tuning mode
1858 if (!checkTuningModeOn(strError)) {
1859
Kevin Rocardace81f82012-12-11 16:19:17 +01001860 lstrError.push_back(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001861 return false;
1862 }
1863
1864 // Delegate to configurable domains
Kevin Rocardace81f82012-12-11 16:19:17 +01001865 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001866}
1867
1868bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1869{
1870 // Check tuning mode
1871 if (!checkTuningModeOn(strError)) {
1872
1873 return false;
1874 }
1875
1876 // Delegate to configurable domains
1877 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1878}
1879
1880// Configurable element - domain association
1881bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1882{
1883 // Check tuning mode
1884 if (!checkTuningModeOn(strError)) {
1885
1886 return false;
1887 }
1888
1889 CElementLocator elementLocator(getSystemClass());
1890
1891 CElement* pLocatedElement = NULL;
1892
1893 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1894
1895 return false;
1896 }
1897
1898 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001899 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001900
1901 // Delegate
1902 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1903}
1904
1905bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1906{
1907 // Check tuning mode
1908 if (!checkTuningModeOn(strError)) {
1909
1910 return false;
1911 }
1912
1913 CElementLocator elementLocator(getSystemClass());
1914
1915 CElement* pLocatedElement = NULL;
1916
1917 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1918
Patrick Benavoli63499d42011-10-24 18:50:03 +02001919 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001920 }
1921
1922 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001923 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001924
1925 // Delegate
1926 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1927}
1928
1929bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1930{
1931 // Check tuning mode
1932 if (!checkTuningModeOn(strError)) {
1933
1934 return false;
1935 }
1936
1937 CElementLocator elementLocator(getSystemClass());
1938
1939 CElement* pLocatedElement = NULL;
1940
1941 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1942
Patrick Benavoli63499d42011-10-24 18:50:03 +02001943 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001944 }
1945
1946 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001947 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001948
1949 // Delegate
1950 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1951}
1952
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001953bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSettings,
1954 bool bFromFile, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001955{
1956 // Check tuning mode
1957 if (!checkTuningModeOn(strError)) {
1958
1959 return false;
1960 }
1961
1962 // check path is absolute
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001963 if (bFromFile && strXmlSource[0] != '/') {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001964
1965 strError = "Please provide absolute path";
1966
1967 return false;
1968 }
1969 // Root element
1970 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1971
1972 // Context
1973 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1974
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001975 // Selection criteria definition for rule creation
1976 xmlDomainSerializingContext.setSelectionCriteriaDefinition(
1977 getConstSelectionCriteria()->getSelectionCriteriaDefinition());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001978
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001979 // Init serializing context
1980 xmlDomainSerializingContext.set(
1981 _pElementLibrarySet->getElementLibrary(EParameterConfigurationLibrary),
1982 "", _strSchemaFolderLocation);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001983
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001984 // Get Schema file associated to root element
1985 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" +
1986 pConfigurableDomains->getKind() + ".xsd";
1987
1988 // Xml Source
1989 CXmlDocSource* pSource;
1990
1991 if (bFromFile) {
1992
1993 // when importing from a file strXmlSource is the file name
1994 pSource = new CXmlFileDocSource(strXmlSource, strXmlSchemaFilePath,
1995 pConfigurableDomains->getKind(),
1996 pConfigurableDomains->getName(), "SystemClassName");
1997
1998 } else {
1999
2000 // when importing from an xml string, strXmlSource contains the string
2001 pSource = new CXmlStringDocSource(strXmlSource, strXmlSchemaFilePath,
2002 pConfigurableDomains->getKind(),
2003 pConfigurableDomains->getName(), "SystemClassName");
2004
2005 }
2006 // Start clean
2007 pConfigurableDomains->clean();
2008
2009 // Use a doc sink that instantiate Configurable Domains from the given doc source
2010 CXmlMemoryDocSink memorySink(pConfigurableDomains);
2011
2012 bool bProcessSuccess = memorySink.process(*pSource, xmlDomainSerializingContext);
2013
2014 if (!bProcessSuccess) {
2015
2016 //Cleanup
2017 pConfigurableDomains->clean();
2018
2019 } else {
2020
2021 // Validate domains after XML import
2022 pConfigurableDomains->validate(_pMainParameterBlackboard);
2023
Patrick Benavoli68a91282011-08-31 11:23:23 +02002024 }
2025
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002026 delete pSource;
Patrick Benavoli68a91282011-08-31 11:23:23 +02002027
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002028 return bProcessSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +02002029}
2030
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002031bool CParameterMgr::exportDomainsXml(string& strXmlDest, bool bWithSettings, bool bToFile,
2032 string& strError) const
Patrick Benavoli68a91282011-08-31 11:23:23 +02002033{
2034 // check path is absolute
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002035 if (bToFile && strXmlDest[0] != '/') {
Patrick Benavoli68a91282011-08-31 11:23:23 +02002036
2037 strError = "Please provide absolute path";
2038
2039 return false;
2040 }
2041
2042 // Root element
2043 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
2044
2045 // Get Schema file associated to root element
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002046 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" +
2047 pConfigurableDomains->getKind() + ".xsd";
Patrick Benavoli68a91282011-08-31 11:23:23 +02002048
2049 // Context
2050 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
2051
2052 // Value space
2053 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
2054
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002055 // Output raw format
2056 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
2057
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002058 // Use a doc source by loading data from instantiated Configurable Domains
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002059 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(),
2060 strXmlSchemaFilePath, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002061
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002062 // Xml Sink
2063 CXmlDocSink* pSink;
Patrick Benavoli68a91282011-08-31 11:23:23 +02002064
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002065 if (bToFile) {
2066
2067 // Use a doc sink to write the doc data in a file
2068 pSink = new CXmlFileDocSink(strXmlDest);
2069
2070 } else {
2071
2072 // Use a doc sink to write the doc data in a string
2073 pSink = new CXmlStringDocSink(strXmlDest);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002074 }
2075
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002076 bool bProcessSuccess = pSink->process(memorySource, xmlDomainSerializingContext);
2077
2078 delete pSink;
2079 return bProcessSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +02002080}
2081
2082// Binary Import/Export
2083bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
2084{
2085 // Check tuning mode
2086 if (!checkTuningModeOn(strError)) {
2087
2088 return false;
2089 }
2090 // check path is absolute
2091 if (strFileName[0] != '/') {
2092
2093 strError = "Please provide absolute path";
2094
2095 return false;
2096 }
2097 // Root element
2098 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
2099
2100 // Serialize in
2101 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
2102}
2103
2104bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
2105{
2106 // check path is absolute
2107 if (strFileName[0] != '/') {
2108
2109 strError = "Please provide absolute path";
2110
2111 return false;
2112 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02002113
Patrick Benavoli68a91282011-08-31 11:23:23 +02002114 // Root element
2115 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
2116
2117 // Serialize out
2118 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
2119}
2120
2121// For tuning, check we're in tuning mode
2122bool CParameterMgr::checkTuningModeOn(string& strError) const
2123{
2124 // Tuning Mode on?
2125 if (!_bTuningModeIsOn) {
2126
2127 strError = "Tuning Mode must be on";
2128
2129 return false;
2130 }
2131 return true;
2132}
2133
Patrick Benavoli065264a2011-11-20 15:46:41 +01002134// Tuning mutex dynamic parameter handling
2135pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002136{
Patrick Benavoli065264a2011-11-20 15:46:41 +01002137 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002138}
2139
Patrick Benavoli065264a2011-11-20 15:46:41 +01002140// Blackboard reference (dynamic parameter handling)
2141CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002142{
Patrick Benavoli065264a2011-11-20 15:46:41 +01002143 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002144}
2145
Patrick Benavoli68a91282011-08-31 11:23:23 +02002146// Dynamic creation library feeding
2147void CParameterMgr::feedElementLibraries()
2148{
2149 // Global Configuration handling
2150 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
2151
Kevin Rocarda7b69602013-08-07 16:15:33 +02002152 pFrameworkConfigurationLibrary->addElementBuilder("ParameterFrameworkConfiguration", new TElementBuilderTemplate<CParameterFrameworkConfiguration>());
2153 pFrameworkConfigurationLibrary->addElementBuilder("SubsystemPlugins", new TKindElementBuilderTemplate<CSubsystemPlugins>());
2154 pFrameworkConfigurationLibrary->addElementBuilder("Location", new TKindElementBuilderTemplate<CPluginLocation>());
2155 pFrameworkConfigurationLibrary->addElementBuilder("StructureDescriptionFileLocation", new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>());
2156 pFrameworkConfigurationLibrary->addElementBuilder("SettingsConfiguration", new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>());
2157 pFrameworkConfigurationLibrary->addElementBuilder("ConfigurableDomainsFileLocation", new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>());
2158 pFrameworkConfigurationLibrary->addElementBuilder("BinarySettingsFileLocation", new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002159
2160 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
2161
2162 // Parameter creation
2163 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
2164
Kevin Rocarda7b69602013-08-07 16:15:33 +02002165 pParameterCreationLibrary->addElementBuilder("Subsystem", new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
2166 pParameterCreationLibrary->addElementBuilder("ComponentType", new TNamedElementBuilderTemplate<CComponentType>());
2167 pParameterCreationLibrary->addElementBuilder("Component", new TNamedElementBuilderTemplate<CComponentInstance>());
2168 pParameterCreationLibrary->addElementBuilder("BitParameter", new TNamedElementBuilderTemplate<CBitParameterType>());
2169 pParameterCreationLibrary->addElementBuilder("BitParameterBlock", new TNamedElementBuilderTemplate<CBitParameterBlockType>());
2170 pParameterCreationLibrary->addElementBuilder("StringParameter", new TNamedElementBuilderTemplate<CStringParameterType>());
2171 pParameterCreationLibrary->addElementBuilder("ParameterBlock", new TNamedElementBuilderTemplate<CParameterBlockType>());
2172 pParameterCreationLibrary->addElementBuilder("BooleanParameter", new TNamedElementBuilderTemplate<CBooleanParameterType>());
2173 pParameterCreationLibrary->addElementBuilder("IntegerParameter", new TNamedElementBuilderTemplate<CIntegerParameterType>());
2174 pParameterCreationLibrary->addElementBuilder("LinearAdaptation", new TElementBuilderTemplate<CLinearParameterAdaptation>());
2175 pParameterCreationLibrary->addElementBuilder("EnumParameter", new TNamedElementBuilderTemplate<CEnumParameterType>());
2176 pParameterCreationLibrary->addElementBuilder("ValuePair", new TElementBuilderTemplate<CEnumValuePair>());
2177 pParameterCreationLibrary->addElementBuilder("FixedPointParameter", new TNamedElementBuilderTemplate<CFixedPointParameterType>());
2178 pParameterCreationLibrary->addElementBuilder("SubsystemInclude", new TKindElementBuilderTemplate<CXmlFileIncluderElement>());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002179
2180 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
2181
2182 // Parameter Configuration Domains creation
2183 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
2184
Kevin Rocarda7b69602013-08-07 16:15:33 +02002185 pParameterConfigurationLibrary->addElementBuilder("ConfigurableDomain", new TNamedElementBuilderTemplate<CConfigurableDomain>());
2186 pParameterConfigurationLibrary->addElementBuilder("Configuration", new TNamedElementBuilderTemplate<CDomainConfiguration>());
2187 pParameterConfigurationLibrary->addElementBuilder("CompoundRule", new TElementBuilderTemplate<CCompoundRule>());
2188 pParameterConfigurationLibrary->addElementBuilder("SelectionCriterionRule", new TElementBuilderTemplate<CSelectionCriterionRule>());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002189
2190 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
2191}
2192
2193// Remote Processor Server connection handling
2194bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
2195{
2196 CAutoLog autoLog(this, "Handling remote processing interface");
2197
2198 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002199 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02002200
Kevin Rocardace81f82012-12-11 16:19:17 +01002201 log_info("Loading remote processor library");
Patrick Benavoli68a91282011-08-31 11:23:23 +02002202
2203 // Load library
Renaud de Chivre1b8b3ca2013-12-13 15:09:44 +01002204 _handleLibRemoteProcessor = dlopen("libremote-processor.so", RTLD_NOW);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002205
Renaud de Chivre1b8b3ca2013-12-13 15:09:44 +01002206 if (!_handleLibRemoteProcessor) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02002207
2208 // Return error
2209 const char* pcError = dlerror();
2210
2211 if (pcError) {
2212
2213 strError = pcError;
2214 } else {
2215
2216 strError = "Unable to load libremote-processor.so library";
2217 }
2218
2219 return false;
2220 }
2221
Renaud de Chivre1b8b3ca2013-12-13 15:09:44 +01002222 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(_handleLibRemoteProcessor, "createRemoteProcessorServer");
Patrick Benavoli68a91282011-08-31 11:23:23 +02002223
2224 if (!pfnCreateRemoteProcessorServer) {
2225
2226 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
2227
2228 return false;
2229 }
2230
2231 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002232 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002233
Kevin Rocardace81f82012-12-11 16:19:17 +01002234 log_info("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002235 // Start
2236 if (!_pRemoteProcessorServer->start()) {
2237
2238 strError = "Unable to start remote processor server";
2239
2240 return false;
2241 }
2242 }
2243
2244 return true;
2245}
2246
2247// Back synchronization
Kevin Rocardace81f82012-12-11 16:19:17 +01002248CBackSynchronizer* CParameterMgr::createBackSynchronizer() const
Patrick Benavoli68a91282011-08-31 11:23:23 +02002249{
2250#ifdef SIMULATION
2251 // In simulation, back synchronization of the blackboard won't probably work
2252 // We need to ensure though the blackboard is initialized with valid data
Kevin Rocardace81f82012-12-11 16:19:17 +01002253 return new CSimulatedBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002254#else
2255 // Real back synchronizer from subsystems
Kevin Rocardace81f82012-12-11 16:19:17 +01002256 return new CHardwareBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002257#endif
2258}
2259
2260// Children typwise access
2261CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
2262{
2263 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
2264}
2265
2266const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
2267{
2268 return getFrameworkConfiguration();
2269}
2270
2271CSelectionCriteria* CParameterMgr::getSelectionCriteria()
2272{
2273 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
2274}
2275
2276const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
2277{
2278 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
2279}
2280
2281CSystemClass* CParameterMgr::getSystemClass()
2282{
2283 return static_cast<CSystemClass*>(getChild(ESystemClass));
2284}
2285
2286const CSystemClass* CParameterMgr::getConstSystemClass() const
2287{
2288 return static_cast<const CSystemClass*>(getChild(ESystemClass));
2289}
2290
2291// Configurable Domains
2292CConfigurableDomains* CParameterMgr::getConfigurableDomains()
2293{
2294 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
2295}
2296
2297const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
2298{
2299 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2300}
2301
2302const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
2303{
2304 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2305}
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002306
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002307// Apply configurations
2308void CParameterMgr::doApplyConfigurations(bool bForce)
2309{
2310 CSyncerSet syncerSet;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002311
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002312 // Check subsystems that need resync
2313 getSystemClass()->checkForSubsystemsToResync(syncerSet);
2314
2315 // Ensure application of currently selected configurations
2316 getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce);
2317
2318 // Reset the modified status of the current criteria to indicate that a new configuration has been applied
2319 getSelectionCriteria()->resetModifiedStatus();
2320}
2321
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002322bool CParameterMgr::getSystemClassXMLString(string& strResult)
2323{
2324 // Root element
2325 const CSystemClass* pSystemClass = getSystemClass();
2326
2327 string strError;
2328
2329 CXmlSerializingContext xmlSerializingContext(strError);
2330
2331 // Use a doc source by loading data from instantiated Configurable Domains
2332 CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind());
2333
2334 // Use a doc sink that write the doc data in a string
2335 CXmlStringDocSink stringSink(strResult);
2336
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002337 bool bProcessSuccess = stringSink.process(memorySource, xmlSerializingContext);
2338
2339 if (!bProcessSuccess) {
2340
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002341 strResult = strError;
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002342
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002343 }
2344
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002345 return bProcessSuccess;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002346}