ReModule_LcmControl.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. #include <sys/time.h>
  2. #include <sys/timeb.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <sys/ipc.h>
  9. #include <sys/shm.h>
  10. #include <sys/shm.h>
  11. #include <sys/mman.h>
  12. #include <linux/wireless.h>
  13. #include <arpa/inet.h>
  14. #include <netinet/in.h>
  15. #include <unistd.h>
  16. #include <stdarg.h>
  17. #include <stdio.h> /*標準輸入輸出定義*/
  18. #include <stdlib.h> /*標準函數庫定義*/
  19. #include <unistd.h> /*Unix 標準函數定義*/
  20. #include <fcntl.h> /*檔控制定義*/
  21. #include <termios.h> /*PPSIX 終端控制定義*/
  22. #include <errno.h> /*錯誤號定義*/
  23. #include <errno.h>
  24. #include <string.h>
  25. #include <time.h>
  26. #include <ctype.h>
  27. #include <ifaddrs.h>
  28. #include <stdbool.h>
  29. #include "../../define.h"
  30. #include "Config.h"
  31. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  32. #define PASS 1
  33. #define FAIL -1
  34. #define YES 1
  35. #define NO 0
  36. typedef unsigned char byte;
  37. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  38. struct StatusCodeData *ShmStatusCodeData;
  39. struct FanModuleData *ShmFanModuleData;
  40. struct PrimaryMcuData *ShmPrimaryMcuData;
  41. #define NO_DEFINE 255
  42. #define DEFAULT_AC_INDEX 2
  43. #define TIME_MAX_SEC 2592000 // 一個月,秒數
  44. #define POWER_MAX_KW 5000
  45. #define ENERGY_MAX_KWH 5000
  46. #define CMD_TITLE_1 0x5A
  47. #define CMD_TITLE_2 0xA5
  48. #define CMD_READ 0x80
  49. #define CMD_WRITE 0x81
  50. #define CMD_MULTI_WRITE 0x82
  51. #define CMD_MULTI_READ 0x83
  52. #define CMD_BACKLIGHT 0x01
  53. #define CMD_REGISTER 0x03
  54. //#define NOODOE_QR_CODE_URL "https://ev-alpha-test.noodoe.com/station?id=" ////For Audi
  55. #define NOODOE_QR_CODE_URL "https://ev.noodoe.com/station?id=" ////For Audi
  56. enum _BATTERY_LEVEL_FOR_MAP {
  57. _BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
  58. _BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
  59. _BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
  60. _BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
  61. _BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
  62. _BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
  63. };
  64. int _port;
  65. //char* pPortName = "/dev/ttyO2";
  66. char *pPortName = "/dev/ttyS3";
  67. char *moduleName = "DMT80480T070_09WT";
  68. byte _totalCount;
  69. byte acgunCount;
  70. struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  71. struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
  72. byte ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
  73. byte isDiffStatus = false;
  74. byte isChangeBattMap = false;
  75. // 當前選擇的槍號
  76. #if defined DD360Audi
  77. short _currentPage = _LCM_SELECT_GUN;
  78. short _oldPage = _LCM_SELECT_GUN;
  79. #else
  80. short _currentPage = _LCM_NONE;
  81. short _oldPage = _LCM_NONE;
  82. #endif //defined DD360Audi
  83. byte _gunIndex = 0;
  84. bool _wifi_conn_status = false;
  85. bool _battery_display_ani = false;
  86. byte _curPage_index = 0;
  87. bool _page_reload = false;
  88. // LCM - HW
  89. byte _everyPageRollChange = 0;
  90. short __conn_status = 0x0030;
  91. short __ethernet_status = 0x0032;
  92. short __3G4G_status = 0x0036;
  93. short __3G4G_status1 = 0x0037;
  94. short __3G4G_move_status = 0x0038;
  95. short __wifi_status = 0x003C;
  96. short __sel_gun_btn = 0x0040;
  97. short __ret_home_btn = 0x0042;
  98. short __stop_method_btn = 0x0044;
  99. short __qr_code = 0x0250;
  100. short __main_rfid = 0x0052;
  101. short __main_qr = 0x0054;
  102. short __main_app = 0x0056;
  103. short __plug_in_arrow = 0x0060;
  104. short __conn_line = 0x0066;
  105. short __gun_type_index = 0x0070;
  106. short __cmp_gun_type_index = 0x0080; ////For Audi
  107. short __batt_map_empty = 0x0090; ////For Audi
  108. short __qr_code_pre = 0x0280;
  109. short __side_top = 0x0090;
  110. short __side_down = 0x0092;
  111. short __side_mid = 0x0094;
  112. short __conn_line_chag = 0x0096;
  113. short __batt_map = 0x0100;
  114. short __soc_value_charging = 0x0102;
  115. short __remain_time_map = 0x0106;
  116. short __power_map = 0x0108;
  117. short __energy_map = 0x010A;
  118. short __remain_time_tx = 0x0110;
  119. short __trp_remain_time_map = 0x0116;
  120. short __trp_power_map = 0x0118;
  121. short __trp_energy_map = 0x011A;
  122. short __output_eng_tx = 0x0120;
  123. short __total_out_eng_tx = 0x0130;
  124. short __conn_line_comp = 0x0140;
  125. short __charging_fee_map = 0x0146;
  126. short __charging_fee_tx = 0x0150;
  127. short __money_by_rate = 0x0200;
  128. short __money_rate = 0x0220;
  129. short __money_rate_map = 0x0230;
  130. //DS60-120 add
  131. short __csu_ver_string = 0x0300;
  132. short __csu_ver_value = 0x0310;
  133. short __fan_speed_string = 0x0390;
  134. short __fan_speed_value = 0x0400;
  135. short __dc1_ver_string = 0x0320;
  136. short __dc1_ver_value = 0x0330;
  137. short __dc2_ver_string = 0x0340;
  138. short __dc2_ver_value = 0x0350;
  139. short __eth0_ip_string = 0x0360;
  140. short __eth0_ip_value = 0x0370;
  141. short __sn_string = 0x0410;
  142. short __sn_value = 0x0420;
  143. //For Audi, for select gun
  144. short __left_gun_map = 0x0260;
  145. short __right_gun_map = 0x0262;
  146. short __add_chk_btn = 0x0264;
  147. //short __station_id = 0x0270;
  148. short __balance = 0x0270;
  149. short __remain_balance = 0x0280;
  150. short __custStationIdL1 = 0x0450;
  151. //short __custStationIdL2 = 0x0470;
  152. short _emergency_map = 0x011C;
  153. // ICON ID
  154. byte _disappear = 0;
  155. byte _disconnect = 1;
  156. byte _connect = 2;
  157. byte _warning = 3;
  158. byte _arrow_dark = 4;
  159. byte _arrow_light = 5;
  160. byte _3G4G_disconnect = 6;
  161. byte __3G4G_connect = 7;
  162. byte _wifi_disconnect = 8;
  163. byte _wifi_connect = 9;
  164. byte _logo = 10;
  165. byte _conn_map1 = 11;
  166. byte _conn_map2 = 12;
  167. byte _sel_gun_btn = 13;
  168. byte _back_home_btn = 14;
  169. byte _stop_charging_btn = 15;
  170. byte _stop_charging_btn_scan = 16;
  171. byte _chademo_dark = 17;
  172. byte _ccs_dark = 18;
  173. byte _gbt_dark = 19;
  174. byte _actype_dark = 20;
  175. byte _chademo_light = 21;
  176. byte _ccs_light = 22;
  177. byte _gbt_light = 23;
  178. byte _actype_light = 24;
  179. byte _main_none_rfid = 25;
  180. byte _main_rfid = 26;
  181. byte _main_none_app = 27;
  182. byte _main_app = 28;
  183. byte _main_none_qr = 29;
  184. byte _main_qr = 30;
  185. byte _charging_map1 = 31;
  186. byte _charging_map2 = 32;
  187. byte _battery_empty = 33;
  188. byte _battery_cap_20 = 34;
  189. byte _battery_cap_40 = 35;
  190. byte _battery_cap_60 = 36;
  191. byte _battery_cap_80 = 37;
  192. byte _battery_cap_100 = 38;
  193. byte _battery_map = 39;
  194. byte _power_map = 40;
  195. byte _time_map = 41;
  196. byte _complete_map = 42;
  197. byte _battery_soc_20 = 43;
  198. byte _battery_soc_40 = 44;
  199. byte _battery_soc_60 = 45;
  200. byte _battery_soc_80 = 46;
  201. byte _battery_soc_100 = 47;
  202. byte _battery_eng_map = 48;
  203. byte _money_map = 49;
  204. byte _elapse_time_map = 50;
  205. byte _charging_money = 51;
  206. //byte _side_none_rfid = 52;
  207. //byte _side_rfid = 53;
  208. //byte _side_none_app = 54;
  209. //byte _side_app = 55;
  210. //byte _side_none_qr = 56;
  211. //byte _side_qr = 57;
  212. byte _eth_disconnect = 52; //58;
  213. byte _eth_connect = 53; //59;
  214. byte _chademo_dark_cmp = 54;
  215. byte _ccs_dark_cmp = 55;
  216. byte _gbt_dark_cmp = 56;
  217. byte _actype_dark_cmp = 57;
  218. byte _chademo_light_cmp = 58;
  219. byte _ccs_light_cmp = 59;
  220. byte _gbt_light_cmp = 60;
  221. byte _actype_light_cmp = 61;
  222. byte _logo_cmp = 62;
  223. byte _battery_eng_trp_map = 63;
  224. byte _money_trp_map = 64;
  225. byte _elapse_time_trp_map = 65;
  226. ////For Audi
  227. byte _left_gun_disable_map = 66;
  228. byte _left_gun_enable_map = 67;
  229. byte _right_gun_disable_map = 68;
  230. byte _right_gun_enable_map = 69;
  231. byte _select_gun_btn = 70;
  232. byte _emergency_disable_map = 72;