2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <boost/assert.hpp>
22 #include <boost/lexical_cast.hpp>
25 //#include <json-glib/json-glib.h>
26 #include <listplusplus.h>
28 #include "timestamp.h"
29 #include "testplugin.h"
30 #define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
31 AbstractRoutingEngine *m_re;
33 //std::list<ObdPid*> Obd2Amb::supportedPidsList;
35 bool beginsWith(std::string a, std::string b)
37 return (a.compare(0, b.length(), b) == 0);
39 void TestPlugin::updateProperty(VehicleProperty::Property property,AbstractPropertyType* value)
44 void TestPlugin::setSupported(PropertyList list)
46 m_re->updateSupported(list,PropertyList());
48 void TestPlugin::setConfiguration(map<string, string> config)
50 // //Config has been passed, let's start stuff up.
53 TestPlugin::TestPlugin(AbstractRoutingEngine *re, map<string, string> config)
54 : AbstractSource(re, config)
56 DebugOut() << "Testing MapPropertyType" << endl;
57 MapPropertyType<BasicPropertyType<Door::Location>,BasicPropertyType<Door::Status>> propmap("something");
58 MapPropertyType<BasicPropertyType<Door::Location>,BasicPropertyType<Door::Status>> propmaptwo("something");
59 propmap.append(Door::LeftRear,Door::Ajar);
60 GVariant *var = propmap.toVariant();
61 gsize dictsize = g_variant_n_children(var);
62 //DebugOut() << var << endl;
63 propmaptwo.fromVariant(var);
64 DebugOut() << propmap.toString() << propmaptwo.toString() << endl;
65 if (propmap.toString() == propmap.toString())
67 DebugOut() << "Success!" << endl;
71 DebugOut() << "Failure" << endl;
75 DebugOut() << "Testing ListPropertyType" << endl;
76 ListPropertyType<BasicPropertyType<uint16_t> > listpropmap("something");
77 ListPropertyType<BasicPropertyType<uint16_t> > listpropmaptwo("something");
78 //listpropmap.append(new VehicleProperty::AccelerationXType());
79 //listpropmap.append(new VehicleProperty::MachineGunTurretStatusType());
80 listpropmap.append(new AbstractPropertyType<VehicleProperty::TripMeters>());
81 GVariant *newvar = listpropmap.toVariant();
82 DebugOut() << "Newvar created" << endl;
83 listpropmaptwo.fromVariant(newvar);
84 DebugOut() << listpropmap.toString() << listpropmaptwo.toString() << endl;
85 if (listpropmap.toString() == listpropmaptwo.toString())
87 DebugOut() << "Success!" << endl;
91 DebugOut() << "Failure" << endl;
95 DebugOut() << "Exiting..." << endl;
98 TestPlugin::~TestPlugin()
100 DebugOut() << "TestPlugin Destructor called!!!"<<endl;
103 PropertyList TestPlugin::supported()
105 return PropertyList();
108 int TestPlugin::supportedOperations()
113 extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
115 return new TestPlugin(routingengine, config);
118 string TestPlugin::uuid()
120 return "f77af740-f1f8-11e1-aff1-0800200c9a66";
122 void TestPlugin::subscribeToPropertyChanges(VehicleProperty::Property property)
127 void TestPlugin::unsubscribeToPropertyChanges(VehicleProperty::Property property)
132 void TestPlugin::getPropertyAsync(AsyncPropertyReply *reply)
137 AsyncPropertyReply *TestPlugin::setProperty(AsyncSetPropertyRequest request )
139 AsyncPropertyReply* reply = new AsyncPropertyReply (request);