automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
amb.h
1 #ifndef _AMB_BLUEMONKEY_PLUGIN_H_
2 #define _AMB_BLUEMONKEY_PLUGIN_H_
3 
4 #include "bluemonkey.h"
5 
6 #include <abstractsource.h>
7 #include <ambpluginimpl.h>
8 #include <uuidhelper.h>
9 
10 #include <map>
11 
12 
13 class Property: public QObject, public AbstractSink
14 {
15  Q_OBJECT
16  Q_PROPERTY(QString name READ name)
17  Q_PROPERTY(QString source READ source)
18  Q_PROPERTY(double timestamp READ timestamp)
19  Q_PROPERTY(QVariant value READ value WRITE setValue)
20  Q_PROPERTY(int zone READ zone)
21 
22 public:
23  Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine * re, Zone::Type zone = Zone::None, QObject * parent = 0);
24 
25  QString name();
26  void setType(QString t);
27 
28  QString source()
29  {
30  return mValue->sourceUuid.c_str();
31  }
32 
33  double timestamp()
34  {
35  return mValue->timestamp;
36  }
37 
38  virtual PropertyList subscriptions() { return PropertyList(); }
39  virtual void supportedChanged(const PropertyList &)
40  {
41  DebugOut()<<"Bluemonkey Property Supported Changed"<<endl;
42  }
43 
44  virtual void propertyChanged(AbstractPropertyType* value);
45 
46  virtual const std::string uuid() { return mUuid; }
47 
48  QVariant value();
49  void setValue(QVariant v);
50 
51  void getHistory(QDateTime begin, QDateTime end, QJSValue cbFunction);
52 
53  Zone::Type zone() { return mZone; }
54 
55 Q_SIGNALS:
56 
57  void changed(QVariant val);
58 
59 private:
60  AbstractPropertyType* mValue;
61  const std::string mUuid;
62  Zone::Type mZone;
63 
64 };
65 
66 
67 class BluemonkeySink : public QObject, public AmbPluginImpl
68 {
69 Q_OBJECT
70 
71 public:
73  using QObject::setProperty;
74 
75  BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource& parent);
76  ~BluemonkeySink();
77  void init();
78  virtual PropertyList subscriptions();
79  virtual void supportedChanged(const PropertyList & supportedProperties);
81  virtual const std::string uuid() const;
82 
83  virtual int supportedOperations();
84 
85 private: //source privates
86 
87  PropertyList mSupported;
88  std::list<AbstractPropertyType*> propertyValueCache;
89 
90 
91 public Q_SLOTS:
92 
93  QObject* subscribeTo(QString str);
94  QObject* subscribeTo(QString str, int zone);
95  QObject* subscribeTo(QString str, int zone, QString srcFilter);
96 
97  QStringList sourcesForProperty(QString property);
98  QVariant zonesForProperty(QString property, QString src);
99 
100  QStringList supportedProperties();
101 
102  bool authenticate(QString pass);
103 
104  void getHistory(QStringList properties, QDateTime begin, QDateTime end, QJSValue cbFunction);
105 
106  void setSilentMode(bool m)
107  {
108  mSilentMode = m;
109  }
110 
111  void createCustomProperty(QString name, QJSValue defaultValue)
112  {
113  createCustomProperty(name, defaultValue, Zone::None);
114  }
115 
116  void createCustomProperty(QString name, QJSValue defaultValue, int zone);
117 
118  void exportInterface(QString name, QJSValue properties);
119 
120 private:
121  Bluemonkey* bluemonkey;
122  Authenticate* auth;
123  bool mSilentMode;
124 };
125 
126 #endif