return reply;
}
-void Core::setProperty(VehicleProperty::Property property, AbstractPropertyType *value)
+AsyncPropertyReply * Core::setProperty(AsyncSetPropertyRequest request)
{
for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++)
{
AbstractSource* src = (*itr);
PropertyList properties = src->supported();
- if(ListPlusPlus<VehicleProperty::Property>(&properties).contains(property))
+ if(ListPlusPlus<VehicleProperty::Property>(&properties).contains(request.property))
{
- src->setProperty(property, value);
+ return src->setProperty(request);
}
}
}
void unregisterSink(AbstractSink *self);
AsyncPropertyReply* getPropertyAsync(AsyncPropertyRequest request);
AsyncRangePropertyReply* getRangePropertyAsync(AsyncRangePropertyRequest request);
- void setProperty(VehicleProperty::Property,AbstractPropertyType*);
+ AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
void subscribeToProperty(VehicleProperty::Property, AbstractSink* self);
void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
PropertyList supported() { return mMasterPropertyList; }
class AsyncPropertyReply;
-typedef std::function<void (AsyncPropertyReply*)> CompletedSignal;
+typedef std::function<void (AsyncPropertyReply*)> GetPropertyCompletedSignal;
+
+class PropertyValueTime {
+public:
+ AbstractPropertyType* value;
+ time_t timestamp;
+};
class AsyncPropertyRequest
{
}
VehicleProperty::Property property;
- CompletedSignal completed;
+ GetPropertyCompletedSignal completed;
};
class AsyncPropertyReply: public AsyncPropertyRequest
{
public:
AsyncPropertyReply(const AsyncPropertyRequest &request)
+ :AsyncPropertyRequest(request), value(NULL), success(false)
+ {
+
+ }
+
+ AbstractPropertyType* value;
+ bool success;
+};
+
+class AsyncSetPropertyRequest: public AsyncPropertyRequest
+{
+public:
+ AsyncSetPropertyRequest()
+ :value(NULL)
+ {
+
+ }
+
+ AsyncSetPropertyRequest(const AsyncPropertyRequest &request)
:AsyncPropertyRequest(request), value(NULL)
{
}
- std::list<AbstractPropertyType*> values;
+ std::list<PropertyValueTime*> values;
};
class AbstractRoutingEngine
/// sinks:
virtual void registerSink(AbstractSink* self) = 0;
virtual void unregisterSink(AbstractSink* self) = 0;
- virtual AsyncPropertyReply *getPropertyAsync(AsyncPropertyRequest request) = 0;
+ virtual AsyncPropertyReply * getPropertyAsync(AsyncPropertyRequest request) = 0;
virtual AsyncRangePropertyReply * getRangePropertyAsync(AsyncRangePropertyRequest request) = 0;
- virtual void setProperty(VehicleProperty::Property, AbstractPropertyType*) = 0;
+ virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
virtual void subscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
virtual void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
virtual PropertyList supported() = 0;
virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0;
virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply) = 0;
- virtual void setProperty(VehicleProperty::Property property, AbstractPropertyType* value) = 0;
+ virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0;
virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property) = 0;
virtual PropertyList supported() = 0;
AbstractPropertyType* apt = VehicleProperty::getPropertyTypeForPropertyNameValue(mAmbPropertyName,"");
apt->setValue(val);
- routingEngine->setProperty(mAmbPropertyName, apt);
+ AsyncSetPropertyRequest request;
+ request.property = mAmbPropertyName;
+ request.value = apt;
+ request.completed = [apt](AsyncPropertyReply* reply)
+ {
+ if(!reply->success) {
+ //TODO: throw DBus exception
+ }
+ delete apt;
+ };
- ///delete this because we should be done
- delete apt;
+ routingEngine->setProperty(request);
}
private:
propertyDBusMap[property] = new BasicProperty<T>(routingEngine, property, propertyName, signature, access, this);
}
- virtual void setProperty(VehicleProperty::Property name, AbstractPropertyType* value)
+ /*virtual void setProperty(VehicleProperty::Property name, AbstractPropertyType* value)
{
- routingEngine->setProperty(name, value);
- }
+ AsyncSetPropertyRequest request;
+ request.property = name;
+ request.value = value;
+ request.completed = [](AsyncPropertyReply* reply) { delete reply; };
+ routingEngine->setProperty(request);
+ }*/
PropertyDBusMap propertyDBusMap;
private:
}
-void ExampleSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType *)
+AsyncPropertyReply *ExampleSourcePlugin::setProperty(AsyncSetPropertyRequest request )
{
}
string uuid();
void getPropertyAsync(AsyncPropertyReply *reply);
void getRangePropertyAsync(AsyncRangePropertyReply *reply);
- void setProperty(VehicleProperty::Property, AbstractPropertyType*);
+ AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
PropertyList supported();
g_async_queue_push(singleShotQueue,requ);
}
-void OBD2Source::setProperty(VehicleProperty::Property , AbstractPropertyType * )
+AsyncPropertyReply *OBD2Source::setProperty(AsyncSetPropertyRequest request )
{
+ AsyncPropertyReply* reply = new AsyncPropertyReply (request);
+ reply->success = false;
+ try
+ {
+ reply->completed(reply);
+ }
+ catch (...)
+ {
+ }
+ return reply;
}
int portHandle;
void getPropertyAsync(AsyncPropertyReply *reply);
void getRangePropertyAsync(AsyncRangePropertyReply *reply){}
- void setProperty(VehicleProperty::Property, AbstractPropertyType*);
+ AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
PropertyList supported();
void WebSocketSinkManager::setValue(string property,string value)
{
AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(property,value);
- m_engine->setProperty(property, type);
+
+ AsyncSetPropertyRequest request;
+ request.property = property;
+ request.value = type;
+ request.completed = [](AsyncPropertyReply* reply)
+ {
+ ///TODO: do something here on !reply->success
+ delete reply;
+ };
+
+ m_engine->setProperty(request);
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "AbstractRoutingEngine::setProperty called with arguments:" << property << value << "\n";
delete type;
{
return m_supportedProperties;
}
-extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
-{
- return new WebSocketSource(routingengine, config);
-
-}
+
string WebSocketSource::uuid()
{
return "d293f670-f0b3-11e1-aff1-0800200c9a66";
///TODO: fill in
}
-void WebSocketSource::setProperty(VehicleProperty::Property , AbstractPropertyType * )
+AsyncPropertyReply * WebSocketSource::setProperty( AsyncSetPropertyRequest request )
{
///TODO: fill in
+ return NULL;
+}
+
+extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
+{
+ return new WebSocketSource(routingengine, config);
+
}
string uuid();
void getPropertyAsync(AsyncPropertyReply *reply);
void getRangePropertyAsync(AsyncRangePropertyReply *reply);
- void setProperty(VehicleProperty::Property, AbstractPropertyType*);
+ AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
PropertyList supported();
delete reply->value;
}
-void WheelSourcePlugin::setProperty(VehicleProperty::Property , AbstractPropertyType * )
+AsyncPropertyReply *WheelSourcePlugin::setProperty(AsyncSetPropertyRequest request )
{
}
string uuid();
void getPropertyAsync(AsyncPropertyReply *reply);
void getRangePropertyAsync(AsyncRangePropertyReply *reply){}
- void setProperty(VehicleProperty::Property, AbstractPropertyType*);
+ AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
void subscribeToPropertyChanges(VehicleProperty::Property property);
void unsubscribeToPropertyChanges(VehicleProperty::Property property);
PropertyList supported();