add source for ces2019
[apps/agl-service-windowmanager-2017.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 #include <string>
21 #include <vector>
22 #include <json-c/json.h>
23
24 namespace wm
25 {
26
27 class LowCanClient
28 {
29
30   public:
31     explicit LowCanClient();
32     ~LowCanClient() = default;
33
34     enum SignalNo
35     {
36         SignalNoVehicliSpeed = 0,
37         SignalNoTransGearPos,
38         SignalNoHeadlame,
39         SignalNoParkingBrake,
40         SignalNoAccelPedalPos,
41         SignalNoLightstatusBrake,
42
43         SignalNum,
44
45         SignalNoMin = SignalNoVehicliSpeed,
46         SignalNoMax = SignalNum - 1,
47     };
48
49     const std::vector<const char *> kSignalName{
50         "vehicle.speed",
51         "transmission_gear_position",
52         "headlamp_status",
53         "parking_brake_status",
54         "accelerator.pedal.position",
55         "lightstatus.brake",
56     };
57
58     void initialize();
59     const char *analyzeCanSignal(struct json_object *object);
60
61     int getCurrentTransGearState();
62     bool getCurrentHeadlampState();
63     bool getCurrentParkingBrakeState();
64     double getCurrentAccelPedalPosition();
65     bool getCurrentAccelPedalState();
66     bool getCurrentLightstatusBrakeState();
67
68     bool isChangedAccelPedalState();
69
70   private:
71     // Disable copy and move
72     LowCanClient(LowCanClient const &) = delete;
73     LowCanClient &operator=(LowCanClient const &) = delete;
74     LowCanClient(LowCanClient &&) = delete;
75     LowCanClient &operator=(LowCanClient &&) = delete;
76
77     enum TransGearPosVal
78     {
79         TransGearPosValD1 = 1,
80         TransGearPosValD2,
81         TransGearPosValD3,
82         TransGearPosValD4,
83         TransGearPosValD5,
84         TransGearPosValD6,
85         TransGearPosValD7,
86         TransGearPosValD8,
87         TransGearPosValR,
88         TransGearPosValN,
89     };
90
91     const std::vector<const char *> kFilterValue{
92         "", // vehicle.speed
93         "", // transmission_gear_position
94         "", // headlamp_status
95         "", // parking_brake_status
96         "", // accelerator.pedal.position
97         "", // lightstatus.brake
98     };
99
100     int vehicle_speed;
101     int trans_gear_pos;
102     json_bool headlamp_status;
103     json_bool parking_brake_status;
104     double accel_pedal_pos;
105     bool accel_pedal_stt;
106     json_bool lightstatus_brake_status;
107
108     bool is_changed_accel_pedal_stt;
109 };
110
111 } // namespace wm
112
113 #endif // TMCAGLWM_LOW_CAN_CLIENT_HPP