blob: 0bef3df1f7e782832588b8ff545e76e478364910 [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 ,
256 "", "Print parameter structure as XML" }
Georges-Henri Baroncec86c12012-09-04 17:30:28 +0200257
Patrick Benavoli68a91282011-08-31 11:23:23 +0200258};
Kevin Rocard3949b342013-05-24 18:43:53 +0200259
Patrick Benavoli68a91282011-08-31 11:23:23 +0200260// Remote command parsers array Size
Patrick Benavoli592ae562011-09-05 16:53:58 +0200261const uint32_t CParameterMgr::guiNbRemoteCommandParserItems = sizeof(gastRemoteCommandParserItems) / sizeof(gastRemoteCommandParserItems[0]);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200262
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100263CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) :
Patrick Benavoli68a91282011-08-31 11:23:23 +0200264 _bTuningModeIsOn(false),
265 _bValueSpaceIsRaw(false),
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200266 _bOutputRawFormatIsHex(false),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200267 _bAutoSyncOn(true),
268 _pMainParameterBlackboard(new CParameterBlackboard),
269 _pElementLibrarySet(new CElementLibrarySet),
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100270 _strXmlConfigurationFilePath(strConfigurationFilePath),
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100271 _pSubsystemPlugins(NULL),
Patrick Benavoli68a91282011-08-31 11:23:23 +0200272 _uiStructureChecksum(0),
273 _pRemoteProcessorServer(NULL),
274 _uiMaxCommandUsageLength(0),
275 _pLogger(NULL),
276 _uiLogDepth(0)
277{
278 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100279 bzero(&_blackboardMutex, sizeof(_blackboardMutex));
280 pthread_mutex_init(&_blackboardMutex, NULL);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200281
282 // Deal with children
283 addChild(new CParameterFrameworkConfiguration);
284 addChild(new CSelectionCriteria);
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100285 addChild(new CSystemClass);
286 addChild(new CConfigurableDomains);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200287
288 // Feed element library
289 feedElementLibraries();
Patrick Benavoli63499d42011-10-24 18:50:03 +0200290
291 _pCommandHandler = new CCommandHandler(this);
292
293 // Add command parsers
294 uint32_t uiRemoteCommandParserItem;
295
296 for (uiRemoteCommandParserItem = 0; uiRemoteCommandParserItem < guiNbRemoteCommandParserItems; uiRemoteCommandParserItem++) {
297
298 const SRemoteCommandParserItem* pRemoteCommandParserItem = &gastRemoteCommandParserItems[uiRemoteCommandParserItem];
299
300 _pCommandHandler->addCommandParser(pRemoteCommandParserItem->_pcCommandName,
301 pRemoteCommandParserItem->_pfnParser,
302 pRemoteCommandParserItem->_uiMinArgumentCount,
303 pRemoteCommandParserItem->_pcHelp,
304 pRemoteCommandParserItem->_pcDescription);
305 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100306
307 // Configuration file folder
308 uint32_t uiSlashPos = _strXmlConfigurationFilePath.rfind('/', -1);
309
310 assert(uiSlashPos != (uint32_t)-1);
311
312 _strXmlConfigurationFolderPath = _strXmlConfigurationFilePath.substr(0, uiSlashPos);
313
314 // Schema absolute folder location
315 _strSchemaFolderLocation = _strXmlConfigurationFolderPath + "/" + gacSystemSchemasSubFolder;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200316}
317
318CParameterMgr::~CParameterMgr()
319{
320 // Children
321 delete _pRemoteProcessorServer;
Frederic Boisnard31242302012-04-26 17:07:34 +0200322 delete _pCommandHandler;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200323 delete _pMainParameterBlackboard;
324 delete _pElementLibrarySet;
325
326 // Tuning Mode Mutex
Patrick Benavoli065264a2011-11-20 15:46:41 +0100327 pthread_mutex_destroy(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200328}
329
330string CParameterMgr::getKind() const
331{
332 return "ParameterMgr";
333}
334
335// Logging
336void CParameterMgr::setLogger(CParameterMgr::ILogger* pLogger)
337{
338 _pLogger = pLogger;
339}
340
341// Logging
Kevin Rocardace81f82012-12-11 16:19:17 +0100342void CParameterMgr::doLog(bool bIsWarning, const string& strLog) const
Patrick Benavoli68a91282011-08-31 11:23:23 +0200343{
344 if (_pLogger) {
345
346 // Nest
347 string strIndent;
348
349 // Level
350 uint32_t uiNbIndents = _uiLogDepth;
351
352 while (uiNbIndents--) {
353
354 strIndent += " ";
355 }
356
357 // Log
Kevin Rocardace81f82012-12-11 16:19:17 +0100358 _pLogger->log(bIsWarning, strIndent + strLog);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200359 }
360}
361
362void CParameterMgr::nestLog() const
363{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200364 _uiLogDepth++;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200365}
366
367void CParameterMgr::unnestLog() const
368{
Patrick Benavoli592ae562011-09-05 16:53:58 +0200369 _uiLogDepth--;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200370}
371
Patrick Benavoli63499d42011-10-24 18:50:03 +0200372// Version
373string CParameterMgr::getVersion() const
374{
375 string strVersion;
376
377 // Major
378 strVersion = toString(guiEditionMajor) + ".";
379 // Minor
380 strVersion += toString(guiEditionMinor) + ".";
381 // Revision
382 strVersion += toString(guiRevision);
383
384 return strVersion;
385}
386
Patrick Benavoli68a91282011-08-31 11:23:23 +0200387bool CParameterMgr::load(string& strError)
388{
389 CAutoLog autoLog(this, "Loading");
390
391 // Load Framework configuration
392 if (!loadFrameworkConfiguration(strError)) {
393
394 return false;
395 }
396
397 // Load subsystems
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100398 if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200399
400 return false;
401 }
402
403 // Load structure
404 if (!loadStructure(strError)) {
405
406 return false;
407 }
408
409 // Load settings
410 if (!loadSettings(strError)) {
411
412 return false;
413 }
414
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200415 // Back synchronization for areas in parameter blackboard not covered by any domain
Kevin Rocardace81f82012-12-11 16:19:17 +0100416 CBackSynchronizer* pBackSynchronizer = createBackSynchronizer();
Patrick Benavoli68a91282011-08-31 11:23:23 +0200417
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200418 // Back-synchronize
Kevin Rocard57096bd2012-11-30 11:24:20 +0100419 {
420 CAutoLog autoLog(this, "Main blackboard back synchronization");
421
Kevin Rocard5d6e05a2013-01-21 15:57:45 +0100422 pBackSynchronizer->sync();
Kevin Rocard57096bd2012-11-30 11:24:20 +0100423
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200424 // Get rid of back synchronizer
425 delete pBackSynchronizer;
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200426 }
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200427
428 // We're done loading the settings and back synchronizing
429 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
430
431 // We need to ensure all domains are valid
432 pConfigurableDomains->validate(_pMainParameterBlackboard);
433
Kevin Rocard7f265822012-12-07 18:51:22 +0100434 // Log selection criterion states
435 {
436 CAutoLog autoLog(this, "Criterion states");
437
438 const CSelectionCriteria* selectionCriteria = getConstSelectionCriteria();
439
440 list<string> lstrSelectionCriteron;
441 selectionCriteria->listSelectionCriteria(lstrSelectionCriteron, true, false);
442
Kevin Rocard36299362013-02-04 14:57:47 +0100443 log_table(false, lstrSelectionCriteron);
Kevin Rocard7f265822012-12-07 18:51:22 +0100444 }
445
Kevin Rocard2fbe6e82013-03-26 17:09:29 +0100446 // Subsystem can not ask for resync as they have not been synced yet
447 getSystemClass()->cleanSubsystemsNeedToResync();
448
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100449 // At initialization, check subsystems that need resync
450 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200451
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200452 // Start remote processor server if appropriate
453 return handleRemoteProcessingInterface(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200454}
455
456bool CParameterMgr::loadFrameworkConfiguration(string& strError)
457{
458 CAutoLog autoLog(this, "Loading framework configuration");
459
Patrick Benavoli68a91282011-08-31 11:23:23 +0200460 // Parse Structure XML file
461 CXmlElementSerializingContext elementSerializingContext(strError);
462
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100463 if (!xmlParse(elementSerializingContext, getFrameworkConfiguration(), _strXmlConfigurationFilePath, _strXmlConfigurationFolderPath, EFrameworkConfigurationLibrary)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200464
465 return false;
466 }
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100467 // Set class name to system class and configurable domains
468 getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
469 getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
470
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100471 // Get subsystem plugins elements
472 _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200473
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100474 if (!_pSubsystemPlugins) {
Patrick Benavoli68a91282011-08-31 11:23:23 +0200475
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100476 strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element";
Patrick Benavoli68a91282011-08-31 11:23:23 +0200477
478 return false;
479 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200480
Patrick Benavoli68a91282011-08-31 11:23:23 +0200481 // Log tuning availability
Kevin Rocardace81f82012-12-11 16:19:17 +0100482 log_info("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200483
484 return true;
485}
486
487bool CParameterMgr::loadStructure(string& strError)
488{
489 // Retrieve system to load structure to
490 CSystemClass* pSystemClass = getSystemClass();
491
Kevin Rocarde25ee792013-04-22 17:46:28 +0200492 log_info("Loading " + pSystemClass->getName() + " system class structure");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200493
494 // Get structure description element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100495 const CFrameworkConfigurationLocation* pStructureDescriptionFileLocation = static_cast<const CFrameworkConfigurationLocation*>(getConstFrameworkConfiguration()->findChildOfKind("StructureDescriptionFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200496
497 if (!pStructureDescriptionFileLocation) {
498
499 strError = "No StructureDescriptionFileLocation element found for SystemClass " + pSystemClass->getName();
500
501 return false;
502 }
503
504 // Get Xml structure folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100505 string strXmlStructureFolder = pStructureDescriptionFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200506
507 // Get Xml structure file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100508 string strXmlStructureFilePath = pStructureDescriptionFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200509
510 // Parse Structure XML file
511 CXmlParameterSerializingContext parameterBuildContext(strError);
512
Kevin Rocard57096bd2012-11-30 11:24:20 +0100513 CAutoLog autolog(pSystemClass, "Importing system structure from file " + strXmlStructureFilePath);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200514
Patrick Benavoli68a91282011-08-31 11:23:23 +0200515 if (!xmlParse(parameterBuildContext, pSystemClass, strXmlStructureFilePath, strXmlStructureFolder, EParameterCreationLibrary)) {
516
517 return false;
518 }
519
520 // Initialize offsets
521 pSystemClass->setOffset(0);
522
523 // Initialize main blackboard's size
524 _pMainParameterBlackboard->setSize(pSystemClass->getFootPrint());
525
526 return true;
527}
528
529bool CParameterMgr::loadSettings(string& strError)
530{
531 CAutoLog autoLog(this, "Loading settings");
532
533 // Get settings configuration element
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100534 const CFrameworkConfigurationGroup* pParameterConfigurationGroup = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChildOfKind("SettingsConfiguration"));
Patrick Benavoli68a91282011-08-31 11:23:23 +0200535
536 if (!pParameterConfigurationGroup) {
537
538 // No settings to load
539
540 return true;
541 }
542 // Get binary settings file location
543 const CFrameworkConfigurationLocation* pBinarySettingsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("BinarySettingsFileLocation"));
544
545 string strXmlBinarySettingsFilePath;
546
547 if (pBinarySettingsFileLocation) {
548
549 // Get Xml binary settings file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100550 strXmlBinarySettingsFilePath = pBinarySettingsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200551 }
552
553 // Get configurable domains element
554 const CFrameworkConfigurationLocation* pConfigurableDomainsFileLocation = static_cast<const CFrameworkConfigurationLocation*>(pParameterConfigurationGroup->findChildOfKind("ConfigurableDomainsFileLocation"));
555
556 if (!pConfigurableDomainsFileLocation) {
557
558 strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
559
560 return false;
561 }
562 // Get destination root element
563 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
564
565 // Get Xml configuration domains file name
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100566 string strXmlConfigurationDomainsFilePath = pConfigurableDomainsFileLocation->getFilePath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200567
568 // Get Xml configuration domains folder
Patrick Benavoli95ac0342011-11-07 20:32:51 +0100569 string strXmlConfigurationDomainsFolder = pConfigurableDomainsFileLocation->getFolderPath(_strXmlConfigurationFolderPath);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200570
571 // Parse configuration domains XML file (ask to read settings from XML file if they are not provided as binary)
572 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, !pBinarySettingsFileLocation);
573
574 // Selection criteria definition for rule creation
575 xmlDomainSerializingContext.setSelectionCriteriaDefinition(getConstSelectionCriteria()->getSelectionCriteriaDefinition());
576
Patrick Benavoli63499d42011-10-24 18:50:03 +0200577 // Auto validation of configurations if no binary settings provided
578 xmlDomainSerializingContext.setAutoValidationRequired(!pBinarySettingsFileLocation);
579
Kevin Rocardace81f82012-12-11 16:19:17 +0100580 log_info("Importing configurable domains from file %s %s settings", strXmlConfigurationDomainsFilePath.c_str(), pBinarySettingsFileLocation ? "without" : "with");
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200581
Patrick Benavoli68a91282011-08-31 11:23:23 +0200582 // Do parse
583 if (!xmlParse(xmlDomainSerializingContext, pConfigurableDomains, strXmlConfigurationDomainsFilePath, strXmlConfigurationDomainsFolder, EParameterConfigurationLibrary, "SystemClassName")) {
584
585 return false;
586 }
587 // We have loaded the whole system structure, compute checksum
588 const CSystemClass* pSystemClass = getConstSystemClass();
589 _uiStructureChecksum = pSystemClass->computeStructureChecksum() + getConfigurableDomains()->computeStructureChecksum() + getSelectionCriteria()->computeStructureChecksum();
590
591 // Load binary settings if any provided
592 if (pBinarySettingsFileLocation && !pConfigurableDomains->serializeSettings(strXmlBinarySettingsFilePath, false, _uiStructureChecksum, strError)) {
593
594 return false;
595 }
596
Patrick Benavoli1387bda2011-08-31 11:23:24 +0200597 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200598}
599
600// XML parsing
601bool CParameterMgr::xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, CParameterMgr::ElementLibrary eElementLibrary, const string& strNameAttrituteName)
602{
603 // Init serializing context
604 elementSerializingContext.set(_pElementLibrarySet->getElementLibrary(eElementLibrary), strXmlFolder, _strSchemaFolderLocation);
605
606 // Get Schema file associated to root element
607 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" + pRootElement->getKind() + ".xsd";
608
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200609 CXmlFileDocSource fileDocSource(strXmlFilePath, strXmlSchemaFilePath, pRootElement->getKind(), pRootElement->getName(), strNameAttrituteName);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200610
611 // Start clean
612 pRootElement->clean();
613
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200614 CXmlMemoryDocSink memorySink(pRootElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200615
Georges-Henri Baron326a31d2012-06-28 12:05:09 +0200616 if (!memorySink.process(fileDocSource, elementSerializingContext)) {
617 //Cleanup
Patrick Benavoli68a91282011-08-31 11:23:23 +0200618 pRootElement->clean();
619
620 return false;
621 }
622
Patrick Benavoli68a91282011-08-31 11:23:23 +0200623 return true;
624}
625
626// Init
627bool CParameterMgr::init(string& strError)
628{
629 return base::init(strError);
630}
631
632// Selection criteria interface
633CSelectionCriterionType* CParameterMgr::createSelectionCriterionType(bool bIsInclusive)
634{
635 // Propagate
636 return getSelectionCriteria()->createSelectionCriterionType(bIsInclusive);
637}
638
639CSelectionCriterion* CParameterMgr::createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType)
640{
641 // Propagate
642 return getSelectionCriteria()->createSelectionCriterion(strName, pSelectionCriterionType);
643}
644
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200645// Selection criterion retrieval
646CSelectionCriterion* CParameterMgr::getSelectionCriterion(const string& strName)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200647{
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200648 // Propagate
649 return getSelectionCriteria()->getSelectionCriterion(strName);
650}
651
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100652// Configuration application
Kevin Rocardace81f82012-12-11 16:19:17 +0100653void CParameterMgr::applyConfigurations()
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200654{
655 CAutoLog autoLog(this, "Configuration application request");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200656
657 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +0100658 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200659
660 if (!_bTuningModeIsOn) {
661
662 // Apply configuration(s)
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +0100663 doApplyConfigurations(false);
Frédéric Boisnarddaaa63c2012-08-27 15:48:15 +0200664 } else {
665
Kevin Rocardace81f82012-12-11 16:19:17 +0100666 log_warning("Configurations were not applied because the TuningMode is on");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200667 }
Patrick Benavoli68a91282011-08-31 11:23:23 +0200668}
669
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200670// Dynamic parameter handling
Patrick Benavoli065264a2011-11-20 15:46:41 +0100671CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, string& strError)
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200672{
Patrick Benavoli065264a2011-11-20 15:46:41 +0100673 CPathNavigator pathNavigator(strPath);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200674
Patrick Benavoli065264a2011-11-20 15:46:41 +0100675 // Nagivate through system class
676 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
677
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100678 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100679 }
680
681 // Find element
682 const CElement* pElement = getConstSystemClass()->findDescendant(pathNavigator);
683
684 if (!pElement) {
685
686 strError = "Path not found";
687
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100688 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100689 }
690
691 // Check found element is a parameter
692 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pElement);
693
694 if (!pConfigurableElement->isParameter()) {
695
696 // Element is not parameter
697 strError = "Not a parameter";
698
Patrick Benavoli79f16cc2011-11-25 22:36:41 +0100699 return NULL;
Patrick Benavoli065264a2011-11-20 15:46:41 +0100700 }
701
702 // Convert as parameter and return new handle
703 return new CParameterHandle(static_cast<const CBaseParameter*>(pElement), this);
Patrick Benavoli4bed9212011-10-27 14:18:00 +0200704}
705
Patrick Benavoli68a91282011-08-31 11:23:23 +0200706/////////////////// Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200707/// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200708CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli592ae562011-09-05 16:53:58 +0200709{
710 (void)remoteCommand;
711
Patrick Benavoli63499d42011-10-24 18:50:03 +0200712 // Show version
713 strResult = getVersion();
Patrick Benavoli592ae562011-09-05 16:53:58 +0200714
Patrick Benavoli63499d42011-10-24 18:50:03 +0200715 return CCommandHandler::ESucceeded;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200716}
717
Patrick Benavoli68a91282011-08-31 11:23:23 +0200718/// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200719CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200720{
721 (void)remoteCommand;
722 // System class
723 const CSystemClass* pSystemClass = getSystemClass();
724
Patrick Benavoli68a91282011-08-31 11:23:23 +0200725 // Show status
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200726 /// General section
727 appendTitle(strResult, "General:");
728 // System class
Patrick Benavoli68a91282011-08-31 11:23:23 +0200729 strResult += "System Class: ";
730 strResult += pSystemClass->getName();
731 strResult += "\n";
732
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200733 // Tuning mode
Patrick Benavoli68a91282011-08-31 11:23:23 +0200734 strResult += "Tuning Mode: ";
735 strResult += tuningModeOn() ? "on" : "off";
736 strResult += "\n";
737
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200738 // Value space
Patrick Benavoli68a91282011-08-31 11:23:23 +0200739 strResult += "Value Space: ";
740 strResult += valueSpaceIsRaw() ? "raw" : "real";
741 strResult += "\n";
742
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200743 // Output raw format
744 strResult += "Output Raw Format: ";
745 strResult += outputRawFormatIsHex() ? "hex" : "dec";
746 strResult += "\n";
747
748 // Auto Sync
Patrick Benavoli68a91282011-08-31 11:23:23 +0200749 strResult += "Auto Sync: ";
750 strResult += autoSyncOn() ? "on" : "off";
751 strResult += "\n";
752
753 /// Subsystem list
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200754 appendTitle(strResult, "Subsystems:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200755 string strSubsystemList;
756 pSystemClass->listChildrenPaths(strSubsystemList);
757 strResult += strSubsystemList;
758
759 /// Last applied configurations
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200760 appendTitle(strResult, "Last Applied [Pending] Configurations:");
Patrick Benavoli68a91282011-08-31 11:23:23 +0200761 string strLastAppliedConfigurations;
762 getConfigurableDomains()->listLastAppliedConfigurations(strLastAppliedConfigurations);
763 strResult += strLastAppliedConfigurations;
764
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200765 /// Criteria states
Frédéric Boisnard8b243f52012-09-06 18:03:20 +0200766 appendTitle(strResult, "Selection Criteria:");
Kevin Rocard7f265822012-12-07 18:51:22 +0100767 list<string> lstrSelectionCriteria;
768 getSelectionCriteria()->listSelectionCriteria(lstrSelectionCriteria, false, true);
769 // Concatenate the criterion list as the command result
770 CUtility::concatenate(lstrSelectionCriteria, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200771
Patrick Benavoli63499d42011-10-24 18:50:03 +0200772 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200773}
774
775/// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200776CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200777{
778 if (remoteCommand.getArgument(0) == "on") {
779
780 if (setTuningMode(true, strResult)) {
781
Patrick Benavoli63499d42011-10-24 18:50:03 +0200782 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200783 }
784 } else if (remoteCommand.getArgument(0) == "off") {
785
786 if (setTuningMode(false, strResult)) {
787
Patrick Benavoli63499d42011-10-24 18:50:03 +0200788 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200789 }
790 } else {
791 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200792 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200793 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200794 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200795}
796
Patrick Benavoli63499d42011-10-24 18:50:03 +0200797CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200798{
799 (void)remoteCommand;
800
801 strResult = tuningModeOn() ? "on" : "off";
802
Patrick Benavoli63499d42011-10-24 18:50:03 +0200803 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200804}
805
806/// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200807CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200808{
809 (void)strResult;
810
811 if (remoteCommand.getArgument(0) == "raw") {
812
813 setValueSpace(true);
814
Patrick Benavoli63499d42011-10-24 18:50:03 +0200815 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200816
817 } else if (remoteCommand.getArgument(0) == "real") {
818
819 setValueSpace(false);
820
Patrick Benavoli63499d42011-10-24 18:50:03 +0200821 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200822
823 } else {
824 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200825 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200826 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200827 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200828}
829
Patrick Benavoli63499d42011-10-24 18:50:03 +0200830CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200831{
832 (void)remoteCommand;
833
834 strResult = valueSpaceIsRaw() ? "raw" : "real";
835
Patrick Benavoli63499d42011-10-24 18:50:03 +0200836 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200837}
838
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200839/// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200840CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200841{
842 (void)strResult;
843
844 if (remoteCommand.getArgument(0) == "hex") {
845
846 setOutputRawFormat(true);
847
Patrick Benavoli63499d42011-10-24 18:50:03 +0200848 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200849
850 } else if (remoteCommand.getArgument(0) == "dec") {
851
852 setOutputRawFormat(false);
853
Patrick Benavoli63499d42011-10-24 18:50:03 +0200854 return CCommandHandler::EDone;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200855
856 } else {
857 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200858 return CCommandHandler::EShowUsage;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200859 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200860 return CCommandHandler::EFailed;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200861}
862
Patrick Benavoli63499d42011-10-24 18:50:03 +0200863CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200864{
865 (void)remoteCommand;
866
867 strResult = outputRawFormatIsHex() ? "hex" : "dec";
868
Patrick Benavoli63499d42011-10-24 18:50:03 +0200869 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200870}
871
Patrick Benavoli68a91282011-08-31 11:23:23 +0200872/// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200873CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200874{
875 if (remoteCommand.getArgument(0) == "on") {
876
877 if (setAutoSync(true, strResult)) {
878
Patrick Benavoli63499d42011-10-24 18:50:03 +0200879 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200880 }
881 } else if (remoteCommand.getArgument(0) == "off") {
882
883 if (setAutoSync(false, strResult)) {
884
Patrick Benavoli63499d42011-10-24 18:50:03 +0200885 return CCommandHandler::EDone;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200886 }
887 } else {
888 // Show usage
Patrick Benavoli63499d42011-10-24 18:50:03 +0200889 return CCommandHandler::EShowUsage;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200890 }
Patrick Benavoli63499d42011-10-24 18:50:03 +0200891 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200892}
893
Patrick Benavoli63499d42011-10-24 18:50:03 +0200894CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200895{
896 (void)remoteCommand;
897
898 strResult = autoSyncOn() ? "on" : "off";
899
Patrick Benavoli63499d42011-10-24 18:50:03 +0200900 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200901}
902
Patrick Benavoli63499d42011-10-24 18:50:03 +0200903CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200904{
905 (void)remoteCommand;
906
Patrick Benavoli63499d42011-10-24 18:50:03 +0200907 return sync(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200908}
909
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200910/// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200911CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200912{
913 (void)remoteCommand;
914
Kevin Rocard4eae8272013-04-18 19:12:46 +0200915 bool humanReadable = true;
Kevin Rocard7f265822012-12-07 18:51:22 +0100916
Kevin Rocard4eae8272013-04-18 19:12:46 +0200917 // Look for optional arguments
918 if (remoteCommand.getArgumentCount() >= 1) {
919
920 // If csv is provided, format the criterion list in Commas Separated Value pairs
921 if (remoteCommand.getArgument(0) == "csv") {
922 humanReadable = false;
923 } else {
924 return CCommandHandler::EShowUsage;
925 }
926 }
927
928 list<string> lstrResult;
929 getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
Kevin Rocard7f265822012-12-07 18:51:22 +0100930
931 // Concatenate the criterion list as the command result
932 CUtility::concatenate(lstrResult, strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200933
Patrick Benavoli63499d42011-10-24 18:50:03 +0200934 return CCommandHandler::ESucceeded;
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200935}
Patrick Benavoli68a91282011-08-31 11:23:23 +0200936
937/// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200938CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200939{
940 (void)remoteCommand;
941
Patrick Benavoli63499d42011-10-24 18:50:03 +0200942 getConfigurableDomains()->listDomains(strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200943
Patrick Benavoli63499d42011-10-24 18:50:03 +0200944 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200945}
946
Patrick Benavoli63499d42011-10-24 18:50:03 +0200947CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200948{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200949 return createDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200950}
951
Patrick Benavoli63499d42011-10-24 18:50:03 +0200952CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200953{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200954 return deleteDomain(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200955}
956
Kevin Rocard170f0a42012-06-18 13:56:05 +0200957CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteAllDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
958{
959 (void)remoteCommand;
960
961 return deleteAllDomains(strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
962}
963
Patrick Benavoli63499d42011-10-24 18:50:03 +0200964CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200965{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200966 return getConfigurableDomains()->renameDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200967}
968
Patrick Benavoli63499d42011-10-24 18:50:03 +0200969CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200970{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200971 // Check tuning mode
972 if (!checkTuningModeOn(strResult)) {
973
974 return CCommandHandler::EFailed;
975 }
976
977 // Set property
978 bool bSequenceAware;
979
980 if (remoteCommand.getArgument(1) == "true") {
981
982 bSequenceAware = true;
983
984 } else if (remoteCommand.getArgument(1) == "false") {
985
986 bSequenceAware = false;
987
988 } else {
989 // Show usage
990 return CCommandHandler::EShowUsage;
991 }
992
993 return getConfigurableDomains()->setSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200994}
995
Patrick Benavoli63499d42011-10-24 18:50:03 +0200996CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +0200997{
Patrick Benavoli63499d42011-10-24 18:50:03 +0200998 // Get property
999 bool bSequenceAware;
1000
1001 if (!getConfigurableDomains()->getSequenceAwareness(remoteCommand.getArgument(0), bSequenceAware, strResult)) {
1002
1003 return CCommandHandler::EFailed;
1004 }
1005
1006 strResult = bSequenceAware ? "true" : "false";
1007
1008 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001009}
1010
Patrick Benavoli63499d42011-10-24 18:50:03 +02001011CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001012{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001013 return getConfigurableDomains()->listDomainElements(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001014}
1015
Patrick Benavoli63499d42011-10-24 18:50:03 +02001016CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001017{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001018 return addConfigurableElementToDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1019}
1020
1021CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1022{
1023 return removeConfigurableElementFromDomain(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1024}
1025
1026CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1027{
1028 return split(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001029}
1030
1031/// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +02001032CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001033{
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001034 return getConstConfigurableDomains()->listConfigurations(remoteCommand.getArgument(0), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1035}
1036
1037CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1038{
1039 (void)remoteCommand;
1040
1041 // Dummy error context
1042 string strError;
1043 CErrorContext errorContext(strError);
1044
1045 // Dump
1046 getConstConfigurableDomains()->dumpContent(strResult, errorContext);
1047
1048 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001049}
1050
Patrick Benavoli63499d42011-10-24 18:50:03 +02001051CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001052{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001053 return createConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001054}
1055
Patrick Benavoli63499d42011-10-24 18:50:03 +02001056CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001057{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001058 return deleteConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001059}
1060
Patrick Benavoli63499d42011-10-24 18:50:03 +02001061CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001062{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001063 return getConfigurableDomains()->renameConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001064}
1065
Patrick Benavoli63499d42011-10-24 18:50:03 +02001066CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001067{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001068 return saveConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001069}
1070
Patrick Benavoli63499d42011-10-24 18:50:03 +02001071CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001072{
Kevin Rocardace81f82012-12-11 16:19:17 +01001073 list<string> lstrResult;
1074 if (!restoreConfiguration(remoteCommand.getArgument(0), remoteCommand.getArgument(1), lstrResult)) {
1075 //Concatenate the error list as the command result
1076 CUtility::concatenate(lstrResult, strResult);
1077
1078 return CCommandHandler::EFailed;
1079 }
1080 return CCommandHandler::EDone;
Patrick Benavoli63499d42011-10-24 18:50:03 +02001081}
1082
1083CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1084{
1085 // Check tuning mode
1086 if (!checkTuningModeOn(strResult)) {
1087
1088 return CCommandHandler::EFailed;
1089 }
1090
1091 // Build configurable element path list
1092 vector<string> astrNewElementSequence;
1093
1094 uint32_t uiArgument;
1095
1096 for (uiArgument = 2; uiArgument < remoteCommand.getArgumentCount(); uiArgument++) {
1097
1098 astrNewElementSequence.push_back(remoteCommand.getArgument(uiArgument));
1099 }
1100
1101 // Delegate to configurable domains
1102 return getConfigurableDomains()->setElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), astrNewElementSequence, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1103}
1104
1105CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1106{
1107 // Delegate to configurable domains
1108 return getConfigurableDomains()->getElementSequence(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001109}
1110
Patrick Benavoli0bd50542011-11-29 11:10:27 +01001111CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1112{
1113 // Delegate to configurable domains
1114 return getConfigurableDomains()->setApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.packArguments(2, remoteCommand.getArgumentCount() - 2), getConstSelectionCriteria()->getSelectionCriteriaDefinition(), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1115}
1116
1117CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::clearRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1118{
1119 // Delegate to configurable domains
1120 return getConfigurableDomains()->clearApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
1121}
1122
1123CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getRuleCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1124{
1125 // Delegate to configurable domains
1126 return getConfigurableDomains()->getApplicationRule(remoteCommand.getArgument(0), remoteCommand.getArgument(1), strResult) ? CCommandHandler::ESucceeded : CCommandHandler::EFailed;
1127}
1128
Patrick Benavoli68a91282011-08-31 11:23:23 +02001129/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001130CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001131{
1132 CElementLocator elementLocator(getSystemClass(), false);
1133
1134 CElement* pLocatedElement = NULL;
1135
1136 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1137
Patrick Benavoli63499d42011-10-24 18:50:03 +02001138 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001139 }
1140
1141 strResult = string("\n");
1142
1143 if (!pLocatedElement) {
1144
1145 // List from root folder
1146
1147 // Return system class qualified name
1148 pLocatedElement = getSystemClass();
1149 }
1150
1151 // Return sub-elements
1152 strResult += pLocatedElement->listQualifiedPaths(false);
1153
Patrick Benavoli63499d42011-10-24 18:50:03 +02001154 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001155}
1156
1157/// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +02001158CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001159{
1160 CElementLocator elementLocator(getSystemClass(), false);
1161
1162 CElement* pLocatedElement = NULL;
1163
1164 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1165
Patrick Benavoli63499d42011-10-24 18:50:03 +02001166 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001167 }
1168
1169 strResult = string("\n");
1170
1171 if (!pLocatedElement) {
1172
1173 // List from root folder
1174
1175 // Return system class qualified name
1176 pLocatedElement = getSystemClass();
1177 }
1178
1179 // Return sub-elements
1180 strResult += pLocatedElement->listQualifiedPaths(true);
1181
Patrick Benavoli63499d42011-10-24 18:50:03 +02001182 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001183}
1184
Patrick Benavoli63499d42011-10-24 18:50:03 +02001185CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001186{
1187 CElementLocator elementLocator(getSystemClass());
1188
1189 CElement* pLocatedElement = NULL;
1190
1191 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1192
Patrick Benavoli63499d42011-10-24 18:50:03 +02001193 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001194 }
1195
1196 string strError;
1197
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001198 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001199
1200 // Dump elements
1201 pLocatedElement->dumpContent(strResult, parameterAccessContext);
1202
Patrick Benavoli63499d42011-10-24 18:50:03 +02001203 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001204}
1205
Patrick Benavoli63499d42011-10-24 18:50:03 +02001206CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001207{
1208 CElementLocator elementLocator(getSystemClass());
1209
1210 CElement* pLocatedElement = NULL;
1211
1212 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1213
Patrick Benavoli63499d42011-10-24 18:50:03 +02001214 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001215 }
1216
1217 // Converted to actual sizable element
1218 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1219
1220 // Get size as string
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001221 strResult = pConfigurableElement->getFootprintAsString();
Patrick Benavoli68a91282011-08-31 11:23:23 +02001222
Patrick Benavoli63499d42011-10-24 18:50:03 +02001223 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001224}
1225
Patrick Benavoli63499d42011-10-24 18:50:03 +02001226CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001227{
1228 CElementLocator elementLocator(getSystemClass());
1229
1230 CElement* pLocatedElement = NULL;
1231
1232 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1233
Patrick Benavoli63499d42011-10-24 18:50:03 +02001234 return CCommandHandler::EFailed;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001235 }
1236
1237 // Convert element
1238 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1239
1240 // Return element properties
1241 pConfigurableElement->showProperties(strResult);
1242
Patrick Benavoli63499d42011-10-24 18:50:03 +02001243 return CCommandHandler::ESucceeded;
Patrick Benavoli2ecf9002011-08-31 11:23:24 +02001244}
1245
Patrick Benavoli63499d42011-10-24 18:50:03 +02001246CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001247{
1248 string strValue;
1249
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001250 if (!accessParameterValue(remoteCommand.getArgument(0), strValue, false, strResult)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001251
Patrick Benavoli63499d42011-10-24 18:50:03 +02001252 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001253 }
1254 // Succeeded
1255 strResult = strValue;
1256
Patrick Benavoli63499d42011-10-24 18:50:03 +02001257 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001258}
1259
Patrick Benavoli63499d42011-10-24 18:50:03 +02001260CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001261{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001262 // Check tuning mode
1263 if (!checkTuningModeOn(strResult)) {
1264
1265 return CCommandHandler::EFailed;
1266 }
1267 // Get value to set
1268 string strValue = remoteCommand.packArguments(1, remoteCommand.getArgumentCount() - 1);
1269
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001270 return accessParameterValue(remoteCommand.getArgument(0), strValue, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001271}
1272
Patrick Benavoli63499d42011-10-24 18:50:03 +02001273CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001274{
1275 CElementLocator elementLocator(getSystemClass());
1276
1277 CElement* pLocatedElement = NULL;
1278
1279 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1280
Patrick Benavoli63499d42011-10-24 18:50:03 +02001281 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001282 }
1283
1284 // Convert element
1285 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1286
1287 // Return element belonging domains
1288 pConfigurableElement->listBelongingDomains(strResult);
1289
Patrick Benavoli63499d42011-10-24 18:50:03 +02001290 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001291}
1292
Patrick Benavoli63499d42011-10-24 18:50:03 +02001293CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001294{
1295 CElementLocator elementLocator(getSystemClass());
1296
1297 CElement* pLocatedElement = NULL;
1298
1299 if (!elementLocator.locate(remoteCommand.getArgument(0), &pLocatedElement, strResult)) {
1300
Patrick Benavoli63499d42011-10-24 18:50:03 +02001301 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001302 }
1303
1304 // Convert element
1305 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1306
1307 // Return element belonging domains
1308 pConfigurableElement->listAssociatedDomains(strResult);
1309
Patrick Benavoli63499d42011-10-24 18:50:03 +02001310 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001311}
1312
Patrick Benavoli63499d42011-10-24 18:50:03 +02001313CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001314{
1315 (void)remoteCommand;
1316
1317 getConfigurableDomains()->listAssociatedElements(strResult);
1318
Patrick Benavoli63499d42011-10-24 18:50:03 +02001319 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001320}
1321
Patrick Benavoli63499d42011-10-24 18:50:03 +02001322CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001323{
1324 (void)remoteCommand;
1325
1326 getConfigurableDomains()->listConflictingElements(strResult);
1327
Patrick Benavoli63499d42011-10-24 18:50:03 +02001328 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001329}
1330
Patrick Benavoli63499d42011-10-24 18:50:03 +02001331CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001332{
1333 (void)remoteCommand;
1334
1335 getSystemClass()->listRogueElements(strResult);
1336
Patrick Benavoli63499d42011-10-24 18:50:03 +02001337 return CCommandHandler::ESucceeded;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001338}
1339
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001340CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::getConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1341{
1342 string strOutputValue;
1343 string strError;
1344
1345 if (!accessConfigurationValue(remoteCommand.getArgument(0), remoteCommand.getArgument(1), remoteCommand.getArgument(2), strOutputValue, false, strError)) {
1346
1347 strResult = strError;
1348 return CCommandHandler::EFailed;
1349 }
1350 // Succeeded
1351 strResult = strOutputValue;
1352
1353 return CCommandHandler::ESucceeded;
1354}
1355
1356CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::setConfigurationParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
1357{
1358 // Get value to set
1359 string strValue = remoteCommand.packArguments(3, remoteCommand.getArgumentCount() - 3);
1360
1361 bool bSuccess = accessConfigurationValue(remoteCommand.getArgument(0),
1362 remoteCommand.getArgument(1),
1363 remoteCommand.getArgument(2),
1364 strValue, true, strResult);
1365
1366 return bSuccess ? CCommandHandler::EDone : CCommandHandler::EFailed;
1367}
1368
Patrick Benavoli68a91282011-08-31 11:23:23 +02001369/// Settings Import/Export
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001370CParameterMgr::CCommandHandler::CommandStatus
1371 CParameterMgr::exportConfigurableDomainsToXMLCommmandProcess(
1372 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001373{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001374 string strFileName = remoteCommand.getArgument(0);
1375 return exportDomainsXml(strFileName, false, true, strResult) ?
1376 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001377}
1378
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001379CParameterMgr::CCommandHandler::CommandStatus
1380 CParameterMgr::importConfigurableDomainsFromXMLCommmandProcess(
1381 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001382{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001383 return importDomainsXml(remoteCommand.getArgument(0), false, true, strResult) ?
1384 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001385}
1386
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001387CParameterMgr::CCommandHandler::CommandStatus
1388 CParameterMgr::exportConfigurableDomainsWithSettingsToXMLCommmandProcess(
1389 const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001390{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001391 string strFileName = remoteCommand.getArgument(0);
1392 return exportDomainsXml(strFileName, true, true, strResult) ?
1393 CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001394}
1395
Patrick Benavoli63499d42011-10-24 18:50:03 +02001396CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001397{
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001398 return importDomainsXml(remoteCommand.getArgument(0), true, true, strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001399}
1400
Patrick Benavoli63499d42011-10-24 18:50:03 +02001401CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001402{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001403 return exportDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001404}
1405
Patrick Benavoli63499d42011-10-24 18:50:03 +02001406CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001407{
Patrick Benavoli63499d42011-10-24 18:50:03 +02001408 return importDomainsBinary(remoteCommand.getArgument(0), strResult) ? CCommandHandler::EDone : CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001409}
1410
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001411CParameterMgr::CCommandHandler::CommandStatus
1412 CParameterMgr::getConfigurableDomainsWithSettingsXMLCommmandProcess(
1413 const IRemoteCommand& remoteCommand, string& strResult)
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001414{
1415 (void)remoteCommand;
1416
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001417 if (!exportDomainsXml(strResult, true, false, strResult)) {
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001418
1419 return CCommandHandler::EFailed;
1420 }
1421 // Succeeded
1422 return CCommandHandler::ESucceeded;
1423}
1424
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001425CParameterMgr::CCommandHandler::CommandStatus
1426 CParameterMgr::setConfigurableDomainsWithSettingsXMLCommmandProcess(
1427 const IRemoteCommand& remoteCommand, string& strResult)
1428{
1429 return importDomainsXml(remoteCommand.getArgument(0), true, false, strResult) ?
1430 CCommandHandler::EDone : CCommandHandler::EFailed;
1431}
1432
1433CParameterMgr::CCommandHandler::CommandStatus
1434 CParameterMgr::getSystemClassXMLCommmandProcess(
1435 const IRemoteCommand& remoteCommand, string& strResult)
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001436{
1437 (void)remoteCommand;
1438
1439 if (!getSystemClassXMLString(strResult)) {
1440
1441 return CCommandHandler::EFailed;
1442 }
1443 // Succeeded
1444 return CCommandHandler::ESucceeded;
1445}
1446
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001447// User set/get parameters in main BlackBoard
1448bool CParameterMgr::accessParameterValue(const string& strPath, string& strValue, bool bSet, string& strError)
1449{
1450 // Define context
1451 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
1452
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001453 // Activate the auto synchronization with the hardware
1454 if (bSet) {
1455
1456 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1457 }
1458
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001459 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1460}
1461
1462// User set/get parameters in specific Configuration BlackBoard
1463bool CParameterMgr::accessConfigurationValue(const string& strDomain, const string& strConfiguration, const string& strPath, string& strValue, bool bSet, string& strError)
1464{
1465 CElementLocator elementLocator(getSystemClass());
1466
1467 CElement* pLocatedElement = NULL;
1468
1469 if (!elementLocator.locate(strPath, &pLocatedElement, strError)) {
1470
1471 return false;
1472 }
1473
1474 // Convert element
1475 const CConfigurableElement* pConfigurableElement = static_cast<const CConfigurableElement*>(pLocatedElement);
1476
1477 // Get the Configuration blackboard and the Base Offset of the configurable element in this blackboard
1478 uint32_t uiBaseOffset;
1479 bool bIsLastApplied;
1480
1481 CParameterBlackboard* pConfigurationBlackboard = getConstConfigurableDomains()->findConfigurationBlackboard(strDomain, strConfiguration, pConfigurableElement, uiBaseOffset, bIsLastApplied, strError);
1482
1483 if (!pConfigurationBlackboard) {
1484
1485 return false;
1486 }
1487
1488 log_info("Element %s in Domain %s, offset: %d, base offset: %d", strPath.c_str(), strDomain.c_str(), pConfigurableElement->getOffset(), uiBaseOffset);
1489
1490 /// Update the Configuration Blackboard
1491
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001492 // 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 +01001493 CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
1494
1495 // Access Value in the Configuration Blackboard
1496 if (!accessValue(parameterAccessContext, strPath, strValue, bSet, strError)) {
1497
1498 return false;
1499 }
1500
1501 /// If the Configuration is the last one applied, update the Main Blackboard as well
1502
1503 if (bIsLastApplied) {
1504
1505 // Define Main context
1506 parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
1507
Frédéric Boisnard150407c2013-03-15 14:46:23 +01001508 // Activate the auto synchronization with the hardware
1509 if (bSet) {
1510
1511 parameterAccessContext.setAutoSync(_bAutoSyncOn);
1512 }
1513
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001514 // Access Value in the Main Blackboard
1515 return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
1516 }
1517
1518 return true;
1519}
1520
Patrick Benavoli68a91282011-08-31 11:23:23 +02001521// User set/get parameters
Frédéric Boisnarde42dacd2013-02-25 15:56:56 +01001522bool CParameterMgr::accessValue(CParameterAccessContext& parameterAccessContext, const string& strPath, string& strValue, bool bSet, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001523{
Patrick Benavoli065264a2011-11-20 15:46:41 +01001524 // Lock state
1525 CAutoLock autoLock(&_blackboardMutex);
1526
1527 CPathNavigator pathNavigator(strPath);
1528
1529 // Nagivate through system class
1530 if (!pathNavigator.navigateThrough(getConstSystemClass()->getName(), strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001531
1532 return false;
1533 }
1534
Patrick Benavoli065264a2011-11-20 15:46:41 +01001535 // Do the get
1536 return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001537}
1538
1539// Tuning mode
1540bool CParameterMgr::setTuningMode(bool bOn, string& strError)
1541{
1542 // Tuning allowed?
Patrick Benavoli95ac0342011-11-07 20:32:51 +01001543 if (bOn && !getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001544
1545 strError = "Tuning prohibited";
1546
1547 return false;
1548 }
1549 // Lock state
Patrick Benavoli065264a2011-11-20 15:46:41 +01001550 CAutoLock autoLock(&_blackboardMutex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001551
1552 // Warn domains about exiting tuning mode
1553 if (!bOn && _bTuningModeIsOn) {
1554
1555 // Ensure application of currently selected configurations
Patrick Benavoli1387bda2011-08-31 11:23:24 +02001556 // Force-apply configurations
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01001557 doApplyConfigurations(true);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001558
Patrick Benavoli68a91282011-08-31 11:23:23 +02001559 // Turn auto sync back on
1560 _bAutoSyncOn = true;
1561 }
1562
1563 // Store
1564 _bTuningModeIsOn = bOn;
1565
Patrick Benavoli68a91282011-08-31 11:23:23 +02001566 return true;
1567}
1568
1569bool CParameterMgr::tuningModeOn() const
1570{
1571 return _bTuningModeIsOn;
1572}
1573
1574// Current value space for user set/get value interpretation
1575void CParameterMgr::setValueSpace(bool bIsRaw)
1576{
1577 _bValueSpaceIsRaw = bIsRaw;
1578}
1579
1580bool CParameterMgr::valueSpaceIsRaw()
1581{
1582 return _bValueSpaceIsRaw;
1583}
1584
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001585// Current Output Raw Format for user get value interpretation
1586void CParameterMgr::setOutputRawFormat(bool bIsHex)
1587{
1588 _bOutputRawFormatIsHex = bIsHex;
1589}
1590
1591bool CParameterMgr::outputRawFormatIsHex()
1592{
1593 return _bOutputRawFormatIsHex;
1594}
1595
Patrick Benavoli68a91282011-08-31 11:23:23 +02001596/// Sync
1597// Automatic hardware synchronization control (during tuning session)
1598bool CParameterMgr::setAutoSync(bool bAutoSyncOn, string& strError)
1599{
1600 // Check tuning mode
1601 if (!checkTuningModeOn(strError)) {
1602
1603 return false;
1604 }
1605 // Warn domains about turning auto sync back on
1606 if (bAutoSyncOn && !_bAutoSyncOn) {
1607
Patrick Benavoli592ae562011-09-05 16:53:58 +02001608 // Do the synchronization at system class level (could be optimized by keeping track of all modified parameters)
1609 if (!sync(strError)) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001610
1611 return false;
1612 }
1613 }
1614
1615 // Set Auto sync
1616 _bAutoSyncOn = bAutoSyncOn;
1617
1618 return true;
1619}
1620
1621bool CParameterMgr::autoSyncOn() const
1622{
1623 return _bAutoSyncOn;
1624}
1625
1626// Manual hardware synchronization control (during tuning session)
1627bool CParameterMgr::sync(string& strError)
1628{
1629 // Check tuning mode
1630 if (!checkTuningModeOn(strError)) {
1631
1632 return false;
1633 }
1634 // Warn domains about turning auto sync back on
1635 if (_bAutoSyncOn) {
1636
1637 strError = "Feature unavailable when Auto Sync is on";
1638
1639 return false;
1640 }
1641
1642 // Get syncer set
1643 CSyncerSet syncerSet;
1644 // ... from system class
1645 getConstSystemClass()->fillSyncerSet(syncerSet);
Kevin Rocardace81f82012-12-11 16:19:17 +01001646
Patrick Benavoli68a91282011-08-31 11:23:23 +02001647 // Sync
Kevin Rocardace81f82012-12-11 16:19:17 +01001648 list<string> lstrError;
1649 if (! syncerSet.sync(*_pMainParameterBlackboard, false, &lstrError)){
1650
1651 CUtility::concatenate(lstrError, strError);
1652 return false;
1653 };
1654
1655 return true;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001656}
1657
1658// Content dump
1659void CParameterMgr::logStructureContent(string& strContent) const
1660{
1661 string strError;
1662
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001663 CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001664
1665 dumpContent(strContent, parameterAccessContext);
1666}
1667
1668// Configuration/Domains handling
1669bool CParameterMgr::createDomain(const string& strName, string& strError)
1670{
1671 // Check tuning mode
1672 if (!checkTuningModeOn(strError)) {
1673
1674 return false;
1675 }
1676
1677 // Delegate to configurable domains
1678 return getConfigurableDomains()->createDomain(strName, strError);
1679}
1680
1681bool CParameterMgr::deleteDomain(const string& strName, string& strError)
1682{
1683 // Check tuning mode
1684 if (!checkTuningModeOn(strError)) {
1685
1686 return false;
1687 }
1688
1689 // Delegate to configurable domains
1690 return getConfigurableDomains()->deleteDomain(strName, strError);
1691}
1692
Kevin Rocard170f0a42012-06-18 13:56:05 +02001693bool CParameterMgr::deleteAllDomains(string& strError)
1694{
1695 // Check tuning mode
1696 if (!checkTuningModeOn(strError)) {
1697
1698 return false;
1699 }
1700
1701 // Delegate to configurable domains
1702 getConfigurableDomains()->deleteAllDomains();
1703
1704 return true;
1705}
1706
Patrick Benavoli68a91282011-08-31 11:23:23 +02001707bool CParameterMgr::createConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1708{
1709 // Check tuning mode
1710 if (!checkTuningModeOn(strError)) {
1711
1712 return false;
1713 }
1714
1715 // Delegate to configurable domains
1716 return getConfigurableDomains()->createConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1717}
1718
1719bool CParameterMgr::deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1720{
1721 // Check tuning mode
1722 if (!checkTuningModeOn(strError)) {
1723
1724 return false;
1725 }
1726
1727 // Delegate to configurable domains
1728 return getConfigurableDomains()->deleteConfiguration(strDomain, strConfiguration, strError);
1729}
1730
Kevin Rocardace81f82012-12-11 16:19:17 +01001731bool CParameterMgr::restoreConfiguration(const string& strDomain, const string& strConfiguration, list<string>& lstrError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001732{
Kevin Rocardace81f82012-12-11 16:19:17 +01001733 string strError;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001734 // Check tuning mode
1735 if (!checkTuningModeOn(strError)) {
1736
Kevin Rocardace81f82012-12-11 16:19:17 +01001737 lstrError.push_back(strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001738 return false;
1739 }
1740
1741 // Delegate to configurable domains
Kevin Rocardace81f82012-12-11 16:19:17 +01001742 return getConstConfigurableDomains()->restoreConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, _bAutoSyncOn, lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001743}
1744
1745bool CParameterMgr::saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError)
1746{
1747 // Check tuning mode
1748 if (!checkTuningModeOn(strError)) {
1749
1750 return false;
1751 }
1752
1753 // Delegate to configurable domains
1754 return getConfigurableDomains()->saveConfiguration(strDomain, strConfiguration, _pMainParameterBlackboard, strError);
1755}
1756
1757// Configurable element - domain association
1758bool CParameterMgr::addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1759{
1760 // Check tuning mode
1761 if (!checkTuningModeOn(strError)) {
1762
1763 return false;
1764 }
1765
1766 CElementLocator elementLocator(getSystemClass());
1767
1768 CElement* pLocatedElement = NULL;
1769
1770 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1771
1772 return false;
1773 }
1774
1775 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001776 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001777
1778 // Delegate
1779 return getConfigurableDomains()->addConfigurableElementToDomain(strDomain, pConfigurableElement, _pMainParameterBlackboard, strError);
1780}
1781
1782bool CParameterMgr::removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1783{
1784 // Check tuning mode
1785 if (!checkTuningModeOn(strError)) {
1786
1787 return false;
1788 }
1789
1790 CElementLocator elementLocator(getSystemClass());
1791
1792 CElement* pLocatedElement = NULL;
1793
1794 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1795
Patrick Benavoli63499d42011-10-24 18:50:03 +02001796 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001797 }
1798
1799 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001800 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001801
1802 // Delegate
1803 return getConfigurableDomains()->removeConfigurableElementFromDomain(strDomain, pConfigurableElement, strError);
1804}
1805
1806bool CParameterMgr::split(const string& strDomain, const string& strConfigurableElementPath, string& strError)
1807{
1808 // Check tuning mode
1809 if (!checkTuningModeOn(strError)) {
1810
1811 return false;
1812 }
1813
1814 CElementLocator elementLocator(getSystemClass());
1815
1816 CElement* pLocatedElement = NULL;
1817
1818 if (!elementLocator.locate(strConfigurableElementPath, &pLocatedElement, strError)) {
1819
Patrick Benavoli63499d42011-10-24 18:50:03 +02001820 return CCommandHandler::EFailed;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001821 }
1822
1823 // Convert element
Pavel Chupin85413ff2012-04-24 10:55:48 +04001824 CConfigurableElement* pConfigurableElement = static_cast<CConfigurableElement*>(pLocatedElement);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001825
1826 // Delegate
1827 return getConfigurableDomains()->split(strDomain, pConfigurableElement, strError);
1828}
1829
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001830bool CParameterMgr::importDomainsXml(const string& strXmlSource, bool bWithSettings,
1831 bool bFromFile, string& strError)
Patrick Benavoli68a91282011-08-31 11:23:23 +02001832{
1833 // Check tuning mode
1834 if (!checkTuningModeOn(strError)) {
1835
1836 return false;
1837 }
1838
1839 // check path is absolute
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001840 if (bFromFile && strXmlSource[0] != '/') {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001841
1842 strError = "Please provide absolute path";
1843
1844 return false;
1845 }
1846 // Root element
1847 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1848
1849 // Context
1850 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1851
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001852 // Selection criteria definition for rule creation
1853 xmlDomainSerializingContext.setSelectionCriteriaDefinition(
1854 getConstSelectionCriteria()->getSelectionCriteriaDefinition());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001855
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001856 // Init serializing context
1857 xmlDomainSerializingContext.set(
1858 _pElementLibrarySet->getElementLibrary(EParameterConfigurationLibrary),
1859 "", _strSchemaFolderLocation);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001860
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001861 // Get Schema file associated to root element
1862 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" +
1863 pConfigurableDomains->getKind() + ".xsd";
1864
1865 // Xml Source
1866 CXmlDocSource* pSource;
1867
1868 if (bFromFile) {
1869
1870 // when importing from a file strXmlSource is the file name
1871 pSource = new CXmlFileDocSource(strXmlSource, strXmlSchemaFilePath,
1872 pConfigurableDomains->getKind(),
1873 pConfigurableDomains->getName(), "SystemClassName");
1874
1875 } else {
1876
1877 // when importing from an xml string, strXmlSource contains the string
1878 pSource = new CXmlStringDocSource(strXmlSource, strXmlSchemaFilePath,
1879 pConfigurableDomains->getKind(),
1880 pConfigurableDomains->getName(), "SystemClassName");
1881
1882 }
1883 // Start clean
1884 pConfigurableDomains->clean();
1885
1886 // Use a doc sink that instantiate Configurable Domains from the given doc source
1887 CXmlMemoryDocSink memorySink(pConfigurableDomains);
1888
1889 bool bProcessSuccess = memorySink.process(*pSource, xmlDomainSerializingContext);
1890
1891 if (!bProcessSuccess) {
1892
1893 //Cleanup
1894 pConfigurableDomains->clean();
1895
1896 } else {
1897
1898 // Validate domains after XML import
1899 pConfigurableDomains->validate(_pMainParameterBlackboard);
1900
Patrick Benavoli68a91282011-08-31 11:23:23 +02001901 }
1902
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001903 delete pSource;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001904
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001905 return bProcessSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001906}
1907
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001908bool CParameterMgr::exportDomainsXml(string& strXmlDest, bool bWithSettings, bool bToFile,
1909 string& strError) const
Patrick Benavoli68a91282011-08-31 11:23:23 +02001910{
1911 // check path is absolute
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001912 if (bToFile && strXmlDest[0] != '/') {
Patrick Benavoli68a91282011-08-31 11:23:23 +02001913
1914 strError = "Please provide absolute path";
1915
1916 return false;
1917 }
1918
1919 // Root element
1920 const CConfigurableDomains* pConfigurableDomains = getConstConfigurableDomains();
1921
1922 // Get Schema file associated to root element
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001923 string strXmlSchemaFilePath = _strSchemaFolderLocation + "/" +
1924 pConfigurableDomains->getKind() + ".xsd";
Patrick Benavoli68a91282011-08-31 11:23:23 +02001925
1926 // Context
1927 CXmlDomainSerializingContext xmlDomainSerializingContext(strError, bWithSettings);
1928
1929 // Value space
1930 xmlDomainSerializingContext.setValueSpaceRaw(_bValueSpaceIsRaw);
1931
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02001932 // Output raw format
1933 xmlDomainSerializingContext.setOutputRawFormat(_bOutputRawFormatIsHex);
1934
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02001935 // Use a doc source by loading data from instantiated Configurable Domains
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001936 CXmlMemoryDocSource memorySource(pConfigurableDomains, pConfigurableDomains->getKind(),
1937 strXmlSchemaFilePath, "parameter-framework", getVersion());
Patrick Benavoli68a91282011-08-31 11:23:23 +02001938
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001939 // Xml Sink
1940 CXmlDocSink* pSink;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001941
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001942 if (bToFile) {
1943
1944 // Use a doc sink to write the doc data in a file
1945 pSink = new CXmlFileDocSink(strXmlDest);
1946
1947 } else {
1948
1949 // Use a doc sink to write the doc data in a string
1950 pSink = new CXmlStringDocSink(strXmlDest);
Patrick Benavoli68a91282011-08-31 11:23:23 +02001951 }
1952
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02001953 bool bProcessSuccess = pSink->process(memorySource, xmlDomainSerializingContext);
1954
1955 delete pSink;
1956 return bProcessSuccess;
Patrick Benavoli68a91282011-08-31 11:23:23 +02001957}
1958
1959// Binary Import/Export
1960bool CParameterMgr::importDomainsBinary(const string& strFileName, string& strError)
1961{
1962 // Check tuning mode
1963 if (!checkTuningModeOn(strError)) {
1964
1965 return false;
1966 }
1967 // check path is absolute
1968 if (strFileName[0] != '/') {
1969
1970 strError = "Please provide absolute path";
1971
1972 return false;
1973 }
1974 // Root element
1975 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1976
1977 // Serialize in
1978 return pConfigurableDomains->serializeSettings(strFileName, false, _uiStructureChecksum, strError);
1979}
1980
1981bool CParameterMgr::exportDomainsBinary(const string& strFileName, string& strError)
1982{
1983 // check path is absolute
1984 if (strFileName[0] != '/') {
1985
1986 strError = "Please provide absolute path";
1987
1988 return false;
1989 }
Patrick Benavoli68a91282011-08-31 11:23:23 +02001990
Patrick Benavoli68a91282011-08-31 11:23:23 +02001991 // Root element
1992 CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
1993
1994 // Serialize out
1995 return pConfigurableDomains->serializeSettings(strFileName, true, _uiStructureChecksum, strError);
1996}
1997
1998// For tuning, check we're in tuning mode
1999bool CParameterMgr::checkTuningModeOn(string& strError) const
2000{
2001 // Tuning Mode on?
2002 if (!_bTuningModeIsOn) {
2003
2004 strError = "Tuning Mode must be on";
2005
2006 return false;
2007 }
2008 return true;
2009}
2010
Patrick Benavoli065264a2011-11-20 15:46:41 +01002011// Tuning mutex dynamic parameter handling
2012pthread_mutex_t* CParameterMgr::getBlackboardMutex()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002013{
Patrick Benavoli065264a2011-11-20 15:46:41 +01002014 return &_blackboardMutex;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002015}
2016
Patrick Benavoli065264a2011-11-20 15:46:41 +01002017// Blackboard reference (dynamic parameter handling)
2018CParameterBlackboard* CParameterMgr::getParameterBlackboard()
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002019{
Patrick Benavoli065264a2011-11-20 15:46:41 +01002020 return _pMainParameterBlackboard;
Patrick Benavoli4bed9212011-10-27 14:18:00 +02002021}
2022
Patrick Benavoli68a91282011-08-31 11:23:23 +02002023// Dynamic creation library feeding
2024void CParameterMgr::feedElementLibraries()
2025{
2026 // Global Configuration handling
2027 CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
2028
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002029 pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +01002030 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSubsystemPlugins>("SubsystemPlugins"));
2031 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CPluginLocation>("Location"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002032 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
2033 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
2034 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));
2035 pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("BinarySettingsFileLocation"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02002036
2037 _pElementLibrarySet->addElementLibrary(pFrameworkConfigurationLibrary);
2038
2039 // Parameter creation
2040 CElementLibrary* pParameterCreationLibrary = new CElementLibrary;
2041
2042 pParameterCreationLibrary->addElementBuilder(new CSubsystemElementBuilder(getSystemClass()->getSubsystemLibrary()));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002043 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentType>("ComponentType"));
2044 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CComponentInstance>("Component"));
2045 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterType>("BitParameter"));
2046 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBitParameterBlockType>("BitParameterBlock"));
Patrick Benavoli1352ae52011-10-21 16:48:04 +02002047 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CStringParameterType>("StringParameter"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002048 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CParameterBlockType>("ParameterBlock"));
2049 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CBooleanParameterType>("BooleanParameter"));
2050 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CIntegerParameterType>("IntegerParameter"));
Patrick Benavoliee65e6d2011-11-20 18:52:24 +01002051 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CLinearParameterAdaptation>("LinearAdaptation"));
Patrick Benavoli9fc3c0d2011-10-27 14:27:27 +02002052 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CEnumParameterType>("EnumParameter"));
Patrick Benavoli68808c62012-02-02 17:12:41 +01002053 pParameterCreationLibrary->addElementBuilder(new TElementBuilderTemplate<CEnumValuePair>("ValuePair"));
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002054 pParameterCreationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CFixedPointParameterType>("FixedPointParameter"));
2055 pParameterCreationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CXmlFileIncluderElement>("SubsystemInclude"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02002056
2057 _pElementLibrarySet->addElementLibrary(pParameterCreationLibrary);
2058
2059 // Parameter Configuration Domains creation
2060 CElementLibrary* pParameterConfigurationLibrary = new CElementLibrary;
2061
Patrick Benavoli6ba361d2011-08-31 11:23:24 +02002062 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CConfigurableDomain>("ConfigurableDomain"));
2063 pParameterConfigurationLibrary->addElementBuilder(new TNamedElementBuilderTemplate<CDomainConfiguration>("Configuration"));
2064 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CCompoundRule>("CompoundRule"));
2065 pParameterConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CSelectionCriterionRule>("SelectionCriterionRule"));
Patrick Benavoli68a91282011-08-31 11:23:23 +02002066
2067 _pElementLibrarySet->addElementLibrary(pParameterConfigurationLibrary);
2068}
2069
2070// Remote Processor Server connection handling
2071bool CParameterMgr::handleRemoteProcessingInterface(string& strError)
2072{
2073 CAutoLog autoLog(this, "Handling remote processing interface");
2074
2075 // Start server if tuning allowed
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002076 if (getConstFrameworkConfiguration()->isTuningAllowed()) {
Patrick Benavoli68a91282011-08-31 11:23:23 +02002077
Kevin Rocardace81f82012-12-11 16:19:17 +01002078 log_info("Loading remote processor library");
Patrick Benavoli68a91282011-08-31 11:23:23 +02002079
2080 // Load library
2081 void* lib_handle = dlopen("libremote-processor.so", RTLD_NOW);
2082
2083 if (!lib_handle) {
2084
2085 // Return error
2086 const char* pcError = dlerror();
2087
2088 if (pcError) {
2089
2090 strError = pcError;
2091 } else {
2092
2093 strError = "Unable to load libremote-processor.so library";
2094 }
2095
2096 return false;
2097 }
2098
2099 CreateRemoteProcessorServer pfnCreateRemoteProcessorServer = (CreateRemoteProcessorServer)dlsym(lib_handle, "createRemoteProcessorServer");
2100
2101 if (!pfnCreateRemoteProcessorServer) {
2102
2103 strError = "libremote-process.so does not contain createRemoteProcessorServer symbol.";
2104
2105 return false;
2106 }
2107
2108 // Create server
Patrick Benavoli95ac0342011-11-07 20:32:51 +01002109 _pRemoteProcessorServer = pfnCreateRemoteProcessorServer(getConstFrameworkConfiguration()->getServerPort(), _pCommandHandler);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002110
Kevin Rocardace81f82012-12-11 16:19:17 +01002111 log_info("Starting remote processor server on port %d", getConstFrameworkConfiguration()->getServerPort());
Patrick Benavoli68a91282011-08-31 11:23:23 +02002112 // Start
2113 if (!_pRemoteProcessorServer->start()) {
2114
2115 strError = "Unable to start remote processor server";
2116
2117 return false;
2118 }
2119 }
2120
2121 return true;
2122}
2123
2124// Back synchronization
Kevin Rocardace81f82012-12-11 16:19:17 +01002125CBackSynchronizer* CParameterMgr::createBackSynchronizer() const
Patrick Benavoli68a91282011-08-31 11:23:23 +02002126{
2127#ifdef SIMULATION
2128 // In simulation, back synchronization of the blackboard won't probably work
2129 // We need to ensure though the blackboard is initialized with valid data
Kevin Rocardace81f82012-12-11 16:19:17 +01002130 return new CSimulatedBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002131#else
2132 // Real back synchronizer from subsystems
Kevin Rocardace81f82012-12-11 16:19:17 +01002133 return new CHardwareBackSynchronizer(getConstSystemClass(), _pMainParameterBlackboard);
Patrick Benavoli68a91282011-08-31 11:23:23 +02002134#endif
2135}
2136
2137// Children typwise access
2138CParameterFrameworkConfiguration* CParameterMgr::getFrameworkConfiguration()
2139{
2140 return static_cast<CParameterFrameworkConfiguration*>(getChild(EFrameworkConfiguration));
2141}
2142
2143const CParameterFrameworkConfiguration* CParameterMgr::getConstFrameworkConfiguration()
2144{
2145 return getFrameworkConfiguration();
2146}
2147
2148CSelectionCriteria* CParameterMgr::getSelectionCriteria()
2149{
2150 return static_cast<CSelectionCriteria*>(getChild(ESelectionCriteria));
2151}
2152
2153const CSelectionCriteria* CParameterMgr::getConstSelectionCriteria()
2154{
2155 return static_cast<const CSelectionCriteria*>(getChild(ESelectionCriteria));
2156}
2157
2158CSystemClass* CParameterMgr::getSystemClass()
2159{
2160 return static_cast<CSystemClass*>(getChild(ESystemClass));
2161}
2162
2163const CSystemClass* CParameterMgr::getConstSystemClass() const
2164{
2165 return static_cast<const CSystemClass*>(getChild(ESystemClass));
2166}
2167
2168// Configurable Domains
2169CConfigurableDomains* CParameterMgr::getConfigurableDomains()
2170{
2171 return static_cast<CConfigurableDomains*>(getChild(EConfigurableDomains));
2172}
2173
2174const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains()
2175{
2176 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2177}
2178
2179const CConfigurableDomains* CParameterMgr::getConstConfigurableDomains() const
2180{
2181 return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
2182}
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002183
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002184// Apply configurations
2185void CParameterMgr::doApplyConfigurations(bool bForce)
2186{
2187 CSyncerSet syncerSet;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002188
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +01002189 // Check subsystems that need resync
2190 getSystemClass()->checkForSubsystemsToResync(syncerSet);
2191
2192 // Ensure application of currently selected configurations
2193 getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce);
2194
2195 // Reset the modified status of the current criteria to indicate that a new configuration has been applied
2196 getSelectionCriteria()->resetModifiedStatus();
2197}
2198
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002199bool CParameterMgr::getSystemClassXMLString(string& strResult)
2200{
2201 // Root element
2202 const CSystemClass* pSystemClass = getSystemClass();
2203
2204 string strError;
2205
2206 CXmlSerializingContext xmlSerializingContext(strError);
2207
2208 // Use a doc source by loading data from instantiated Configurable Domains
2209 CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind());
2210
2211 // Use a doc sink that write the doc data in a string
2212 CXmlStringDocSink stringSink(strResult);
2213
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002214 bool bProcessSuccess = stringSink.process(memorySource, xmlSerializingContext);
2215
2216 if (!bProcessSuccess) {
2217
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002218 strResult = strError;
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002219
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002220 }
2221
Georges-Henri Baroncec86c12012-09-04 17:30:28 +02002222 return bProcessSuccess;
Georges-Henri Baron326a31d2012-06-28 12:05:09 +02002223}