summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-14 18:19:46 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-14 18:19:46 +0100
commitb59d45196f14f2401e148bbe37c04b514850d859 (patch)
tree1507647a3084c98ef606a83dc0a9179ae44e2d23
parent28c03d4ea61c7ec40d62e49818bdfb2d8ef80a7f (diff)
Implement GetSignals method
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--src/can-signals.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/can-signals.cpp b/src/can-signals.cpp
index 13ff30b1..7af957f9 100644
--- a/src/can-signals.cpp
+++ b/src/can-signals.cpp
@@ -16,6 +16,7 @@
*/
#include <string>
+#include <vector>
#include "can-signals.h"
bool match(const std::string &first, const std::string &second)
@@ -23,18 +24,34 @@ bool match(const std::string &first, const std::string &second)
}
-CanSignal* getSignals(std::string name)
+CanSignal* getSignals(openxc_DynamicField *key)
{
int n_signals, i;
- CanSignal ret_signals[];
+ std::vector <CanSignal> ret_signals;
- n_signals = size(SIGNALS);
+ n_signals = SIGNALS.size();
- for(i=0; i<=n_signals; i++)
+ switch(key->type):
{
- if(SIGNALS[i].generic_name == name)
- return &SIGNALS[i];
- i++;
+ case openxc_DynamicField_Type::openxc_DynamicField_Type_STRING:
+ for(i=0; i<=n_signals; i++)
+ {
+ if(match((std::string*)key->string_value, (std::string*)SIGNALS[i]->genericName))
+ ret_signals.insert(&SIGNALS[i]);
+ }
+ break;
+ case openxc_DynamicField_Type::openxc_DynamicField_Type_NUM:
+ for(i=0; i<=n_signals; i++)
+ {
+ CanMessageDefinition *msg_def = SIGNALS[i]->message;
+ if(msg_def->id == key->numeric_value)
+ ret_signals.insert(&SIGNALS[i])
+ }
+ break;
+ default:
+ return NULL;
+ break;
}
- return 0;
-}
+
+ return &ret_signals;
+} \ No newline at end of file