|
@@ -76,6 +76,7 @@
|
|
|
|
|
|
#define DB_FILE "/Storage/ChargeLog/localCgargingRecord.db"
|
|
|
|
|
|
+#define MAIN_PRIORITY_INTERVAL 5
|
|
|
#define SELFTEST_TIMEOUT 60
|
|
|
#define AUTHORIZE_TIMEOUT 30
|
|
|
#define AUTHORIZE_COMP_TIMEOUT 1
|
|
@@ -83,8 +84,8 @@
|
|
|
#define AUTHORIZE_STOP_TIMEOUT 30
|
|
|
#define RETURN_TO_CHARGING_PAGE 30
|
|
|
#define GUN_PREPARE_TIMEOUT 30
|
|
|
-#define GUN_EV_WAIT_TIMEOUT 120
|
|
|
-#define GUN_EVSE_WAIT_TIMEOUT 60
|
|
|
+#define GUN_EV_WAIT_TIMEOUT (120 + 10)
|
|
|
+#define GUN_EVSE_WAIT_TIMEOUT (60 + 10)
|
|
|
#define GUN_COMP_WAIT_TIMEOUT 10
|
|
|
#define GUN_PRECHARGING_TIMEOUT 60
|
|
|
|
|
@@ -110,6 +111,9 @@
|
|
|
#define FORCE_CHARGING_WAIT_EVSE 10 // unit: second
|
|
|
#define TRY_RESET_4G_WIFI_TIME 300 // unit: second
|
|
|
#define FAST_RESET_4G_WIFI_TIME 60 // unit: second
|
|
|
+#define ENERAGY_INTERVAL 1 // unit: second
|
|
|
+
|
|
|
+#define AUTO_START_CHARGING "AutoStartCharging"
|
|
|
|
|
|
char *valid_Internet[2] = {"8.8.8.8", "180.76.76.76"};
|
|
|
unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
|
|
@@ -165,12 +169,12 @@ unsigned char DetectBitValue(unsigned char _byte, unsigned char _bit);
|
|
|
void SetBitValue(unsigned char *_byte, unsigned char _bit, unsigned char value);
|
|
|
void ChargingTerminalProcess(byte gunIndex);
|
|
|
void ChkPrimaryStatus();
|
|
|
-void StartSystemTimeoutDet(unsigned char flag);
|
|
|
-void StopSystemTimeoutDet();
|
|
|
-void StartGunInfoTimeoutDet(unsigned char gunIndex, unsigned char flag);
|
|
|
-void StopGunInfoTimeoutDet(unsigned char gunIndex);
|
|
|
+//void StartSystemTimeoutDet(unsigned char flag);
|
|
|
+//void StopSystemTimeoutDet();
|
|
|
+//void StartGunInfoTimeoutDet(unsigned char gunIndex, unsigned char flag);
|
|
|
+//void StopGunInfoTimeoutDet(unsigned char gunIndex);
|
|
|
int StoreLogMsg_1(const char *fmt, ...);
|
|
|
-unsigned long GetTimeoutValue(struct timeval _sour_time);
|
|
|
+
|
|
|
void gpio_set_value(unsigned int gpio, unsigned int value);
|
|
|
void ChangeGunSelectByIndex(byte sel);
|
|
|
void ChargingAlarmProcess(byte gunIndex);
|
|
@@ -210,21 +214,20 @@ PsuGroupCollectionData *ShmGroupCollection;
|
|
|
|
|
|
struct ChargingInfoData *chargingInfo[CONNECTOR_QUANTITY];
|
|
|
struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
|
-struct timeb startChargingTime[CONNECTOR_QUANTITY];
|
|
|
-struct timeb endChargingTime[CONNECTOR_QUANTITY];
|
|
|
|
|
|
-struct timeval _ConnectorAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
-struct timeval _ConnectorAuthorizeFail_Time[CONNECTOR_QUANTITY];
|
|
|
-struct timeval _DispenserAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
-int chargingTime[CONNECTOR_QUANTITY];
|
|
|
-struct timeval _DispenserUpgrade_time;
|
|
|
-struct timeval _Standby_time;
|
|
|
-struct timeval _SystemStatus_Time[CONNECTOR_QUANTITY];
|
|
|
+struct timespec _cmdMainPriority_time;
|
|
|
+struct timespec _cmdSubPriority_time;
|
|
|
+struct timespec _ConnectorAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
+struct timespec _ConnectorAuthorizeFail_Time[CONNECTOR_QUANTITY];
|
|
|
+struct timespec _DispenserAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
+struct timespec _DispenserUpgrade_time;
|
|
|
+struct timespec _Standby_time;
|
|
|
+struct timespec _SystemStatus_Time[CONNECTOR_QUANTITY];
|
|
|
|
|
|
unsigned char _PsuGroupAvailable[CONNECTOR_QUANTITY];
|
|
|
|
|
|
bool _NeedReset4gWifi;
|
|
|
-struct timeval _4gWifiReset_time;
|
|
|
+struct timespec _4gWifiReset_time;
|
|
|
|
|
|
// for initial index to check EV board type is correct
|
|
|
byte _gunIndex = 0;
|
|
@@ -243,7 +246,7 @@ bool isModelNameMatch = true;
|
|
|
|
|
|
//int rfidFd = -1;
|
|
|
//char* rfidPortName = "/dev/ttyS2";
|
|
|
-char* fwVersion = "V1.01.00.0000.00";
|
|
|
+char* fwVersion = "V1.02.00.0000.00";
|
|
|
|
|
|
sqlite3 *localDb;
|
|
|
bool isDb_ready;
|
|
@@ -392,14 +395,6 @@ int StoreLogMsg_1(const char *fmt, ...)
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-unsigned long GetTimeoutValue(struct timeval _sour_time)
|
|
|
-{
|
|
|
- struct timeval _end_time;
|
|
|
- gettimeofday(&_end_time, NULL);
|
|
|
-
|
|
|
- return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
|
|
|
-}
|
|
|
-
|
|
|
int mystrcmp(unsigned char *p1, unsigned char *p2)
|
|
|
{
|
|
|
while(*p1==*p2)
|
|
@@ -1356,7 +1351,7 @@ void Check4gWifiReset(void)
|
|
|
{
|
|
|
if(!_NeedReset4gWifi)
|
|
|
{
|
|
|
- gettimeofday(&_4gWifiReset_time, NULL);
|
|
|
+ GetClockTime(&_4gWifiReset_time);
|
|
|
LOG_INFO("Backend Enable But Internet Not Available!");
|
|
|
}
|
|
|
_NeedReset4gWifi = true;
|
|
@@ -2097,8 +2092,7 @@ bool DisplaySelfTestFailReason()
|
|
|
|
|
|
void SelfTestRun()
|
|
|
{
|
|
|
- struct timeval _selfTest_time;
|
|
|
-
|
|
|
+ struct timespec _selfTest_time;
|
|
|
|
|
|
ShmRelayModuleData[0]->SelfTest_Comp = NO;
|
|
|
ShmRelayModuleData[1]->SelfTest_Comp = NO;
|
|
@@ -2106,7 +2100,7 @@ void SelfTestRun()
|
|
|
ShmPrimaryMcuData->SelfTest_Comp = NO;
|
|
|
|
|
|
ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_VERSION;
|
|
|
- gettimeofday(&_selfTest_time, NULL);
|
|
|
+ GetClockTime(&_selfTest_time);
|
|
|
|
|
|
while (ShmSysConfigAndInfo->SysInfo.SelfTestSeq != _STEST_COMPLETE)
|
|
|
{
|
|
@@ -2868,7 +2862,7 @@ void ChkPrimaryStatus()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct timeval _AcContactReOpen_Time;
|
|
|
+struct timespec _AcContactReOpen_Time;
|
|
|
|
|
|
void ChkPsuStatus(void)
|
|
|
{
|
|
@@ -2921,7 +2915,7 @@ void PsuFailureResume(void)
|
|
|
{
|
|
|
LOG_INFO("Ac Contactor Off By Psu Failure");
|
|
|
// update _AcContactReOpen_Time
|
|
|
- gettimeofday(&_AcContactReOpen_Time, NULL);
|
|
|
+ GetClockTime(&_AcContactReOpen_Time);
|
|
|
ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByPsu = YES;
|
|
|
AcContactorReOpenCount++;
|
|
|
}
|
|
@@ -2934,7 +2928,7 @@ void PsuFailureResume(void)
|
|
|
ReleaseEmsOccureByString(0, "042267");
|
|
|
|
|
|
// update _AcContactReOpen_Time
|
|
|
- gettimeofday(&_AcContactReOpen_Time, NULL);
|
|
|
+ GetClockTime(&_AcContactReOpen_Time);
|
|
|
ShmChargerInfo->Control.RelayCtrl.bits.AcContactorOffByPsu = NO;
|
|
|
ShmChargerInfo->Control.PsuCtrl.bits.FailureResume = NO;
|
|
|
LOG_INFO("Psu Failure Resume");
|
|
@@ -2993,7 +2987,7 @@ void StandbyCheck(void)
|
|
|
else
|
|
|
{
|
|
|
ShmChargerInfo->Control.RelayCtrl.bits.StandbyCountdown = YES;
|
|
|
- gettimeofday(&_Standby_time, NULL);
|
|
|
+ GetClockTime(&_Standby_time);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -3367,7 +3361,7 @@ void ScannerCardProcess()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-struct timeval _StartAuthorizing_Time;
|
|
|
+struct timespec _StartAuthorizing_Time;
|
|
|
|
|
|
void PowerCabinetAuthorizingSettingInitial(void)
|
|
|
{
|
|
@@ -3599,7 +3593,7 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
}
|
|
|
|
|
|
// update start authorizing timeout
|
|
|
- gettimeofday(&_StartAuthorizing_Time, NULL);
|
|
|
+ GetClockTime(&_StartAuthorizing_Time);
|
|
|
ShmSysConfigAndInfo->SysInfo.AuthorizedStatus = _AuthorizeStatus_Busy;
|
|
|
}
|
|
|
break;
|
|
@@ -3662,12 +3656,23 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
if (strcmp((char *)ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[i], (char *)ShmSysConfigAndInfo->SysConfig.UserId) == EQUAL)
|
|
|
{
|
|
|
find = true;
|
|
|
+ LOG_INFO("*********** Dispenser %d White Card OK ***********", dispenser + 1);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- LOG_INFO("*********** Dispenser %d White Card %s ***********", dispenser + 1, find ? "OK" : "NG");
|
|
|
+ if(find == false)
|
|
|
+ {
|
|
|
+ if(ShmChargerInfo->AuthInfo.AuthMode.bits.AutoStartEnable &&
|
|
|
+ strcmp((char *)ShmSysConfigAndInfo->SysConfig.UserId, AUTO_START_CHARGING) == EQUAL)
|
|
|
+ {
|
|
|
+ find = true;
|
|
|
+ LOG_INFO("******** Dispenser %d Auto Start Charging ********", dispenser + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG_INFO("*********** Dispenser %d Local Authorization %s ***********", dispenser + 1, find ? "OK" : "NG");
|
|
|
|
|
|
ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].AuthResult = find ? _AuthResult_Valid : _AuthResult_Invalid;
|
|
|
ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].AuthStatus = _AuthorizeStatus_Done;
|
|
@@ -3714,18 +3719,18 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
else if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].AuthResult == _AuthResult_Invalid)
|
|
|
{
|
|
|
// update connector authorizing timeout
|
|
|
- gettimeofday(&_ConnectorAuthorizeFail_Time[connector], NULL);
|
|
|
+ GetClockTime(&_ConnectorAuthorizeFail_Time[connector]);
|
|
|
}
|
|
|
}
|
|
|
// authorize completed
|
|
|
ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizingCompleted = true;
|
|
|
|
|
|
// update dispenser authorizing timeout
|
|
|
- gettimeofday(&_DispenserAuthorizing_Time[dispenser], NULL);
|
|
|
+ GetClockTime(&_DispenserAuthorizing_Time[dispenser]);
|
|
|
ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].AuthStatus = _AuthorizeStatus_End;
|
|
|
|
|
|
// update authorizing completed timeout
|
|
|
- gettimeofday(&_StartAuthorizing_Time, NULL);
|
|
|
+ GetClockTime(&_StartAuthorizing_Time);
|
|
|
ShmSysConfigAndInfo->SysInfo.AuthorizedStatus = _AuthorizeStatus_End;
|
|
|
break;
|
|
|
case _AuthorizeStatus_End:
|
|
@@ -3737,7 +3742,7 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
break;
|
|
|
default:
|
|
|
// update authorizing completed timeout
|
|
|
- gettimeofday(&_StartAuthorizing_Time, NULL);
|
|
|
+ GetClockTime(&_StartAuthorizing_Time);
|
|
|
ShmSysConfigAndInfo->SysInfo.AuthorizedStatus = _AuthorizeStatus_End;
|
|
|
break;
|
|
|
}
|
|
@@ -4003,7 +4008,7 @@ BOOL WaitAllDispenserUpgradeCompleted(void)
|
|
|
{
|
|
|
BOOL completed = TRUE;
|
|
|
|
|
|
- gettimeofday(&_DispenserUpgrade_time, NULL);
|
|
|
+ GetClockTime(&_DispenserUpgrade_time);
|
|
|
do
|
|
|
{
|
|
|
completed = TRUE;
|
|
@@ -4325,7 +4330,7 @@ void CreateRfidFork()
|
|
|
}
|
|
|
}
|
|
|
*/
|
|
|
-
|
|
|
+#if 0
|
|
|
void StartSystemTimeoutDet(unsigned char flag)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag != flag)
|
|
@@ -4360,6 +4365,7 @@ void StopGunInfoTimeoutDet(unsigned char gunIndex)
|
|
|
chargingInfo[gunIndex]->TimeoutFlag = Timeout_None;
|
|
|
}
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
void TriggerDispenserConnectionTimeoutSetting(void)
|
|
|
{
|
|
@@ -4417,7 +4423,7 @@ void CreateTimeoutFork()
|
|
|
timeoutPid = fork();
|
|
|
if (timeoutPid > 0)
|
|
|
{
|
|
|
- gettimeofday(&_cmdSubPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdSubPriority_time);
|
|
|
CheckConnectionTimeout();
|
|
|
|
|
|
while(true)
|
|
@@ -4425,13 +4431,13 @@ void CreateTimeoutFork()
|
|
|
if ((GetTimeoutValue(_cmdSubPriority_time) / 1000) > 5000)
|
|
|
{
|
|
|
CheckConnectionTimeout();
|
|
|
- gettimeofday(&_cmdSubPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdSubPriority_time);
|
|
|
}
|
|
|
|
|
|
//printf("Timeout ***********SystemTimeoutFlag = %d, ********\n", ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag);
|
|
|
// 系統
|
|
|
- switch(ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag)
|
|
|
- {
|
|
|
+// switch(ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag)
|
|
|
+// {
|
|
|
// case Timeout_SelftestChk:
|
|
|
// if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= SELFTEST_TIMEOUT)
|
|
|
// {
|
|
@@ -4460,85 +4466,85 @@ void CreateTimeoutFork()
|
|
|
// StopSystemTimeoutDet();
|
|
|
// }
|
|
|
// break;
|
|
|
- case Timeout_WaitPlug:
|
|
|
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= _connectionTimeout)
|
|
|
- {
|
|
|
- _DetectPlugInTimeout();
|
|
|
- StopSystemTimeoutDet();
|
|
|
- }
|
|
|
- break;
|
|
|
- case Timeout_ReturnToChargingGunDet:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= RETURN_TO_CHARGING_PAGE)
|
|
|
- {
|
|
|
- DisplayChargingInfo();
|
|
|
- StopSystemTimeoutDet();
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case Timeout_AuthorizingForStop:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_STOP_TIMEOUT)
|
|
|
- {
|
|
|
- strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- ClearAuthorizedFlag();
|
|
|
- StopSystemTimeoutDet();
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+// case Timeout_WaitPlug:
|
|
|
+// if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= _connectionTimeout)
|
|
|
+// {
|
|
|
+// _DetectPlugInTimeout();
|
|
|
+// StopSystemTimeoutDet();
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case Timeout_ReturnToChargingGunDet:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= RETURN_TO_CHARGING_PAGE)
|
|
|
+// {
|
|
|
+// DisplayChargingInfo();
|
|
|
+// StopSystemTimeoutDet();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case Timeout_AuthorizingForStop:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_STOP_TIMEOUT)
|
|
|
+// {
|
|
|
+// strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
+// ClearAuthorizedFlag();
|
|
|
+// StopSystemTimeoutDet();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// }
|
|
|
// 各槍
|
|
|
- for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
|
|
|
- {
|
|
|
+// for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
|
|
|
+// {
|
|
|
//printf("Timeout ***********TimeoutFlag = %d, ********\n", chargingInfo[gun_index]->TimeoutFlag);
|
|
|
- switch(chargingInfo[gun_index]->TimeoutFlag)
|
|
|
- {
|
|
|
- case Timeout_Preparing:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_PREPARE_TIMEOUT)
|
|
|
- {
|
|
|
- _PrepareTimeout(gun_index);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case Timeout_EvChargingDet:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT)
|
|
|
- {
|
|
|
- _DetectEvChargingEnableTimeout(gun_index);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case Timeout_EvseChargingDet:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT)
|
|
|
- {
|
|
|
- _DetectEvseChargingEnableTimeout(gun_index);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case Timeout_EvseCompleteDet:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT)
|
|
|
- {
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case Timeout_ForCcsPrechargeDet:
|
|
|
- {
|
|
|
- if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT)
|
|
|
- {
|
|
|
- _CcsPrechargeTimeout(gun_index);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+// switch(chargingInfo[gun_index]->TimeoutFlag)
|
|
|
+// {
|
|
|
+// case Timeout_Preparing:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_PREPARE_TIMEOUT)
|
|
|
+// {
|
|
|
+// _PrepareTimeout(gun_index);
|
|
|
+// StopGunInfoTimeoutDet(gun_index);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case Timeout_EvChargingDet:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT)
|
|
|
+// {
|
|
|
+// _DetectEvChargingEnableTimeout(gun_index);
|
|
|
+// StopGunInfoTimeoutDet(gun_index);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case Timeout_EvseChargingDet:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT)
|
|
|
+// {
|
|
|
+// _DetectEvseChargingEnableTimeout(gun_index);
|
|
|
+// StopGunInfoTimeoutDet(gun_index);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case Timeout_EvseCompleteDet:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT)
|
|
|
+// {
|
|
|
+// StopGunInfoTimeoutDet(gun_index);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case Timeout_ForCcsPrechargeDet:
|
|
|
+// {
|
|
|
+// if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT)
|
|
|
+// {
|
|
|
+// _CcsPrechargeTimeout(gun_index);
|
|
|
+// StopGunInfoTimeoutDet(gun_index);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
sleep(1);
|
|
|
}
|
|
|
}
|
|
@@ -4656,40 +4662,39 @@ void ExecuteWriteWiringInfo(void)
|
|
|
int result = StoreUsrConfigData(&config);
|
|
|
if(result != 1)
|
|
|
{
|
|
|
- LOG_INFO("Write Wiring Info NG");
|
|
|
+ LOG_INFO("Store User Config NG");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LOG_INFO("WriteWiringInfo OK");
|
|
|
+ LOG_INFO("Store User Config OK");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct timeval _WiringInfo_time;
|
|
|
+struct timespec _WiringInfo_time;
|
|
|
int CheckWiringInfoUpdate(void)
|
|
|
{
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.WiringInfoChanged)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.FlashConfigChanged)
|
|
|
{
|
|
|
- ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.WiringInfoChanged = false;
|
|
|
- LOG_INFO("Wiring Info Changed");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.FlashConfigChanged = false;
|
|
|
+ LOG_INFO("Flash Config Changed");
|
|
|
|
|
|
- gettimeofday(&_WiringInfo_time, NULL);
|
|
|
- ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.EnableWriteWiringInfo = true;
|
|
|
+ GetClockTime(&_WiringInfo_time);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.EnableWriteFlash = true;
|
|
|
}
|
|
|
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.EnableWriteWiringInfo)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.EnableWriteFlash)
|
|
|
{
|
|
|
// 30s for reboot request timeout
|
|
|
if((GetTimeoutValue(_WiringInfo_time) / uSEC_VAL) >= WIRING_INFO_DELAY ||
|
|
|
ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.CleanWiringInfo)
|
|
|
{
|
|
|
- ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.EnableWriteWiringInfo = false;
|
|
|
- LOG_INFO("Start Wirte Wiring Info To Flash");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.EnableWriteFlash = false;
|
|
|
+ LOG_INFO("Start Write To Flash");
|
|
|
|
|
|
pid_t writePid = fork();
|
|
|
if(writePid == 0)
|
|
|
{
|
|
|
ExecuteWriteWiringInfo();
|
|
|
- LOG_INFO("Wirte Wiring Info OK");
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.CleanWiringInfo)
|
|
|
{
|
|
@@ -4699,7 +4704,7 @@ int CheckWiringInfoUpdate(void)
|
|
|
}
|
|
|
return NO;
|
|
|
}
|
|
|
- LOG_INFO("Clean Wirte Wiring Info Flag");
|
|
|
+ LOG_INFO("Clean Write Flahs Flag");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4756,7 +4761,7 @@ int isReservationExpired(unsigned char gun_index)
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-struct timeval _Reboot_time;
|
|
|
+struct timespec _Reboot_time;
|
|
|
|
|
|
void TriggerDispenserHardwareReboot(void)
|
|
|
{
|
|
@@ -4777,7 +4782,7 @@ void TriggerDispenserHardwareReboot(void)
|
|
|
|
|
|
if(trigger)
|
|
|
{
|
|
|
- gettimeofday(&_Reboot_time, NULL);
|
|
|
+ GetClockTime(&_Reboot_time);
|
|
|
LOG_INFO("********** Trigger Dispenser Hardware Reboot **********");
|
|
|
}
|
|
|
}
|
|
@@ -4807,7 +4812,7 @@ BOOL IsDispenserHardwareRebootResponsed(void)
|
|
|
return response_ok;
|
|
|
}
|
|
|
|
|
|
-struct timeval _Reset_time;
|
|
|
+struct timespec _Reset_time;
|
|
|
|
|
|
void TriggerDispenserSoftwareReset(void)
|
|
|
{
|
|
@@ -4828,7 +4833,7 @@ void TriggerDispenserSoftwareReset(void)
|
|
|
|
|
|
if(trigger)
|
|
|
{
|
|
|
- gettimeofday(&_Reset_time, NULL);
|
|
|
+ GetClockTime(&_Reset_time);
|
|
|
LOG_INFO("********** Trigger Dispenser Software Reset **********");
|
|
|
}
|
|
|
}
|
|
@@ -4994,7 +4999,7 @@ void RunningFinalCostHandler(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].TotalCost = TotalCost;
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].AccountBalance = AccountBalance;
|
|
|
|
|
|
- memset(&ShmOCPP16Data->Cost.RunningCost[i], 0x00, sizeof(struct StrcutRunningFinalCost));
|
|
|
+ memset(&ShmOCPP16Data->Cost.RunningCost[i], 0x00, sizeof(struct StrcutRunningCost));
|
|
|
}
|
|
|
|
|
|
if(strlen((char *)ShmOCPP16Data->Cost.FinalCost[i].description) > 0)
|
|
@@ -5021,13 +5026,13 @@ void RunningFinalCostHandler(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].TotalCost = TotalCost;
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].AccountBalance = AccountBalance;
|
|
|
|
|
|
- memset(&ShmOCPP16Data->Cost.FinalCost[i], 0x00, sizeof(struct StrcutRunningFinalCost));
|
|
|
+ memset(&ShmOCPP16Data->Cost.FinalCost[i], 0x00, sizeof(struct StrcutFinalCost));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct timeval _Cost_Price_time;
|
|
|
+struct timespec _Cost_Price_time;
|
|
|
char MyDefaultPriceString[128];
|
|
|
struct StrcutSetUserPrice MyUserPrice;
|
|
|
char MyConnectorRunningCostString[CONNECTOR_QUANTITY][128];
|
|
@@ -5038,7 +5043,7 @@ void CheckOcppCostAndPrice(void)
|
|
|
// 5s for reboot request timeout
|
|
|
if((GetTimeoutValue(_Cost_Price_time) / uSEC_VAL) >= OCPP_COST_REQ_INTERVAL)
|
|
|
{
|
|
|
- gettimeofday(&_Cost_Price_time, NULL);
|
|
|
+ GetClockTime(&_Cost_Price_time);
|
|
|
|
|
|
if(strcmp(MyDefaultPriceString, (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData) != EQUAL)
|
|
|
{
|
|
@@ -5987,14 +5992,10 @@ void CheckSmartChargeProfile(byte _index)
|
|
|
|
|
|
void TheEndCharging(byte gun_index)
|
|
|
{
|
|
|
- ftime(&endChargingTime[gun_index]);
|
|
|
- if (chargingInfo[gun_index]->PresentChargedDuration != 0)
|
|
|
- chargingInfo[gun_index]->PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index]);
|
|
|
-
|
|
|
chargingInfo[gun_index]->isRemoteStart = NO;
|
|
|
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- StartGunInfoTimeoutDet(gun_index, Timeout_EvseCompleteDet);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ //StartGunInfoTimeoutDet(gun_index, Timeout_EvseCompleteDet);
|
|
|
ChangeStartOrStopDateTime(NO, gun_index);
|
|
|
//DB_Insert_Record(localDb, gun_index);
|
|
|
}
|
|
@@ -6147,10 +6148,10 @@ void SetLedIndicationStatus(unsigned char connector, unsigned char indication)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct timeval _standardIndication_time;
|
|
|
+struct timespec _standardIndication_time;
|
|
|
unsigned char _standardLedStatus, _preStandardLedStatus;
|
|
|
unsigned char _e4youLedStatus[2], _preE4youLedStatus[2];
|
|
|
-struct timeval _e4youIndication_time[2];
|
|
|
+struct timespec _e4youIndication_time[2];
|
|
|
|
|
|
void LedIndicationProcess(void)
|
|
|
{
|
|
@@ -6176,7 +6177,7 @@ void LedIndicationProcess(void)
|
|
|
_preStandardLedStatus = _standardLedStatus;
|
|
|
|
|
|
// reset led status & indication time
|
|
|
- gettimeofday(&_standardIndication_time, NULL);
|
|
|
+ GetClockTime(&_standardIndication_time);
|
|
|
SetLedIndicationStatus(0, _LED_INDICATION_OFF);
|
|
|
}
|
|
|
|
|
@@ -6184,7 +6185,7 @@ void LedIndicationProcess(void)
|
|
|
{
|
|
|
SetLedIndicationStatus(0, _LED_INDICATION_GREEN_TOGGLE);
|
|
|
SetLedIndicationStatus(0, _LED_INDICATION_RED_TOGGLE);
|
|
|
- gettimeofday(&_standardIndication_time, NULL);
|
|
|
+ GetClockTime(&_standardIndication_time);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -6223,13 +6224,13 @@ void LedIndicationProcess(void)
|
|
|
_preE4youLedStatus[i] = _e4youLedStatus[i];
|
|
|
|
|
|
// reset led status & indication time
|
|
|
- gettimeofday(&_e4youIndication_time[i], NULL);
|
|
|
+ GetClockTime(&_e4youIndication_time[i]);
|
|
|
SetLedIndicationStatus(i, _LED_INDICATION_OFF);
|
|
|
}
|
|
|
|
|
|
if((GetTimeoutValue(_e4youIndication_time[i]) / mSEC_VAL) >= INDICATION_BLINK_INTERVAL)
|
|
|
{
|
|
|
- gettimeofday(&_e4youIndication_time[i], NULL);
|
|
|
+ GetClockTime(&_e4youIndication_time[i]);
|
|
|
SetLedIndicationStatus(i, _LED_INDICATION_GREEN_TOGGLE);
|
|
|
SetLedIndicationStatus(i, _LED_INDICATION_RED_TOGGLE);
|
|
|
}
|
|
@@ -6255,13 +6256,13 @@ void LedIndicationProcess(void)
|
|
|
_preE4youLedStatus[i] = _e4youLedStatus[i];
|
|
|
|
|
|
// reset led status & indication time
|
|
|
- gettimeofday(&_e4youIndication_time[i], NULL);
|
|
|
+ GetClockTime(&_e4youIndication_time[i]);
|
|
|
SetLedIndicationStatus(i, _LED_INDICATION_OFF);
|
|
|
}
|
|
|
|
|
|
if((GetTimeoutValue(_e4youIndication_time[i]) / mSEC_VAL) >= E4YOU_BLINK_INTERVAL)
|
|
|
{
|
|
|
- gettimeofday(&_e4youIndication_time[i], NULL);
|
|
|
+ GetClockTime(&_e4youIndication_time[i]);
|
|
|
SetLedIndicationStatus(i, _LED_INDICATION_GREEN_TOGGLE);
|
|
|
}
|
|
|
}
|
|
@@ -6491,7 +6492,7 @@ int main(void)
|
|
|
|
|
|
// Main loop
|
|
|
LOG_INFO("****************************Main Loop********************************** \n");
|
|
|
- gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdMainPriority_time);
|
|
|
for (;;)
|
|
|
{
|
|
|
CheckOcppStatus();
|
|
@@ -6525,7 +6526,7 @@ int main(void)
|
|
|
// 當 AC 沒有搭上時,清除一些錯誤碼
|
|
|
ClearAlarmCodeWhenAcOff();
|
|
|
|
|
|
- if ((GetTimeoutValue(_cmdMainPriority_time) / 1000) > 5000)
|
|
|
+ if ((GetTimeoutValue(_cmdMainPriority_time) / uSEC_VAL) > MAIN_PRIORITY_INTERVAL)
|
|
|
{
|
|
|
CheckTask();
|
|
|
for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++)
|
|
@@ -6534,7 +6535,7 @@ int main(void)
|
|
|
CheckSmartChargeProfile(_index);
|
|
|
}
|
|
|
|
|
|
- gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
+ GetClockTime(&_cmdMainPriority_time);
|
|
|
}
|
|
|
|
|
|
//LedIndicationProcess();
|
|
@@ -6579,7 +6580,6 @@ int main(void)
|
|
|
LOG_INFO("================== S_IDLE (%x) ================== \n", gun_index + 1);
|
|
|
chargingInfo[gun_index]->PresentChargedDuration = 0;
|
|
|
chargingInfo[gun_index]->RemainChargingDuration = 0;
|
|
|
- chargingTime[gun_index] = 0;
|
|
|
strcpy((char *)chargingInfo[gun_index]->StartDateTime, "");
|
|
|
strcpy((char *)chargingInfo[gun_index]->StopDateTime, "");
|
|
|
strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
|
|
@@ -6619,8 +6619,8 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.FaultStatusRequest = false;
|
|
|
memset(chargingInfo[gun_index]->ConnectorAlarmCode, 0x00, sizeof(chargingInfo[gun_index]->ConnectorAlarmCode));
|
|
|
|
|
|
- memset(&ShmOCPP16Data->Cost.RunningCost[gun_index], 0x00, sizeof(struct StrcutRunningFinalCost));
|
|
|
- memset(&ShmOCPP16Data->Cost.FinalCost[gun_index], 0x00, sizeof(struct StrcutRunningFinalCost));
|
|
|
+ memset(&ShmOCPP16Data->Cost.RunningCost[gun_index], 0x00, sizeof(struct StrcutRunningCost));
|
|
|
+ memset(&ShmOCPP16Data->Cost.FinalCost[gun_index], 0x00, sizeof(struct StrcutFinalCost));
|
|
|
chargingInfo[gun_index]->PresentChargedEnergy = 0;
|
|
|
chargingInfo[gun_index]->PresentChargingPower = 0;
|
|
|
|
|
@@ -6759,10 +6759,10 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
|
|
|
if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
- StopSystemTimeoutDet();
|
|
|
+ //StopSystemTimeoutDet();
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = false;
|
|
|
SetAcContactor(ON);
|
|
|
- gettimeofday(&_ConnectorAuthorizing_Time[gun_index], NULL);
|
|
|
+ GetClockTime(&_ConnectorAuthorizing_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
if(GetTimeoutValue(_ConnectorAuthorizing_Time[gun_index]) / uSEC_VAL >= FORCE_BALANCE_TIME)
|
|
@@ -6776,7 +6776,7 @@ int main(void)
|
|
|
{
|
|
|
// sync with dispenser
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.RemoteStartConfirm = false;
|
|
|
- gettimeofday(&_ConnectorAuthorizing_Time[gun_index], NULL);
|
|
|
+ GetClockTime(&_ConnectorAuthorizing_Time[gun_index]);
|
|
|
LOG_INFO("Sync with Connector %d through remote start", gun_index + 1);
|
|
|
FouceAnnounceAccountBalance(gun_index);
|
|
|
}
|
|
@@ -6788,7 +6788,7 @@ int main(void)
|
|
|
{
|
|
|
// sync with dispenser
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.SwipeRfidConfirm = false;
|
|
|
- gettimeofday(&_ConnectorAuthorizing_Time[gun_index], NULL);
|
|
|
+ GetClockTime(&_ConnectorAuthorizing_Time[gun_index]);
|
|
|
LOG_INFO("Sync with Connector %d through swipe rfid", gun_index + 1);
|
|
|
}
|
|
|
}
|
|
@@ -6835,7 +6835,7 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
|
|
|
if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
- StopSystemTimeoutDet();
|
|
|
+ //StopSystemTimeoutDet();
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = false;
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].MaxTotalChargingCurrent = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].MaxTotalChargingPower = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
|
|
@@ -6848,7 +6848,7 @@ int main(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].MaxOutputEnergy,
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].MaxOutputDuration);
|
|
|
SetAcContactor(ON);
|
|
|
- gettimeofday(&_SystemStatus_Time[gun_index], NULL);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
@@ -6876,8 +6876,8 @@ int main(void)
|
|
|
if (isModeChange(gun_index))
|
|
|
{
|
|
|
LOG_INFO("================== S_REASSIGN (%x) ================== \n", gun_index + 1);
|
|
|
- gettimeofday(&_toAverage_time, NULL);
|
|
|
- gettimeofday(&_SystemStatus_Time[gun_index], NULL);
|
|
|
+ //gettimeofday(&_toAverage_time, NULL);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
@@ -6898,10 +6898,10 @@ int main(void)
|
|
|
if (isModeChange(gun_index))
|
|
|
{
|
|
|
LOG_INFO("================== S_PREPARNING (%x) ================== \n", gun_index + 1);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- StartGunInfoTimeoutDet(gun_index, Timeout_Preparing);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ //StartGunInfoTimeoutDet(gun_index, Timeout_Preparing);
|
|
|
SetAcContactor(ON);
|
|
|
- gettimeofday(&_SystemStatus_Time[gun_index], NULL);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
@@ -6932,14 +6932,23 @@ int main(void)
|
|
|
}
|
|
|
ChargingTerminalProcess(gun_index);
|
|
|
}
|
|
|
- /*
|
|
|
- if(time >= GUN_PREPARE_TIMEOUT)
|
|
|
+
|
|
|
+ if(time > GUN_PREPARE_TIMEOUT)
|
|
|
{
|
|
|
LOG_INFO("********** Gun %d PrepareTimeout **********", gun_index + 1);
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuNoResource = YES;
|
|
|
- ChargingTerminalProcess(gun_index);
|
|
|
+
|
|
|
+ if(strncmp((char *)chargingInfo[gun_index]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ {
|
|
|
+ memcpy(chargingInfo[gun_index]->ConnectorAlarmCode, "012279", 6);
|
|
|
+ LOG_INFO("Gun %d No Psu Resource", gun_index + 1);
|
|
|
+ }
|
|
|
+ if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ }
|
|
|
+ ChargingAlarmProcess(gun_index);
|
|
|
}
|
|
|
- */
|
|
|
}
|
|
|
break;
|
|
|
case S_PREPARING_FOR_EV: // 等待車端的通訊 (EV 小板),待車端回報後,開始樁端的測試
|
|
@@ -6948,11 +6957,13 @@ int main(void)
|
|
|
{
|
|
|
LOG_INFO("================== S_PREPARING_FOR_EV (%x) ================== \n", gun_index + 1);
|
|
|
//strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- StartGunInfoTimeoutDet(gun_index, Timeout_EvChargingDet);
|
|
|
- gettimeofday(&_SystemStatus_Time[gun_index], NULL);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ //StartGunInfoTimeoutDet(gun_index, Timeout_EvChargingDet);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
+ time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
|
+
|
|
|
if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PermissionRequest)
|
|
|
{
|
|
|
setChargerMode(gun_index, MODE_PREPARE_FOR_EVSE);
|
|
@@ -6984,6 +6995,12 @@ int main(void)
|
|
|
}
|
|
|
ChargingTerminalProcess(gun_index);
|
|
|
}
|
|
|
+
|
|
|
+ if(time >= GUN_EV_WAIT_TIMEOUT)
|
|
|
+ {
|
|
|
+ LOG_INFO("********** Gun %d Wait Dispenser Timeout **********", gun_index + 1);
|
|
|
+ ChargingTerminalProcess(gun_index);
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case S_PREPARING_FOR_EVSE: // 等待 RB 通訊及測試,並將狀態回報, CSU 確認 Pass 後,開始進入充電
|
|
@@ -6991,11 +7008,13 @@ int main(void)
|
|
|
if (isModeChange(gun_index))
|
|
|
{
|
|
|
LOG_INFO("================== S_PREPARING_FOR_EVSE (%x) ================== \n", gun_index + 1);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- StartGunInfoTimeoutDet(gun_index, Timeout_EvseChargingDet);
|
|
|
- gettimeofday(&_SystemStatus_Time[gun_index], NULL);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ //StartGunInfoTimeoutDet(gun_index, Timeout_EvseChargingDet);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
+ time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
|
+
|
|
|
// only for test & debug purpose
|
|
|
if(ShmChargerInfo->Control.FCharging[gun_index].FCtrl.bits.EnableForceCharging)
|
|
|
{
|
|
@@ -7017,8 +7036,6 @@ int main(void)
|
|
|
// only for test & debug purpose
|
|
|
else if(ShmChargerInfo->Control.FCharging[gun_index].FCtrl.bits.EnableForceCharging)
|
|
|
{
|
|
|
- time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
|
-
|
|
|
if(time >= FORCE_CHARGING_WAIT_EVSE)
|
|
|
{
|
|
|
LOG_INFO("Gun %d [Charging Simulation] S_PREPARING_FOR_EVSE OK", gun_index + 1);
|
|
@@ -7046,6 +7063,12 @@ int main(void)
|
|
|
}
|
|
|
ChargingTerminalProcess(gun_index);
|
|
|
}
|
|
|
+
|
|
|
+ if(time >= GUN_EVSE_WAIT_TIMEOUT)
|
|
|
+ {
|
|
|
+ LOG_INFO("********** Gun %d GFD timeout **********", gun_index + 1);
|
|
|
+ ChargingTerminalProcess(gun_index);
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case S_CHARGING: // 剛進入充電狀態,等待 EV 小板要求的輸出電流後開始輸出
|
|
@@ -7053,8 +7076,9 @@ int main(void)
|
|
|
if (isModeChange(gun_index))
|
|
|
{
|
|
|
LOG_INFO("================== S_CHARGING (%x) ================== \n", gun_index + 1);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- ftime(&startChargingTime[gun_index]);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
+ chargingInfo[gun_index]->PresentChargedDuration = 0;
|
|
|
ChangeStartOrStopDateTime(YES, gun_index);
|
|
|
OcppStartTransation(gun_index);
|
|
|
}
|
|
@@ -7073,33 +7097,24 @@ int main(void)
|
|
|
chargingInfo[gun_index]->EvBatterytargetCurrent = current;
|
|
|
}
|
|
|
|
|
|
- ftime(&endChargingTime[gun_index]);
|
|
|
- chargingInfo[gun_index]->PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index]);
|
|
|
+ time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
|
|
|
|
// 計算 Power
|
|
|
//chargingInfo[gun_index]->PresentChargingPower = ((float)((chargingInfo[gun_index]->PresentChargingVoltage) * (chargingInfo[gun_index]->PresentChargingCurrent)) / 1000);
|
|
|
chargingInfo[gun_index]->PresentChargingPower = (((float)((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteChargingVoltage) * (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteChargingCurrent))) / 1000 / 100);
|
|
|
|
|
|
- if (chargingTime[gun_index] == 0 || chargingTime[gun_index] > chargingInfo[gun_index]->PresentChargedDuration)
|
|
|
+ if(time >= (chargingInfo[gun_index]->PresentChargedDuration + ENERAGY_INTERVAL))
|
|
|
{
|
|
|
- chargingTime[gun_index] = chargingInfo[gun_index]->PresentChargedDuration;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int passTime = chargingInfo[gun_index]->PresentChargedDuration - chargingTime[gun_index];
|
|
|
+ chargingInfo[gun_index]->PresentChargedDuration++;
|
|
|
|
|
|
- if(passTime > 0)
|
|
|
+ float changingPow = (chargingInfo[gun_index]->PresentChargingPower) / 3600;
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
|
|
|
{
|
|
|
- float changingPow = (chargingInfo[gun_index]->PresentChargingPower) * passTime / 3600;
|
|
|
- if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
|
|
|
- {
|
|
|
- chargingInfo[gun_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
|
|
|
- }
|
|
|
-
|
|
|
- chargingInfo[gun_index]->PresentChargedEnergy += changingPow;
|
|
|
- chargingInfo[gun_index]->PowerConsumption += changingPow;
|
|
|
- chargingTime[gun_index] = chargingInfo[gun_index]->PresentChargedDuration;
|
|
|
+ chargingInfo[gun_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
|
|
|
}
|
|
|
+
|
|
|
+ chargingInfo[gun_index]->PresentChargedEnergy += changingPow;
|
|
|
+ chargingInfo[gun_index]->PowerConsumption += changingPow;
|
|
|
}
|
|
|
|
|
|
if (isEvBoardStopChargeFlag(gun_index))
|
|
@@ -7164,12 +7179,15 @@ int main(void)
|
|
|
LOG_INFO("================== S_TERMINATING (%x) ================== \n", gun_index + 1);
|
|
|
}
|
|
|
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
+ time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
|
+
|
|
|
if (chargingInfo[gun_index]->SystemStatus == S_ALARM)
|
|
|
{
|
|
|
- if(GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 10000000)
|
|
|
+ if(time >= GUN_COMP_WAIT_TIMEOUT)
|
|
|
{
|
|
|
if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
|
|
|
{
|
|
@@ -7201,9 +7219,12 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
TheEndCharging(gun_index);
|
|
|
+ GetClockTime(&_SystemStatus_Time[gun_index]);
|
|
|
}
|
|
|
|
|
|
- if(GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 10000000)
|
|
|
+ time = GetTimeoutValue(_SystemStatus_Time[gun_index]) / uSEC_VAL;
|
|
|
+
|
|
|
+ if(time >= GUN_COMP_WAIT_TIMEOUT)
|
|
|
{
|
|
|
if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
|
|
|
{
|
|
@@ -7224,8 +7245,8 @@ int main(void)
|
|
|
if (isModeChange(gun_index))
|
|
|
{
|
|
|
LOG_INFO("CCS Precharge Processing 1....................%x \n", gun_index);
|
|
|
- StopGunInfoTimeoutDet(gun_index);
|
|
|
- StartGunInfoTimeoutDet(gun_index, Timeout_ForCcsPrechargeDet);
|
|
|
+ //StopGunInfoTimeoutDet(gun_index);
|
|
|
+ //StartGunInfoTimeoutDet(gun_index, Timeout_ForCcsPrechargeDet);
|
|
|
}
|
|
|
break;
|
|
|
|