diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-01 13:46:10 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-01 18:40:13 +0200 |
commit | e9b00c3af0c469726e32755715a69395ad1d3718 (patch) | |
tree | a4ab62ebf0a69a9657292104cd7ee822af996d42 /CAN-binder/low-can-binding/can | |
parent | 4499dbbeadc3fb2a7234d2021097ddca2ba3351e (diff) |
Simplify processing event
Set afb_event into subscription object then there is no more
std::pair used t access it, better use a method from
low_can_subscription_t class
Change-Id: Ic0772d97c18ca8899821cf3ce175166bbe0be660
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/can')
-rw-r--r-- | CAN-binder/low-can-binding/can/can-bus.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/CAN-binder/low-can-binding/can/can-bus.cpp b/CAN-binder/low-can-binding/can/can-bus.cpp index 65e2acd..56cde47 100644 --- a/CAN-binder/low-can-binding/can/can-bus.cpp +++ b/CAN-binder/low-can-binding/can/can-bus.cpp @@ -74,12 +74,12 @@ void can_bus_t::process_can_signals(const can_message_t& can_message) { std::lock_guard<std::mutex> subscribed_signals_lock(sm.get_subscribed_signals_mutex()); - std::map<int, std::pair<std::shared_ptr<low_can_subscription_t>, struct afb_event> >& s = sm.get_subscribed_signals(); + std::map<int, std::shared_ptr<low_can_subscription_t> >& s = sm.get_subscribed_signals(); // First we have to found which can_signal_t it is - std::shared_ptr<low_can_subscription_t> sig = s[subscription_id].first; + std::shared_ptr<low_can_subscription_t> sig = s[subscription_id]; - if( s.find(subscription_id) != s.end() && afb_event_is_valid(s[subscription_id].second)) + if( s.find(subscription_id) != s.end() && afb_event_is_valid(s[subscription_id]->get_event())) { bool send = true; decoded_message = decoder_t::translateSignal(*sig->get_can_signal(), can_message, conf.get_all_can_signals(), &send); @@ -112,17 +112,17 @@ void can_bus_t::process_diagnostic_signals(diagnostic_manager_t& manager, const { std::lock_guard<std::mutex> subscribed_signals_lock(sm.get_subscribed_signals_mutex()); - std::map<int, std::pair<std::shared_ptr<low_can_subscription_t>, struct afb_event> >& s = sm.get_subscribed_signals(); + std::map<int, std::shared_ptr<low_can_subscription_t> >& s = sm.get_subscribed_signals(); openxc_VehicleMessage vehicle_message = manager.find_and_decode_adr(can_message); if( (vehicle_message.has_simple_message && vehicle_message.simple_message.has_name) && - s.find(subscription_id) != s.end() && afb_event_is_valid(s[subscription_id].second)) + s.find(subscription_id) != s.end() && afb_event_is_valid(s[subscription_id]->get_event())) { - if (apply_filter(vehicle_message, s[subscription_id].first)) + if (apply_filter(vehicle_message, s[subscription_id])) { std::lock_guard<std::mutex> decoded_can_message_lock(decoded_can_message_mutex_); push_new_vehicle_message(subscription_id, vehicle_message); - DEBUG(binder_interface, "%s: %s CAN signals processed.", __FUNCTION__, s[subscription_id].first->get_name().c_str()); + DEBUG(binder_interface, "%s: %s CAN signals processed.", __FUNCTION__, s[subscription_id]->get_name().c_str()); } } } @@ -180,12 +180,12 @@ void can_bus_t::can_event_push() s_message = get_simple_message(v_message.second); { std::lock_guard<std::mutex> subscribed_signals_lock(sm.get_subscribed_signals_mutex()); - std::map<int, std::pair<std::shared_ptr<low_can_subscription_t>, struct afb_event> >& s = sm.get_subscribed_signals(); - if(s.find(v_message.first) != s.end() && afb_event_is_valid(s[v_message.first].second)) + std::map<int, std::shared_ptr<low_can_subscription_t> >& s = sm.get_subscribed_signals(); + if(s.find(v_message.first) != s.end() && afb_event_is_valid(s[v_message.first]->get_event())) { jo = json_object_new_object(); jsonify_simple(s_message, jo); - if(afb_event_push(s[v_message.first].second, jo) == 0) + if(afb_event_push(s[v_message.first]->get_event(), jo) == 0) on_no_clients(std::string(s_message.name)); } } |