aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-05-11 15:42:29 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-11 15:42:29 +0900
commitf317b379ffd8a7c0f20cd2dd9f81be2d112e73fb (patch)
tree5396b33544696bb64f9cf3fe64ea7ea63881ed70
parent160b8947d684ce037120cf5237bd221bd9ea9785 (diff)
LowCanClient can set filter
Change-Id: I9464b631a5b36cdfeba28ebd146fce3f5ca7f879 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/low_can_client.cpp14
-rw-r--r--src/low_can_client.hpp21
2 files changed, 32 insertions, 3 deletions
diff --git a/src/low_can_client.cpp b/src/low_can_client.cpp
index 01a7340..a42e641 100644
--- a/src/low_can_client.cpp
+++ b/src/low_can_client.cpp
@@ -66,12 +66,20 @@ void LowCanClient::initialize() {
// low-can subscribe { "event": "headlamp_status" }
// low-can subscribe { "event": "parking_brake_status" }
// low-can subscribe { "event": "accelerator.pedal.position" }
- int num_event = this->kEventName_.size();
- for (int i=0; i<num_event; i++) {
+ for (int i=SignalNoMin; i<=SignalNoMax; i++) {
+ // Set Event
json_object *json_obj = json_object_new_object();
- json_object_object_add(json_obj, "event", json_object_new_string(this->kEventName_[i]));
+ json_object_object_add(json_obj, "event",
+ json_object_new_string(this->kEventName_[i]));
+
+ // Set filter
+ if (0 != strcmp("", this->kFilterValue_[i])) {
+ json_object_object_add(json_obj, "filter",
+ json_tokener_parse(this->kFilterValue_[i]));
+ }
HMI_DEBUG("wm:lcc", "subscribe message:%s", json_object_get_string(json_obj));
+ // Subscribe
json_object *json_result = json_object_new_object();
ret = afb_service_call_sync("low-can", "subscribe", json_obj, &json_result);
if (0 > ret) {
diff --git a/src/low_can_client.hpp b/src/low_can_client.hpp
index 2941e6e..5ba671e 100644
--- a/src/low_can_client.hpp
+++ b/src/low_can_client.hpp
@@ -49,6 +49,19 @@ private:
LowCanClient(LowCanClient &&) = delete;
LowCanClient &operator=(LowCanClient &&) = delete;
+ enum SignalNo {
+ SignalNoVehicliSpeed = 0,
+ SignalNoTransGearPos,
+ SignalNoHeadlame,
+ SignalNoParkingBrake,
+ SignalNoAccelPedalPos,
+
+ SignalNum,
+
+ SignalNoMin = SignalNoVehicliSpeed,
+ SignalNoMax = SignalNum - 1,
+ };
+
const std::vector<const char*> kEventName_{
"vehicle.speed",
"transmission_gear_position",
@@ -57,6 +70,14 @@ private:
"accelerator.pedal.position",
};
+ const std::vector<const char*> kFilterValue_{
+ "",
+ "",
+ "",
+ "",
+ "", //"{ \"min\": 0, \"max\": 10}",
+ };
+
int vehicle_speed_;
int trans_gear_pos_;
json_bool headlamp_status_;