From ab69dae6d9cfb1c317a9b162f099da1ed35c586e Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Mon, 26 Nov 2012 15:59:12 -0800 Subject: [PATCH] fixed currenttime bugs --- TODO | 7 ++---- examples/testmultiisource | 2 +- lib/debugout.h | 11 ++++++++- lib/timestamp.h | 8 ++++++- plugins/websocketsink/websocketsink.cpp | 3 ++- plugins/websocketsourceplugin/websocketsource.cpp | 28 +++++++++++++++++++---- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index c79cfa2..3594458 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,9 @@ - test for memory leaks in websocket sink plugin -- implement websocket source getProperty methods and setProperty +- test websocket source getProperty methods and setProperty - per-source property filtering in routing engine - historic data "get" interface in routing engine - sqlite database storage plugin -- connect/disconnect on first/last subscription in obd2source - improve obd2source speed via Physical Addressing (see https://www.scantool.net/forum/index.php?topic=6661.msg25024#msg25024) - timestamp on property get/update operations - squence on property get/update operation -- fix issue regarding obd2 thread loop not exiting sometimes -- optimize CPU performance in obd2source -- obd2source blacklist unsupported: persistent blacklist mapped to VIN? +- getSupported websocket call should only return supported not capabilities diff --git a/examples/testmultiisource b/examples/testmultiisource index aa0b15c..525ea39 100755 --- a/examples/testmultiisource +++ b/examples/testmultiisource @@ -12,7 +12,7 @@ sleep 10 for (( i=1; i<=$numclients; i++ )) do - ambd -D -c configwebsocketsource -d1 -l client.$i.output + ambd -D -c configwebsocketsource -d2 -l client.$i.output done sleep 60 diff --git a/lib/debugout.h b/lib/debugout.h index 8d598c4..045a844 100644 --- a/lib/debugout.h +++ b/lib/debugout.h @@ -50,7 +50,16 @@ public: return *this; } - DebugOut const & operator << (uint16_t val) const + /*DebugOut const & operator << (uint16_t val) const + { + ostream out(buf); + + if(mDebugLevel <= debugThreshhold) + out< +#include namespace amb { @@ -11,7 +12,12 @@ double currentTime() clock_gettime(CLOCK_REALTIME, &tm); - double time = tm.tv_sec + (tm.tv_nsec / 1000000); + double ns = double(tm.tv_nsec) / 1000000000; + + + double time = double(tm.tv_sec) + ns; + + return time; } } diff --git a/plugins/websocketsink/websocketsink.cpp b/plugins/websocketsink/websocketsink.cpp index 31f98b5..e1460a1 100644 --- a/plugins/websocketsink/websocketsink.cpp +++ b/plugins/websocketsink/websocketsink.cpp @@ -64,8 +64,9 @@ void WebSocketSink::propertyChanged(VehicleProperty::Property property, Abstract tmpstr = property; } + s.precision(15); - s << "{\"type\":\"valuechanged\",\"name\":\"" << tmpstr << "\",\"data\":\"" << value->toString() << "\",\"transactionid\":\"" << m_uuid << "\"}"; + s << "{\"type\":\"valuechanged\",\"name\":\"" << tmpstr << "\",\"data\":\"" << value->toString() << "\",\"transactionid\":\"" << m_uuid << "\", \"timestamp\":\""<message<updateProperty(name, type, source->uuid(), amb::currentTime(), 0); + m_re->updateProperty(name, type, source->uuid(), timestamp, 0); + + double currenttime = amb::currentTime(); + + DebugOut(2)<<"websocket source latency: "<<(currenttime - timestamp)*1000<<"ms"<