blob: 768a5c53747525487408ae8e296323dc2eaba133 [file] [log] [blame]
Patrick Benavoli68a91282011-08-31 11:23:23 +02001/* <auto_header>
2 * <FILENAME>
3 *
4 * INTEL CONFIDENTIAL
5 * Copyright © 2011 Intel
6 * Corporation All Rights Reserved.
7 *
8 * The source code contained or described herein and all documents related to
9 * the source code ("Material") are owned by Intel Corporation or its suppliers
10 * or licensors. Title to the Material remains with Intel Corporation or its
11 * suppliers and licensors. The Material contains trade secrets and proprietary
12 * and confidential information of Intel or its suppliers and licensors. The
13 * Material is protected by worldwide copyright and trade secret laws and
14 * treaty provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed, or
16 * disclosed in any way without Intel’s prior express written permission.
17 *
18 * No license under any patent, copyright, trade secret or other intellectual
19 * property right is granted to or conferred upon you by disclosure or delivery
20 * of the Materials, either expressly, by implication, inducement, estoppel or
21 * otherwise. Any license under such intellectual property rights must be
22 * express and approved by Intel in writing.
23 *
24 * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
25 * CREATED: 2011-06-01
26 * UPDATED: 2011-07-27
27 *
28 *
29 * </auto_header>
30 */
31#include "ParameterMgr.h"
32#include "XmlParser.h"
33#include "XmlParameterSerializingContext.h"
34#include "XmlElementSerializingContext.h"
35#include "SystemClass.h"
36#include "ElementLibrarySet.h"
37#include "SubsystemLibrary.h"
38#include "NamedElementBuilderTemplate.h"
39#include "KindElementBuilderTemplate.h"
40#include "ElementBuilderTemplate.h"
41#include "SelectionCriterionType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020042#include "SubsystemElementBuilder.h"
43#include "SelectionCriteria.h"
44#include "ComponentType.h"
45#include "ComponentInstance.h"
46#include "ParameterBlockType.h"
47#include "BooleanParameterType.h"
48#include "IntegerParameterType.h"
49#include "FixedPointParameterType.h"
50#include "ParameterBlackboard.h"
51#include "Parameter.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020052#include "ParameterBlackboard.h"
53#include "ParameterAccessContext.h"
54#include "XmlFileIncluderElement.h"
55#include "ParameterFrameworkConfiguration.h"
56#include "FrameworkConfigurationGroup.h"
57#include "FrameworkConfigurationLocation.h"
58#include "SystemClassConfiguration.h"
59#include "ConfigurableDomains.h"
60#include "ConfigurableDomain.h"
61#include "DomainConfiguration.h"
62#include "XmlComposer.h"
63#include "XmlDomainSerializingContext.h"
64#include "BitParameterBlockType.h"
65#include "BitParameterType.h"
Patrick Benavoli1352ae52011-10-21 16:48:04 +020066#include "StringParameterType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020067#include "RemoteProcessorServerInterface.h"
68#include "ElementLocator.h"
69#include "AutoLog.h"
70#include "CompoundRule.h"
71#include "SelectionCriterionRule.h"
72#include "SimulatedBackSynchronizer.h"
73#include "HardwareBackSynchronizer.h"
Patrick Benavoli1387bda2011-08-31 11:23:24 +020074#include "AutoLock.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020075#include <strings.h>
76#include <dlfcn.h>
77#include <assert.h>
Patrick Benavoli68a91282011-08-31 11:23:23 +020078
79#define base CElement
80
81// Used for remote processor server creation
82typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler);
83
84// Global configuration file name (fixed)
85const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml";
86const char* gacSystemSchemasSubFolder = "Schemas";
87
88// Config File System looks normally like this:
89// ---------------------------------------------
90//├── ParameterFrameworkConfiguration.xml
91//├── Schemas
92//│ └── *.xsd
93//├── Settings
94//│ └── <SystemClassName folder>*
95//│ ├── <ConfigurableDomains>.xml
96//│ └── <Settings>.bin?
97//└── Structure
98// └── <SystemClassName folder>*
99// ├── <SystemClassName>Class.xml
100// └── <Subsystem>.xml*
101// --------------------------------------------
102
103
104// Remote command parser array
Patrick Benavoli592ae562011-09-05 16:53:58 +0200105const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
Patrick Benavoli592ae562011-09-05 16:53:58 +0200106 /// Version
107 { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200108 /// Status
109 { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" },
110 /// Tuning Mode
111 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" },
112 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" },
113 /// Value Space
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200114 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200115 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200116 /// Output Raw Format
117 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
118 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200119 /// Sync
120 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
121 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" },
122 { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200123 /// Criteria
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200124 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200125 /// Domains
126 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" },
127 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" },
128 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" },
129 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200130 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" },
131 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200132 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" },
133 { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" },
134 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
135 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" },
136 /// Configurations
137 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" },
138 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" },
139 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" },
140 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" },
141 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" },
142 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200143 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 2, "<domain> <configuration> <elem path list>", "Set element application order for configuration" },
144 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200145 /// Elements/Parameters
146 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" },
Patrick Benavoli592ae562011-09-05 16:53:58 +0200147 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200148 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" },
149 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200150 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200151 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200152 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200153 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200154 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" },
155 /// Browse
156 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" },
157 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" },
158 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" },
159 /// Settings Import/Export
160 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" },
161 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" },
162 { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" },
163 { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" },
164 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" },
165 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }
166};
167// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200168const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200169
170CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName) :
171 _bTuningModeIsOn(false),
172 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200173 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200174 _bAutoSyncOn(true),
175 _pMainParameterBlackboard(new CParameterBlackboard),
176 _pElementLibrarySet(new CElementLibrarySet),
177 _strParameterFrameworkConfigurationFolderPath(strParameterFrameworkConfigurationFolderPath),
178 _strSchemaFolderLocation(strParameterFrameworkConfigurationFolderPath + "/" + gacSystemSchemasSubFolder),
179 _pSystemClassConfiguration(NULL),
180 _uiStructureChecksum(0),
181 _pRemoteProcessorServer(NULL),
182 _uiMaxCommandUsageLength(0),
183 _pLogger(NULL),
184 _uiLogDepth(0)
185{
186 // Tuning Mode Mutex
187 bzero(&_tuningModeMutex, sizeof(_tuningModeMutex));
188 pthread_mutex_init(&_tuningModeMutex, NULL);
189
190 // Deal with children
191 addChild(new CParameterFrameworkConfiguration);
192 addChild(new CSelectionCriteria);
193 addChild(new CSystemClass(strSystemClassName));
194 addChild(new CConfigurableDomains(strSystemClassName));
195
196 // Feed element library
197 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200198
199 _pCommandHandler = new CCommandHandler(this);
200
201 // Add command parsers
202 uint32_t uiRemoteCommandParserItem;
203
204 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
205
206 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
207
208 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
209 pRemoteCommandParserItem->_pfnParser,
210 pRemoteCommandParserItem->_uiMinArgumentCount,
211 pRemoteCommandParserItem->_pcHelp,
212 pRemoteCommandParserItem->_pcDescription);
213 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200214}
215
216CParameterMgr::~CParameterMgr()
217{
218 // Children
219 delete _pRemoteProcessorServer;
220 delete _pMainParameterBlackboard;
221 delete _pElementLibrarySet;
222
223 // Tuning Mode Mutex
224 pthread_mutex_destroy(&_tuningModeMutex);
225}
226
227string CParameterMgr::getKind() const
228{
229 return "ParameterMgr";
230}
231
232// Logging
233void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
234{
235 _pLogger = pLogger;
236}
237
238// Logging
239void CParameterMgr::doLog(const string& strLog) const
240{
241 if (_pLogger) {
242
243 // Nest
244 string strIndent;
245
246 // Level
247 uint32_t uiNbIndents = _uiLogDepth;
248
249 while (uiNbIndents--) {
250
251 strIndent += " ";
252 }
253
254 // Log
255 _pLogger->log(strIndent + strLog);
256 }
257}
258
259void CParameterMgr::nestLog() const
260{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200261 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200262}
263
264void CParameterMgr::unnestLog() const
265{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200266 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200267}
268
Patrick Benavoli63499d42011-10-24 18:50:03 +0200269// Version
270string CParameterMgr::getVersion() const
271{
272 string strVersion;
273
274 // Major
275 strVersion = toString(guiEditionMajor) + ".";
276 // Minor
277 strVersion += toString(guiEditionMinor) + ".";
278 // Revision
279 strVersion += toString(guiRevision);
280
281 return strVersion;
282}
283
Patrick Benavoli68a91282011-08-31 11:23:23 +0200284bool CParameterMgr::load(string& strError)
285{
286 CAutoLog autoLog(this, "Loading");
287
288 // Load Framework configuration
289 if (!loadFrameworkConfiguration(strError)) {
290
291 return false;
292 }
293
294 // Load subsystems
295 if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) {
296
297 return false;
298 }
299
300 // Load structure
301 if (!loadStructure(strError)) {
302
303 return false;
304 }
305
306 // Load settings
307 if (!loadSettings(strError)) {
308
309 return false;
310 }
311
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200312 // Back synchronization for areas in parameter blackboard not covered by any domain
313 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200314
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200315 log("Main blackboard back synchronization");
316
317 // Back-synchronize
318 if (!pBackSynchronizer->sync()) {
319 // Get rid of back synchronizer
320 delete pBackSynchronizer;
321
322 strError = "Main blackboard back synchronization failed: " + strError;
323
324 return false;
325 }
326 // Get rif of back synchronizer
327 delete pBackSynchronizer;
328
329 // We're done loading the settings and back synchronizing
330 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
331
332 // We need to ensure all domains are valid
333 pConfigurableDomains->validate(_pMainParameterBlackboard);
334
335 // Ensure application of currently selected configurations
336 // Force-apply configurations
337 if (!pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200338
339 return false;
340 }
341
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200342 // Start remote processor server if appropriate
343 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200344}
345
346bool CParameterMgr::loadFrameworkConfiguration(string& strError)
347{
348 CAutoLog autoLog(this, "Loading framework configuration");
349
350 // Get Xml config file name
351 string strXmlConfigurationFilePath = _strParameterFrameworkConfigurationFolderPath + "/" + gacParameterFrameworkConfigurationFileName;
352
353 // Parse Structure XML file
354 CXmlElementSerializingContext elementSerializingContext(strError);
355
356 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), strXmlConfigurationFilePath, _strParameterFrameworkConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
357
358 return false;
359 }
360 // Get subsystem plugins folders element
361 const CFrameworkConfigurationGroup* pSubsystemPluginFolders= static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders"));
362
363 if (!pSubsystemPluginFolders) {
364
365 strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element";
366
367 return false;
368 }
369 // Get plugin locations
370 uint32_t uiPluginFolderLocation;
371 uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren();
372
373 if (!uiNbPluginFolderLocations) {
374
375 strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element";
376
377 return false;
378 }
379
380 for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) {
381
382 const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation));
383
384 _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath));
385 }
386
387 // Get configuration for current system class
388 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("ParameterConfiguration"));
389
390 if (!pParameterConfigurationGroup) {
391
392 strError = "Parameter Framework Configuration: couldn't find ParameterConfiguration element";
393
394 return false;
395 }
396 _pSystemClassConfiguration = static_cast<const CSystemClassConfiguration*>(pParameterConfigurationGroup->findChild(getSystemClass()->getName()));
397
398 if (!_pSystemClassConfiguration) {
399
400 strError = "No framework configuration found for SystemClass " + getSystemClass()->getName();
401
402 return false;
403 }
404 // Log tuning availability
405 log("Tuning %s", _pSystemClassConfiguration->isTuningAllowed() ? "allowed" : "prohibited");
406
407 return true;
408}
409
410bool CParameterMgr::loadStructure(string& strError)
411{
412 // Retrieve system to load structure to
413 CSystemClass* pSystemClass = getSystemClass();
414
415 CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure");
416
417 // Get structure description element
418 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(_pSystemClassConfiguration->findChildOfKind("StructureDescriptionFileLocation"));
419
420 if (!pStructureDescriptionFileLocation) {
421
422 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
423
424 return false;
425 }
426
427 // Get Xml structure folder
428 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath);
429
430 // Get Xml structure file name
431 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath);
432
433 // Parse Structure XML file
434 CXmlParameterSerializingContext parameterBuildContext(strError);
435
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200436 log("Importing system structure from file %s", strXmlStructureFilePath.c_str());
437
Patrick Benavoli68a91282011-08-31 11:23:23 +0200438 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
439
440 return false;
441 }
442
443 // Initialize offsets
444 pSystemClass->setOffset(0);
445
446 // Initialize main blackboard's size
447 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
448
449 return true;
450}
451
452bool CParameterMgr::loadSettings(string& strError)
453{
454 CAutoLog autoLog(this, "Loading settings");
455
456 // Get settings configuration element
457 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(_pSystemClassConfiguration->findChildOfKind("SettingsConfiguration"));
458
459 if (!pParameterConfigurationGroup) {
460
461 // No settings to load
462
463 return true;
464 }
465 // Get binary settings file location
466 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
467
468 string strXmlBinarySettingsFilePath;
469
470 if (pBinarySettingsFileLocation) {
471
472 // Get Xml binary settings file name
473 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath);
474 }
475
476 // Get configurable domains element
477 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
478
479 if (!pConfigurableDomainsFileLocation) {
480
481 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
482
483 return false;
484 }
485 // Get destination root element
486 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
487
488 // Get Xml configuration domains file name
489 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath);
490
491 // Get Xml configuration domains folder
492 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath);
493
494 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
495 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
496
497 // Selection criteria definition for rule creation
498 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
499
Patrick Benavoli63499d42011-10-24 18:50:03 +0200500 // Auto validation of configurations if no binary settings provided
501 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
502
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200503 log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
504
Patrick Benavoli68a91282011-08-31 11:23:23 +0200505 // Do parse
506 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
507
508 return false;
509 }
510 // We have loaded the whole system structure, compute checksum
511 const CSystemClass* pSystemClass = getConstSystemClass();
512 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
513
514 // Load binary settings if any provided
515 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
516
517 return false;
518 }
519
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200520 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200521}
522
523// XML parsing
524bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
525{
526 // Init serializing context
527 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
528
529 // Get Schema file associated to root element
530 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
531
532 // Parse Structure XML file
533 CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext);
534
535 if (!parser.open()) {
536
537 return false;
538 }
539
540 // Check Root element name attribute (if any)
541 string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName);
542
543 if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) {
544
545 elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath);
546 elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName());
547
548 return false;
549 }
550
551 // Start clean
552 pRootElement->clean();
553
554 // Parse
555 if (!parser.parse(pRootElement)) {
556
557 // Cleanup
558 pRootElement->clean();
559
560 return false;
561 }
562
563 // Close parser
564 if (!parser.close()) {
565
566 return false;
567 }
568
569 return true;
570}
571
572// Init
573bool CParameterMgr::init(string& strError)
574{
575 return base::init(strError);
576}
577
578// Selection criteria interface
579CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
580{
581 // Propagate
582 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
583}
584
585CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
586{
587 // Propagate
588 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
589}
590
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200591// Selection criterion retrieval
592CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200593{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200594 // Propagate
595 return getSelectionCriteria()->getSelectionCriterion(strName);
596}
597
598// Selection criteria changed event
599bool CParameterMgr::applyConfigurations(string& strError)
600{
601 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200602
603 // Lock state
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200604 CAutoLock autoLock(&_tuningModeMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200605
606 if (!_bTuningModeIsOn) {
607
608 // Apply configuration(s)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200609 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) {
610
611 log("Failed to apply configurations!");
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200612
613 return false;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200614 }
615 }
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200616
617 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200618}
619
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200620// Dynamic parameter handling
621bool CParameterMgr::setValue(const string& strPath, const string& strValue, bool bRawValueSpace, string& strError)
622{
623 // Delegate to low level functionality
624 return doSetValue(strPath, strValue, bRawValueSpace, true, strError);
625}
626
627bool CParameterMgr::getValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, string& strError) const
628{
629 // Delegate to low level functionality
630 return doGetValue(strPath, strValue, bRawValueSpace, bHexOutputRawFormat, true, strError);
631}
632
Patrick Benavoli68a91282011-08-31 11:23:23 +0200633/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200634/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200635CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200636{
637 (void)remoteCommand;
638
Patrick Benavoli63499d42011-10-24 18:50:03 +0200639 // Show version
640 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200641
Patrick Benavoli63499d42011-10-24 18:50:03 +0200642 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200643}
644
Patrick Benavoli68a91282011-08-31 11:23:23 +0200645/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200646CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200647{
648 (void)remoteCommand;
649 // System class
650 const CSystemClass* pSystemClass = getSystemClass();
651
Patrick Benavoli68a91282011-08-31 11:23:23 +0200652 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200653 /// General section
654 appendTitle(strResult, "General:");
655 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200656 strResult += "System Class: ";
657 strResult += pSystemClass->getName();
658 strResult += "\n";
659
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200660 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200661 strResult += "Tuning Mode: ";
662 strResult += tuningModeOn() ? "on" : "off";
663 strResult += "\n";
664
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200665 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200666 strResult += "Value Space: ";
667 strResult += valueSpaceIsRaw() ? "raw" : "real";
668 strResult += "\n";
669
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200670 // Output raw format
671 strResult += "Output Raw Format: ";
672 strResult += outputRawFormatIsHex() ? "hex" : "dec";
673 strResult += "\n";
674
675 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200676 strResult += "Auto Sync: ";
677 strResult += autoSyncOn() ? "on" : "off";
678 strResult += "\n";
679
680 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200681 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200682 string strSubsystemList;
683 pSystemClass->listChildrenPaths(strSubsystemList);
684 strResult += strSubsystemList;
685
686 /// Last applied configurations
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200687 appendTitle(strResult, "Last applied configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200688 string strLastAppliedConfigurations;
689 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
690 strResult += strLastAppliedConfigurations;
691
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200692 /// Criteria states
693 appendTitle(strResult, "Selection criteria:");
694 string strSelectionCriteria;
695 getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false);
696 strResult += strSelectionCriteria;
697
Patrick Benavoli63499d42011-10-24 18:50:03 +0200698 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200699}
700
701/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200702CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200703{
704 if (remoteCommand.getArgument(0) == "on") {
705
706 if (setTuningMode(true, strResult)) {
707
Patrick Benavoli63499d42011-10-24 18:50:03 +0200708 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200709 }
710 } else if (remoteCommand.getArgument(0) == "off") {
711
712 if (setTuningMode(false, strResult)) {
713
Patrick Benavoli63499d42011-10-24 18:50:03 +0200714 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200715 }
716 } else {
717 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200718 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200719 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200720 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200721}
722
Patrick Benavoli63499d42011-10-24 18:50:03 +0200723CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200724{
725 (void)remoteCommand;
726
727 strResult = tuningModeOn() ? "on" : "off";
728
Patrick Benavoli63499d42011-10-24 18:50:03 +0200729 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200730}
731
732/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200733CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200734{
735 (void)strResult;
736
737 if (remoteCommand.getArgument(0) == "raw") {
738
739 setValueSpace(true);
740
Patrick Benavoli63499d42011-10-24 18:50:03 +0200741 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200742
743 } else if (remoteCommand.getArgument(0) == "real") {
744
745 setValueSpace(false);
746
Patrick Benavoli63499d42011-10-24 18:50:03 +0200747 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200748
749 } else {
750 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200751 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200752 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200753 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200754}
755
Patrick Benavoli63499d42011-10-24 18:50:03 +0200756CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200757{
758 (void)remoteCommand;
759
760 strResult = valueSpaceIsRaw() ? "raw" : "real";
761
Patrick Benavoli63499d42011-10-24 18:50:03 +0200762 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200763}
764
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200765/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200766CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200767{
768 (void)strResult;
769
770 if (remoteCommand.getArgument(0) == "hex") {
771
772 setOutputRawFormat(true);
773
Patrick Benavoli63499d42011-10-24 18:50:03 +0200774 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200775
776 } else if (remoteCommand.getArgument(0) == "dec") {
777
778 setOutputRawFormat(false);
779
Patrick Benavoli63499d42011-10-24 18:50:03 +0200780 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200781
782 } else {
783 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200784 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200785 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200786 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200787}
788
Patrick Benavoli63499d42011-10-24 18:50:03 +0200789CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200790{
791 (void)remoteCommand;
792
793 strResult = outputRawFormatIsHex() ? "hex" : "dec";
794
Patrick Benavoli63499d42011-10-24 18:50:03 +0200795 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200796}
797
Patrick Benavoli68a91282011-08-31 11:23:23 +0200798/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200799CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200800{
801 if (remoteCommand.getArgument(0) == "on") {
802
803 if (setAutoSync(true, strResult)) {
804
Patrick Benavoli63499d42011-10-24 18:50:03 +0200805 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200806 }
807 } else if (remoteCommand.getArgument(0) == "off") {
808
809 if (setAutoSync(false, strResult)) {
810
Patrick Benavoli63499d42011-10-24 18:50:03 +0200811 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200812 }
813 } else {
814 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200815 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200816 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200817 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200818}
819
Patrick Benavoli63499d42011-10-24 18:50:03 +0200820CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200821{
822 (void)remoteCommand;
823
824 strResult = autoSyncOn() ? "on" : "off";
825
Patrick Benavoli63499d42011-10-24 18:50:03 +0200826 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200827}
828
Patrick Benavoli63499d42011-10-24 18:50:03 +0200829CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200830{
831 (void)remoteCommand;
832
Patrick Benavoli63499d42011-10-24 18:50:03 +0200833 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200834}
835
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200836/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200837CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200838{
839 (void)remoteCommand;
840
841 getSelectionCriteria()->listSelectionCriteria(strResult, true);
842
Patrick Benavoli63499d42011-10-24 18:50:03 +0200843 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200844}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200845
846/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200847CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200848{
849 (void)remoteCommand;
850
Patrick Benavoli63499d42011-10-24 18:50:03 +0200851 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200852
Patrick Benavoli63499d42011-10-24 18:50:03 +0200853 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200854}
855
Patrick Benavoli63499d42011-10-24 18:50:03 +0200856CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200857{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200858 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200859}
860
Patrick Benavoli63499d42011-10-24 18:50:03 +0200861CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200862{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200863 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200864}
865
Patrick Benavoli63499d42011-10-24 18:50:03 +0200866CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200867{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200868 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200869}
870
Patrick Benavoli63499d42011-10-24 18:50:03 +0200871CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200872{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200873 // Check tuning mode
874 if (!checkTuningModeOn(strResult)) {
875
876 return CCommandHandler::EFailed;
877 }
878
879 // Set property
880 bool bSequenceAware;
881
882 if (remoteCommand.getArgument(1) == "true") {
883
884 bSequenceAware = true;
885
886 } else if (remoteCommand.getArgument(1) == "false") {
887
888 bSequenceAware = false;
889
890 } else {
891 // Show usage
892 return CCommandHandler::EShowUsage;
893 }
894
895 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200896}
897
Patrick Benavoli63499d42011-10-24 18:50:03 +0200898CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200899{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200900 // Get property
901 bool bSequenceAware;
902
903 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
904
905 return CCommandHandler::EFailed;
906 }
907
908 strResult = bSequenceAware ? "true" : "false";
909
910 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200911}
912
Patrick Benavoli63499d42011-10-24 18:50:03 +0200913CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200914{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200915 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200916}
917
Patrick Benavoli63499d42011-10-24 18:50:03 +0200918CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200919{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200920 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
921}
922
923CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
924{
925 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
926}
927
928CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
929{
930 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200931}
932
933/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +0200934CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200935{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200936 return getConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200937}
938
Patrick Benavoli63499d42011-10-24 18:50:03 +0200939CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200940{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200941 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200942}
943
Patrick Benavoli63499d42011-10-24 18:50:03 +0200944CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200945{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200946 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200947}
948
Patrick Benavoli63499d42011-10-24 18:50:03 +0200949CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200950{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200951 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200952}
953
Patrick Benavoli63499d42011-10-24 18:50:03 +0200954CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200955{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200956 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200957}
958
Patrick Benavoli63499d42011-10-24 18:50:03 +0200959CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200960{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200961 return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
962}
963
964CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
965{
966 // Check tuning mode
967 if (!checkTuningModeOn(strResult)) {
968
969 return CCommandHandler::EFailed;
970 }
971
972 // Build configurable element path list
973 vector<string> astrNewElementSequence;
974
975 uint32_t uiArgument;
976
977 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
978
979 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
980 }
981
982 // Delegate to configurable domains
983 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
984}
985
986CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
987{
988 // Delegate to configurable domains
989 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200990}
991
992/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +0200993CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200994{
995 CElementLocator elementLocator(getSystemClass(), false);
996
997 CElement* pLocatedElement = NULL;
998
999 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1000
Patrick Benavoli63499d42011-10-24 18:50:03 +02001001 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001002 }
1003
1004 strResult = string("\n");
1005
1006 if (!pLocatedElement) {
1007
1008 // List from root folder
1009
1010 // Return system class qualified name
1011 pLocatedElement = getSystemClass();
1012 }
1013
1014 // Return sub-elements
1015 strResult += pLocatedElement->listQualifiedPaths(false);
1016
Patrick Benavoli63499d42011-10-24 18:50:03 +02001017 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001018}
1019
1020/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001021CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001022{
1023 CElementLocator elementLocator(getSystemClass(), false);
1024
1025 CElement* pLocatedElement = NULL;
1026
1027 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1028
Patrick Benavoli63499d42011-10-24 18:50:03 +02001029 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001030 }
1031
1032 strResult = string("\n");
1033
1034 if (!pLocatedElement) {
1035
1036 // List from root folder
1037
1038 // Return system class qualified name
1039 pLocatedElement = getSystemClass();
1040 }
1041
1042 // Return sub-elements
1043 strResult += pLocatedElement->listQualifiedPaths(true);
1044
Patrick Benavoli63499d42011-10-24 18:50:03 +02001045 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001046}
1047
Patrick Benavoli63499d42011-10-24 18:50:03 +02001048CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001049{
1050 CElementLocator elementLocator(getSystemClass());
1051
1052 CElement* pLocatedElement = NULL;
1053
1054 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1055
Patrick Benavoli63499d42011-10-24 18:50:03 +02001056 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001057 }
1058
1059 string strError;
1060
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001061 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001062
1063 // Dump elements
1064 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1065
Patrick Benavoli63499d42011-10-24 18:50:03 +02001066 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001067}
1068
Patrick Benavoli63499d42011-10-24 18:50:03 +02001069CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001070{
1071 CElementLocator elementLocator(getSystemClass());
1072
1073 CElement* pLocatedElement = NULL;
1074
1075 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1076
Patrick Benavoli63499d42011-10-24 18:50:03 +02001077 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001078 }
1079
1080 // Converted to actual sizable element
1081 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1082
1083 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001084 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001085
Patrick Benavoli63499d42011-10-24 18:50:03 +02001086 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001087}
1088
Patrick Benavoli63499d42011-10-24 18:50:03 +02001089CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001090{
1091 CElementLocator elementLocator(getSystemClass());
1092
1093 CElement* pLocatedElement = NULL;
1094
1095 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1096
Patrick Benavoli63499d42011-10-24 18:50:03 +02001097 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001098 }
1099
1100 // Convert element
1101 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1102
1103 // Return element properties
1104 pConfigurableElement->showProperties(strResult);
1105
Patrick Benavoli63499d42011-10-24 18:50:03 +02001106 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001107}
1108
Patrick Benavoli63499d42011-10-24 18:50:03 +02001109CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001110{
1111 string strValue;
1112
1113 if (!getValue(remoteCommand.getArgument(0), strValue, strResult)) {
1114
Patrick Benavoli63499d42011-10-24 18:50:03 +02001115 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001116 }
1117 // Succeeded
1118 strResult = strValue;
1119
Patrick Benavoli63499d42011-10-24 18:50:03 +02001120 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001121}
1122
Patrick Benavoli63499d42011-10-24 18:50:03 +02001123CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001124{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001125 return setValue(remoteCommand.getArgument(0), remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001126}
1127
Patrick Benavoli63499d42011-10-24 18:50:03 +02001128CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001129{
1130 CElementLocator elementLocator(getSystemClass());
1131
1132 CElement* pLocatedElement = NULL;
1133
1134 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1135
Patrick Benavoli63499d42011-10-24 18:50:03 +02001136 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001137 }
1138
1139 // Convert element
1140 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1141
1142 // Return element belonging domains
1143 pConfigurableElement->listBelongingDomains(strResult);
1144
Patrick Benavoli63499d42011-10-24 18:50:03 +02001145 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001146}
1147
Patrick Benavoli63499d42011-10-24 18:50:03 +02001148CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001149{
1150 CElementLocator elementLocator(getSystemClass());
1151
1152 CElement* pLocatedElement = NULL;
1153
1154 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1155
Patrick Benavoli63499d42011-10-24 18:50:03 +02001156 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001157 }
1158
1159 // Convert element
1160 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1161
1162 // Return element belonging domains
1163 pConfigurableElement->listAssociatedDomains(strResult);
1164
Patrick Benavoli63499d42011-10-24 18:50:03 +02001165 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001166}
1167
Patrick Benavoli63499d42011-10-24 18:50:03 +02001168CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001169{
1170 (void)remoteCommand;
1171
1172 getConfigurableDomains()->listAssociatedElements(strResult);
1173
Patrick Benavoli63499d42011-10-24 18:50:03 +02001174 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001175}
1176
Patrick Benavoli63499d42011-10-24 18:50:03 +02001177CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001178{
1179 (void)remoteCommand;
1180
1181 getConfigurableDomains()->listConflictingElements(strResult);
1182
Patrick Benavoli63499d42011-10-24 18:50:03 +02001183 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001184}
1185
Patrick Benavoli63499d42011-10-24 18:50:03 +02001186CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001187{
1188 (void)remoteCommand;
1189
1190 getSystemClass()->listRogueElements(strResult);
1191
Patrick Benavoli63499d42011-10-24 18:50:03 +02001192 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001193}
1194
1195/// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +02001196CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001197{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001198 return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001199}
1200
Patrick Benavoli63499d42011-10-24 18:50:03 +02001201CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001202{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001203 return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001204}
1205
Patrick Benavoli63499d42011-10-24 18:50:03 +02001206CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001207{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001208 return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001209}
1210
Patrick Benavoli63499d42011-10-24 18:50:03 +02001211CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001212{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001213 return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001214}
1215
Patrick Benavoli63499d42011-10-24 18:50:03 +02001216CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001217{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001218 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001219}
1220
Patrick Benavoli63499d42011-10-24 18:50:03 +02001221CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001222{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001223 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001224}
1225
1226// User set/get parameters
1227bool CParameterMgr::setValue(const string& strPath, const string& strValue, string& strError)
1228{
1229 // Check tuning mode
1230 if (!checkTuningModeOn(strError)) {
1231
1232 return false;
1233 }
1234
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001235 // Delegate to low level functionality
1236 return doSetValue(strPath, strValue, _bValueSpaceIsRaw, false, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001237}
1238
1239bool CParameterMgr::getValue(const string& strPath, string& strValue, string& strError) const
1240{
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001241 // Delegate to low level functionality
1242 return doGetValue(strPath, strValue, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, false, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001243}
1244
1245// Tuning mode
1246bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1247{
1248 // Tuning allowed?
1249 if (bOn && !_pSystemClassConfiguration->isTuningAllowed()) {
1250
1251 strError = "Tuning prohibited";
1252
1253 return false;
1254 }
1255 // Lock state
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001256 CAutoLock autoLock(&_tuningModeMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001257
1258 // Warn domains about exiting tuning mode
1259 if (!bOn && _bTuningModeIsOn) {
1260
1261 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001262 // Force-apply configurations
Patrick Benavoli68a91282011-08-31 11:23:23 +02001263 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) {
1264
1265 return false;
1266 }
1267 // Turn auto sync back on
1268 _bAutoSyncOn = true;
1269 }
1270
1271 // Store
1272 _bTuningModeIsOn = bOn;
1273
Patrick Benavoli68a91282011-08-31 11:23:23 +02001274 return true;
1275}
1276
1277bool CParameterMgr::tuningModeOn() const
1278{
1279 return _bTuningModeIsOn;
1280}
1281
1282// Current value space for user set/get value interpretation
1283void CParameterMgr::setValueSpace(bool bIsRaw)
1284{
1285 _bValueSpaceIsRaw = bIsRaw;
1286}
1287
1288bool CParameterMgr::valueSpaceIsRaw()
1289{
1290 return _bValueSpaceIsRaw;
1291}
1292
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001293// Current Output Raw Format for user get value interpretation
1294void CParameterMgr::setOutputRawFormat(bool bIsHex)
1295{
1296 _bOutputRawFormatIsHex = bIsHex;
1297}
1298
1299bool CParameterMgr::outputRawFormatIsHex()
1300{
1301 return _bOutputRawFormatIsHex;
1302}
1303
Patrick Benavoli68a91282011-08-31 11:23:23 +02001304/// Sync
1305// Automatic hardware synchronization control (during tuning session)
1306bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1307{
1308 // Check tuning mode
1309 if (!checkTuningModeOn(strError)) {
1310
1311 return false;
1312 }
1313 // Warn domains about turning auto sync back on
1314 if (bAutoSyncOn && !_bAutoSyncOn) {
1315
Patrick Benavoli592ae562011-09-05 16:53:58 +02001316 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1317 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001318
1319 return false;
1320 }
1321 }
1322
1323 // Set Auto sync
1324 _bAutoSyncOn = bAutoSyncOn;
1325
1326 return true;
1327}
1328
1329bool CParameterMgr::autoSyncOn() const
1330{
1331 return _bAutoSyncOn;
1332}
1333
1334// Manual hardware synchronization control (during tuning session)
1335bool CParameterMgr::sync(string& strError)
1336{
1337 // Check tuning mode
1338 if (!checkTuningModeOn(strError)) {
1339
1340 return false;
1341 }
1342 // Warn domains about turning auto sync back on
1343 if (_bAutoSyncOn) {
1344
1345 strError = "Feature unavailable when Auto Sync is on";
1346
1347 return false;
1348 }
1349
1350 // Get syncer set
1351 CSyncerSet syncerSet;
1352 // ... from system class
1353 getConstSystemClass()->fillSyncerSet(syncerSet);
1354 // Sync
1355 return syncerSet.sync(*_pMainParameterBlackboard, false, strError);
1356}
1357
1358// Content dump
1359void CParameterMgr::logStructureContent(string& strContent) const
1360{
1361 string strError;
1362
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001363 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001364
1365 dumpContent(strContent, parameterAccessContext);
1366}
1367
1368// Configuration/Domains handling
1369bool CParameterMgr::createDomain(const string& strName, string& strError)
1370{
1371 // Check tuning mode
1372 if (!checkTuningModeOn(strError)) {
1373
1374 return false;
1375 }
1376
1377 // Delegate to configurable domains
1378 return getConfigurableDomains()->createDomain(strName, strError);
1379}
1380
1381bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1382{
1383 // Check tuning mode
1384 if (!checkTuningModeOn(strError)) {
1385
1386 return false;
1387 }
1388
1389 // Delegate to configurable domains
1390 return getConfigurableDomains()->deleteDomain(strName, strError);
1391}
1392
1393bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1394{
1395 // Check tuning mode
1396 if (!checkTuningModeOn(strError)) {
1397
1398 return false;
1399 }
1400
1401 // Delegate to configurable domains
1402 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1403}
1404
1405bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1406{
1407 // Check tuning mode
1408 if (!checkTuningModeOn(strError)) {
1409
1410 return false;
1411 }
1412
1413 // Delegate to configurable domains
1414 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1415}
1416
1417bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1418{
1419 // Check tuning mode
1420 if (!checkTuningModeOn(strError)) {
1421
1422 return false;
1423 }
1424
1425 // Delegate to configurable domains
1426 return getConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError);
1427}
1428
1429bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1430{
1431 // Check tuning mode
1432 if (!checkTuningModeOn(strError)) {
1433
1434 return false;
1435 }
1436
1437 // Delegate to configurable domains
1438 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1439}
1440
1441// Configurable element - domain association
1442bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1443{
1444 // Check tuning mode
1445 if (!checkTuningModeOn(strError)) {
1446
1447 return false;
1448 }
1449
1450 CElementLocator elementLocator(getSystemClass());
1451
1452 CElement* pLocatedElement = NULL;
1453
1454 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1455
1456 return false;
1457 }
1458
1459 // Convert element
1460 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1461
1462 // Delegate
1463 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1464}
1465
1466bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1467{
1468 // Check tuning mode
1469 if (!checkTuningModeOn(strError)) {
1470
1471 return false;
1472 }
1473
1474 CElementLocator elementLocator(getSystemClass());
1475
1476 CElement* pLocatedElement = NULL;
1477
1478 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1479
Patrick Benavoli63499d42011-10-24 18:50:03 +02001480 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001481 }
1482
1483 // Convert element
1484 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1485
1486 // Delegate
1487 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1488}
1489
1490bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1491{
1492 // Check tuning mode
1493 if (!checkTuningModeOn(strError)) {
1494
1495 return false;
1496 }
1497
1498 CElementLocator elementLocator(getSystemClass());
1499
1500 CElement* pLocatedElement = NULL;
1501
1502 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1503
Patrick Benavoli63499d42011-10-24 18:50:03 +02001504 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001505 }
1506
1507 // Convert element
1508 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1509
1510 // Delegate
1511 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1512}
1513
1514// XML Import/Export
1515bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError)
1516{
1517 // Check tuning mode
1518 if (!checkTuningModeOn(strError)) {
1519
1520 return false;
1521 }
1522
1523 // check path is absolute
1524 if (strFileName[0] != '/') {
1525
1526 strError = "Please provide absolute path";
1527
1528 return false;
1529 }
1530 // Root element
1531 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1532
1533 // Context
1534 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1535
1536 // Secltion criteria definition for rule creation
1537 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
1538
1539 // Parse
1540 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) {
1541
1542 return false;
1543 }
1544
1545 // Validate domains after XML import
1546 pConfigurableDomains->validate(_pMainParameterBlackboard);
1547
1548 return true;
1549}
1550
1551bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const
1552{
1553 // check path is absolute
1554 if (strFileName[0] != '/') {
1555
1556 strError = "Please provide absolute path";
1557
1558 return false;
1559 }
1560
1561 // Root element
1562 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1563
1564 // Get Schema file associated to root element
1565 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
1566
1567 // Context
1568 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1569
1570 // Value space
1571 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1572
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001573 // Output raw format
1574 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1575
Patrick Benavoli68a91282011-08-31 11:23:23 +02001576 // Instantiate composer
1577 CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext);
1578
1579 // Open composer
1580 if (!xmlComposer.open()) {
1581
1582 return false;
1583 }
1584
1585 // Compose
Patrick Benavoli63499d42011-10-24 18:50:03 +02001586 xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001587
1588 // Close composer
1589 if (!xmlComposer.close()) {
1590
1591 return false;
1592 }
1593
1594 return true;
1595}
1596
1597// Binary Import/Export
1598bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1599{
1600 // Check tuning mode
1601 if (!checkTuningModeOn(strError)) {
1602
1603 return false;
1604 }
1605 // check path is absolute
1606 if (strFileName[0] != '/') {
1607
1608 strError = "Please provide absolute path";
1609
1610 return false;
1611 }
1612 // Root element
1613 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1614
1615 // Serialize in
1616 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1617}
1618
1619bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1620{
1621 // check path is absolute
1622 if (strFileName[0] != '/') {
1623
1624 strError = "Please provide absolute path";
1625
1626 return false;
1627 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001628
Patrick Benavoli68a91282011-08-31 11:23:23 +02001629 // Root element
1630 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1631
1632 // Serialize out
1633 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1634}
1635
1636// For tuning, check we're in tuning mode
1637bool CParameterMgr::checkTuningModeOn(string& strError) const
1638{
1639 // Tuning Mode on?
1640 if (!_bTuningModeIsOn) {
1641
1642 strError = "Tuning Mode must be on";
1643
1644 return false;
1645 }
1646 return true;
1647}
1648
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001649// Parameter access
1650bool CParameterMgr::doSetValue(const string& strPath, const string& strValue, bool bRawValueSpace, bool bDynamicAccess, string& strError)
1651{
1652 CPathNavigator pathNavigator(strPath);
1653
1654 if (!pathNavigator.isPathValid()) {
1655
1656 strError = "Path not well formed";
1657
1658 return false;
1659 }
1660
1661 string* pStrChildName = pathNavigator.next();
1662
1663 if (!pStrChildName) {
1664
1665 strError = "Non settable element";
1666
1667 return false;
1668 }
1669
1670 if (*pStrChildName != getSystemClass()->getName()) {
1671
1672 strError = "Path not found";
1673
1674 return false;
1675 }
1676
1677 // Define context
1678 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, false);
1679
1680 // Set auto sync
1681 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1682
1683 // Set dynamic access
1684 parameterAccessContext.setDynamicAccess(bDynamicAccess);
1685
1686 // Do the set
1687 return getSystemClass()->setValue(pathNavigator, strValue, parameterAccessContext);
1688}
1689
1690bool CParameterMgr::doGetValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, string& strError) const
1691{
1692 CPathNavigator pathNavigator(strPath);
1693
1694 if (!pathNavigator.isPathValid()) {
1695
1696 strError = "Path not well formed";
1697
1698 return false;
1699 }
1700
1701 string* pStrChildName = pathNavigator.next();
1702
1703 if (!pStrChildName) {
1704
1705 strError = "Non settable element";
1706
1707 return false;
1708 }
1709
1710 if (*pStrChildName != getConstSystemClass()->getName()) {
1711
1712 strError = "Path not found";
1713
1714 return false;
1715 }
1716
1717 // Define context
1718 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, bHexOutputRawFormat);
1719
1720 // Set dynamic access
1721 parameterAccessContext.setDynamicAccess(bDynamicAccess);
1722
1723 // Do the get
1724 return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext);
1725}
1726
Patrick Benavoli68a91282011-08-31 11:23:23 +02001727// Dynamic creation library feeding
1728void CParameterMgr::feedElementLibraries()
1729{
1730 // Global Configuration handling
1731 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
1732
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001733 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
1734 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders"));
1735 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation"));
1736 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("ParameterConfiguration"));
1737 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSystemClassConfiguration>("SystemClassConfiguration"));
1738 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
1739 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
1740 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
1741 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001742
1743 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
1744
1745 // Parameter creation
1746 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
1747
1748 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001749 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
1750 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
1751 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
1752 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02001753 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001754 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
1755 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
1756 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
1757 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
1758 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001759
1760 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
1761
1762 // Parameter Configuration Domains creation
1763 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
1764
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001765 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
1766 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
1767 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
1768 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001769
1770 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
1771}
1772
1773// Remote Processor Server connection handling
1774bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
1775{
1776 CAutoLog autoLog(this, "Handling remote processing interface");
1777
1778 // Start server if tuning allowed
1779 if (_pSystemClassConfiguration->isTuningAllowed()) {
1780
1781 log("Loading remote processor library");
1782
1783 // Load library
1784 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
1785
1786 if (!lib_handle) {
1787
1788 // Return error
1789 const char* pcError = dlerror();
1790
1791 if (pcError) {
1792
1793 strError = pcError;
1794 } else {
1795
1796 strError = "Unable to load libremote-processor.so library";
1797 }
1798
1799 return false;
1800 }
1801
1802 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
1803
1804 if (!pfnCreateRemoteProcessorServer) {
1805
1806 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
1807
1808 return false;
1809 }
1810
1811 // Create server
Patrick Benavoli63499d42011-10-24 18:50:03 +02001812 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(_pSystemClassConfiguration->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001813
1814 log("Starting remote processor server on port %d", _pSystemClassConfiguration->getServerPort());
1815 // Start
1816 if (!_pRemoteProcessorServer->start()) {
1817
1818 strError = "Unable to start remote processor server";
1819
1820 return false;
1821 }
1822 }
1823
1824 return true;
1825}
1826
1827// Back synchronization
1828CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const
1829{
1830#ifdef SIMULATION
1831 // In simulation, back synchronization of the blackboard won't probably work
1832 // We need to ensure though the blackboard is initialized with valid data
1833 return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1834#else
1835 // Real back synchronizer from subsystems
1836 return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1837#endif
1838}
1839
1840// Children typwise access
1841CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
1842{
1843 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
1844}
1845
1846const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
1847{
1848 return getFrameworkConfiguration();
1849}
1850
1851CSelectionCriteria* CParameterMgr::getSelectionCriteria()
1852{
1853 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
1854}
1855
1856const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
1857{
1858 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
1859}
1860
1861CSystemClass* CParameterMgr::getSystemClass()
1862{
1863 return static_cast<CSystemClass*>(getChild(ESystemClass));
1864}
1865
1866const CSystemClass* CParameterMgr::getConstSystemClass() const
1867{
1868 return static_cast<const CSystemClass*>(getChild(ESystemClass));
1869}
1870
1871// Configurable Domains
1872CConfigurableDomains* CParameterMgr::getConfigurableDomains()
1873{
1874 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
1875}
1876
1877const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
1878{
1879 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1880}
1881
1882const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
1883{
1884 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1885}