Module_PsuComm.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <linux/can.h>
  13. #include <linux/can/raw.h>
  14. #include <arpa/inet.h>
  15. #include <netinet/in.h>
  16. #include <unistd.h>
  17. #include <stdarg.h>
  18. #include <stdio.h> /*標準輸入輸出定義*/
  19. #include <stdlib.h> /*標準函數庫定義*/
  20. #include <unistd.h> /*Unix 標準函數定義*/
  21. #include <fcntl.h> /*檔控制定義*/
  22. #include <termios.h> /*PPSIX 終端控制定義*/
  23. #include <errno.h> /*錯誤號定義*/
  24. #include <string.h>
  25. #include <time.h>
  26. #include <ctype.h>
  27. #include <ifaddrs.h>
  28. #include <math.h>
  29. #include "../../define.h"
  30. #include <stdbool.h>
  31. typedef unsigned char byte;
  32. typedef unsigned short word;
  33. typedef unsigned int unit;
  34. #define PSU_CUR_GAP 20 // 0.1A
  35. #define LOG_TIME 5000 // 1ms
  36. unsigned char _gunCountRecord;
  37. struct ChargingInfoData *chargingInfo[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  38. bool isStartOutputSwitch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  39. struct timespec _cmdSubPsuPriority_time;
  40. struct timespec _derating_time;
  41. struct timespec _max_time;
  42. struct timespec _log_time;
  43. byte _delayToGetCap;
  44. byte _maxChargingStatus;
  45. bool isReadyToCharging = false;
  46. int preChargingTarget;
  47. int preChargingCur;
  48. float toAverVolPoint;
  49. byte toAverVolCount;
  50. int _forceWaitToCompforMaxMode;
  51. byte _delay2GetPsuTemp;
  52. enum _CHARGING_GUN_STATUS
  53. {
  54. _CHARGING_GUN_STATUS_NONE = 0,
  55. _CHARGING_GUN_STATUS_COMM,
  56. _CHARGING_GUN_STATUS_CHARGING,
  57. _CHARGING_GUN_STATUS_STOP
  58. };
  59. enum _PSU_CMD_SEQ
  60. {
  61. _PSU_CMD_STATUS = 1,
  62. _PSU_CMD_VERSION = 2,
  63. _PSU_CMD_CAP = 10,
  64. _PSU_CMD_IAVAILABLE = 11,
  65. _PSU_CMD_TEMP = 12,
  66. _PSU_CMD_GETCOUNT = 13,
  67. _PSU_CMD_OUTPUT_V = 14,
  68. };
  69. enum _CHARGING_LOG_INDEX
  70. {
  71. _CHARGING_LOG_NEED_VOL = 0,
  72. _CHARGING_LOG_NEED_CUR = 1,
  73. _CHARGING_LOG_OUTPUT_VOL = 2,
  74. _CHARGING_LOG_OUTPUT_CUR = 3
  75. };