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());
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*
return nullptr;
};
- addPropertySupport(Zone::None, create);
+ addPropertySupport(zone, create);
routingEngine->updateSupported(supported(), PropertyList(), &source);
}
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());
}
void Property::propertyChanged(AbstractPropertyType *value)
{
+ if(value->zone != mZone)
+ return;
+
if(mValue)
{
delete mValue;
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;
+}
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);
void setValue(QVariant v);
void getHistory(QDateTime begin, QDateTime end, QJSValue cbFunction);
+
+ Zone::Type zone() { return mZone; }
+
Q_SIGNALS:
void changed(QVariant val);
private:
AbstractPropertyType* mValue;
const std::string mUuid;
+ Zone::Type mZone;
};
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();
mSilentMode = m;
}
- void createCustomProperty(QString name, QJSValue defaultValue);
+ void createCustomProperty(QString name, QJSValue defaultValue, Zone::Type zone);
private:
QStringList configsToLoad;