blob: 02bedb9fc32d7c217bbd20421fb091dbed0e6984 [file] [log] [blame]
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001 /*
Patrick Benavoli68a91282011-08-31 11:23:23 +02002 * INTEL CONFIDENTIAL
3 * Copyright © 2011 Intel
4 * Corporation All Rights Reserved.
5 *
6 * The source code contained or described herein and all documents related to
7 * the source code ("Material") are owned by Intel Corporation or its suppliers
8 * or licensors. Title to the Material remains with Intel Corporation or its
9 * suppliers and licensors. The Material contains trade secrets and proprietary
10 * and confidential information of Intel or its suppliers and licensors. The
11 * Material is protected by worldwide copyright and trade secret laws and
12 * treaty provisions. No part of the Material may be used, copied, reproduced,
13 * modified, published, uploaded, posted, transmitted, distributed, or
14 * disclosed in any way without Intel’s prior express written permission.
15 *
16 * No license under any patent, copyright, trade secret or other intellectual
17 * property right is granted to or conferred upon you by disclosure or delivery
18 * of the Materials, either expressly, by implication, inducement, estoppel or
19 * otherwise. Any license under such intellectual property rights must be
20 * express and approved by Intel in writing.
21 *
Patrick Benavoli68a91282011-08-31 11:23:23 +020022 * CREATED: 2011-06-01
23 * UPDATED: 2011-07-27
Patrick Benavoli68a91282011-08-31 11:23:23 +020024 */
25#include "ParameterMgr.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020026#include "XmlParameterSerializingContext.h"
27#include "XmlElementSerializingContext.h"
28#include "SystemClass.h"
29#include "ElementLibrarySet.h"
30#include "SubsystemLibrary.h"
31#include "NamedElementBuilderTemplate.h"
32#include "KindElementBuilderTemplate.h"
33#include "ElementBuilderTemplate.h"
34#include "SelectionCriterionType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020035#include "SubsystemElementBuilder.h"
36#include "SelectionCriteria.h"
37#include "ComponentType.h"
38#include "ComponentInstance.h"
39#include "ParameterBlockType.h"
40#include "BooleanParameterType.h"
41#include "IntegerParameterType.h"
42#include "FixedPointParameterType.h"
43#include "ParameterBlackboard.h"
44#include "Parameter.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020045#include "ParameterAccessContext.h"
46#include "XmlFileIncluderElement.h"
47#include "ParameterFrameworkConfiguration.h"
48#include "FrameworkConfigurationGroup.h"
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +010049#include "PluginLocation.h"
50#include "SubsystemPlugins.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020051#include "FrameworkConfigurationLocation.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020052#include "ConfigurableDomains.h"
53#include "ConfigurableDomain.h"
54#include "DomainConfiguration.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020055#include "XmlDomainSerializingContext.h"
56#include "BitParameterBlockType.h"
57#include "BitParameterType.h"
Patrick Benavoli1352ae52011-10-21 16:48:04 +020058#include "StringParameterType.h"
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +020059#include "EnumParameterType.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020060#include "RemoteProcessorServerInterface.h"
61#include "ElementLocator.h"
62#include "AutoLog.h"
63#include "CompoundRule.h"
64#include "SelectionCriterionRule.h"
65#include "SimulatedBackSynchronizer.h"
66#include "HardwareBackSynchronizer.h"
Patrick Benavoli1387bda2011-08-31 11:23:24 +020067#include "AutoLock.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020068#include <strings.h>
69#include <dlfcn.h>
70#include <assert.h>
Patrick Benavoli065264a2011-11-20 15:46:41 +010071#include "ParameterHandle.h"
Patrick Benavoliee65e6d2011-11-20 18:52:24 +010072#include "LinearParameterAdaptation.h"
Patrick Benavoli68808c62012-02-02 17:12:41 +010073#include "EnumValuePair.h"
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020074#include "XmlFileDocSink.h"
75#include "XmlFileDocSource.h"
76#include "XmlStringDocSink.h"
Georges-Henri Baroncec86c12012-09-04 17:30:28 +020077#include "XmlStringDocSource.h"
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020078#include "XmlMemoryDocSink.h"
79#include "XmlMemoryDocSource.h"
Kevin Rocardace81f82012-12-11 16:19:17 +010080#include "Utility.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[] = {
Kevin Rocard3949b342013-05-24 18:43:53 +0200109
Patrick Benavoli592ae562011-09-05 16:53:58 +0200110 /// Version
Kevin Rocard3949b342013-05-24 18:43:53 +0200111 { "version", &CParameterMgr::versionCommandProcess, 0,
112 "", "Show version" },
113
Patrick Benavoli68a91282011-08-31 11:23:23 +0200114 /// Status
Kevin Rocard3949b342013-05-24 18:43:53 +0200115 { "status", &CParameterMgr::statusCommandProcess, 0, "",
116 "Show current status" },
117
Patrick Benavoli68a91282011-08-31 11:23:23 +0200118 /// Tuning Mode
Kevin Rocard3949b342013-05-24 18:43:53 +0200119 { "setTuningMode", &CParameterMgr::setTuningModeCommmandProcess, 1,
120 "on|off*", "Turn on or off Tuning Mode" },
121 { "getTuningMode", &CParameterMgr::getTuningModeCommmandProcess, 0,
122 "", "Show Tuning Mode" },
123
Patrick Benavoli68a91282011-08-31 11:23:23 +0200124 /// Value Space
Kevin Rocard3949b342013-05-24 18:43:53 +0200125 { "setValueSpace", &CParameterMgr::setValueSpaceCommmandProcess, 1,
126 "raw|real*", "Assigns Value Space used for parameter value interpretation" },
127 { "getValueSpace", &CParameterMgr::getValueSpaceCommmandProcess, 0,
128 "", "Show Value Space" },
129
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200130 /// Output Raw Format
Kevin Rocard3949b342013-05-24 18:43:53 +0200131 { "setOutputRawFormat", &CParameterMgr::setOutputRawFormatCommmandProcess, 1,
132 "dec*|hex", "Assigns format used to output parameter values when in raw Value Space" },
133 { "getOutputRawFormat", &CParameterMgr::getOutputRawFormatCommmandProcess, 0,
134 "", "Show Output Raw Format" },
135
Patrick Benavoli68a91282011-08-31 11:23:23 +0200136 /// Sync
Kevin Rocard3949b342013-05-24 18:43:53 +0200137 { "setAutoSync", &CParameterMgr::setAutoSyncCommmandProcess, 1,
138 "on*|off", "Turn on or off automatic synchronization to hardware while in Tuning Mode" },
139 { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0,
140 "", "Show Auto Sync state" },
141 { "sync", &CParameterMgr::syncCommmandProcess, 0,
142 "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
143
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200144 /// Criteria
Kevin Rocard3949b342013-05-24 18:43:53 +0200145 { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0,
146 "[csv]", "List selection criteria" },
147
Patrick Benavoli68a91282011-08-31 11:23:23 +0200148 /// Domains
Kevin Rocard3949b342013-05-24 18:43:53 +0200149 { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0,
150 "", "List configurable domains" },
151 { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0,
152 "", "Show all domains and configurations, including applicability conditions" },
153 { "createDomain", &CParameterMgr::createDomainCommmandProcess, 1,
154 "<domain>", "Create new configurable domain" },
155 { "deleteDomain", &CParameterMgr::deleteDomainCommmandProcess, 1,
156 "<domain>", "Delete configurable domain" },
157 { "deleteAllDomains", &CParameterMgr::deleteAllDomainsCommmandProcess, 0,
158 "", "Delete all configurable domains" },
159 { "renameDomain", &CParameterMgr::renameDomainCommmandProcess, 2,
160 "<domain> <new name>", "Rename configurable domain" },
161 { "setSequenceAwareness", &CParameterMgr::setSequenceAwarenessCommmandProcess, 1,
162 "<domain> true|false*", "Set configurable domain sequence awareness" },
163 { "getSequenceAwareness", &CParameterMgr::getSequenceAwarenessCommmandProcess, 1,
164 "<domain>", "Get configurable domain sequence awareness" },
165 { "listDomainElements", &CParameterMgr::listDomainElementsCommmandProcess, 1,
166 "<domain>", "List elements associated to configurable domain" },
167 { "addElement", &CParameterMgr::addElementCommmandProcess, 2,
168 "<domain> <elem path>", "Associate element at given path to configurable domain" },
169 { "removeElement", &CParameterMgr::removeElementCommmandProcess, 2,
170 "<domain> <elem path>", "Dissociate element at given path from configurable domain" },
171 { "splitDomain", &CParameterMgr::splitDomainCommmandProcess, 2,
172 "<domain> <elem path>", "Split configurable domain at given associated element path" },
173
Patrick Benavoli68a91282011-08-31 11:23:23 +0200174 /// Configurations
Kevin Rocard3949b342013-05-24 18:43:53 +0200175 { "listConfigurations", &CParameterMgr::listConfigurationsCommmandProcess, 1,
176 "<domain>", "List domain configurations" },
177 { "createConfiguration", &CParameterMgr::createConfigurationCommmandProcess, 2,
178 "<domain> <configuration>", "Create new domain configuration" },
179 { "deleteConfiguration", &CParameterMgr::deleteConfigurationCommmandProcess, 2,
180 "<domain> <configuration>", "Delete domain configuration" },
181 { "renameConfiguration", &CParameterMgr::renameConfigurationCommmandProcess, 3,
182 "<domain> <configuration> <new name>", "Rename domain configuration" },
183 { "saveConfiguration", &CParameterMgr::saveConfigurationCommmandProcess, 2,
184 "<domain> <configuration>", "Save current settings into configuration" },
185 { "restoreConfiguration", &CParameterMgr::restoreConfigurationCommmandProcess, 2,
186 "<domain> <configuration>", "Restore current settings from configuration" },
187 { "setElementSequence", &CParameterMgr::setElementSequenceCommmandProcess, 3,
188 "<domain> <configuration> <elem path list>",
189 "Set element application order for configuration" },
190 { "getElementSequence", &CParameterMgr::getElementSequenceCommmandProcess, 2,
191 "<domain> <configuration>", "Get element application order for configuration" },
192 { "setRule", &CParameterMgr::setRuleCommmandProcess, 3,
193 "<domain> <configuration> <rule>", "Set configuration application rule" },
194 { "clearRule", &CParameterMgr::clearRuleCommmandProcess, 2,
195 "<domain> <configuration>", "Clear configuration application rule" },
196 { "getRule", &CParameterMgr::getRuleCommmandProcess, 2,
197 "<domain> <configuration>", "Get configuration application rule" },
198
Patrick Benavoli68a91282011-08-31 11:23:23 +0200199 /// Elements/Parameters
Kevin Rocard3949b342013-05-24 18:43:53 +0200200 { "listElements", &CParameterMgr::listElementsCommmandProcess, 1,
201 "<elem path>|/", "List elements under element at given path or root" },
202 { "listParameters", &CParameterMgr::listParametersCommmandProcess, 1,
203 "<elem path>|/", "List parameters under element at given path or root" },
204 { "dumpElement", &CParameterMgr::dumpElementCommmandProcess, 1,
205 "<elem path>", "Dump structure and content of element at given path" },
206 { "getElementSize", &CParameterMgr::getElementSizeCommmandProcess, 1,
207 "<elem path>", "Show size of element at given path" },
208 { "showProperties", &CParameterMgr::showPropertiesCommmandProcess, 1,
209 "<elem path>", "Show properties of element at given path" },
210 { "getParameter", &CParameterMgr::getParameterCommmandProcess, 1,
211 "<param path>", "Get value for parameter at given path" },
212 { "setParameter", &CParameterMgr::setParameterCommmandProcess, 2,
213 "<param path> <value>", "Set value for parameter at given path" },
214 { "listBelongingDomains", &CParameterMgr::listBelongingDomainsCommmandProcess, 1,
215 "<elem path>", "List domain(s) element at given path belongs to" },
216 { "listAssociatedDomains", &CParameterMgr::listAssociatedDomainsCommmandProcess, 1,
217 "<elem path>", "List domain(s) element at given path is associated to" },
218 { "getConfigurationParameter", &CParameterMgr::getConfigurationParameterCommmandProcess, 3,
219 "<domain> <configuration> <param path>",
220 "Get value for parameter at given path from configuration" },
221 { "setConfigurationParameter", &CParameterMgr::setConfigurationParameterCommmandProcess, 4,
222 "<domain> <configuration> <param path> <value>",
223 "Set value for parameter at given path to configuration" },
224
Patrick Benavoli68a91282011-08-31 11:23:23 +0200225 /// Browse
Kevin Rocard3949b342013-05-24 18:43:53 +0200226 { "listAssociatedElements", &CParameterMgr::listAssociatedElementsCommmandProcess, 0,
227 "", "List element sub-trees associated to at least one configurable domain" },
228 { "listConflictingElements", &CParameterMgr::listConflictingElementsCommmandProcess, 0,
229 "", "List element sub-trees contained in more than one configurable domain" },
230 { "listRogueElements", &CParameterMgr::listRogueElementsCommmandProcess, 0,
231 "", "List element sub-trees owned by no configurable domain" },
232
Patrick Benavoli68a91282011-08-31 11:23:23 +0200233 /// Settings Import/Export
Kevin Rocard3949b342013-05-24 18:43:53 +0200234 { "exportDomainsXML", &CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess, 1,
235 "<file path> ", "Export domains to XML file" },
236 { "importDomainsXML", &CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess, 1,
237 "<file path>", "Import domains from XML file" },
238 { "exportDomainsWithSettingsXML",
239 &CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess, 1,
240 "<file path> ", "Export domains including settings to XML file" },
241 { "importDomainsWithSettingsXML",
242 &CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess, 1,
243 "<file path>", "Import domains including settings from XML file" },
244 { "exportSettings", &CParameterMgr::exportSettingsCommmandProcess, 1,
245 "<file path>", "Export settings to binary file" },
246 { "importSettings", &CParameterMgr::importSettingsCommmandProcess, 1,
247 "<file path>", "Import settings from binary file" },
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200248 { "getDomainsWithSettingsXML",
249 &CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess, 0,
Kevin Rocard3949b342013-05-24 18:43:53 +0200250 "", "Print domains including settings as XML" },
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200251 { "setDomainsWithSettingsXML",
252 &CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess, 1,
253 "<xml configurable domains>", "Import domains including settings from XML string" },
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200254 /// Structure Export
Kevin Rocard3949b342013-05-24 18:43:53 +0200255 { "getSystemClassXML", &CParameterMgr::getSystemClassXMLCommmandProcess, 0 ,
Kevin Rocardc0211572013-06-18 11:34:53 +0200256 "", "Print parameter structure as XML" },
257 /// Deprecated Commands
258 { "getDomainsXML",
259 &CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess, 0,
260 "", "DEPRECATED COMMAND, please use getDomainsWithSettingsXML" },
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200261
Patrick Benavoli68a91282011-08-31 11:23:23 +0200262};
Kevin Rocard3949b342013-05-24 18:43:53 +0200263
Patrick Benavoli68a91282011-08-31 11:23:23 +0200264// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200265const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200266
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100267CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200268 _bTuningModeIsOn(false),
269 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200270 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200271 _bAutoSyncOn(true),
272 _pMainParameterBlackboard(new CParameterBlackboard),
273 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100274 _strXmlConfigurationFilePath(strConfigurationFilePath),
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100275 _pSubsystemPlugins(NULL),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200276 _uiStructureChecksum(0),
277 _pRemoteProcessorServer(NULL),
278 _uiMaxCommandUsageLength(0),
279 _pLogger(NULL),
280 _uiLogDepth(0)
281{
282 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100283 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
284 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200285
286 // Deal with children
287 addChild(new CParameterFrameworkConfiguration);
288 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100289 addChild(new CSystemClass);
290 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200291
292 // Feed element library
293 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200294
295 _pCommandHandler = new CCommandHandler(this);
296
297 // Add command parsers
298 uint32_t uiRemoteCommandParserItem;
299
300 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
301
302 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
303
304 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
305 pRemoteCommandParserItem->_pfnParser,
306 pRemoteCommandParserItem->_uiMinArgumentCount,
307 pRemoteCommandParserItem->_pcHelp,
308 pRemoteCommandParserItem->_pcDescription);
309 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100310
311 // Configuration file folder
312 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
313
314 assert(uiSlashPos != (uint32_t)-1);
315
316 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
317
318 // Schema absolute folder location
319 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200320}
321
322CParameterMgr::~CParameterMgr()
323{
324 // Children
325 delete _pRemoteProcessorServer;
Frederic Boisnard31242302012-04-26 17:07:34 +0200326 delete _pCommandHandler;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200327 delete _pMainParameterBlackboard;
328 delete _pElementLibrarySet;
329
330 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100331 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200332}
333
334string CParameterMgr::getKind() const
335{
336 return "ParameterMgr";
337}
338
339// Logging
340void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
341{
342 _pLogger = pLogger;
343}
344
345// Logging
Kevin Rocardace81f82012-12-11 16:19:17 +0100346void CParameterMgr::doLog(bool bIsWarning, const string& strLog) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200347{
348 if (_pLogger) {
349
350 // Nest
351 string strIndent;
352
353 // Level
354 uint32_t uiNbIndents = _uiLogDepth;
355
356 while (uiNbIndents--) {
357
358 strIndent += " ";
359 }
360
361 // Log
Kevin Rocardace81f82012-12-11 16:19:17 +0100362 _pLogger->log(bIsWarning, strIndent + strLog);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200363 }
364}
365
366void CParameterMgr::nestLog() const
367{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200368 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200369}
370
371void CParameterMgr::unnestLog() const
372{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200373 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200374}
375
Patrick Benavoli63499d42011-10-24 18:50:03 +0200376// Version
377string CParameterMgr::getVersion() const
378{
379 string strVersion;
380
381 // Major
382 strVersion = toString(guiEditionMajor) + ".";
383 // Minor
384 strVersion += toString(guiEditionMinor) + ".";
385 // Revision
386 strVersion += toString(guiRevision);
387
388 return strVersion;
389}
390
Patrick Benavoli68a91282011-08-31 11:23:23 +0200391bool CParameterMgr::load(string& strError)
392{
393 CAutoLog autoLog(this, "Loading");
394
395 // Load Framework configuration
396 if (!loadFrameworkConfiguration(strError)) {
397
398 return false;
399 }
400
401 // Load subsystems
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100402 if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200403
404 return false;
405 }
406
407 // Load structure
408 if (!loadStructure(strError)) {
409
410 return false;
411 }
412
413 // Load settings
414 if (!loadSettings(strError)) {
415
416 return false;
417 }
418
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200419 // Back synchronization for areas in parameter blackboard not covered by any domain
Kevin Rocardace81f82012-12-11 16:19:17 +0100420 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer();
Patrick Benavoli68a91282011-08-31 11:23:23 +0200421
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200422 // Back-synchronize
Kevin Rocard57096bd2012-11-30 11:24:20 +0100423 {
424 CAutoLog autoLog(this, "Main blackboard back synchronization");
425
Kevin Rocard5d6e05a2013-01-21 15:57:45 +0100426 pBackSynchronizer->sync();
Kevin Rocard57096bd2012-11-30 11:24:20 +0100427
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200428 // Get rid of back synchronizer
429 delete pBackSynchronizer;
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200430 }
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200431
432 // We're done loading the settings and back synchronizing
433 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
434
435 // We need to ensure all domains are valid
436 pConfigurableDomains->validate(_pMainParameterBlackboard);
437
Kevin Rocard7f265822012-12-07 18:51:22 +0100438 // Log selection criterion states
439 {
440 CAutoLog autoLog(this, "Criterion states");
441
442 const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria();
443
444 list<string> lstrSelectionCriteron;
445 selectionCriteria->listSelectionCriteria(lstrSelectionCriteron, true, false);
446
Kevin Rocard36299362013-02-04 14:57:47 +0100447 log_table(false, lstrSelectionCriteron);
Kevin Rocard7f265822012-12-07 18:51:22 +0100448 }
449
Kevin Rocard2fbe6e82013-03-26 17:09:29 +0100450 // Subsystem can not ask for resync as they have not been synced yet
451 getSystemClass()->cleanSubsystemsNeedToResync();
452
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100453 // At initialization, check subsystems that need resync
454 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200455
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200456 // Start remote processor server if appropriate
457 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200458}
459
460bool CParameterMgr::loadFrameworkConfiguration(string& strError)
461{
462 CAutoLog autoLog(this, "Loading framework configuration");
463
Patrick Benavoli68a91282011-08-31 11:23:23 +0200464 // Parse Structure XML file
465 CXmlElementSerializingContext elementSerializingContext(strError);
466
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100467 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200468
469 return false;
470 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100471 // Set class name to system class and configurable domains
472 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
473 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
474
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100475 // Get subsystem plugins elements
476 _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200477
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100478 if (!_pSubsystemPlugins) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200479
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100480 strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element";
Patrick Benavoli68a91282011-08-31 11:23:23 +0200481
482 return false;
483 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200484
Patrick Benavoli68a91282011-08-31 11:23:23 +0200485 // Log tuning availability
Kevin Rocardace81f82012-12-11 16:19:17 +0100486 log_info("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200487
488 return true;
489}
490
491bool CParameterMgr::loadStructure(string& strError)
492{
493 // Retrieve system to load structure to
494 CSystemClass* pSystemClass = getSystemClass();
495
Kevin Rocarde25ee792013-04-22 17:46:28 +0200496 log_info("Loading " + pSystemClass->getName() + " system class structure");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200497
498 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100499 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200500
501 if (!pStructureDescriptionFileLocation) {
502
503 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
504
505 return false;
506 }
507
508 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100509 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200510
511 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100512 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200513
514 // Parse Structure XML file
515 CXmlParameterSerializingContext parameterBuildContext(strError);
516
Kevin Rocard57096bd2012-11-30 11:24:20 +0100517 CAutoLog autolog(pSystemClass, "Importing system structure from file " + strXmlStructureFilePath);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200518
Patrick Benavoli68a91282011-08-31 11:23:23 +0200519 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
520
521 return false;
522 }
523
524 // Initialize offsets
525 pSystemClass->setOffset(0);
526
527 // Initialize main blackboard's size
528 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
529
530 return true;
531}
532
533bool CParameterMgr::loadSettings(string& strError)
534{
535 CAutoLog autoLog(this, "Loading settings");
536
537 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100538 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200539
540 if (!pParameterConfigurationGroup) {
541
542 // No settings to load
543
544 return true;
545 }
546 // Get binary settings file location
547 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
548
549 string strXmlBinarySettingsFilePath;
550
551 if (pBinarySettingsFileLocation) {
552
553 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100554 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200555 }
556
557 // Get configurable domains element
558 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
559
560 if (!pConfigurableDomainsFileLocation) {
561
562 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
563
564 return false;
565 }
566 // Get destination root element
567 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
568
569 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100570 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200571
572 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100573 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200574
575 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
576 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
577
578 // Selection criteria definition for rule creation
579 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
580
Patrick Benavoli63499d42011-10-24 18:50:03 +0200581 // Auto validation of configurations if no binary settings provided
582 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
583
Kevin Rocardace81f82012-12-11 16:19:17 +0100584 log_info("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200585
Patrick Benavoli68a91282011-08-31 11:23:23 +0200586 // Do parse
587 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
588
589 return false;
590 }
591 // We have loaded the whole system structure, compute checksum
592 const CSystemClass* pSystemClass = getConstSystemClass();
593 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
594
595 // Load binary settings if any provided
596 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
597
598 return false;
599 }
600
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200601 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200602}
603
604// XML parsing
605bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
606{
607 // Init serializing context
608 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
609
610 // Get Schema file associated to root element
611 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
612
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200613 CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200614
615 // Start clean
616 pRootElement->clean();
617
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200618 CXmlMemoryDocSink memorySink(pRootElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200619
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200620 if (!memorySink.process(fileDocSource, elementSerializingContext)) {
621 //Cleanup
Patrick Benavoli68a91282011-08-31 11:23:23 +0200622 pRootElement->clean();
623
624 return false;
625 }
626
Patrick Benavoli68a91282011-08-31 11:23:23 +0200627 return true;
628}
629
630// Init
631bool CParameterMgr::init(string& strError)
632{
633 return base::init(strError);
634}
635
636// Selection criteria interface
637CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
638{
639 // Propagate
640 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
641}
642
643CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
644{
645 // Propagate
646 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
647}
648
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200649// Selection criterion retrieval
650CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200651{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200652 // Propagate
653 return getSelectionCriteria()->getSelectionCriterion(strName);
654}
655
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100656// Configuration application
Kevin Rocardace81f82012-12-11 16:19:17 +0100657void CParameterMgr::applyConfigurations()
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200658{
659 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200660
661 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100662 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200663
664 if (!_bTuningModeIsOn) {
665
666 // Apply configuration(s)
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100667 doApplyConfigurations(false);
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +0200668 } else {
669
Kevin Rocardace81f82012-12-11 16:19:17 +0100670 log_warning("Configurations were not applied because the TuningMode is on");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200671 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200672}
673
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200674// Dynamic parameter handling
Patrick Benavoli065264a2011-11-20 15:46:41 +0100675CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200676{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100677 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200678
Patrick Benavoli065264a2011-11-20 15:46:41 +0100679 // Nagivate through system class
680 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
681
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100682 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100683 }
684
685 // Find element
686 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
687
688 if (!pElement) {
689
690 strError = "Path not found";
691
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100692 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100693 }
694
695 // Check found element is a parameter
696 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
697
698 if (!pConfigurableElement->isParameter()) {
699
700 // Element is not parameter
701 strError = "Not a parameter";
702
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100703 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100704 }
705
706 // Convert as parameter and return new handle
707 return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200708}
709
Patrick Benavoli68a91282011-08-31 11:23:23 +0200710/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200711/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200712CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200713{
714 (void)remoteCommand;
715
Patrick Benavoli63499d42011-10-24 18:50:03 +0200716 // Show version
717 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200718
Patrick Benavoli63499d42011-10-24 18:50:03 +0200719 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200720}
721
Patrick Benavoli68a91282011-08-31 11:23:23 +0200722/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200723CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200724{
725 (void)remoteCommand;
726 // System class
727 const CSystemClass* pSystemClass = getSystemClass();
728
Patrick Benavoli68a91282011-08-31 11:23:23 +0200729 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200730 /// General section
731 appendTitle(strResult, "General:");
732 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200733 strResult += "System Class: ";
734 strResult += pSystemClass->getName();
735 strResult += "\n";
736
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200737 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200738 strResult += "Tuning Mode: ";
739 strResult += tuningModeOn() ? "on" : "off";
740 strResult += "\n";
741
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200742 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200743 strResult += "Value Space: ";
744 strResult += valueSpaceIsRaw() ? "raw" : "real";
745 strResult += "\n";
746
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200747 // Output raw format
748 strResult += "Output Raw Format: ";
749 strResult += outputRawFormatIsHex() ? "hex" : "dec";
750 strResult += "\n";
751
752 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200753 strResult += "Auto Sync: ";
754 strResult += autoSyncOn() ? "on" : "off";
755 strResult += "\n";
756
757 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200758 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200759 string strSubsystemList;
760 pSystemClass->listChildrenPaths(strSubsystemList);
761 strResult += strSubsystemList;
762
763 /// Last applied configurations
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200764 appendTitle(strResult, "Last Applied [Pending] Configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200765 string strLastAppliedConfigurations;
766 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
767 strResult += strLastAppliedConfigurations;
768
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200769 /// Criteria states
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200770 appendTitle(strResult, "Selection Criteria:");
Kevin Rocard7f265822012-12-07 18:51:22 +0100771 list<string> lstrSelectionCriteria;
772 getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true);
773 // Concatenate the criterion list as the command result
774 CUtility::concatenate(lstrSelectionCriteria, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200775
Patrick Benavoli63499d42011-10-24 18:50:03 +0200776 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200777}
778
779/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200780CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200781{
782 if (remoteCommand.getArgument(0) == "on") {
783
784 if (setTuningMode(true, strResult)) {
785
Patrick Benavoli63499d42011-10-24 18:50:03 +0200786 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200787 }
788 } else if (remoteCommand.getArgument(0) == "off") {
789
790 if (setTuningMode(false, strResult)) {
791
Patrick Benavoli63499d42011-10-24 18:50:03 +0200792 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200793 }
794 } else {
795 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200796 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200797 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200798 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200799}
800
Patrick Benavoli63499d42011-10-24 18:50:03 +0200801CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200802{
803 (void)remoteCommand;
804
805 strResult = tuningModeOn() ? "on" : "off";
806
Patrick Benavoli63499d42011-10-24 18:50:03 +0200807 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200808}
809
810/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200811CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200812{
813 (void)strResult;
814
815 if (remoteCommand.getArgument(0) == "raw") {
816
817 setValueSpace(true);
818
Patrick Benavoli63499d42011-10-24 18:50:03 +0200819 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200820
821 } else if (remoteCommand.getArgument(0) == "real") {
822
823 setValueSpace(false);
824
Patrick Benavoli63499d42011-10-24 18:50:03 +0200825 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200826
827 } else {
828 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200829 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200830 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200831 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200832}
833
Patrick Benavoli63499d42011-10-24 18:50:03 +0200834CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200835{
836 (void)remoteCommand;
837
838 strResult = valueSpaceIsRaw() ? "raw" : "real";
839
Patrick Benavoli63499d42011-10-24 18:50:03 +0200840 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200841}
842
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200843/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200844CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200845{
846 (void)strResult;
847
848 if (remoteCommand.getArgument(0) == "hex") {
849
850 setOutputRawFormat(true);
851
Patrick Benavoli63499d42011-10-24 18:50:03 +0200852 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200853
854 } else if (remoteCommand.getArgument(0) == "dec") {
855
856 setOutputRawFormat(false);
857
Patrick Benavoli63499d42011-10-24 18:50:03 +0200858 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200859
860 } else {
861 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200862 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200863 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200864 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200865}
866
Patrick Benavoli63499d42011-10-24 18:50:03 +0200867CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200868{
869 (void)remoteCommand;
870
871 strResult = outputRawFormatIsHex() ? "hex" : "dec";
872
Patrick Benavoli63499d42011-10-24 18:50:03 +0200873 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200874}
875
Patrick Benavoli68a91282011-08-31 11:23:23 +0200876/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200877CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200878{
879 if (remoteCommand.getArgument(0) == "on") {
880
881 if (setAutoSync(true, strResult)) {
882
Patrick Benavoli63499d42011-10-24 18:50:03 +0200883 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200884 }
885 } else if (remoteCommand.getArgument(0) == "off") {
886
887 if (setAutoSync(false, strResult)) {
888
Patrick Benavoli63499d42011-10-24 18:50:03 +0200889 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200890 }
891 } else {
892 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200893 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200894 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200895 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200896}
897
Patrick Benavoli63499d42011-10-24 18:50:03 +0200898CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200899{
900 (void)remoteCommand;
901
902 strResult = autoSyncOn() ? "on" : "off";
903
Patrick Benavoli63499d42011-10-24 18:50:03 +0200904 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200905}
906
Patrick Benavoli63499d42011-10-24 18:50:03 +0200907CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200908{
909 (void)remoteCommand;
910
Patrick Benavoli63499d42011-10-24 18:50:03 +0200911 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200912}
913
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200914/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200915CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200916{
917 (void)remoteCommand;
918
Kevin Rocard4eae8272013-04-18 19:12:46 +0200919 bool humanReadable = true;
Kevin Rocard7f265822012-12-07 18:51:22 +0100920
Kevin Rocard4eae8272013-04-18 19:12:46 +0200921 // Look for optional arguments
922 if (remoteCommand.getArgumentCount() >= 1) {
923
924 // If csv is provided, format the criterion list in Commas Separated Value pairs
925 if (remoteCommand.getArgument(0) == "csv") {
926 humanReadable = false;
927 } else {
928 return CCommandHandler::EShowUsage;
929 }
930 }
931
932 list<string> lstrResult;
933 getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
Kevin Rocard7f265822012-12-07 18:51:22 +0100934
935 // Concatenate the criterion list as the command result
936 CUtility::concatenate(lstrResult, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200937
Patrick Benavoli63499d42011-10-24 18:50:03 +0200938 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200939}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200940
941/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200942CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200943{
944 (void)remoteCommand;
945
Patrick Benavoli63499d42011-10-24 18:50:03 +0200946 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200947
Patrick Benavoli63499d42011-10-24 18:50:03 +0200948 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200949}
950
Patrick Benavoli63499d42011-10-24 18:50:03 +0200951CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200952{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200953 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200954}
955
Patrick Benavoli63499d42011-10-24 18:50:03 +0200956CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200957{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200958 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200959}
960
Kevin Rocard170f0a42012-06-18 13:56:05 +0200961CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
962{
963 (void)remoteCommand;
964
965 return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
966}
967
Patrick Benavoli63499d42011-10-24 18:50:03 +0200968CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200969{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200970 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200971}
972
Patrick Benavoli63499d42011-10-24 18:50:03 +0200973CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200974{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200975 // Check tuning mode
976 if (!checkTuningModeOn(strResult)) {
977
978 return CCommandHandler::EFailed;
979 }
980
981 // Set property
982 bool bSequenceAware;
983
984 if (remoteCommand.getArgument(1) == "true") {
985
986 bSequenceAware = true;
987
988 } else if (remoteCommand.getArgument(1) == "false") {
989
990 bSequenceAware = false;
991
992 } else {
993 // Show usage
994 return CCommandHandler::EShowUsage;
995 }
996
997 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200998}
999
Patrick Benavoli63499d42011-10-24 18:50:03 +02001000CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001001{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001002 // Get property
1003 bool bSequenceAware;
1004
1005 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
1006
1007 return CCommandHandler::EFailed;
1008 }
1009
1010 strResult = bSequenceAware ? "true" : "false";
1011
1012 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001013}
1014
Patrick Benavoli63499d42011-10-24 18:50:03 +02001015CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001016{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001017 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001018}
1019
Patrick Benavoli63499d42011-10-24 18:50:03 +02001020CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001021{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001022 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1023}
1024
1025CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1026{
1027 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1028}
1029
1030CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1031{
1032 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001033}
1034
1035/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +02001036CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001037{
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001038 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1039}
1040
1041CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1042{
1043 (void)remoteCommand;
1044
1045 // Dummy error context
1046 string strError;
1047 CErrorContext errorContext(strError);
1048
1049 // Dump
1050 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
1051
1052 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001053}
1054
Patrick Benavoli63499d42011-10-24 18:50:03 +02001055CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001056{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001057 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001058}
1059
Patrick Benavoli63499d42011-10-24 18:50:03 +02001060CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001061{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001062 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001063}
1064
Patrick Benavoli63499d42011-10-24 18:50:03 +02001065CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001066{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001067 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001068}
1069
Patrick Benavoli63499d42011-10-24 18:50:03 +02001070CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001071{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001072 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001073}
1074
Patrick Benavoli63499d42011-10-24 18:50:03 +02001075CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001076{
Kevin Rocardace81f82012-12-11 16:19:17 +01001077 list<string> lstrResult;
1078 if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) {
1079 //Concatenate the error list as the command result
1080 CUtility::concatenate(lstrResult, strResult);
1081
1082 return CCommandHandler::EFailed;
1083 }
1084 return CCommandHandler::EDone;
Patrick Benavoli63499d42011-10-24 18:50:03 +02001085}
1086
1087CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1088{
1089 // Check tuning mode
1090 if (!checkTuningModeOn(strResult)) {
1091
1092 return CCommandHandler::EFailed;
1093 }
1094
1095 // Build configurable element path list
1096 vector<string> astrNewElementSequence;
1097
1098 uint32_t uiArgument;
1099
1100 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1101
1102 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1103 }
1104
1105 // Delegate to configurable domains
1106 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1107}
1108
1109CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1110{
1111 // Delegate to configurable domains
1112 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001113}
1114
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001115CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1116{
1117 // Delegate to configurable domains
1118 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1119}
1120
1121CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1122{
1123 // Delegate to configurable domains
1124 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1125}
1126
1127CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1128{
1129 // Delegate to configurable domains
1130 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1131}
1132
Patrick Benavoli68a91282011-08-31 11:23:23 +02001133/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001134CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001135{
1136 CElementLocator elementLocator(getSystemClass(), false);
1137
1138 CElement* pLocatedElement = NULL;
1139
1140 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1141
Patrick Benavoli63499d42011-10-24 18:50:03 +02001142 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001143 }
1144
1145 strResult = string("\n");
1146
1147 if (!pLocatedElement) {
1148
1149 // List from root folder
1150
1151 // Return system class qualified name
1152 pLocatedElement = getSystemClass();
1153 }
1154
1155 // Return sub-elements
1156 strResult += pLocatedElement->listQualifiedPaths(false);
1157
Patrick Benavoli63499d42011-10-24 18:50:03 +02001158 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001159}
1160
1161/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001162CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001163{
1164 CElementLocator elementLocator(getSystemClass(), false);
1165
1166 CElement* pLocatedElement = NULL;
1167
1168 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1169
Patrick Benavoli63499d42011-10-24 18:50:03 +02001170 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001171 }
1172
1173 strResult = string("\n");
1174
1175 if (!pLocatedElement) {
1176
1177 // List from root folder
1178
1179 // Return system class qualified name
1180 pLocatedElement = getSystemClass();
1181 }
1182
1183 // Return sub-elements
1184 strResult += pLocatedElement->listQualifiedPaths(true);
1185
Patrick Benavoli63499d42011-10-24 18:50:03 +02001186 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001187}
1188
Patrick Benavoli63499d42011-10-24 18:50:03 +02001189CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001190{
1191 CElementLocator elementLocator(getSystemClass());
1192
1193 CElement* pLocatedElement = NULL;
1194
1195 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1196
Patrick Benavoli63499d42011-10-24 18:50:03 +02001197 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001198 }
1199
1200 string strError;
1201
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001202 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001203
1204 // Dump elements
1205 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1206
Patrick Benavoli63499d42011-10-24 18:50:03 +02001207 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001208}
1209
Patrick Benavoli63499d42011-10-24 18:50:03 +02001210CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001211{
1212 CElementLocator elementLocator(getSystemClass());
1213
1214 CElement* pLocatedElement = NULL;
1215
1216 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1217
Patrick Benavoli63499d42011-10-24 18:50:03 +02001218 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001219 }
1220
1221 // Converted to actual sizable element
1222 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1223
1224 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001225 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001226
Patrick Benavoli63499d42011-10-24 18:50:03 +02001227 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001228}
1229
Patrick Benavoli63499d42011-10-24 18:50:03 +02001230CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001231{
1232 CElementLocator elementLocator(getSystemClass());
1233
1234 CElement* pLocatedElement = NULL;
1235
1236 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1237
Patrick Benavoli63499d42011-10-24 18:50:03 +02001238 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001239 }
1240
1241 // Convert element
1242 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1243
1244 // Return element properties
1245 pConfigurableElement->showProperties(strResult);
1246
Patrick Benavoli63499d42011-10-24 18:50:03 +02001247 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001248}
1249
Patrick Benavoli63499d42011-10-24 18:50:03 +02001250CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001251{
1252 string strValue;
1253
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001254 if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001255
Patrick Benavoli63499d42011-10-24 18:50:03 +02001256 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001257 }
1258 // Succeeded
1259 strResult = strValue;
1260
Patrick Benavoli63499d42011-10-24 18:50:03 +02001261 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001262}
1263
Patrick Benavoli63499d42011-10-24 18:50:03 +02001264CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001265{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001266 // Check tuning mode
1267 if (!checkTuningModeOn(strResult)) {
1268
1269 return CCommandHandler::EFailed;
1270 }
1271 // Get value to set
1272 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1273
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001274 return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001275}
1276
Patrick Benavoli63499d42011-10-24 18:50:03 +02001277CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001278{
1279 CElementLocator elementLocator(getSystemClass());
1280
1281 CElement* pLocatedElement = NULL;
1282
1283 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1284
Patrick Benavoli63499d42011-10-24 18:50:03 +02001285 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001286 }
1287
1288 // Convert element
1289 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1290
1291 // Return element belonging domains
1292 pConfigurableElement->listBelongingDomains(strResult);
1293
Patrick Benavoli63499d42011-10-24 18:50:03 +02001294 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001295}
1296
Patrick Benavoli63499d42011-10-24 18:50:03 +02001297CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001298{
1299 CElementLocator elementLocator(getSystemClass());
1300
1301 CElement* pLocatedElement = NULL;
1302
1303 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1304
Patrick Benavoli63499d42011-10-24 18:50:03 +02001305 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001306 }
1307
1308 // Convert element
1309 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1310
1311 // Return element belonging domains
1312 pConfigurableElement->listAssociatedDomains(strResult);
1313
Patrick Benavoli63499d42011-10-24 18:50:03 +02001314 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001315}
1316
Patrick Benavoli63499d42011-10-24 18:50:03 +02001317CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001318{
1319 (void)remoteCommand;
1320
1321 getConfigurableDomains()->listAssociatedElements(strResult);
1322
Patrick Benavoli63499d42011-10-24 18:50:03 +02001323 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001324}
1325
Patrick Benavoli63499d42011-10-24 18:50:03 +02001326CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001327{
1328 (void)remoteCommand;
1329
1330 getConfigurableDomains()->listConflictingElements(strResult);
1331
Patrick Benavoli63499d42011-10-24 18:50:03 +02001332 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001333}
1334
Patrick Benavoli63499d42011-10-24 18:50:03 +02001335CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001336{
1337 (void)remoteCommand;
1338
1339 getSystemClass()->listRogueElements(strResult);
1340
Patrick Benavoli63499d42011-10-24 18:50:03 +02001341 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001342}
1343
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001344CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1345{
1346 string strOutputValue;
1347 string strError;
1348
1349 if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) {
1350
1351 strResult = strError;
1352 return CCommandHandler::EFailed;
1353 }
1354 // Succeeded
1355 strResult = strOutputValue;
1356
1357 return CCommandHandler::ESucceeded;
1358}
1359
1360CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1361{
1362 // Get value to set
1363 string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3);
1364
1365 bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0),
1366 remoteCommand.getArgument(1),
1367 remoteCommand.getArgument(2),
1368 strValue, true, strResult);
1369
1370 return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed;
1371}
1372
Patrick Benavoli68a91282011-08-31 11:23:23 +02001373/// Settings Import/Export
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001374CParameterMgr::CCommandHandler::CommandStatus
1375 CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(
1376 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001377{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001378 string strFileName = remoteCommand.getArgument(0);
1379 return exportDomainsXml(strFileName, false, true, strResult) ?
1380 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001381}
1382
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001383CParameterMgr::CCommandHandler::CommandStatus
1384 CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(
1385 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001386{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001387 return importDomainsXml(remoteCommand.getArgument(0), false, true, strResult) ?
1388 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001389}
1390
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001391CParameterMgr::CCommandHandler::CommandStatus
1392 CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(
1393 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001394{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001395 string strFileName = remoteCommand.getArgument(0);
1396 return exportDomainsXml(strFileName, true, true, strResult) ?
1397 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001398}
1399
Patrick Benavoli63499d42011-10-24 18:50:03 +02001400CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001401{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001402 return importDomainsXml(remoteCommand.getArgument(0), true, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001403}
1404
Patrick Benavoli63499d42011-10-24 18:50:03 +02001405CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001406{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001407 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001408}
1409
Patrick Benavoli63499d42011-10-24 18:50:03 +02001410CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001411{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001412 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001413}
1414
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001415CParameterMgr::CCommandHandler::CommandStatus
1416 CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess(
1417 const IRemoteCommand& remoteCommand, string& strResult)
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001418{
1419 (void)remoteCommand;
1420
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001421 if (!exportDomainsXml(strResult, true, false, strResult)) {
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001422
1423 return CCommandHandler::EFailed;
1424 }
1425 // Succeeded
1426 return CCommandHandler::ESucceeded;
1427}
1428
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001429CParameterMgr::CCommandHandler::CommandStatus
1430 CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess(
1431 const IRemoteCommand& remoteCommand, string& strResult)
1432{
1433 return importDomainsXml(remoteCommand.getArgument(0), true, false, strResult) ?
1434 CCommandHandler::EDone : CCommandHandler::EFailed;
1435}
1436
1437CParameterMgr::CCommandHandler::CommandStatus
1438 CParameterMgr::getSystemClassXMLCommmandProcess(
1439 const IRemoteCommand& remoteCommand, string& strResult)
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001440{
1441 (void)remoteCommand;
1442
1443 if (!getSystemClassXMLString(strResult)) {
1444
1445 return CCommandHandler::EFailed;
1446 }
1447 // Succeeded
1448 return CCommandHandler::ESucceeded;
1449}
1450
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001451// User set/get parameters in main BlackBoard
1452bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError)
1453{
1454 // Define context
1455 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
1456
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001457 // Activate the auto synchronization with the hardware
1458 if (bSet) {
1459
1460 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1461 }
1462
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001463 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1464}
1465
1466// User set/get parameters in specific Configuration BlackBoard
1467bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError)
1468{
1469 CElementLocator elementLocator(getSystemClass());
1470
1471 CElement* pLocatedElement = NULL;
1472
1473 if (!elementLocator.locate(strPath, &pLocatedElement, strError)) {
1474
1475 return false;
1476 }
1477
1478 // Convert element
1479 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1480
1481 // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard
1482 uint32_t uiBaseOffset;
1483 bool bIsLastApplied;
1484
1485 CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
1486
1487 if (!pConfigurationBlackboard) {
1488
1489 return false;
1490 }
1491
1492 log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset);
1493
1494 /// Update the Configuration Blackboard
1495
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001496 // Define Configuration context using Base Offset and keep Auto Sync off to prevent access to HW
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001497 CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
1498
1499 // Access Value in the Configuration Blackboard
1500 if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) {
1501
1502 return false;
1503 }
1504
1505 /// If the Configuration is the last one applied, update the Main Blackboard as well
1506
1507 if (bIsLastApplied) {
1508
1509 // Define Main context
1510 parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
1511
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001512 // Activate the auto synchronization with the hardware
1513 if (bSet) {
1514
1515 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1516 }
1517
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001518 // Access Value in the Main Blackboard
1519 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1520 }
1521
1522 return true;
1523}
1524
Patrick Benavoli68a91282011-08-31 11:23:23 +02001525// User set/get parameters
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001526bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001527{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001528 // Lock state
1529 CAutoLock autoLock(&_blackboardMutex);
1530
1531 CPathNavigator pathNavigator(strPath);
1532
1533 // Nagivate through system class
1534 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001535
1536 return false;
1537 }
1538
Patrick Benavoli065264a2011-11-20 15:46:41 +01001539 // Do the get
1540 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001541}
1542
1543// Tuning mode
1544bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1545{
1546 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001547 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001548
1549 strError = "Tuning prohibited";
1550
1551 return false;
1552 }
1553 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001554 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001555
1556 // Warn domains about exiting tuning mode
1557 if (!bOn && _bTuningModeIsOn) {
1558
1559 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001560 // Force-apply configurations
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01001561 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001562
Patrick Benavoli68a91282011-08-31 11:23:23 +02001563 // Turn auto sync back on
1564 _bAutoSyncOn = true;
1565 }
1566
1567 // Store
1568 _bTuningModeIsOn = bOn;
1569
Patrick Benavoli68a91282011-08-31 11:23:23 +02001570 return true;
1571}
1572
1573bool CParameterMgr::tuningModeOn() const
1574{
1575 return _bTuningModeIsOn;
1576}
1577
1578// Current value space for user set/get value interpretation
1579void CParameterMgr::setValueSpace(bool bIsRaw)
1580{
1581 _bValueSpaceIsRaw = bIsRaw;
1582}
1583
1584bool CParameterMgr::valueSpaceIsRaw()
1585{
1586 return _bValueSpaceIsRaw;
1587}
1588
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001589// Current Output Raw Format for user get value interpretation
1590void CParameterMgr::setOutputRawFormat(bool bIsHex)
1591{
1592 _bOutputRawFormatIsHex = bIsHex;
1593}
1594
1595bool CParameterMgr::outputRawFormatIsHex()
1596{
1597 return _bOutputRawFormatIsHex;
1598}
1599
Patrick Benavoli68a91282011-08-31 11:23:23 +02001600/// Sync
1601// Automatic hardware synchronization control (during tuning session)
1602bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1603{
1604 // Check tuning mode
1605 if (!checkTuningModeOn(strError)) {
1606
1607 return false;
1608 }
1609 // Warn domains about turning auto sync back on
1610 if (bAutoSyncOn && !_bAutoSyncOn) {
1611
Patrick Benavoli592ae562011-09-05 16:53:58 +02001612 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1613 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001614
1615 return false;
1616 }
1617 }
1618
1619 // Set Auto sync
1620 _bAutoSyncOn = bAutoSyncOn;
1621
1622 return true;
1623}
1624
1625bool CParameterMgr::autoSyncOn() const
1626{
1627 return _bAutoSyncOn;
1628}
1629
1630// Manual hardware synchronization control (during tuning session)
1631bool CParameterMgr::sync(string& strError)
1632{
1633 // Check tuning mode
1634 if (!checkTuningModeOn(strError)) {
1635
1636 return false;
1637 }
1638 // Warn domains about turning auto sync back on
1639 if (_bAutoSyncOn) {
1640
1641 strError = "Feature unavailable when Auto Sync is on";
1642
1643 return false;
1644 }
1645
1646 // Get syncer set
1647 CSyncerSet syncerSet;
1648 // ... from system class
1649 getConstSystemClass()->fillSyncerSet(syncerSet);
Kevin Rocardace81f82012-12-11 16:19:17 +01001650
Patrick Benavoli68a91282011-08-31 11:23:23 +02001651 // Sync
Kevin Rocardace81f82012-12-11 16:19:17 +01001652 list<string> lstrError;
1653 if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){
1654
1655 CUtility::concatenate(lstrError, strError);
1656 return false;
1657 };
1658
1659 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001660}
1661
1662// Content dump
1663void CParameterMgr::logStructureContent(string& strContent) const
1664{
1665 string strError;
1666
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001667 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001668
1669 dumpContent(strContent, parameterAccessContext);
1670}
1671
1672// Configuration/Domains handling
1673bool CParameterMgr::createDomain(const string& strName, string& strError)
1674{
1675 // Check tuning mode
1676 if (!checkTuningModeOn(strError)) {
1677
1678 return false;
1679 }
1680
1681 // Delegate to configurable domains
1682 return getConfigurableDomains()->createDomain(strName, strError);
1683}
1684
1685bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1686{
1687 // Check tuning mode
1688 if (!checkTuningModeOn(strError)) {
1689
1690 return false;
1691 }
1692
1693 // Delegate to configurable domains
1694 return getConfigurableDomains()->deleteDomain(strName, strError);
1695}
1696
Kevin Rocard170f0a42012-06-18 13:56:05 +02001697bool CParameterMgr::deleteAllDomains(string& strError)
1698{
1699 // Check tuning mode
1700 if (!checkTuningModeOn(strError)) {
1701
1702 return false;
1703 }
1704
1705 // Delegate to configurable domains
1706 getConfigurableDomains()->deleteAllDomains();
1707
1708 return true;
1709}
1710
Patrick Benavoli68a91282011-08-31 11:23:23 +02001711bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1712{
1713 // Check tuning mode
1714 if (!checkTuningModeOn(strError)) {
1715
1716 return false;
1717 }
1718
1719 // Delegate to configurable domains
1720 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1721}
1722
1723bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1724{
1725 // Check tuning mode
1726 if (!checkTuningModeOn(strError)) {
1727
1728 return false;
1729 }
1730
1731 // Delegate to configurable domains
1732 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1733}
1734
Kevin Rocardace81f82012-12-11 16:19:17 +01001735bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& lstrError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001736{
Kevin Rocardace81f82012-12-11 16:19:17 +01001737 string strError;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001738 // Check tuning mode
1739 if (!checkTuningModeOn(strError)) {
1740
Kevin Rocardace81f82012-12-11 16:19:17 +01001741 lstrError.push_back(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001742 return false;
1743 }
1744
1745 // Delegate to configurable domains
Kevin Rocardace81f82012-12-11 16:19:17 +01001746 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001747}
1748
1749bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1750{
1751 // Check tuning mode
1752 if (!checkTuningModeOn(strError)) {
1753
1754 return false;
1755 }
1756
1757 // Delegate to configurable domains
1758 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1759}
1760
1761// Configurable element - domain association
1762bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1763{
1764 // Check tuning mode
1765 if (!checkTuningModeOn(strError)) {
1766
1767 return false;
1768 }
1769
1770 CElementLocator elementLocator(getSystemClass());
1771
1772 CElement* pLocatedElement = NULL;
1773
1774 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1775
1776 return false;
1777 }
1778
1779 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001780 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001781
1782 // Delegate
1783 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1784}
1785
1786bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1787{
1788 // Check tuning mode
1789 if (!checkTuningModeOn(strError)) {
1790
1791 return false;
1792 }
1793
1794 CElementLocator elementLocator(getSystemClass());
1795
1796 CElement* pLocatedElement = NULL;
1797
1798 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1799
Patrick Benavoli63499d42011-10-24 18:50:03 +02001800 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001801 }
1802
1803 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001804 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001805
1806 // Delegate
1807 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1808}
1809
1810bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1811{
1812 // Check tuning mode
1813 if (!checkTuningModeOn(strError)) {
1814
1815 return false;
1816 }
1817
1818 CElementLocator elementLocator(getSystemClass());
1819
1820 CElement* pLocatedElement = NULL;
1821
1822 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1823
Patrick Benavoli63499d42011-10-24 18:50:03 +02001824 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001825 }
1826
1827 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001828 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001829
1830 // Delegate
1831 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1832}
1833
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001834bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSettings,
1835 bool bFromFile, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001836{
1837 // Check tuning mode
1838 if (!checkTuningModeOn(strError)) {
1839
1840 return false;
1841 }
1842
1843 // check path is absolute
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001844 if (bFromFile && strXmlSource[0] != '/') {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001845
1846 strError = "Please provide absolute path";
1847
1848 return false;
1849 }
1850 // Root element
1851 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1852
1853 // Context
1854 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1855
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001856 // Selection criteria definition for rule creation
1857 xmlDomainSerializingContext.setSelectionCriteriaDefinition(
1858 getConstSelectionCriteria()->getSelectionCriteriaDefinition());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001859
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001860 // Init serializing context
1861 xmlDomainSerializingContext.set(
1862 _pElementLibrarySet->getElementLibrary(EParameterConfigurationLibrary),
1863 "", _strSchemaFolderLocation);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001864
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001865 // Get Schema file associated to root element
1866 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" +
1867 pConfigurableDomains->getKind() + ".xsd";
1868
1869 // Xml Source
1870 CXmlDocSource* pSource;
1871
1872 if (bFromFile) {
1873
1874 // when importing from a file strXmlSource is the file name
1875 pSource = new CXmlFileDocSource(strXmlSource, strXmlSchemaFilePath,
1876 pConfigurableDomains->getKind(),
1877 pConfigurableDomains->getName(), "SystemClassName");
1878
1879 } else {
1880
1881 // when importing from an xml string, strXmlSource contains the string
1882 pSource = new CXmlStringDocSource(strXmlSource, strXmlSchemaFilePath,
1883 pConfigurableDomains->getKind(),
1884 pConfigurableDomains->getName(), "SystemClassName");
1885
1886 }
1887 // Start clean
1888 pConfigurableDomains->clean();
1889
1890 // Use a doc sink that instantiate Configurable Domains from the given doc source
1891 CXmlMemoryDocSink memorySink(pConfigurableDomains);
1892
1893 bool bProcessSuccess = memorySink.process(*pSource, xmlDomainSerializingContext);
1894
1895 if (!bProcessSuccess) {
1896
1897 //Cleanup
1898 pConfigurableDomains->clean();
1899
1900 } else {
1901
1902 // Validate domains after XML import
1903 pConfigurableDomains->validate(_pMainParameterBlackboard);
1904
Patrick Benavoli68a91282011-08-31 11:23:23 +02001905 }
1906
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001907 delete pSource;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001908
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001909 return bProcessSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001910}
1911
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001912bool CParameterMgr::exportDomainsXml(string& strXmlDest, bool bWithSettings, bool bToFile,
1913 string& strError) const
Patrick Benavoli68a91282011-08-31 11:23:23 +02001914{
1915 // check path is absolute
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001916 if (bToFile && strXmlDest[0] != '/') {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001917
1918 strError = "Please provide absolute path";
1919
1920 return false;
1921 }
1922
1923 // Root element
1924 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1925
1926 // Get Schema file associated to root element
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001927 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" +
1928 pConfigurableDomains->getKind() + ".xsd";
Patrick Benavoli68a91282011-08-31 11:23:23 +02001929
1930 // Context
1931 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1932
1933 // Value space
1934 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1935
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001936 // Output raw format
1937 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1938
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001939 // Use a doc source by loading data from instantiated Configurable Domains
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001940 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(),
1941 strXmlSchemaFilePath, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001942
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001943 // Xml Sink
1944 CXmlDocSink* pSink;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001945
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001946 if (bToFile) {
1947
1948 // Use a doc sink to write the doc data in a file
1949 pSink = new CXmlFileDocSink(strXmlDest);
1950
1951 } else {
1952
1953 // Use a doc sink to write the doc data in a string
1954 pSink = new CXmlStringDocSink(strXmlDest);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001955 }
1956
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001957 bool bProcessSuccess = pSink->process(memorySource, xmlDomainSerializingContext);
1958
1959 delete pSink;
1960 return bProcessSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001961}
1962
1963// Binary Import/Export
1964bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1965{
1966 // Check tuning mode
1967 if (!checkTuningModeOn(strError)) {
1968
1969 return false;
1970 }
1971 // check path is absolute
1972 if (strFileName[0] != '/') {
1973
1974 strError = "Please provide absolute path";
1975
1976 return false;
1977 }
1978 // Root element
1979 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1980
1981 // Serialize in
1982 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1983}
1984
1985bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1986{
1987 // check path is absolute
1988 if (strFileName[0] != '/') {
1989
1990 strError = "Please provide absolute path";
1991
1992 return false;
1993 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001994
Patrick Benavoli68a91282011-08-31 11:23:23 +02001995 // Root element
1996 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1997
1998 // Serialize out
1999 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
2000}
2001
2002// For tuning, check we're in tuning mode
2003bool CParameterMgr::checkTuningModeOn(string& strError) const
2004{
2005 // Tuning Mode on?
2006 if (!_bTuningModeIsOn) {
2007
2008 strError = "Tuning Mode must be on";
2009
2010 return false;
2011 }
2012 return true;
2013}
2014
Patrick Benavoli065264a2011-11-20 15:46:41 +01002015// Tuning mutex dynamic parameter handling
2016pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002017{
Patrick Benavoli065264a2011-11-20 15:46:41 +01002018 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002019}
2020
Patrick Benavoli065264a2011-11-20 15:46:41 +01002021// Blackboard reference (dynamic parameter handling)
2022CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002023{
Patrick Benavoli065264a2011-11-20 15:46:41 +01002024 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002025}
2026
Patrick Benavoli68a91282011-08-31 11:23:23 +02002027// Dynamic creation library feeding
2028void CParameterMgr::feedElementLibraries()
2029{
2030 // Global Configuration handling
2031 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
2032
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002033 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +01002034 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSubsystemPlugins>("SubsystemPlugins"));
2035 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CPluginLocation>("Location"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002036 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
2037 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
2038 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
2039 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02002040
2041 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
2042
2043 // Parameter creation
2044 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
2045
2046 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002047 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
2048 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
2049 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
2050 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02002051 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002052 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
2053 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
2054 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoliee65e6d2011-11-20 18:52:24 +01002055 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02002056 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli68808c62012-02-02 17:12:41 +01002057 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002058 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
2059 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02002060
2061 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
2062
2063 // Parameter Configuration Domains creation
2064 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
2065
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002066 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
2067 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
2068 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
2069 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02002070
2071 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
2072}
2073
2074// Remote Processor Server connection handling
2075bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
2076{
2077 CAutoLog autoLog(this, "Handling remote processing interface");
2078
2079 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002080 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02002081
Kevin Rocardace81f82012-12-11 16:19:17 +01002082 log_info("Loading remote processor library");
Patrick Benavoli68a91282011-08-31 11:23:23 +02002083
2084 // Load library
2085 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
2086
2087 if (!lib_handle) {
2088
2089 // Return error
2090 const char* pcError = dlerror();
2091
2092 if (pcError) {
2093
2094 strError = pcError;
2095 } else {
2096
2097 strError = "Unable to load libremote-processor.so library";
2098 }
2099
2100 return false;
2101 }
2102
2103 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
2104
2105 if (!pfnCreateRemoteProcessorServer) {
2106
2107 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
2108
2109 return false;
2110 }
2111
2112 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002113 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002114
Kevin Rocardace81f82012-12-11 16:19:17 +01002115 log_info("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002116 // Start
2117 if (!_pRemoteProcessorServer->start()) {
2118
2119 strError = "Unable to start remote processor server";
2120
2121 return false;
2122 }
2123 }
2124
2125 return true;
2126}
2127
2128// Back synchronization
Kevin Rocardace81f82012-12-11 16:19:17 +01002129CBackSynchronizer* CParameterMgr::createBackSynchronizer() const
Patrick Benavoli68a91282011-08-31 11:23:23 +02002130{
2131#ifdef SIMULATION
2132 // In simulation, back synchronization of the blackboard won't probably work
2133 // We need to ensure though the blackboard is initialized with valid data
Kevin Rocardace81f82012-12-11 16:19:17 +01002134 return new CSimulatedBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002135#else
2136 // Real back synchronizer from subsystems
Kevin Rocardace81f82012-12-11 16:19:17 +01002137 return new CHardwareBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002138#endif
2139}
2140
2141// Children typwise access
2142CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
2143{
2144 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
2145}
2146
2147const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
2148{
2149 return getFrameworkConfiguration();
2150}
2151
2152CSelectionCriteria* CParameterMgr::getSelectionCriteria()
2153{
2154 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
2155}
2156
2157const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
2158{
2159 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
2160}
2161
2162CSystemClass* CParameterMgr::getSystemClass()
2163{
2164 return static_cast<CSystemClass*>(getChild(ESystemClass));
2165}
2166
2167const CSystemClass* CParameterMgr::getConstSystemClass() const
2168{
2169 return static_cast<const CSystemClass*>(getChild(ESystemClass));
2170}
2171
2172// Configurable Domains
2173CConfigurableDomains* CParameterMgr::getConfigurableDomains()
2174{
2175 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
2176}
2177
2178const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
2179{
2180 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2181}
2182
2183const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
2184{
2185 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2186}
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002187
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002188// Apply configurations
2189void CParameterMgr::doApplyConfigurations(bool bForce)
2190{
2191 CSyncerSet syncerSet;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002192
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002193 // Check subsystems that need resync
2194 getSystemClass()->checkForSubsystemsToResync(syncerSet);
2195
2196 // Ensure application of currently selected configurations
2197 getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce);
2198
2199 // Reset the modified status of the current criteria to indicate that a new configuration has been applied
2200 getSelectionCriteria()->resetModifiedStatus();
2201}
2202
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002203bool CParameterMgr::getSystemClassXMLString(string& strResult)
2204{
2205 // Root element
2206 const CSystemClass* pSystemClass = getSystemClass();
2207
2208 string strError;
2209
2210 CXmlSerializingContext xmlSerializingContext(strError);
2211
2212 // Use a doc source by loading data from instantiated Configurable Domains
2213 CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind());
2214
2215 // Use a doc sink that write the doc data in a string
2216 CXmlStringDocSink stringSink(strResult);
2217
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002218 bool bProcessSuccess = stringSink.process(memorySource, xmlSerializingContext);
2219
2220 if (!bProcessSuccess) {
2221
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002222 strResult = strError;
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002223
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002224 }
2225
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002226 return bProcessSuccess;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002227}