"sources" : [
{
- "path" : "/usr/lib/automotive-message-broker/examplesourceplugin.so"
+ "path" : "/usr/lib/automotive-message-broker/murphysourceplugin.so"
}
],
"sinks": [
{
DebugOut()<<"executing script"<<endl;
- QTimer* timer = new QTimer(this);
-
- timer->setInterval(20000);
+ QTimer *timer = new QTimer();
timer->setSingleShot(true);
- timer->start();
+ timer->connect(timer, SIGNAL(timeout(QPrivateSignal)), this, SLOT(timeout(QPrivateSignal)));
+ timer->start(5000);
+
+ timerIdMap[timer] = id;
+}
+
+void BluemonkeyAgent::timeout(QPrivateSignal)
+{
+ quint64 id = timerIdMap[sender()];
+
+ if(idList.contains(id))
+ {
+ DebugOut()<<"script aborted evaluation. timed out."<<endl;
+ engine()->abortEvaluation();
+ }
- QScriptEngine* e = engine();
+ timerIdMap.remove(sender());
- connect(timer, &QTimer::timeout, [id,&e,&timer,this](){
- if(idList.contains(id))
- {
- e->abortEvaluation();
- }
- });
+ sender()->deleteLater();
}
void BluemonkeyAgent::scriptUnload(qint64 id)
void scriptLoad (qint64 id, const QString &program, const QString &fileName, int baseLineNumber );
void scriptUnload(qint64 id);
+private Q_SLOTS:
+ void timeout(QPrivateSignal);
+
private:
QList<quint64> idList;
+ QMap<QObject*,quint64> timerIdMap;
};
}
-BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSink(e, config), agent(nullptr), engine(nullptr)
+BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config): QObject(0), AbstractSink(e, config), agent(nullptr), engine(nullptr), mSilentMode(false)
{
irc = new IrcCommunication(config, this);
{
if(!auth->isAuthorized(prefix))
{
- irc->respond(sender, "denied");
+ if(!mSilentMode)
+ irc->respond(sender, "denied");
return;
}
codes = codes.mid(bm.length()+1);
- irc->respond(sender, engine->evaluate(codes).toString());
+ QString response = engine->evaluate(codes).toString();
+
+ if(!mSilentMode || response != "undefined" )
+ irc->respond(sender, response);
}
});
-
-
}
void getHistory(QStringList properties, QDateTime begin, QDateTime end, QScriptValue cbFunction);
+ void setSilentMode(bool m)
+ {
+ mSilentMode = m;
+ }
+
private Q_SLOTS: /// methods:
void loadConfigPriv();
Authenticate* auth;
BluemonkeyAgent* agent;
+ bool mSilentMode;
};
class BluemonkeySinkManager: public AbstractSinkManager
QTimer::singleShot(5000,this,SLOT(open()));
}
-void IrcCommunication::sslError(QList<QSslError> &)
+void IrcCommunication::sslError(QList<QSslError> )
{
qDebug()<<"some ssl errors!! trying to ignore them";
QSslSocket* sock = qobject_cast<QSslSocket*>(socket());
void IrcCommunication::setIgnoreInvalidCert(bool ignore)
{
if(ignore)
- QObject::connect(socket(),SIGNAL(sslErrors(QList<QSslError>&)),this,SLOT(sslError(QList<QSslError>&)));
+ QObject::connect(socket(),SIGNAL(sslErrors(QList<QSslError>)),this,SLOT(sslError(QList<QSslError>)));
}
private Q_SLOTS:
void onMessageReceived(IrcMessage*);
- void sslError(QList<QSslError> &);
+ void sslError(QList<QSslError>);
void socketError(QAbstractSocket::SocketError);
Q_SIGNALS:
"<signal name='" + pn + "Changed' >"
" <arg type='v' name='" + nameToLower + "' direction='out' />"
" <arg type='d' name='timestamp' direction='out' />"
- "</signal>";
+ "</signal>"
+ "<property type='i' name='" + property->name() + "Sequence' access='read' />";
properties[property->name()] = property;
g_variant_builder_init(&builder, G_VARIANT_TYPE_DICTIONARY);
g_variant_builder_add(&builder, "{sv}", property->name().c_str(), val);
+ g_variant_builder_add(&builder, "{sv}", std::string(property->name() + "Sequence").c_str(), g_variant_new("(i)", property->sequence()));
g_variant_builder_add(&builder, "{sv}", "Time", g_variant_new("(d)", mTime) );
GError *error2 = NULL;
return value;
}
+ if(boost::ends_with(pn, "Sequence"))
+ {
+ AbstractDBusInterface* t = static_cast<AbstractDBusInterface*>(userData);
+
+ int pos = pn.find("Sequence");
+
+ std::string p = pn.substr(0,pos);
+
+ AbstractProperty* theProperty = t->property(p);
+
+ if(!theProperty)
+ {
+ DebugOut(DebugOut::Error)<<"Invalid Sequence property: "<<p<<endl;
+ return nullptr;
+ }
+
+ int sequence = theProperty->sequence();
+
+ GVariant* value = g_variant_new("(i)", sequence);
+ return value;
+ }
+
if(pn == "Zone")
{
if(objectMap.find(objectPath) == objectMap.end())
double time() { return mTime; }
+ AbstractProperty* property(std::string propertyName)
+ {
+ if(properties.find(propertyName) != properties.end())
+ return properties[propertyName];
+ return nullptr;
+ }
+
AbstractRoutingEngine* re;
void setObjectPath(std::string op)
return mTimestamp;
}
+ int sequence()
+ {
+ if(mValue)
+ return mValue->sequence;
+ return 0;
+ }
+
virtual void setValue(AbstractPropertyType* val)
{
if(mValue) delete mValue;