diff options
author | Kevron Rees <tripzero.kev@gmail.com> | 2013-08-15 10:18:57 -0700 |
---|---|---|
committer | Kevron Rees <tripzero.kev@gmail.com> | 2013-08-15 10:18:57 -0700 |
commit | cfe5566ec569a58bfb38324b44390f485851f29b (patch) | |
tree | ab14904af2192f2941e1289f7fc77e24bcba7b5e | |
parent | f354e864e63626c8c5d5b8d32a92548f6ea19e0e (diff) | |
parent | d5b71840d090fb0c7d9bdbc5701af3bdaec1760c (diff) | |
download | automotive-message-broker-cfe5566ec569a58bfb38324b44390f485851f29b.tar.gz |
fixed merge
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | ambd/pluginloader.cpp | 18 | ||||
-rw-r--r-- | docs/manager.txt | 7 | ||||
-rw-r--r-- | plugins/dbus/abstractdbusinterface.cpp | 58 | ||||
-rw-r--r-- | plugins/dbus/abstractdbusinterface.h | 5 | ||||
-rw-r--r-- | plugins/dbus/abstractproperty.h | 7 | ||||
-rw-r--r-- | plugins/dbus/automotivemanager.cpp | 4 | ||||
-rw-r--r-- | plugins/dbus/basicproperty.h | 1 | ||||
-rw-r--r-- | plugins/dbus/custompropertyinterface.cpp | 2 | ||||
-rw-r--r-- | plugins/dbus/dbusinterfacemanager.cpp | 64 | ||||
-rw-r--r-- | plugins/dbus/dbusinterfacemanager.h | 15 | ||||
-rw-r--r-- | plugins/dbus/dbusplugin.cpp | 3 | ||||
-rw-r--r-- | plugins/dbus/dbusplugin.h | 2 | ||||
-rw-r--r-- | plugins/dbus/uncategorizedproperty.cpp | 2 | ||||
-rw-r--r-- | plugins/dbus/varianttype.cpp | 4 | ||||
-rw-r--r-- | plugins/dbus/varianttype.h | 2 | ||||
-rw-r--r-- | plugins/dbus/vehicleinfo.h | 4 | ||||
-rw-r--r-- | plugins/demosink/demosinkplugin.cpp | 1 | ||||
-rw-r--r-- | plugins/exampleplugin.cpp | 22 | ||||
-rw-r--r-- | plugins/wheel/wheelplugin.cpp | 61 |
20 files changed, 193 insertions, 91 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 67f6da06..f33d9098 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_BUILD_TYPE, Debug) include(FindPkgConfig) set(PROJECT_NAME "automotive-message-broker") -set(PROJECT_VERSION "0.9.9") +set(PROJECT_VERSION "0.9.13") set(PROJECT_CODENAME "chevelle") add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}") diff --git a/ambd/pluginloader.cpp b/ambd/pluginloader.cpp index 62ab14fd..be52bbb7 100644 --- a/ambd/pluginloader.cpp +++ b/ambd/pluginloader.cpp @@ -130,8 +130,8 @@ PluginLoader::PluginLoader(string configFile, AbstractRoutingEngine* re, int arg DebugOut() << "plugin config key: " << key << "value:" << valstr << endl; configurationMap[key] = valstr; } - json_object *pathobject = json_object_object_get(obj,"path"); - string path = string(json_object_get_string(pathobject)); + + string path = configurationMap["path"]; AbstractSource* plugin = loadPlugin<AbstractSource*>(path,configurationMap); @@ -139,11 +139,10 @@ PluginLoader::PluginLoader(string configFile, AbstractRoutingEngine* re, int arg { mSources.push_back(plugin); } - json_object_put(pathobject); } DebugOut() << "Trying to free obj" << endl; - //json_object_put(sourcesobject); + json_object_put(sourcesobject); DebugOut() << "Done first" << endl; ///read the sinks: @@ -181,8 +180,7 @@ PluginLoader::PluginLoader(string configFile, AbstractRoutingEngine* re, int arg } - json_object *pathobject = json_object_object_get(obj,"path"); - string path = string(json_object_get_string(pathobject)); + string path = configurationMap["path"]; AbstractSinkManager* plugin = loadPlugin<AbstractSinkManager*>(path, configurationMap); @@ -190,14 +188,10 @@ PluginLoader::PluginLoader(string configFile, AbstractRoutingEngine* re, int arg { throw std::runtime_error("plugin is not a SinkManager"); } - json_object_put(pathobject); - //json_object_put(obj); - } - DebugOut() << "Trying to free list" << endl; - array_list_free(sinkslist); + DebugOut() << "Trying to free obj" << endl; - //json_object_put(sinksobject); + json_object_put(sinksobject); DebugOut() << "Done" << endl; diff --git a/docs/manager.txt b/docs/manager.txt index 903649c5..80869fc7 100644 --- a/docs/manager.txt +++ b/docs/manager.txt @@ -4,5 +4,8 @@ Object Path: / Methods: - ObjectPath findObject(string property) - returns object path representing the property. + ObjectPath findProperty(string objectName) + returns object path representing the object name. + + Array{String} list() + returns list of supported object names diff --git a/plugins/dbus/abstractdbusinterface.cpp b/plugins/dbus/abstractdbusinterface.cpp index 1a873014..921d6a45 100644 --- a/plugins/dbus/abstractdbusinterface.cpp +++ b/plugins/dbus/abstractdbusinterface.cpp @@ -37,16 +37,33 @@ static void handleMethodCall(GDBusConnection *connection, GDBusMethodInvocation *invocation, gpointer user_data) { + AbstractDBusInterface* iface = static_cast<AbstractDBusInterface*>(user_data); std::string method = method_name; + if(method == "getHistory") + { + double beginTime = 0; + double endTime = 0; + + g_variant_get(parameters, "(dd)", &beginTime, &endTime); + + auto propertyList = iface->getAmbProperties(); + +// auto cb = [&invocation](std::list<>){}; + + for(auto itr = propertyList.begin(); itr != propertyList.end(); itr++) + { + } + //AsyncRangePropertyRequest + } } AbstractDBusInterface::AbstractDBusInterface(string interfaceName, string op, GDBusConnection* connection) - : mInterfaceName(interfaceName), mObjectPath(op), mConnection(connection), supported(false) + : mInterfaceName(interfaceName), mObjectPath(op), mConnection(connection), supported(false), mTime(0) { interfaceMap[interfaceName] = this; startRegistration(); @@ -76,9 +93,10 @@ void AbstractDBusInterface::addProperty(AbstractProperty* property) properties[property->name()] = property; - if(!ListPlusPlus<string>(&mimplementedProperties).contains(property->name())) + if(!ListPlusPlus<string>(&mimplementedProperties).contains(property->ambPropertyName())) { - mimplementedProperties.push_back(property->name()); + std::string pname = property->ambPropertyName(); + mimplementedProperties.push_back(pname); } } @@ -163,6 +181,7 @@ void AbstractDBusInterface::updateValue(AbstractProperty *property) g_variant_builder_init(&builder, G_VARIANT_TYPE_DICTIONARY); g_variant_builder_add(&builder, "{sv}", property->name().c_str(), val); + g_variant_builder_add(&builder, "{sv}", "Time", g_variant_new("(d)", mTime) ); GError *error2 = NULL; @@ -210,22 +229,51 @@ bool AbstractDBusInterface::implementsProperty(string property) return false; } +std::list<std::string> AbstractDBusInterface::getAmbProperties() +{ + std::list<std::string> list; + + for(auto itr = properties.begin(); itr != properties.end(); itr++) + { + AbstractProperty* prop = (*itr).second; + list.push_back(prop->ambPropertyName()); + } + + return list; +} + void AbstractDBusInterface::startRegistration() { unregisterObject(); introspectionXml ="<node>" ; - introspectionXml += "<interface name='"+ mInterfaceName + "' >"; + introspectionXml += "<interface name='"+ mInterfaceName + "' >" + + "<property type='d' name='Time' access='read' />" + "<method name='getHistory'>" + " <arg type='d' direction='in' name='beginTimestamp' />" + " <arg type='d' direction='in' name='endTimestamp' />" + "</method>"; } GVariant* AbstractDBusInterface::getProperty(GDBusConnection* connection, const gchar* sender, const gchar* objectPath, const gchar* interfaceName, const gchar* propertyName, GError** error, gpointer userData) { + std::string pn = propertyName; + if(pn == "Time") + { + double time = interfaceMap[interfaceName]->time(); + + GVariant* value = g_variant_new("(d)", time); + return value; + } + if(interfaceMap.count(interfaceName)) { GVariant* value = interfaceMap[interfaceName]->getProperty(propertyName); return value; } - debugOut("No interface for" + string(interfaceName)); + + DebugOut(DebugOut::Error)<<"No interface for" + string(interfaceName)<<endl; return nullptr; } diff --git a/plugins/dbus/abstractdbusinterface.h b/plugins/dbus/abstractdbusinterface.h index de1d7703..a97a1964 100644 --- a/plugins/dbus/abstractdbusinterface.h +++ b/plugins/dbus/abstractdbusinterface.h @@ -63,6 +63,10 @@ public: bool isSupported() { return supported; } + std::list<string> getAmbProperties(); + + double time() { return mTime; } + protected: void startRegistration(); @@ -80,6 +84,7 @@ protected: unordered_map<string, AbstractProperty*> properties; bool supported; + double mTime; private: string mInterfaceName; diff --git a/plugins/dbus/abstractproperty.h b/plugins/dbus/abstractproperty.h index 41d4f0ca..aee9b7a1 100644 --- a/plugins/dbus/abstractproperty.h +++ b/plugins/dbus/abstractproperty.h @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "debugout.h" #include "abstractpropertytype.h" +#include "vehicleproperty.h" class AbstractDBusInterface; @@ -61,6 +62,11 @@ public: return mPropertyName; } + virtual VehicleProperty::Property ambPropertyName() + { + return mAmbPropertyName; + } + virtual Access access() { return mAccess; @@ -112,6 +118,7 @@ protected: boost::any mAnyValue; string mPropertyName; + VehicleProperty::Property mAmbPropertyName; string mSignature; SetterFunc mSetterFunc; Access mAccess; diff --git a/plugins/dbus/automotivemanager.cpp b/plugins/dbus/automotivemanager.cpp index 9b3fdf12..68710f01 100644 --- a/plugins/dbus/automotivemanager.cpp +++ b/plugins/dbus/automotivemanager.cpp @@ -4,7 +4,7 @@ static const gchar introspection_xml[] = "<node>" " <interface name='org.automotive.Manager'>" - " <method name='findObject'>" + " <method name='findProperty'>" " <arg type='s' name='searchstring' direction='in'/>" " <arg type='o' name='response' direction='out'/>" " </method>" @@ -26,7 +26,7 @@ static void handleMethodCall(GDBusConnection *connection, std::string method = method_name; - if(method == "findObject") + if(method == "findProperty") { gchar* arg; diff --git a/plugins/dbus/basicproperty.h b/plugins/dbus/basicproperty.h index 7afd9ffb..7d572a28 100644 --- a/plugins/dbus/basicproperty.h +++ b/plugins/dbus/basicproperty.h @@ -92,7 +92,6 @@ public: } private: - VehicleProperty::Property mAmbPropertyName; AbstractRoutingEngine* routingEngine; }; diff --git a/plugins/dbus/custompropertyinterface.cpp b/plugins/dbus/custompropertyinterface.cpp index a808b77b..b2ef92fb 100644 --- a/plugins/dbus/custompropertyinterface.cpp +++ b/plugins/dbus/custompropertyinterface.cpp @@ -19,7 +19,7 @@ CustomPropertyInterface::CustomPropertyInterface(VehicleProperty::Property prop, std::string signature = g_variant_get_type_string(temp->toVariant()); - propertyDBusMap[prop] = new VariantType(re, signature, prop, VariantType::ReadWrite, this); + propertyDBusMap[prop] = new VariantType(re, signature, prop, prop, VariantType::ReadWrite, this); delete temp; } diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp index 542492cd..0fa6caa1 100644 --- a/plugins/dbus/dbusinterfacemanager.cpp +++ b/plugins/dbus/dbusinterfacemanager.cpp @@ -45,6 +45,8 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d { DBusInterfaceManager* iface = static_cast<DBusInterfaceManager*>(user_data); + iface->connection = connection; + new AutomotiveManager(connection); /// properties: @@ -94,32 +96,7 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d ConstructProperty(OccupantStatusProperty); ConstructProperty(ObstacleDistanceProperty); - PropertyList list = VehicleProperty::customProperties(); - - for (auto itr = list.begin(); itr != list.end(); itr++) - { - VehicleProperty::Property prop = *itr; - - new CustomPropertyInterface(prop,iface->re,connection); - } - - - /// Create objects for unimplemented properties: - - PropertyList capabilitiesList = VehicleProperty::capabilities(); - - for (auto itr = capabilitiesList.begin(); itr != capabilitiesList.end(); itr++) - { - VehicleProperty::Property prop = *itr; - - PropertyList implemented = AbstractDBusInterface::implementedProperties(); - - if(!ListPlusPlus<VehicleProperty::Property>(&implemented).contains(prop)) - { - new UncategorizedPropertyInterface(prop, iface->re, connection); - } - } - + iface->supportedChanged(PropertyList()); } static void @@ -142,8 +119,8 @@ on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data -DBusInterfaceManager::DBusInterfaceManager(AbstractRoutingEngine* engine) - :re(engine) +DBusInterfaceManager::DBusInterfaceManager(AbstractRoutingEngine* engine,std::map<std::string,std::string> config) + :AbstractSink(engine,config),re(engine) { g_type_init(); @@ -163,4 +140,35 @@ DBusInterfaceManager::~DBusInterfaceManager() g_bus_unown_name(ownerId); } +void DBusInterfaceManager::supportedChanged(PropertyList supportedProperties) +{ + + PropertyList list = VehicleProperty::customProperties(); + PropertyList implemented = AbstractDBusInterface::implementedProperties(); + + for (auto itr = list.begin(); itr != list.end(); itr++) + { + VehicleProperty::Property prop = *itr; + + if(!ListPlusPlus<VehicleProperty::Property>(&implemented).contains(prop)) + { + new CustomPropertyInterface(prop,re,connection); + } + } + + /// Create objects for unimplemented properties: + + PropertyList capabilitiesList = VehicleProperty::capabilities(); + + for (auto itr = capabilitiesList.begin(); itr != capabilitiesList.end(); itr++) + { + VehicleProperty::Property prop = *itr; + + if(!ListPlusPlus<VehicleProperty::Property>(&implemented).contains(prop)) + { + new UncategorizedPropertyInterface(prop, re, connection); + } + } +} + diff --git a/plugins/dbus/dbusinterfacemanager.h b/plugins/dbus/dbusinterfacemanager.h index 45804fef..94e67347 100644 --- a/plugins/dbus/dbusinterfacemanager.h +++ b/plugins/dbus/dbusinterfacemanager.h @@ -20,22 +20,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #ifndef DBUSINTERFACEMANAGER_H #define DBUSINTERFACEMANAGER_H +#include "abstractsink.h" +#include "gio/gio.h" + class AbstractRoutingEngine; -class DBusInterfaceManager +class DBusInterfaceManager: public AbstractSink { public: - DBusInterfaceManager(AbstractRoutingEngine* re); + DBusInterfaceManager(AbstractRoutingEngine* re, std::map<string, string> config); ~DBusInterfaceManager(); AbstractRoutingEngine* re; + + /// From AbstractSink: + virtual string uuid(){ return "DBusInterfaceManager"; } + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) { } + virtual void supportedChanged(PropertyList supportedProperties); + GDBusConnection * connection; + private: unsigned int ownerId; + }; #endif // DBUSINTERFACEMANAGER_H diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp index bb91c98c..da0e1a0d 100644 --- a/plugins/dbus/dbusplugin.cpp +++ b/plugins/dbus/dbusplugin.cpp @@ -61,6 +61,7 @@ void DBusSink::propertyChanged(VehicleProperty::Property property, AbstractPrope AbstractProperty* prop = propertyDBusMap[property]; prop->setValue(value); + mTime = value->timestamp; } std::string DBusSink::uuid() @@ -71,5 +72,5 @@ std::string DBusSink::uuid() DBusSinkManager::DBusSinkManager(AbstractRoutingEngine *engine, map<string, string> config) :AbstractSinkManager(engine, config) { - DBusInterfaceManager* manager = new DBusInterfaceManager(engine); + DBusInterfaceManager* manager = new DBusInterfaceManager(engine, config); } diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h index ea8cd963..45e238b7 100644 --- a/plugins/dbus/dbusplugin.h +++ b/plugins/dbus/dbusplugin.h @@ -54,7 +54,7 @@ protected: void wantPropertyVariant(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access) { - propertyDBusMap[property] = new VariantType(routingEngine, signature, property, access, this); + propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access, this); } PropertyDBusMap propertyDBusMap; diff --git a/plugins/dbus/uncategorizedproperty.cpp b/plugins/dbus/uncategorizedproperty.cpp index fdbbe8b4..6e7ef6e1 100644 --- a/plugins/dbus/uncategorizedproperty.cpp +++ b/plugins/dbus/uncategorizedproperty.cpp @@ -15,7 +15,7 @@ UncategorizedPropertyInterface::UncategorizedPropertyInterface(VehicleProperty:: std::string signature = g_variant_get_type_string(temp->toVariant()); - propertyDBusMap[prop] = new VariantType(re, signature, prop, VariantType::ReadWrite, this); + propertyDBusMap[prop] = new VariantType(re, signature, prop, prop, VariantType::ReadWrite, this); delete temp; diff --git a/plugins/dbus/varianttype.cpp b/plugins/dbus/varianttype.cpp index 5f568534..a47aefc0 100644 --- a/plugins/dbus/varianttype.cpp +++ b/plugins/dbus/varianttype.cpp @@ -2,12 +2,12 @@ #include "abstractroutingengine.h" #include "debugout.h" -VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, std::string propertyName, Access access, AbstractDBusInterface *interface) +VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, std::string propertyName, string ambPropName, Access access, AbstractDBusInterface *interface) :AbstractProperty(propertyName, signature, access, interface),routingEngine(re) { //set default value: setValue(VehicleProperty::getPropertyTypeForPropertyNameValue(propertyName)); - + mAmbPropertyName = ambPropName; AsyncPropertyRequest request; request.property = mPropertyName; diff --git a/plugins/dbus/varianttype.h b/plugins/dbus/varianttype.h index ad26dd98..7a290897 100644 --- a/plugins/dbus/varianttype.h +++ b/plugins/dbus/varianttype.h @@ -8,7 +8,7 @@ class VariantType: public AbstractProperty { public: - VariantType(AbstractRoutingEngine* re, string signature, string propertyName, Access access, AbstractDBusInterface* interface); + VariantType(AbstractRoutingEngine* re, string signature, string propertyName, string ambPropName, Access access, AbstractDBusInterface* interface); GVariant* toGVariant(); void fromGVariant(GVariant *value); diff --git a/plugins/dbus/vehicleinfo.h b/plugins/dbus/vehicleinfo.h index 65e8958e..a5f0904f 100644 --- a/plugins/dbus/vehicleinfo.h +++ b/plugins/dbus/vehicleinfo.h @@ -19,14 +19,14 @@ public: * @attributeComment \brief MUST return World Manufacturer Identifier (WMI) * @attributeComment WMI is defined by SAE ISO 3780:2009. 3 characters. **/ - wantPropertyString(VehicleProperty::WMI, "WMI", "s", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::WMI, "WMI", "s", AbstractProperty::Read); /** @attributeName VIN * @type DOMString * @access readonly * @attributeComment \brief MUST return Vehicle Identification Number (VIN) as defined by ISO 3779. 17 characters. **/ - wantPropertyString(VehicleProperty::VIN, "VIN", "s", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::VIN, "VIN", "s", AbstractProperty::Read); supportedChanged(re->supported()); } diff --git a/plugins/demosink/demosinkplugin.cpp b/plugins/demosink/demosinkplugin.cpp index 13675ba7..d8f40577 100644 --- a/plugins/demosink/demosinkplugin.cpp +++ b/plugins/demosink/demosinkplugin.cpp @@ -58,6 +58,7 @@ DemoSink::DemoSink(AbstractRoutingEngine* re, map<string, string> config) { routingEngine->subscribeToProperty(VehicleProperty::ButtonEvent, this); routingEngine->subscribeToProperty(VehicleProperty::TurnSignal, this); + routingEngine->subscribeToProperty(VehicleProperty::MachineGunTurretStatus, this); } DemoSink::~DemoSink() diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index d0668f5c..8ee40550 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -33,6 +33,7 @@ uint16_t steeringWheelAngle=0; uint16_t throttlePos = 0; uint16_t engineCoolant = 40; bool machineGun = false; +uint16_t exteriorBrightness = 500; static gboolean timeoutCallback(gpointer data) { @@ -70,8 +71,6 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) { DebugOut()<<"ExampleSource: getPropertyAsync called for property: "<<reply->property<<endl; - - if(reply->property == VehicleProperty::VehicleSpeed) { VehicleProperty::VehicleSpeedType temp(velocity); @@ -171,6 +170,13 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) reply->success = true; reply->completed(reply); } + else if(reply->property == VehicleProperty::ExteriorBrightness) + { + VehicleProperty::ExteriorBrightnessType temp(exteriorBrightness); + reply->value = &temp; + reply->success = true; + reply->completed(reply); + } } void ExampleSourcePlugin::getRangePropertyAsync(AsyncRangePropertyReply *reply) @@ -206,6 +212,7 @@ PropertyList ExampleSourcePlugin::supported() props.push_back(VehicleProperty::DoorsPerRow); props.push_back(VehicleProperty::AirbagStatus); props.push_back(VehicleProperty::MachineGunTurretStatus); + props.push_back(VehicleProperty::ExteriorBrightness); return props; } @@ -229,6 +236,7 @@ void ExampleSourcePlugin::randomizeProperties() steeringWheelAngle = 1 + (359.00 * (rand() / (RAND_MAX + 1.0))); throttlePos = 1 + (100.00 * (rand() / (RAND_MAX + 1.0))); engineCoolant = 1 + (40.00 * (rand() / (RAND_MAX + 140.0))); + exteriorBrightness = 1 + (5000 * (rand() / (RAND_MAX + 1.0))); DebugOut()<<"setting velocity to: "<<velocity<<endl; DebugOut()<<"setting enginespeed to: "<<engineSpeed<<endl; @@ -241,17 +249,10 @@ void ExampleSourcePlugin::randomizeProperties() VehicleProperty::ThrottlePositionType tp(throttlePos); VehicleProperty::EngineCoolantTemperatureType ec(engineCoolant); VehicleProperty::MachineGunTurretStatusType mgt(machineGun); + VehicleProperty::ExteriorBrightnessType eb(exteriorBrightness); machineGun = !machineGun; - vel.timestamp = amb::currentTime(); - es.timestamp = amb::currentTime(); - ac.timestamp = amb::currentTime(); - swa.timestamp = amb::currentTime(); - tsp.timestamp = amb::currentTime(); - tp.timestamp = amb::currentTime(); - ec.timestamp = amb::currentTime(); - routingEngine->updateProperty(VehicleProperty::VehicleSpeed, &vel, uuid()); routingEngine->updateProperty(VehicleProperty::EngineSpeed, &es, uuid()); routingEngine->updateProperty(VehicleProperty::AccelerationX, &ac, uuid()); @@ -260,4 +261,5 @@ void ExampleSourcePlugin::randomizeProperties() routingEngine->updateProperty(VehicleProperty::ThrottlePosition, &tp, uuid()); routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, &ec, uuid()); //routingEngine->updateProperty(VehicleProperty::MachineGunTurretStatus, &mgt); + routingEngine->updateProperty(VehicleProperty::ExteriorBrightness, &eb, uuid()); } diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp index e06f69f4..78d4ec6d 100644 --- a/plugins/wheel/wheelplugin.cpp +++ b/plugins/wheel/wheelplugin.cpp @@ -310,13 +310,16 @@ void WheelPrivate::newButtonValue(char number, bool val) { switch (number) { case 0: //Gear attach diamond down + checkButtonEvents(); break; case 1: //Gear attach diamond left checkButtonEvents(); break; case 2: //Gear attach diamond right + checkButtonEvents(); break; case 3: //Gear attach diamond up + checkButtonEvents(); break; case 11://Gear attach red button row, left button checkButtonEvents(); @@ -331,10 +334,12 @@ void WheelPrivate::newButtonValue(char number, bool val) checkButtonEvents(); break; case 4: //Right paddle shifter - this->changeMachineGuns(val); + this->changeGear(Transmission::TransmissionPositions(this->currentGear+1)); + changeMachineGuns(val); break; case 5: //Left paddle shifter - this->changeMachineGuns(val); + this->changeGear(Transmission::TransmissionPositions(this->currentGear-1)); + break; case 6: //Right upper wheel button this->changeTurnSignal(TurnSignals::Right, val); @@ -566,27 +571,45 @@ uint16_t WheelPrivate::calcRPM() void WheelPrivate::checkButtonEvents() { - //cout << "checkButtonEvents, b1/b11/b8/b9/b10 " << (int)this->button[1] << " " << (int)this->button[11] << " " << (int)this->button[8] << " " << (int)this->button[9] << " " << (int)this->button[10] << endl; + if (this->button[0]) { + // cout << "Inside button 11!" << endl; + VehicleProperty::ButtonEventType tempButton(ButtonEvents::StopButton); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } if (this->button[1]) { - if (this->button[11]) { // cout << "Inside button 11!" << endl; - VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset1Button); - this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); - } - if (this->button[8]) { + VehicleProperty::ButtonEventType tempButton(ButtonEvents::PrevButton); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } + if (this->button[2]) { + // cout << "Inside button 11!" << endl; + VehicleProperty::ButtonEventType tempButton(ButtonEvents::SkipButton); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } + if (this->button[3]) { + // cout << "Inside button 11!" << endl; + VehicleProperty::ButtonEventType tempButton(ButtonEvents::PlayButton); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } + if (this->button[11]) { + // cout << "Inside button 11!" << endl; + VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset1Button); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } + if (this->button[8]) { // cout << "Inside button 8!" << endl; - VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset2Button); - this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); - } - if (this->button[9]) { + VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset2Button); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } + if (this->button[9]) { // cout << "Inside button 9!" << endl; - VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset3Button); - this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); - } - if (this->button[10]) { + VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset3Button); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); + } + if (this->button[10]) { // cout << "Inside button 10!" << endl; - VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset4Button); - this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); - } + VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset4Button); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); } + } |