|
@@ -1167,36 +1167,31 @@ void CheckSystemValue(void)
|
|
|
// send Heartbeat
|
|
|
//===============================
|
|
|
//HeartBeatWaitTime = ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval;
|
|
|
- if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= HeartBeatWaitTime))
|
|
|
+ if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
|
|
|
{
|
|
|
- DEBUG_INFO("Heartbeat !!!\n");
|
|
|
- //parameter for test
|
|
|
- sendHeartbeatRequest(0);
|
|
|
- //==============================================
|
|
|
- // Reset Waiting Time
|
|
|
- //==============================================
|
|
|
clientTime.Heartbeat=time((time_t*)NULL);
|
|
|
- HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
|
|
|
+
|
|
|
+ if(server_sign == TRUE)
|
|
|
+ {
|
|
|
+ HeartBeatWaitTime = ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ HeartBeatWaitTime = 10;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
- else if((server_sign == TRUE) &&(FirstHeartBeat == 0)) // Send First HeartBeat
|
|
|
+
|
|
|
+ if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= HeartBeatWaitTime))
|
|
|
{
|
|
|
- DEBUG_INFO("FirstHeartBeat !!!\n");
|
|
|
+ DEBUG_INFO("Heartbeat !!!\n");
|
|
|
//parameter for test
|
|
|
sendHeartbeatRequest(0);
|
|
|
- //==============================================
|
|
|
- // Reset Waiting Time
|
|
|
+ //==============================================
|
|
|
+ // Reset Waiting Time
|
|
|
//==============================================
|
|
|
clientTime.Heartbeat=time((time_t*)NULL);
|
|
|
HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
|
|
|
- if(HeartBeatWaitTime <= 0)
|
|
|
- {
|
|
|
- HeartBeatWaitTime = 10;
|
|
|
- }
|
|
|
-
|
|
|
- DEBUG_INFO("difftime(time((time_t*)NULL), clientTime.Heartbeat)=%d !!!\n",difftime(time((time_t*)NULL), clientTime.Heartbeat));
|
|
|
- DEBUG_INFO("HeartBeatWaitTime=%d !!!\n",HeartBeatWaitTime);
|
|
|
- DEBUG_INFO("ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval=%d !!!\n",ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1242,7 +1237,7 @@ void CheckSystemValue(void)
|
|
|
//===============================
|
|
|
// CSU Trigger Smart Charging Profilw
|
|
|
//===============================
|
|
|
- if((server_sign == TRUE) && (ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq == 1))
|
|
|
+ if(ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq == 1)
|
|
|
{
|
|
|
ShmOCPP16Data->CSUMsg.bits[gun_index].ChargingProfileReq = 0;
|
|
|
GetChargingProfileRequest(gun_index);
|
|
@@ -1291,7 +1286,7 @@ void CheckSystemValue(void)
|
|
|
statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
- #if 0 // for TempStopTransaction
|
|
|
+ #if 1 // for TempStopTransaction
|
|
|
if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
|
|
|
{
|
|
|
checkTempStopTransaction(gun_index);
|
|
@@ -1316,7 +1311,7 @@ void CheckSystemValue(void)
|
|
|
statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
- #if 0 // for TempStopTransaction
|
|
|
+ #if 1 // for TempStopTransaction
|
|
|
if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
|
|
|
{
|
|
|
checkTempStopTransaction(gun_index);
|
|
@@ -1341,7 +1336,7 @@ void CheckSystemValue(void)
|
|
|
statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
- #if 0 // for TempStopTransaction
|
|
|
+ #if 1 // for TempStopTransaction
|
|
|
if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
|
|
|
{
|
|
|
checkTempStopTransaction(gun_index);
|
|
@@ -1367,7 +1362,7 @@ void CheckSystemValue(void)
|
|
|
statusModeChage[gun_index] = TRUE;
|
|
|
}
|
|
|
|
|
|
- #if 0 // for TempStopTransaction
|
|
|
+ #if 1 // for TempStopTransaction
|
|
|
if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
|
|
|
{
|
|
|
checkTempStopTransaction(gun_index);
|
|
@@ -1391,6 +1386,7 @@ void CheckSystemValue(void)
|
|
|
clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
|
|
|
statusModeChage[gun_index] = FALSE;
|
|
|
|
|
|
+ DEBUG_INFO("SystemInitial=%d !!!\n",SystemInitial);
|
|
|
DEBUG_INFO("difftime(time((time_t*)NULL), clientTime.Heartbeat)=%d !!!\n",difftime(time((time_t*)NULL), clientTime.Heartbeat));
|
|
|
DEBUG_INFO("HeartBeatWaitTime=%d !!!\n",HeartBeatWaitTime);
|
|
|
DEBUG_INFO("ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval=%d !!!\n",ShmOCPP16Data->BootNotification.ResponseHeartbeatInterval);
|
|
@@ -1501,7 +1497,7 @@ void CheckSystemValue(void)
|
|
|
if(meterValueSend[gun_index] == 1)
|
|
|
{
|
|
|
sendMeterValuesRequest(gun_index);
|
|
|
-#if 0 // for TempStopTransaction
|
|
|
+#if 1 // for TempStopTransaction
|
|
|
storeTempStopTransaction(gun_index);
|
|
|
#endif
|
|
|
}
|
|
@@ -2141,7 +2137,7 @@ int sendStatusNotificationRequest(int gun_index)
|
|
|
// it's option
|
|
|
strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].Info, "");
|
|
|
|
|
|
- /*
|
|
|
+/*
|
|
|
enum _SYSTEM_STATUS
|
|
|
{
|
|
|
S_BOOTING = 0,
|
|
@@ -2159,7 +2155,7 @@ S_ALARM, =11
|
|
|
S_FAULT =12
|
|
|
}
|
|
|
|
|
|
- */
|
|
|
+*/
|
|
|
|
|
|
//check Transaction active
|
|
|
//J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
|
|
@@ -15865,21 +15861,6 @@ void SetOcppConnStatus(uint8_t status)
|
|
|
{
|
|
|
ShmOCPP16Data->OcppConnStatus = status;
|
|
|
ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
|
|
|
-
|
|
|
-#if 0
|
|
|
- if(status == FALSE)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
|
|
|
- {
|
|
|
- SystemInitial = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SystemInitial = AC_QUANTITY;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
int GetHeartBeatWithNOResponse(void)
|
|
@@ -18458,12 +18439,21 @@ void checkTempStopTransaction(int gun_index)
|
|
|
{
|
|
|
FILE *fptr1;
|
|
|
char ch;
|
|
|
- char str[100]={0};
|
|
|
+ char str[1200]={0};
|
|
|
char guid[37]={0};
|
|
|
char tempdata[65]={0};
|
|
|
|
|
|
+ //=====================================================
|
|
|
+ // Check InternetConn 0: disconnected, 1: connected
|
|
|
+ //====================================================
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("\n offline now !!!\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
|
|
|
+ fptr1 = fopen("/Storage/OCPP/TempStopTransaction", "r");
|
|
|
if (!fptr1)
|
|
|
{
|
|
|
//printf(" File not found or unable to open the input file!!\n");
|
|
@@ -18494,15 +18484,13 @@ void checkTempStopTransaction(int gun_index)
|
|
|
}
|
|
|
queue_operation(4, guid, str );//addq(guid, queuedata); ---> remove temporally
|
|
|
|
|
|
- if(GetTransactionQueueNum() == 1)
|
|
|
- {
|
|
|
- LWS_Send(str);
|
|
|
- }
|
|
|
+ memset(str,0,sizeof str);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
|
|
|
+ // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
|
|
|
fclose(fptr1);
|
|
|
remove("/Storage/OCPP/TempStopTransaction"); // remove the original file
|
|
|
}
|
|
@@ -18555,11 +18543,13 @@ void InitialSystemValue(void)
|
|
|
GunStatusInterval = 10;
|
|
|
TransactionMessageAttemptsValue = 0;
|
|
|
TransactionMessageRetryIntervalValue = 0;
|
|
|
+
|
|
|
+ //Hear Beat
|
|
|
HeartBeatWithNOResponse = 0;
|
|
|
HeartBeatCountPerHour = 0;
|
|
|
-
|
|
|
HeartBeatWaitTime = 10;
|
|
|
FirstHeartBeat = 0;
|
|
|
+
|
|
|
FirmwareStatusNotificationStatus = 3; // Idle
|
|
|
DiagnosticsStatusNotificationStatus = 0; // Idle
|
|
|
|
|
@@ -18575,9 +18565,7 @@ void InitialSystemValue(void)
|
|
|
memset(AcPreviousConnectorPlugIn, 0, sizeof(AcPreviousConnectorPlugIn));
|
|
|
memset(gunType, 0, sizeof(gunType));
|
|
|
|
|
|
- //gunTotalNumber = (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY;
|
|
|
-
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
|
|
|
{
|
|
|
//check connector / socket type (index: 8, 9, 10)
|
|
|
for(int index=7; index <10 ; index++)
|
|
@@ -18606,8 +18594,6 @@ void InitialSystemValue(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //SystemInitial = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
|
|
|
- //gunTotalNumber =
|
|
|
//DEBUG_INFO("DC ...\n");
|
|
|
}
|
|
|
else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
|
|
@@ -18629,12 +18615,11 @@ void InitialSystemValue(void)
|
|
|
|
|
|
DEBUG_INFO("gunTotalNumber: %d\n", gunTotalNumber);
|
|
|
DEBUG_INFO("connectorIndex: %d\n", connectorIndex);
|
|
|
- //SystemInitial = AC_QUANTITY;
|
|
|
- //gunTotalNumber =
|
|
|
+ DEBUG_INFO("SystemInitial: %d\n", SystemInitial);
|
|
|
//DEBUG_INFO("AC ...\n");
|
|
|
}
|
|
|
|
|
|
- //Status / ConnectorPlugIn Setting
|
|
|
+ //Status && ConnectorPlugIn Setting
|
|
|
for (int index = 0; index < CHAdeMO_QUANTITY; index++)
|
|
|
{
|
|
|
ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
|