Module_LcmContro.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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/mman.h>
  11. #include <linux/wireless.h>
  12. #include <arpa/inet.h>
  13. #include <netinet/in.h>
  14. #include <unistd.h>
  15. #include <stdarg.h>
  16. #include <stdio.h> /*標準輸入輸出定義*/
  17. #include <stdlib.h> /*標準函數庫定義*/
  18. #include <unistd.h> /*Unix 標準函數定義*/
  19. #include <fcntl.h> /*檔控制定義*/
  20. #include <termios.h> /*PPSIX 終端控制定義*/
  21. #include <errno.h> /*錯誤號定義*/
  22. #include <string.h>
  23. #include <time.h>
  24. #include <ctype.h>
  25. #include <ifaddrs.h>
  26. #include <stdbool.h>
  27. #include <dirent.h>
  28. #include "lcmComm_dgus.h"
  29. #include "cbmp.h"
  30. #include "../../define.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. #define EQUAL 0
  37. typedef unsigned char byte;
  38. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  39. struct StatusCodeData *ShmStatusCodeData;
  40. struct FanModuleData *ShmFanModuleData;
  41. struct DcCommonInformation *ShmDcCommonData;
  42. #define NO_DEFINE 255
  43. #define DEFAULT_AC_INDEX 2
  44. #define TIME_MAX_SEC 2592000 // 一個月,秒數
  45. #define POWER_MAX_KW 5000
  46. #define ENERGY_MAX_KWH 5000
  47. #define CMD_BACKLIGHT 0x01
  48. #define CMD_REGISTER 0x03
  49. //=======================================
  50. // Register Control type
  51. //=======================================
  52. #define REG_TYPE_CONTROL 0x00
  53. #define REG_TYPE_RAM 0x01
  54. #define REG_TYPE_SPECIAL_CONTROL 0x02
  55. enum _BATTERY_LEVEL_FOR_MAP
  56. {
  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 Uart1Fd;
  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. byte _lcmGunSelect;
  76. byte _lcmGunStatus;
  77. // 當前選擇的槍號
  78. short _currentPage = _LCM_NONE;
  79. short _oldPage = _LCM_NONE;
  80. byte _gunIndex = 0;
  81. bool _battery_display_ani = false;
  82. byte _curPage_index = 0;
  83. bool _page_reload = false;
  84. byte QRCodeBuf[128];
  85. // LCM - HW
  86. byte _everyPageRollChange = 0;
  87. short __logo = 0x0000;
  88. short __conn_status = 0x0030;
  89. short __ethernet_status = 0x0032;
  90. short __3G4G_status = 0x0036;
  91. short __3G4G_move_status = 0x0038;
  92. short __wifi_status = 0x003C;
  93. short __sel_gun_btn = 0x0040;
  94. short __ret_home_btn = 0x0042;
  95. short __stop_method_btn = 0x0044;
  96. short __phihong_string = 0x0046;
  97. short __lcm_version = 0x004A;
  98. short __qr_code = 0x0250;
  99. short __main_rfid = 0x0052;
  100. short __main_qr = 0x0054;
  101. short __main_app = 0x0056;
  102. short __plug_in_arrow = 0x0060;
  103. short __conn_line = 0x0066;
  104. short __gun_type_index = 0x0070;
  105. short __gun_type_index_jp = 0x0076;
  106. short __cmp_gun_type_index = 0x0080;
  107. short __cmp_gun_type_index_jp = 0x0086;
  108. short __qr_code_pre = 0x0280;
  109. short __batt_map_empty = 0x0090;
  110. //LW_tpc plug detect
  111. short __tpc_detect_map = 0x0092;
  112. short __conn_line_chag = 0x0096;
  113. short __conn1_cabinet_charging = 0x0098;
  114. short __conn1_cabinet_complete = 0x009A;
  115. short __batt_map = 0x0100;
  116. short __soc_value_charging = 0x0102;
  117. short __remain_time_map = 0x0106;
  118. short __power_map = 0x0108;
  119. short __energy_map = 0x010A;
  120. short __remain_time_tx = 0x0110;
  121. short __trp_remain_time_map = 0x0116;
  122. short __trp_power_map = 0x0118;
  123. short __trp_energy_map = 0x011A;
  124. short __output_eng_tx = 0x0120;
  125. short __total_out_eng_tx = 0x0130;
  126. short __conn_line_comp = 0x0140;
  127. short __charging_fee_map = 0x0146;
  128. short __logo_cmp = 0x014A;
  129. short __charging_fee_tx = 0x0150;
  130. short __money_by_rate = 0x0200;
  131. short __money_rate = 0x0220;
  132. short __money_rate_map = 0x0230;
  133. short __csu_ver_string = 0x0300;
  134. short __csu_ver_value = 0x0310;
  135. short __fan_speed_string = 0x0390;
  136. short __fan_speed_value = 0x0400;
  137. short __dc1_ver_string = 0x0320;
  138. short __dc1_ver_value = 0x0330;
  139. short __dc2_ver_string = 0x0340;
  140. short __dc2_ver_value = 0x0350;
  141. short __eth0_ip_string = 0x0360;
  142. short __eth0_ip_value = 0x0370;
  143. short __sn_string = 0x0410;
  144. short __sn_value = 0x0420;
  145. short __sys_date_value = 0x0470;
  146. short __sys_time_value = 0x0480;
  147. short __sys_period_value = 0x0489;
  148. short __Energy_Cost_complete = 0x0500;
  149. short __Parking_Fee_complete = 0x0510;
  150. short __Total_Cost_complete = 0x0520;
  151. short __ctep_time_string = 0x0530;
  152. short __ctep_energy_string = 0x0540;
  153. short __ctep_energy_mon_string = 0x0550;
  154. short __ctep_packing_mon_string = 0x0560;
  155. short __ctep_total_mon_string = 0x0570;
  156. short __Energy_Cost_charging = 0x0610;
  157. short __Parking_Fee_charging = 0x0620;
  158. short __Total_Cost_charging = 0x0630;
  159. short __Energy_Cost_comp = 0x0640;
  160. short __Parking_Fee_comp = 0x0650;
  161. short __Total_Cost_comp = 0x0660;
  162. short __receipt_qrcode = 0x0670;
  163. short __receipt_qrcode_bg = 0x0700;
  164. short _ctep_energy_mon_comm = 0x0702;
  165. short _ctep_packing_mon_comm = 0x0704;
  166. short _ctep_total_mon_comm = 0x0706;
  167. short _ctep_energy_mon_chg = 0x0708;
  168. short _ctep_packing_mon_chg = 0x070A;
  169. short _ctep_total_mon_chg = 0x070C;
  170. short _ctep_energy_mon_comp = 0x070E;
  171. short _ctep_packing_mon_comp = 0x0710;
  172. short _ctep_total_mon_comp = 0x0712;
  173. short __scroll_display_value = 0x6010;
  174. // ICON ID
  175. byte _disappear = 0;
  176. byte _disconnect = 1;
  177. byte _connect = 2;
  178. byte _warning = 3;
  179. byte _arrow_dark = 4;
  180. byte _arrow_light = 5;
  181. byte _3G4G_disconnect = 6;
  182. byte _3G4G_connect = 7;
  183. byte _wifi_disconnect = 8;
  184. byte _wifi_connect = 9;
  185. byte _logo = 10;
  186. byte _conn_map1 = 11;
  187. byte _conn_map2 = 12;
  188. byte _sel_gun_btn = 13;
  189. byte _back_home_btn = 14;
  190. byte _stop_charging_btn = 15;
  191. byte _stop_charging_btn_scan = 16;
  192. byte _chademo_dark = 17;
  193. byte _ccs_dark = 18;
  194. byte _gbt_dark = 19;
  195. byte _actype_dark = 20;
  196. byte _chademo_light = 21;
  197. byte _ccs_light = 22;
  198. byte _gbt_light = 23;
  199. byte _actype_light = 24;
  200. byte _main_none_rfid = 25;
  201. byte _main_rfid = 26;
  202. byte _main_none_app = 27;
  203. byte _main_app = 28;
  204. byte _main_none_qr = 29;
  205. byte _main_qr = 30;
  206. byte _charging_map1 = 31;
  207. byte _charging_map2 = 32;
  208. byte _battery_empty = 33;
  209. byte _battery_cap_20 = 34;
  210. byte _battery_cap_40 = 35;
  211. byte _battery_cap_60 = 36;
  212. byte _battery_cap_80 = 37;
  213. byte _battery_cap_100 = 38;
  214. byte _battery_map = 39;
  215. byte _power_map = 40;
  216. byte _time_map = 41;
  217. byte _complete_map = 42;
  218. byte _battery_soc_20 = 43;
  219. byte _battery_soc_40 = 44;
  220. byte _battery_soc_60 = 45;
  221. byte _battery_soc_80 = 46;
  222. byte _battery_soc_100 = 47;
  223. byte _battery_eng_map = 48;
  224. byte _money_map = 49;
  225. byte _elapse_time_map = 50;
  226. byte _charging_money = 51;
  227. byte _ethernet_disconnect = 52;
  228. byte _ethernet_connect = 53;
  229. byte _chademo_dark_cmp = 54;
  230. byte _ccs_dark_cmp = 55;
  231. byte _gbt_dark_cmp = 56;
  232. byte _actype_dark_cmp = 57;
  233. byte _chademo_light_cmp = 58;
  234. byte _ccs_light_cmp = 59;
  235. byte _gbt_light_cmp = 60;
  236. byte _actype_light_cmp = 61;
  237. byte _logo_cmp = 62;
  238. byte _battery_eng_trp_map = 63;
  239. byte _money_trp_map = 64;
  240. byte _elapse_time_trp_map = 65;
  241. byte _phihong_string_map = 66;
  242. byte _ctep_qr_background = 67;
  243. byte _ctep_packing_mon_comm_map = 68;
  244. byte _ctep_energy_mon_comm_map = 69;
  245. byte _ctep_total_mon_comm_map = 70;
  246. byte _ctep_packing_mon_comp_map = 71;
  247. byte _ctep_energy_mon_comp_map = 72;
  248. byte _ctep_total_mon_comp_map = 73;
  249. byte _ctep_packing_mon_chg_map= 74;
  250. byte _ctep_energy_mon_chg_map = 75;
  251. byte _ctep_total_mon_chg_map = 76;
  252. //LW_tpc plug detect
  253. byte _tpc_start_detect_btn = 77;
  254. byte _tpc_wait_plugin_btn= 78;
  255. byte _n1_jp_cha_dark = 96;
  256. byte _n2_jp_cha_dark = 97;
  257. byte _n1_jp_cha_light = 98;
  258. byte _n2_jp_cha_light = 99;
  259. byte _n1_jp_cha_dark_cmp = 100;
  260. byte _n2_jp_cha_dark_cmp = 101;
  261. byte _n1_jp_cha_light_cmp = 102;
  262. byte _n2_jp_cha_light_cmp = 103;
  263. byte _conn1_cabinet_double_chg_map = 104;
  264. byte _conn2_cabinet_single_chg_map = 105;
  265. byte _conn1_cabinet_double_cop_map = 106;
  266. byte _conn2_cabinet_single_cop_map = 107;