const VehicleProperty::Property VehicleProperty::EngineSpeed = "EngineSpeed";
const VehicleProperty::Property VehicleProperty::TransmissionShiftPosition = "TransmissionShiftPosition";
const VehicleProperty::Property VehicleProperty::TransmissionGearPosition = "TransmissionGearPostion";
+const VehicleProperty::Property VehicleProperty::TransmissionMode = "TransmissionMode";
const VehicleProperty::Property VehicleProperty::ThrottlePosition = "ThrottlePosition";
const VehicleProperty::Property VehicleProperty::WheelBrake = "WheelBrake";
const VehicleProperty::Property VehicleProperty::SteeringWheelAngle = "SteeringWheelAngle";
registerProperty(EngineSpeed, [](){ return new EngineSpeedType(0); });
registerProperty(TransmissionShiftPosition, [](){ return new TransmissionShiftPositionType(Transmission::Neutral); });
registerProperty(TransmissionGearPosition, [](){ return new TransmissionGearPositionType(Transmission::Neutral); });
+ REGISTERPROPERTY(TransmissionMode,Transmission::Normal);
registerProperty(ThrottlePosition, [](){ return new ThrottlePositionType(0); });
registerProperty(WheelBrake, [](){ return new WheelBrakeType(false); });
registerProperty(SteeringWheelAngle, [](){ return new SteeringWheelAngleType(0); });
Park = 255
};
+enum Mode {
+ Normal=0,
+ Sports = 1,
+ Economy = 2,
+ OEMCustom1 = 3,
+ OEMCustom2 = 4
+};
}
namespace Power {
static const Property TransmissionGearPosition;
typedef BasicPropertyType<Transmission::TransmissionPositions> TransmissionGearPositionType;
+ static const Property TransmissionMode;
+ typedef BasicPropertyType<Transmission::Mode> TransmissionModeType;
+
/**< Throttle position 0-100% */
static const Property ThrottlePosition;
typedef BasicPropertyType<uint16_t> ThrottlePositionType;
target_link_libraries(dbussinkplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES})
install (TARGETS dbussinkplugin LIBRARY DESTINATION lib/automotive-message-broker)
+install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/amb.conf DESTINATION /etc/dbus-1/system.d )
: mInterfaceName(interfaceName), mObjectPath(objectPath), mConnection(connection)
{
interfaceMap[interfaceName] = this;
- introspectionXml ="<node>" ;
- introspectionXml += "<interface name='"+ interfaceName + "' >";
+ startRegistration();
}
void AbstractDBusInterface::addProperty(AbstractProperty* property)
const GDBusInterfaceVTable vtable = { NULL, AbstractDBusInterface::getProperty, AbstractDBusInterface::setProperty };
- guint regId = g_dbus_connection_register_object(mConnection, mObjectPath.c_str(), mInterfaceInfo, &vtable, NULL, NULL, &error);
+ regId = g_dbus_connection_register_object(mConnection, mObjectPath.c_str(), mInterfaceInfo, &vtable, NULL, NULL, &error);
if(error) throw -1;
g_assert(regId > 0);
}
+void AbstractDBusInterface::unregisterObject()
+{
+ g_dbus_connection_unregister_object(mConnection, regId);
+}
+
void AbstractDBusInterface::updateValue(AbstractProperty *property)
{
if(mConnection == nullptr)
}
}
+void AbstractDBusInterface::startRegistration()
+{
+ unregisterObject();
+ introspectionXml ="<node>" ;
+ introspectionXml += "<interface name='"+ mInterfaceName + "' >";
+}
+
GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GError** error, gpointer userData)
{
*error = NULL;
}
void registerObject();
+ void unregisterObject();
void addProperty(AbstractProperty* property);
virtual void updateValue(AbstractProperty* property);
protected:
+
+ void startRegistration();
static GVariant *getProperty(GDBusConnection * connection, const gchar * sender, const gchar *objectPath,
const gchar *interfaceName, const gchar * propertyName, GError** error,
string introspectionXml;
GDBusConnection * mConnection;
static unordered_map<string, AbstractDBusInterface*> interfaceMap;
+ guint regId;
};
#endif // ABSTRACTDBUSINTERFACE_H
AbstractProperty::AbstractProperty(string pn, string sig, Access access, AbstractDBusInterface* interface)
: mPropertyName(pn), mSignature(sig), mAccess(access), mInterface(interface)
{
- interface->addProperty(this);
+
}
void AbstractProperty::updateValue()
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+ <policy context="default">
+ <!-- <deny send_destination="org.automotive.message.broker"/> -->
+ <allow send_destination="org.automotive.message.broker"/>
+ <allow own="org.automotive.message.broker"/>
+ </policy>
+
+</busconfig>
AbstractDBusInterface* tirePressure = new TirePressureProperty(iface->re, connection);
ConstructProperty(VehiclePowerModeProperty);
ConstructProperty(TripMeterProperty);
-
-
+ ConstructProperty(TransmissionProperty);
}
static void
{
g_type_init();
- ownerId = g_bus_own_name(G_BUS_TYPE_SESSION,
+ ownerId = g_bus_own_name(G_BUS_TYPE_SYSTEM,
DBusServiceName,
G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired,
this,
NULL);
- ///TODO: instantiate other interfaces here!
}
DBusInterfaceManager::~DBusInterfaceManager()
void DBusSink::supportedChanged(PropertyList supportedProperties)
{
+ startRegistration();
for(PropertyDBusMap::iterator itr = propertyDBusMap.begin(); itr != propertyDBusMap.end(); itr++)
{
if(ListPlusPlus<VehicleProperty::Property>(&supportedProperties).contains((*itr).first))
{
routingEngine->subscribeToProperty((*itr).first, this);
+ addProperty((*itr).second);
supported = true;
}
}
}
};
+class TransmissionProperty: public DBusSink
+{
+public:
+ TransmissionProperty(AbstractRoutingEngine *re, GDBusConnection *connection)
+ :DBusSink("org.automotive.transmission","/org/automotive/runningstatus/transmission", re, connection, map<string, string>())
+ {
+ wantProperty<Transmission::TransmissionPositions>(VehicleProperty::TransmissionShiftPosition,
+ "ShiftPosition", "y", AbstractProperty::Read);
+ wantProperty<Transmission::TransmissionPositions>(VehicleProperty::TransmissionGearPosition,
+ "GearPosition", "y", AbstractProperty::Read);
+ wantProperty<Transmission::TransmissionPositions>(VehicleProperty::TransmissionMode,
+ "Mode", "y", AbstractProperty::Read);
+
+ supportedChanged(re->supported());
+ }
+};
+
#endif