initial zone support for bluemonkey
authorKevron Rees <kevron.m.rees@intel.com>
Tue, 14 Oct 2014 22:06:20 +0000 (15:06 -0700)
committerKevron Rees <kevron.m.rees@intel.com>
Tue, 14 Oct 2014 22:06:20 +0000 (15:06 -0700)
plugins/bluemonkey/bluemonkey.cpp
plugins/bluemonkey/bluemonkey.h

index e92175e..a7f0785 100644 (file)
@@ -132,14 +132,20 @@ int BluemonkeySink::supportedOperations()
 
 QObject *BluemonkeySink::subscribeTo(QString str)
 {
-       return new Property(str.toStdString(), "", routingEngine, this);
+       return new Property(str.toStdString(), "", routingEngine, Zone::None, this);
 }
 
 QObject *BluemonkeySink::subscribeToSource(QString str, QString srcFilter)
 {
-       return new Property(str.toStdString(), srcFilter, routingEngine, this);
+       return new Property(str.toStdString(), srcFilter, routingEngine, Zone::None, this);
 }
 
+QObject* BluemonkeySink::subscribeToZone(QString str, int zone)
+{
+       return new Property(str.toStdString(), "", routingEngine, zone, this);
+}
+
+
 QStringList BluemonkeySink::sourcesForProperty(QString property)
 {
        std::list<std::string> list = routingEngine->sourcesForProperty(property.toStdString());
@@ -316,7 +322,7 @@ void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTi
        routingEngine->getRangePropertyAsync(request);
 }
 
-void BluemonkeySink::createCustomProperty(QString name, QJSValue defaultValue)
+void BluemonkeySink::createCustomProperty(QString name, QJSValue defaultValue, Zone::Type zone = Zone::None)
 {
 
        auto create = [defaultValue, name]() -> AbstractPropertyType*
@@ -341,7 +347,7 @@ void BluemonkeySink::createCustomProperty(QString name, QJSValue defaultValue)
                        return nullptr;
        };
 
-       addPropertySupport(Zone::None, create);
+       addPropertySupport(zone, create);
 
        routingEngine->updateSupported(supported(), PropertyList(), &source);
 }
@@ -424,8 +430,8 @@ void Property::getHistory(QDateTime begin, QDateTime end, QJSValue cbFunction)
        routingEngine->getRangePropertyAsync(request);
 }
 
-Property::Property(VehicleProperty::Property prop, QString srcFilter, AbstractRoutingEngine* re, QObject *parent)
-       :QObject(parent), AbstractSink(re, std::map<std::string,std::string>()),mValue(nullptr), mUuid(amb::createUuid())
+Property::Property(VehicleProperty::Property prop, QString srcFilter, AbstractRoutingEngine* re, Zone::Type zone, QObject *parent)
+       :QObject(parent), AbstractSink(re, std::map<std::string,std::string>()),mValue(nullptr), mUuid(amb::createUuid()), mZone(zone)
 {
        setType(prop.c_str());
 }
@@ -462,6 +468,9 @@ void Property::setType(QString t)
 
 void Property::propertyChanged(AbstractPropertyType *value)
 {
+       if(value->zone != mZone)
+               return;
+
        if(mValue)
        {
                delete mValue;
@@ -470,3 +479,18 @@ void Property::propertyChanged(AbstractPropertyType *value)
 
        changed(gvariantToQVariant(mValue->toVariant()));
 }
+
+
+QVariant BluemonkeySink::zonesForProperty(QString prop, QString src)
+{
+       PropertyInfo info = routingEngine->getPropertyInfo(prop.toStdString(), src.toStdString());
+
+       QVariantList list;
+
+       for(auto i : info.zones())
+       {
+               list << i;
+       }
+
+       return list;
+}
index 19b8edb..13ee9ba 100644 (file)
@@ -49,9 +49,10 @@ class Property: public QObject, public AbstractSink
        Q_OBJECT
        Q_PROPERTY(QString type READ type)
        Q_PROPERTY(QVariant value READ value WRITE setValue)
+       Q_PROPERTY(int zone READ zone)
 
 public:
-       Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, QObject *parent = 0);
+       Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, Zone::Type zone = Zone::None, QObject *parent = 0);
 
        QString type();
        void setType(QString t);
@@ -70,6 +71,9 @@ public:
        void setValue(QVariant v);
 
        void getHistory(QDateTime begin, QDateTime end, QJSValue cbFunction);
+
+       Zone::Type zone() { return mZone; }
+
 Q_SIGNALS:
 
        void changed(QVariant val);
@@ -77,6 +81,7 @@ Q_SIGNALS:
 private:
        AbstractPropertyType* mValue;
        const std::string mUuid;
+       Zone::Type mZone;
 
 };
 
@@ -104,8 +109,10 @@ public Q_SLOTS:
 
        QObject* subscribeTo(QString str);
        QObject* subscribeToSource(QString str, QString srcFilter);
+       QObject* subscribeToZone(QString str, int zone);
 
        QStringList sourcesForProperty(QString property);
+       QVariant zonesForProperty(QString property, QString src);
 
        QStringList supportedProperties();
 
@@ -130,7 +137,7 @@ public Q_SLOTS:
                mSilentMode = m;
        }
 
-       void createCustomProperty(QString name, QJSValue defaultValue);
+       void createCustomProperty(QString name, QJSValue defaultValue, Zone::Type zone);
 
 private:
        QStringList configsToLoad;