aboutsummaryrefslogtreecommitdiffstats
path: root/parameter/SubsystemObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parameter/SubsystemObject.cpp')
-rw-r--r--parameter/SubsystemObject.cpp95
1 files changed, 80 insertions, 15 deletions
diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp
index fb53520..f0f1985 100644
--- a/parameter/SubsystemObject.cpp
+++ b/parameter/SubsystemObject.cpp
@@ -32,9 +32,15 @@
#include "InstanceConfigurableElement.h"
#include "ParameterBlackboard.h"
#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sstream>
CSubsystemObject::CSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement)
- : _pInstanceConfigurableElement(pInstanceConfigurableElement), _uiDataSize(pInstanceConfigurableElement->getFootPrint()), _pvSynchronizedLocation(NULL)
+ : _pInstanceConfigurableElement(pInstanceConfigurableElement),
+ _uiDataSize(pInstanceConfigurableElement->getFootPrint()),
+ _pucBlackboardLocation(NULL),
+ _uiAccessedIndex(0)
{
// Syncer
_pInstanceConfigurableElement->setSyncer(this);
@@ -45,10 +51,10 @@ CSubsystemObject::~CSubsystemObject()
_pInstanceConfigurableElement->unsetSyncer();
}
-// Synchronized location
-void CSubsystemObject::setSynchronizedLocation(void* pvSynchronizedLocation)
+// Blackboard data location
+uint8_t* CSubsystemObject::getBlackboardLocation() const
{
- _pvSynchronizedLocation = pvSynchronizedLocation;
+ return _pucBlackboardLocation;
}
// Size
@@ -57,10 +63,28 @@ uint32_t CSubsystemObject::getSize() const
return _uiDataSize;
}
+// Conversion utility
+uint32_t CSubsystemObject::asInteger(const string& strValue)
+{
+ return strtoul(strValue.c_str(), NULL, 0);
+}
+
+string CSubsystemObject::asString(uint32_t uiValue)
+{
+ ostringstream ostr;
+
+ ostr << uiValue;
+
+ return ostr.str();
+}
+
// Synchronization
bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError)
{
- assert(_pvSynchronizedLocation);
+ // Get blackboard location
+ _pucBlackboardLocation = parameterBlackboard.getLocation(_pInstanceConfigurableElement->getOffset());
+ // Access index init
+ _uiAccessedIndex = 0;
#ifdef SIMULATION
return true;
@@ -70,28 +94,69 @@ bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBac
if (bBack) {
// Read from HW
- if (!receiveFromHW()) {
+ if (!accessHW(true, strError)) {
- strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath();
+ strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError;
return false;
}
- // Write parameter block data
- parameterBlackboard.rawWrite(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset());
-
} else {
- // Read parameter block data
- parameterBlackboard.rawRead(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset());
-
// Send to HW
- if (!sendToHW()) {
+ if (!accessHW(false, strError)) {
- strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath();
+ strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError;
return false;
}
}
return true;
}
+
+// Sync to/from HW
+bool CSubsystemObject::sendToHW(string& strError)
+{
+ strError = "Send to HW interface not implemented at subsystsem level!";
+
+ return false;
+}
+
+bool CSubsystemObject::receiveFromHW(string& strError)
+{
+ strError = "Receive from HW interface not implemented at subsystsem level!";
+
+ return false;
+}
+
+// Fall back HW access
+bool CSubsystemObject::accessHW(bool bReceive, string& strError)
+{
+ // Default access falls back
+ if (bReceive) {
+
+ return receiveFromHW(strError);
+ } else {
+
+ return sendToHW(strError);
+ }
+}
+
+// Blackboard access from subsystems
+void CSubsystemObject::blackboardRead(void* pvData, uint32_t uiSize)
+{
+ assert(_uiAccessedIndex + uiSize <= _uiDataSize);
+
+ memcpy(pvData, _pucBlackboardLocation + _uiAccessedIndex, uiSize);
+
+ _uiAccessedIndex += uiSize;
+}
+
+void CSubsystemObject::blackboardWrite(const void* pvData, uint32_t uiSize)
+{
+ assert(_uiAccessedIndex + uiSize <= _uiDataSize);
+
+ memcpy(_pucBlackboardLocation + _uiAccessedIndex, pvData, uiSize);
+
+ _uiAccessedIndex += uiSize;
+}