Module_LcmContro.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  31. #define PASS 1
  32. #define FAIL -1
  33. #define YES 1
  34. #define NO 0
  35. typedef unsigned char byte;
  36. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  37. struct StatusCodeData *ShmStatusCodeData;
  38. struct FanModuleData *ShmFanModuleData;
  39. #define NO_DEFINE 255
  40. #define DEFAULT_AC_INDEX 2
  41. #define TIME_MAX_SEC 2592000 // 一個月,秒數
  42. #define POWER_MAX_KW 5000
  43. #define ENERGY_MAX_KWH 5000
  44. #define CMD_TITLE_1 0x5A
  45. #define CMD_TITLE_2 0xA5
  46. #define CMD_READ 0x80
  47. #define CMD_WRITE 0x81
  48. #define CMD_MULTI_WRITE 0x82
  49. #define CMD_MULTI_READ 0x83
  50. #define CMD_BACKLIGHT 0x01
  51. #define CMD_REGISTER 0x03
  52. enum _BATTERY_LEVEL_FOR_MAP
  53. {
  54. _BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
  55. _BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
  56. _BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
  57. _BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
  58. _BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
  59. _BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
  60. };
  61. int _port;
  62. //char* pPortName = "/dev/ttyO2";
  63. char* pPortName = "/dev/ttyS3";
  64. char* moduleName = "DMT80480T070_09WT";
  65. byte _totalCount;
  66. byte acgunCount;
  67. struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  68. struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
  69. byte ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
  70. byte isDiffStatus = false;
  71. byte isChangeBattMap = false;
  72. // 當前選擇的槍號
  73. short _currentPage = _LCM_NONE;
  74. short _oldPage = _LCM_NONE;
  75. byte _gunIndex = 0;
  76. bool _wifi_conn_status = false;
  77. bool _battery_display_ani = false;
  78. byte _curPage_index = 0;
  79. bool _page_reload = false;
  80. // LCM - HW
  81. byte _everyPageRollChange = 0;
  82. short __conn_status = 0x0030;
  83. short __ethernet_status = 0x0036;
  84. short __wifi_status = 0x003C;
  85. short __sel_gun_btn = 0x0040;
  86. short __ret_home_btn = 0x0042;
  87. short __stop_method_btn = 0x0044;
  88. short __qr_code = 0x0250;
  89. short __main_rfid = 0x0052;
  90. short __main_qr = 0x0054;
  91. short __main_app = 0x0056;
  92. short __plug_in_arrow = 0x0060;
  93. short __conn_line = 0x0066;
  94. short __gun_type_index = 0x0070;
  95. short __qr_code_pre = 0x0280;
  96. short __side_top = 0x0090;
  97. short __side_down = 0x0092;
  98. short __side_mid = 0x0094;
  99. short __conn_line_chag = 0x0096;
  100. short __batt_map = 0x0100;
  101. short __soc_value_charging = 0x0102;
  102. short __remain_time_map = 0x0106;
  103. short __power_map = 0x0108;
  104. short __energy_map = 0x010A;
  105. short __remain_time_tx = 0x0110;
  106. short __output_eng_tx = 0x0120;
  107. short __total_out_eng_tx = 0x0130;
  108. short __conn_line_comp = 0x0140;
  109. short __charging_fee_map = 0x0146;
  110. short __charging_fee_tx = 0x0150;
  111. short __money_by_rate = 0x0200;
  112. short __money_rate = 0x0220;
  113. short __money_rate_map = 0x0230;
  114. // ICON ID
  115. byte _disappear = 0;
  116. byte _disconnect = 1;
  117. byte _connect = 2;
  118. byte _warning = 3;
  119. byte _arrow_dark = 4;
  120. byte _arrow_light = 5;
  121. byte _ethernet_disconnect = 6;
  122. byte _ethernet_connect = 7;
  123. byte _wifi_disconnect = 8;
  124. byte _wifi_connect = 9;
  125. byte _logo = 10;
  126. byte _conn_map1 = 11;
  127. byte _conn_map2 = 12;
  128. byte _sel_gun_btn = 13;
  129. byte _back_home_btn = 14;
  130. byte _stop_charging_btn = 15;
  131. byte _stop_charging_btn_scan = 16;
  132. byte _chademo_dark = 17;
  133. byte _ccs_dark = 18;
  134. byte _gbt_dark = 19;
  135. byte _actype_dark = 20;
  136. byte _chademo_light = 21;
  137. byte _ccs_light = 22;
  138. byte _gbt_light = 23;
  139. byte _actype_light = 24;
  140. byte _main_none_rfid = 25;
  141. byte _main_rfid = 26;
  142. byte _main_none_app = 27;
  143. byte _main_app = 28;
  144. byte _main_none_qr = 29;
  145. byte _main_qr = 30;
  146. byte _charging_map1 = 31;
  147. byte _charging_map2 = 32;
  148. byte _battery_empty = 33;
  149. byte _battery_cap_20 = 34;
  150. byte _battery_cap_40 = 35;
  151. byte _battery_cap_60 = 36;
  152. byte _battery_cap_80 = 37;
  153. byte _battery_cap_100 = 38;
  154. byte _battery_map = 39;
  155. byte _power_map = 40;
  156. byte _time_map = 41;
  157. byte _complete_map = 42;
  158. byte _battery_soc_20 = 43;
  159. byte _battery_soc_40 = 44;
  160. byte _battery_soc_60 = 45;
  161. byte _battery_soc_80 = 46;
  162. byte _battery_soc_100 = 47;
  163. byte _battery_eng_map = 48;
  164. byte _money_map = 49;
  165. byte _elapse_time_map = 50;
  166. byte _charging_money = 51;
  167. byte _side_none_rfid = 52;
  168. byte _side_rfid = 53;
  169. byte _side_none_app = 54;
  170. byte _side_app = 55;
  171. byte _side_none_qr = 56;
  172. byte _side_qr = 57;