|
@@ -88,12 +88,12 @@ char* DebugVersion = "V2.09.00"; // Software debug version
|
|
|
bool isDb_ready;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
-void ClearDetectPluginFlag();
|
|
|
+void ClearDetectPluginFlag(int gunIndex);
|
|
|
|
|
|
long long DiffTimebWithNow(struct timeb ST);
|
|
|
uint8_t DetectBitValue(uint8_t _byte, uint8_t _bit);
|
|
|
void SetBitValue(uint8_t *_byte, uint8_t _bit, uint8_t value);
|
|
|
-unsigned long GetTimeoutValue(struct timeval _sour_time);
|
|
|
+unsigned long GetTimeoutValue(struct timespec _start_time);
|
|
|
void GetClockTime(struct timespec *_now_time, void *null);
|
|
|
unsigned long GetClockTimeoutValue(struct timespec _start_time);
|
|
|
void gpio_set_value(unsigned int gpio, unsigned int value);
|
|
@@ -758,19 +758,39 @@ static void checkEvBoardAlarmState(uint8_t gunType)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-unsigned long GetTimeoutValue(struct timeval _sour_time)
|
|
|
+unsigned long GetSecTimeoutValue(struct timespec _start_time)
|
|
|
{
|
|
|
- struct timeval _end_time;
|
|
|
- gettimeofday(&_end_time, NULL);
|
|
|
+ struct timespec ts_end;
|
|
|
+ unsigned long ret = 0;
|
|
|
+
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &ts_end);
|
|
|
|
|
|
- return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
|
|
|
+ ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000) + ((unsigned long)((ts_end.tv_nsec / 1000000) - (_start_time.tv_nsec / 1000000)));
|
|
|
+ /*
|
|
|
+ printf("\r\n TimeInterval: %ld.%09ld - %ld.%09ld = %ld.%03ld ms",
|
|
|
+ ts_end.tv_sec, ts_end.tv_nsec, _start_time.tv_sec, _start_time.tv_nsec,
|
|
|
+ (ret / 1000), (ret % 1000));
|
|
|
+ */
|
|
|
+ ret /= 1000;
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
void GetClockTime(struct timespec *_now_time, void *null)
|
|
|
{
|
|
|
clock_gettime(CLOCK_MONOTONIC, _now_time);
|
|
|
}
|
|
|
+unsigned long GetTimeoutValue(struct timespec _start_time)
|
|
|
+{
|
|
|
+ struct timespec ts_end;
|
|
|
+ unsigned long ret = 0;
|
|
|
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &ts_end);
|
|
|
+
|
|
|
+ ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
// return value unit: 1us
|
|
|
unsigned long GetClockTimeoutValue(struct timespec _start_time)
|
|
|
{
|
|
@@ -1201,7 +1221,7 @@ int Initialization(void)
|
|
|
ClearAuthorizedFlag();
|
|
|
|
|
|
// 初始化插槍驗證的 Flag
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ ClearDetectPluginFlag(pSysInfo->CurGunSelected);
|
|
|
|
|
|
for (count = 0; count < pSysConfig->TotalConnectorCount; count++) {
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(count);
|
|
@@ -1347,34 +1367,30 @@ bool isEvBoardNormalStopChargeFlag(uint8_t gunIndex)
|
|
|
//===============================================
|
|
|
// 掃描插槍狀況
|
|
|
//===============================================
|
|
|
-void ClearDetectPluginFlag(void)
|
|
|
+void ClearDetectPluginFlag(int gunIndex)
|
|
|
{
|
|
|
- uint8_t gunIndex = 0;
|
|
|
- pSysInfo->WaitForPlugit = NO;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
|
|
|
|
|
|
- //DS60-120 add
|
|
|
- for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
|
|
|
- /*
|
|
|
- if (pDcChargingInfo->RemoteStartFlag == YES) {
|
|
|
- pDcChargingInfo->RemoteStartFlag = NO;
|
|
|
- }
|
|
|
- */
|
|
|
+ if (pDcChargingInfo->RemoteStartFlag == YES) {
|
|
|
+ pDcChargingInfo->RemoteStartFlag = NO;
|
|
|
}
|
|
|
+ ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit = NO;
|
|
|
+
|
|
|
|
|
|
if (pSysInfo->OrderCharging != NO_DEFINE) {
|
|
|
pSysInfo->OrderCharging = NO_DEFINE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void DetectPluginStart()
|
|
|
+void DetectPluginStart(int gunIndex)
|
|
|
{
|
|
|
- pSysInfo->WaitForPlugit = YES;
|
|
|
+ //pSysInfo->WaitForPlugit = YES;
|
|
|
+ ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit = YES;
|
|
|
}
|
|
|
|
|
|
-bool isDetectPlugin()
|
|
|
+bool isDetectPlugin(int gunIndex)
|
|
|
{
|
|
|
- if (pSysInfo->WaitForPlugit == YES) {
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit == YES) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -1469,7 +1485,7 @@ bool isEvGunLocked_ccs(uint8_t gunIndex)
|
|
|
|
|
|
uint8_t isPrechargeStatus_ccs(uint8_t gunIndex)
|
|
|
{
|
|
|
- uint8_t result = 0x00;
|
|
|
+
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
|
|
|
|
|
|
return ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus;
|
|
@@ -1529,7 +1545,7 @@ void _AutoReturnTimeout(void)
|
|
|
pDcChargingInfo->SystemStatus = S_ALARM;
|
|
|
//pSysInfo->SystemPage = _LCM_ERROR;
|
|
|
pSysInfo->SystemPage = _LCM_MAINTAIN;
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ ClearDetectPluginFlag(pSysInfo->CurGunSelected);
|
|
|
} else if (pSysInfo->SystemPage ==_LCM_START_AUTHORIZE_FAIL) {
|
|
|
pSysInfo->SystemPage = _LCM_START_SCAN;
|
|
|
StartSystemTimeoutDet(Timeout_ReturnViewPage);
|
|
@@ -1566,16 +1582,17 @@ void _AuthorizedTimeout(void)
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
-void _DetectPlugInTimeout(void)
|
|
|
+void _DetectPlugInTimeout(int gunIndex)
|
|
|
{
|
|
|
log_info("*********** _DetectPlugInTimeout *********** ");
|
|
|
strcpy((char *)pSysConfig->UserId, "");
|
|
|
- StopSystemTimeoutDet();
|
|
|
- pSysInfo->SystemPage = _LCM_LINK_ERROR;
|
|
|
- StartSystemTimeoutDet(Timeout_ReturnViewPage);
|
|
|
- ClearDetectPluginFlag();
|
|
|
- //setChargerMode(pSysInfo->CurGunSelected, S_TERMINATING);
|
|
|
- //systemPageRestoreInit();
|
|
|
+
|
|
|
+ //pSysInfo->SystemPage = _LCM_LINK_ERROR;
|
|
|
+ //StartSystemTimeoutDet(Timeout_ReturnViewPage);
|
|
|
+ ClearDetectPluginFlag(gunIndex);
|
|
|
+ setChargerMode(gunIndex, S_IDLE);
|
|
|
+ if (pSysInfo->CurGunSelected == gunIndex)
|
|
|
+ systemPageRestoreInit();
|
|
|
}
|
|
|
|
|
|
void _DetectEvChargingEnableTimeout(uint8_t gunIndex)
|
|
@@ -2458,7 +2475,7 @@ void StartGunInfoTimeoutDet(uint8_t gunIndex, uint8_t flag)
|
|
|
|
|
|
if (gunIndex < pSysConfig->TotalConnectorCount) {
|
|
|
if (pDcChargingInfo->TimeoutFlag != flag) {
|
|
|
- gettimeofday(&pDcChargingInfo->TimeoutTimer, NULL);
|
|
|
+ GetClockTime(&pDcChargingInfo->ConnectorTimeout, NULL);
|
|
|
//log_info("Set Gun%d Timeout Flag %d", gunIndex,flag);
|
|
|
}
|
|
|
pDcChargingInfo->TimeoutFlag = flag;
|
|
@@ -2498,7 +2515,7 @@ void CreateTimeoutFork(void)
|
|
|
|
|
|
timeoutPid = fork();
|
|
|
if (timeoutPid == 0) {
|
|
|
- gettimeofday(&_cmdSubPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdSubPriority_time, NULL);
|
|
|
CheckConnectionTimeout();
|
|
|
|
|
|
//log_info("Timeout Fork Child's PID is %d", getpid());
|
|
@@ -2506,7 +2523,7 @@ void CreateTimeoutFork(void)
|
|
|
while (1) {
|
|
|
if ((GetTimeoutValue(_cmdSubPriority_time) / 1000) > 5000) {
|
|
|
CheckConnectionTimeout();
|
|
|
- gettimeofday(&_cmdSubPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdSubPriority_time, NULL);
|
|
|
}
|
|
|
//if (pSysInfo->SystemTimeoutFlag != 0)
|
|
|
//log_info("Timeout ***********SystemTimeoutFlag = %d(%d) ********",pSysInfo->SystemTimeoutFlag,
|
|
@@ -2581,13 +2598,6 @@ void CreateTimeoutFork(void)
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case Timeout_WaitPlug:
|
|
|
- if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= _connectionTimeout) {
|
|
|
- _DetectPlugInTimeout();
|
|
|
-
|
|
|
- //destroySelGun(pSysInfo->CurGunSelected);
|
|
|
- }
|
|
|
- break;
|
|
|
/*
|
|
|
case Timeout_ReturnToChargingGunDet:
|
|
|
if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= RETURN_TO_CHARGING_PAGE) {
|
|
@@ -2623,17 +2633,17 @@ void CreateTimeoutFork(void)
|
|
|
/*
|
|
|
if (pDcChargingInfo->TimeoutFlag != 0)
|
|
|
log_info("Timeout ***********GunTimeoutFlag = %d(%d) ********",pDcChargingInfo->TimeoutFlag,
|
|
|
- GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL);
|
|
|
+ GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL);
|
|
|
*/
|
|
|
switch (pDcChargingInfo->TimeoutFlag) {
|
|
|
case Timeout_EVCCID_Link:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= EVCCID_LINK_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= EVCCID_LINK_TIMEOUT) {
|
|
|
_evccidlinktimeout(gunIndex);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Timeout_Preparing:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_PREPARE_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_PREPARE_TIMEOUT) {
|
|
|
_PrepareTimeout(gunIndex);
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
@@ -2641,7 +2651,7 @@ void CreateTimeoutFork(void)
|
|
|
break;
|
|
|
|
|
|
case Timeout_EvChargingDet:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT) {
|
|
|
_DetectEvChargingEnableTimeout(gunIndex);
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
@@ -2649,7 +2659,7 @@ void CreateTimeoutFork(void)
|
|
|
break;
|
|
|
|
|
|
case Timeout_EvseChargingDet:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT) {
|
|
|
_DetectEvseChargingEnableTimeout(gunIndex);
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
@@ -2657,14 +2667,14 @@ void CreateTimeoutFork(void)
|
|
|
break;
|
|
|
|
|
|
case Timeout_EvseCompleteDet:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT) {
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case Timeout_ForCcsPrechargeDet:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT) {
|
|
|
_CcsPrechargeTimeout(gunIndex);
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
@@ -2672,7 +2682,7 @@ void CreateTimeoutFork(void)
|
|
|
break;
|
|
|
/*
|
|
|
case Timeout_SelectGun: //Jerry add
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
|
|
|
log_info("Timeout_SelectGun");
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
@@ -2680,21 +2690,21 @@ void CreateTimeoutFork(void)
|
|
|
break;
|
|
|
*/
|
|
|
case Timeout_PlugOut:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= PLUGOUT_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= PLUGOUT_TIMEOUT) {
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
|
setChargerMode(gunIndex, S_IDLE);
|
|
|
}
|
|
|
break;
|
|
|
case Timeout_GunAuthorizePage:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_AUTHORIZE_PAGE) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_AUTHORIZE_PAGE) {
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
destroySelGun(gunIndex); //jerry add
|
|
|
pDcChargingInfo->SystemStatus = S_IDLE;
|
|
|
}
|
|
|
break;
|
|
|
case Timeout_Terminating:
|
|
|
- if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= TERMINATING_TIMEOUT) {
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= TERMINATING_TIMEOUT) {
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
|
|
|
|
|
@@ -2703,6 +2713,14 @@ void CreateTimeoutFork(void)
|
|
|
setChargerMode(gunIndex, S_COMPLETE);
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
+ case Timeout_WaitPlug:
|
|
|
+ if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= _connectionTimeout) {
|
|
|
+ StopGunInfoTimeoutDet(gunIndex);
|
|
|
+ _DetectPlugInTimeout(gunIndex);
|
|
|
+ destroySelGun(gunIndex);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
sleep(1);
|
|
@@ -2860,36 +2878,35 @@ void OcppRemoteStartChk()
|
|
|
{
|
|
|
if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
|
|
|
|
|
|
- } else if (!isDetectPlugin()) {
|
|
|
+ } else {
|
|
|
// 如果有 AC 槍,則固定是第 2 把槍,所以索引固定為 1
|
|
|
uint8_t acDirIndex = pSysConfig->AcConnectorCount;
|
|
|
+ if (!isDetectPlugin(acDirIndex)) {
|
|
|
+ for (uint8_t ac_index = 0; ac_index < pSysConfig->AcConnectorCount; ac_index++) {
|
|
|
+ pAcChargingInfo = (struct ChargingInfoData*)GetAcChargingInfoData(ac_index);
|
|
|
|
|
|
- for (uint8_t ac_index = 0; ac_index < pSysConfig->AcConnectorCount; ac_index++) {
|
|
|
- pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(ac_index);
|
|
|
-
|
|
|
- if (ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq == YES) {
|
|
|
- if (pAcChargingInfo->SystemStatus == S_IDLE ||
|
|
|
+ if (ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq == YES) {
|
|
|
+ if (pAcChargingInfo->SystemStatus == S_IDLE ||
|
|
|
pAcChargingInfo->SystemStatus == S_RESERVATION) {
|
|
|
+ ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq = NO;
|
|
|
+ pAcChargingInfo->RemoteStartFlag = YES;
|
|
|
+ pSysInfo->OrderCharging = YES;
|
|
|
+ //pSysInfo->OrderCharging = DEFAULT_AC_INDEX;
|
|
|
+ ShmOCPP16Data->CsMsg.bits[pSysConfig->TotalConnectorCount + ac_index].RemoteStartTransactionReq = NO;
|
|
|
+ DetectPluginStart(acDirIndex);
|
|
|
+ return;
|
|
|
+ }
|
|
|
ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq = NO;
|
|
|
- pAcChargingInfo->RemoteStartFlag = YES;
|
|
|
- pSysInfo->OrderCharging = YES;
|
|
|
- //pSysInfo->OrderCharging = DEFAULT_AC_INDEX;
|
|
|
- ShmOCPP16Data->CsMsg.bits[pSysConfig->TotalConnectorCount + ac_index].RemoteStartTransactionReq = NO;
|
|
|
- DetectPluginStart();
|
|
|
- return;
|
|
|
}
|
|
|
- ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq = NO;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- uint8_t threeGunIndex = 0;
|
|
|
- uint8_t dcIndex = 0;
|
|
|
- bool isGunUsingStatus = false;
|
|
|
- bool _remotestarting = false;
|
|
|
+ //uint8_t threeGunIndex = 0;
|
|
|
+ //uint8_t dcIndex = 0;
|
|
|
+ //bool isGunUsingStatus = false;
|
|
|
|
|
|
for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
|
|
|
-
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_index);
|
|
|
+ /*
|
|
|
// 如果有 AC 槍,且 DC 槍也有兩把
|
|
|
if (acDirIndex == 1 && _index == 1) {
|
|
|
threeGunIndex = 1;
|
|
@@ -2903,7 +2920,7 @@ void OcppRemoteStartChk()
|
|
|
isGunUsingStatus = true;
|
|
|
}
|
|
|
if (pDcChargingInfo->RemoteStartFlag == YES) {
|
|
|
- _remotestarting = true;
|
|
|
+ //_remotestarting = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2920,24 +2937,26 @@ void OcppRemoteStartChk()
|
|
|
if (dcIndex == 0) {
|
|
|
threeGunIndex = 0;
|
|
|
}
|
|
|
+ */
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_index);
|
|
|
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(dcIndex);
|
|
|
-
|
|
|
- if (ShmOCPP16Data->CsMsg.bits[dcIndex + threeGunIndex].RemoteStartTransactionReq == YES &&
|
|
|
- !_remotestarting ) {
|
|
|
- if (pDcChargingInfo->SystemStatus == S_IDLE ||
|
|
|
- pDcChargingInfo->SystemStatus == S_AUTHORIZING ||
|
|
|
+ if (ShmOCPP16Data->CsMsg.bits[_index].RemoteStartTransactionReq == YES &&
|
|
|
+ !isDetectPlugin(_index)) {
|
|
|
+ if (pDcChargingInfo->SystemStatus == S_IDLE ||
|
|
|
+ pDcChargingInfo->SystemStatus == MODE_AUTHORIZING ||
|
|
|
pDcChargingInfo->SystemStatus == S_RESERVATION) {
|
|
|
- pDcChargingInfo->RemoteStartFlag = YES;
|
|
|
- pSysInfo->OrderCharging = YES;
|
|
|
- //pDcChargingInfo->SystemStatus = S_AUTHORIZING;
|
|
|
- //pSysInfo->OrderCharging = gunIndex;
|
|
|
- ShmOCPP16Data->CsMsg.bits[dcIndex + threeGunIndex].RemoteStartTransactionReq = NO;
|
|
|
- DetectPluginStart();
|
|
|
- setSelGunWaitToAuthor(dcIndex);
|
|
|
- log_info("Ocpp Remote Start Pass");
|
|
|
+ pDcChargingInfo->RemoteStartFlag = YES;
|
|
|
+ //ShmDcCommonData->is_RemoteStart[_index] = TRUE;
|
|
|
+ //pSysInfo->OrderCharging = YES;
|
|
|
+ //pDcChargingInfo->SystemStatus = S_AUTHORIZING;
|
|
|
+ //pSysInfo->OrderCharging = gunIndex;
|
|
|
+ ShmOCPP16Data->CsMsg.bits[_index].RemoteStartTransactionReq = NO;
|
|
|
+ DetectPluginStart(_index);
|
|
|
+ setSelGunWaitToAuthor(_index);
|
|
|
+ log_info("Ocpp Remote Start Gun%d Pass", _index);
|
|
|
+ }
|
|
|
+ ShmOCPP16Data->CsMsg.bits[_index].RemoteStartTransactionReq = NO;
|
|
|
}
|
|
|
- ShmOCPP16Data->CsMsg.bits[dcIndex + threeGunIndex].RemoteStartTransactionReq = NO;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -3110,7 +3129,6 @@ void ChangeStartOrStopDateTime(uint8_t isStart, uint8_t gunIndex)
|
|
|
}
|
|
|
void GetChargeTranscationDateTime(uint8_t gunIndex)
|
|
|
{
|
|
|
- char cmdBuf[32];
|
|
|
struct timeb csuTime;
|
|
|
struct tm* tmCSU;
|
|
|
|
|
@@ -3827,7 +3845,7 @@ void ResetIdleData(uint8_t gunIndex)
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
|
|
|
ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
|
|
|
ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
|
|
|
-
|
|
|
+ float powerconsumption = ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption;
|
|
|
pDcChargingInfo->PresentChargedDuration = 0;
|
|
|
pDcChargingInfo->RemainChargingDuration = 0;
|
|
|
pDcChargingInfo->PresentChargingVoltage = 0;//DS60-120 add
|
|
@@ -3841,11 +3859,13 @@ void ResetIdleData(uint8_t gunIndex)
|
|
|
ShmDcCommonData->isIntoCharge[gunIndex] = FALSE;
|
|
|
ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
|
|
|
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ ClearDetectPluginFlag(gunIndex);
|
|
|
//Jerry add
|
|
|
memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
|
|
|
memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));
|
|
|
- DB_Get_PowerConsumption(gunIndex);
|
|
|
+
|
|
|
+ ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption = powerconsumption;
|
|
|
+
|
|
|
ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
|
|
|
destroySelGun(gunIndex);
|
|
|
ResetDetAlarmStatus(gunIndex); //recovery OVP status code
|
|
@@ -3874,7 +3894,7 @@ void CheckErrorCode(uint8_t gunIndex)
|
|
|
systemPageRestoreInit();
|
|
|
}
|
|
|
}
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ ClearDetectPluginFlag(gunIndex);
|
|
|
if (pDcChargingInfo->SystemStatus != S_FAULT)
|
|
|
{
|
|
|
UpdateErrorCodeToOcpp(gunIndex);
|
|
@@ -3939,7 +3959,6 @@ int main(void)
|
|
|
bool isModelNameMatch = true;
|
|
|
uint8_t _ocppProfileChkFlag;
|
|
|
uint8_t gunIndex = 0;
|
|
|
- uint8_t isplugin[2] = {0};
|
|
|
if (CreateAllCsuShareMemory() == FAIL) {
|
|
|
log_error("create share memory error");
|
|
|
return FAIL;
|
|
@@ -4058,16 +4077,15 @@ int main(void)
|
|
|
|
|
|
CheckFwSlotStatusLog();
|
|
|
//AdjustChargerCurrent();
|
|
|
- gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdMainPriority_time, NULL);
|
|
|
|
|
|
- GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
|
|
|
+ //GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
|
|
|
|
|
|
CheckTaskAlive();
|
|
|
|
|
|
CreateWatchdog();
|
|
|
- int is_idle = TRUE;
|
|
|
- time_t ShowEVStatusTimer[2] = { 0 };
|
|
|
- int EVStatus[2];
|
|
|
+ int is_prepare0 = FALSE;
|
|
|
+ int is_prepare1 = FALSE;
|
|
|
pSysInfo->OTPTemp = GUN_OTP_VALUE;
|
|
|
pSysInfo->OTPTempR = GUN_OTP_RECOVERY;
|
|
|
|
|
@@ -4115,26 +4133,42 @@ int main(void)
|
|
|
}
|
|
|
checkGunOTPState(gunIndex); //check gun OTP
|
|
|
}
|
|
|
- gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdMainPriority_time, NULL);
|
|
|
}
|
|
|
|
|
|
gEvBoardErr.GunErrMessage = 0; //清除系統執行中的錯誤訊息
|
|
|
gChillerTempErr.TempErrMsg = 0;//清除系統執行中的錯誤訊息
|
|
|
- is_idle = TRUE;
|
|
|
+ is_prepare0 = FALSE;
|
|
|
+ is_prepare1 = FALSE;
|
|
|
for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
|
|
|
// 重新收集各槍的錯誤狀態
|
|
|
collectError(gunIndex);
|
|
|
checkEvBoardAlarmState(pDcChargingInfo->Type);
|
|
|
- if ((pDcChargingInfo->SystemStatus >= S_REASSIGN_CHECK &&
|
|
|
- pDcChargingInfo->SystemStatus <= S_COMPLETE) ||
|
|
|
+ if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
|
|
|
+ pDcChargingInfo->SystemStatus <= S_PREPARING_FOR_EVSE) ||
|
|
|
pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 ||
|
|
|
pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) {
|
|
|
- is_idle = FALSE;
|
|
|
+ (gunIndex == LEFT_GUN_NUM) ? (is_prepare0 = TRUE) : (is_prepare1 = TRUE);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ // 檢查是否有槍處於Preparing & precharging 狀態
|
|
|
+ if (is_prepare0 && !is_prepare1) {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
|
|
|
+ if (pDcChargingInfo->SystemStatus != S_AUTHORIZING)
|
|
|
+ pSysInfo->CurGunSelected = LEFT_GUN_NUM;
|
|
|
+ else if (pDcChargingInfo->SystemStatus == S_AUTHORIZING) {
|
|
|
+ pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
|
|
|
+ }
|
|
|
+ } else if (!is_prepare0 && is_prepare1) {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
|
|
|
+ if (pDcChargingInfo->SystemStatus != S_AUTHORIZING)
|
|
|
+ pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
|
|
|
+ else if (pDcChargingInfo->SystemStatus == S_AUTHORIZING) {
|
|
|
+ pSysInfo->CurGunSelected = LEFT_GUN_NUM;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ////////////////////////////////////////
|
|
|
checkChillerAlarmState();
|
|
|
|
|
|
// 確認當前錯誤 Level = 2 ?
|
|
@@ -4243,7 +4277,8 @@ CheckStatus:
|
|
|
// 隨插即充
|
|
|
//autoStartCharging(gunIndex);
|
|
|
|
|
|
- if (isDetectPlugin() && pSysInfo->SystemPage != _LCM_LINK_ERROR) {
|
|
|
+ if (isDetectPlugin(gunIndex) && pSysInfo->SystemPage != _LCM_LINK_ERROR) {
|
|
|
+ StartGunInfoTimeoutDet(gunIndex, Timeout_WaitPlug);
|
|
|
// 卡號驗證成功後,等待充電槍插入充電車
|
|
|
if (pDcChargingInfo->RemoteStartFlag == YES) {
|
|
|
if (pDcChargingInfo->ConnectorPlugIn == YES &&
|
|
@@ -4256,7 +4291,7 @@ CheckStatus:
|
|
|
setChargerMode(gunIndex, MODE_REASSIGN_CHECK);
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
strcpy((char *)pDcChargingInfo->StartUserId, "");
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ ClearDetectPluginFlag(gunIndex);
|
|
|
continue;
|
|
|
}
|
|
|
} else if (pSysInfo->OrderCharging == NO_DEFINE) {
|
|
@@ -4279,7 +4314,7 @@ CheckStatus:
|
|
|
// 當前操作的槍號,進入 Preparing
|
|
|
setChargerMode(gunIndex, MODE_REASSIGN_CHECK);
|
|
|
StopGunInfoTimeoutDet(gunIndex);
|
|
|
- ClearDetectPluginFlag();
|
|
|
+ ClearDetectPluginFlag(gunIndex);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
@@ -4321,7 +4356,7 @@ CheckStatus:
|
|
|
|
|
|
if (ShmPsuData->SystemPresentPsuQuantity > 0 &&
|
|
|
ShmPsuData->SystemAvailablePower > 10 &&
|
|
|
- GetTimeoutValue(pDcChargingInfo->TimeoutTimer) >= 1000000) {
|
|
|
+ GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) >= 1000000) {
|
|
|
setChargerMode(gunIndex, MODE_PREPARE_FOR_EV);
|
|
|
}
|
|
|
|
|
@@ -4458,7 +4493,8 @@ CheckStatus:
|
|
|
ftime(&startChargingTime[gunIndex]);
|
|
|
strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].ResponseIdTagInfo.Status, ""); //DS60-120 add
|
|
|
ChangeStartOrStopDateTime(YES, gunIndex);
|
|
|
- pSysInfo->SystemPage = _LCM_VIEW;
|
|
|
+ if (pSysInfo->CurGunSelected == gunIndex)
|
|
|
+ pSysInfo->SystemPage = _LCM_VIEW;
|
|
|
ShmDcCommonData->isIntoCharge[gunIndex] = TRUE;
|
|
|
}
|
|
|
|