- bluetooth adapter setting in obd2source
- test for memory leaks in websocket sink plugin
+- implement websocket source getProperty methods and setProperty
- per-source property filtering in routing engine
- historic data "get" interface in routing engine
- sqlite database storage plugin
return reply;
}
+AsyncRangePropertyReply *Core::getRangePropertyAsync(AsyncRangePropertyRequest request)
+{
+ AsyncRangePropertyReply * reply = new AsyncRangePropertyReply(request);
+
+ for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
+ {
+ AbstractSource* src = (*itr);
+ PropertyList properties = src->supported();
+ if(ListPlusPlus<VehicleProperty::Property>(&properties).contains(request.property))
+ {
+ src->getRangePropertyAsync(reply);
+ }
+ }
+
+ return reply;
+}
+
void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType *value)
{
for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
void registerSink(AbstractSink *self);
void unregisterSink(AbstractSink *self);
AsyncPropertyReply* getPropertyAsync(AsyncPropertyRequest request);
+ AsyncRangePropertyReply* getRangePropertyAsync(AsyncRangePropertyRequest request);
void setProperty(VehicleProperty::Property,AbstractPropertyType*);
void subscribeToProperty(VehicleProperty::Property, AbstractSink* self);
void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
#include <boost/any.hpp>
#include <functional>
+#include <time.h>
#include "vehicleproperty.h"
#include "abstractpropertytype.h"
class AsyncPropertyRequest
{
public:
+ AsyncPropertyRequest()
+ :property(VehicleProperty::NoValue)
+ {
+
+ }
+
+ AsyncPropertyRequest(const AsyncPropertyRequest &request)
+ {
+ this->property = request.property;
+ this->completed = request.completed;
+ }
+
+ AsyncPropertyRequest & operator = (const AsyncPropertyRequest & other)
+ {
+ this->property = other.property;
+ this->completed = other.completed;
+
+ return *this;
+ }
+
VehicleProperty::Property property;
CompletedSignal completed;
};
class AsyncPropertyReply: public AsyncPropertyRequest
{
public:
- AsyncPropertyReply(AsyncPropertyRequest request)
+ AsyncPropertyReply(const AsyncPropertyRequest &request)
+ :AsyncPropertyRequest(request), value(NULL)
+ {
+
+ }
+
+ AbstractPropertyType* value;
+};
+
+class AsyncRangePropertyRequest: public AsyncPropertyRequest
+{
+public:
+ AsyncRangePropertyRequest()
+ :begin(0), end(0)
+ {
+
+ }
+
+ AsyncRangePropertyRequest(const AsyncPropertyRequest &request)
+ :AsyncPropertyRequest(request), begin(0), end(0)
{
this->property = request.property;
this->completed = request.completed;
}
- AbstractPropertyType* value;
+ AsyncRangePropertyRequest(const AsyncRangePropertyRequest &request)
+ :AsyncPropertyRequest(request)
+ {
+ this->property = request.property;
+ this->completed = request.completed;
+ this->begin = request.begin;
+ this->end = request.end;
+ }
+
+ time_t begin;
+ time_t end;
+};
+
+class AsyncRangePropertyReply: public AsyncRangePropertyRequest
+{
+public:
+ AsyncRangePropertyReply(AsyncRangePropertyRequest request)
+ :AsyncRangePropertyRequest(request)
+ {
+
+ }
+
+ std::list<AbstractPropertyType*> values;
};
class AbstractRoutingEngine
virtual void registerSink(AbstractSink* self) = 0;
virtual void unregisterSink(AbstractSink* self) = 0;
virtual AsyncPropertyReply *getPropertyAsync(AsyncPropertyRequest request) = 0;
+ virtual AsyncRangePropertyReply * getRangePropertyAsync(AsyncRangePropertyRequest request) = 0;
virtual void setProperty(VehicleProperty::Property, AbstractPropertyType*) = 0;
virtual void subscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
virtual void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
///pure virtual methods:
virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0;
+ virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply) = 0;
virtual void setProperty(VehicleProperty::Property property, AbstractPropertyType* value) = 0;
virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0;
virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property) = 0;
}
namespace Power {
+/**< Vehicle Power Modes
+ * Off = Vehicle is off and key is in the "off" position.
+ * Accessory1 = Vehicle is off and key is in Accessory1 position.
+ * Accessory2 = Vehicle is off and key is in Accessory2 position.
+ * Run = Vehichle is running. Key is in the running position.
+ */
enum PowerModes
{
Off = 0,
static const Property TirePressureRightRear;
typedef BasicPropertyType<uint16_t> TirePressureType;
+ /**< Vehicle Power Mode.
+ *@see Power::PowerModes
+ */
static const Property VehiclePowerMode;
typedef BasicPropertyType<Power::PowerModes> VehiclePowerModeType;
static const Property InteriorLightCenter;
static const Property InteriorLightPassenger;
+
+
static std::list<VehicleProperty::Property> capabilities();
/*! getPropertyTypeForPropertyNameValue returns an AbstractPropertyType* for the property name
void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
{
DebugOut()<<"ExampleSource: getPropertyAsync called for property: "<<reply->property<<endl;
+
+
+
if(reply->property == VehicleProperty::VehicleSpeed)
{
VehicleProperty::VehicleSpeedType temp(velocity);
}
}
+void ExampleSourcePlugin::getRangePropertyAsync(AsyncRangePropertyReply *reply)
+{
+
+}
+
void ExampleSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType *)
{
routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition,&tsp);
routingEngine->updateProperty(VehicleProperty::ThrottlePosition, &tp);
routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, &ec);
- routingEngine->updateProperty(VehicleProperty::MachineGunTurretStatus, &mgt);
+ //routingEngine->updateProperty(VehicleProperty::MachineGunTurretStatus, &mgt);
}
string uuid();
void getPropertyAsync(AsyncPropertyReply *reply);
+ void getRangePropertyAsync(AsyncRangePropertyReply *reply);
void setProperty(VehicleProperty::Property, AbstractPropertyType*);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
string uuid();
int portHandle;
void getPropertyAsync(AsyncPropertyReply *reply);
+ void getRangePropertyAsync(AsyncRangePropertyReply *reply){}
void setProperty(VehicleProperty::Property, AbstractPropertyType*);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
}
void WebSocketSinkManager::disconnectAll(libwebsocket* socket)
{
+ std::list<WebSocketSink*> toDeleteList;
+
for (auto i=m_sinkMap.begin(); i != m_sinkMap.end();i++)
{
if ((*i).second->socket() == socket)
{
//This is the sink in question.
WebSocketSink* sink = (*i).second;
- delete sink;
- m_sinkMap.erase((*i).first);
- i--;
- //printf("Sink removed\n");
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Sink removed\n";
+ if(!ListPlusPlus<WebSocketSink*>(&toDeleteList).contains(sink))
+ {
+ toDeleteList.push_back(sink);
+ }
+ m_sinkMap.erase(i);
+ i=m_sinkMap.begin();
+ DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Sink removed"<<endl;
}
}
+
+ for(auto i=toDeleteList.begin();i!=toDeleteList.end();i++)
+ {
+ delete *i;
+ }
}
void WebSocketSinkManager::addPoll(int fd)
{
void addPoll(int fd);
void removePoll(int fd);
void init();
- map<std::string,WebSocketSink*> m_sinkMap;
+ map<std::string, WebSocketSink*> m_sinkMap;
void setConfiguration(map<string, string> config);
void setValue(string property,string value);
private:
m_re = re;
context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,protocols, libwebsocket_internal_extensions,NULL, NULL, -1, -1, 0);
-
+ setConfiguration(config);
re->setSupported(supported(), this);
+
//printf("websocketsource loaded!!!\n");
}
{
return "d293f670-f0b3-11e1-aff1-0800200c9a66";
}
-boost::any WebSocketSource::getProperty(VehicleProperty::Property property)
-{
- if(property == VehicleProperty::VehicleSpeed)
- {
- //return velocity;
- }
- else if(property == VehicleProperty::EngineSpeed)
- {
- //return engineSpeed;
- }
-}
+
void WebSocketSource::subscribeToPropertyChanges(VehicleProperty::Property property)
{
//printf("Subscribed to property: %s\n",property.c_str());
void WebSocketSource::getPropertyAsync(AsyncPropertyReply *reply)
{
- /*if(reply->property == VehicleProperty::VehicleSpeed)
- {
- reply->value = velocity;
- reply->completed(reply);
- }
- else if(reply->property == VehicleProperty::EngineSpeed)
- {
- reply->value = engineSpeed;
- reply->completed(reply);
- }
- else if(reply->property == VehicleProperty::AccelerationX)
- {
- reply->value = accelerationX;
- reply->completed(reply);
- }
- else if(reply->property == VehicleProperty::TransmissionShiftPosition)
- {
- reply->value = transmissionShiftPostion;
- reply->completed(reply);
- }
- else if(reply->property == VehicleProperty::SteeringWheelAngle)
- {
- reply->value = steeringWheelAngle;
- reply->completed(reply);
- }*/
+ ///TODO: fill in
}
-void WebSocketSource::setProperty(VehicleProperty::Property , AbstractPropertyType * )
+void WebSocketSource::getRangePropertyAsync(AsyncRangePropertyReply *reply)
{
+ ///TODO: fill in
+}
+void WebSocketSource::setProperty(VehicleProperty::Property , AbstractPropertyType * )
+{
+ ///TODO: fill in
}
public:
WebSocketSource(AbstractRoutingEngine* re, map<string, string> config);
string uuid();
- boost::any getProperty(VehicleProperty::Property property);
void getPropertyAsync(AsyncPropertyReply *reply);
+ void getRangePropertyAsync(AsyncRangePropertyReply *reply);
void setProperty(VehicleProperty::Property, AbstractPropertyType*);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {}
void supportedChanged(PropertyList) {}
void setConfiguration(map<string, string> config);
- //void randomizeProperties();
+
private:
PropertyList m_supportedProperties;
string uuid();
void getPropertyAsync(AsyncPropertyReply *reply);
+ void getRangePropertyAsync(AsyncRangePropertyReply *reply){}
void setProperty(VehicleProperty::Property, AbstractPropertyType*);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);