Module_PsuComm.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 2000 // 1ms
  36. #define SMOOTH_TIME 100 // 1ms
  37. #define WAIT_LIMIT_TIME 10000 // 1ms
  38. unsigned char _gunCountRecord;
  39. struct ChargingInfoData *chargingInfo[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  40. bool isStartOutputSwitch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  41. struct timespec _cmdSubPsuPriority_time;
  42. struct timespec _derating_time;
  43. struct timespec _max_time;
  44. struct timespec _log_time;
  45. struct timespec _smooth_time;
  46. struct timespec _releaseWait_time[DC_CONNECTOR_COUNT];
  47. bool _releaseWait_chk[DC_CONNECTOR_COUNT];
  48. byte _delayToGetCap;
  49. byte _maxChargingStatus;
  50. bool isReadyToCharging = false;
  51. int preChargingTarget;
  52. int preChargingCur;
  53. float toAverVolPoint;
  54. byte toAverVolCount;
  55. int _forceWaitToCompforMaxMode;
  56. byte _delay2GetPsuTemp;
  57. enum _CHARGING_GUN_STATUS
  58. {
  59. _CHARGING_GUN_STATUS_NONE = 0,
  60. _CHARGING_GUN_STATUS_COMM,
  61. _CHARGING_GUN_STATUS_CHARGING,
  62. _CHARGING_GUN_STATUS_STOP
  63. };
  64. enum _PSU_CMD_SEQ
  65. {
  66. _PSU_CMD_STATUS = 1,
  67. _PSU_CMD_VERSION = 2,
  68. _PSU_CMD_CAP = 10,
  69. _PSU_CMD_IAVAILABLE = 11,
  70. _PSU_CMD_TEMP = 12,
  71. _PSU_CMD_GETCOUNT = 13,
  72. _PSU_CMD_OUTPUT_V = 14,
  73. };
  74. enum _CHARGING_LOG_INDEX
  75. {
  76. _CHARGING_LOG_NEED_VOL = 0,
  77. _CHARGING_LOG_NEED_CUR = 1,
  78. _CHARGING_LOG_OUTPUT_VOL = 2,
  79. _CHARGING_LOG_OUTPUT_CUR = 3
  80. };