blob: 9a180fa1d6db4efe9cf27d84d3e47ac4199342c5 [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"
Patrick Benavoli68a91282011-08-31 11:23:23 +020058#include "ConfigurableDomains.h"
59#include "ConfigurableDomain.h"
60#include "DomainConfiguration.h"
61#include "XmlComposer.h"
62#include "XmlDomainSerializingContext.h"
63#include "BitParameterBlockType.h"
64#include "BitParameterType.h"
Patrick Benavoli1352ae52011-10-21 16:48:04 +020065#include "StringParameterType.h"
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +020066#include "EnumParameterType.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 Benavoli065264a2011-11-20 15:46:41 +010078#include "ParameterHandle.h"
Patrick Benavoliee65e6d2011-11-20 18:52:24 +010079#include "LinearParameterAdaptation.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020080
81#define base CElement
82
83// Used for remote processor server creation
84typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler);
85
86// Global configuration file name (fixed)
87const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml";
88const char* gacSystemSchemasSubFolder = "Schemas";
89
90// Config File System looks normally like this:
91// ---------------------------------------------
Patrick Benavoli95ac0342011-11-07 20:32:51 +010092//├── <ParameterFrameworkConfiguration>.xml
Patrick Benavoli68a91282011-08-31 11:23:23 +020093//├── Schemas
94//│ └── *.xsd
95//├── Settings
96//│ └── <SystemClassName folder>*
97//│ ├── <ConfigurableDomains>.xml
98//│ └── <Settings>.bin?
99//└── Structure
100// └── <SystemClassName folder>*
101// ├── <SystemClassName>Class.xml
102// └── <Subsystem>.xml*
103// --------------------------------------------
104
105
106// Remote command parser array
Patrick Benavoli592ae562011-09-05 16:53:58 +0200107const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
Patrick Benavoli592ae562011-09-05 16:53:58 +0200108 /// Version
109 { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200110 /// Status
111 { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" },
112 /// Tuning Mode
113 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" },
114 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" },
115 /// Value Space
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200116 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200117 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200118 /// Output Raw Format
119 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
120 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200121 /// Sync
122 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
123 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" },
124 { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200125 /// Criteria
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200126 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200127 /// Domains
128 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100129 { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0, "", "Show all domains and configurations, including applicability conditions" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200130 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" },
131 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" },
132 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200133 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" },
134 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200135 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" },
136 { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" },
137 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
138 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" },
139 /// Configurations
140 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" },
141 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" },
142 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" },
143 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" },
144 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" },
145 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100146 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3, "<domain> <configuration> <elem path list>", "Set element application order for configuration" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200147 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100148 { "setRule", &CParameterMgr::setRuleCommmandProcess, 3, "<domain> <configuration> <rule>", "Set configuration application rule" },
149 { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2, "<domain> <configuration>", "Clear configuration application rule" },
150 { "getRule", &CParameterMgr::getRuleCommmandProcess, 2, "<domain> <configuration>", "Get configuration application rule" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200151 /// Elements/Parameters
152 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" },
Patrick Benavoli592ae562011-09-05 16:53:58 +0200153 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200154 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" },
155 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200156 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200157 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200158 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200159 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200160 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" },
161 /// Browse
162 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" },
163 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" },
164 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" },
165 /// Settings Import/Export
166 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" },
167 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" },
168 { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" },
169 { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" },
170 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" },
171 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }
172};
173// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200174const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200175
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100176CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200177 _bTuningModeIsOn(false),
178 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200179 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200180 _bAutoSyncOn(true),
181 _pMainParameterBlackboard(new CParameterBlackboard),
182 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100183 _strXmlConfigurationFilePath(strConfigurationFilePath),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200184 _uiStructureChecksum(0),
185 _pRemoteProcessorServer(NULL),
186 _uiMaxCommandUsageLength(0),
187 _pLogger(NULL),
188 _uiLogDepth(0)
189{
190 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100191 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
192 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200193
194 // Deal with children
195 addChild(new CParameterFrameworkConfiguration);
196 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100197 addChild(new CSystemClass);
198 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200199
200 // Feed element library
201 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200202
203 _pCommandHandler = new CCommandHandler(this);
204
205 // Add command parsers
206 uint32_t uiRemoteCommandParserItem;
207
208 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
209
210 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
211
212 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
213 pRemoteCommandParserItem->_pfnParser,
214 pRemoteCommandParserItem->_uiMinArgumentCount,
215 pRemoteCommandParserItem->_pcHelp,
216 pRemoteCommandParserItem->_pcDescription);
217 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100218
219 // Configuration file folder
220 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
221
222 assert(uiSlashPos != (uint32_t)-1);
223
224 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
225
226 // Schema absolute folder location
227 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200228}
229
230CParameterMgr::~CParameterMgr()
231{
232 // Children
233 delete _pRemoteProcessorServer;
234 delete _pMainParameterBlackboard;
235 delete _pElementLibrarySet;
236
237 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100238 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200239}
240
241string CParameterMgr::getKind() const
242{
243 return "ParameterMgr";
244}
245
246// Logging
247void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
248{
249 _pLogger = pLogger;
250}
251
252// Logging
253void CParameterMgr::doLog(const string& strLog) const
254{
255 if (_pLogger) {
256
257 // Nest
258 string strIndent;
259
260 // Level
261 uint32_t uiNbIndents = _uiLogDepth;
262
263 while (uiNbIndents--) {
264
265 strIndent += " ";
266 }
267
268 // Log
269 _pLogger->log(strIndent + strLog);
270 }
271}
272
273void CParameterMgr::nestLog() const
274{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200275 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200276}
277
278void CParameterMgr::unnestLog() const
279{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200280 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200281}
282
Patrick Benavoli63499d42011-10-24 18:50:03 +0200283// Version
284string CParameterMgr::getVersion() const
285{
286 string strVersion;
287
288 // Major
289 strVersion = toString(guiEditionMajor) + ".";
290 // Minor
291 strVersion += toString(guiEditionMinor) + ".";
292 // Revision
293 strVersion += toString(guiRevision);
294
295 return strVersion;
296}
297
Patrick Benavoli68a91282011-08-31 11:23:23 +0200298bool CParameterMgr::load(string& strError)
299{
300 CAutoLog autoLog(this, "Loading");
301
302 // Load Framework configuration
303 if (!loadFrameworkConfiguration(strError)) {
304
305 return false;
306 }
307
308 // Load subsystems
309 if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) {
310
311 return false;
312 }
313
314 // Load structure
315 if (!loadStructure(strError)) {
316
317 return false;
318 }
319
320 // Load settings
321 if (!loadSettings(strError)) {
322
323 return false;
324 }
325
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200326 // Back synchronization for areas in parameter blackboard not covered by any domain
327 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200328
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200329 log("Main blackboard back synchronization");
330
331 // Back-synchronize
332 if (!pBackSynchronizer->sync()) {
333 // Get rid of back synchronizer
334 delete pBackSynchronizer;
335
336 strError = "Main blackboard back synchronization failed: " + strError;
337
338 return false;
339 }
340 // Get rif of back synchronizer
341 delete pBackSynchronizer;
342
343 // We're done loading the settings and back synchronizing
344 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
345
346 // We need to ensure all domains are valid
347 pConfigurableDomains->validate(_pMainParameterBlackboard);
348
349 // Ensure application of currently selected configurations
350 // Force-apply configurations
351 if (!pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200352
353 return false;
354 }
355
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200356 // Start remote processor server if appropriate
357 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200358}
359
360bool CParameterMgr::loadFrameworkConfiguration(string& strError)
361{
362 CAutoLog autoLog(this, "Loading framework configuration");
363
Patrick Benavoli68a91282011-08-31 11:23:23 +0200364 // Parse Structure XML file
365 CXmlElementSerializingContext elementSerializingContext(strError);
366
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100367 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200368
369 return false;
370 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100371 // Set class name to system class and configurable domains
372 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
373 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
374
Patrick Benavoli68a91282011-08-31 11:23:23 +0200375 // Get subsystem plugins folders element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100376 const CFrameworkConfigurationGroup* pSubsystemPluginFolders = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200377
378 if (!pSubsystemPluginFolders) {
379
380 strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element";
381
382 return false;
383 }
384 // Get plugin locations
385 uint32_t uiPluginFolderLocation;
386 uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren();
387
388 if (!uiNbPluginFolderLocations) {
389
390 strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element";
391
392 return false;
393 }
394
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100395 // Collect plugin paths
Patrick Benavoli68a91282011-08-31 11:23:23 +0200396 for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) {
397
398 const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation));
399
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100400 _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strXmlConfigurationFilePath));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200401 }
402
Patrick Benavoli68a91282011-08-31 11:23:23 +0200403 // Log tuning availability
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100404 log("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200405
406 return true;
407}
408
409bool CParameterMgr::loadStructure(string& strError)
410{
411 // Retrieve system to load structure to
412 CSystemClass* pSystemClass = getSystemClass();
413
414 CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure");
415
416 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100417 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200418
419 if (!pStructureDescriptionFileLocation) {
420
421 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
422
423 return false;
424 }
425
426 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100427 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200428
429 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100430 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200431
432 // Parse Structure XML file
433 CXmlParameterSerializingContext parameterBuildContext(strError);
434
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200435 log("Importing system structure from file %s", strXmlStructureFilePath.c_str());
436
Patrick Benavoli68a91282011-08-31 11:23:23 +0200437 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
438
439 return false;
440 }
441
442 // Initialize offsets
443 pSystemClass->setOffset(0);
444
445 // Initialize main blackboard's size
446 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
447
448 return true;
449}
450
451bool CParameterMgr::loadSettings(string& strError)
452{
453 CAutoLog autoLog(this, "Loading settings");
454
455 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100456 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200457
458 if (!pParameterConfigurationGroup) {
459
460 // No settings to load
461
462 return true;
463 }
464 // Get binary settings file location
465 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
466
467 string strXmlBinarySettingsFilePath;
468
469 if (pBinarySettingsFileLocation) {
470
471 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100472 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200473 }
474
475 // Get configurable domains element
476 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
477
478 if (!pConfigurableDomainsFileLocation) {
479
480 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
481
482 return false;
483 }
484 // Get destination root element
485 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
486
487 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100488 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200489
490 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100491 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200492
493 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
494 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
495
496 // Selection criteria definition for rule creation
497 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
498
Patrick Benavoli63499d42011-10-24 18:50:03 +0200499 // Auto validation of configurations if no binary settings provided
500 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
501
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200502 log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
503
Patrick Benavoli68a91282011-08-31 11:23:23 +0200504 // Do parse
505 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
506
507 return false;
508 }
509 // We have loaded the whole system structure, compute checksum
510 const CSystemClass* pSystemClass = getConstSystemClass();
511 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
512
513 // Load binary settings if any provided
514 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
515
516 return false;
517 }
518
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200519 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200520}
521
522// XML parsing
523bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
524{
525 // Init serializing context
526 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
527
528 // Get Schema file associated to root element
529 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
530
531 // Parse Structure XML file
532 CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext);
533
534 if (!parser.open()) {
535
536 return false;
537 }
538
539 // Check Root element name attribute (if any)
540 string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName);
541
542 if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) {
543
544 elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath);
545 elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName());
546
547 return false;
548 }
549
550 // Start clean
551 pRootElement->clean();
552
553 // Parse
554 if (!parser.parse(pRootElement)) {
555
556 // Cleanup
557 pRootElement->clean();
558
559 return false;
560 }
561
562 // Close parser
563 if (!parser.close()) {
564
565 return false;
566 }
567
568 return true;
569}
570
571// Init
572bool CParameterMgr::init(string& strError)
573{
574 return base::init(strError);
575}
576
577// Selection criteria interface
578CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
579{
580 // Propagate
581 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
582}
583
584CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
585{
586 // Propagate
587 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
588}
589
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200590// Selection criterion retrieval
591CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200592{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200593 // Propagate
594 return getSelectionCriteria()->getSelectionCriterion(strName);
595}
596
597// Selection criteria changed event
598bool CParameterMgr::applyConfigurations(string& strError)
599{
600 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200601
602 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100603 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200604
605 if (!_bTuningModeIsOn) {
606
607 // Apply configuration(s)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200608 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) {
609
610 log("Failed to apply configurations!");
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200611
612 return false;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200613 }
614 }
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200615
616 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200617}
618
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200619// Dynamic parameter handling
Patrick Benavoli065264a2011-11-20 15:46:41 +0100620CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200621{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100622 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200623
Patrick Benavoli065264a2011-11-20 15:46:41 +0100624 // Nagivate through system class
625 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
626
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100627 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100628 }
629
630 // Find element
631 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
632
633 if (!pElement) {
634
635 strError = "Path not found";
636
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100637 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100638 }
639
640 // Check found element is a parameter
641 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
642
643 if (!pConfigurableElement->isParameter()) {
644
645 // Element is not parameter
646 strError = "Not a parameter";
647
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100648 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100649 }
650
651 // Convert as parameter and return new handle
652 return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200653}
654
Patrick Benavoli68a91282011-08-31 11:23:23 +0200655/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200656/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200657CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200658{
659 (void)remoteCommand;
660
Patrick Benavoli63499d42011-10-24 18:50:03 +0200661 // Show version
662 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200663
Patrick Benavoli63499d42011-10-24 18:50:03 +0200664 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200665}
666
Patrick Benavoli68a91282011-08-31 11:23:23 +0200667/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200668CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200669{
670 (void)remoteCommand;
671 // System class
672 const CSystemClass* pSystemClass = getSystemClass();
673
Patrick Benavoli68a91282011-08-31 11:23:23 +0200674 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200675 /// General section
676 appendTitle(strResult, "General:");
677 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200678 strResult += "System Class: ";
679 strResult += pSystemClass->getName();
680 strResult += "\n";
681
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200682 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200683 strResult += "Tuning Mode: ";
684 strResult += tuningModeOn() ? "on" : "off";
685 strResult += "\n";
686
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200687 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200688 strResult += "Value Space: ";
689 strResult += valueSpaceIsRaw() ? "raw" : "real";
690 strResult += "\n";
691
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200692 // Output raw format
693 strResult += "Output Raw Format: ";
694 strResult += outputRawFormatIsHex() ? "hex" : "dec";
695 strResult += "\n";
696
697 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200698 strResult += "Auto Sync: ";
699 strResult += autoSyncOn() ? "on" : "off";
700 strResult += "\n";
701
702 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200703 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200704 string strSubsystemList;
705 pSystemClass->listChildrenPaths(strSubsystemList);
706 strResult += strSubsystemList;
707
708 /// Last applied configurations
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200709 appendTitle(strResult, "Last applied configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200710 string strLastAppliedConfigurations;
711 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
712 strResult += strLastAppliedConfigurations;
713
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200714 /// Criteria states
715 appendTitle(strResult, "Selection criteria:");
716 string strSelectionCriteria;
717 getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false);
718 strResult += strSelectionCriteria;
719
Patrick Benavoli63499d42011-10-24 18:50:03 +0200720 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200721}
722
723/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200724CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200725{
726 if (remoteCommand.getArgument(0) == "on") {
727
728 if (setTuningMode(true, strResult)) {
729
Patrick Benavoli63499d42011-10-24 18:50:03 +0200730 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200731 }
732 } else if (remoteCommand.getArgument(0) == "off") {
733
734 if (setTuningMode(false, strResult)) {
735
Patrick Benavoli63499d42011-10-24 18:50:03 +0200736 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200737 }
738 } else {
739 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200740 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200741 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200742 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200743}
744
Patrick Benavoli63499d42011-10-24 18:50:03 +0200745CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200746{
747 (void)remoteCommand;
748
749 strResult = tuningModeOn() ? "on" : "off";
750
Patrick Benavoli63499d42011-10-24 18:50:03 +0200751 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200752}
753
754/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200755CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200756{
757 (void)strResult;
758
759 if (remoteCommand.getArgument(0) == "raw") {
760
761 setValueSpace(true);
762
Patrick Benavoli63499d42011-10-24 18:50:03 +0200763 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200764
765 } else if (remoteCommand.getArgument(0) == "real") {
766
767 setValueSpace(false);
768
Patrick Benavoli63499d42011-10-24 18:50:03 +0200769 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200770
771 } else {
772 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200773 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200774 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200775 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200776}
777
Patrick Benavoli63499d42011-10-24 18:50:03 +0200778CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200779{
780 (void)remoteCommand;
781
782 strResult = valueSpaceIsRaw() ? "raw" : "real";
783
Patrick Benavoli63499d42011-10-24 18:50:03 +0200784 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200785}
786
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200787/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200788CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200789{
790 (void)strResult;
791
792 if (remoteCommand.getArgument(0) == "hex") {
793
794 setOutputRawFormat(true);
795
Patrick Benavoli63499d42011-10-24 18:50:03 +0200796 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200797
798 } else if (remoteCommand.getArgument(0) == "dec") {
799
800 setOutputRawFormat(false);
801
Patrick Benavoli63499d42011-10-24 18:50:03 +0200802 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200803
804 } else {
805 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200806 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200807 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200808 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200809}
810
Patrick Benavoli63499d42011-10-24 18:50:03 +0200811CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200812{
813 (void)remoteCommand;
814
815 strResult = outputRawFormatIsHex() ? "hex" : "dec";
816
Patrick Benavoli63499d42011-10-24 18:50:03 +0200817 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200818}
819
Patrick Benavoli68a91282011-08-31 11:23:23 +0200820/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200821CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200822{
823 if (remoteCommand.getArgument(0) == "on") {
824
825 if (setAutoSync(true, strResult)) {
826
Patrick Benavoli63499d42011-10-24 18:50:03 +0200827 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200828 }
829 } else if (remoteCommand.getArgument(0) == "off") {
830
831 if (setAutoSync(false, strResult)) {
832
Patrick Benavoli63499d42011-10-24 18:50:03 +0200833 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200834 }
835 } else {
836 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200837 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200838 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200839 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200840}
841
Patrick Benavoli63499d42011-10-24 18:50:03 +0200842CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200843{
844 (void)remoteCommand;
845
846 strResult = autoSyncOn() ? "on" : "off";
847
Patrick Benavoli63499d42011-10-24 18:50:03 +0200848 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200849}
850
Patrick Benavoli63499d42011-10-24 18:50:03 +0200851CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200852{
853 (void)remoteCommand;
854
Patrick Benavoli63499d42011-10-24 18:50:03 +0200855 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200856}
857
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200858/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200859CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200860{
861 (void)remoteCommand;
862
863 getSelectionCriteria()->listSelectionCriteria(strResult, true);
864
Patrick Benavoli63499d42011-10-24 18:50:03 +0200865 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200866}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200867
868/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200869CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200870{
871 (void)remoteCommand;
872
Patrick Benavoli63499d42011-10-24 18:50:03 +0200873 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200874
Patrick Benavoli63499d42011-10-24 18:50:03 +0200875 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200876}
877
Patrick Benavoli63499d42011-10-24 18:50:03 +0200878CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200879{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200880 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200881}
882
Patrick Benavoli63499d42011-10-24 18:50:03 +0200883CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200884{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200885 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200886}
887
Patrick Benavoli63499d42011-10-24 18:50:03 +0200888CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200889{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200890 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200891}
892
Patrick Benavoli63499d42011-10-24 18:50:03 +0200893CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200894{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200895 // Check tuning mode
896 if (!checkTuningModeOn(strResult)) {
897
898 return CCommandHandler::EFailed;
899 }
900
901 // Set property
902 bool bSequenceAware;
903
904 if (remoteCommand.getArgument(1) == "true") {
905
906 bSequenceAware = true;
907
908 } else if (remoteCommand.getArgument(1) == "false") {
909
910 bSequenceAware = false;
911
912 } else {
913 // Show usage
914 return CCommandHandler::EShowUsage;
915 }
916
917 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200918}
919
Patrick Benavoli63499d42011-10-24 18:50:03 +0200920CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200921{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200922 // Get property
923 bool bSequenceAware;
924
925 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
926
927 return CCommandHandler::EFailed;
928 }
929
930 strResult = bSequenceAware ? "true" : "false";
931
932 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200933}
934
Patrick Benavoli63499d42011-10-24 18:50:03 +0200935CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200936{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200937 return getConfigurableDomains()->listDomainElements(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::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200941{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200942 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
943}
944
945CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
946{
947 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
948}
949
950CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
951{
952 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200953}
954
955/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +0200956CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200957{
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100958 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
959}
960
961CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
962{
963 (void)remoteCommand;
964
965 // Dummy error context
966 string strError;
967 CErrorContext errorContext(strError);
968
969 // Dump
970 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
971
972 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200973}
974
Patrick Benavoli63499d42011-10-24 18:50:03 +0200975CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200976{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200977 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200978}
979
Patrick Benavoli63499d42011-10-24 18:50:03 +0200980CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200981{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200982 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200983}
984
Patrick Benavoli63499d42011-10-24 18:50:03 +0200985CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200986{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200987 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200988}
989
Patrick Benavoli63499d42011-10-24 18:50:03 +0200990CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200991{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200992 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200993}
994
Patrick Benavoli63499d42011-10-24 18:50:03 +0200995CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200996{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200997 return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
998}
999
1000CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1001{
1002 // Check tuning mode
1003 if (!checkTuningModeOn(strResult)) {
1004
1005 return CCommandHandler::EFailed;
1006 }
1007
1008 // Build configurable element path list
1009 vector<string> astrNewElementSequence;
1010
1011 uint32_t uiArgument;
1012
1013 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1014
1015 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1016 }
1017
1018 // Delegate to configurable domains
1019 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1020}
1021
1022CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1023{
1024 // Delegate to configurable domains
1025 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001026}
1027
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001028CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1029{
1030 // Delegate to configurable domains
1031 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1032}
1033
1034CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1035{
1036 // Delegate to configurable domains
1037 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1038}
1039
1040CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1041{
1042 // Delegate to configurable domains
1043 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1044}
1045
Patrick Benavoli68a91282011-08-31 11:23:23 +02001046/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001047CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001048{
1049 CElementLocator elementLocator(getSystemClass(), false);
1050
1051 CElement* pLocatedElement = NULL;
1052
1053 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1054
Patrick Benavoli63499d42011-10-24 18:50:03 +02001055 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001056 }
1057
1058 strResult = string("\n");
1059
1060 if (!pLocatedElement) {
1061
1062 // List from root folder
1063
1064 // Return system class qualified name
1065 pLocatedElement = getSystemClass();
1066 }
1067
1068 // Return sub-elements
1069 strResult += pLocatedElement->listQualifiedPaths(false);
1070
Patrick Benavoli63499d42011-10-24 18:50:03 +02001071 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001072}
1073
1074/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001075CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001076{
1077 CElementLocator elementLocator(getSystemClass(), false);
1078
1079 CElement* pLocatedElement = NULL;
1080
1081 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1082
Patrick Benavoli63499d42011-10-24 18:50:03 +02001083 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001084 }
1085
1086 strResult = string("\n");
1087
1088 if (!pLocatedElement) {
1089
1090 // List from root folder
1091
1092 // Return system class qualified name
1093 pLocatedElement = getSystemClass();
1094 }
1095
1096 // Return sub-elements
1097 strResult += pLocatedElement->listQualifiedPaths(true);
1098
Patrick Benavoli63499d42011-10-24 18:50:03 +02001099 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001100}
1101
Patrick Benavoli63499d42011-10-24 18:50:03 +02001102CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001103{
1104 CElementLocator elementLocator(getSystemClass());
1105
1106 CElement* pLocatedElement = NULL;
1107
1108 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1109
Patrick Benavoli63499d42011-10-24 18:50:03 +02001110 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001111 }
1112
1113 string strError;
1114
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001115 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001116
1117 // Dump elements
1118 pLocatedElement->dumpContent(strResult, parameterAccessContext);
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::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001124{
1125 CElementLocator elementLocator(getSystemClass());
1126
1127 CElement* pLocatedElement = NULL;
1128
1129 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1130
Patrick Benavoli63499d42011-10-24 18:50:03 +02001131 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001132 }
1133
1134 // Converted to actual sizable element
1135 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1136
1137 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001138 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001139
Patrick Benavoli63499d42011-10-24 18:50:03 +02001140 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001141}
1142
Patrick Benavoli63499d42011-10-24 18:50:03 +02001143CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001144{
1145 CElementLocator elementLocator(getSystemClass());
1146
1147 CElement* pLocatedElement = NULL;
1148
1149 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1150
Patrick Benavoli63499d42011-10-24 18:50:03 +02001151 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001152 }
1153
1154 // Convert element
1155 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1156
1157 // Return element properties
1158 pConfigurableElement->showProperties(strResult);
1159
Patrick Benavoli63499d42011-10-24 18:50:03 +02001160 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001161}
1162
Patrick Benavoli63499d42011-10-24 18:50:03 +02001163CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001164{
1165 string strValue;
1166
Patrick Benavoli065264a2011-11-20 15:46:41 +01001167 if (!accessValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001168
Patrick Benavoli63499d42011-10-24 18:50:03 +02001169 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001170 }
1171 // Succeeded
1172 strResult = strValue;
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::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001178{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001179 // Check tuning mode
1180 if (!checkTuningModeOn(strResult)) {
1181
1182 return CCommandHandler::EFailed;
1183 }
1184 // Get value to set
1185 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1186
1187 return accessValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001188}
1189
Patrick Benavoli63499d42011-10-24 18:50:03 +02001190CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001191{
1192 CElementLocator elementLocator(getSystemClass());
1193
1194 CElement* pLocatedElement = NULL;
1195
1196 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1197
Patrick Benavoli63499d42011-10-24 18:50:03 +02001198 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001199 }
1200
1201 // Convert element
1202 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1203
1204 // Return element belonging domains
1205 pConfigurableElement->listBelongingDomains(strResult);
1206
Patrick Benavoli63499d42011-10-24 18:50:03 +02001207 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001208}
1209
Patrick Benavoli63499d42011-10-24 18:50:03 +02001210CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001211{
1212 CElementLocator elementLocator(getSystemClass());
1213
1214 CElement* pLocatedElement = NULL;
1215
1216 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1217
Patrick Benavoli63499d42011-10-24 18:50:03 +02001218 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001219 }
1220
1221 // Convert element
1222 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1223
1224 // Return element belonging domains
1225 pConfigurableElement->listAssociatedDomains(strResult);
1226
Patrick Benavoli63499d42011-10-24 18:50:03 +02001227 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001228}
1229
Patrick Benavoli63499d42011-10-24 18:50:03 +02001230CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001231{
1232 (void)remoteCommand;
1233
1234 getConfigurableDomains()->listAssociatedElements(strResult);
1235
Patrick Benavoli63499d42011-10-24 18:50:03 +02001236 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001237}
1238
Patrick Benavoli63499d42011-10-24 18:50:03 +02001239CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001240{
1241 (void)remoteCommand;
1242
1243 getConfigurableDomains()->listConflictingElements(strResult);
1244
Patrick Benavoli63499d42011-10-24 18:50:03 +02001245 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001246}
1247
Patrick Benavoli63499d42011-10-24 18:50:03 +02001248CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001249{
1250 (void)remoteCommand;
1251
1252 getSystemClass()->listRogueElements(strResult);
1253
Patrick Benavoli63499d42011-10-24 18:50:03 +02001254 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001255}
1256
1257/// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +02001258CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001259{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001260 return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001261}
1262
Patrick Benavoli63499d42011-10-24 18:50:03 +02001263CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001264{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001265 return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001266}
1267
Patrick Benavoli63499d42011-10-24 18:50:03 +02001268CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001269{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001270 return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001271}
1272
Patrick Benavoli63499d42011-10-24 18:50:03 +02001273CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001274{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001275 return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001276}
1277
Patrick Benavoli63499d42011-10-24 18:50:03 +02001278CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001279{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001280 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001281}
1282
Patrick Benavoli63499d42011-10-24 18:50:03 +02001283CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001284{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001285 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001286}
1287
1288// User set/get parameters
Patrick Benavoli065264a2011-11-20 15:46:41 +01001289bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001290{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001291 // Lock state
1292 CAutoLock autoLock(&_blackboardMutex);
1293
1294 CPathNavigator pathNavigator(strPath);
1295
1296 // Nagivate through system class
1297 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001298
1299 return false;
1300 }
1301
Patrick Benavoli065264a2011-11-20 15:46:41 +01001302 // Define context
1303 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001304
Patrick Benavoli065264a2011-11-20 15:46:41 +01001305 // Do the get
1306 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001307}
1308
1309// Tuning mode
1310bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1311{
1312 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001313 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001314
1315 strError = "Tuning prohibited";
1316
1317 return false;
1318 }
1319 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001320 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001321
1322 // Warn domains about exiting tuning mode
1323 if (!bOn && _bTuningModeIsOn) {
1324
1325 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001326 // Force-apply configurations
Patrick Benavoli68a91282011-08-31 11:23:23 +02001327 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) {
1328
1329 return false;
1330 }
1331 // Turn auto sync back on
1332 _bAutoSyncOn = true;
1333 }
1334
1335 // Store
1336 _bTuningModeIsOn = bOn;
1337
Patrick Benavoli68a91282011-08-31 11:23:23 +02001338 return true;
1339}
1340
1341bool CParameterMgr::tuningModeOn() const
1342{
1343 return _bTuningModeIsOn;
1344}
1345
1346// Current value space for user set/get value interpretation
1347void CParameterMgr::setValueSpace(bool bIsRaw)
1348{
1349 _bValueSpaceIsRaw = bIsRaw;
1350}
1351
1352bool CParameterMgr::valueSpaceIsRaw()
1353{
1354 return _bValueSpaceIsRaw;
1355}
1356
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001357// Current Output Raw Format for user get value interpretation
1358void CParameterMgr::setOutputRawFormat(bool bIsHex)
1359{
1360 _bOutputRawFormatIsHex = bIsHex;
1361}
1362
1363bool CParameterMgr::outputRawFormatIsHex()
1364{
1365 return _bOutputRawFormatIsHex;
1366}
1367
Patrick Benavoli68a91282011-08-31 11:23:23 +02001368/// Sync
1369// Automatic hardware synchronization control (during tuning session)
1370bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1371{
1372 // Check tuning mode
1373 if (!checkTuningModeOn(strError)) {
1374
1375 return false;
1376 }
1377 // Warn domains about turning auto sync back on
1378 if (bAutoSyncOn && !_bAutoSyncOn) {
1379
Patrick Benavoli592ae562011-09-05 16:53:58 +02001380 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1381 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001382
1383 return false;
1384 }
1385 }
1386
1387 // Set Auto sync
1388 _bAutoSyncOn = bAutoSyncOn;
1389
1390 return true;
1391}
1392
1393bool CParameterMgr::autoSyncOn() const
1394{
1395 return _bAutoSyncOn;
1396}
1397
1398// Manual hardware synchronization control (during tuning session)
1399bool CParameterMgr::sync(string& strError)
1400{
1401 // Check tuning mode
1402 if (!checkTuningModeOn(strError)) {
1403
1404 return false;
1405 }
1406 // Warn domains about turning auto sync back on
1407 if (_bAutoSyncOn) {
1408
1409 strError = "Feature unavailable when Auto Sync is on";
1410
1411 return false;
1412 }
1413
1414 // Get syncer set
1415 CSyncerSet syncerSet;
1416 // ... from system class
1417 getConstSystemClass()->fillSyncerSet(syncerSet);
1418 // Sync
1419 return syncerSet.sync(*_pMainParameterBlackboard, false, strError);
1420}
1421
1422// Content dump
1423void CParameterMgr::logStructureContent(string& strContent) const
1424{
1425 string strError;
1426
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001427 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001428
1429 dumpContent(strContent, parameterAccessContext);
1430}
1431
1432// Configuration/Domains handling
1433bool CParameterMgr::createDomain(const string& strName, string& strError)
1434{
1435 // Check tuning mode
1436 if (!checkTuningModeOn(strError)) {
1437
1438 return false;
1439 }
1440
1441 // Delegate to configurable domains
1442 return getConfigurableDomains()->createDomain(strName, strError);
1443}
1444
1445bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1446{
1447 // Check tuning mode
1448 if (!checkTuningModeOn(strError)) {
1449
1450 return false;
1451 }
1452
1453 // Delegate to configurable domains
1454 return getConfigurableDomains()->deleteDomain(strName, strError);
1455}
1456
1457bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1458{
1459 // Check tuning mode
1460 if (!checkTuningModeOn(strError)) {
1461
1462 return false;
1463 }
1464
1465 // Delegate to configurable domains
1466 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1467}
1468
1469bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1470{
1471 // Check tuning mode
1472 if (!checkTuningModeOn(strError)) {
1473
1474 return false;
1475 }
1476
1477 // Delegate to configurable domains
1478 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1479}
1480
1481bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1482{
1483 // Check tuning mode
1484 if (!checkTuningModeOn(strError)) {
1485
1486 return false;
1487 }
1488
1489 // Delegate to configurable domains
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001490 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001491}
1492
1493bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1494{
1495 // Check tuning mode
1496 if (!checkTuningModeOn(strError)) {
1497
1498 return false;
1499 }
1500
1501 // Delegate to configurable domains
1502 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1503}
1504
1505// Configurable element - domain association
1506bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1507{
1508 // Check tuning mode
1509 if (!checkTuningModeOn(strError)) {
1510
1511 return false;
1512 }
1513
1514 CElementLocator elementLocator(getSystemClass());
1515
1516 CElement* pLocatedElement = NULL;
1517
1518 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1519
1520 return false;
1521 }
1522
1523 // Convert element
1524 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1525
1526 // Delegate
1527 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1528}
1529
1530bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1531{
1532 // Check tuning mode
1533 if (!checkTuningModeOn(strError)) {
1534
1535 return false;
1536 }
1537
1538 CElementLocator elementLocator(getSystemClass());
1539
1540 CElement* pLocatedElement = NULL;
1541
1542 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1543
Patrick Benavoli63499d42011-10-24 18:50:03 +02001544 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001545 }
1546
1547 // Convert element
1548 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1549
1550 // Delegate
1551 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1552}
1553
1554bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1555{
1556 // Check tuning mode
1557 if (!checkTuningModeOn(strError)) {
1558
1559 return false;
1560 }
1561
1562 CElementLocator elementLocator(getSystemClass());
1563
1564 CElement* pLocatedElement = NULL;
1565
1566 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1567
Patrick Benavoli63499d42011-10-24 18:50:03 +02001568 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001569 }
1570
1571 // Convert element
1572 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1573
1574 // Delegate
1575 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1576}
1577
1578// XML Import/Export
1579bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError)
1580{
1581 // Check tuning mode
1582 if (!checkTuningModeOn(strError)) {
1583
1584 return false;
1585 }
1586
1587 // check path is absolute
1588 if (strFileName[0] != '/') {
1589
1590 strError = "Please provide absolute path";
1591
1592 return false;
1593 }
1594 // Root element
1595 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1596
1597 // Context
1598 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1599
1600 // Secltion criteria definition for rule creation
1601 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
1602
1603 // Parse
1604 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) {
1605
1606 return false;
1607 }
1608
1609 // Validate domains after XML import
1610 pConfigurableDomains->validate(_pMainParameterBlackboard);
1611
1612 return true;
1613}
1614
1615bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const
1616{
1617 // check path is absolute
1618 if (strFileName[0] != '/') {
1619
1620 strError = "Please provide absolute path";
1621
1622 return false;
1623 }
1624
1625 // Root element
1626 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1627
1628 // Get Schema file associated to root element
1629 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
1630
1631 // Context
1632 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1633
1634 // Value space
1635 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1636
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001637 // Output raw format
1638 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1639
Patrick Benavoli68a91282011-08-31 11:23:23 +02001640 // Instantiate composer
1641 CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext);
1642
1643 // Open composer
1644 if (!xmlComposer.open()) {
1645
1646 return false;
1647 }
1648
1649 // Compose
Patrick Benavoli63499d42011-10-24 18:50:03 +02001650 xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001651
1652 // Close composer
1653 if (!xmlComposer.close()) {
1654
1655 return false;
1656 }
1657
1658 return true;
1659}
1660
1661// Binary Import/Export
1662bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1663{
1664 // Check tuning mode
1665 if (!checkTuningModeOn(strError)) {
1666
1667 return false;
1668 }
1669 // check path is absolute
1670 if (strFileName[0] != '/') {
1671
1672 strError = "Please provide absolute path";
1673
1674 return false;
1675 }
1676 // Root element
1677 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1678
1679 // Serialize in
1680 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1681}
1682
1683bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1684{
1685 // check path is absolute
1686 if (strFileName[0] != '/') {
1687
1688 strError = "Please provide absolute path";
1689
1690 return false;
1691 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001692
Patrick Benavoli68a91282011-08-31 11:23:23 +02001693 // Root element
1694 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1695
1696 // Serialize out
1697 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1698}
1699
1700// For tuning, check we're in tuning mode
1701bool CParameterMgr::checkTuningModeOn(string& strError) const
1702{
1703 // Tuning Mode on?
1704 if (!_bTuningModeIsOn) {
1705
1706 strError = "Tuning Mode must be on";
1707
1708 return false;
1709 }
1710 return true;
1711}
1712
Patrick Benavoli065264a2011-11-20 15:46:41 +01001713// Tuning mutex dynamic parameter handling
1714pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001715{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001716 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001717}
1718
Patrick Benavoli065264a2011-11-20 15:46:41 +01001719// Blackboard reference (dynamic parameter handling)
1720CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001721{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001722 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001723}
1724
Patrick Benavoli68a91282011-08-31 11:23:23 +02001725// Dynamic creation library feeding
1726void CParameterMgr::feedElementLibraries()
1727{
1728 // Global Configuration handling
1729 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
1730
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001731 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
1732 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders"));
1733 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001734 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
1735 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
1736 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
1737 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001738
1739 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
1740
1741 // Parameter creation
1742 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
1743
1744 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001745 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
1746 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
1747 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
1748 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02001749 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001750 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
1751 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
1752 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoliee65e6d2011-11-20 18:52:24 +01001753 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02001754 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001755 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
1756 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001757
1758 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
1759
1760 // Parameter Configuration Domains creation
1761 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
1762
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001763 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
1764 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
1765 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
1766 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001767
1768 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
1769}
1770
1771// Remote Processor Server connection handling
1772bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
1773{
1774 CAutoLog autoLog(this, "Handling remote processing interface");
1775
1776 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001777 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001778
1779 log("Loading remote processor library");
1780
1781 // Load library
1782 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
1783
1784 if (!lib_handle) {
1785
1786 // Return error
1787 const char* pcError = dlerror();
1788
1789 if (pcError) {
1790
1791 strError = pcError;
1792 } else {
1793
1794 strError = "Unable to load libremote-processor.so library";
1795 }
1796
1797 return false;
1798 }
1799
1800 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
1801
1802 if (!pfnCreateRemoteProcessorServer) {
1803
1804 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
1805
1806 return false;
1807 }
1808
1809 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001810 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001811
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001812 log("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001813 // Start
1814 if (!_pRemoteProcessorServer->start()) {
1815
1816 strError = "Unable to start remote processor server";
1817
1818 return false;
1819 }
1820 }
1821
1822 return true;
1823}
1824
1825// Back synchronization
1826CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const
1827{
1828#ifdef SIMULATION
1829 // In simulation, back synchronization of the blackboard won't probably work
1830 // We need to ensure though the blackboard is initialized with valid data
1831 return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1832#else
1833 // Real back synchronizer from subsystems
1834 return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1835#endif
1836}
1837
1838// Children typwise access
1839CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
1840{
1841 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
1842}
1843
1844const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
1845{
1846 return getFrameworkConfiguration();
1847}
1848
1849CSelectionCriteria* CParameterMgr::getSelectionCriteria()
1850{
1851 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
1852}
1853
1854const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
1855{
1856 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
1857}
1858
1859CSystemClass* CParameterMgr::getSystemClass()
1860{
1861 return static_cast<CSystemClass*>(getChild(ESystemClass));
1862}
1863
1864const CSystemClass* CParameterMgr::getConstSystemClass() const
1865{
1866 return static_cast<const CSystemClass*>(getChild(ESystemClass));
1867}
1868
1869// Configurable Domains
1870CConfigurableDomains* CParameterMgr::getConfigurableDomains()
1871{
1872 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
1873}
1874
1875const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
1876{
1877 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1878}
1879
1880const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
1881{
1882 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1883}