|
@@ -124,15 +124,15 @@ byte ac_startTransationFlag;
|
|
|
Relay acOutputRelay;
|
|
|
|
|
|
bool _isOutputNoneMatch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
-struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
+struct timespec _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
|
|
|
//bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
//struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
-struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
+struct timespec _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
|
|
|
// SMR1 *2 + SMR2 * 2 + Parallel * 2
|
|
|
-struct timeval _relayStateChkTimer[6];
|
|
|
+struct timespec _relayStateChkTimer[6];
|
|
|
|
|
|
byte _threePhaseOvp[3] = {0, 0, 0};
|
|
|
byte _threePhaseUvp[3] = {0, 0, 0};
|
|
@@ -144,20 +144,20 @@ char *relayRs485PortName = "/dev/ttyS5";
|
|
|
unsigned short fanSpeedSmoothValue = 500;
|
|
|
|
|
|
bool isStopChargingCount = false;
|
|
|
-struct timeval _close_ac_contactor;
|
|
|
+struct timespec _close_ac_contactor;
|
|
|
|
|
|
-struct timeval _priority_time;
|
|
|
-struct timeval _led_priority_time;
|
|
|
-struct timeval _led_blink_time;
|
|
|
+struct timespec _priority_time;
|
|
|
+struct timespec _led_priority_time;
|
|
|
+struct timespec _led_blink_time;
|
|
|
|
|
|
-struct timeval _ac_charging_comp;
|
|
|
-struct timeval _ac_preparing;
|
|
|
+struct timespec _ac_charging_comp;
|
|
|
+struct timespec _ac_preparing;
|
|
|
struct timeb _ac_startChargingTime;
|
|
|
struct timeb _ac_endChargingTime;
|
|
|
byte _ac_duty;
|
|
|
|
|
|
bool isCriticalStop;
|
|
|
-struct timeval _psuCriticalStop;
|
|
|
+struct timespec _psuCriticalStop;
|
|
|
|
|
|
unsigned short _setFanSpeed = 0;
|
|
|
float _beforeChargingTotalEnergy = 0.0;
|
|
@@ -227,18 +227,36 @@ int _alarm_code[] = {L1_AC_OVP, L1_AC_UVP, L1_AC_OCP, AC_OTP, AC_GMI_FAULT, AC_C
|
|
|
void PRINTF_FUNC(char *string, ...);
|
|
|
|
|
|
int StoreLogMsg(const char *fmt, ...);
|
|
|
-unsigned long GetTimeoutValue(struct timeval _sour_time);
|
|
|
+int GetTimeoutValue(struct timespec *startTime);
|
|
|
|
|
|
#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
|
|
|
-unsigned long GetTimeoutValue(struct timeval _sour_time)
|
|
|
+long int GetTimeoutMValue(struct timespec *startTime)
|
|
|
{
|
|
|
- struct timeval _end_time;
|
|
|
- gettimeofday(&_end_time, NULL);
|
|
|
+ struct timespec endTime;
|
|
|
|
|
|
- return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &endTime);
|
|
|
+ return 1000 * (endTime.tv_sec - startTime->tv_sec) + (endTime.tv_nsec - startTime->tv_nsec) / 1000000;
|
|
|
+}
|
|
|
+
|
|
|
+void GetTimespecMFunc(struct timespec *time)
|
|
|
+{
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, time);
|
|
|
+}
|
|
|
+
|
|
|
+int GetTimeoutValue(struct timespec *startTime)
|
|
|
+{
|
|
|
+ struct timespec endTime;
|
|
|
+
|
|
|
+ clock_gettime(CLOCK_MONOTONIC_COARSE, &endTime);
|
|
|
+ return endTime.tv_sec - startTime->tv_sec;
|
|
|
+}
|
|
|
+
|
|
|
+void GetTimespecFunc(struct timespec *time)
|
|
|
+{
|
|
|
+ clock_gettime(CLOCK_MONOTONIC_COARSE, time);
|
|
|
}
|
|
|
|
|
|
int StoreLogMsg(const char *fmt, ...)
|
|
@@ -848,7 +866,7 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
// }
|
|
|
// else
|
|
|
{
|
|
|
- if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
+ if (_chargingData[index]->SystemStatus == SYS_MODE_CCS_PRECHARGE_STEP0)
|
|
|
_chargingData[index]->RelayKPK2Status = YES;
|
|
|
else
|
|
|
_chargingData[index]->RelayKPK2Status = NO;
|
|
@@ -869,7 +887,7 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
// else
|
|
|
// _chargingData[index]->RelayKPK2Status = NO;
|
|
|
|
|
|
- if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
+ if (_chargingData[index]->SystemStatus == SYS_MODE_CCS_PRECHARGE_STEP0)
|
|
|
_chargingData[index]->RelayKPK2Status = YES;
|
|
|
else
|
|
|
_chargingData[index]->RelayKPK2Status = NO;
|
|
@@ -890,7 +908,7 @@ void CheckK1K2RelayOutput(byte index)
|
|
|
// else
|
|
|
// _chargingData[index]->RelayKPK2Status = NO;
|
|
|
|
|
|
- if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
+ if (_chargingData[index]->SystemStatus == SYS_MODE_CCS_PRECHARGE_STEP0)
|
|
|
_chargingData[index]->RelayKPK2Status = YES;
|
|
|
else
|
|
|
_chargingData[index]->RelayKPK2Status = NO;
|
|
@@ -1109,8 +1127,8 @@ void SetK1K2RelayStatus(byte index)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (_chargingData[index]->SystemStatus < S_PREPARING_FOR_EVSE ||
|
|
|
- _chargingData[index]->SystemStatus == S_FAULT)
|
|
|
+ if (_chargingData[index]->SystemStatus < SYS_MODE_PREPARE_FOR_EVSE ||
|
|
|
+ _chargingData[index]->SystemStatus == SYS_MODE_FAULT)
|
|
|
{
|
|
|
if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
{
|
|
@@ -1135,8 +1153,8 @@ void SetK1K2RelayStatus(byte index)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE &&
|
|
|
- _chargingData[index]->SystemStatus <= S_CHARGING))
|
|
|
+ else if ((_chargingData[index]->SystemStatus >= SYS_MODE_PREPARE_FOR_EVSE &&
|
|
|
+ _chargingData[index]->SystemStatus <= SYS_MODE_CHARGING))
|
|
|
{
|
|
|
//if (_chargingData[index]->RelayWeldingCheck == YES)
|
|
|
{
|
|
@@ -1156,8 +1174,8 @@ void SetK1K2RelayStatus(byte index)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (_chargingData[index]->SystemStatus >= S_TERMINATING &&
|
|
|
- _chargingData[index]->SystemStatus <= S_ALARM)
|
|
|
+ else if (_chargingData[index]->SystemStatus >= SYS_MODE_TERMINATING &&
|
|
|
+ _chargingData[index]->SystemStatus <= SYS_MODE_ALARM)
|
|
|
{
|
|
|
if ((_chargingData[index]->PresentChargingCurrent * 10) <= SEFETY_SWITCH_RELAY_CUR)
|
|
|
{
|
|
@@ -1177,7 +1195,7 @@ void SetK1K2RelayStatus(byte index)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0)
|
|
|
+ else if (_chargingData[index]->SystemStatus == SYS_MODE_CCS_PRECHARGE_STEP0)
|
|
|
{
|
|
|
// if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
// {
|
|
@@ -1203,7 +1221,7 @@ void SetK1K2RelayStatus(byte index)
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
- else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST1)
|
|
|
+ else if (_chargingData[index]->SystemStatus == SYS_MODE_CCS_PRECHARGE_STEP1)
|
|
|
{
|
|
|
// if (_chargingData[index]->Evboard_id == 0x01)
|
|
|
// {
|
|
@@ -1236,9 +1254,9 @@ void SetParalleRelayStatus()
|
|
|
// 之後雙槍單模機種,橋接都會上
|
|
|
if (gunCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
|
|
|
{
|
|
|
- if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
|
|
|
- ((_chargingData[0]->SystemStatus == S_IDLE || _chargingData[0]->SystemStatus == S_MAINTAIN) &&
|
|
|
- (_chargingData[1]->SystemStatus == S_IDLE || _chargingData[1]->SystemStatus == S_MAINTAIN)))
|
|
|
+ if (_chargingData[0]->SystemStatus == SYS_MODE_BOOTING || _chargingData[1]->SystemStatus == SYS_MODE_BOOTING ||
|
|
|
+ ((_chargingData[0]->SystemStatus == SYS_MODE_IDLE || _chargingData[0]->SystemStatus == SYS_MODE_MAINTAIN) &&
|
|
|
+ (_chargingData[1]->SystemStatus == SYS_MODE_IDLE || _chargingData[1]->SystemStatus == SYS_MODE_MAINTAIN)))
|
|
|
{
|
|
|
// 初始化~ 不搭橋接
|
|
|
if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
|
|
@@ -1395,7 +1413,7 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
_colorBuf = COLOR_MAX_LV * LED_INTENSITY_MEDIUM;
|
|
|
|
|
|
if (ShmSysConfigAndInfo->SysWarningInfo.Level == _ALARM_LEVEL_CRITICAL ||
|
|
|
- (chargingData_1->SystemStatus == S_UPDATE && chargingData_2->SystemStatus == S_UPDATE))
|
|
|
+ (chargingData_1->SystemStatus == SYS_MODE_UPDATE && chargingData_2->SystemStatus == SYS_MODE_UPDATE))
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
@@ -1408,8 +1426,8 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf)
|
|
|
{
|
|
|
- if ((chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION || chargingData_1->SystemStatus == S_MAINTAIN) &&
|
|
|
- (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION || chargingData_2->SystemStatus == S_MAINTAIN))
|
|
|
+ if ((chargingData_1->SystemStatus == SYS_MODE_BOOTING || chargingData_1->SystemStatus == SYS_MODE_IDLE || chargingData_1->SystemStatus == SYS_MODE_RESERVATION || chargingData_1->SystemStatus == SYS_MODE_MAINTAIN) &&
|
|
|
+ (chargingData_2->SystemStatus == SYS_MODE_BOOTING || chargingData_2->SystemStatus == SYS_MODE_IDLE || chargingData_2->SystemStatus == SYS_MODE_RESERVATION || chargingData_2->SystemStatus == SYS_MODE_MAINTAIN))
|
|
|
{
|
|
|
led_color.Connect_1_Green = _colorBuf;
|
|
|
led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
@@ -1418,17 +1436,17 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
|
led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
|
|
|
- if (chargingData_1->SystemStatus == S_RESERVATION ||
|
|
|
- chargingData_2->SystemStatus == S_RESERVATION)
|
|
|
+ if (chargingData_1->SystemStatus == SYS_MODE_RESERVATION ||
|
|
|
+ chargingData_2->SystemStatus == SYS_MODE_RESERVATION)
|
|
|
{
|
|
|
- if (GetTimeoutValue(_led_blink_time) / 1000 > 3000)
|
|
|
+ if (GetTimeoutValue(&_led_blink_time) > 3)
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
}
|
|
|
}
|
|
|
- else if (chargingData_1->SystemStatus == S_MAINTAIN ||
|
|
|
- chargingData_2->SystemStatus == S_MAINTAIN)
|
|
|
+ else if (chargingData_1->SystemStatus == SYS_MODE_MAINTAIN ||
|
|
|
+ chargingData_2->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
@@ -1436,10 +1454,10 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
led_color.Connect_2_Red = _colorBuf;
|
|
|
}
|
|
|
}
|
|
|
- else if ((chargingData_1->SystemStatus >= S_AUTHORIZING && chargingData_1->SystemStatus <= S_COMPLETE) ||
|
|
|
- (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
|
|
|
- (chargingData_2->SystemStatus >= S_AUTHORIZING && chargingData_2->SystemStatus <= S_COMPLETE) ||
|
|
|
- (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ else if ((chargingData_1->SystemStatus >= SYS_MODE_AUTHORIZING && chargingData_1->SystemStatus <= SYS_MODE_COMPLETE) ||
|
|
|
+ (chargingData_1->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_1->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) ||
|
|
|
+ (chargingData_2->SystemStatus >= SYS_MODE_AUTHORIZING && chargingData_2->SystemStatus <= SYS_MODE_COMPLETE) ||
|
|
|
+ (chargingData_2->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_2->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_1_Blue = _colorBuf;
|
|
@@ -1451,30 +1469,30 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (chargingData_1->SystemStatus == S_BOOTING ||
|
|
|
- chargingData_1->SystemStatus == S_IDLE ||
|
|
|
- chargingData_1->SystemStatus == S_RESERVATION ||
|
|
|
- chargingData_1->SystemStatus == S_MAINTAIN)
|
|
|
+ if (chargingData_1->SystemStatus == SYS_MODE_BOOTING ||
|
|
|
+ chargingData_1->SystemStatus == SYS_MODE_IDLE ||
|
|
|
+ chargingData_1->SystemStatus == SYS_MODE_RESERVATION ||
|
|
|
+ chargingData_1->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_1_Green = _colorBuf;
|
|
|
led_color.Connect_1_Blue = COLOR_MIN_LV;
|
|
|
led_color.Connect_1_Red = COLOR_MIN_LV;
|
|
|
|
|
|
- if (chargingData_1->SystemStatus == S_RESERVATION)
|
|
|
+ if (chargingData_1->SystemStatus == SYS_MODE_RESERVATION)
|
|
|
{
|
|
|
- if (GetTimeoutValue(_led_blink_time) / 1000 > 3000)
|
|
|
+ if (GetTimeoutValue(&_led_blink_time) > 3)
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
}
|
|
|
}
|
|
|
- else if (chargingData_1->SystemStatus == S_MAINTAIN)
|
|
|
+ else if (chargingData_1->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_1_Red = _colorBuf;
|
|
|
}
|
|
|
}
|
|
|
- else if ((chargingData_1->SystemStatus >= S_AUTHORIZING && chargingData_1->SystemStatus <= S_COMPLETE) ||
|
|
|
- (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ else if ((chargingData_1->SystemStatus >= SYS_MODE_AUTHORIZING && chargingData_1->SystemStatus <= SYS_MODE_COMPLETE) ||
|
|
|
+ (chargingData_1->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_1->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
led_color.Connect_1_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_1_Blue = _colorBuf;
|
|
@@ -1482,30 +1500,30 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
|
|
|
}
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
- if (chargingData_2->SystemStatus == S_BOOTING ||
|
|
|
- chargingData_2->SystemStatus == S_IDLE ||
|
|
|
- chargingData_2->SystemStatus == S_RESERVATION ||
|
|
|
- chargingData_2->SystemStatus == S_MAINTAIN)
|
|
|
+ if (chargingData_2->SystemStatus == SYS_MODE_BOOTING ||
|
|
|
+ chargingData_2->SystemStatus == SYS_MODE_IDLE ||
|
|
|
+ chargingData_2->SystemStatus == SYS_MODE_RESERVATION ||
|
|
|
+ chargingData_2->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_2_Green = _colorBuf;
|
|
|
led_color.Connect_2_Blue = COLOR_MIN_LV;
|
|
|
led_color.Connect_2_Red = COLOR_MIN_LV;
|
|
|
|
|
|
- if (chargingData_2->SystemStatus == S_RESERVATION)
|
|
|
+ if (chargingData_2->SystemStatus == SYS_MODE_RESERVATION)
|
|
|
{
|
|
|
- if (GetTimeoutValue(_led_blink_time) / 1000 > 3000)
|
|
|
+ if (GetTimeoutValue(&_led_blink_time) > 3)
|
|
|
{
|
|
|
led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
}
|
|
|
}
|
|
|
- else if (chargingData_2->SystemStatus == S_MAINTAIN)
|
|
|
+ else if (chargingData_2->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_2_Red = _colorBuf;
|
|
|
}
|
|
|
}
|
|
|
- else if ((chargingData_2->SystemStatus >= S_AUTHORIZING && chargingData_2->SystemStatus <= S_COMPLETE) ||
|
|
|
- (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ else if ((chargingData_2->SystemStatus >= SYS_MODE_AUTHORIZING && chargingData_2->SystemStatus <= SYS_MODE_COMPLETE) ||
|
|
|
+ (chargingData_2->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_2->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
led_color.Connect_2_Green = COLOR_MIN_LV;
|
|
|
led_color.Connect_2_Blue = _colorBuf;
|
|
@@ -1583,7 +1601,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- memset(ShmFanModuleData,0,sizeof(struct FanModuleData));
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), 0777)) < 0)
|
|
|
{
|
|
@@ -1599,7 +1616,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- memset(ShmRelayModuleData,0,sizeof(struct RelayModuleData));
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), 0777)) < 0)
|
|
|
{
|
|
@@ -1615,7 +1631,6 @@ int InitShareMemory()
|
|
|
#endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
- memset(ShmLedModuleData,0,sizeof(struct LedModuleData));
|
|
|
|
|
|
if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
|
|
|
{
|
|
@@ -1824,18 +1839,18 @@ void StartCheckRelayInfo(byte _chkIndex, byte toState)
|
|
|
{
|
|
|
if (ShmDcCommonData->RelayCheckStatus[_chkIndex] == STOP)
|
|
|
{
|
|
|
- gettimeofday(&_relayStateChkTimer[_chkIndex], NULL);
|
|
|
+ GetTimespecFunc(&_relayStateChkTimer[_chkIndex]);
|
|
|
ShmDcCommonData->RelayCheckStatus[_chkIndex] = START;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- unsigned long _timebuf = GetTimeoutValue(_relayStateChkTimer[_chkIndex]);
|
|
|
+ int _timebuf = GetTimeoutValue(&_relayStateChkTimer[_chkIndex]);
|
|
|
|
|
|
if (_timebuf < 0)
|
|
|
- gettimeofday(&_relayStateChkTimer[_chkIndex], NULL);
|
|
|
+ GetTimespecFunc(&_relayStateChkTimer[_chkIndex]);
|
|
|
else
|
|
|
{
|
|
|
- if ((_timebuf / 1000) > RELAY_CHECK_TIME * 1000)
|
|
|
+ if (_timebuf > RELAY_CHECK_TIME)
|
|
|
{
|
|
|
//PRINTF_FUNC ("relay welding or driving fault = %d \n", _chkIndex);
|
|
|
if (toState == 1)
|
|
@@ -2007,20 +2022,20 @@ void CableCheckDetected(byte index)
|
|
|
if ((_chargingData[index]->Type >= _Type_Chademo && _chargingData[index]->Type <= _Type_GB) ||
|
|
|
(_chargingData[index]->Type == 0x09 && ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag))
|
|
|
{
|
|
|
- if ((_chargingData[index]->SystemStatus >= S_PREPARING_FOR_EVSE && _chargingData[index]->SystemStatus < S_TERMINATING) ||
|
|
|
- (_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ if ((_chargingData[index]->SystemStatus >= SYS_MODE_PREPARE_FOR_EVSE && _chargingData[index]->SystemStatus < SYS_MODE_TERMINATING) ||
|
|
|
+ (_chargingData[index]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && _chargingData[index]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
|
|
|
{
|
|
|
- if (_chargingData[index]->SystemStatus == S_PREPARING_FOR_EVSE)
|
|
|
+ if (_chargingData[index]->SystemStatus == SYS_MODE_PREPARE_FOR_EVSE)
|
|
|
{
|
|
|
SetGfdConfig(index, GFD_CABLECHK);
|
|
|
}
|
|
|
- else if (_chargingData[index]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
|
|
|
- _chargingData[index]->SystemStatus <= S_CCS_PRECHARGE_ST1)
|
|
|
+ else if (_chargingData[index]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 &&
|
|
|
+ _chargingData[index]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1)
|
|
|
{
|
|
|
SetGfdConfig(index, GFD_PRECHARGE);
|
|
|
}
|
|
|
- else if (_chargingData[index]->SystemStatus >= S_CHARGING &&
|
|
|
- _chargingData[index]->SystemStatus < S_TERMINATING)
|
|
|
+ else if (_chargingData[index]->SystemStatus >= SYS_MODE_CHARGING &&
|
|
|
+ _chargingData[index]->SystemStatus < SYS_MODE_TERMINATING)
|
|
|
{
|
|
|
if (_chargingData[index]->Type == _Type_GB || _chargingData[index]->Type == _Type_Chademo)
|
|
|
SetGfdConfig(index, GFD_IDLE);
|
|
@@ -2052,7 +2067,7 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
{
|
|
|
if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10)
|
|
|
{
|
|
|
- gettimeofday(&_checkOutputVolProtectTimer[index], NULL);
|
|
|
+ GetTimespecMFunc(&_checkOutputVolProtectTimer[index]);
|
|
|
_isOvpChkTimeFlag[index] = YES;
|
|
|
PRINTF_FUNC("First time : CheckOutputPowerOverCarReq NG : fire = %f, req = %f, max-battery = %f \n",
|
|
|
_chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10), carV);
|
|
@@ -2060,13 +2075,13 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- unsigned long _timebuf = GetTimeoutValue(_checkOutputVolProtectTimer[index]);
|
|
|
+ int _timebuf = GetTimeoutMValue(&_checkOutputVolProtectTimer[index]);
|
|
|
|
|
|
if (_timebuf < 0)
|
|
|
- gettimeofday(&_checkOutputVolProtectTimer[index], NULL);
|
|
|
+ GetTimespecMFunc(&_checkOutputVolProtectTimer[index]);
|
|
|
else
|
|
|
{
|
|
|
- if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME)
|
|
|
+ if (GetTimeoutMValue(&_checkOutputVolProtectTimer[index]) >= OUTPUT_VOL_CHK_TIME)
|
|
|
{
|
|
|
PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, req = %f, max-battery = %f \n",
|
|
|
_chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10), carV);
|
|
@@ -2102,77 +2117,49 @@ void CheckOutputPowerOverCarReq(byte index)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//void CheckOutputVolNoneMatchFire(byte index)
|
|
|
-//{
|
|
|
-// if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
|
|
|
-// (_chargingData[index]->Type == _Type_Chademo ||
|
|
|
-// _chargingData[index]->Type == _Type_CCS_2 ||
|
|
|
-// _chargingData[index]->Type == _Type_GB))
|
|
|
-// {
|
|
|
-// if (((_chargingData[index]->PresentChargingVoltage * 10) < _chargingData[index]->FireChargingVoltage - 300) ||
|
|
|
-// ((_chargingData[index]->PresentChargingVoltage * 10) > _chargingData[index]->FireChargingVoltage + 300))
|
|
|
-// {
|
|
|
-// if (!_isOutputNoneMatch[index])
|
|
|
-// {
|
|
|
-// _isOutputNoneMatch[index] = YES;
|
|
|
-// gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000)
|
|
|
-// {
|
|
|
-// PRINTF_FUNC("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f \n",
|
|
|
-// index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
-// DEBUG_ERROR("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f \n",
|
|
|
-// index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
-//
|
|
|
-// if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
-// ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault = YES;
|
|
|
-// else if (_chargingData[index]->Type == _Type_GB)
|
|
|
-// ShmStatusCodeData->FaultCode.FaultEvents.bits.GbOutputRelayDrivingFault = YES;
|
|
|
-// else if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
-// ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault = YES;
|
|
|
-//
|
|
|
-// _chargingData[index]->StopChargeFlag = YES;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// _isOutputNoneMatch[index] = NO;
|
|
|
-// }
|
|
|
-//}
|
|
|
-
|
|
|
-void CheckRelayWeldingStatus(byte index)
|
|
|
+void CheckOutputVolNoneMatchFire(byte index)
|
|
|
{
|
|
|
-// if (!_isRelayWelding[index])
|
|
|
-// {
|
|
|
-// if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10)
|
|
|
-// {
|
|
|
-// gettimeofday(&_checkRelayWeldingTimer[index], NULL);
|
|
|
-// _isRelayWelding[index] = YES;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// if ((GetTimeoutValue(_checkRelayWeldingTimer[index]) / 1000) >= 1000)
|
|
|
-// {
|
|
|
-// _chargingData[index]->RelayWeldingCheck = YES;
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (_chargingData[index]->FireChargingVoltage >= VOUT_MIN_VOLTAGE)
|
|
|
-// {
|
|
|
-// if (_chargingData[index]->Type == _Type_Chademo)
|
|
|
-// ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayWelding = YES;
|
|
|
-// else if (_chargingData[index]->Type == _Type_GB)
|
|
|
-// ShmStatusCodeData->FaultCode.FaultEvents.bits.GbOutputRelayWelding = YES;
|
|
|
-// else if (_chargingData[index]->Type == _Type_CCS_2)
|
|
|
-// ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayWelding = YES;
|
|
|
-//
|
|
|
-// PRINTF_FUNC("CheckRelayWeldingStatus : fail \n");
|
|
|
-// _chargingData[index]->StopChargeFlag = YES;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if (((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 ||
|
|
|
+ _chargingData[index]->RelayK1K2Status == NO) &&
|
|
|
+ (_chargingData[index]->Type == _Type_Chademo ||
|
|
|
+ _chargingData[index]->Type == _Type_CCS ||
|
|
|
+ _chargingData[index]->Type == _Type_GB))
|
|
|
+ {
|
|
|
+ if (((_chargingData[index]->PresentChargingVoltage * 10) < _chargingData[index]->FireChargingVoltage - 300) ||
|
|
|
+ ((_chargingData[index]->PresentChargingVoltage * 10) > _chargingData[index]->FireChargingVoltage + 300))
|
|
|
+ {
|
|
|
+ if (!_isOutputNoneMatch[index])
|
|
|
+ {
|
|
|
+ _isOutputNoneMatch[index] = YES;
|
|
|
+ GetTimespecFunc(&_checkOutputNoneMatchTimer[index]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (GetTimeoutValue(&_checkOutputNoneMatchTimer[index]) >= 2)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("Abnormal voltage on the Output at the stage of GFD. (%d) : pre = %.1f, fire = %.1f \n",
|
|
|
+ index, (_chargingData[index]->PresentChargingVoltage * 10), _chargingData[index]->FireChargingVoltage);
|
|
|
+
|
|
|
+ if (index == 0)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AbnormalVoltageOnOutputLine_1 = YES;
|
|
|
+ if (strncmp((char *)_chargingData[index]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ memcpy(_chargingData[index]->ConnectorAlarmCode, "012324", 6);
|
|
|
+ }
|
|
|
+ else if (index == 1)
|
|
|
+ {
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AbnormalVoltageOnOutputLine_2 = YES;
|
|
|
+ if (strncmp((char *)_chargingData[index]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ memcpy(_chargingData[index]->ConnectorAlarmCode, "012325", 6);
|
|
|
+ }
|
|
|
+
|
|
|
+ _chargingData[index]->StopChargeFlag = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ _isOutputNoneMatch[index] = NO;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void GetPsuTempForFanSpeed()
|
|
@@ -2336,11 +2323,11 @@ unsigned char GetAcChargingCurrent()
|
|
|
|
|
|
void ChangeLedStatus()
|
|
|
{
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_IDLE)
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_IDLE)
|
|
|
ledStatus.ActionMode = 1;
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_PREPARNING)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_PREPARING)
|
|
|
ledStatus.ActionMode = 3;
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_CHARGING)
|
|
|
ledStatus.ActionMode = 4;
|
|
|
|
|
|
Config_LED_Status(Uart5Fd, Addr.AcPlug, &ledStatus);
|
|
@@ -2658,42 +2645,42 @@ void AcChargeTypeProcess()
|
|
|
|
|
|
if (ac_chargingInfo[0]->IsAvailable == NO)
|
|
|
{
|
|
|
- _status = S_MAINTAIN;
|
|
|
+ _status = SYS_MODE_MAINTAIN;
|
|
|
}
|
|
|
|
|
|
//printf("SystemStatus = %d, err = %d \n", ac_chargingInfo[0]->SystemStatus, ac_chargingInfo[0]->IsErrorOccur);
|
|
|
- if ((ac_chargingInfo[0]->SystemStatus == S_IDLE || ac_chargingInfo[0]->SystemStatus == S_MAINTAIN) &&
|
|
|
+ if ((ac_chargingInfo[0]->SystemStatus == SYS_MODE_IDLE || ac_chargingInfo[0]->SystemStatus == SYS_MODE_MAINTAIN) &&
|
|
|
ac_chargingInfo[0]->IsErrorOccur)
|
|
|
{
|
|
|
- _status = S_FAULT;
|
|
|
+ _status = SYS_MODE_FAULT;
|
|
|
}
|
|
|
- else if (_status == S_MAINTAIN)
|
|
|
+ else if (_status == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
// do nothing
|
|
|
}
|
|
|
else if (acStatus.CpStatus == AC_SYS_A)
|
|
|
{
|
|
|
if (ac_chargingInfo[0]->IsErrorOccur &&
|
|
|
- (ac_chargingInfo[0]->SystemStatus >= S_PREPARNING ||
|
|
|
- ac_chargingInfo[0]->SystemStatus <= S_CHARGING))
|
|
|
- _status = S_ALARM;
|
|
|
+ (ac_chargingInfo[0]->SystemStatus >= SYS_MODE_PREPARING ||
|
|
|
+ ac_chargingInfo[0]->SystemStatus <= SYS_MODE_CHARGING))
|
|
|
+ _status = SYS_MODE_ALARM;
|
|
|
else if (!ac_chargingInfo[0]->IsErrorOccur &&
|
|
|
- (ac_chargingInfo[0]->SystemStatus >= S_TERMINATING ||
|
|
|
- ac_chargingInfo[0]->SystemStatus <= S_ALARM))
|
|
|
+ (ac_chargingInfo[0]->SystemStatus >= SYS_MODE_TERMINATING ||
|
|
|
+ ac_chargingInfo[0]->SystemStatus <= SYS_MODE_ALARM))
|
|
|
{
|
|
|
- if (GetTimeoutValue(_ac_charging_comp) >= 10000000 && acStatus.CpStatus == AC_SYS_A)
|
|
|
- _status = S_IDLE;
|
|
|
+ if (GetTimeoutValue(&_ac_charging_comp) >= 10 && acStatus.CpStatus == AC_SYS_A)
|
|
|
+ _status = SYS_MODE_IDLE;
|
|
|
}
|
|
|
// else
|
|
|
-// _status = S_IDLE;
|
|
|
+// _status = SYS_MODE_IDLE;
|
|
|
}
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus >= S_PREPARNING &&
|
|
|
- ac_chargingInfo[0]->SystemStatus < S_CHARGING)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus >= SYS_MODE_PREPARING &&
|
|
|
+ ac_chargingInfo[0]->SystemStatus < SYS_MODE_CHARGING)
|
|
|
{
|
|
|
if (acStatus.CpStatus == AC_SYS_C)
|
|
|
- _status = S_CHARGING;
|
|
|
- else if (GetTimeoutValue(_ac_preparing) >= 120000000)
|
|
|
- _status = S_IDLE;
|
|
|
+ _status = SYS_MODE_CHARGING;
|
|
|
+ else if (GetTimeoutValue(&_ac_preparing) >= 120)
|
|
|
+ _status = SYS_MODE_IDLE;
|
|
|
}
|
|
|
else if ((acStatus.CpStatus == AC_SYS_B || ac_chargingInfo[0]->ConnectorPlugIn == AC_SYS_B) &&
|
|
|
ac_chargingInfo[0]->IsAvailable &&
|
|
@@ -2707,7 +2694,7 @@ void AcChargeTypeProcess()
|
|
|
ac_chargingInfo[0]->RemoteStartFlag = NO;
|
|
|
strcpy((char *)ac_chargingInfo[0]->StartUserId, "");
|
|
|
ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
- _status = S_PREPARNING;
|
|
|
+ _status = SYS_MODE_PREPARING;
|
|
|
}
|
|
|
else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE)
|
|
|
{
|
|
@@ -2716,22 +2703,22 @@ void AcChargeTypeProcess()
|
|
|
PRINTF_FUNC("** CardNumber = %s \n", ac_chargingInfo[0]->StartUserId);
|
|
|
strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
- _status = S_PREPARNING;
|
|
|
+ _status = SYS_MODE_PREPARING;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_PREPARNING ||
|
|
|
- ac_chargingInfo[0]->SystemStatus == S_CHARGING)
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_PREPARING ||
|
|
|
+ ac_chargingInfo[0]->SystemStatus == SYS_MODE_CHARGING)
|
|
|
{
|
|
|
if (ocpp_ac_remoteStopReq_cmd())
|
|
|
{
|
|
|
ocpp_ac_set_stopReason_by_cmd("Remote");
|
|
|
- _status = S_TERMINATING;
|
|
|
+ _status = SYS_MODE_TERMINATING;
|
|
|
}
|
|
|
else if (ac_chargingInfo[0]->StopChargeFlag ||
|
|
|
acStatus.CpStatus == AC_SYS_F)
|
|
|
{
|
|
|
- _status = S_TERMINATING;
|
|
|
+ _status = SYS_MODE_TERMINATING;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2755,17 +2742,18 @@ void AcChargeTypeProcess()
|
|
|
// 設定限制最大充電電流 >= 6 ~ <= 32
|
|
|
switch(ac_chargingInfo[0]->SystemStatus)
|
|
|
{
|
|
|
- case S_IDLE:
|
|
|
- case S_MAINTAIN:
|
|
|
- case S_FAULT:
|
|
|
+ case SYS_MODE_IDLE:
|
|
|
+ case SYS_MODE_MAINTAIN:
|
|
|
+ case SYS_MODE_RESERVATION:
|
|
|
+ case SYS_MODE_FAULT:
|
|
|
{
|
|
|
if (isModeChange())
|
|
|
{
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_IDLE)
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_IDLE)
|
|
|
PRINTF_FUNC("================== S_IDLE (AC Gun) ================ \n");
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_MAINTAIN)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
PRINTF_FUNC("================== S_MAINTAIN (AC Gun) ================ \n");
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_FAULT)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_FAULT)
|
|
|
PRINTF_FUNC("================== S_FAULT (AC Gun) ================ \n");
|
|
|
|
|
|
SetCpDuty(100);
|
|
@@ -2785,7 +2773,7 @@ void AcChargeTypeProcess()
|
|
|
ChangeLedStatus();
|
|
|
}
|
|
|
break;
|
|
|
- case S_PREPARNING:
|
|
|
+ case SYS_MODE_PREPARING:
|
|
|
{
|
|
|
if (isModeChange())
|
|
|
{
|
|
@@ -2796,7 +2784,7 @@ void AcChargeTypeProcess()
|
|
|
ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
|
|
|
if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
- gettimeofday(&_ac_preparing, NULL);
|
|
|
+ GetTimespecFunc(&_ac_preparing);
|
|
|
}
|
|
|
|
|
|
if (GetChargingEnergy() == PASS)
|
|
@@ -2836,7 +2824,7 @@ void AcChargeTypeProcess()
|
|
|
SetCpDuty(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent);
|
|
|
}
|
|
|
else if (ac_startTransationFlag == START_TRANSATION_STATUS_FAIL ||
|
|
|
- (ac_startTransationFlag == START_TRANSATION_STATUS_WAIT && (GetTimeoutValue(_ac_preparing) / 1000) > 10000))
|
|
|
+ (ac_startTransationFlag == START_TRANSATION_STATUS_WAIT && GetTimeoutValue(&_ac_preparing) > 10))
|
|
|
{
|
|
|
PRINTF_FUNC("StartTransaction Fail / Timeout. \n");
|
|
|
ac_chargingInfo[0]->StopChargeFlag = YES;
|
|
@@ -2844,7 +2832,7 @@ void AcChargeTypeProcess()
|
|
|
ChangeLedStatus();
|
|
|
}
|
|
|
break;
|
|
|
- case S_CHARGING:
|
|
|
+ case SYS_MODE_CHARGING:
|
|
|
{
|
|
|
if (isModeChange())
|
|
|
{
|
|
@@ -2919,25 +2907,25 @@ void AcChargeTypeProcess()
|
|
|
ChangeLedStatus();
|
|
|
}
|
|
|
break;
|
|
|
- case S_TERMINATING:
|
|
|
- case S_ALARM:
|
|
|
+ case SYS_MODE_TERMINATING:
|
|
|
+ case SYS_MODE_ALARM:
|
|
|
{
|
|
|
//ocpp_set_errCode_cmd
|
|
|
if (isModeChange())
|
|
|
{
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_TERMINATING)
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_TERMINATING)
|
|
|
PRINTF_FUNC("================== S_TERMINATING (AC Gun) ================ \n");
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_ALARM)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_ALARM)
|
|
|
PRINTF_FUNC("================== S_ALARM (AC Gun) ================ \n");
|
|
|
|
|
|
ChangeStartOrStopDateTime(NO);
|
|
|
- gettimeofday(&_ac_charging_comp, NULL);
|
|
|
+ GetTimespecFunc(&_ac_charging_comp);
|
|
|
ocpp_ac_set_stopReason_by_cmd("Local");
|
|
|
SetCpDuty(100);
|
|
|
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_TERMINATING)
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_TERMINATING)
|
|
|
PRINTF_FUNC("================== S_TERMINATING (AC Gun) ================ \n");
|
|
|
- else if (ac_chargingInfo[0]->SystemStatus == S_ALARM)
|
|
|
+ else if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_ALARM)
|
|
|
{
|
|
|
ftime(&_ac_endChargingTime);
|
|
|
|
|
@@ -2954,8 +2942,8 @@ void AcChargeTypeProcess()
|
|
|
SetLegacyReq(NO);
|
|
|
if (acStatus.RelayStatus == NO)
|
|
|
{
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_TERMINATING)
|
|
|
- ac_chargingInfo[0]->SystemStatus = S_COMPLETE;
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_TERMINATING)
|
|
|
+ ac_chargingInfo[0]->SystemStatus = SYS_MODE_COMPLETE;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2964,17 +2952,17 @@ void AcChargeTypeProcess()
|
|
|
SetAcModuleRelay(NO);
|
|
|
}
|
|
|
|
|
|
- if (ac_chargingInfo[0]->SystemStatus == S_ALARM)
|
|
|
+ if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_ALARM)
|
|
|
ac_chargingInfo[0]->PresentChargedDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
|
|
|
}
|
|
|
break;
|
|
|
- case S_COMPLETE:
|
|
|
+ case SYS_MODE_COMPLETE:
|
|
|
{
|
|
|
if (isModeChange())
|
|
|
{
|
|
|
PRINTF_FUNC("================== S_COMPLETE (AC Gun) ================ \n");
|
|
|
|
|
|
- gettimeofday(&_ac_charging_comp, NULL);
|
|
|
+ GetTimespecFunc(&_ac_charging_comp);
|
|
|
ftime(&_ac_endChargingTime);
|
|
|
ocpp_ac_set_errCode_cmd();
|
|
|
if (strcmp((char *)ac_chargingInfo[0]->StartDateTime, "") != EQUAL)
|
|
@@ -2999,17 +2987,17 @@ void RunForceStopProcess()
|
|
|
if (isCriticalStop == NO)
|
|
|
{
|
|
|
isCriticalStop = YES;
|
|
|
- gettimeofday(&_psuCriticalStop, NULL);
|
|
|
+ GetTimespecFunc(&_psuCriticalStop);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- unsigned long _timebuf = GetTimeoutValue(_psuCriticalStop);
|
|
|
+ int _timebuf = GetTimeoutValue(&_psuCriticalStop);
|
|
|
|
|
|
if (_timebuf < 0)
|
|
|
- gettimeofday(&_psuCriticalStop, NULL);
|
|
|
+ GetTimespecFunc(&_psuCriticalStop);
|
|
|
else
|
|
|
{
|
|
|
- if (_timebuf / 1000 >= (FORCE_STOP_TIME * 1000))
|
|
|
+ if (_timebuf >= FORCE_STOP_TIME)
|
|
|
{
|
|
|
isCriticalStop = NO;
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm = NORMAL;
|
|
@@ -3074,7 +3062,7 @@ int main(void)
|
|
|
|
|
|
relayMatchFlag = NO;
|
|
|
isCriticalStop = NO;
|
|
|
- gettimeofday(&_led_blink_time, NULL);
|
|
|
+ GetTimespecFunc(&_led_blink_time);
|
|
|
for(;;)
|
|
|
{
|
|
|
bool isCharging = false;
|
|
@@ -3093,7 +3081,7 @@ int main(void)
|
|
|
SetModelName_Fan();
|
|
|
SetRtcData_Fan();
|
|
|
sleep(1);
|
|
|
- gettimeofday(&_priority_time, NULL);
|
|
|
+ GetTimespecFunc(&_priority_time);
|
|
|
}
|
|
|
|
|
|
// 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
|
|
@@ -3104,7 +3092,7 @@ int main(void)
|
|
|
{
|
|
|
GetFwAndHwVersion_Led();
|
|
|
sleep(1);
|
|
|
- gettimeofday(&_led_priority_time, NULL);
|
|
|
+ GetTimespecFunc(&_led_priority_time);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -3140,27 +3128,31 @@ int main(void)
|
|
|
// 依據當前各槍的狀態選擇 搭上/放開 Relay
|
|
|
SetK1K2RelayStatus(i);
|
|
|
|
|
|
- if (_chargingData[i]->SystemStatus == S_IDLE ||
|
|
|
- _chargingData[i]->SystemStatus == S_RESERVATION ||
|
|
|
- _chargingData[i]->SystemStatus == S_MAINTAIN)
|
|
|
+ if (_chargingData[i]->SystemStatus == SYS_MODE_IDLE ||
|
|
|
+ _chargingData[i]->SystemStatus == SYS_MODE_RESERVATION ||
|
|
|
+ _chargingData[i]->SystemStatus == SYS_MODE_MAINTAIN)
|
|
|
{
|
|
|
- //_chargingData[i]->RelayWeldingCheck = NO;
|
|
|
_isOvpChkTimeFlag[i] = NO;
|
|
|
}
|
|
|
|
|
|
- if (_chargingData[i]->SystemStatus == S_BOOTING ||
|
|
|
- (_chargingData[i]->SystemStatus >= S_REASSIGN_CHECK && _chargingData[i]->SystemStatus <= S_COMPLETE) ||
|
|
|
- (_chargingData[i]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[i]->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
|
|
|
+ if (_chargingData[i]->SystemStatus == SYS_MODE_BOOTING ||
|
|
|
+ (_chargingData[i]->SystemStatus >= SYS_MODE_MODE_REASSIGN_CHECK && _chargingData[i]->SystemStatus <= SYS_MODE_COMPLETE) ||
|
|
|
+ (_chargingData[i]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && _chargingData[i]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) ||
|
|
|
ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.PageIndex >= _LCM_AUTHORIZING && ShmSysConfigAndInfo->SysInfo.PageIndex <= _LCM_WAIT_FOR_PLUG))
|
|
|
{
|
|
|
_chargingData[i]->IsReadyToCharging = YES;
|
|
|
isCharging = true;
|
|
|
|
|
|
- if (_chargingData[i]->SystemStatus == S_CHARGING)
|
|
|
+ if (_chargingData[i]->SystemStatus == SYS_MODE_CHARGING)
|
|
|
{
|
|
|
- CheckOutputPowerOverCarReq(i); // load dump
|
|
|
- //CheckOutputVolNoneMatchFire(i);
|
|
|
+ // OVP
|
|
|
+ CheckOutputPowerOverCarReq(i);
|
|
|
+ }
|
|
|
+ else if (_chargingData[i]->SystemStatus == SYS_MODE_PREPARE_FOR_EVSE)
|
|
|
+ {
|
|
|
+ // abnormal voltage at the stage of GFD
|
|
|
+ CheckOutputVolNoneMatchFire(i);
|
|
|
}
|
|
|
else
|
|
|
_isOutputNoneMatch[i] = NO;
|
|
@@ -3189,12 +3181,12 @@ int main(void)
|
|
|
{
|
|
|
if (!isStopChargingCount)
|
|
|
{
|
|
|
- gettimeofday(&_close_ac_contactor, NULL);
|
|
|
+ GetTimespecFunc(&_close_ac_contactor);
|
|
|
isStopChargingCount = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if ((outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000)))
|
|
|
+ if ((outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(&_close_ac_contactor) >= TEN_MINUTES))
|
|
|
outputRelay.relay_event.bits.AC_Contactor = NO;
|
|
|
}
|
|
|
}
|
|
@@ -3214,9 +3206,11 @@ int main(void)
|
|
|
outputRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_P = YES;
|
|
|
|
|
|
// 搭上/鬆開 Relay
|
|
|
+
|
|
|
if(IsNoneMatchRelayStatus())
|
|
|
{
|
|
|
relayMatchFlag = NO;
|
|
|
+
|
|
|
if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay))
|
|
|
{
|
|
|
//regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
|
|
@@ -3282,19 +3276,19 @@ int main(void)
|
|
|
{
|
|
|
ShmFanModuleData->SelfTest_Comp = YES;
|
|
|
|
|
|
- unsigned long _timebuf = GetTimeoutValue(_priority_time);
|
|
|
+ int _timebuf = GetTimeoutValue(&_priority_time);
|
|
|
|
|
|
if (_timebuf < 0)
|
|
|
- gettimeofday(&_priority_time, NULL);
|
|
|
+ GetTimespecFunc(&_priority_time);
|
|
|
else
|
|
|
{
|
|
|
- if (_timebuf / 1000 >= 1000)
|
|
|
+ if (_timebuf >= 1)
|
|
|
{
|
|
|
//GetPsuTempForFanSpeed();
|
|
|
GetFanSpeedByFunction();
|
|
|
GetFanSpeed();
|
|
|
ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed = _setFanSpeed;
|
|
|
- gettimeofday(&_priority_time, NULL);
|
|
|
+ GetTimespecFunc(&_priority_time);
|
|
|
|
|
|
ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
|
|
|
ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
|
|
@@ -3309,15 +3303,15 @@ int main(void)
|
|
|
|
|
|
if (ShmLedModuleData->SelfTest_Comp == YES)
|
|
|
{
|
|
|
- unsigned long _timebuf = GetTimeoutValue(_led_priority_time);
|
|
|
+ int _timebuf = GetTimeoutValue(&_led_priority_time);
|
|
|
if (_timebuf < 0)
|
|
|
- gettimeofday(&_led_priority_time, NULL);
|
|
|
+ GetTimespecFunc(&_led_priority_time);
|
|
|
else
|
|
|
{
|
|
|
- if (GetTimeoutValue(_led_blink_time) / 1000 > 6000)
|
|
|
- gettimeofday(&_led_blink_time, NULL);
|
|
|
+ if (GetTimeoutValue(&_led_blink_time) > 6)
|
|
|
+ GetTimespecFunc(&_led_blink_time);
|
|
|
|
|
|
- if (_timebuf / 1000 >= 1000)
|
|
|
+ if (_timebuf >= 1)
|
|
|
{
|
|
|
if(gunCount == 1)
|
|
|
{
|
|
@@ -3328,7 +3322,7 @@ int main(void)
|
|
|
SetLedColor(_chargingData[0], _chargingData[1]);
|
|
|
}
|
|
|
|
|
|
- gettimeofday(&_led_priority_time, NULL);
|
|
|
+ GetTimespecFunc(&_led_priority_time);
|
|
|
}
|
|
|
}
|
|
|
}
|