diff options
author | Kevron Rees <tripzero.kev@gmail.com> | 2012-08-28 16:00:50 -0700 |
---|---|---|
committer | Kevron Rees <tripzero.kev@gmail.com> | 2012-08-28 16:00:50 -0700 |
commit | cda158a2629eb52b0c57ccd253649737fd63c75f (patch) | |
tree | 86e38c6b0e9e58c266c861198e845f6a9ac56cf3 | |
parent | eda84a1f1c029687c3f1963ddd012105927a9da3 (diff) | |
download | automotive-message-broker-cda158a2629eb52b0c57ccd253649737fd63c75f.tar.gz |
more updating. still broken
-rw-r--r-- | lib/abstractsource.h | 1 | ||||
-rw-r--r-- | lib/vehicleproperty.h | 6 | ||||
-rw-r--r-- | plugins/dbus/abstractproperty.h | 7 | ||||
-rw-r--r-- | plugins/dbus/dbusplugin.cpp | 2 | ||||
-rw-r--r-- | plugins/dbus/dbusplugin.h | 2 | ||||
-rw-r--r-- | plugins/exampleplugin.cpp | 11 | ||||
-rw-r--r-- | plugins/exampleplugin.h | 1 | ||||
-rw-r--r-- | plugins/websocketsink/websocketsink.cpp | 2 | ||||
-rw-r--r-- | plugins/websocketsink/websocketsink.h | 2 | ||||
-rw-r--r-- | plugins/wheel/wheelplugin.cpp | 56 | ||||
-rw-r--r-- | plugins/wheel/wheelplugin.h | 2 |
11 files changed, 42 insertions, 50 deletions
diff --git a/lib/abstractsource.h b/lib/abstractsource.h index 34ff456b..3ec399a1 100644 --- a/lib/abstractsource.h +++ b/lib/abstractsource.h @@ -44,7 +44,6 @@ public: ///pure virtual methods: - virtual AbstractPropertyType getProperty(VehicleProperty::Property) = 0; virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0; virtual void setProperty(VehicleProperty::Property property, AbstractPropertyType value) = 0; virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0; diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 826f66c8..75921fc6 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -88,18 +88,23 @@ public: /**< Clutch pedal status 0=off, 1=on */ static const Property ClutchStatus; + typedef BasicPropertyType<bool> ClutchStatusType; /**< Oil pressure TODO: units */ static const Property EngineOilPressure; + typedef BasicPropertyType<uint16_t> EngineOilPressureType; /**< Engine coolant temperature in degrees celcius **/ static const Property EngineCoolantTemperature; + typedef BasicPropertyType<int> EngineCoolantTemperatureType; /**< 0=off, 1=on */ static const Property MachineGunTurretStatus; + typedef BasicPropertyType<bool> MachineGunTurretStatusType; /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */ static const Property AccelerationX; + typedef BasicPropertyType<uint16_t> AcclerationType; /**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */ static const Property AccelerationY; @@ -109,6 +114,7 @@ public: /**< Mass Air Flow. TODO: units */ static const Property MassAirFlow; + typedef BasicPropertyType<uint16_t> MassAirFlowType; static std::list<VehicleProperty::Property> capabilities(); diff --git a/plugins/dbus/abstractproperty.h b/plugins/dbus/abstractproperty.h index 921d0df0..94b65e84 100644 --- a/plugins/dbus/abstractproperty.h +++ b/plugins/dbus/abstractproperty.h @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include <glib.h> #include "debugout.h" +#include "abstractpropertytype.h" class AbstractDBusInterface; @@ -68,7 +69,7 @@ public: virtual GVariant* toGVariant() = 0; virtual void fromGVariant(GVariant *value) = 0; - void setValue(boost::any val) + void setValue(AbstractPropertyType val) { mValue = val; updateValue(); @@ -84,7 +85,7 @@ public: template<typename T> T value() { - return boost::any_cast<T>(mValue); + return mValue.value<T>(); } protected: ///methods: @@ -93,7 +94,7 @@ protected: ///methods: protected: - boost::any mValue; + AbstractPropertyType mValue; string mPropertyName; string mSignature; SetterFunc mSetterFunc; diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp index ebc92d24..f21f3d10 100644 --- a/plugins/dbus/dbusplugin.cpp +++ b/plugins/dbus/dbusplugin.cpp @@ -52,7 +52,7 @@ void DBusSink::supportedChanged(PropertyList supportedProperties) registerObject(); } -void DBusSink::propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) +void DBusSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) { if(!propertyDBusMap.count(property)) return; diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h index 2fd26f25..abd55aca 100644 --- a/plugins/dbus/dbusplugin.h +++ b/plugins/dbus/dbusplugin.h @@ -33,7 +33,7 @@ class DBusSink : public AbstractSink, public AbstractDBusInterface public: DBusSink(std::string interface, std::string path, AbstractRoutingEngine* engine, GDBusConnection* connection); virtual void supportedChanged(PropertyList supportedProperties); - virtual void propertyChanged(VehicleProperty::Property property, boost::any value, std::string uuid); + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, std::string uuid); virtual std::string uuid(); protected: diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index 0b931f21..b11bf142 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -63,17 +63,6 @@ string ExampleSourcePlugin::uuid() return "6dd4268a-c605-4a06-9034-59c1e8344c8e"; } -boost::any ExampleSourcePlugin::getProperty(VehicleProperty::Property property) -{ - if(property == VehicleProperty::VehicleSpeed) - { - return velocity; - } - else if(property == VehicleProperty::EngineSpeed) - { - return engineSpeed; - } -} void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) { diff --git a/plugins/exampleplugin.h b/plugins/exampleplugin.h index 50a3b21e..5463816c 100644 --- a/plugins/exampleplugin.h +++ b/plugins/exampleplugin.h @@ -31,7 +31,6 @@ public: ExampleSourcePlugin(AbstractRoutingEngine* re); string uuid(); - boost::any getProperty(VehicleProperty::Property property); void getPropertyAsync(AsyncPropertyReply *reply); void setProperty(VehicleProperty::Property, AbstractPropertyType); void subscribeToPropertyChanges(VehicleProperty::Property property); diff --git a/plugins/websocketsink/websocketsink.cpp b/plugins/websocketsink/websocketsink.cpp index 35ceda52..495d2d1e 100644 --- a/plugins/websocketsink/websocketsink.cpp +++ b/plugins/websocketsink/websocketsink.cpp @@ -45,7 +45,7 @@ string WebSocketSink::uuid() { return m_uuid; } -void WebSocketSink::propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) +void WebSocketSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid) { //printf("Got property:%i\n",boost::any_cast<uint16_t>(reply->value)); uint16_t velocity = boost::any_cast<uint16_t>(value); diff --git a/plugins/websocketsink/websocketsink.h b/plugins/websocketsink/websocketsink.h index 40f790c5..57c0b1ae 100644 --- a/plugins/websocketsink/websocketsink.h +++ b/plugins/websocketsink/websocketsink.h @@ -30,7 +30,7 @@ public: WebSocketSink(AbstractRoutingEngine* re,libwebsocket *wsi,string uuid,VehicleProperty::Property property,std::string ambdproperty); ~WebSocketSink(); string uuid() ; - void propertyChanged(VehicleProperty::Property property, boost::any value, string uuid); + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType value, string uuid); void supportedChanged(PropertyList supportedProperties); PropertyList subscriptions(); private: diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp index 6517ee62..db5a335f 100644 --- a/plugins/wheel/wheelplugin.cpp +++ b/plugins/wheel/wheelplugin.cpp @@ -132,13 +132,9 @@ string WheelSourcePlugin::uuid() return "c0ffee8a-c605-4a06-9034-59c1deadbeef"; } -AbstractPropertyType WheelSourcePlugin::getProperty(VehicleProperty::Property property) -{ - return this->mWheel->getProperty(property); -} - void WheelSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) { + reply->value = this->mWheel->getProperty(reply->property); reply->completed(reply); } @@ -233,32 +229,34 @@ WheelPrivate::~WheelPrivate() } -boost::any WheelPrivate::getProperty(VehicleProperty::Property propType) +AbstractPropertyType WheelPrivate::getProperty(VehicleProperty::Property propType) { if (propType == VehicleProperty::VehicleSpeed) - return BasicPropertyType<uint16_t>(this->calcCarSpeed()); + return VehicleProperty::VehicleSpeedType(this->calcCarSpeed()); else if (propType == VehicleProperty::EngineSpeed) - return BasicPropertyType<uint16_t>(this->calcRPM()); + return VehicleProperty::EngineSpeedType(this->calcRPM()); else if (propType == VehicleProperty::TransmissionShiftPosition) - return this->currentGear; + return VehicleProperty::TransmissionShiftPositionType(this->currentGear); else if (propType == VehicleProperty::ThrottlePosition) - return this->throttle; + return VehicleProperty::ThrottlePositionType(this->throttle); else if (propType == VehicleProperty::WheelBrake) - return this->brake; + return VehicleProperty::WheelBrakeType(this->brake); else if (propType == VehicleProperty::SteeringWheelAngle) - return this->steeringAngle; + return VehicleProperty::SteeringWheelAngleType(this->steeringAngle); else if (propType == VehicleProperty::TurnSignal) - return this->turnSignal; + return VehicleProperty::TurnSignalType(this->turnSignal); else if (propType == VehicleProperty::ClutchStatus) - return this->clutch; + return VehicleProperty::ClutchStatusType(this->clutch); else if (propType == VehicleProperty::EngineOilPressure) - return this->oilPSI; + return VehicleProperty::EngineOilPressureType(this->oilPSI); else if (propType == VehicleProperty::EngineCoolantTemperature) - return this->coolantTemp; + return VehicleProperty::EngineCoolantTemperatureType(this->coolantTemp); else if (propType == VehicleProperty::MachineGunTurretStatus) - return this->machineGuns; + return VehicleProperty::MachineGunTurretStatusType(this->machineGuns); else cout << "Unhandled getProperty type: " << propType << endl; + + return AbstractPropertyType(); } void WheelPrivate::newButtonValue(char number, bool val) @@ -409,7 +407,7 @@ void WheelPrivate::gotData(GAsyncResult *res) void WheelPrivate::changeMachineGuns(bool val) { this->machineGuns = val; - this->re->updateProperty(VehicleProperty::MachineGunTurretStatus, this->machineGuns); + this->re->updateProperty(VehicleProperty::MachineGunTurretStatus, VehicleProperty::MachineGunTurretStatusType(this->machineGuns)); } void WheelPrivate::changeTurnSignal(TurnSignal dir, bool val) @@ -422,31 +420,31 @@ void WheelPrivate::changeTurnSignal(TurnSignal dir, bool val) tsVal = 1; } this->turnSignal = tsVal; - this->re->updateProperty(VehicleProperty::TurnSignal, this->turnSignal); + this->re->updateProperty(VehicleProperty::TurnSignal, VehicleProperty::TurnSignalType(this->turnSignal)); } void WheelPrivate::changeGear(int gear) { this->currentGear = gear; - this->re->updateProperty(VehicleProperty::TransmissionShiftPosition, this->currentGear); - this->re->updateProperty(VehicleProperty::VehicleSpeed, this->calcCarSpeed()); + this->re->updateProperty(VehicleProperty::TransmissionShiftPosition, VehicleProperty::TransmissionShiftPositionType(this->currentGear)); + this->re->updateProperty(VehicleProperty::VehicleSpeed, VehicleProperty::VehicleSpeedType(this->calcCarSpeed())); } void WheelPrivate::changeOilPressure(bool increase) { - this->re->updateProperty(VehicleProperty::EngineOilPressure, (increase ? ++this->oilPSI : --this->oilPSI)); + this->re->updateProperty(VehicleProperty::EngineOilPressure, VehicleProperty::EngineOilPressureType(increase ? ++this->oilPSI : --this->oilPSI)); } void WheelPrivate::changeCoolantTemp(bool increase) { - this->re->updateProperty(VehicleProperty::EngineCoolantTemperature, (increase ? ++this->coolantTemp : --this->coolantTemp)); + this->re->updateProperty(VehicleProperty::EngineCoolantTemperature, VehicleProperty::EngineCoolantTemperatureType(increase ? ++this->coolantTemp : --this->coolantTemp)); } void WheelPrivate::changeSteeringAngle(int val) { this->steeringAngle = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0; - this->re->updateProperty(VehicleProperty::SteeringWheelAngle, this->steeringAngle); + this->re->updateProperty(VehicleProperty::SteeringWheelAngle, VehicleProperty::SteeringWheelAngleType(this->steeringAngle)); } void WheelPrivate::changeClutch(int val) @@ -454,16 +452,16 @@ void WheelPrivate::changeClutch(int val) this->oldClutch = this->clutch; this->clutch = (val < 20000); if (this->oldClutch != this->clutch) - this->re->updateProperty(VehicleProperty::ClutchStatus, this->clutch); + this->re->updateProperty(VehicleProperty::ClutchStatus, VehicleProperty::ClutchStatusType(this->clutch)); } void WheelPrivate::changeThrottle(int val) { this->throttle = ((double)(val - 32767)/(double)-65534.0)*(double)100.0; - this->re->updateProperty(VehicleProperty::ThrottlePosition, this->throttle); - this->re->updateProperty(VehicleProperty::EngineSpeed, this->calcRPM()); - this->re->updateProperty(VehicleProperty::VehicleSpeed, this->calcCarSpeed()); + this->re->updateProperty(VehicleProperty::ThrottlePosition, VehicleProperty::ThrottlePositionType(this->throttle)); + this->re->updateProperty(VehicleProperty::EngineSpeed, VehicleProperty::EngineSpeedType(this->calcRPM())); + this->re->updateProperty(VehicleProperty::VehicleSpeed, VehicleProperty::VehicleSpeedType(this->calcCarSpeed())); } void WheelPrivate::changeBrake(int val) @@ -471,7 +469,7 @@ void WheelPrivate::changeBrake(int val) this->oldBrake = this->brake; this->brake = (val < 20000); if (this->oldBrake != this->brake) - this->re->updateProperty(VehicleProperty::WheelBrake, this->brake); + this->re->updateProperty(VehicleProperty::WheelBrake, VehicleProperty::WheelBrakeType(this->brake)); } diff --git a/plugins/wheel/wheelplugin.h b/plugins/wheel/wheelplugin.h index cb4ca4cc..1c448901 100644 --- a/plugins/wheel/wheelplugin.h +++ b/plugins/wheel/wheelplugin.h @@ -34,7 +34,7 @@ public: ~WheelSourcePlugin(); string uuid(); - boost::any getProperty(VehicleProperty::Property property); + AbstractPropertyType getProperty(VehicleProperty::Property property); void getPropertyAsync(AsyncPropertyReply *reply); void setProperty(VehicleProperty::Property, AbstractPropertyType); void subscribeToPropertyChanges(VehicleProperty::Property property); |