report out property updates per second
authorKevron Rees <tripzero.kev@gmail.com>
Sun, 30 Sep 2012 21:39:36 +0000 (14:39 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Sun, 30 Sep 2012 21:39:36 +0000 (14:39 -0700)
ambd/core.cpp
ambd/core.h
plugins/obd2plugin/obd2source.cpp

index aed5c57..1059498 100644 (file)
 
 #include "core.h"
 #include <functional>
+#include <glib.h>
 #include "listplusplus.h"
 #include "debugout.h"
 
 using namespace std::placeholders;
 
+int lastpps=0;
+
+static int PPSUpdate(void* data)
+{
+       int* pps = (int*)data;
+
+       int temp = *pps;
+
+       if(temp > 0 && temp != lastpps)
+       {
+               lastpps = temp;
+               DebugOut(1)<<"Property updates per second: "<<temp<<endl;
+       }
+
+       *pps = 0;
+}
+
 Core::Core()
+       :propertiesPerSecond(0)
 {
-       
+       g_timeout_add(1000,PPSUpdate,&propertiesPerSecond);
 }
 
 Core::~Core()
@@ -126,7 +145,9 @@ void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyTy
        SinkList list = propertySinkMap[property];
        
        DebugOut()<<__FUNCTION__<<"() there are "<<list.size()<<" sinks connected to property: "<<property<<endl;
-       
+
+       propertiesPerSecond++;
+
        for(SinkList::iterator itr = list.begin(); itr != list.end(); itr++)
        {
                (*itr)->propertyChanged(property, value,(*itr)->uuid());
@@ -182,7 +203,7 @@ void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType
 
 void Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink* self)
 {
-  printf("Subscribing\n");
+       printf("Subscribing\n");
        if(!ListPlusPlus<VehicleProperty::Property>(&mMasterPropertyList).contains((property)))
        {
                DebugOut()<<__FUNCTION__<<"(): property not supported: "<<property<<endl;
index 477da54..b03d84d 100644 (file)
@@ -56,6 +56,8 @@ private:
        
        SourceList mSources;
        SinkList mSinks;
+
+       int propertiesPerSecond;
        
        std::map<VehicleProperty::Property, SinkList> propertySinkMap;
     
index 0aea6dc..06debe5 100644 (file)
@@ -27,7 +27,7 @@
 #include <listplusplus.h>
 #include "debugout.h"
 #include "bluetooth.hpp"
-#include "asyncqueuewatcher.h"
+
 
 #define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
 AbstractRoutingEngine *m_re;