|
@@ -19,21 +19,22 @@
|
|
|
//==========================
|
|
|
// Timeout constant define
|
|
|
//==========================
|
|
|
-#define TIMEOUT_SPEC_HANDSHAKING 180000
|
|
|
-#define TIMEOUT_SPEC_AUTH 15000
|
|
|
-#define TIMEOUT_SPEC_HANDSHAKING_LED 185000
|
|
|
-#define TIMEOUT_SPEC_LOGPPRINTOUT 30000
|
|
|
-#define TIMEOUT_SPEC_PROFILE_PREPARE 60000
|
|
|
-#define TIMEOUT_SPEC_BS_HLC_HANDSHAKE 60000
|
|
|
-#define TIMEOUT_SPEC_EV_READY 30000
|
|
|
-#define TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET 10000
|
|
|
-#define TIMEOUT_SPEC_CCS_HANDSHAKE 120000
|
|
|
-#define TIMEOUT_SPEC_PWN_CHANGE 5000
|
|
|
-#define TIMEOUT_SPEC_POWERSAVING_LCD 120000
|
|
|
-#define TIMEOUT_SPEC_POWERSAVING_RFID 120000
|
|
|
-#define TIMEOUT_SPEC_POWERSAVING_METER 120000
|
|
|
-#define TIMEOUT_SPEC_POWERSAVING_LED_STATUS 120000
|
|
|
-#define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION 15000
|
|
|
+#define TIMEOUT_SPEC_HANDSHAKING 180
|
|
|
+#define TIMEOUT_SPEC_AUTH 15
|
|
|
+#define TIMEOUT_SPEC_HANDSHAKING_LED 185
|
|
|
+#define TIMEOUT_SPEC_LOGPPRINTOUT 30
|
|
|
+#define TIMEOUT_SPEC_PROFILE_PREPARE 60
|
|
|
+#define TIMEOUT_SPEC_BS_HLC_HANDSHAKE 60
|
|
|
+#define TIMEOUT_SPEC_EV_READY 30
|
|
|
+#define TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET 10
|
|
|
+#define TIMEOUT_SPEC_CCS_HANDSHAKE 120
|
|
|
+#define TIMEOUT_SPEC_PWN_CHANGE 5
|
|
|
+#define TIMEOUT_SPEC_POWERSAVING_LCD 120
|
|
|
+#define TIMEOUT_SPEC_POWERSAVING_RFID 120
|
|
|
+#define TIMEOUT_SPEC_POWERSAVING_METER 120
|
|
|
+#define TIMEOUT_SPEC_POWERSAVING_LED_STATUS 120
|
|
|
+#define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION 15
|
|
|
+#define TIMEOUT_SPEC_RESET_WIFI_MODULE 180
|
|
|
|
|
|
//==========================
|
|
|
// GPIO constant define
|
|
@@ -90,9 +91,9 @@ struct OCPP16Data *ShmOCPP16Data;
|
|
|
struct OCPP20Data *ShmOCPP20Data;
|
|
|
struct Charger *ShmCharger;
|
|
|
|
|
|
-struct timeb startTime[AC_QUANTITY][TMR_IDX_CNT];
|
|
|
-struct timeb startChargingTime[AC_QUANTITY];
|
|
|
-struct timeb endChargingTime[AC_QUANTITY];
|
|
|
+struct timespec startTime[AC_QUANTITY][TMR_IDX_CNT];
|
|
|
+struct timespec startChargingTime[AC_QUANTITY];
|
|
|
+struct timespec endChargingTime[AC_QUANTITY];
|
|
|
sqlite3 *localDb;
|
|
|
|
|
|
struct SysConfigData SysConfigOrg;
|
|
@@ -197,6 +198,25 @@ int StoreLogMsg(const char *fmt, ...)
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
+void refreshStartTimer(struct timespec *timer)
|
|
|
+{
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, timer);
|
|
|
+}
|
|
|
+
|
|
|
+int getDiffSecNow(struct timespec timer)
|
|
|
+{
|
|
|
+ struct timespec timerNow;
|
|
|
+
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &timerNow);
|
|
|
+
|
|
|
+ return (int)((((unsigned long)(timerNow.tv_sec - timer.tv_sec) * 1000) + ((unsigned long)((timerNow.tv_nsec / 1000000) - (timer.tv_nsec / 1000000))))/1000);
|
|
|
+}
|
|
|
+
|
|
|
+int getDiffSecBetween(struct timespec start, struct timespec end)
|
|
|
+{
|
|
|
+ return (int)((((unsigned long)(end.tv_sec - start.tv_sec) * 1000) + ((unsigned long)((end.tv_nsec / 1000000) - (start.tv_nsec / 1000000))))/1000);
|
|
|
+}
|
|
|
+
|
|
|
long long DiffTimebWithNow(struct timeb ST)
|
|
|
{
|
|
|
//return milli-second
|
|
@@ -476,7 +496,7 @@ uint8_t ocpp_get_connection_status()
|
|
|
|
|
|
uint16_t ocpp_get_connection_timeout()
|
|
|
{
|
|
|
- uint16_t result = (TIMEOUT_SPEC_HANDSHAKING/1000);
|
|
|
+ uint16_t result = TIMEOUT_SPEC_HANDSHAKING;
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
|
|
|
{
|
|
@@ -2430,26 +2450,29 @@ void InitEthernet()
|
|
|
if(cnt_pingDNS_Fail >= 3)
|
|
|
{
|
|
|
ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet=ON;
|
|
|
- if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
|
|
|
+ if(!ShmSysConfigAndInfo->SysInfo.OcppConnStatus)
|
|
|
{
|
|
|
- system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
|
|
|
- sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
- system(tmpbuf);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
|
|
|
- memset(tmpbuf,0,256);
|
|
|
- sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
|
|
|
- system(tmpbuf);
|
|
|
- memset(tmpbuf,0,256);
|
|
|
- sprintf(tmpbuf,"route add default gw %s eth0 &",
|
|
|
- ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
|
|
|
- system(tmpbuf);
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient==0))
|
|
|
+ {
|
|
|
+ system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
|
|
|
+ sprintf(tmpbuf, "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &", ShmSysConfigAndInfo->SysConfig.SystemId);
|
|
|
+ system(tmpbuf);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
|
|
|
+ memset(tmpbuf,0,256);
|
|
|
+ sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
|
|
|
+ ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,
|
|
|
+ ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
|
|
|
+ system(tmpbuf);
|
|
|
+ memset(tmpbuf,0,256);
|
|
|
+ sprintf(tmpbuf,"route add default gw %s eth0 &",
|
|
|
+ ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
|
|
|
+ system(tmpbuf);
|
|
|
+ }
|
|
|
+ cnt_pingDNS_Fail = 0;
|
|
|
}
|
|
|
- cnt_pingDNS_Fail = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2557,6 +2580,60 @@ void InitEthernet()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Reset wifi function
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1))
|
|
|
+ {
|
|
|
+ if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
|
|
|
+ (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON) &&
|
|
|
+ (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
|
|
|
+ {
|
|
|
+ if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Wifi [Station] mode: Reset wifi power. \n");
|
|
|
+ DEBUG_INFO("The wifi interface may not be found. \n");
|
|
|
+
|
|
|
+ system("echo 1 > /sys/class/gpio/gpio59/value");
|
|
|
+ sleep(3);
|
|
|
+ system("echo 0 > /sys/class/gpio/gpio59/value");
|
|
|
+
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2))
|
|
|
+ {
|
|
|
+ if((ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))
|
|
|
+ {
|
|
|
+ if((getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE))
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Wifi [Access Point] mode: reset wifi power. \n");
|
|
|
+ DEBUG_INFO("The wifi interface may not be found. \n");
|
|
|
+
|
|
|
+ system("echo 1 > /sys/class/gpio/gpio59/value");
|
|
|
+ sleep(3);
|
|
|
+ system("echo 0 > /sys/class/gpio/gpio59/value");
|
|
|
+
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
|
|
|
+ }
|
|
|
+
|
|
|
sleep(5);
|
|
|
}
|
|
|
}
|
|
@@ -2882,7 +2959,7 @@ void get_firmware_version(unsigned char gun_index)
|
|
|
strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
|
|
|
|
|
|
// Get CSU root file system version
|
|
|
- sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.58.00.0000.00");
|
|
|
+ sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "B0.60.00.0000.00");
|
|
|
|
|
|
// Get AC connector type from model name
|
|
|
for(uint8_t idx=0;idx<3;idx++)
|
|
@@ -3952,13 +4029,6 @@ void checkTask()
|
|
|
DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
|
|
|
system ("/root/Module_PowerSharing &");
|
|
|
}
|
|
|
-
|
|
|
- if((system("pidof -s Module_InitUpgrade > /dev/null") != 0) &&
|
|
|
- ShmSysConfigAndInfo->SysConfig.isReqFirstUpgrade)
|
|
|
- {
|
|
|
- DEBUG_INFO("Module_InitUpgrade not running, restart it.\n");
|
|
|
- system ("/root/Module_InitUpgrade &");
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void checkConnectionTimeout()
|
|
@@ -3966,19 +4036,19 @@ void checkConnectionTimeout()
|
|
|
if((system("pidof -s OcppBackend > /dev/null") != 0) && (system("pidof -s OcppBackend20 > /dev/null") != 0))
|
|
|
{
|
|
|
ShmCharger->timeoutSpec.Present_Timeout_Spec = TIMEOUT_SPEC_HANDSHAKING;
|
|
|
- //DEBUG_INFO("Handshaking timeout specification follow by initial setting : %d s \n", TIMEOUT_SPEC_HANDSHAKING/1000);
|
|
|
+ //DEBUG_INFO("Handshaking timeout specification follow by initial setting : %d s \n", TIMEOUT_SPEC_HANDSHAKING);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ShmCharger->timeoutSpec.Setting_Timeout_Spec = ocpp_get_connection_timeout();
|
|
|
- if((ShmCharger->timeoutSpec.Setting_Timeout_Spec*1000) < TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
|
|
|
+ if((ShmCharger->timeoutSpec.Setting_Timeout_Spec) < TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
|
|
|
{
|
|
|
- ShmCharger->timeoutSpec.Present_Timeout_Spec = (TIMEOUT_SPEC_BS_HLC_HANDSHAKE+10000);
|
|
|
+ ShmCharger->timeoutSpec.Present_Timeout_Spec = (TIMEOUT_SPEC_BS_HLC_HANDSHAKE+10);
|
|
|
//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : Fail. Value can't be zero or less than zero.\n.");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ShmCharger->timeoutSpec.Present_Timeout_Spec = (ShmCharger->timeoutSpec.Setting_Timeout_Spec*1000);
|
|
|
+ ShmCharger->timeoutSpec.Present_Timeout_Spec = ShmCharger->timeoutSpec.Setting_Timeout_Spec;
|
|
|
//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : Pass...\n.");
|
|
|
}
|
|
|
//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : %s s \n.",ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
|
|
@@ -4161,7 +4231,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
(((strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidFrom)>0) && (strlen((char*)ShmOCPP16Data->SmartChargingProfile[gun_index].ValidTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
{
|
|
|
// Debug information
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
{
|
|
|
DEBUG_INFO("===============================================================\n");
|
|
|
DEBUG_INFO("Profile ID found: %d\n", ShmOCPP16Data->SmartChargingProfile[gun_index].ChargingProfileId);
|
|
@@ -4211,7 +4281,7 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
(((strlen((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].validFrom)>0) && (strlen((char*)ShmOCPP20Data->SmartChargingProfile[gun_index].validTo)>0)) ? isProfileValid(gun_index) : ON))
|
|
|
{
|
|
|
// Debug information
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT)
|
|
|
{
|
|
|
DEBUG_INFO("===============================================================\n");
|
|
|
DEBUG_INFO("Profile ID found: %d\n", ShmOCPP20Data->SmartChargingProfile[gun_index].id);
|
|
@@ -4314,12 +4384,12 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_BS)
|
|
|
{
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent <= 5)? 6:((ShmCharger->gun_info[gun_index].targetCurrent == 0)? 100:ShmCharger->gun_info[gun_index].targetCurrent));
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
}
|
|
|
}
|
|
|
else if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
|
|
@@ -4336,12 +4406,12 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_BS)
|
|
|
{
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_PWN_CHANGE]) > TIMEOUT_SPEC_PWN_CHANGE)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current = ((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent <= 5)? 6:((ShmCharger->gun_info[gun_index].targetCurrent == 0)? 100:ShmCharger->gun_info[gun_index].targetCurrent));
|
|
|
ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty = YES;
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
}
|
|
|
}
|
|
|
else if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
|
|
@@ -4562,6 +4632,34 @@ void checkRemoteUpgradeStatus()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void checkHandshakeCountdown(uint8_t gun_index)
|
|
|
+{
|
|
|
+ switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus)
|
|
|
+ {
|
|
|
+ case SYS_MODE_IDLE:
|
|
|
+
|
|
|
+ if(ShmCharger->gun_info[ShmCharger->gun_selectd].isHandshakeTimerRefresh == YES)
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_GUN_DETECT]);
|
|
|
+ else
|
|
|
+ ShmCharger->timeoutSpec.Handshake_Timeout = ((ocpp_get_connection_timeout()) - (getDiffSecNow(startTime[0][TMR_IDX_GUN_DETECT])));
|
|
|
+
|
|
|
+ if(!ShmCharger->isAuthrizing)
|
|
|
+ {
|
|
|
+ if(ocpp_get_isRemoteStartWait())
|
|
|
+ ShmCharger->timeoutSpec.Handshake_Timeout = ((ocpp_get_connection_timeout()) - (getDiffSecNow(startTime[0][TMR_IDX_GUN_DETECT])));
|
|
|
+ else
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_GUN_DETECT]);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case SYS_MODE_PREPARING:
|
|
|
+
|
|
|
+ ShmCharger->timeoutSpec.Handshake_Timeout = ((ocpp_get_connection_timeout()) - getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]));
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void checkRfidAuthrize()
|
|
|
{
|
|
|
static uint8_t isCheckdResult = FALSE;
|
|
@@ -4641,7 +4739,7 @@ void checkRfidAuthrize()
|
|
|
if(!isSnStart)
|
|
|
{
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.UserId, bufferRFID, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
- ftime(&startTime[0][TMR_IDX_AUTH]);
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_AUTH]);
|
|
|
ocpp_set_auth_conf(OFF);
|
|
|
ocpp_set_auth_req(ON, "ISO14443");
|
|
|
setLedMotion(0,LED_ACTION_AUTHED);
|
|
@@ -4654,7 +4752,7 @@ void checkRfidAuthrize()
|
|
|
else
|
|
|
{
|
|
|
// Wait authorize result
|
|
|
- if(!ocpp_get_auth_conf() && (DiffTimebWithNow(startTime[0][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH))
|
|
|
+ if(!ocpp_get_auth_conf() && (getDiffSecNow(startTime[0][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH))
|
|
|
{
|
|
|
// Authorization timeout process.
|
|
|
DEBUG_WARN("Authorize timeout !!!\n");
|
|
@@ -4673,7 +4771,7 @@ void checkRfidAuthrize()
|
|
|
{
|
|
|
if(ocpp_get_auth_conf() ||
|
|
|
(!ocpp_get_connection_status() && ((ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE) || (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_NOCHARGE))) ||
|
|
|
- (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST) && (DiffTimebWithNow(startTime[0][TMR_IDX_AUTH]) > 2000))
|
|
|
+ (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST) && (getDiffSecNow(startTime[0][TMR_IDX_AUTH]) > 2))
|
|
|
)
|
|
|
{
|
|
|
if(ocpp_get_auth_result(NO) ||
|
|
@@ -4684,7 +4782,7 @@ void checkRfidAuthrize()
|
|
|
{
|
|
|
DEBUG_INFO("Authorize pass.\n");
|
|
|
setSpeaker(ON, SPEAKER_SHORT);
|
|
|
- ftime(&startTime[0][TMR_IDX_GUN_DETECT]);
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_GUN_DETECT]);
|
|
|
ShmCharger->isGetAuthResult = TRUE;
|
|
|
isCheckdResult = TRUE;
|
|
|
|
|
@@ -4696,15 +4794,11 @@ void checkRfidAuthrize()
|
|
|
for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
ShmCharger->gun_info[gun_index].resultAuthorization = VALIDATED_RFID;
|
|
|
}
|
|
|
-
|
|
|
- // Handskake timer needs to refresh
|
|
|
- if(ShmCharger->gun_info[ShmCharger->gun_selectd].isHandshakeTimerRefresh == YES)
|
|
|
- ftime(&startTime[0][TMR_IDX_GUN_DETECT]);
|
|
|
|
|
|
- // Timer for lcm to shows
|
|
|
- ShmCharger->timeoutSpec.Handshake_Timeout = ((ocpp_get_connection_timeout()) - (DiffTimebWithNow(startTime[0][TMR_IDX_GUN_DETECT])/1000));
|
|
|
+ for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
+ checkHandshakeCountdown(gun_index);
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[0][TMR_IDX_GUN_DETECT]) < (ocpp_get_connection_timeout()*1000))
|
|
|
+ if(getDiffSecNow(startTime[0][TMR_IDX_GUN_DETECT]) < (ocpp_get_connection_timeout()))
|
|
|
{
|
|
|
if(GetCardSerialNumber() != FAIL)
|
|
|
{
|
|
@@ -4723,7 +4817,7 @@ void checkRfidAuthrize()
|
|
|
{
|
|
|
for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
|
|
|
{
|
|
|
- if(DiffTimebWithNow(startTime[0][TMR_IDX_GUN_DETECT]) < 3000)
|
|
|
+ if(getDiffSecNow(startTime[0][TMR_IDX_GUN_DETECT]) < 3)
|
|
|
setLedMotion(gun_index,LED_ACTION_RFID_PASS);
|
|
|
else
|
|
|
setLedMotion(gun_index,LED_ACTION_AUTHED);
|
|
@@ -4830,7 +4924,7 @@ int main(void)
|
|
|
//==============================================
|
|
|
// Period check for 10 seconds
|
|
|
//==============================================
|
|
|
- if((DiffTimebWithNow(startTime[0][TMR_IDX_CHECK_TASK]) > 10000) || (DiffTimebWithNow(startTime[0][TMR_IDX_CHECK_TASK]) < 0))
|
|
|
+ if((getDiffSecNow(startTime[0][TMR_IDX_CHECK_TASK]) > 10) || (getDiffSecNow(startTime[0][TMR_IDX_CHECK_TASK]) < 0))
|
|
|
{
|
|
|
//==============================================
|
|
|
// Check task processing
|
|
@@ -4843,7 +4937,7 @@ int main(void)
|
|
|
//==============================================
|
|
|
checkConnectionTimeout();
|
|
|
|
|
|
- ftime(&startTime[0][TMR_IDX_CHECK_TASK]);
|
|
|
+ refreshStartTimer(&startTime[0][TMR_IDX_CHECK_TASK]);
|
|
|
}
|
|
|
|
|
|
//==============================================
|
|
@@ -4933,7 +5027,7 @@ int main(void)
|
|
|
*/
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && (ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == OFF))
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
|
|
|
}
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_ALARM) ||
|
|
@@ -4941,13 +5035,13 @@ int main(void)
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_UPDATE) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_MAINTAIN) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_CHARGING) ||
|
|
|
- (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING) ||
|
|
|
+ (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_TERMINATING) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_COMPLETE))
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -4956,37 +5050,37 @@ int main(void)
|
|
|
(ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON) ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus != ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus) ||
|
|
|
(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_RESERVATION)) &&
|
|
|
- ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) || (ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)) &&
|
|
|
- (DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]) < 10000)))
|
|
|
+ ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) || (ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn == ON)) &&
|
|
|
+ (getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]) < 10)))
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
|
|
|
if(((gpio_get_value(GPIO_IN_WAKEUP) == OFF) || (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON)) &&
|
|
|
(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) &&
|
|
|
- (DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_CHECK_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
+ (getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_CHECK_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].isCheckPowerConsumption = YES;
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_CHECK_POWER_CONSUMPTION]);
|
|
|
- if((DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_LCM_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_CHECK_POWER_CONSUMPTION]);
|
|
|
+ if((getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_LCM_POWER_CONSUMPTION]) > TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION))
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].isCheckPowerConsumption = NO;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LCD]) > TIMEOUT_SPEC_POWERSAVING_LCD)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LCD]) > TIMEOUT_SPEC_POWERSAVING_LCD)
|
|
|
{
|
|
|
if(ShmCharger->isLcdOn == ON)
|
|
|
{
|
|
|
- DEBUG_INFO("LCD into power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LCD]));
|
|
|
+ DEBUG_INFO("LCD into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LCD]));
|
|
|
ShmCharger->isLcdOn = OFF;
|
|
|
}
|
|
|
}
|
|
@@ -4994,16 +5088,16 @@ int main(void)
|
|
|
{
|
|
|
if(ShmCharger->isLcdOn == OFF)
|
|
|
{
|
|
|
- DEBUG_INFO("LCD exit power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LCD]));
|
|
|
+ DEBUG_INFO("LCD exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LCD]));
|
|
|
ShmCharger->isLcdOn = ON;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]) > TIMEOUT_SPEC_POWERSAVING_RFID)
|
|
|
+ if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]) > TIMEOUT_SPEC_POWERSAVING_RFID)
|
|
|
{
|
|
|
if(gpio_get_value(GPIO_OUT_RST_RFID) == ON)
|
|
|
{
|
|
|
- DEBUG_INFO("RFID into power saving...%d\n", DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
+ DEBUG_INFO("RFID into power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
gpio_set_value(GPIO_OUT_RST_RFID, OFF);
|
|
|
}
|
|
|
}
|
|
@@ -5011,16 +5105,16 @@ int main(void)
|
|
|
{
|
|
|
if(gpio_get_value(GPIO_OUT_RST_RFID) == OFF)
|
|
|
{
|
|
|
- DEBUG_INFO("RFID exit power saving...%d\n", DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
+ DEBUG_INFO("RFID exit power saving...%d\n", getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_POWERSAVING_RFID]));
|
|
|
gpio_set_value(GPIO_OUT_RST_RFID, ON);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]) > TIMEOUT_SPEC_POWERSAVING_METER)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]) > TIMEOUT_SPEC_POWERSAVING_METER)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].isMeterOn)
|
|
|
{
|
|
|
- DEBUG_INFO("Meter into power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
+ DEBUG_INFO("Meter into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
ShmCharger->gun_info[gun_index].isMeterOn = OFF;
|
|
|
}
|
|
|
}
|
|
@@ -5028,16 +5122,16 @@ int main(void)
|
|
|
{
|
|
|
if(!ShmCharger->gun_info[gun_index].isMeterOn)
|
|
|
{
|
|
|
- DEBUG_INFO("Meter exit power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
+ DEBUG_INFO("Meter exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_METER]));
|
|
|
ShmCharger->gun_info[gun_index].isMeterOn = ON;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]) > TIMEOUT_SPEC_POWERSAVING_LED_STATUS)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]) > TIMEOUT_SPEC_POWERSAVING_LED_STATUS)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].isSleepOn == NO)
|
|
|
{
|
|
|
- DEBUG_INFO("LED status into power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
+ DEBUG_INFO("LED status into power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
ShmCharger->gun_info[gun_index].isSleepOn = YES;
|
|
|
}
|
|
|
}
|
|
@@ -5045,7 +5139,7 @@ int main(void)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].isSleepOn == YES)
|
|
|
{
|
|
|
- DEBUG_INFO("LED status exit power saving...%d\n", DiffTimebWithNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
+ DEBUG_INFO("LED status exit power saving...%d\n", getDiffSecNow(startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]));
|
|
|
ShmCharger->gun_info[gun_index].isSleepOn = NO;
|
|
|
}
|
|
|
}
|
|
@@ -5090,7 +5184,7 @@ int main(void)
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[0].SystemStatus != SYS_MODE_BOOTING)
|
|
|
{
|
|
|
// Alarm event check
|
|
|
- if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0) || ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail)
|
|
|
+ if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode>0) || (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode) || ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail)
|
|
|
{
|
|
|
if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus != SYS_MODE_ALARM)
|
|
|
{
|
|
@@ -5149,12 +5243,12 @@ int main(void)
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = ON;
|
|
|
}
|
|
|
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_RFID]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_METER]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_STATE_B]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LED_STATUS]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_LCM_POWER_CONSUMPTION]);
|
|
|
}
|
|
|
|
|
|
if(ShmCharger->gun_info[gun_index].mcuFlag.isReadFwVerPass &&
|
|
@@ -5279,23 +5373,21 @@ int main(void)
|
|
|
if(ShmCharger->isCcsEnable)system("pkill Module_CCS");
|
|
|
DB_Check_Record_Buf(localDb, gun_index);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ checkHandshakeCountdown(gun_index);
|
|
|
+
|
|
|
// LED status in Idle mode
|
|
|
if(!ShmCharger->isAuthrizing)
|
|
|
{
|
|
|
if(ocpp_get_isRemoteStartWait())
|
|
|
{
|
|
|
- ShmCharger->timeoutSpec.Handshake_Timeout = ((ocpp_get_connection_timeout()) - (DiffTimebWithNow(startTime[0][TMR_IDX_GUN_DETECT])/1000));
|
|
|
-
|
|
|
ShmCharger->gun_info[gun_index].isSleepOn = OFF;
|
|
|
setLedMotion(gun_index, LED_ACTION_AUTHED);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
- DEBUG_INFO("Remote Start Transaction without connector Id.\n");
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
|
|
|
+ //DEBUG_INFO("Remote Start Transaction without connector Id.\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ftime(&startTime[0][TMR_IDX_GUN_DETECT]);
|
|
|
-
|
|
|
if(ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON)
|
|
|
{
|
|
|
if(ShmCharger->gun_info[gun_index].rfidReq == OFF)
|
|
@@ -5377,7 +5469,7 @@ int main(void)
|
|
|
case SYS_MODE_AUTHORIZING:
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_AUTH]);
|
|
|
if(ocpp_isAuthorizeRemoteStart() && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == START_METHOD_BACKEND))
|
|
|
{
|
|
|
DEBUG_INFO("Remote start request authorize.\n");
|
|
@@ -5385,7 +5477,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_AUTH]) > TIMEOUT_SPEC_AUTH)
|
|
|
{
|
|
|
// Authorization timeout process.
|
|
|
setSpeaker(ON,SPEAKER_INTERVAL_3COUNT);
|
|
@@ -5473,7 +5565,7 @@ int main(void)
|
|
|
case SYS_MODE_PREPARING:
|
|
|
if(isModeChange(gun_index))
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
setLedMotion(gun_index,LED_ACTION_AUTHED);
|
|
|
ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
|
|
|
|
|
@@ -5502,7 +5594,7 @@ int main(void)
|
|
|
{
|
|
|
setRequest(gun_index, ON);
|
|
|
setLedMotion(gun_index,LED_ACTION_CONNECTED);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
DEBUG_INFO("Set Request On.\n");
|
|
|
|
|
|
//Let CCS task start to negotiate
|
|
@@ -5523,17 +5615,17 @@ int main(void)
|
|
|
if((ShmCharger->gun_info[gun_index].mcuFlag.isSetCpPwmDuty == OFF))
|
|
|
{
|
|
|
//2 secs timeout
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
|
|
|
ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_CCS;
|
|
|
}
|
|
|
break;
|
|
|
case HANDSHAKE_CCS:
|
|
|
//CCS handshake timeout
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission = OFF;
|
|
|
ShmCharger->gun_info[gun_index].acCcsInfo.EVSENotification = NOTIFICATION_STOP;
|
|
|
- DEBUG_INFO("BS/HLC %d secs handshake timeout.\n", (TIMEOUT_SPEC_BS_HLC_HANDSHAKE/1000));
|
|
|
+ DEBUG_INFO("BS/HLC %d secs handshake timeout.\n", TIMEOUT_SPEC_BS_HLC_HANDSHAKE);
|
|
|
}
|
|
|
|
|
|
if((ShmCharger->gun_info[gun_index].acCcsInfo.ChargingPermission == OFF) && (ShmCharger->gun_info[gun_index].acCcsInfo.CpSetPWMDuty != CCS_PWM_DUTY_5))
|
|
@@ -5551,7 +5643,7 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].chargingMode = CHARGING_MODE_HLC;
|
|
|
DEBUG_INFO("Enter HLC Mode charging.\n");
|
|
|
ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_HLC_MODE;
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -5574,7 +5666,7 @@ int main(void)
|
|
|
checkChargingProfileLimit(gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus);
|
|
|
|
|
|
ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_SET_MAX_CURRENT;
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
|
|
|
}
|
|
|
break;
|
|
|
case HANDSHAKE_SET_MAX_CURRENT:
|
|
@@ -5583,15 +5675,15 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].ccsHandshakeState = HANDSHAKE_BS_MODE;
|
|
|
DEBUG_INFO("Enter BS Mode charging.\n");
|
|
|
//for EV READY 30 secs didn't start charging to STATE E
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
}
|
|
|
break;
|
|
|
case HANDSHAKE_BS_MODE:
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
|
|
|
checkChargingProfileLimit(gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus);
|
|
|
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C) && ((ShmCharger->gun_info[gun_index].targetCurrent != 0)))
|
|
|
- {
|
|
|
+ {
|
|
|
setRelay(gun_index,ON);
|
|
|
}
|
|
|
|
|
@@ -5616,7 +5708,7 @@ int main(void)
|
|
|
memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
ocpp_copy_userid_to_starttransaction(gun_index);
|
|
|
ocpp_set_starttransaction_req(gun_index, ON);
|
|
|
- ftime(&startChargingTime[gun_index]);
|
|
|
+ refreshStartTimer(&startChargingTime[gun_index]);
|
|
|
|
|
|
setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
}
|
|
@@ -5719,16 +5811,16 @@ int main(void)
|
|
|
ocpp_set_starttransaction_req(gun_index, ON);
|
|
|
ShmCharger->gun_info[gun_index].isCCSStartTransation = OFF;
|
|
|
setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
- ftime(&startChargingTime[gun_index]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]);
|
|
|
+ refreshStartTimer(&startChargingTime[gun_index]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]);
|
|
|
}
|
|
|
|
|
|
//120 sec timeout
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE)
|
|
|
{
|
|
|
setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE+5000)
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE+5)
|
|
|
{
|
|
|
DEBUG_INFO("CCS 120 secs handshake timeout, change to BS Mode...\n");
|
|
|
//Cancel CCS task negotiating
|
|
@@ -5762,7 +5854,7 @@ int main(void)
|
|
|
memcpy((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
|
|
|
ocpp_copy_userid_to_starttransaction(gun_index);
|
|
|
ocpp_set_starttransaction_req(gun_index, ON);
|
|
|
- ftime(&startChargingTime[gun_index]);
|
|
|
+ refreshStartTimer(&startChargingTime[gun_index]);
|
|
|
setChargerMode(gun_index, SYS_MODE_CHARGING);
|
|
|
}
|
|
|
|
|
@@ -5789,14 +5881,13 @@ int main(void)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
}
|
|
|
-
|
|
|
- ShmCharger->timeoutSpec.Handshake_Timeout = ((ocpp_get_connection_timeout()) - (DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING])/1000));
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
|
|
|
+ checkHandshakeCountdown(gun_index);
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
|
|
|
{
|
|
|
setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
|
|
|
|
|
|
- if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5000))
|
|
|
+ if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5))
|
|
|
{
|
|
|
DEBUG_INFO("Handshaking timeout...\n");
|
|
|
|
|
@@ -5822,9 +5913,9 @@ int main(void)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].rfidReq = OFF;
|
|
|
//ftime(&startChargingTime[gun_index]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_PWN_CHANGE]);
|
|
|
ocpp_set_auth_req(OFF);
|
|
|
ocpp_reset_smartcharging_profileId(gun_index);
|
|
|
ocpp_set_profile_req(gun_index, ON);
|
|
@@ -5834,9 +5925,9 @@ int main(void)
|
|
|
|
|
|
//if time up, clear CCS MSG count
|
|
|
if((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC) &&
|
|
|
- (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]) > TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET))
|
|
|
+ (getDiffSecNow(startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]) > TIMEOUT_SPEC_CCS_HEARTBEAT_COUNT_RESET))
|
|
|
{
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]);
|
|
|
if(ShmCharger->gun_info[gun_index].acCcsInfo.CcsHeartBeat > 0)
|
|
|
{
|
|
|
ShmCharger->gun_info[gun_index].acCcsInfo.CcsHeartBeat = 0;
|
|
@@ -5878,20 +5969,20 @@ int main(void)
|
|
|
//ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PowerConsumption[2] = (ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/10000.0);
|
|
|
}
|
|
|
|
|
|
- ftime(&endChargingTime[gun_index]);
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
+ refreshStartTimer(&endChargingTime[gun_index]);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = getDiffSecBetween(startChargingTime[gun_index], endChargingTime[gun_index]);
|
|
|
presentChargedEnergyUpdate(gun_index);
|
|
|
|
|
|
// Response StartTransactionConf
|
|
|
ocpp_set_starttransaction_conf(gun_index, OFF);
|
|
|
|
|
|
// Charging profile preparation
|
|
|
- if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) > TIMEOUT_SPEC_PROFILE_PREPARE) || (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) < 0))
|
|
|
+ if((getDiffSecNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) > TIMEOUT_SPEC_PROFILE_PREPARE) || (getDiffSecNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) < 0))
|
|
|
{
|
|
|
if(!ocpp_get_profile_conf(gun_index))
|
|
|
{
|
|
|
ocpp_set_profile_req(gun_index, ON);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -6026,14 +6117,14 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
// Debug information
|
|
|
- if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT) || (DiffTimebWithNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) < 0))
|
|
|
+ if((getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT) || (getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) < 0))
|
|
|
{
|
|
|
DEBUG_INFO("==============================================================\n");
|
|
|
DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent: %d \n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
|
|
|
DEBUG_INFO("ShmCharger->gun_info[%d].primaryMcuCp_Pwn_Duty.max_current: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
|
|
|
DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent: %d\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
DEBUG_INFO("==============================================================\n");
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
|
|
|
|
|
|
getDateTimeString((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime);
|
|
|
DB_Update_Record_Buf(localDb, gun_index);
|
|
@@ -6055,10 +6146,10 @@ int main(void)
|
|
|
ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
|
|
|
}
|
|
|
|
|
|
- ftime(&endChargingTime[gun_index]);
|
|
|
+ refreshStartTimer(&endChargingTime[gun_index]);
|
|
|
//if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration != 0)
|
|
|
//{
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index])/1000;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration = getDiffSecBetween(startChargingTime[gun_index], endChargingTime[gun_index]);
|
|
|
//}
|
|
|
|
|
|
// End authorize pass
|
|
@@ -6109,12 +6200,12 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
// Charging profile preparation
|
|
|
- if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) > TIMEOUT_SPEC_PROFILE_PREPARE) || (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) < 0))
|
|
|
+ if((getDiffSecNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) > TIMEOUT_SPEC_PROFILE_PREPARE) || (getDiffSecNow(startTime[gun_index][TMR_IDX_PROFILE_PREPARE]) < 0))
|
|
|
{
|
|
|
if(!ocpp_get_profile_conf(gun_index))
|
|
|
{
|
|
|
ocpp_set_profile_req(gun_index, ON);
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_PROFILE_PREPARE]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -6128,14 +6219,14 @@ int main(void)
|
|
|
setRelay(gun_index, OFF);
|
|
|
|
|
|
// Debug information
|
|
|
- if((DiffTimebWithNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT) || (DiffTimebWithNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) < 0))
|
|
|
+ if((getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) > TIMEOUT_SPEC_LOGPPRINTOUT) || (getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]) < 0))
|
|
|
{
|
|
|
DEBUG_INFO("=============================================================\n");
|
|
|
DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent: %d\n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
|
|
|
DEBUG_INFO("ShmCharger->gun_info[%d].primaryMcuCp_Pwn_Duty.max_current: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuCp_Pwn_Duty.max_current);
|
|
|
DEBUG_INFO("ShmCharger->gun_info[%d].targetCurrent: %d\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
|
|
|
DEBUG_INFO("=============================================================\n");
|
|
|
- ftime(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
|
|
|
+ refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_CHARGING_INFO]);
|
|
|
}
|
|
|
|
|
|
if(!ocpp_get_auth_result(YES, gun_index))
|