blob: 83867d59fa86abd818a6ec44622766884d6e1d72 [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 Benavoli9fc3c0d2011-10-27 14:27:27 +020067#include "EnumParameterType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020068#include "RemoteProcessorServerInterface.h"
69#include "ElementLocator.h"
70#include "AutoLog.h"
71#include "CompoundRule.h"
72#include "SelectionCriterionRule.h"
73#include "SimulatedBackSynchronizer.h"
74#include "HardwareBackSynchronizer.h"
Patrick Benavoli1387bda2011-08-31 11:23:24 +020075#include "AutoLock.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020076#include <strings.h>
77#include <dlfcn.h>
78#include <assert.h>
Patrick Benavoli68a91282011-08-31 11:23:23 +020079
80#define base CElement
81
82// Used for remote processor server creation
83typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler);
84
85// Global configuration file name (fixed)
86const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml";
87const char* gacSystemSchemasSubFolder = "Schemas";
88
89// Config File System looks normally like this:
90// ---------------------------------------------
91//├── ParameterFrameworkConfiguration.xml
92//├── Schemas
93//│ └── *.xsd
94//├── Settings
95//│ └── <SystemClassName folder>*
96//│ ├── <ConfigurableDomains>.xml
97//│ └── <Settings>.bin?
98//└── Structure
99// └── <SystemClassName folder>*
100// ├── <SystemClassName>Class.xml
101// └── <Subsystem>.xml*
102// --------------------------------------------
103
104
105// Remote command parser array
Patrick Benavoli592ae562011-09-05 16:53:58 +0200106const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
Patrick Benavoli592ae562011-09-05 16:53:58 +0200107 /// Version
108 { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200109 /// Status
110 { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" },
111 /// Tuning Mode
112 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" },
113 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" },
114 /// Value Space
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200115 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200116 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200117 /// Output Raw Format
118 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
119 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200120 /// Sync
121 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
122 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" },
123 { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200124 /// Criteria
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200125 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200126 /// Domains
127 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" },
128 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" },
129 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" },
130 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200131 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" },
132 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200133 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" },
134 { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" },
135 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
136 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" },
137 /// Configurations
138 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" },
139 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" },
140 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" },
141 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" },
142 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" },
143 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200144 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 2, "<domain> <configuration> <elem path list>", "Set element application order for configuration" },
145 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200146 /// Elements/Parameters
147 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" },
Patrick Benavoli592ae562011-09-05 16:53:58 +0200148 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200149 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" },
150 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200151 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200152 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200153 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200154 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200155 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" },
156 /// Browse
157 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" },
158 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" },
159 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" },
160 /// Settings Import/Export
161 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" },
162 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" },
163 { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" },
164 { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" },
165 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" },
166 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }
167};
168// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200169const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200170
171CParameterMgr::CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName) :
172 _bTuningModeIsOn(false),
173 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200174 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200175 _bAutoSyncOn(true),
176 _pMainParameterBlackboard(new CParameterBlackboard),
177 _pElementLibrarySet(new CElementLibrarySet),
178 _strParameterFrameworkConfigurationFolderPath(strParameterFrameworkConfigurationFolderPath),
179 _strSchemaFolderLocation(strParameterFrameworkConfigurationFolderPath + "/" + gacSystemSchemasSubFolder),
180 _pSystemClassConfiguration(NULL),
181 _uiStructureChecksum(0),
182 _pRemoteProcessorServer(NULL),
183 _uiMaxCommandUsageLength(0),
184 _pLogger(NULL),
185 _uiLogDepth(0)
186{
187 // Tuning Mode Mutex
188 bzero(&_tuningModeMutex, sizeof(_tuningModeMutex));
189 pthread_mutex_init(&_tuningModeMutex, NULL);
190
191 // Deal with children
192 addChild(new CParameterFrameworkConfiguration);
193 addChild(new CSelectionCriteria);
194 addChild(new CSystemClass(strSystemClassName));
195 addChild(new CConfigurableDomains(strSystemClassName));
196
197 // Feed element library
198 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200199
200 _pCommandHandler = new CCommandHandler(this);
201
202 // Add command parsers
203 uint32_t uiRemoteCommandParserItem;
204
205 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
206
207 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
208
209 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
210 pRemoteCommandParserItem->_pfnParser,
211 pRemoteCommandParserItem->_uiMinArgumentCount,
212 pRemoteCommandParserItem->_pcHelp,
213 pRemoteCommandParserItem->_pcDescription);
214 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200215}
216
217CParameterMgr::~CParameterMgr()
218{
219 // Children
220 delete _pRemoteProcessorServer;
221 delete _pMainParameterBlackboard;
222 delete _pElementLibrarySet;
223
224 // Tuning Mode Mutex
225 pthread_mutex_destroy(&_tuningModeMutex);
226}
227
228string CParameterMgr::getKind() const
229{
230 return "ParameterMgr";
231}
232
233// Logging
234void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
235{
236 _pLogger = pLogger;
237}
238
239// Logging
240void CParameterMgr::doLog(const string& strLog) const
241{
242 if (_pLogger) {
243
244 // Nest
245 string strIndent;
246
247 // Level
248 uint32_t uiNbIndents = _uiLogDepth;
249
250 while (uiNbIndents--) {
251
252 strIndent += " ";
253 }
254
255 // Log
256 _pLogger->log(strIndent + strLog);
257 }
258}
259
260void CParameterMgr::nestLog() const
261{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200262 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200263}
264
265void CParameterMgr::unnestLog() const
266{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200267 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200268}
269
Patrick Benavoli63499d42011-10-24 18:50:03 +0200270// Version
271string CParameterMgr::getVersion() const
272{
273 string strVersion;
274
275 // Major
276 strVersion = toString(guiEditionMajor) + ".";
277 // Minor
278 strVersion += toString(guiEditionMinor) + ".";
279 // Revision
280 strVersion += toString(guiRevision);
281
282 return strVersion;
283}
284
Patrick Benavoli68a91282011-08-31 11:23:23 +0200285bool CParameterMgr::load(string& strError)
286{
287 CAutoLog autoLog(this, "Loading");
288
289 // Load Framework configuration
290 if (!loadFrameworkConfiguration(strError)) {
291
292 return false;
293 }
294
295 // Load subsystems
296 if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) {
297
298 return false;
299 }
300
301 // Load structure
302 if (!loadStructure(strError)) {
303
304 return false;
305 }
306
307 // Load settings
308 if (!loadSettings(strError)) {
309
310 return false;
311 }
312
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200313 // Back synchronization for areas in parameter blackboard not covered by any domain
314 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200315
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200316 log("Main blackboard back synchronization");
317
318 // Back-synchronize
319 if (!pBackSynchronizer->sync()) {
320 // Get rid of back synchronizer
321 delete pBackSynchronizer;
322
323 strError = "Main blackboard back synchronization failed: " + strError;
324
325 return false;
326 }
327 // Get rif of back synchronizer
328 delete pBackSynchronizer;
329
330 // We're done loading the settings and back synchronizing
331 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
332
333 // We need to ensure all domains are valid
334 pConfigurableDomains->validate(_pMainParameterBlackboard);
335
336 // Ensure application of currently selected configurations
337 // Force-apply configurations
338 if (!pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200339
340 return false;
341 }
342
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200343 // Start remote processor server if appropriate
344 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200345}
346
347bool CParameterMgr::loadFrameworkConfiguration(string& strError)
348{
349 CAutoLog autoLog(this, "Loading framework configuration");
350
351 // Get Xml config file name
352 string strXmlConfigurationFilePath = _strParameterFrameworkConfigurationFolderPath + "/" + gacParameterFrameworkConfigurationFileName;
353
354 // Parse Structure XML file
355 CXmlElementSerializingContext elementSerializingContext(strError);
356
357 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), strXmlConfigurationFilePath, _strParameterFrameworkConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
358
359 return false;
360 }
361 // Get subsystem plugins folders element
362 const CFrameworkConfigurationGroup* pSubsystemPluginFolders= static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders"));
363
364 if (!pSubsystemPluginFolders) {
365
366 strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element";
367
368 return false;
369 }
370 // Get plugin locations
371 uint32_t uiPluginFolderLocation;
372 uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren();
373
374 if (!uiNbPluginFolderLocations) {
375
376 strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element";
377
378 return false;
379 }
380
381 for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) {
382
383 const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation));
384
385 _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath));
386 }
387
388 // Get configuration for current system class
389 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("ParameterConfiguration"));
390
391 if (!pParameterConfigurationGroup) {
392
393 strError = "Parameter Framework Configuration: couldn't find ParameterConfiguration element";
394
395 return false;
396 }
397 _pSystemClassConfiguration = static_cast<const CSystemClassConfiguration*>(pParameterConfigurationGroup->findChild(getSystemClass()->getName()));
398
399 if (!_pSystemClassConfiguration) {
400
401 strError = "No framework configuration found for SystemClass " + getSystemClass()->getName();
402
403 return false;
404 }
405 // Log tuning availability
406 log("Tuning %s", _pSystemClassConfiguration->isTuningAllowed() ? "allowed" : "prohibited");
407
408 return true;
409}
410
411bool CParameterMgr::loadStructure(string& strError)
412{
413 // Retrieve system to load structure to
414 CSystemClass* pSystemClass = getSystemClass();
415
416 CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure");
417
418 // Get structure description element
419 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(_pSystemClassConfiguration->findChildOfKind("StructureDescriptionFileLocation"));
420
421 if (!pStructureDescriptionFileLocation) {
422
423 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
424
425 return false;
426 }
427
428 // Get Xml structure folder
429 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath);
430
431 // Get Xml structure file name
432 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath);
433
434 // Parse Structure XML file
435 CXmlParameterSerializingContext parameterBuildContext(strError);
436
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200437 log("Importing system structure from file %s", strXmlStructureFilePath.c_str());
438
Patrick Benavoli68a91282011-08-31 11:23:23 +0200439 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
440
441 return false;
442 }
443
444 // Initialize offsets
445 pSystemClass->setOffset(0);
446
447 // Initialize main blackboard's size
448 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
449
450 return true;
451}
452
453bool CParameterMgr::loadSettings(string& strError)
454{
455 CAutoLog autoLog(this, "Loading settings");
456
457 // Get settings configuration element
458 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(_pSystemClassConfiguration->findChildOfKind("SettingsConfiguration"));
459
460 if (!pParameterConfigurationGroup) {
461
462 // No settings to load
463
464 return true;
465 }
466 // Get binary settings file location
467 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
468
469 string strXmlBinarySettingsFilePath;
470
471 if (pBinarySettingsFileLocation) {
472
473 // Get Xml binary settings file name
474 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath);
475 }
476
477 // Get configurable domains element
478 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
479
480 if (!pConfigurableDomainsFileLocation) {
481
482 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
483
484 return false;
485 }
486 // Get destination root element
487 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
488
489 // Get Xml configuration domains file name
490 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strParameterFrameworkConfigurationFolderPath);
491
492 // Get Xml configuration domains folder
493 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strParameterFrameworkConfigurationFolderPath);
494
495 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
496 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
497
498 // Selection criteria definition for rule creation
499 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
500
Patrick Benavoli63499d42011-10-24 18:50:03 +0200501 // Auto validation of configurations if no binary settings provided
502 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
503
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200504 log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
505
Patrick Benavoli68a91282011-08-31 11:23:23 +0200506 // Do parse
507 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
508
509 return false;
510 }
511 // We have loaded the whole system structure, compute checksum
512 const CSystemClass* pSystemClass = getConstSystemClass();
513 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
514
515 // Load binary settings if any provided
516 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
517
518 return false;
519 }
520
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200521 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200522}
523
524// XML parsing
525bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
526{
527 // Init serializing context
528 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
529
530 // Get Schema file associated to root element
531 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
532
533 // Parse Structure XML file
534 CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext);
535
536 if (!parser.open()) {
537
538 return false;
539 }
540
541 // Check Root element name attribute (if any)
542 string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName);
543
544 if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) {
545
546 elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath);
547 elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName());
548
549 return false;
550 }
551
552 // Start clean
553 pRootElement->clean();
554
555 // Parse
556 if (!parser.parse(pRootElement)) {
557
558 // Cleanup
559 pRootElement->clean();
560
561 return false;
562 }
563
564 // Close parser
565 if (!parser.close()) {
566
567 return false;
568 }
569
570 return true;
571}
572
573// Init
574bool CParameterMgr::init(string& strError)
575{
576 return base::init(strError);
577}
578
579// Selection criteria interface
580CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
581{
582 // Propagate
583 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
584}
585
586CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
587{
588 // Propagate
589 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
590}
591
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200592// Selection criterion retrieval
593CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200594{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200595 // Propagate
596 return getSelectionCriteria()->getSelectionCriterion(strName);
597}
598
599// Selection criteria changed event
600bool CParameterMgr::applyConfigurations(string& strError)
601{
602 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200603
604 // Lock state
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200605 CAutoLock autoLock(&_tuningModeMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200606
607 if (!_bTuningModeIsOn) {
608
609 // Apply configuration(s)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200610 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) {
611
612 log("Failed to apply configurations!");
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200613
614 return false;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200615 }
616 }
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200617
618 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200619}
620
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200621// Dynamic parameter handling
622bool CParameterMgr::setValue(const string& strPath, const string& strValue, bool bRawValueSpace, string& strError)
623{
624 // Delegate to low level functionality
625 return doSetValue(strPath, strValue, bRawValueSpace, true, strError);
626}
627
628bool CParameterMgr::getValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, string& strError) const
629{
630 // Delegate to low level functionality
631 return doGetValue(strPath, strValue, bRawValueSpace, bHexOutputRawFormat, true, strError);
632}
633
Patrick Benavoli68a91282011-08-31 11:23:23 +0200634/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200635/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200636CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200637{
638 (void)remoteCommand;
639
Patrick Benavoli63499d42011-10-24 18:50:03 +0200640 // Show version
641 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200642
Patrick Benavoli63499d42011-10-24 18:50:03 +0200643 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200644}
645
Patrick Benavoli68a91282011-08-31 11:23:23 +0200646/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200647CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200648{
649 (void)remoteCommand;
650 // System class
651 const CSystemClass* pSystemClass = getSystemClass();
652
Patrick Benavoli68a91282011-08-31 11:23:23 +0200653 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200654 /// General section
655 appendTitle(strResult, "General:");
656 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200657 strResult += "System Class: ";
658 strResult += pSystemClass->getName();
659 strResult += "\n";
660
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200661 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200662 strResult += "Tuning Mode: ";
663 strResult += tuningModeOn() ? "on" : "off";
664 strResult += "\n";
665
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200666 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200667 strResult += "Value Space: ";
668 strResult += valueSpaceIsRaw() ? "raw" : "real";
669 strResult += "\n";
670
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200671 // Output raw format
672 strResult += "Output Raw Format: ";
673 strResult += outputRawFormatIsHex() ? "hex" : "dec";
674 strResult += "\n";
675
676 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200677 strResult += "Auto Sync: ";
678 strResult += autoSyncOn() ? "on" : "off";
679 strResult += "\n";
680
681 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200682 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200683 string strSubsystemList;
684 pSystemClass->listChildrenPaths(strSubsystemList);
685 strResult += strSubsystemList;
686
687 /// Last applied configurations
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200688 appendTitle(strResult, "Last applied configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200689 string strLastAppliedConfigurations;
690 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
691 strResult += strLastAppliedConfigurations;
692
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200693 /// Criteria states
694 appendTitle(strResult, "Selection criteria:");
695 string strSelectionCriteria;
696 getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false);
697 strResult += strSelectionCriteria;
698
Patrick Benavoli63499d42011-10-24 18:50:03 +0200699 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200700}
701
702/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200703CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200704{
705 if (remoteCommand.getArgument(0) == "on") {
706
707 if (setTuningMode(true, strResult)) {
708
Patrick Benavoli63499d42011-10-24 18:50:03 +0200709 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200710 }
711 } else if (remoteCommand.getArgument(0) == "off") {
712
713 if (setTuningMode(false, strResult)) {
714
Patrick Benavoli63499d42011-10-24 18:50:03 +0200715 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200716 }
717 } else {
718 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200719 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200720 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200721 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200722}
723
Patrick Benavoli63499d42011-10-24 18:50:03 +0200724CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200725{
726 (void)remoteCommand;
727
728 strResult = tuningModeOn() ? "on" : "off";
729
Patrick Benavoli63499d42011-10-24 18:50:03 +0200730 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200731}
732
733/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200734CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200735{
736 (void)strResult;
737
738 if (remoteCommand.getArgument(0) == "raw") {
739
740 setValueSpace(true);
741
Patrick Benavoli63499d42011-10-24 18:50:03 +0200742 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200743
744 } else if (remoteCommand.getArgument(0) == "real") {
745
746 setValueSpace(false);
747
Patrick Benavoli63499d42011-10-24 18:50:03 +0200748 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200749
750 } else {
751 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200752 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200753 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200754 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200755}
756
Patrick Benavoli63499d42011-10-24 18:50:03 +0200757CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200758{
759 (void)remoteCommand;
760
761 strResult = valueSpaceIsRaw() ? "raw" : "real";
762
Patrick Benavoli63499d42011-10-24 18:50:03 +0200763 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200764}
765
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200766/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200767CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200768{
769 (void)strResult;
770
771 if (remoteCommand.getArgument(0) == "hex") {
772
773 setOutputRawFormat(true);
774
Patrick Benavoli63499d42011-10-24 18:50:03 +0200775 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200776
777 } else if (remoteCommand.getArgument(0) == "dec") {
778
779 setOutputRawFormat(false);
780
Patrick Benavoli63499d42011-10-24 18:50:03 +0200781 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200782
783 } else {
784 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200785 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200786 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200787 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200788}
789
Patrick Benavoli63499d42011-10-24 18:50:03 +0200790CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200791{
792 (void)remoteCommand;
793
794 strResult = outputRawFormatIsHex() ? "hex" : "dec";
795
Patrick Benavoli63499d42011-10-24 18:50:03 +0200796 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200797}
798
Patrick Benavoli68a91282011-08-31 11:23:23 +0200799/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200800CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200801{
802 if (remoteCommand.getArgument(0) == "on") {
803
804 if (setAutoSync(true, strResult)) {
805
Patrick Benavoli63499d42011-10-24 18:50:03 +0200806 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200807 }
808 } else if (remoteCommand.getArgument(0) == "off") {
809
810 if (setAutoSync(false, strResult)) {
811
Patrick Benavoli63499d42011-10-24 18:50:03 +0200812 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200813 }
814 } else {
815 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200816 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200817 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200818 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200819}
820
Patrick Benavoli63499d42011-10-24 18:50:03 +0200821CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200822{
823 (void)remoteCommand;
824
825 strResult = autoSyncOn() ? "on" : "off";
826
Patrick Benavoli63499d42011-10-24 18:50:03 +0200827 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200828}
829
Patrick Benavoli63499d42011-10-24 18:50:03 +0200830CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200831{
832 (void)remoteCommand;
833
Patrick Benavoli63499d42011-10-24 18:50:03 +0200834 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200835}
836
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200837/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200838CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200839{
840 (void)remoteCommand;
841
842 getSelectionCriteria()->listSelectionCriteria(strResult, true);
843
Patrick Benavoli63499d42011-10-24 18:50:03 +0200844 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200845}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200846
847/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200848CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200849{
850 (void)remoteCommand;
851
Patrick Benavoli63499d42011-10-24 18:50:03 +0200852 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200853
Patrick Benavoli63499d42011-10-24 18:50:03 +0200854 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200855}
856
Patrick Benavoli63499d42011-10-24 18:50:03 +0200857CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200858{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200859 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200860}
861
Patrick Benavoli63499d42011-10-24 18:50:03 +0200862CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200863{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200864 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200865}
866
Patrick Benavoli63499d42011-10-24 18:50:03 +0200867CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200868{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200869 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200870}
871
Patrick Benavoli63499d42011-10-24 18:50:03 +0200872CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200873{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200874 // Check tuning mode
875 if (!checkTuningModeOn(strResult)) {
876
877 return CCommandHandler::EFailed;
878 }
879
880 // Set property
881 bool bSequenceAware;
882
883 if (remoteCommand.getArgument(1) == "true") {
884
885 bSequenceAware = true;
886
887 } else if (remoteCommand.getArgument(1) == "false") {
888
889 bSequenceAware = false;
890
891 } else {
892 // Show usage
893 return CCommandHandler::EShowUsage;
894 }
895
896 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200897}
898
Patrick Benavoli63499d42011-10-24 18:50:03 +0200899CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200900{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200901 // Get property
902 bool bSequenceAware;
903
904 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
905
906 return CCommandHandler::EFailed;
907 }
908
909 strResult = bSequenceAware ? "true" : "false";
910
911 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200912}
913
Patrick Benavoli63499d42011-10-24 18:50:03 +0200914CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200915{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200916 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200917}
918
Patrick Benavoli63499d42011-10-24 18:50:03 +0200919CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200920{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200921 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
922}
923
924CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
925{
926 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
927}
928
929CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
930{
931 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200932}
933
934/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +0200935CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200936{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200937 return getConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200938}
939
Patrick Benavoli63499d42011-10-24 18:50:03 +0200940CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200941{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200942 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200943}
944
Patrick Benavoli63499d42011-10-24 18:50:03 +0200945CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200946{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200947 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200948}
949
Patrick Benavoli63499d42011-10-24 18:50:03 +0200950CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200951{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200952 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200953}
954
Patrick Benavoli63499d42011-10-24 18:50:03 +0200955CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200956{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200957 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200958}
959
Patrick Benavoli63499d42011-10-24 18:50:03 +0200960CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200961{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200962 return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
963}
964
965CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
966{
967 // Check tuning mode
968 if (!checkTuningModeOn(strResult)) {
969
970 return CCommandHandler::EFailed;
971 }
972
973 // Build configurable element path list
974 vector<string> astrNewElementSequence;
975
976 uint32_t uiArgument;
977
978 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
979
980 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
981 }
982
983 // Delegate to configurable domains
984 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
985}
986
987CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
988{
989 // Delegate to configurable domains
990 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200991}
992
993/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +0200994CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200995{
996 CElementLocator elementLocator(getSystemClass(), false);
997
998 CElement* pLocatedElement = NULL;
999
1000 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1001
Patrick Benavoli63499d42011-10-24 18:50:03 +02001002 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001003 }
1004
1005 strResult = string("\n");
1006
1007 if (!pLocatedElement) {
1008
1009 // List from root folder
1010
1011 // Return system class qualified name
1012 pLocatedElement = getSystemClass();
1013 }
1014
1015 // Return sub-elements
1016 strResult += pLocatedElement->listQualifiedPaths(false);
1017
Patrick Benavoli63499d42011-10-24 18:50:03 +02001018 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001019}
1020
1021/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001022CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001023{
1024 CElementLocator elementLocator(getSystemClass(), false);
1025
1026 CElement* pLocatedElement = NULL;
1027
1028 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1029
Patrick Benavoli63499d42011-10-24 18:50:03 +02001030 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001031 }
1032
1033 strResult = string("\n");
1034
1035 if (!pLocatedElement) {
1036
1037 // List from root folder
1038
1039 // Return system class qualified name
1040 pLocatedElement = getSystemClass();
1041 }
1042
1043 // Return sub-elements
1044 strResult += pLocatedElement->listQualifiedPaths(true);
1045
Patrick Benavoli63499d42011-10-24 18:50:03 +02001046 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001047}
1048
Patrick Benavoli63499d42011-10-24 18:50:03 +02001049CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001050{
1051 CElementLocator elementLocator(getSystemClass());
1052
1053 CElement* pLocatedElement = NULL;
1054
1055 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1056
Patrick Benavoli63499d42011-10-24 18:50:03 +02001057 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001058 }
1059
1060 string strError;
1061
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001062 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001063
1064 // Dump elements
1065 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1066
Patrick Benavoli63499d42011-10-24 18:50:03 +02001067 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001068}
1069
Patrick Benavoli63499d42011-10-24 18:50:03 +02001070CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001071{
1072 CElementLocator elementLocator(getSystemClass());
1073
1074 CElement* pLocatedElement = NULL;
1075
1076 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1077
Patrick Benavoli63499d42011-10-24 18:50:03 +02001078 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001079 }
1080
1081 // Converted to actual sizable element
1082 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1083
1084 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001085 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001086
Patrick Benavoli63499d42011-10-24 18:50:03 +02001087 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001088}
1089
Patrick Benavoli63499d42011-10-24 18:50:03 +02001090CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001091{
1092 CElementLocator elementLocator(getSystemClass());
1093
1094 CElement* pLocatedElement = NULL;
1095
1096 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1097
Patrick Benavoli63499d42011-10-24 18:50:03 +02001098 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001099 }
1100
1101 // Convert element
1102 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1103
1104 // Return element properties
1105 pConfigurableElement->showProperties(strResult);
1106
Patrick Benavoli63499d42011-10-24 18:50:03 +02001107 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001108}
1109
Patrick Benavoli63499d42011-10-24 18:50:03 +02001110CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001111{
1112 string strValue;
1113
1114 if (!getValue(remoteCommand.getArgument(0), strValue, strResult)) {
1115
Patrick Benavoli63499d42011-10-24 18:50:03 +02001116 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001117 }
1118 // Succeeded
1119 strResult = strValue;
1120
Patrick Benavoli63499d42011-10-24 18:50:03 +02001121 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001122}
1123
Patrick Benavoli63499d42011-10-24 18:50:03 +02001124CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001125{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001126 return setValue(remoteCommand.getArgument(0), remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 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::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001130{
1131 CElementLocator elementLocator(getSystemClass());
1132
1133 CElement* pLocatedElement = NULL;
1134
1135 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1136
Patrick Benavoli63499d42011-10-24 18:50:03 +02001137 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001138 }
1139
1140 // Convert element
1141 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1142
1143 // Return element belonging domains
1144 pConfigurableElement->listBelongingDomains(strResult);
1145
Patrick Benavoli63499d42011-10-24 18:50:03 +02001146 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001147}
1148
Patrick Benavoli63499d42011-10-24 18:50:03 +02001149CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001150{
1151 CElementLocator elementLocator(getSystemClass());
1152
1153 CElement* pLocatedElement = NULL;
1154
1155 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1156
Patrick Benavoli63499d42011-10-24 18:50:03 +02001157 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001158 }
1159
1160 // Convert element
1161 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1162
1163 // Return element belonging domains
1164 pConfigurableElement->listAssociatedDomains(strResult);
1165
Patrick Benavoli63499d42011-10-24 18:50:03 +02001166 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001167}
1168
Patrick Benavoli63499d42011-10-24 18:50:03 +02001169CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001170{
1171 (void)remoteCommand;
1172
1173 getConfigurableDomains()->listAssociatedElements(strResult);
1174
Patrick Benavoli63499d42011-10-24 18:50:03 +02001175 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001176}
1177
Patrick Benavoli63499d42011-10-24 18:50:03 +02001178CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001179{
1180 (void)remoteCommand;
1181
1182 getConfigurableDomains()->listConflictingElements(strResult);
1183
Patrick Benavoli63499d42011-10-24 18:50:03 +02001184 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001185}
1186
Patrick Benavoli63499d42011-10-24 18:50:03 +02001187CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001188{
1189 (void)remoteCommand;
1190
1191 getSystemClass()->listRogueElements(strResult);
1192
Patrick Benavoli63499d42011-10-24 18:50:03 +02001193 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001194}
1195
1196/// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +02001197CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001198{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001199 return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001200}
1201
Patrick Benavoli63499d42011-10-24 18:50:03 +02001202CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001203{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001204 return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001205}
1206
Patrick Benavoli63499d42011-10-24 18:50:03 +02001207CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001208{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001209 return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001210}
1211
Patrick Benavoli63499d42011-10-24 18:50:03 +02001212CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001213{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001214 return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001215}
1216
Patrick Benavoli63499d42011-10-24 18:50:03 +02001217CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001218{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001219 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001220}
1221
Patrick Benavoli63499d42011-10-24 18:50:03 +02001222CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001223{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001224 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001225}
1226
1227// User set/get parameters
1228bool CParameterMgr::setValue(const string& strPath, const string& strValue, string& strError)
1229{
1230 // Check tuning mode
1231 if (!checkTuningModeOn(strError)) {
1232
1233 return false;
1234 }
1235
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001236 // Delegate to low level functionality
1237 return doSetValue(strPath, strValue, _bValueSpaceIsRaw, false, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001238}
1239
1240bool CParameterMgr::getValue(const string& strPath, string& strValue, string& strError) const
1241{
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001242 // Delegate to low level functionality
1243 return doGetValue(strPath, strValue, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, false, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001244}
1245
1246// Tuning mode
1247bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1248{
1249 // Tuning allowed?
1250 if (bOn && !_pSystemClassConfiguration->isTuningAllowed()) {
1251
1252 strError = "Tuning prohibited";
1253
1254 return false;
1255 }
1256 // Lock state
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001257 CAutoLock autoLock(&_tuningModeMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001258
1259 // Warn domains about exiting tuning mode
1260 if (!bOn && _bTuningModeIsOn) {
1261
1262 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001263 // Force-apply configurations
Patrick Benavoli68a91282011-08-31 11:23:23 +02001264 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) {
1265
1266 return false;
1267 }
1268 // Turn auto sync back on
1269 _bAutoSyncOn = true;
1270 }
1271
1272 // Store
1273 _bTuningModeIsOn = bOn;
1274
Patrick Benavoli68a91282011-08-31 11:23:23 +02001275 return true;
1276}
1277
1278bool CParameterMgr::tuningModeOn() const
1279{
1280 return _bTuningModeIsOn;
1281}
1282
1283// Current value space for user set/get value interpretation
1284void CParameterMgr::setValueSpace(bool bIsRaw)
1285{
1286 _bValueSpaceIsRaw = bIsRaw;
1287}
1288
1289bool CParameterMgr::valueSpaceIsRaw()
1290{
1291 return _bValueSpaceIsRaw;
1292}
1293
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001294// Current Output Raw Format for user get value interpretation
1295void CParameterMgr::setOutputRawFormat(bool bIsHex)
1296{
1297 _bOutputRawFormatIsHex = bIsHex;
1298}
1299
1300bool CParameterMgr::outputRawFormatIsHex()
1301{
1302 return _bOutputRawFormatIsHex;
1303}
1304
Patrick Benavoli68a91282011-08-31 11:23:23 +02001305/// Sync
1306// Automatic hardware synchronization control (during tuning session)
1307bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1308{
1309 // Check tuning mode
1310 if (!checkTuningModeOn(strError)) {
1311
1312 return false;
1313 }
1314 // Warn domains about turning auto sync back on
1315 if (bAutoSyncOn && !_bAutoSyncOn) {
1316
Patrick Benavoli592ae562011-09-05 16:53:58 +02001317 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1318 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001319
1320 return false;
1321 }
1322 }
1323
1324 // Set Auto sync
1325 _bAutoSyncOn = bAutoSyncOn;
1326
1327 return true;
1328}
1329
1330bool CParameterMgr::autoSyncOn() const
1331{
1332 return _bAutoSyncOn;
1333}
1334
1335// Manual hardware synchronization control (during tuning session)
1336bool CParameterMgr::sync(string& strError)
1337{
1338 // Check tuning mode
1339 if (!checkTuningModeOn(strError)) {
1340
1341 return false;
1342 }
1343 // Warn domains about turning auto sync back on
1344 if (_bAutoSyncOn) {
1345
1346 strError = "Feature unavailable when Auto Sync is on";
1347
1348 return false;
1349 }
1350
1351 // Get syncer set
1352 CSyncerSet syncerSet;
1353 // ... from system class
1354 getConstSystemClass()->fillSyncerSet(syncerSet);
1355 // Sync
1356 return syncerSet.sync(*_pMainParameterBlackboard, false, strError);
1357}
1358
1359// Content dump
1360void CParameterMgr::logStructureContent(string& strContent) const
1361{
1362 string strError;
1363
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001364 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001365
1366 dumpContent(strContent, parameterAccessContext);
1367}
1368
1369// Configuration/Domains handling
1370bool CParameterMgr::createDomain(const string& strName, string& strError)
1371{
1372 // Check tuning mode
1373 if (!checkTuningModeOn(strError)) {
1374
1375 return false;
1376 }
1377
1378 // Delegate to configurable domains
1379 return getConfigurableDomains()->createDomain(strName, strError);
1380}
1381
1382bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1383{
1384 // Check tuning mode
1385 if (!checkTuningModeOn(strError)) {
1386
1387 return false;
1388 }
1389
1390 // Delegate to configurable domains
1391 return getConfigurableDomains()->deleteDomain(strName, strError);
1392}
1393
1394bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1395{
1396 // Check tuning mode
1397 if (!checkTuningModeOn(strError)) {
1398
1399 return false;
1400 }
1401
1402 // Delegate to configurable domains
1403 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1404}
1405
1406bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1407{
1408 // Check tuning mode
1409 if (!checkTuningModeOn(strError)) {
1410
1411 return false;
1412 }
1413
1414 // Delegate to configurable domains
1415 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1416}
1417
1418bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1419{
1420 // Check tuning mode
1421 if (!checkTuningModeOn(strError)) {
1422
1423 return false;
1424 }
1425
1426 // Delegate to configurable domains
1427 return getConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError);
1428}
1429
1430bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1431{
1432 // Check tuning mode
1433 if (!checkTuningModeOn(strError)) {
1434
1435 return false;
1436 }
1437
1438 // Delegate to configurable domains
1439 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1440}
1441
1442// Configurable element - domain association
1443bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1444{
1445 // Check tuning mode
1446 if (!checkTuningModeOn(strError)) {
1447
1448 return false;
1449 }
1450
1451 CElementLocator elementLocator(getSystemClass());
1452
1453 CElement* pLocatedElement = NULL;
1454
1455 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1456
1457 return false;
1458 }
1459
1460 // Convert element
1461 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1462
1463 // Delegate
1464 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1465}
1466
1467bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1468{
1469 // Check tuning mode
1470 if (!checkTuningModeOn(strError)) {
1471
1472 return false;
1473 }
1474
1475 CElementLocator elementLocator(getSystemClass());
1476
1477 CElement* pLocatedElement = NULL;
1478
1479 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1480
Patrick Benavoli63499d42011-10-24 18:50:03 +02001481 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001482 }
1483
1484 // Convert element
1485 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1486
1487 // Delegate
1488 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1489}
1490
1491bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1492{
1493 // Check tuning mode
1494 if (!checkTuningModeOn(strError)) {
1495
1496 return false;
1497 }
1498
1499 CElementLocator elementLocator(getSystemClass());
1500
1501 CElement* pLocatedElement = NULL;
1502
1503 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1504
Patrick Benavoli63499d42011-10-24 18:50:03 +02001505 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001506 }
1507
1508 // Convert element
1509 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1510
1511 // Delegate
1512 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1513}
1514
1515// XML Import/Export
1516bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError)
1517{
1518 // Check tuning mode
1519 if (!checkTuningModeOn(strError)) {
1520
1521 return false;
1522 }
1523
1524 // check path is absolute
1525 if (strFileName[0] != '/') {
1526
1527 strError = "Please provide absolute path";
1528
1529 return false;
1530 }
1531 // Root element
1532 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1533
1534 // Context
1535 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1536
1537 // Secltion criteria definition for rule creation
1538 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
1539
1540 // Parse
1541 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) {
1542
1543 return false;
1544 }
1545
1546 // Validate domains after XML import
1547 pConfigurableDomains->validate(_pMainParameterBlackboard);
1548
1549 return true;
1550}
1551
1552bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const
1553{
1554 // check path is absolute
1555 if (strFileName[0] != '/') {
1556
1557 strError = "Please provide absolute path";
1558
1559 return false;
1560 }
1561
1562 // Root element
1563 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1564
1565 // Get Schema file associated to root element
1566 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
1567
1568 // Context
1569 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1570
1571 // Value space
1572 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1573
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001574 // Output raw format
1575 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1576
Patrick Benavoli68a91282011-08-31 11:23:23 +02001577 // Instantiate composer
1578 CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext);
1579
1580 // Open composer
1581 if (!xmlComposer.open()) {
1582
1583 return false;
1584 }
1585
1586 // Compose
Patrick Benavoli63499d42011-10-24 18:50:03 +02001587 xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001588
1589 // Close composer
1590 if (!xmlComposer.close()) {
1591
1592 return false;
1593 }
1594
1595 return true;
1596}
1597
1598// Binary Import/Export
1599bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1600{
1601 // Check tuning mode
1602 if (!checkTuningModeOn(strError)) {
1603
1604 return false;
1605 }
1606 // check path is absolute
1607 if (strFileName[0] != '/') {
1608
1609 strError = "Please provide absolute path";
1610
1611 return false;
1612 }
1613 // Root element
1614 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1615
1616 // Serialize in
1617 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1618}
1619
1620bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1621{
1622 // check path is absolute
1623 if (strFileName[0] != '/') {
1624
1625 strError = "Please provide absolute path";
1626
1627 return false;
1628 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001629
Patrick Benavoli68a91282011-08-31 11:23:23 +02001630 // Root element
1631 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1632
1633 // Serialize out
1634 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1635}
1636
1637// For tuning, check we're in tuning mode
1638bool CParameterMgr::checkTuningModeOn(string& strError) const
1639{
1640 // Tuning Mode on?
1641 if (!_bTuningModeIsOn) {
1642
1643 strError = "Tuning Mode must be on";
1644
1645 return false;
1646 }
1647 return true;
1648}
1649
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001650// Parameter access
1651bool CParameterMgr::doSetValue(const string& strPath, const string& strValue, bool bRawValueSpace, bool bDynamicAccess, string& strError)
1652{
1653 CPathNavigator pathNavigator(strPath);
1654
1655 if (!pathNavigator.isPathValid()) {
1656
1657 strError = "Path not well formed";
1658
1659 return false;
1660 }
1661
1662 string* pStrChildName = pathNavigator.next();
1663
1664 if (!pStrChildName) {
1665
1666 strError = "Non settable element";
1667
1668 return false;
1669 }
1670
1671 if (*pStrChildName != getSystemClass()->getName()) {
1672
1673 strError = "Path not found";
1674
1675 return false;
1676 }
1677
1678 // Define context
1679 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, false);
1680
1681 // Set auto sync
1682 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1683
1684 // Set dynamic access
1685 parameterAccessContext.setDynamicAccess(bDynamicAccess);
1686
1687 // Do the set
1688 return getSystemClass()->setValue(pathNavigator, strValue, parameterAccessContext);
1689}
1690
1691bool CParameterMgr::doGetValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, string& strError) const
1692{
1693 CPathNavigator pathNavigator(strPath);
1694
1695 if (!pathNavigator.isPathValid()) {
1696
1697 strError = "Path not well formed";
1698
1699 return false;
1700 }
1701
1702 string* pStrChildName = pathNavigator.next();
1703
1704 if (!pStrChildName) {
1705
1706 strError = "Non settable element";
1707
1708 return false;
1709 }
1710
1711 if (*pStrChildName != getConstSystemClass()->getName()) {
1712
1713 strError = "Path not found";
1714
1715 return false;
1716 }
1717
1718 // Define context
1719 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, bHexOutputRawFormat);
1720
1721 // Set dynamic access
1722 parameterAccessContext.setDynamicAccess(bDynamicAccess);
1723
1724 // Do the get
1725 return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext);
1726}
1727
Patrick Benavoli68a91282011-08-31 11:23:23 +02001728// Dynamic creation library feeding
1729void CParameterMgr::feedElementLibraries()
1730{
1731 // Global Configuration handling
1732 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
1733
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001734 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
1735 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders"));
1736 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation"));
1737 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("ParameterConfiguration"));
1738 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSystemClassConfiguration>("SystemClassConfiguration"));
1739 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
1740 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
1741 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
1742 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001743
1744 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
1745
1746 // Parameter creation
1747 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
1748
1749 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001750 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
1751 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
1752 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
1753 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02001754 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001755 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
1756 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
1757 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02001758 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001759 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
1760 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001761
1762 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
1763
1764 // Parameter Configuration Domains creation
1765 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
1766
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001767 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
1768 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
1769 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
1770 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001771
1772 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
1773}
1774
1775// Remote Processor Server connection handling
1776bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
1777{
1778 CAutoLog autoLog(this, "Handling remote processing interface");
1779
1780 // Start server if tuning allowed
1781 if (_pSystemClassConfiguration->isTuningAllowed()) {
1782
1783 log("Loading remote processor library");
1784
1785 // Load library
1786 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
1787
1788 if (!lib_handle) {
1789
1790 // Return error
1791 const char* pcError = dlerror();
1792
1793 if (pcError) {
1794
1795 strError = pcError;
1796 } else {
1797
1798 strError = "Unable to load libremote-processor.so library";
1799 }
1800
1801 return false;
1802 }
1803
1804 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
1805
1806 if (!pfnCreateRemoteProcessorServer) {
1807
1808 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
1809
1810 return false;
1811 }
1812
1813 // Create server
Patrick Benavoli63499d42011-10-24 18:50:03 +02001814 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(_pSystemClassConfiguration->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001815
1816 log("Starting remote processor server on port %d", _pSystemClassConfiguration->getServerPort());
1817 // Start
1818 if (!_pRemoteProcessorServer->start()) {
1819
1820 strError = "Unable to start remote processor server";
1821
1822 return false;
1823 }
1824 }
1825
1826 return true;
1827}
1828
1829// Back synchronization
1830CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const
1831{
1832#ifdef SIMULATION
1833 // In simulation, back synchronization of the blackboard won't probably work
1834 // We need to ensure though the blackboard is initialized with valid data
1835 return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1836#else
1837 // Real back synchronizer from subsystems
1838 return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1839#endif
1840}
1841
1842// Children typwise access
1843CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
1844{
1845 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
1846}
1847
1848const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
1849{
1850 return getFrameworkConfiguration();
1851}
1852
1853CSelectionCriteria* CParameterMgr::getSelectionCriteria()
1854{
1855 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
1856}
1857
1858const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
1859{
1860 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
1861}
1862
1863CSystemClass* CParameterMgr::getSystemClass()
1864{
1865 return static_cast<CSystemClass*>(getChild(ESystemClass));
1866}
1867
1868const CSystemClass* CParameterMgr::getConstSystemClass() const
1869{
1870 return static_cast<const CSystemClass*>(getChild(ESystemClass));
1871}
1872
1873// Configurable Domains
1874CConfigurableDomains* CParameterMgr::getConfigurableDomains()
1875{
1876 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
1877}
1878
1879const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
1880{
1881 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1882}
1883
1884const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
1885{
1886 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1887}