--- /dev/null
+/*
+Copyright (C) 2012 Intel Corporation
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "wheelplugin.h"
+
+#include <iostream>
+#include <boost/assert.hpp>
+#include <glib.h>
+
+using namespace std;
+
+#include "debugout.h"
+
+static gboolean timeoutCallback(gpointer data)
+{
+ WheelSourcePlugin* src = (WheelSourcePlugin*)data;
+
+ src->randomizeProperties();
+
+ return true;
+}
+
+WheelSourcePlugin::WheelSourcePlugin(AbstractRoutingEngine* re)
+:AbstractSource(re), velocity(0), engineSpeed(0)
+{
+ re->setSupported(supported(), this);
+
+ debugOut("setting timeout");
+ g_timeout_add(1000, timeoutCallback, this );
+
+}
+
+
+
+extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine)
+{
+ return new WheelSourcePlugin(routingengine);
+
+}
+
+string WheelSourcePlugin::uuid()
+{
+ return "6dd4268a-c605-4a06-9034-59c1e8344c8e";
+}
+
+boost::any WheelSourcePlugin::getProperty(VehicleProperty::Property property)
+{
+ if(property == VehicleProperty::VehicleSpeed)
+ {
+ return velocity;
+ }
+ else if(property == VehicleProperty::EngineSpeed)
+ {
+ return engineSpeed;
+ }
+}
+
+void WheelSourcePlugin::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);
+ }
+}
+
+void WheelSourcePlugin::setProperty(VehicleProperty::Property , boost::any )
+{
+
+}
+
+void WheelSourcePlugin::subscribeToPropertyChanges(VehicleProperty::Property property)
+{
+ mRequests.push_back(property);
+}
+
+PropertyList WheelSourcePlugin::supported()
+{
+ PropertyList props;
+ props.push_back(VehicleProperty::EngineSpeed);
+ props.push_back(VehicleProperty::VehicleSpeed);
+
+ return props;
+}
+
+void WheelSourcePlugin::unsubscribeToPropertyChanges(VehicleProperty::Property property)
+{
+ mRequests.remove(property);
+}
+
+void WheelSourcePlugin::randomizeProperties()
+{
+ velocity = 1 + (255.00 * (rand() / (RAND_MAX + 1.0)));
+ engineSpeed = 1 + (15000.00 * (rand() / (RAND_MAX + 1.0)));
+
+ DebugOut()<<"setting velocity to: "<<velocity<<endl;
+ DebugOut()<<"setting enginespeed to: "<<engineSpeed<<endl;
+
+ routingEngine->updateProperty(VehicleProperty::VehicleSpeed, velocity);
+ routingEngine->updateProperty(VehicleProperty::EngineSpeed, engineSpeed);
+}
--- /dev/null
+/*
+Copyright (C) 2012 Intel Corporation
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef WHEELPLUGIN_H
+#define WHEELPLUGIN_H
+
+#include <abstractsource.h>
+#include <string>
+
+using namespace std;
+
+class WheelSourcePlugin: public AbstractSource
+{
+
+public:
+ WheelSourcePlugin(AbstractRoutingEngine* re);
+
+ string uuid();
+ boost::any getProperty(VehicleProperty::Property property);
+ void getPropertyAsync(AsyncPropertyReply *reply);
+ void setProperty(VehicleProperty::Property, boost::any);
+ void subscribeToPropertyChanges(VehicleProperty::Property property);
+ void unsubscribeToPropertyChanges(VehicleProperty::Property property);
+ PropertyList supported();
+
+ void propertyChanged(VehicleProperty::Property property, boost::any value, string uuid) {}
+ void supportedChanged(PropertyList) {}
+
+ void randomizeProperties();
+
+private:
+ PropertyList mRequests;
+ uint16_t velocity;
+ uint16_t engineSpeed;
+};
+
+#endif // WHEELPLUGIN_H