summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2013-09-16 15:40:00 -0700
committerKevron Rees <kevron.m.rees@intel.com>2013-09-16 15:40:00 -0700
commite60c4af4f37df81b39df305b63667a517a934076 (patch)
tree9e26d0f9d378900557c16f558aa083387f160554
parent679a6c7fba2536eec10b57fb96b56385d56db8e7 (diff)
downloadautomotive-message-broker-e60c4af4f37df81b39df305b63667a517a934076.tar.gz
make bluemonkey a source
-rw-r--r--examples/bluemonkey/bluemonkeyconfig12
-rw-r--r--plugins/bluemonkey/bluemonkey.cpp61
-rw-r--r--plugins/bluemonkey/bluemonkey.h24
3 files changed, 85 insertions, 12 deletions
diff --git a/examples/bluemonkey/bluemonkeyconfig b/examples/bluemonkey/bluemonkeyconfig
index 0c15befe..9677ba58 100644
--- a/examples/bluemonkey/bluemonkeyconfig
+++ b/examples/bluemonkey/bluemonkeyconfig
@@ -3,18 +3,18 @@
"sources" : [
{
- "path" : "/usr/lib/automotive-message-broker/examplesourceplugin.so"
- }
- ],
- "sinks": [
- {
- "name" : "Bluemonkey Sink",
"path" : "/usr/lib/automotive-message-broker/bluemonkeyplugin.so",
"authSettings" : "authSettings.js",
"ircSettings" : "ircSettings.js",
"config" : "config.js",
"customPrograms" : "customPrograms.js"
+ }
+ ],
+
+ "sinks" : [
+ {
+ "path" : "/usr/lib/automotive-message-broker/examplesinkplugin.so"
}
]
}
diff --git a/plugins/bluemonkey/bluemonkey.cpp b/plugins/bluemonkey/bluemonkey.cpp
index c57eba2d..13030c0c 100644
--- a/plugins/bluemonkey/bluemonkey.cpp
+++ b/plugins/bluemonkey/bluemonkey.cpp
@@ -89,7 +89,7 @@ QVariant gvariantToQVariant(GVariant *value)
}
-BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSink(e, config), agent(nullptr), engine(nullptr), mSilentMode(false)
+BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSource(e, config), agent(nullptr), engine(nullptr), mSilentMode(false)
{
irc = new IrcCommunication(config, this);
@@ -155,6 +155,36 @@ const string BluemonkeySink::uuid()
return "bluemonkey";
}
+void BluemonkeySink::getPropertyAsync(AsyncPropertyReply *reply)
+{
+}
+
+void BluemonkeySink::getRangePropertyAsync(AsyncRangePropertyReply *reply)
+{
+}
+
+AsyncPropertyReply *BluemonkeySink::setProperty(AsyncSetPropertyRequest request)
+{
+}
+
+void BluemonkeySink::subscribeToPropertyChanges(VehicleProperty::Property property)
+{
+}
+
+void BluemonkeySink::unsubscribeToPropertyChanges(VehicleProperty::Property property)
+{
+}
+
+PropertyList BluemonkeySink::supported()
+{
+ return mSupported;
+}
+
+int BluemonkeySink::supportedOperations()
+{
+ return AbstractSource::Get | AbstractSource::Set;
+}
+
QObject *BluemonkeySink::subscribeTo(QString str)
{
return new Property(str.toStdString(), "", routingEngine, this);
@@ -301,6 +331,35 @@ void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTi
routingEngine->getRangePropertyAsync(request);
}
+void BluemonkeySink::createCustomProperty(QString name, QScriptValue defaultValue)
+{
+
+ auto create = [defaultValue, name]() -> AbstractPropertyType*
+ {
+ QVariant var = defaultValue.toVariant();
+
+ if(!var.isValid())
+ return nullptr;
+
+ if(var.type() == QVariant::UInt)
+ return new BasicPropertyType<uint>(name.toStdString(),var.toUInt());
+ else if(var.type() == QVariant::Double)
+ return new BasicPropertyType<double>(name.toStdString(), var.toDouble());
+ else if(var.type() == QVariant::Bool)
+ return new BasicPropertyType<bool>(name.toStdString(), var.toBool());
+ else if(var.type() == QVariant::Int)
+ return new BasicPropertyType<int>(name.toStdString(),var.toInt());
+ else if(var.type() == QVariant::String)
+ return new StringPropertyType(name.toStdString(),var.toString().toStdString());
+
+
+ return nullptr;
+ };
+
+ VehicleProperty::registerProperty(name.toStdString(),create);
+ mSupported.push_back(name.toStdString());
+}
+
QVariant Property::value()
{
diff --git a/plugins/bluemonkey/bluemonkey.h b/plugins/bluemonkey/bluemonkey.h
index 5c2b9a8b..9a3b2c49 100644
--- a/plugins/bluemonkey/bluemonkey.h
+++ b/plugins/bluemonkey/bluemonkey.h
@@ -20,7 +20,7 @@
#ifndef BluemonkeySink_H
#define BluemonkeySink_H
-#include "abstractsink.h"
+#include "abstractsource.h"
#include <QObject>
#include <QVariant>
#include <QJsonDocument>
@@ -70,7 +70,7 @@ private:
};
-class BluemonkeySink : public QObject, public AbstractSink
+class BluemonkeySink : public QObject, public AbstractSource
{
Q_OBJECT
public:
@@ -82,6 +82,22 @@ public:
QScriptEngine* engine;
+ /// source methods:
+ virtual void getPropertyAsync(AsyncPropertyReply *reply);
+ virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply);
+ virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
+ virtual void subscribeToPropertyChanges(VehicleProperty::Property property);
+ virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property);
+ virtual PropertyList supported();
+
+ virtual int supportedOperations();
+
+private: //source privates
+
+ PropertyList mSupported;
+ std::list<AbstractPropertyType*> propertyValueCache;
+
+
public Q_SLOTS:
QObject* subscribeTo(QString str);
@@ -106,9 +122,7 @@ public Q_SLOTS:
mSilentMode = m;
}
-private Q_SLOTS: /// methods:
-
- void loadConfigPriv();
+ void createCustomProperty(QString name, QScriptValue defaultValue);
private:
QStringList configsToLoad;