blob: 6ef37bb2ae251b681983acd51eb5cc379c6b3003 [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 Benavoli68808c62012-02-02 17:12:41 +010080#include "EnumValuePair.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020081
82#define base CElement
83
84// Used for remote processor server creation
85typedef IRemoteProcessorServerInterface* (*CreateRemoteProcessorServer)(uint16_t uiPort, IRemoteCommandHandler* pCommandHandler);
86
87// Global configuration file name (fixed)
88const char* gacParameterFrameworkConfigurationFileName = "ParameterFrameworkConfiguration.xml";
89const char* gacSystemSchemasSubFolder = "Schemas";
90
91// Config File System looks normally like this:
92// ---------------------------------------------
Patrick Benavoli95ac0342011-11-07 20:32:51 +010093//├── <ParameterFrameworkConfiguration>.xml
Patrick Benavoli68a91282011-08-31 11:23:23 +020094//├── Schemas
95//│ └── *.xsd
96//├── Settings
97//│ └── <SystemClassName folder>*
98//│ ├── <ConfigurableDomains>.xml
99//│ └── <Settings>.bin?
100//└── Structure
101// └── <SystemClassName folder>*
102// ├── <SystemClassName>Class.xml
103// └── <Subsystem>.xml*
104// --------------------------------------------
105
106
107// Remote command parser array
Patrick Benavoli592ae562011-09-05 16:53:58 +0200108const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandParserItems[] = {
Patrick Benavoli592ae562011-09-05 16:53:58 +0200109 /// Version
110 { "version", &CParameterMgr::versionCommandProcess, 0, "", "Show version" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200111 /// Status
112 { "status", &CParameterMgr::statusCommandProcess, 0, "", "Show current status" },
113 /// Tuning Mode
114 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1, "on|off*", "Turn on or off Tuning Mode" },
115 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0, "", "Show Tuning Mode" },
116 /// Value Space
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200117 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1, "raw|real*", "Assigns Value Space used for parameter value interpretation" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200118 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0, "", "Show Value Space" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200119 /// Output Raw Format
120 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1, "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
121 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0, "", "Show Output Raw Format" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200122 /// Sync
123 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1, "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
124 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" },
125 { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200126 /// Criteria
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200127 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200128 /// Domains
129 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100130 { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0, "", "Show all domains and configurations, including applicability conditions" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200131 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1, "<domain>", "Create new configurable domain" },
132 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1, "<domain>", "Delete configurable domain" },
133 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2, "<domain> <new name>", "Rename configurable domain" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200134 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1, "<domain> true|false*", "Set configurable domain sequence awareness" },
135 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1, "<domain>", "Get configurable domain sequence awareness" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200136 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1, "<domain>", "List elements associated to configurable domain" },
137 { "addElement", &CParameterMgr::addElementCommmandProcess, 2, "<domain> <elem path>", "Associate element at given path to configurable domain" },
138 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2, "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
139 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2, "<domain> <elem path>", "Split configurable domain at given associated element path" },
140 /// Configurations
141 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1, "<domain>", "List domain configurations" },
142 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2, "<domain> <configuration>", "Create new domain configuration" },
143 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2, "<domain> <configuration>", "Delete domain configuration" },
144 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3, "<domain> <configuration> <new name>", "Rename domain configuration" },
145 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2, "<domain> <configuration>", "Save current settings into configuration" },
146 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2, "<domain> <configuration>", "Restore current settings from configuration" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100147 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3, "<domain> <configuration> <elem path list>", "Set element application order for configuration" },
Patrick Benavoli63499d42011-10-24 18:50:03 +0200148 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2, "<domain> <configuration>", "Get element application order for configuration" },
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100149 { "setRule", &CParameterMgr::setRuleCommmandProcess, 3, "<domain> <configuration> <rule>", "Set configuration application rule" },
150 { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2, "<domain> <configuration>", "Clear configuration application rule" },
151 { "getRule", &CParameterMgr::getRuleCommmandProcess, 2, "<domain> <configuration>", "Get configuration application rule" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200152 /// Elements/Parameters
153 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1, "<elem path>|/", "List elements under element at given path or root" },
Patrick Benavoli592ae562011-09-05 16:53:58 +0200154 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1, "<elem path>|/", "List parameters under element at given path or root" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200155 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1, "<elem path>", "Dump structure and content of element at given path" },
156 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1, "<elem path>", "Show size of element at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200157 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1, "<elem path>", "Show properties of element at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200158 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1, "<param path>", "Get value for parameter at given path" },
Patrick Benavoli2ecf9002011-08-31 11:23:24 +0200159 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2, "<param path> <value>", "Set value for parameter at given path" },
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200160 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path belongs to" },
Patrick Benavoli68a91282011-08-31 11:23:23 +0200161 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1, "<elem path>", "List domain(s) element at given path is associated to" },
162 /// Browse
163 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0, "", "List element sub-trees associated to at least one configurable domain" },
164 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0, "", "List element sub-trees contained in more than one configurable domain" },
165 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0, "", "List element sub-trees owned by no configurable domain" },
166 /// Settings Import/Export
167 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1, "<file path> ", "Export domains to XML file" },
168 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1, "<file path>", "Import domains from XML file" },
169 { "exportDomainsWithSettingsXML", &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1, "<file path> ", "Export domains including settings to XML file" },
170 { "importDomainsWithSettingsXML", &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1, "<file path>", "Import domains including settings from XML file" },
171 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1, "<file path>", "Export settings to binary file" },
172 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1, "<file path>", "Import settings from binary file" }
173};
174// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200175const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200176
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100177CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200178 _bTuningModeIsOn(false),
179 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200180 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200181 _bAutoSyncOn(true),
182 _pMainParameterBlackboard(new CParameterBlackboard),
183 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100184 _strXmlConfigurationFilePath(strConfigurationFilePath),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200185 _uiStructureChecksum(0),
186 _pRemoteProcessorServer(NULL),
187 _uiMaxCommandUsageLength(0),
188 _pLogger(NULL),
189 _uiLogDepth(0)
190{
191 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100192 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
193 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200194
195 // Deal with children
196 addChild(new CParameterFrameworkConfiguration);
197 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100198 addChild(new CSystemClass);
199 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200200
201 // Feed element library
202 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200203
204 _pCommandHandler = new CCommandHandler(this);
205
206 // Add command parsers
207 uint32_t uiRemoteCommandParserItem;
208
209 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
210
211 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
212
213 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
214 pRemoteCommandParserItem->_pfnParser,
215 pRemoteCommandParserItem->_uiMinArgumentCount,
216 pRemoteCommandParserItem->_pcHelp,
217 pRemoteCommandParserItem->_pcDescription);
218 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100219
220 // Configuration file folder
221 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
222
223 assert(uiSlashPos != (uint32_t)-1);
224
225 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
226
227 // Schema absolute folder location
228 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200229}
230
231CParameterMgr::~CParameterMgr()
232{
233 // Children
234 delete _pRemoteProcessorServer;
235 delete _pMainParameterBlackboard;
236 delete _pElementLibrarySet;
237
238 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100239 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200240}
241
242string CParameterMgr::getKind() const
243{
244 return "ParameterMgr";
245}
246
247// Logging
248void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
249{
250 _pLogger = pLogger;
251}
252
253// Logging
254void CParameterMgr::doLog(const string& strLog) const
255{
256 if (_pLogger) {
257
258 // Nest
259 string strIndent;
260
261 // Level
262 uint32_t uiNbIndents = _uiLogDepth;
263
264 while (uiNbIndents--) {
265
266 strIndent += " ";
267 }
268
269 // Log
270 _pLogger->log(strIndent + strLog);
271 }
272}
273
274void CParameterMgr::nestLog() const
275{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200276 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200277}
278
279void CParameterMgr::unnestLog() const
280{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200281 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200282}
283
Patrick Benavoli63499d42011-10-24 18:50:03 +0200284// Version
285string CParameterMgr::getVersion() const
286{
287 string strVersion;
288
289 // Major
290 strVersion = toString(guiEditionMajor) + ".";
291 // Minor
292 strVersion += toString(guiEditionMinor) + ".";
293 // Revision
294 strVersion += toString(guiRevision);
295
296 return strVersion;
297}
298
Patrick Benavoli68a91282011-08-31 11:23:23 +0200299bool CParameterMgr::load(string& strError)
300{
301 CAutoLog autoLog(this, "Loading");
302
303 // Load Framework configuration
304 if (!loadFrameworkConfiguration(strError)) {
305
306 return false;
307 }
308
309 // Load subsystems
310 if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) {
311
312 return false;
313 }
314
315 // Load structure
316 if (!loadStructure(strError)) {
317
318 return false;
319 }
320
321 // Load settings
322 if (!loadSettings(strError)) {
323
324 return false;
325 }
326
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200327 // Back synchronization for areas in parameter blackboard not covered by any domain
328 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200329
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200330 log("Main blackboard back synchronization");
331
332 // Back-synchronize
333 if (!pBackSynchronizer->sync()) {
334 // Get rid of back synchronizer
335 delete pBackSynchronizer;
336
337 strError = "Main blackboard back synchronization failed: " + strError;
338
339 return false;
340 }
341 // Get rif of back synchronizer
342 delete pBackSynchronizer;
343
344 // We're done loading the settings and back synchronizing
345 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
346
347 // We need to ensure all domains are valid
348 pConfigurableDomains->validate(_pMainParameterBlackboard);
349
350 // Ensure application of currently selected configurations
351 // Force-apply configurations
352 if (!pConfigurableDomains->apply(_pMainParameterBlackboard, true, strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200353
354 return false;
355 }
356
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200357 // Start remote processor server if appropriate
358 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200359}
360
361bool CParameterMgr::loadFrameworkConfiguration(string& strError)
362{
363 CAutoLog autoLog(this, "Loading framework configuration");
364
Patrick Benavoli68a91282011-08-31 11:23:23 +0200365 // Parse Structure XML file
366 CXmlElementSerializingContext elementSerializingContext(strError);
367
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100368 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200369
370 return false;
371 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100372 // Set class name to system class and configurable domains
373 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
374 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
375
Patrick Benavoli68a91282011-08-31 11:23:23 +0200376 // Get subsystem plugins folders element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100377 const CFrameworkConfigurationGroup* pSubsystemPluginFolders = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200378
379 if (!pSubsystemPluginFolders) {
380
381 strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element";
382
383 return false;
384 }
385 // Get plugin locations
386 uint32_t uiPluginFolderLocation;
387 uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren();
388
389 if (!uiNbPluginFolderLocations) {
390
391 strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element";
392
393 return false;
394 }
395
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100396 // Collect plugin paths
Patrick Benavoli68a91282011-08-31 11:23:23 +0200397 for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) {
398
399 const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation));
400
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100401 _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strXmlConfigurationFilePath));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200402 }
403
Patrick Benavoli68a91282011-08-31 11:23:23 +0200404 // Log tuning availability
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100405 log("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200406
407 return true;
408}
409
410bool CParameterMgr::loadStructure(string& strError)
411{
412 // Retrieve system to load structure to
413 CSystemClass* pSystemClass = getSystemClass();
414
415 CAutoLog autoLog(this, "Loading " + pSystemClass->getName() + " system class structure");
416
417 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100418 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200419
420 if (!pStructureDescriptionFileLocation) {
421
422 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
423
424 return false;
425 }
426
427 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100428 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200429
430 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100431 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200432
433 // Parse Structure XML file
434 CXmlParameterSerializingContext parameterBuildContext(strError);
435
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200436 log("Importing system structure from file %s", strXmlStructureFilePath.c_str());
437
Patrick Benavoli68a91282011-08-31 11:23:23 +0200438 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
439
440 return false;
441 }
442
443 // Initialize offsets
444 pSystemClass->setOffset(0);
445
446 // Initialize main blackboard's size
447 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
448
449 return true;
450}
451
452bool CParameterMgr::loadSettings(string& strError)
453{
454 CAutoLog autoLog(this, "Loading settings");
455
456 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100457 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200458
459 if (!pParameterConfigurationGroup) {
460
461 // No settings to load
462
463 return true;
464 }
465 // Get binary settings file location
466 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
467
468 string strXmlBinarySettingsFilePath;
469
470 if (pBinarySettingsFileLocation) {
471
472 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100473 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200474 }
475
476 // Get configurable domains element
477 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
478
479 if (!pConfigurableDomainsFileLocation) {
480
481 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
482
483 return false;
484 }
485 // Get destination root element
486 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
487
488 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100489 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200490
491 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100492 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200493
494 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
495 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
496
497 // Selection criteria definition for rule creation
498 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
499
Patrick Benavoli63499d42011-10-24 18:50:03 +0200500 // Auto validation of configurations if no binary settings provided
501 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
502
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200503 log("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
504
Patrick Benavoli68a91282011-08-31 11:23:23 +0200505 // Do parse
506 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
507
508 return false;
509 }
510 // We have loaded the whole system structure, compute checksum
511 const CSystemClass* pSystemClass = getConstSystemClass();
512 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
513
514 // Load binary settings if any provided
515 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
516
517 return false;
518 }
519
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200520 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200521}
522
523// XML parsing
524bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
525{
526 // Init serializing context
527 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
528
529 // Get Schema file associated to root element
530 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
531
532 // Parse Structure XML file
533 CXmlParser parser(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), elementSerializingContext);
534
535 if (!parser.open()) {
536
537 return false;
538 }
539
540 // Check Root element name attribute (if any)
541 string strRootElementName = parser.getRootElementAttributeString(strNameAttrituteName);
542
543 if (!strRootElementName.empty() && strRootElementName != pRootElement->getName()) {
544
545 elementSerializingContext.setError("Error: Wrong XML structure file " + strXmlFilePath);
546 elementSerializingContext.appendLineToError(pRootElement->getKind() + " element " + pRootElement->getName() + " mismatches expected " + pRootElement->getKind() + " type " + pRootElement->getName());
547
548 return false;
549 }
550
551 // Start clean
552 pRootElement->clean();
553
554 // Parse
555 if (!parser.parse(pRootElement)) {
556
557 // Cleanup
558 pRootElement->clean();
559
560 return false;
561 }
562
563 // Close parser
564 if (!parser.close()) {
565
566 return false;
567 }
568
569 return true;
570}
571
572// Init
573bool CParameterMgr::init(string& strError)
574{
575 return base::init(strError);
576}
577
578// Selection criteria interface
579CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
580{
581 // Propagate
582 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
583}
584
585CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
586{
587 // Propagate
588 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
589}
590
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200591// Selection criterion retrieval
592CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200593{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200594 // Propagate
595 return getSelectionCriteria()->getSelectionCriterion(strName);
596}
597
598// Selection criteria changed event
599bool CParameterMgr::applyConfigurations(string& strError)
600{
601 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200602
603 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100604 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200605
606 if (!_bTuningModeIsOn) {
607
608 // Apply configuration(s)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200609 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, false, strError)) {
610
611 log("Failed to apply configurations!");
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200612
613 return false;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200614 }
615 }
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200616
617 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200618}
619
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200620// Dynamic parameter handling
Patrick Benavoli065264a2011-11-20 15:46:41 +0100621CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200622{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100623 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200624
Patrick Benavoli065264a2011-11-20 15:46:41 +0100625 // Nagivate through system class
626 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
627
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100628 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100629 }
630
631 // Find element
632 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
633
634 if (!pElement) {
635
636 strError = "Path not found";
637
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100638 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100639 }
640
641 // Check found element is a parameter
642 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
643
644 if (!pConfigurableElement->isParameter()) {
645
646 // Element is not parameter
647 strError = "Not a parameter";
648
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100649 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100650 }
651
652 // Convert as parameter and return new handle
653 return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200654}
655
Patrick Benavoli68a91282011-08-31 11:23:23 +0200656/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200657/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200658CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200659{
660 (void)remoteCommand;
661
Patrick Benavoli63499d42011-10-24 18:50:03 +0200662 // Show version
663 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200664
Patrick Benavoli63499d42011-10-24 18:50:03 +0200665 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200666}
667
Patrick Benavoli68a91282011-08-31 11:23:23 +0200668/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200669CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200670{
671 (void)remoteCommand;
672 // System class
673 const CSystemClass* pSystemClass = getSystemClass();
674
Patrick Benavoli68a91282011-08-31 11:23:23 +0200675 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200676 /// General section
677 appendTitle(strResult, "General:");
678 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200679 strResult += "System Class: ";
680 strResult += pSystemClass->getName();
681 strResult += "\n";
682
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200683 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200684 strResult += "Tuning Mode: ";
685 strResult += tuningModeOn() ? "on" : "off";
686 strResult += "\n";
687
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200688 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200689 strResult += "Value Space: ";
690 strResult += valueSpaceIsRaw() ? "raw" : "real";
691 strResult += "\n";
692
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200693 // Output raw format
694 strResult += "Output Raw Format: ";
695 strResult += outputRawFormatIsHex() ? "hex" : "dec";
696 strResult += "\n";
697
698 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200699 strResult += "Auto Sync: ";
700 strResult += autoSyncOn() ? "on" : "off";
701 strResult += "\n";
702
703 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200704 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200705 string strSubsystemList;
706 pSystemClass->listChildrenPaths(strSubsystemList);
707 strResult += strSubsystemList;
708
709 /// Last applied configurations
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200710 appendTitle(strResult, "Last applied configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200711 string strLastAppliedConfigurations;
712 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
713 strResult += strLastAppliedConfigurations;
714
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200715 /// Criteria states
716 appendTitle(strResult, "Selection criteria:");
717 string strSelectionCriteria;
718 getSelectionCriteria()->listSelectionCriteria(strSelectionCriteria, false);
719 strResult += strSelectionCriteria;
720
Patrick Benavoli63499d42011-10-24 18:50:03 +0200721 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200722}
723
724/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200725CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200726{
727 if (remoteCommand.getArgument(0) == "on") {
728
729 if (setTuningMode(true, strResult)) {
730
Patrick Benavoli63499d42011-10-24 18:50:03 +0200731 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200732 }
733 } else if (remoteCommand.getArgument(0) == "off") {
734
735 if (setTuningMode(false, strResult)) {
736
Patrick Benavoli63499d42011-10-24 18:50:03 +0200737 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200738 }
739 } else {
740 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200741 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200742 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200743 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200744}
745
Patrick Benavoli63499d42011-10-24 18:50:03 +0200746CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200747{
748 (void)remoteCommand;
749
750 strResult = tuningModeOn() ? "on" : "off";
751
Patrick Benavoli63499d42011-10-24 18:50:03 +0200752 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200753}
754
755/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200756CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200757{
758 (void)strResult;
759
760 if (remoteCommand.getArgument(0) == "raw") {
761
762 setValueSpace(true);
763
Patrick Benavoli63499d42011-10-24 18:50:03 +0200764 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200765
766 } else if (remoteCommand.getArgument(0) == "real") {
767
768 setValueSpace(false);
769
Patrick Benavoli63499d42011-10-24 18:50:03 +0200770 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200771
772 } else {
773 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200774 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200775 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200776 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200777}
778
Patrick Benavoli63499d42011-10-24 18:50:03 +0200779CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200780{
781 (void)remoteCommand;
782
783 strResult = valueSpaceIsRaw() ? "raw" : "real";
784
Patrick Benavoli63499d42011-10-24 18:50:03 +0200785 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200786}
787
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200788/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200789CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200790{
791 (void)strResult;
792
793 if (remoteCommand.getArgument(0) == "hex") {
794
795 setOutputRawFormat(true);
796
Patrick Benavoli63499d42011-10-24 18:50:03 +0200797 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200798
799 } else if (remoteCommand.getArgument(0) == "dec") {
800
801 setOutputRawFormat(false);
802
Patrick Benavoli63499d42011-10-24 18:50:03 +0200803 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200804
805 } else {
806 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200807 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200808 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200809 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200810}
811
Patrick Benavoli63499d42011-10-24 18:50:03 +0200812CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200813{
814 (void)remoteCommand;
815
816 strResult = outputRawFormatIsHex() ? "hex" : "dec";
817
Patrick Benavoli63499d42011-10-24 18:50:03 +0200818 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200819}
820
Patrick Benavoli68a91282011-08-31 11:23:23 +0200821/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200822CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200823{
824 if (remoteCommand.getArgument(0) == "on") {
825
826 if (setAutoSync(true, strResult)) {
827
Patrick Benavoli63499d42011-10-24 18:50:03 +0200828 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200829 }
830 } else if (remoteCommand.getArgument(0) == "off") {
831
832 if (setAutoSync(false, strResult)) {
833
Patrick Benavoli63499d42011-10-24 18:50:03 +0200834 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200835 }
836 } else {
837 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200838 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200839 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200840 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200841}
842
Patrick Benavoli63499d42011-10-24 18:50:03 +0200843CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200844{
845 (void)remoteCommand;
846
847 strResult = autoSyncOn() ? "on" : "off";
848
Patrick Benavoli63499d42011-10-24 18:50:03 +0200849 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200850}
851
Patrick Benavoli63499d42011-10-24 18:50:03 +0200852CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200853{
854 (void)remoteCommand;
855
Patrick Benavoli63499d42011-10-24 18:50:03 +0200856 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200857}
858
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200859/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200860CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200861{
862 (void)remoteCommand;
863
864 getSelectionCriteria()->listSelectionCriteria(strResult, true);
865
Patrick Benavoli63499d42011-10-24 18:50:03 +0200866 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200867}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200868
869/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200870CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200871{
872 (void)remoteCommand;
873
Patrick Benavoli63499d42011-10-24 18:50:03 +0200874 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200875
Patrick Benavoli63499d42011-10-24 18:50:03 +0200876 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200877}
878
Patrick Benavoli63499d42011-10-24 18:50:03 +0200879CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200880{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200881 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200882}
883
Patrick Benavoli63499d42011-10-24 18:50:03 +0200884CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200885{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200886 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200887}
888
Patrick Benavoli63499d42011-10-24 18:50:03 +0200889CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200890{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200891 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200892}
893
Patrick Benavoli63499d42011-10-24 18:50:03 +0200894CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200895{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200896 // Check tuning mode
897 if (!checkTuningModeOn(strResult)) {
898
899 return CCommandHandler::EFailed;
900 }
901
902 // Set property
903 bool bSequenceAware;
904
905 if (remoteCommand.getArgument(1) == "true") {
906
907 bSequenceAware = true;
908
909 } else if (remoteCommand.getArgument(1) == "false") {
910
911 bSequenceAware = false;
912
913 } else {
914 // Show usage
915 return CCommandHandler::EShowUsage;
916 }
917
918 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200919}
920
Patrick Benavoli63499d42011-10-24 18:50:03 +0200921CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200922{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200923 // Get property
924 bool bSequenceAware;
925
926 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
927
928 return CCommandHandler::EFailed;
929 }
930
931 strResult = bSequenceAware ? "true" : "false";
932
933 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200934}
935
Patrick Benavoli63499d42011-10-24 18:50:03 +0200936CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200937{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200938 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200939}
940
Patrick Benavoli63499d42011-10-24 18:50:03 +0200941CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200942{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200943 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
944}
945
946CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
947{
948 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
949}
950
951CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
952{
953 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200954}
955
956/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +0200957CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200958{
Patrick Benavoli0bd50542011-11-29 11:10:27 +0100959 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
960}
961
962CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
963{
964 (void)remoteCommand;
965
966 // Dummy error context
967 string strError;
968 CErrorContext errorContext(strError);
969
970 // Dump
971 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
972
973 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200974}
975
Patrick Benavoli63499d42011-10-24 18:50:03 +0200976CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200977{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200978 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200979}
980
Patrick Benavoli63499d42011-10-24 18:50:03 +0200981CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200982{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200983 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200984}
985
Patrick Benavoli63499d42011-10-24 18:50:03 +0200986CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200987{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200988 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200989}
990
Patrick Benavoli63499d42011-10-24 18:50:03 +0200991CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200992{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200993 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200994}
995
Patrick Benavoli63499d42011-10-24 18:50:03 +0200996CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200997{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200998 return restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
999}
1000
1001CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1002{
1003 // Check tuning mode
1004 if (!checkTuningModeOn(strResult)) {
1005
1006 return CCommandHandler::EFailed;
1007 }
1008
1009 // Build configurable element path list
1010 vector<string> astrNewElementSequence;
1011
1012 uint32_t uiArgument;
1013
1014 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1015
1016 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1017 }
1018
1019 // Delegate to configurable domains
1020 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1021}
1022
1023CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1024{
1025 // Delegate to configurable domains
1026 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001027}
1028
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001029CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1030{
1031 // Delegate to configurable domains
1032 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1033}
1034
1035CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1036{
1037 // Delegate to configurable domains
1038 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1039}
1040
1041CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1042{
1043 // Delegate to configurable domains
1044 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1045}
1046
Patrick Benavoli68a91282011-08-31 11:23:23 +02001047/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001048CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001049{
1050 CElementLocator elementLocator(getSystemClass(), false);
1051
1052 CElement* pLocatedElement = NULL;
1053
1054 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1055
Patrick Benavoli63499d42011-10-24 18:50:03 +02001056 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001057 }
1058
1059 strResult = string("\n");
1060
1061 if (!pLocatedElement) {
1062
1063 // List from root folder
1064
1065 // Return system class qualified name
1066 pLocatedElement = getSystemClass();
1067 }
1068
1069 // Return sub-elements
1070 strResult += pLocatedElement->listQualifiedPaths(false);
1071
Patrick Benavoli63499d42011-10-24 18:50:03 +02001072 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001073}
1074
1075/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001076CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001077{
1078 CElementLocator elementLocator(getSystemClass(), false);
1079
1080 CElement* pLocatedElement = NULL;
1081
1082 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1083
Patrick Benavoli63499d42011-10-24 18:50:03 +02001084 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001085 }
1086
1087 strResult = string("\n");
1088
1089 if (!pLocatedElement) {
1090
1091 // List from root folder
1092
1093 // Return system class qualified name
1094 pLocatedElement = getSystemClass();
1095 }
1096
1097 // Return sub-elements
1098 strResult += pLocatedElement->listQualifiedPaths(true);
1099
Patrick Benavoli63499d42011-10-24 18:50:03 +02001100 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001101}
1102
Patrick Benavoli63499d42011-10-24 18:50:03 +02001103CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001104{
1105 CElementLocator elementLocator(getSystemClass());
1106
1107 CElement* pLocatedElement = NULL;
1108
1109 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1110
Patrick Benavoli63499d42011-10-24 18:50:03 +02001111 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001112 }
1113
1114 string strError;
1115
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001116 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001117
1118 // Dump elements
1119 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1120
Patrick Benavoli63499d42011-10-24 18:50:03 +02001121 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001122}
1123
Patrick Benavoli63499d42011-10-24 18:50:03 +02001124CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001125{
1126 CElementLocator elementLocator(getSystemClass());
1127
1128 CElement* pLocatedElement = NULL;
1129
1130 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1131
Patrick Benavoli63499d42011-10-24 18:50:03 +02001132 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001133 }
1134
1135 // Converted to actual sizable element
1136 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1137
1138 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001139 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001140
Patrick Benavoli63499d42011-10-24 18:50:03 +02001141 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001142}
1143
Patrick Benavoli63499d42011-10-24 18:50:03 +02001144CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001145{
1146 CElementLocator elementLocator(getSystemClass());
1147
1148 CElement* pLocatedElement = NULL;
1149
1150 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1151
Patrick Benavoli63499d42011-10-24 18:50:03 +02001152 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001153 }
1154
1155 // Convert element
1156 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1157
1158 // Return element properties
1159 pConfigurableElement->showProperties(strResult);
1160
Patrick Benavoli63499d42011-10-24 18:50:03 +02001161 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001162}
1163
Patrick Benavoli63499d42011-10-24 18:50:03 +02001164CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001165{
1166 string strValue;
1167
Patrick Benavoli065264a2011-11-20 15:46:41 +01001168 if (!accessValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001169
Patrick Benavoli63499d42011-10-24 18:50:03 +02001170 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001171 }
1172 // Succeeded
1173 strResult = strValue;
1174
Patrick Benavoli63499d42011-10-24 18:50:03 +02001175 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001176}
1177
Patrick Benavoli63499d42011-10-24 18:50:03 +02001178CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001179{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001180 // Check tuning mode
1181 if (!checkTuningModeOn(strResult)) {
1182
1183 return CCommandHandler::EFailed;
1184 }
1185 // Get value to set
1186 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1187
1188 return accessValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001189}
1190
Patrick Benavoli63499d42011-10-24 18:50:03 +02001191CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001192{
1193 CElementLocator elementLocator(getSystemClass());
1194
1195 CElement* pLocatedElement = NULL;
1196
1197 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1198
Patrick Benavoli63499d42011-10-24 18:50:03 +02001199 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001200 }
1201
1202 // Convert element
1203 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1204
1205 // Return element belonging domains
1206 pConfigurableElement->listBelongingDomains(strResult);
1207
Patrick Benavoli63499d42011-10-24 18:50:03 +02001208 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001209}
1210
Patrick Benavoli63499d42011-10-24 18:50:03 +02001211CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001212{
1213 CElementLocator elementLocator(getSystemClass());
1214
1215 CElement* pLocatedElement = NULL;
1216
1217 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1218
Patrick Benavoli63499d42011-10-24 18:50:03 +02001219 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001220 }
1221
1222 // Convert element
1223 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1224
1225 // Return element belonging domains
1226 pConfigurableElement->listAssociatedDomains(strResult);
1227
Patrick Benavoli63499d42011-10-24 18:50:03 +02001228 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001229}
1230
Patrick Benavoli63499d42011-10-24 18:50:03 +02001231CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001232{
1233 (void)remoteCommand;
1234
1235 getConfigurableDomains()->listAssociatedElements(strResult);
1236
Patrick Benavoli63499d42011-10-24 18:50:03 +02001237 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001238}
1239
Patrick Benavoli63499d42011-10-24 18:50:03 +02001240CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001241{
1242 (void)remoteCommand;
1243
1244 getConfigurableDomains()->listConflictingElements(strResult);
1245
Patrick Benavoli63499d42011-10-24 18:50:03 +02001246 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001247}
1248
Patrick Benavoli63499d42011-10-24 18:50:03 +02001249CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001250{
1251 (void)remoteCommand;
1252
1253 getSystemClass()->listRogueElements(strResult);
1254
Patrick Benavoli63499d42011-10-24 18:50:03 +02001255 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001256}
1257
1258/// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +02001259CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001260{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001261 return exportDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001262}
1263
Patrick Benavoli63499d42011-10-24 18:50:03 +02001264CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001265{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001266 return importDomainsXml(remoteCommand.getArgument(0), false, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001267}
1268
Patrick Benavoli63499d42011-10-24 18:50:03 +02001269CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001270{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001271 return exportDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001272}
1273
Patrick Benavoli63499d42011-10-24 18:50:03 +02001274CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001275{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001276 return importDomainsXml(remoteCommand.getArgument(0), true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001277}
1278
Patrick Benavoli63499d42011-10-24 18:50:03 +02001279CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001280{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001281 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001282}
1283
Patrick Benavoli63499d42011-10-24 18:50:03 +02001284CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001285{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001286 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001287}
1288
1289// User set/get parameters
Patrick Benavoli065264a2011-11-20 15:46:41 +01001290bool CParameterMgr::accessValue(const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001291{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001292 // Lock state
1293 CAutoLock autoLock(&_blackboardMutex);
1294
1295 CPathNavigator pathNavigator(strPath);
1296
1297 // Nagivate through system class
1298 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001299
1300 return false;
1301 }
1302
Patrick Benavoli065264a2011-11-20 15:46:41 +01001303 // Define context
1304 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001305
Patrick Benavoli68808c62012-02-02 17:12:41 +01001306 // Auto Sync
1307 if (bSet) {
1308
1309 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1310 }
1311
Patrick Benavoli065264a2011-11-20 15:46:41 +01001312 // Do the get
1313 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001314}
1315
1316// Tuning mode
1317bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1318{
1319 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001320 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001321
1322 strError = "Tuning prohibited";
1323
1324 return false;
1325 }
1326 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001327 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001328
1329 // Warn domains about exiting tuning mode
1330 if (!bOn && _bTuningModeIsOn) {
1331
1332 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001333 // Force-apply configurations
Patrick Benavoli68a91282011-08-31 11:23:23 +02001334 if (!getConfigurableDomains()->apply(_pMainParameterBlackboard, true, strError)) {
1335
1336 return false;
1337 }
1338 // Turn auto sync back on
1339 _bAutoSyncOn = true;
1340 }
1341
1342 // Store
1343 _bTuningModeIsOn = bOn;
1344
Patrick Benavoli68a91282011-08-31 11:23:23 +02001345 return true;
1346}
1347
1348bool CParameterMgr::tuningModeOn() const
1349{
1350 return _bTuningModeIsOn;
1351}
1352
1353// Current value space for user set/get value interpretation
1354void CParameterMgr::setValueSpace(bool bIsRaw)
1355{
1356 _bValueSpaceIsRaw = bIsRaw;
1357}
1358
1359bool CParameterMgr::valueSpaceIsRaw()
1360{
1361 return _bValueSpaceIsRaw;
1362}
1363
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001364// Current Output Raw Format for user get value interpretation
1365void CParameterMgr::setOutputRawFormat(bool bIsHex)
1366{
1367 _bOutputRawFormatIsHex = bIsHex;
1368}
1369
1370bool CParameterMgr::outputRawFormatIsHex()
1371{
1372 return _bOutputRawFormatIsHex;
1373}
1374
Patrick Benavoli68a91282011-08-31 11:23:23 +02001375/// Sync
1376// Automatic hardware synchronization control (during tuning session)
1377bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1378{
1379 // Check tuning mode
1380 if (!checkTuningModeOn(strError)) {
1381
1382 return false;
1383 }
1384 // Warn domains about turning auto sync back on
1385 if (bAutoSyncOn && !_bAutoSyncOn) {
1386
Patrick Benavoli592ae562011-09-05 16:53:58 +02001387 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1388 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001389
1390 return false;
1391 }
1392 }
1393
1394 // Set Auto sync
1395 _bAutoSyncOn = bAutoSyncOn;
1396
1397 return true;
1398}
1399
1400bool CParameterMgr::autoSyncOn() const
1401{
1402 return _bAutoSyncOn;
1403}
1404
1405// Manual hardware synchronization control (during tuning session)
1406bool CParameterMgr::sync(string& strError)
1407{
1408 // Check tuning mode
1409 if (!checkTuningModeOn(strError)) {
1410
1411 return false;
1412 }
1413 // Warn domains about turning auto sync back on
1414 if (_bAutoSyncOn) {
1415
1416 strError = "Feature unavailable when Auto Sync is on";
1417
1418 return false;
1419 }
1420
1421 // Get syncer set
1422 CSyncerSet syncerSet;
1423 // ... from system class
1424 getConstSystemClass()->fillSyncerSet(syncerSet);
1425 // Sync
1426 return syncerSet.sync(*_pMainParameterBlackboard, false, strError);
1427}
1428
1429// Content dump
1430void CParameterMgr::logStructureContent(string& strContent) const
1431{
1432 string strError;
1433
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001434 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001435
1436 dumpContent(strContent, parameterAccessContext);
1437}
1438
1439// Configuration/Domains handling
1440bool CParameterMgr::createDomain(const string& strName, string& strError)
1441{
1442 // Check tuning mode
1443 if (!checkTuningModeOn(strError)) {
1444
1445 return false;
1446 }
1447
1448 // Delegate to configurable domains
1449 return getConfigurableDomains()->createDomain(strName, strError);
1450}
1451
1452bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1453{
1454 // Check tuning mode
1455 if (!checkTuningModeOn(strError)) {
1456
1457 return false;
1458 }
1459
1460 // Delegate to configurable domains
1461 return getConfigurableDomains()->deleteDomain(strName, strError);
1462}
1463
1464bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1465{
1466 // Check tuning mode
1467 if (!checkTuningModeOn(strError)) {
1468
1469 return false;
1470 }
1471
1472 // Delegate to configurable domains
1473 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1474}
1475
1476bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1477{
1478 // Check tuning mode
1479 if (!checkTuningModeOn(strError)) {
1480
1481 return false;
1482 }
1483
1484 // Delegate to configurable domains
1485 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1486}
1487
1488bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1489{
1490 // Check tuning mode
1491 if (!checkTuningModeOn(strError)) {
1492
1493 return false;
1494 }
1495
1496 // Delegate to configurable domains
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001497 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001498}
1499
1500bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1501{
1502 // Check tuning mode
1503 if (!checkTuningModeOn(strError)) {
1504
1505 return false;
1506 }
1507
1508 // Delegate to configurable domains
1509 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1510}
1511
1512// Configurable element - domain association
1513bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1514{
1515 // Check tuning mode
1516 if (!checkTuningModeOn(strError)) {
1517
1518 return false;
1519 }
1520
1521 CElementLocator elementLocator(getSystemClass());
1522
1523 CElement* pLocatedElement = NULL;
1524
1525 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1526
1527 return false;
1528 }
1529
1530 // Convert element
1531 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1532
1533 // Delegate
1534 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1535}
1536
1537bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1538{
1539 // Check tuning mode
1540 if (!checkTuningModeOn(strError)) {
1541
1542 return false;
1543 }
1544
1545 CElementLocator elementLocator(getSystemClass());
1546
1547 CElement* pLocatedElement = NULL;
1548
1549 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1550
Patrick Benavoli63499d42011-10-24 18:50:03 +02001551 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001552 }
1553
1554 // Convert element
1555 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1556
1557 // Delegate
1558 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1559}
1560
1561bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1562{
1563 // Check tuning mode
1564 if (!checkTuningModeOn(strError)) {
1565
1566 return false;
1567 }
1568
1569 CElementLocator elementLocator(getSystemClass());
1570
1571 CElement* pLocatedElement = NULL;
1572
1573 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1574
Patrick Benavoli63499d42011-10-24 18:50:03 +02001575 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001576 }
1577
1578 // Convert element
1579 CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1580
1581 // Delegate
1582 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1583}
1584
1585// XML Import/Export
1586bool CParameterMgr::importDomainsXml(const string& strFileName, bool bWithSettings, string& strError)
1587{
1588 // Check tuning mode
1589 if (!checkTuningModeOn(strError)) {
1590
1591 return false;
1592 }
1593
1594 // check path is absolute
1595 if (strFileName[0] != '/') {
1596
1597 strError = "Please provide absolute path";
1598
1599 return false;
1600 }
1601 // Root element
1602 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1603
1604 // Context
1605 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1606
1607 // Secltion criteria definition for rule creation
1608 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
1609
1610 // Parse
1611 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strFileName, "", EParameterConfigurationLibrary, "SystemClassName")) {
1612
1613 return false;
1614 }
1615
1616 // Validate domains after XML import
1617 pConfigurableDomains->validate(_pMainParameterBlackboard);
1618
1619 return true;
1620}
1621
1622bool CParameterMgr::exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const
1623{
1624 // check path is absolute
1625 if (strFileName[0] != '/') {
1626
1627 strError = "Please provide absolute path";
1628
1629 return false;
1630 }
1631
1632 // Root element
1633 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1634
1635 // Get Schema file associated to root element
1636 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pConfigurableDomains->getKind() + ".xsd";
1637
1638 // Context
1639 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1640
1641 // Value space
1642 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1643
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001644 // Output raw format
1645 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1646
Patrick Benavoli68a91282011-08-31 11:23:23 +02001647 // Instantiate composer
1648 CXmlComposer xmlComposer(strFileName, strXmlSchemaFilePath, pConfigurableDomains->getKind(), xmlDomainSerializingContext);
1649
1650 // Open composer
1651 if (!xmlComposer.open()) {
1652
1653 return false;
1654 }
1655
1656 // Compose
Patrick Benavoli63499d42011-10-24 18:50:03 +02001657 xmlComposer.compose(pConfigurableDomains, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001658
1659 // Close composer
1660 if (!xmlComposer.close()) {
1661
1662 return false;
1663 }
1664
1665 return true;
1666}
1667
1668// Binary Import/Export
1669bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1670{
1671 // Check tuning mode
1672 if (!checkTuningModeOn(strError)) {
1673
1674 return false;
1675 }
1676 // check path is absolute
1677 if (strFileName[0] != '/') {
1678
1679 strError = "Please provide absolute path";
1680
1681 return false;
1682 }
1683 // Root element
1684 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1685
1686 // Serialize in
1687 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1688}
1689
1690bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1691{
1692 // check path is absolute
1693 if (strFileName[0] != '/') {
1694
1695 strError = "Please provide absolute path";
1696
1697 return false;
1698 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001699
Patrick Benavoli68a91282011-08-31 11:23:23 +02001700 // Root element
1701 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1702
1703 // Serialize out
1704 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1705}
1706
1707// For tuning, check we're in tuning mode
1708bool CParameterMgr::checkTuningModeOn(string& strError) const
1709{
1710 // Tuning Mode on?
1711 if (!_bTuningModeIsOn) {
1712
1713 strError = "Tuning Mode must be on";
1714
1715 return false;
1716 }
1717 return true;
1718}
1719
Patrick Benavoli065264a2011-11-20 15:46:41 +01001720// Tuning mutex dynamic parameter handling
1721pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001722{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001723 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001724}
1725
Patrick Benavoli065264a2011-11-20 15:46:41 +01001726// Blackboard reference (dynamic parameter handling)
1727CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001728{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001729 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02001730}
1731
Patrick Benavoli68a91282011-08-31 11:23:23 +02001732// Dynamic creation library feeding
1733void CParameterMgr::feedElementLibraries()
1734{
1735 // Global Configuration handling
1736 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
1737
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001738 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
1739 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders"));
1740 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001741 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
1742 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
1743 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
1744 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001745
1746 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
1747
1748 // Parameter creation
1749 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
1750
1751 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001752 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
1753 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
1754 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
1755 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02001756 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001757 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
1758 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
1759 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoliee65e6d2011-11-20 18:52:24 +01001760 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02001761 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli68808c62012-02-02 17:12:41 +01001762 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001763 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
1764 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001765
1766 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
1767
1768 // Parameter Configuration Domains creation
1769 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
1770
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001771 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
1772 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
1773 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
1774 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02001775
1776 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
1777}
1778
1779// Remote Processor Server connection handling
1780bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
1781{
1782 CAutoLog autoLog(this, "Handling remote processing interface");
1783
1784 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001785 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001786
1787 log("Loading remote processor library");
1788
1789 // Load library
1790 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
1791
1792 if (!lib_handle) {
1793
1794 // Return error
1795 const char* pcError = dlerror();
1796
1797 if (pcError) {
1798
1799 strError = pcError;
1800 } else {
1801
1802 strError = "Unable to load libremote-processor.so library";
1803 }
1804
1805 return false;
1806 }
1807
1808 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
1809
1810 if (!pfnCreateRemoteProcessorServer) {
1811
1812 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
1813
1814 return false;
1815 }
1816
1817 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001818 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001819
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001820 log("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001821 // Start
1822 if (!_pRemoteProcessorServer->start()) {
1823
1824 strError = "Unable to start remote processor server";
1825
1826 return false;
1827 }
1828 }
1829
1830 return true;
1831}
1832
1833// Back synchronization
1834CBackSynchronizer* CParameterMgr::createBackSynchronizer(string& strError) const
1835{
1836#ifdef SIMULATION
1837 // In simulation, back synchronization of the blackboard won't probably work
1838 // We need to ensure though the blackboard is initialized with valid data
1839 return new CSimulatedBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1840#else
1841 // Real back synchronizer from subsystems
1842 return new CHardwareBackSynchronizer(getConstSystemClass(), strError, _pMainParameterBlackboard);
1843#endif
1844}
1845
1846// Children typwise access
1847CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
1848{
1849 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
1850}
1851
1852const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
1853{
1854 return getFrameworkConfiguration();
1855}
1856
1857CSelectionCriteria* CParameterMgr::getSelectionCriteria()
1858{
1859 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
1860}
1861
1862const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
1863{
1864 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
1865}
1866
1867CSystemClass* CParameterMgr::getSystemClass()
1868{
1869 return static_cast<CSystemClass*>(getChild(ESystemClass));
1870}
1871
1872const CSystemClass* CParameterMgr::getConstSystemClass() const
1873{
1874 return static_cast<const CSystemClass*>(getChild(ESystemClass));
1875}
1876
1877// Configurable Domains
1878CConfigurableDomains* CParameterMgr::getConfigurableDomains()
1879{
1880 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
1881}
1882
1883const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
1884{
1885 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1886}
1887
1888const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
1889{
1890 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
1891}