aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/source.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'signal-composer-binding/source.cpp')
-rw-r--r--signal-composer-binding/source.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/signal-composer-binding/source.cpp b/signal-composer-binding/source.cpp
index 6e7fec2..80c59d6 100644
--- a/signal-composer-binding/source.cpp
+++ b/signal-composer-binding/source.cpp
@@ -33,19 +33,39 @@ void SourceAPI::addSignal(const std::string& id, std::vector<std::string>& sourc
{
std::shared_ptr<Signal> sig = std::make_shared<Signal>(id, sources, unit, frequency, onReceived);
- signals_.push_back(sig);
+ signalsList_.push_back(sig);
}
std::vector<std::shared_ptr<Signal>> SourceAPI::getSignals() const
{
- return signals_;
+ return signalsList_;
}
std::shared_ptr<Signal> SourceAPI::searchSignal(const std::string& name) const
{
- for (auto& sig: signals_)
+ for (auto& sig: signalsList_)
{
if(*sig == name) {return sig;}
}
return nullptr;
}
+
+int SourceAPI::makeSubscription() const
+{
+ int err = 0;
+ if(getSignal_)
+ {
+ for(std::shared_ptr<Signal> sig: signalsList_)
+ {
+ json_object* lowSignalNameJ = sig->toJSON();
+ if(!lowSignalNameJ)
+ {
+ AFB_ERROR("Error building JSON query object to subscribe to for signal %s", sig->id().c_str());
+ return -1;
+ }
+ err += ActionExecOne(getSignal_, lowSignalNameJ);
+ }
+ }
+
+ return err;
+}