LowCanClient can set filter
[apps/agl-service-windowmanager.git] / src / low_can_client.hpp
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef TMCAGLWM_LOW_CAN_CLIENT_HPP
18 #define TMCAGLWM_LOW_CAN_CLIENT_HPP
19
20
21 #include <string>
22 #include <vector>
23 #include <json-c/json.h>
24
25
26 namespace wm {
27
28 class LowCanClient {
29
30 public:
31     explicit LowCanClient();
32     ~LowCanClient() = default;
33
34     void initialize();
35     void analyzeCanSignal(struct json_object *object);
36     bool isChangedLampState();
37     bool isChangedParkingBrakeState();
38     bool isChangedAccelPedalState();
39     bool isChangedCarState();
40     const char* getCurrentLampState();
41     const char* getCurrentParkingBrakeState();
42     const char* getCurrentAccelPedalState();
43     const char* getCurrentCarState();
44
45 private:
46     // Disable copy and move
47     LowCanClient(LowCanClient const &) = delete;
48     LowCanClient &operator=(LowCanClient const &) = delete;
49     LowCanClient(LowCanClient &&) = delete;
50     LowCanClient &operator=(LowCanClient &&) = delete;
51
52     enum SignalNo {
53         SignalNoVehicliSpeed = 0,
54         SignalNoTransGearPos,
55         SignalNoHeadlame,
56         SignalNoParkingBrake,
57         SignalNoAccelPedalPos,
58
59         SignalNum,
60
61         SignalNoMin = SignalNoVehicliSpeed,
62         SignalNoMax = SignalNum - 1,
63     };
64
65     const std::vector<const char*> kEventName_{
66         "vehicle.speed",
67         "transmission_gear_position",
68         "headlamp_status",
69         "parking_brake_status",
70         "accelerator.pedal.position",
71     };
72
73     const std::vector<const char*> kFilterValue_{
74         "",
75         "",
76         "",
77         "",
78         "", //"{ \"min\": 0, \"max\": 10}",
79     };
80
81     int vehicle_speed_;
82     int trans_gear_pos_;
83     json_bool headlamp_status_;
84     json_bool parking_brake_status_;
85     double accel_pedal_pos_;
86
87     std::string prv_lamp_state_;
88     std::string crr_lamp_state_;
89     std::string prv_parking_brake_state_;
90     std::string crr_parking_brake_state_;
91     std::string prv_accel_pedal_state_;
92     std::string crr_accel_pedal_state_;
93     std::string prv_car_state_;
94     std::string crr_car_state_;
95
96     bool is_changed_lamp_state_;
97     bool is_changed_parking_brake_state_;
98     bool is_changed_accel_pedal_state_;
99     bool is_changed_car_state_;
100 };
101
102 } // namespace wm
103
104
105 #endif  // TMCAGLWM_LOW_CAN_CLIENT_HPP