From: Kevron Rees Date: Wed, 28 Nov 2012 23:04:31 +0000 (-0800) Subject: refactored how timestamp and sequence are stored: moved to AbstractProperty X-Git-Tag: 0.6.0~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40f12a897644a69f5b08d957cc4047421d9f1979;p=profile%2Fivi%2Fautomotive-message-broker.git refactored how timestamp and sequence are stored: moved to AbstractProperty --- diff --git a/ambd/core.cpp b/ambd/core.cpp index 02aa4cb..0107ee9 100644 --- a/ambd/core.cpp +++ b/ambd/core.cpp @@ -140,7 +140,7 @@ void Core::updateSupported(PropertyList added, PropertyList removed) } } -void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid, double timestamp, uint32_t sequence) +void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid) { SinkList list = propertySinkMap[property]; @@ -148,21 +148,10 @@ void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyTy propertiesPerSecond++; - /*if(previousValueMap.find(property) != previousValueMap.end()) - { - std::string v = previousValueMap[property]; - if(v == value->toString()) - { - ///no change from last value; - return; - } - } - - previousValueMap[property] = value->toString();*/ for(SinkList::iterator itr = list.begin(); itr != list.end(); itr++) { - (*itr)->propertyChanged(property, value, uuid, timestamp, sequence); + (*itr)->propertyChanged(property, value, uuid); } } diff --git a/ambd/core.h b/ambd/core.h index 6afe7b2..7ad4ad0 100644 --- a/ambd/core.h +++ b/ambd/core.h @@ -36,7 +36,7 @@ public: void setSupported(PropertyList supported, AbstractSource* source); void updateSupported(PropertyList added, PropertyList removed); - void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value, string uuid, double timestamp, uint32_t sequence); + void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value, string uuid); /// sinks: diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e822f2d..b8fe915 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -set(amb_sources abstractpropertytype.cpp abstractroutingengine.cpp listplusplus.cpp abstractsink.cpp vehicleproperty.cpp abstractsource.cpp debugout.cpp) +set(amb_sources abstractpropertytype.cpp abstractroutingengine.cpp listplusplus.cpp abstractsink.cpp vehicleproperty.cpp abstractsource.cpp debugout.cpp timestamp.cpp) set(amb_headers_install abstractpropertytype.h nullptr.h abstractroutingengine.h listplusplus.h abstractsink.h vehicleproperty.h debugout.h abstractsource.h timestamp.h) include_directories( ${include_dirs} ) add_library(amb SHARED ${amb_sources}) diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index c9297e5..87272e4 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -26,19 +26,27 @@ #include #include #include +#include "timestamp.h" class AbstractPropertyType { public: + AbstractPropertyType(): timestamp(0), sequence(0) {} + virtual std::string toString() const = 0; virtual void fromString(std::string)= 0; virtual AbstractPropertyType* copy() = 0; + double timestamp; + + uint32_t sequence; + void setValue(boost::any val) { mValue = val; + timestamp = amb::currentTime(); } template diff --git a/lib/abstractroutingengine.h b/lib/abstractroutingengine.h index 1bf7578..f45d846 100644 --- a/lib/abstractroutingengine.h +++ b/lib/abstractroutingengine.h @@ -38,17 +38,6 @@ class AsyncRangePropertyReply; typedef std::function GetPropertyCompletedSignal; typedef std::function GetRangedPropertyCompletedSignal; -class PropertyValueTime { -public: - ~PropertyValueTime() - { - delete value; - } - - AbstractPropertyType* value; - double timestamp; -}; - class AsyncPropertyRequest { public: @@ -150,7 +139,7 @@ public: values.clear(); } - std::list values; + std::list values; bool success; }; @@ -159,7 +148,7 @@ class AbstractRoutingEngine public: virtual void setSupported(PropertyList supported, AbstractSource* source) = 0; virtual void updateSupported(PropertyList added, PropertyList removed) = 0; - virtual void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid, double timestamp, uint32_t sequence) = 0; + virtual void updateProperty(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid) = 0; /// sinks: virtual void registerSink(AbstractSink* self) = 0; diff --git a/lib/abstractsink.h b/lib/abstractsink.h index 4a74691..110c72e 100644 --- a/lib/abstractsink.h +++ b/lib/abstractsink.h @@ -57,7 +57,7 @@ public: * Do not destroy it. If you need to store the value use value.anyValue() or value.value() to copy. * @param uuid Unique identifier representing the source */ - virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid, double timestamp, uint32_t sequence) = 0; + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) = 0; virtual void supportedChanged(PropertyList supportedProperties) = 0; diff --git a/lib/timestamp.cpp b/lib/timestamp.cpp new file mode 100644 index 0000000..6756803 --- /dev/null +++ b/lib/timestamp.cpp @@ -0,0 +1,18 @@ +#include "timestamp.h" + +#include +#include + +double amb::currentTime() +{ + struct timespec tm; + + clock_gettime(CLOCK_REALTIME, &tm); + + double ns = double(tm.tv_nsec) / 1000000000; + + + double time = double(tm.tv_sec) + ns; + + return time; +} diff --git a/lib/timestamp.h b/lib/timestamp.h index 1d3a2f7..745bc13 100644 --- a/lib/timestamp.h +++ b/lib/timestamp.h @@ -1,24 +1,10 @@ -#ifndef _TIMESTAMP_H__ -#define _TIMESTAMP_H__ +#ifndef _TIMESTAMP_H___ +#define _TIMESTAMP_H___ -#include -#include namespace amb { -double currentTime() -{ - struct timespec tm; - - clock_gettime(CLOCK_REALTIME, &tm); - - double ns = double(tm.tv_nsec) / 1000000000; - - - double time = double(tm.tv_sec) + ns; - - return time; -} +double currentTime(); } diff --git a/plugins/database/databasesink.cpp b/plugins/database/databasesink.cpp index ac605a8..abb7bef 100644 --- a/plugins/database/databasesink.cpp +++ b/plugins/database/databasesink.cpp @@ -63,12 +63,14 @@ void DatabaseSink::supportedChanged(PropertyList supportedProperties) } -void DatabaseSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid, double timestamp, uint32_t sequence) +void DatabaseSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid) { DBObject* obj = new DBObject; obj->key = property; obj->value = value->toString(); obj->source = uuid; + obj->time = value->timestamp; + obj->sequence = value->sequence; } diff --git a/plugins/database/databasesink.h b/plugins/database/databasesink.h index 09f62c6..5884c81 100644 --- a/plugins/database/databasesink.h +++ b/plugins/database/databasesink.h @@ -111,7 +111,7 @@ public: ~DatabaseSink(); virtual PropertyList subscriptions(); virtual void supportedChanged(PropertyList supportedProperties); - virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid, double timestamp, uint32_t sequence); + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid); virtual std::string uuid(); private: diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp index 196d54d..682df0c 100644 --- a/plugins/dbus/dbusplugin.cpp +++ b/plugins/dbus/dbusplugin.cpp @@ -54,7 +54,7 @@ void DBusSink::supportedChanged(PropertyList supportedProperties) registerObject(); } -void DBusSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid, double, uint32_t) +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 025fbd6..103cfaa 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, map config); virtual void supportedChanged(PropertyList supportedProperties); - virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid,double,uint32_t); + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, std::string uuid); virtual std::string uuid(); protected: diff --git a/plugins/demosink/demosinkplugin.cpp b/plugins/demosink/demosinkplugin.cpp index af47696..9f7f6b3 100644 --- a/plugins/demosink/demosinkplugin.cpp +++ b/plugins/demosink/demosinkplugin.cpp @@ -75,7 +75,7 @@ string DemoSink::uuid() return "5b0e8a04-d6d7-43af-b827-1663627a25d9"; } -void DemoSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid, double, uint32_t) +void DemoSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid) { std::string app = configuration["script"]; std::string strValue = value->toString(); diff --git a/plugins/demosink/demosinkplugin.h b/plugins/demosink/demosinkplugin.h index 2340a78..ffd806c 100644 --- a/plugins/demosink/demosinkplugin.h +++ b/plugins/demosink/demosinkplugin.h @@ -33,7 +33,7 @@ public: string uuid(); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid, double, uint32_t); + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid); void supportedChanged(PropertyList); friend class WheelPrivate; diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index 44da9cd..db7b95a 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -184,12 +184,20 @@ void ExampleSourcePlugin::randomizeProperties() machineGun = !machineGun; - routingEngine->updateProperty(VehicleProperty::VehicleSpeed, &vel, uuid(),amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::EngineSpeed, &es, uuid(),amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::AccelerationX, &ac, uuid(),amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::SteeringWheelAngle, &swa, uuid(),amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition,&tsp, uuid(),amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::ThrottlePosition, &tp, uuid(),amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, &ec, uuid(),amb::currentTime(), 0); + 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()); + routingEngine->updateProperty(VehicleProperty::SteeringWheelAngle, &swa, uuid()); + routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition,&tsp, uuid()); + routingEngine->updateProperty(VehicleProperty::ThrottlePosition, &tp, uuid()); + routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, &ec, uuid()); //routingEngine->updateProperty(VehicleProperty::MachineGunTurretStatus, &mgt); } diff --git a/plugins/exampleplugin.h b/plugins/exampleplugin.h index 8cb2bf4..8f4327b 100644 --- a/plugins/exampleplugin.h +++ b/plugins/exampleplugin.h @@ -38,7 +38,7 @@ public: void unsubscribeToPropertyChanges(VehicleProperty::Property property); PropertyList supported(); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid, double timestamp, uint32_t sequence) {} + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {} void supportedChanged(PropertyList) {} void randomizeProperties(); diff --git a/plugins/examplesink.cpp b/plugins/examplesink.cpp index 39a04be..dd531f5 100644 --- a/plugins/examplesink.cpp +++ b/plugins/examplesink.cpp @@ -69,10 +69,10 @@ ExampleSink::ExampleSink(AbstractRoutingEngine* engine, map conf vehicleSpeedFromLastWeek.property = VehicleProperty::VehicleSpeed; vehicleSpeedFromLastWeek.completed = [](AsyncRangePropertyReply* reply) { - std::list values = reply->values; + std::list values = reply->values; for(auto itr = values.begin(); itr != values.end(); itr++) { - DebugOut(0)<<"Velocity value from last week: "<<(*itr)->value->toString()<<" time: "<<(*itr)->timestamp<toString()<<" time: "<<(*itr)->timestamp<subscribeToProperty(VehicleProperty::VehicleSpeed, this); } -void ExampleSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid, double timestamp, uint32_t sequence) +void ExampleSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid) { DebugOut()<toString()< config); virtual PropertyList subscriptions(); virtual void supportedChanged(PropertyList supportedProperties); - virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid, double timestamp, uint32_t sequence); + virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid); virtual std::string uuid(); }; diff --git a/plugins/obd2plugin/obd2source.cpp b/plugins/obd2plugin/obd2source.cpp index 5e75e99..4170145 100644 --- a/plugins/obd2plugin/obd2source.cpp +++ b/plugins/obd2plugin/obd2source.cpp @@ -472,6 +472,7 @@ static int updateProperties(/*gpointer retval,*/ gpointer data) return true; } + void OBD2Source::updateProperty(VehicleProperty::Property property,AbstractPropertyType* value) { //m_re->updateProperty(property,&value); @@ -484,29 +485,10 @@ void OBD2Source::updateProperty(VehicleProperty::Property property,AbstractPrope } else { - m_re->updateProperty(property,value,uuid(),amb::currentTime(),0); + m_re->updateProperty(property,value,uuid()); } } -void OBD2Source::mafValue(double maf) -{ - VehicleProperty::VehicleSpeedType emaf(maf); - m_re->updateProperty(VehicleProperty::MassAirFlow,&emaf,uuid(),amb::currentTime(),0); -} -void OBD2Source::engineCoolantTemp(int temp) -{ - VehicleProperty::VehicleSpeedType etemp(temp); - m_re->updateProperty(VehicleProperty::EngineCoolantTemperature,&etemp,uuid(),amb::currentTime(),0); -} -void OBD2Source::engineSpeed(double speed) -{ - VehicleProperty::VehicleSpeedType espeed(speed); - m_re->updateProperty(VehicleProperty::EngineSpeed,&espeed,uuid(),amb::currentTime(),0); -} -void OBD2Source::vehicleSpeed(int speed) -{ - VehicleProperty::EngineSpeedType vspeed(speed); - m_re->updateProperty(VehicleProperty::VehicleSpeed,&vspeed,uuid(),amb::currentTime(),0); -} + void OBD2Source::setSupported(PropertyList list) { m_supportedProperties = list; diff --git a/plugins/obd2plugin/obd2source.h b/plugins/obd2plugin/obd2source.h index 60045de..b9499db 100644 --- a/plugins/obd2plugin/obd2source.h +++ b/plugins/obd2plugin/obd2source.h @@ -143,7 +143,7 @@ public: void engineCoolantTemp(int temp); PropertyList removeRequests; void setSupported(PropertyList list); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid,double,uint32_t) {} + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {} void supportedChanged(PropertyList) {} GAsyncQueue* commandQueue; GAsyncQueue* subscriptionAddQueue; diff --git a/plugins/tpms/tpmsplugin.cpp b/plugins/tpms/tpmsplugin.cpp index 836f0ed..c3f912d 100644 --- a/plugins/tpms/tpmsplugin.cpp +++ b/plugins/tpms/tpmsplugin.cpp @@ -299,14 +299,14 @@ int TpmsPlugin::readValues() VehicleProperty::TireTemperatureType lrTemp(lrTemperature); VehicleProperty::TireTemperatureType rrTemp(rrTemperature); - routingEngine->updateProperty(VehicleProperty::TirePressureLeftFront, &lfPres, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TirePressureRightFront, &rfPres, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TirePressureLeftRear, &lrPres, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TirePressureRightRear, &rrPres, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TireTemperatureLeftFront, &lfTemp, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TireTemperatureRightFront, &rfTemp, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TireTemperatureLeftRear, &lrTemp, uuid(), amb::currentTime(), 0); - routingEngine->updateProperty(VehicleProperty::TireTemperatureRightRear, &rrTemp, uuid(), amb::currentTime(), 0); + routingEngine->updateProperty(VehicleProperty::TirePressureLeftFront, &lfPres, uuid()); + routingEngine->updateProperty(VehicleProperty::TirePressureRightFront, &rfPres, uuid()); + routingEngine->updateProperty(VehicleProperty::TirePressureLeftRear, &lrPres, uuid()); + routingEngine->updateProperty(VehicleProperty::TirePressureRightRear, &rrPres, uuid()); + routingEngine->updateProperty(VehicleProperty::TireTemperatureLeftFront, &lfTemp, uuid()); + routingEngine->updateProperty(VehicleProperty::TireTemperatureRightFront, &rfTemp, uuid()); + routingEngine->updateProperty(VehicleProperty::TireTemperatureLeftRear, &lrTemp, uuid()); + routingEngine->updateProperty(VehicleProperty::TireTemperatureRightRear, &rrTemp, uuid()); return 0; } diff --git a/plugins/tpms/tpmsplugin.h b/plugins/tpms/tpmsplugin.h index b4e36da..189c91b 100644 --- a/plugins/tpms/tpmsplugin.h +++ b/plugins/tpms/tpmsplugin.h @@ -38,7 +38,7 @@ public: void unsubscribeToPropertyChanges(VehicleProperty::Property property); PropertyList supported(); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid,double,uint32_t) {} + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {} void supportedChanged(PropertyList) {} int readValues(); diff --git a/plugins/websocketsink/websocketsink.cpp b/plugins/websocketsink/websocketsink.cpp index e1460a1..bbcb452 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, AbstractPropertyType *value, string uuid, double timestamp, uint32_t sequence) +void WebSocketSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid) { //printf("Got property:%i\n",boost::any_cast(reply->value)); //uint16_t velocity = boost::any_cast(value); @@ -66,7 +66,7 @@ void WebSocketSink::propertyChanged(VehicleProperty::Property property, Abstract s.precision(15); - s << "{\"type\":\"valuechanged\",\"name\":\"" << tmpstr << "\",\"data\":\"" << value->toString() << "\",\"transactionid\":\"" << m_uuid << "\", \"timestamp\":\""<toString() << "\",\"transactionid\":\"" << m_uuid << "\", \"timestamp\":\""<timestamp<<"\",\"sequence\":\""<sequence<<"\"}"; string replystr = s.str(); //printf("Reply: %s\n",replystr.c_str()); diff --git a/plugins/websocketsink/websocketsink.h b/plugins/websocketsink/websocketsink.h index 09c76e2..c65ebff 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, AbstractPropertyType *value, string uuid, double timestamp, uint32_t sequence); + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid); void supportedChanged(PropertyList supportedProperties); PropertyList subscriptions(); libwebsocket *socket() { return m_wsi; } diff --git a/plugins/websocketsink/websocketsinkmanager.cpp b/plugins/websocketsink/websocketsinkmanager.cpp index 6530458..05a5570 100644 --- a/plugins/websocketsink/websocketsinkmanager.cpp +++ b/plugins/websocketsink/websocketsinkmanager.cpp @@ -190,7 +190,7 @@ void WebSocketSinkManager::addSingleShotRangedSink(libwebsocket* socket, Vehicle //TODO: Dirty hack hardcoded stuff, jsut to make it work. stringstream data ("["); - std::list values = reply->values; + std::list values = reply->values; for(auto itr = values.begin(); itr != values.end(); itr++) { if(itr != values.begin()) @@ -198,7 +198,7 @@ void WebSocketSinkManager::addSingleShotRangedSink(libwebsocket* socket, Vehicle data<<","; } - data << "{ \"value\" : " << "\"" << (*itr)->value->toString() << "\", \"time\" : \"" << (*itr)->timestamp << "\" }"; + data << "{ \"value\" : " << "\"" << (*itr)->toString() << "\", \"time\" : \"" << (*itr)->timestamp << "\" }"; } data<<"]"; diff --git a/plugins/websocketsourceplugin/websocketsource.cpp b/plugins/websocketsourceplugin/websocketsource.cpp index b15c0ed..3cfa094 100644 --- a/plugins/websocketsourceplugin/websocketsource.cpp +++ b/plugins/websocketsourceplugin/websocketsource.cpp @@ -308,7 +308,7 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket try { AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(name,data.front()); - m_re->updateProperty(name, type, source->uuid(), timestamp, 0); + m_re->updateProperty(name, type, source->uuid()); double currenttime = amb::currentTime(); @@ -356,9 +356,11 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket pairdata.pop_front(); if (source->propertyReplyMap.find(pair.first) != source->propertyReplyMap.end()) { - source->propertyReplyMap[pair.first]->value = VehicleProperty::getPropertyTypeForPropertyNameValue(source->propertyReplyMap[pair.first]->property,pair.second); + AbstractPropertyType* v = VehicleProperty::getPropertyTypeForPropertyNameValue(source->propertyReplyMap[pair.first]->property,pair.second); + source->propertyReplyMap[pair.first]->value = v; source->propertyReplyMap[pair.first]->completed(source->propertyReplyMap[pair.first]); source->propertyReplyMap.erase(pair.first); + delete v; } } //data will contain a property/value map. diff --git a/plugins/websocketsourceplugin/websocketsource.h b/plugins/websocketsourceplugin/websocketsource.h index eb14f1e..3eaaaa5 100644 --- a/plugins/websocketsourceplugin/websocketsource.h +++ b/plugins/websocketsourceplugin/websocketsource.h @@ -47,7 +47,7 @@ public: PropertyList activeRequests; PropertyList removeRequests; void setSupported(PropertyList list); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid,double, uint32_t) {} + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {} void supportedChanged(PropertyList) {} void setConfiguration(map config); map propertyReplyMap; diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp index b947546..b8f0e50 100644 --- a/plugins/wheel/wheelplugin.cpp +++ b/plugins/wheel/wheelplugin.cpp @@ -449,7 +449,8 @@ void WheelPrivate::changeMachineGuns(bool val) { this->machineGuns = val; VehicleProperty::MachineGunTurretStatusType temp(this->machineGuns); - this->re->updateProperty(VehicleProperty::MachineGunTurretStatus, &temp, mParent->uuid(), amb::currentTime(), 0); + temp.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::MachineGunTurretStatus, &temp, mParent->uuid()); } void WheelPrivate::changeTurnSignal(TurnSignals::TurnSignalType dir, bool val) @@ -463,7 +464,8 @@ void WheelPrivate::changeTurnSignal(TurnSignals::TurnSignalType dir, bool val) } this->turnSignal = tsVal; VehicleProperty::TurnSignalType temp(this->turnSignal); - this->re->updateProperty(VehicleProperty::TurnSignal, &temp, mParent->uuid(), amb::currentTime(), 0); + temp.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::TurnSignal, &temp, mParent->uuid()); } void WheelPrivate::changeGear(int gear) @@ -471,20 +473,24 @@ void WheelPrivate::changeGear(int gear) this->currentGear = (Transmission::TransmissionPositions)gear; VehicleProperty::TransmissionShiftPositionType tempTrans(this->currentGear); VehicleProperty::VehicleSpeedType tempSpeed(this->calcCarSpeed()); - this->re->updateProperty(VehicleProperty::TransmissionShiftPosition, &tempTrans, mParent->uuid(), amb::currentTime(), 0); - this->re->updateProperty(VehicleProperty::VehicleSpeed, &tempSpeed, mParent->uuid(), amb::currentTime(), 0); + tempTrans.timestamp = amb::currentTime(); + tempSpeed.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::TransmissionShiftPosition, &tempTrans, mParent->uuid()); + this->re->updateProperty(VehicleProperty::VehicleSpeed, &tempSpeed, mParent->uuid()); } void WheelPrivate::changeOilPressure(bool increase) { VehicleProperty::EngineOilPressureType temp(increase ? ++this->oilPSI : --this->oilPSI); - this->re->updateProperty(VehicleProperty::EngineOilPressure, &temp, mParent->uuid(), amb::currentTime(), 0); + temp.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::EngineOilPressure, &temp, mParent->uuid()); } void WheelPrivate::changeCoolantTemp(bool increase) { - VehicleProperty::EngineCoolantTemperatureType temp(increase ? ++this->coolantTemp : --this->coolantTemp); - this->re->updateProperty(VehicleProperty::EngineCoolantTemperature, &temp, mParent->uuid(), amb::currentTime(), 0); + VehicleProperty::EngineCoolantTemperatureType temp(increase ? ++this->coolantTemp : --this->coolantTemp); + temp.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::EngineCoolantTemperature, &temp, mParent->uuid()); } @@ -492,7 +498,8 @@ void WheelPrivate::changeSteeringAngle(int val) { this->steeringAngle = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0; VehicleProperty::SteeringWheelAngleType temp(this->steeringAngle); - this->re->updateProperty(VehicleProperty::SteeringWheelAngle, &temp, mParent->uuid(), amb::currentTime(), 0); + temp.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::SteeringWheelAngle, &temp, mParent->uuid()); } void WheelPrivate::changeClutch(int val) @@ -502,7 +509,8 @@ void WheelPrivate::changeClutch(int val) if (this->oldClutch != this->clutch) { VehicleProperty::ClutchStatusType temp(this->clutch); - this->re->updateProperty(VehicleProperty::ClutchStatus, &temp, mParent->uuid(), amb::currentTime(), 0); + temp.timestamp = amb::currentTime(); + this->re->updateProperty(VehicleProperty::ClutchStatus, &temp, mParent->uuid()); } } @@ -514,9 +522,9 @@ void WheelPrivate::changeThrottle(int val) VehicleProperty::EngineSpeedType tempRpm(this->calcRPM()); VehicleProperty::VehicleSpeedType tempSpeed(this->calcCarSpeed()); - this->re->updateProperty(VehicleProperty::ThrottlePosition, &tempThrottle, mParent->uuid(), amb::currentTime(), 0); - this->re->updateProperty(VehicleProperty::EngineSpeed, &tempRpm, mParent->uuid(), amb::currentTime(), 0); - this->re->updateProperty(VehicleProperty::VehicleSpeed, &tempSpeed, mParent->uuid(), amb::currentTime(), 0); + this->re->updateProperty(VehicleProperty::ThrottlePosition, &tempThrottle, mParent->uuid()); + this->re->updateProperty(VehicleProperty::EngineSpeed, &tempRpm, mParent->uuid()); + this->re->updateProperty(VehicleProperty::VehicleSpeed, &tempSpeed, mParent->uuid()); } void WheelPrivate::changeBrake(int val) @@ -526,7 +534,7 @@ void WheelPrivate::changeBrake(int val) if (this->oldBrake != this->brake) { VehicleProperty::WheelBrakeType temp(this->brake); - this->re->updateProperty(VehicleProperty::WheelBrake, &temp, mParent->uuid(), amb::currentTime(), 0); + this->re->updateProperty(VehicleProperty::WheelBrake, &temp, mParent->uuid()); } } @@ -551,22 +559,22 @@ void WheelPrivate::checkButtonEvents() if (this->button[11]) { // cout << "Inside button 11!" << endl; VehicleProperty::ButtonEventType tempButton(ButtonEvents::Preset1Button); - this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid(), amb::currentTime(), 0); + 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(), amb::currentTime(), 0); + 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(), amb::currentTime(), 0); + 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(), amb::currentTime(), 0); + this->re->updateProperty(VehicleProperty::ButtonEvent, &tempButton, mParent->uuid()); } } } diff --git a/plugins/wheel/wheelplugin.h b/plugins/wheel/wheelplugin.h index 5c7f45d..ab7e662 100644 --- a/plugins/wheel/wheelplugin.h +++ b/plugins/wheel/wheelplugin.h @@ -41,7 +41,7 @@ public: void unsubscribeToPropertyChanges(VehicleProperty::Property property); PropertyList supported(); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid, double, uint32_t) {} + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {} void supportedChanged(PropertyList) {} map getConfiguration() { return configuration; }