aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-16 19:52:41 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit5bbc6cb56995d23cb8a4eb584ef0161be092da1f (patch)
tree0a63676d64a67f4323ed5e7fce1be147f95c2e69 /signal-composer-binding/signal.cpp
parentde24d7de2b87f5d8164f49fb130f8693b32362a0 (diff)
Adding new verb, implemented basic signal method
Change-Id: I453ddc0ca374436275e7d76cdc27b3d843a2770f Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal.cpp')
-rw-r--r--signal-composer-binding/signal.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/signal-composer-binding/signal.cpp b/signal-composer-binding/signal.cpp
index 2dc517c..147aef0 100644
--- a/signal-composer-binding/signal.cpp
+++ b/signal-composer-binding/signal.cpp
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+#include <float.h>
+#include <fnmatch.h>
#include <memory>
#include "signal.hpp"
@@ -45,12 +47,12 @@ bool Signal::operator ==(const Signal& other) const
return false;
}
-bool Signal::operator==(const std::string& aName) const
+bool Signal::operator ==(const std::string& aName) const
{
- if(id_ == aName) {return true;}
+ if(! fnmatch(aName.c_str(), id_.c_str(), FNM_CASEFOLD)) {return true;}
for( const std::string& src : signalSigList_)
{
- if(src == aName) {return true;}
+ if(! fnmatch(aName.c_str(), src.c_str(), FNM_CASEFOLD)) {return true;}
}
return false;
}
@@ -152,3 +154,33 @@ int Signal::recursionCheck()
}
return 0;
}
+
+double Signal::average(int seconds) const
+{
+ return 0.0;
+}
+double Signal::minimum() const
+{
+ double min = DBL_MAX;
+ for (auto& v : history_)
+ {
+ double temp_min = v.second;
+ if(temp_min < min) { min = temp_min;}
+ }
+ return min;
+}
+
+double Signal::maximum() const
+{
+ double max = 0.0;
+ for (auto& v : history_)
+ {
+ double temp_max = v.second;
+ if(temp_max > max) { max = temp_max;}
+ }
+ return max;
+}
+double Signal::last() const
+{
+ return history_.rbegin()->second;
+}