diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/low_can_client.cpp | 14 | ||||
-rw-r--r-- | src/low_can_client.hpp | 21 |
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_; |