summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/abstractpropertytype.h27
-rw-r--r--lib/mappropertytype.hpp5
-rw-r--r--plugins/dbus/abstractdbusinterface.cpp9
-rw-r--r--plugins/dbus/abstractdbusinterface.h4
-rw-r--r--plugins/dbus/abstractproperty.cpp2
-rw-r--r--plugins/dbus/dbusinterfacemanager.cpp1
-rw-r--r--plugins/dbus/dbusplugin.cpp2
-rw-r--r--plugins/dbus/drivingsafety.h10
-rw-r--r--plugins/dbus/varianttype.cpp25
-rw-r--r--plugins/dbus/varianttype.h1
-rw-r--r--plugins/exampleplugin.cpp33
-rw-r--r--plugins/exampleplugin.h1
12 files changed, 75 insertions, 45 deletions
diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h
index d636e0aa..dffdc124 100644
--- a/lib/abstractpropertytype.h
+++ b/lib/abstractpropertytype.h
@@ -38,20 +38,22 @@ namespace Zone {
enum Type {
None = 0,
- FrontRight = 1,
+ FrontLeft = 1,
FrontMiddle = 1 << 1,
- FrontLeft = 1 << 2,
- LeftRear = 1 << 3,
- MiddleRear = 1 << 4,
- RightRear = 1 << 5
+ FrontRight = 1 << 2,
+ RearLeft = 1 << 3,
+ RearMiddle = 1 << 4,
+ RearRight = 1 << 5
};
+typedef std::list<Zone::Type> ZoneList;
+
}
class AbstractPropertyType
{
public:
- AbstractPropertyType(std::string property): name(property), timestamp(-1), sequence(-1), zone(Zone::None), index(0) {}
+ AbstractPropertyType(std::string property): name(property), timestamp(-1), sequence(-1), zone(Zone::None) {}
virtual ~AbstractPropertyType() { }
@@ -89,8 +91,6 @@ public:
Zone::Type zone;
- int index;
-
void setValue(boost::any val)
{
mValue = val;
@@ -279,8 +279,9 @@ public:
timestamp = other.timestamp;
sequence = other.sequence;
sourceUuid = other.sourceUuid;
- index = other.index;
name = other.name;
+ zone = other.zone;
+
}
BasicPropertyType & operator = (BasicPropertyType const & other)
@@ -289,8 +290,8 @@ public:
timestamp = other.timestamp;
sequence = other.sequence;
sourceUuid = other.sourceUuid;
- index = other.index;
name = other.name;
+ zone = other.zone;
return *this;
}
@@ -447,8 +448,8 @@ public:
timestamp = other.timestamp;
sequence = other.sequence;
sourceUuid = other.sourceUuid;
- index = other.index;
name = other.name;
+ zone = other.zone;
}
StringPropertyType & operator = (StringPropertyType const & other)
@@ -457,8 +458,8 @@ public:
timestamp = other.timestamp;
sequence = other.sequence;
sourceUuid = other.sourceUuid;
- index = other.index;
name = other.name;
+ zone = other.zone;
return *this;
}
@@ -521,8 +522,8 @@ public:
timestamp = other.timestamp;
sequence = other.sequence;
sourceUuid = other.sourceUuid;
- index = other.index;
name = other.name;
+ zone = other.zone;
}
~ListPropertyType()
diff --git a/lib/mappropertytype.hpp b/lib/mappropertytype.hpp
index f95e4968..35bcffbb 100644
--- a/lib/mappropertytype.hpp
+++ b/lib/mappropertytype.hpp
@@ -24,6 +24,11 @@ public:
MapPropertyType<T,N> *t = new MapPropertyType<T,N>(name);
t->setMap(mMap);
+ t->timestamp = timestamp;
+ t->sequence = sequence;
+ t->sourceUuid = sourceUuid;
+ t->name = name;
+ t->zone = zone;
return t;
}
diff --git a/plugins/dbus/abstractdbusinterface.cpp b/plugins/dbus/abstractdbusinterface.cpp
index 067ff83b..74322740 100644
--- a/plugins/dbus/abstractdbusinterface.cpp
+++ b/plugins/dbus/abstractdbusinterface.cpp
@@ -48,7 +48,6 @@ AbstractDBusInterface::AbstractDBusInterface(string interfaceName, string proper
GDBusConnection* connection)
: mInterfaceName(interfaceName), mPropertyName(propertyName), mConnection(connection)
{
- interfaceMap[interfaceName] = this;
startRegistration();
mObjectPath = "/" + propertyName;
@@ -222,9 +221,9 @@ void AbstractDBusInterface::startRegistration()
GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GError** error, gpointer userData)
{
- if(interfaceMap.count(interfaceName))
+ if(interfaceMap.count(objectPath))
{
- GVariant* value = interfaceMap[interfaceName]->getProperty(propertyName);
+ GVariant* value = interfaceMap[objectPath]->getProperty(propertyName);
return value;
}
@@ -234,9 +233,9 @@ GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const
gboolean AbstractDBusInterface::setProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GVariant* value, GError** error, gpointer userData)
{
- if(interfaceMap.count(interfaceName))
+ if(interfaceMap.count(objectPath))
{
- interfaceMap[interfaceName]->setProperty(propertyName, value);
+ interfaceMap[objectPath]->setProperty(propertyName, value);
return true;
}
diff --git a/plugins/dbus/abstractdbusinterface.h b/plugins/dbus/abstractdbusinterface.h
index 463d4dd8..ca56bde9 100644
--- a/plugins/dbus/abstractdbusinterface.h
+++ b/plugins/dbus/abstractdbusinterface.h
@@ -60,7 +60,11 @@ public:
void setObjectPath(std::string op)
{
+ if(interfaceMap.find(op) != interfaceMap.end())
+ interfaceMap.erase(op);
+
mObjectPath = op;
+ interfaceMap[mObjectPath] = this;
}
std::string propertyName() { return mPropertyName; }
diff --git a/plugins/dbus/abstractproperty.cpp b/plugins/dbus/abstractproperty.cpp
index 1d417b62..d10eada2 100644
--- a/plugins/dbus/abstractproperty.cpp
+++ b/plugins/dbus/abstractproperty.cpp
@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "abstractdbusinterface.h"
AbstractProperty::AbstractProperty(string pn, string sig, Access access, AbstractDBusInterface* interface)
- : mPropertyName(pn), mSignature(sig), mAccess(access), mInterface(interface), mTimestamp(0),mValue(NULL)
+ : mPropertyName(pn), mSignature(sig), mAccess(access), mInterface(interface), mTimestamp(0),mValue(NULL), mZoneFilter(Zone::None)
{
}
diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp
index 664d949b..f4ae79f0 100644
--- a/plugins/dbus/dbusinterfacemanager.cpp
+++ b/plugins/dbus/dbusinterfacemanager.cpp
@@ -84,7 +84,6 @@ void exportProperty(AbstractRoutingEngine *re, GDBusConnection *connection)
std::list<VehicleProperty::Property> implementedProperties = t->wantsProperties();
-
std::map<std::string, std::map<Zone::Type, bool> > uniqueSourcesList = getUniqueSourcesList(re, implementedProperties);
delete t;
diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp
index b328374f..493c5cd1 100644
--- a/plugins/dbus/dbusplugin.cpp
+++ b/plugins/dbus/dbusplugin.cpp
@@ -62,7 +62,7 @@ void DBusSink::supportedChanged(PropertyList supportedProperties)
void DBusSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid)
{
- if(!propertyDBusMap.count(property) || value->zone != zoneFilter)
+ if(propertyDBusMap.find(property) == propertyDBusMap.end() || value->zone != zoneFilter)
return;
AbstractProperty* prop = propertyDBusMap[property];
diff --git a/plugins/dbus/drivingsafety.h b/plugins/dbus/drivingsafety.h
index b2308929..e16c6531 100644
--- a/plugins/dbus/drivingsafety.h
+++ b/plugins/dbus/drivingsafety.h
@@ -75,10 +75,6 @@ public:
{
/**
- * @enum const unsigned short AIRBAGLOCATION_DRIVER = 0;
- * @enum const unsigned short AIRBAGLOCATION_PASSENGER= 1;
- * @enum const unsigned short AIRBAGLOCATION_LEFTSIDE = 2;
- * @enum const unsigned short AIRBAGLOCATION_RIGHTSIDE = 3;
* @enum const unsigned short AIRBAGSTATUS_INACTIVE = 0;
* @enum const unsigned short AIRBAGSTATUS_ACTIVE = 1;
* @enum const unsigned short AIRBAGSTATUS_DEPLOYED = 2;
@@ -87,12 +83,12 @@ public:
/** @attributeName AirbagStatus
* @type object
* @access readonly
- * @attributeComment \brief MUST returns a dictionary of Airbag (byte) and Status (byte) (see AIRBAGLOCATION_* and AIRBAGSTATUS_*)
+ * @attributeComment \brief MUST returns airbag status (byte) (see AIRBAGSTATUS_*)
**/
- wantPropertyVariant(VehicleProperty::AirbagStatus, "AirbagStatus", "a{yy}", AbstractProperty::Read);
+ wantPropertyVariant(VehicleProperty::AirbagStatus, "AirbagStatus", "y", AbstractProperty::Read);
- supportedChanged(re->supported());
+ //supportedChanged(re->supported());
}
};
diff --git a/plugins/dbus/varianttype.cpp b/plugins/dbus/varianttype.cpp
index ec892254..4a8a9bec 100644
--- a/plugins/dbus/varianttype.cpp
+++ b/plugins/dbus/varianttype.cpp
@@ -3,7 +3,7 @@
#include "debugout.h"
VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, std::string propertyName, Access access, AbstractDBusInterface *interface)
- :AbstractProperty(propertyName, signature, access, interface), routingEngine(re)
+ :AbstractProperty(propertyName, signature, access, interface), routingEngine(re), mInitialized(false)
{
//set default value:
setValue(VehicleProperty::getPropertyTypeForPropertyNameValue(propertyName));
@@ -11,13 +11,25 @@ VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, std::
void VariantType::initialize()
{
+ if(mInitialized) return;
+
AsyncPropertyRequest request;
request.property = mPropertyName;
request.sourceUuidFilter = mSourceFilter;
request.zoneFilter = mZoneFilter;
using namespace std::placeholders;
- request.completed = std::bind(&VariantType::asyncReply, this, _1);
+ request.completed = [this](AsyncPropertyReply* reply)
+ {
+ if(reply->success)
+ setValue(reply->value);
+ else
+ DebugOut(DebugOut::Error)<<"get request unsuccessful for "<<reply->property<<" : "<<reply->error<<endl;
+
+ mInitialized = true;
+
+ delete reply;
+ };
routingEngine->getPropertyAsync(request);
}
@@ -51,7 +63,7 @@ void VariantType::fromGVariant(GVariant *val)
/// TODO: throw dbus exception
if(!reply->success)
{
- DebugOut(0)<<"Success fail";
+ DebugOut(DebugOut::Error)<<"setProperty fail: "<<reply->error<<endl;
}
delete reply;
};
@@ -59,10 +71,3 @@ void VariantType::fromGVariant(GVariant *val)
routingEngine->setProperty(request);
}
-void VariantType::asyncReply(AsyncPropertyReply * reply)
-{
- if(reply->success)
- setValue(reply->value);
-
- delete reply;
-}
diff --git a/plugins/dbus/varianttype.h b/plugins/dbus/varianttype.h
index c99f5ff7..4adb23de 100644
--- a/plugins/dbus/varianttype.h
+++ b/plugins/dbus/varianttype.h
@@ -18,6 +18,7 @@ public:
private:
void asyncReply(AsyncPropertyReply*);
AbstractRoutingEngine* routingEngine;
+ bool mInitialized;
};
diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp
index 039313b1..f7efa315 100644
--- a/plugins/exampleplugin.cpp
+++ b/plugins/exampleplugin.cpp
@@ -64,6 +64,21 @@ ExampleSourcePlugin::ExampleSourcePlugin(AbstractRoutingEngine* re, map<string,
addPropertySupport(VehicleProperty::DoorsPerRow, Zone::None);
addPropertySupport(VehicleProperty::AirbagStatus, Zone::FrontLeft);
+ Zone::ZoneList airbagZones;
+ airbagZones.push_back(Zone::FrontLeft);
+ airbagZones.push_back(Zone::FrontRight);
+ airbagZones.push_back(Zone::RearLeft);
+ airbagZones.push_back(Zone::RearRight);
+
+ airbagStatus[Zone::FrontLeft] = Airbag::Active;
+ airbagStatus[Zone::FrontRight] = Airbag::Inactive;
+ airbagStatus[Zone::RearLeft] = Airbag::Deployed;
+ airbagStatus[Zone::RearRight] = Airbag::Deployed;
+
+ PropertyInfo airbagInfo(0,airbagZones);
+
+ propertyInfoMap[VehicleProperty::AirbagStatus] = airbagInfo;
+
re->setSupported(supported(), this);
}
@@ -168,20 +183,24 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
}
else if(reply->property == VehicleProperty::AirbagStatus)
{
-
- if(reply->zoneFilter != Zone::None && reply->zoneFilter != Zone::FrontLeft)
+ if(airbagStatus.find(reply->zoneFilter) == airbagStatus.end())
{
reply->success = false;
reply->error = AsyncPropertyReply::ZoneNotSupported;
reply->completed(reply);
}
- VehicleProperty::AirbagStatusType temp(Airbag::Active);
- temp.zone = Zone::FrontLeft;
+ else
+ {
+
+ VehicleProperty::AirbagStatusType temp;
+ temp.setValue(airbagStatus[reply->zoneFilter]);
+ temp.zone = reply->zoneFilter;
- reply->value = &temp;
- reply->success = true;
- reply->completed(reply);
+ reply->value = &temp;
+ reply->success = true;
+ reply->completed(reply);
+ }
}
else if(reply->property == VehicleProperty::MachineGunTurretStatus)
{
diff --git a/plugins/exampleplugin.h b/plugins/exampleplugin.h
index 60304968..44832611 100644
--- a/plugins/exampleplugin.h
+++ b/plugins/exampleplugin.h
@@ -58,6 +58,7 @@ private:
void addPropertySupport(VehicleProperty::Property property, Zone::Type zone);
std::map<VehicleProperty::Property, PropertyInfo> propertyInfoMap;
+ std::map<Zone::Type, Airbag::Status> airbagStatus;
PropertyList mRequests;
PropertyList mSupported;
uint16_t velocity;