2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief Pseudo-driving vehicle
21 #include "CJoyStick.h"
22 #include "CJoyStickEV.h"
23 #include "CJoyStickG25.h"
24 #include "CJoyStickG27.h"
34 #include <sys/types.h>
41 #include <glib-object.h>
42 #include <json-glib/json-glib.h>
45 #include "AmbpiComm.h"
52 const useconds_t g_sleeptime = 10000; // = 10milli sec = 0.01 sec
53 const int g_JoyStickTypeNum = 3;
54 const std::string g_ConfPathG25 = "/etc/carsim/G25.conf";
55 const std::string g_ConfPathG27 = "/etc/carsim/G27.conf";
56 #define D_RUNLOOP_INTERVAL_COUNT 5
57 #define D_RUNLOOP_INTERVAL_COUNT2 50
60 #define PIE 3.14159265
63 #define NOTRCSIZE(n) (n | 0x01000000)
65 #define NOTRCSIZE(n) (n)
69 #define AMB_CONF "/etc/ambd/config"
77 void DisconnectClient(int ClientID);
78 int ClientHandShake(int ClientID);
79 int ClientRequest(int ClientID);
83 void FullMakeFdSet(void);
85 void DaemonTerminate(int SigNo);
88 struct VehicleInfoNameList
90 const static int maxlen = 64;
94 char name[maxlen][64];
95 long priority[maxlen];
97 /*--------------------------------------------------------------------------*/
104 /*--------------------------------------------------------------------------*/
108 memset(&name[0], 0x00, maxlen * 64);
109 memset(&priority[0], 0x00, sizeof(priority));
112 /*--------------------------------------------------------------------------*/
114 * @brief check to exist vehicle information name
116 * @param[in] s name of vehicle information
117 * @return bool true:exist
119 /*--------------------------------------------------------------------------*/
120 bool isContainVehicleName(const char *s)
126 if (getIdx(s) >= 0) {
132 /*--------------------------------------------------------------------------*/
134 * @brief set priority to send vehicle information
136 * @param[in] s name of vehicle information
137 * @param[in] p priority
140 /*--------------------------------------------------------------------------*/
141 void setPriority(const char *s, long p)
147 if ((idx = getIdx(s)) >= 0) {
152 /*--------------------------------------------------------------------------*/
154 * @brief get priority to send vehicle information
156 * @param[in] s name of vehicle information
157 * @return int priority. if negative value returned, failure
159 /*--------------------------------------------------------------------------*/
160 long getPriority(const char *s)
167 if ((idx = getIdx(s)) >= 0) {
175 /*--------------------------------------------------------------------------*/
177 * @brief get number of vehicle information list
179 * @param[in] s name of vehicle information
180 * @return int number of element
182 /*--------------------------------------------------------------------------*/
183 int getIdx(const char *s)
185 int limit = length < maxlen ? length : maxlen;
187 for (int i = 0; i < limit; i++) {
188 if (!strcmp(name[i], s)) {
213 int nBrakeHydraulicPressure;
217 bool bHeadLight; // HEAD LIGHT ON(true)/OFF(false) status
279 static void signal_handler(int signo);
286 std::string m_strConfPath;
288 VehicleInfo m_stVehicleInfo;
290 int m_ambpicomm_port[4];
291 AmbpiCommIF m_ambpicomm_client[4];
292 KeyEventOptMsg_t m_msgOpt;
293 KeyDataMsg_t m_msgDat;
295 VehicleInfoNameList m_viList;
297 std::list<std::string> m_sendMsgInfo;
299 bool LoadConfigJson(const char *);
300 bool LoadConfigAMBJson(const char *, char *, int);
301 bool LoadConfigJsonCommon(JsonReader *);
302 bool LoadConfigJsonCarSim(JsonReader *);
303 void DelJsonObj(JsonParser *, JsonReader *);
304 bool SendVehicleInfo(ProtocolType type, const char *key, bool data);
305 bool SendVehicleInfo(ProtocolType type, const char *key, int data);
306 bool SendVehicleInfo(ProtocolType type, const char *key, int data[],
308 bool SendVehicleInfo(ProtocolType type, const char *key, double data[],
310 bool SendVehicleInfo(ProtocolType type, const char *key, char data[],
312 bool sendVehicleInfo(ProtocolType type, const char *key, void *data,
313 unsigned int unit_size, int unit_cnt);
314 bool GetConfigValue(JsonReader *, const char *, char *, int);
315 bool GetConfigValue(JsonReader *, const char *, int *, int);
316 bool GetConfigValue(JsonReader *, const char *, double *, int);
317 bool GetConfigValue(JsonReader *, const char *, bool *, int);
318 bool GetConfigValText(JsonReader *, const char *, char *, int);
319 bool GetConfigValInt(JsonReader *, const char *, int *);
320 bool GetConfigValDouble(JsonReader *, const char *, double *);
321 bool GetConfigValBool(JsonReader *, const char *, bool *);
322 void SetMQKeyData(char *buf, unsigned int bufsize, long &mtype,
323 const char *key, char status[], unsigned int size);
324 void CheckSendResult(int mqid);
327 #endif /* CGTCTRL_H_ */
329 * End of File.(CGtCtrl.h)