|
@@ -64,7 +64,7 @@
|
|
|
|
|
|
#define uSEC_VAL 1000000
|
|
|
#define SELFTEST_TIMEOUT 45
|
|
|
-#define AUTHORIZE_TIMEOUT 30
|
|
|
+#define AUTHORIZE_TIMEOUT 15
|
|
|
#define AUTHORIZE_COMP_TIMEOUT 3
|
|
|
#define AUTHORIZE_FAIL_TIMEOUT 3
|
|
|
#define AUTHORIZE_STOP_TIMEOUT 30
|
|
@@ -112,6 +112,8 @@ int DB_Open(sqlite3 *db);
|
|
|
int DB_Insert_Record(sqlite3 *db, int gun_index);
|
|
|
int DB_Update_Operactive(sqlite3 *db, uint8_t gun_index, uint8_t IsAvailable);
|
|
|
int DB_Get_Operactive(sqlite3 *db, uint8_t gun_index);
|
|
|
+void InitialDHCP();
|
|
|
+int GetStartScheduleTime(unsigned char *time);
|
|
|
|
|
|
#define DEBUG_INFO_MSG(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
#define DEBUG_WARN_MSG(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
@@ -151,7 +153,7 @@ bool isModelNameMatch = true;
|
|
|
|
|
|
int rfidFd = -1;
|
|
|
char* rfidPortName = "/dev/ttyS2";
|
|
|
-char* fwVersion = "V0.16.00.0000.00";
|
|
|
+char* fwVersion = "V0.18.00.0000.00";
|
|
|
|
|
|
sqlite3 *localDb;
|
|
|
bool isDb_ready;
|
|
@@ -365,12 +367,12 @@ long long DiffTimebWithNow(struct timeb ST)
|
|
|
{
|
|
|
//return milli-second
|
|
|
struct timeb ET;
|
|
|
- long long StartTime,StopTime;
|
|
|
+ long long StartTime, StopTime;
|
|
|
|
|
|
ftime(&ET);
|
|
|
- StartTime=(long long)ST.time;
|
|
|
- StopTime=(long long)ET.time;
|
|
|
- return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
|
|
|
+ StartTime = (long long)ST.time;
|
|
|
+ StopTime = (long long)ET.time;
|
|
|
+ return ((StopTime - StartTime)*1000) + (ET.millitm - ST.millitm);
|
|
|
}
|
|
|
|
|
|
//==========================================
|
|
@@ -707,6 +709,14 @@ void InitGPIO()
|
|
|
system("echo 116 > /sys/class/gpio/export");
|
|
|
system("echo \"out\" > /sys/class/gpio/gpio116/direction");
|
|
|
system("echo 0 > /sys/class/gpio/gpio116/value");
|
|
|
+ /* (C14) EMU0.gpio3[7] */ /*CP open/short feature enable/disable, pull low for default enable*/
|
|
|
+ system("echo 103 > /sys/class/gpio/export");
|
|
|
+ system("echo \"out\" > /sys/class/gpio/gpio103/direction");
|
|
|
+ system("echo 0 > /sys/class/gpio/gpio103/value");
|
|
|
+ /* (B14) EMU1.gpio3[8] */ /*4G module reset, pull high to reset when entry kernel, after Application start, it should be pull low.*/
|
|
|
+ system("echo 104 > /sys/class/gpio/export");
|
|
|
+ system("echo \"out\" > /sys/class/gpio/gpio104/direction");
|
|
|
+ system("echo 0 > /sys/class/gpio/gpio104/value");
|
|
|
#ifdef SystemLogMessage
|
|
|
DEBUG_INFO_MSG("[main]InitGPIO: Initial GPIO OK");
|
|
|
#endif
|
|
@@ -881,6 +891,26 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
|
|
|
return PASS;
|
|
|
}
|
|
|
|
|
|
+int isRouteFail()
|
|
|
+{
|
|
|
+ int result = YES;
|
|
|
+ FILE *fp;
|
|
|
+ char buf[512];
|
|
|
+
|
|
|
+ fp = popen("route -n", "r");
|
|
|
+ if(fp != NULL)
|
|
|
+ {
|
|
|
+ while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(buf, "eth0") != NULL)
|
|
|
+ result = NO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pclose(fp);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
int isReachableInternet()
|
|
|
{
|
|
|
int result = FAIL;
|
|
@@ -889,11 +919,11 @@ int isReachableInternet()
|
|
|
char buf[512];
|
|
|
char tmp[512];
|
|
|
|
|
|
- if (ShmOCPP16Data->OcppConnStatus == PASS)
|
|
|
- {
|
|
|
- result = PASS;
|
|
|
- }
|
|
|
- else
|
|
|
+// if (ShmOCPP16Data->OcppConnStatus == PASS)
|
|
|
+// {
|
|
|
+// result = PASS;
|
|
|
+// }
|
|
|
+// else
|
|
|
{
|
|
|
strcpy(cmd, "ifconfig eth0");
|
|
|
fp = popen(cmd, "r");
|
|
@@ -979,6 +1009,7 @@ void InitEthernet()
|
|
|
system("rm -rf /etc/resolv.conf");
|
|
|
system("echo nameserver 8.8.8.8 > /etc/resolv.conf"); //Google DNS server
|
|
|
system("echo nameserver 180.76.76.76 > /etc/resolv.conf"); //Baidu DNS server
|
|
|
+ system("/sbin/ifconfig eth0 down;/sbin/ifconfig eth0 up");
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient == 0)
|
|
|
{
|
|
@@ -997,6 +1028,17 @@ void InitEthernet()
|
|
|
{
|
|
|
for(;;)
|
|
|
{
|
|
|
+ if (isRouteFail())
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("eth0 not in route, restart eht0. \n");
|
|
|
+ system("/sbin/ifconfig eth0 down;/sbin/ifconfig eth0 up");
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient == 0)
|
|
|
+ {
|
|
|
+ InitialDHCP();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(isReachableInternet() == PASS)
|
|
|
{
|
|
|
ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet= NO;
|
|
@@ -1013,18 +1055,54 @@ void InitEthernet()
|
|
|
bool ethResult = YES;
|
|
|
|
|
|
if(ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet)
|
|
|
- {
|
|
|
ethResult = NO;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ system("/sbin/ifmetric eth0 0");
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ system("/sbin/ifmetric mlan0 1");
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ system("/sbin/ifmetric ppp0 2");
|
|
|
}
|
|
|
|
|
|
- if (!ethResult && ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W')
|
|
|
+ if (!ethResult &&
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W' || ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
{
|
|
|
ethResult = !ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi;
|
|
|
+
|
|
|
+ if (ethResult)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ {
|
|
|
+ system("/sbin/ifmetric eth0 1");
|
|
|
+ system("/sbin/ifmetric mlan0 0");
|
|
|
+ }
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ system("/sbin/ifmetric ppp0 2");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (!ethResult && ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T')
|
|
|
+ if (!ethResult &&
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T' || ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
{
|
|
|
ethResult = !ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi;
|
|
|
+
|
|
|
+ if (ethResult)
|
|
|
+ {
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ system("/sbin/ifmetric mlan0 2");
|
|
|
+
|
|
|
+ if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
|
|
|
+ {
|
|
|
+ system("/sbin/ifmetric eth0 1");
|
|
|
+ system("/sbin/ifmetric ppp0 0");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ShmSysConfigAndInfo->SysInfo.InternetConn = ethResult;
|
|
@@ -1034,7 +1112,7 @@ void InitEthernet()
|
|
|
}
|
|
|
|
|
|
#ifdef SystemLogMessage
|
|
|
- DEBUG_INFO_MSG("[main]InitEthernet: Initial Ethernet OK");
|
|
|
+ DEBUG_INFO_MSG("[main]InitEthernet: Initial Ethernet OK. \n");
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -1366,35 +1444,38 @@ bool InitialSystemDefaultConfig()
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-void DisplaySelfTestFailReason()
|
|
|
+bool DisplaySelfTestFailReason()
|
|
|
{
|
|
|
+ bool result = false;
|
|
|
// RB、FB、407、EV 小板中有些板子無回應
|
|
|
if (ShmRelayModuleData->SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RelayboardStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RelayboardStestFail = YES; result = true; }
|
|
|
if (ShmFanModuleData->SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FanboardStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FanboardStestFail = YES; result = true; }
|
|
|
if (ShmPrimaryMcuData->SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PrimaryStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PrimaryStestFail = YES; result = true; }
|
|
|
// if (ShmLedModuleData->SelfTest_Comp == NO)
|
|
|
// { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES; }
|
|
|
+ if (ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutQCA7000Comm == YES)
|
|
|
+ { result = true; }
|
|
|
for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++)
|
|
|
{
|
|
|
if (chargingInfo[index]->Type == _Type_Chademo)
|
|
|
{
|
|
|
if (ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoboardStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoboardStestFail = YES; result = true; }
|
|
|
}
|
|
|
else if (chargingInfo[index]->Type == _Type_GB)
|
|
|
{
|
|
|
if (ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.GbtboardStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.GbtboardStestFail = YES; result = true; }
|
|
|
}
|
|
|
else if (chargingInfo[index]->Type == _Type_CCS_2)
|
|
|
{
|
|
|
if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121)
|
|
|
{
|
|
|
if (ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CCSboardStestFail = YES; result = true; }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1402,19 +1483,23 @@ void DisplaySelfTestFailReason()
|
|
|
{
|
|
|
// 先借 GBT 顯示
|
|
|
if (ac_chargingInfo[index]->SelfTest_Comp == NO)
|
|
|
- { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcConnectorStestFail = YES; }
|
|
|
+ { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcConnectorStestFail = YES; result = true; }
|
|
|
}
|
|
|
|
|
|
if (ShmSysConfigAndInfo->SysInfo.AcContactorStatus == NO)
|
|
|
{
|
|
|
// AC Contact 未搭上
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcContactStestFail = YES;
|
|
|
+ result = true;
|
|
|
}
|
|
|
else if (ShmPsuData->SystemAvailablePower <= 0 && ShmPsuData->SystemAvailableCurrent <= 0)
|
|
|
{
|
|
|
// PSU 通訊問題
|
|
|
ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuModuleStestFail = YES;
|
|
|
+ result = true;
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
void SelfTestRun()
|
|
@@ -1423,7 +1508,8 @@ void SelfTestRun()
|
|
|
|
|
|
StartSystemTimeoutDet(Timeout_SelftestChk);
|
|
|
ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_VERSION;
|
|
|
- while (ShmSysConfigAndInfo->SysInfo.SelfTestSeq != _STEST_COMPLETE)
|
|
|
+ while (ShmSysConfigAndInfo->SysInfo.SelfTestSeq != _STEST_COMPLETE ||
|
|
|
+ GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL <= 20)
|
|
|
{
|
|
|
ChkPrimaryStatus();
|
|
|
if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2)
|
|
@@ -1700,6 +1786,14 @@ bool isEvBoardStopChargeFlag(byte gunIndex)
|
|
|
void ClearDetectPluginFlag()
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
|
|
|
+ for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
|
|
|
+ {
|
|
|
+ if (chargingInfo[gun_index]->RemoteStartFlag == YES)
|
|
|
+ chargingInfo[gun_index]->RemoteStartFlag = NO;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
+ ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
}
|
|
|
|
|
|
void DetectPluginStart()
|
|
@@ -1956,9 +2050,12 @@ bool canStartCharging()
|
|
|
sprintf(buf2 + (index - 1) * 2, "%02X", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status[index]);
|
|
|
}
|
|
|
sprintf(buf2, "%s", ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status);
|
|
|
+ //printf("ExpiryDate = %s \n", ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate);
|
|
|
+ //printf("ParentIdTag = %s \n", ShmOCPP16Data->Authorize.ResponseIdTagInfo.ParentIdTag);
|
|
|
+ int _time = GetStartScheduleTime(ShmOCPP16Data->Authorize.ResponseIdTagInfo.ExpiryDate);
|
|
|
|
|
|
// 因為無法得知實際的長度,所以只能用搜尋的方式
|
|
|
- if(strcmp(buf2, "Accepted") == EQUAL)
|
|
|
+ if(strcmp(buf2, "Accepted") == EQUAL && _time < -5)
|
|
|
return true;
|
|
|
else
|
|
|
{
|
|
@@ -2380,7 +2477,8 @@ void ChkPrimaryStatus()
|
|
|
break;
|
|
|
case S_CHARGING:
|
|
|
{
|
|
|
- if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE)
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE &&
|
|
|
+ chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->isRemoteStart == NO)
|
|
|
{
|
|
|
// 停止充電
|
|
|
ChargingTerminalProcess(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
|
|
@@ -2727,6 +2825,7 @@ void SetBitValue(unsigned char *_byte, unsigned char _bit, unsigned char value)
|
|
|
void UserScanFunction()
|
|
|
{
|
|
|
bool idleReq = false;
|
|
|
+ unsigned char idleIndex = 255;
|
|
|
unsigned char stopReq = 255;
|
|
|
|
|
|
// 當前非驗證的狀態
|
|
@@ -2747,10 +2846,11 @@ void UserScanFunction()
|
|
|
{
|
|
|
stopReq = i;
|
|
|
}
|
|
|
- if ((chargingInfo[i]->SystemStatus == S_IDLE && chargingInfo[i]->IsAvailable) == YES ||
|
|
|
- (_acgunIndex > 0 && ac_chargingInfo[0]->SystemStatus == S_IDLE && ac_chargingInfo[0]->IsAvailable))
|
|
|
+ if ((chargingInfo[i]->SystemStatus == S_IDLE && chargingInfo[i]->IsAvailable == YES) ||
|
|
|
+ (_acgunIndex > 0 && ac_chargingInfo[0]->SystemStatus == S_IDLE && ac_chargingInfo[0]->IsAvailable == YES))
|
|
|
{
|
|
|
idleReq = true;
|
|
|
+ idleIndex = i;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2797,18 +2897,19 @@ void UserScanFunction()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // 進驗證
|
|
|
- if (_acgunIndex > 0 && ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == DEFAULT_AC_INDEX)
|
|
|
- {
|
|
|
- _authorizeIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _authorizeIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
|
|
|
- }
|
|
|
-
|
|
|
- StartSystemTimeoutDet(Timeout_AuthorizingForStop);
|
|
|
- AuthorizingStart();
|
|
|
+ strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
+// // 進驗證
|
|
|
+// if (_acgunIndex > 0 && ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == DEFAULT_AC_INDEX)
|
|
|
+// {
|
|
|
+// _authorizeIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// _authorizeIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
|
|
|
+// }
|
|
|
+//
|
|
|
+// StartSystemTimeoutDet(Timeout_AuthorizingForStop);
|
|
|
+// AuthorizingStart();
|
|
|
}
|
|
|
}
|
|
|
else if (idleReq)
|
|
@@ -2821,7 +2922,7 @@ void UserScanFunction()
|
|
|
strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
|
|
|
}
|
|
|
else if ((_acgunIndex > 0 && ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
|
|
|
- chargingInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == S_IDLE)
|
|
|
+ (idleIndex != 255 && chargingInfo[idleIndex]->SystemStatus == S_IDLE))
|
|
|
{
|
|
|
PRINTF_FUNC("// LCM => Authorizing \n");
|
|
|
// LCM => Authorizing
|
|
@@ -4041,7 +4142,7 @@ void ChkOcppStatus(byte gunIndex)
|
|
|
if (ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorReq == YES)
|
|
|
{
|
|
|
ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorReq = NO;
|
|
|
- if (chargingInfo[gunIndex]->SystemStatus >= S_REASSIGN_CHECK ||
|
|
|
+ if (chargingInfo[gunIndex]->SystemStatus >= S_REASSIGN_CHECK &&
|
|
|
chargingInfo[gunIndex]->SystemStatus <= S_CHARGING)
|
|
|
{
|
|
|
// 充電中,需停止充電
|
|
@@ -4149,6 +4250,11 @@ int DB_Open(sqlite3 *db)
|
|
|
"`connector` INTEGER NOT NULL, "
|
|
|
"`val` TEXT NOT NULL, unique(IsAvailable,connector) on conflict replace);";
|
|
|
|
|
|
+ char* createrecordSql="CREATE TABLE IF NOT EXISTS `event_record` ( "
|
|
|
+ "`idx` INTEGER PRIMARY KEY AUTOINCREMENT, "
|
|
|
+ "`occurDatetime` TEXT NOT NULL, "
|
|
|
+ "`statusCode` INTEGER NOT NULL, unique(occurDatetime,statusCode) on conflict replace);";
|
|
|
+
|
|
|
if(sqlite3_open(DB_FILE, &db))
|
|
|
{
|
|
|
result = FAIL;
|
|
@@ -4179,6 +4285,16 @@ int DB_Open(sqlite3 *db)
|
|
|
PRINTF_FUNC( "Opened local config table successfully\n");
|
|
|
}
|
|
|
|
|
|
+ if (sqlite3_exec(db, createrecordSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ PRINTF_FUNC( "Create local record table error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ PRINTF_FUNC( "Opened local record table successfully\n");
|
|
|
+ }
|
|
|
+
|
|
|
sqlite3_close(db);
|
|
|
}
|
|
|
|
|
@@ -4193,26 +4309,26 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
|
|
|
|
|
|
sprintf(insertSql, "insert into charging_record(reservationId, transactionId, startMethod, userId, dateTimeStart, dateTimeStop, socStart, socStop, chargeEnergy, stopReason) "
|
|
|
"values('%d', '%d', '%d', '%s', '%s', '%s', '%d', '%d', '%f', '%s');",
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].ReservationId,
|
|
|
+ chargingInfo[gun_index]->ReservationId,
|
|
|
ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartDateTime,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StopDateTime,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].EvBatterySoc,
|
|
|
- ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy,
|
|
|
+ chargingInfo[gun_index]->StartMethod,
|
|
|
+ chargingInfo[gun_index]->StartUserId,
|
|
|
+ chargingInfo[gun_index]->StartDateTime,
|
|
|
+ chargingInfo[gun_index]->StopDateTime,
|
|
|
+ chargingInfo[gun_index]->EvBatteryStartSoc,
|
|
|
+ chargingInfo[gun_index]->EvBatterySoc,
|
|
|
+ chargingInfo[gun_index]->PresentChargedEnergy,
|
|
|
ShmOCPP16Data->StopTransaction[gun_index].StopReason);
|
|
|
|
|
|
- if(sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db))
|
|
|
+ if(sqlite3_open(DB_FILE, &db))
|
|
|
{
|
|
|
result = FAIL;
|
|
|
- PRINTF_FUNC( "Can't open database: %s\r\n", sqlite3_errmsg(db));
|
|
|
+ PRINTF_FUNC( "Can't open database: %s\n", sqlite3_errmsg(db));
|
|
|
sqlite3_close(db);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- PRINTF_FUNC( "Local charging record database open successfully.\r\n");
|
|
|
+ PRINTF_FUNC( "Local charging record database open successfully.\n");
|
|
|
if (sqlite3_exec(db, insertSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
{
|
|
|
result = FAIL;
|
|
@@ -4222,6 +4338,18 @@ int DB_Insert_Record(sqlite3 *db, int gun_index)
|
|
|
{
|
|
|
PRINTF_FUNC( "Insert local charging record successfully\n");
|
|
|
}
|
|
|
+
|
|
|
+ sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
|
|
|
+ if (sqlite3_exec(db, insertSql, 0, 0, &errMsg) != SQLITE_OK)
|
|
|
+ {
|
|
|
+ result = FAIL;
|
|
|
+ PRINTF_FUNC( "delete local charging error message: %s\n", errMsg);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ PRINTF_FUNC( "delete local charging record successfully\n");
|
|
|
+ }
|
|
|
+
|
|
|
sqlite3_close(db);
|
|
|
}
|
|
|
|
|
@@ -4417,7 +4545,9 @@ void CheckIsAlternatvieByModelName()
|
|
|
if(strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DWWU301J0UT1PH") == EQUAL ||
|
|
|
strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DWYE301J0ET1PH") == EQUAL ||
|
|
|
strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DSYE301J3EW2PH") == EQUAL ||
|
|
|
- strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DWYC301J0UW1PH") == EQUAL)
|
|
|
+ strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DWYC301J0UW1PH") == EQUAL ||
|
|
|
+ strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DWYC301J0UD1PH") == EQUAL ||
|
|
|
+ strcmp((char *)ShmSysConfigAndInfo->SysConfig.ModelName, "DWYE301J0ED1PH") == EQUAL)
|
|
|
ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf = YES;
|
|
|
else
|
|
|
ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf = NO;
|
|
@@ -4518,6 +4648,15 @@ void CheckTask()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void InitialDHCP()
|
|
|
+{
|
|
|
+ char tmpbuf[256];
|
|
|
+ memset(tmpbuf,0,256);
|
|
|
+ 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);
|
|
|
+}
|
|
|
+
|
|
|
//==========================================
|
|
|
// Check Smart Charging Profile
|
|
|
//==========================================
|
|
@@ -4531,6 +4670,7 @@ int GetStartScheduleTime(unsigned char *time)
|
|
|
{
|
|
|
tmScheduleStart.tm_year -= 1900;
|
|
|
tmScheduleStart.tm_mon -= 1;
|
|
|
+
|
|
|
tbScheduleStart.time = mktime(&tmScheduleStart);
|
|
|
tbScheduleStart.millitm = 0;
|
|
|
|
|
@@ -4560,10 +4700,13 @@ void CheckSmartChargeProfile(byte _index)
|
|
|
for (byte _count = 0; _count < _maxCount; _count++)
|
|
|
{
|
|
|
// 預設最小輸出電流 (MIN_OUTPUT_CUR) A
|
|
|
- if (_time >= ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].StartPeriod &&
|
|
|
- ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].Limit > MIN_OUTPUT_CUR)
|
|
|
+ if (_time >= ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].StartPeriod)
|
|
|
{
|
|
|
- _startCount = _count;
|
|
|
+ if ((_count == 0 && ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].Limit >= MIN_OUTPUT_CUR) ||
|
|
|
+ ShmOCPP16Data->SmartChargingProfile[_index].ChargingSchedule.ChargingSchedulePeriod[_count].Limit > MIN_OUTPUT_CUR)
|
|
|
+ {
|
|
|
+ _startCount = _count;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4718,6 +4861,7 @@ int main(void)
|
|
|
StopProcessingLoop();
|
|
|
}
|
|
|
|
|
|
+ PRINTF_FUNC("SW Version = %s \n", fwVersion);
|
|
|
PRINTF_FUNC("Chademo = %d, CCS = %d, GB = %d, AC = %d \n",
|
|
|
CHAdeMO_QUANTITY, CCS_QUANTITY, GB_QUANTITY, AC_QUANTITY);
|
|
|
PRINTF_FUNC("CheckConnectorTypeStatus. \n");
|
|
@@ -4752,10 +4896,21 @@ int main(void)
|
|
|
StopSystemTimeoutDet();
|
|
|
PRINTF_FUNC("SelfTestSeq = %d, Work_Step = %d \n", ShmSysConfigAndInfo->SysInfo.SelfTestSeq, ShmPsuData->Work_Step);
|
|
|
if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq == _STEST_FAIL ||
|
|
|
- ShmPsuData->Work_Step == _NO_WORKING)
|
|
|
+ ShmPsuData->Work_Step == _NO_WORKING ||
|
|
|
+ ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutQCA7000Comm == YES)
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysWarningInfo.Level != 2)
|
|
|
- DisplaySelfTestFailReason();
|
|
|
+ {
|
|
|
+ if (!DisplaySelfTestFailReason())
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("Soft reboot for retry self-tets. \n");
|
|
|
+ sleep(3);
|
|
|
+ system("killall OcppBackend &");
|
|
|
+ KillTask();
|
|
|
+ system("/usr/bin/run_evse_restart.sh");
|
|
|
+ StopProcessingLoop();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
|
|
|
{
|
|
@@ -4885,7 +5040,10 @@ int main(void)
|
|
|
setChargerMode(gun_index, MODE_ALARM);
|
|
|
}
|
|
|
else if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING)
|
|
|
- {/* 不給充電 */}
|
|
|
+ {/* 不給充電 */
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_IDLE;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.SystemPage == _LCM_FIX)
|
|
@@ -4941,6 +5099,7 @@ int main(void)
|
|
|
{
|
|
|
PRINTF_FUNC("-----------------1----------------- %d \n", gun_index);
|
|
|
chargingInfo[gun_index]->RemoteStartFlag = NO;
|
|
|
+ chargingInfo[gun_index]->isRemoteStart = YES;
|
|
|
ChangeGunSelectByIndex(gun_index);
|
|
|
AddPlugInTimes(gun_index);
|
|
|
setChargerMode(gun_index, MODE_REASSIGN_CHECK);
|
|
@@ -5206,7 +5365,7 @@ int main(void)
|
|
|
else if (chargingInfo[gun_index]->Type == _Type_GB)
|
|
|
{
|
|
|
// 檢查樁端的 GFD 結果
|
|
|
- if (isPrechargeStatus_gb(gun_index) > 5 && isPrechargeStatus_gb(gun_index) < 9)
|
|
|
+ if (isPrechargeStatus_gb(gun_index) > 9)
|
|
|
{
|
|
|
setChargerMode(gun_index, MODE_CHARGING);
|
|
|
}
|
|
@@ -5364,7 +5523,9 @@ int main(void)
|
|
|
if (isEvStopCharging_chademo(gun_index) == YES)
|
|
|
{
|
|
|
if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
|
|
|
+ {
|
|
|
strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
|
|
@@ -5391,7 +5552,9 @@ int main(void)
|
|
|
if (isEvStopCharging_chademo(gun_index) == YES)
|
|
|
{
|
|
|
if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
|
|
@@ -5417,7 +5580,9 @@ int main(void)
|
|
|
if (isEvStopCharging_chademo(gun_index) == YES)
|
|
|
{
|
|
|
if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
|
|
@@ -5441,7 +5606,9 @@ int main(void)
|
|
|
|
|
|
// 車端的停止
|
|
|
if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
|
|
|
+ {
|
|
|
strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
|
|
|
+ }
|
|
|
|
|
|
if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index)
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_COMPLETE;
|
|
@@ -5460,9 +5627,12 @@ int main(void)
|
|
|
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);
|
|
|
ChangeStartOrStopDateTime(NO, gun_index);
|
|
|
+ DB_Insert_Record(localDb, gun_index);
|
|
|
}
|
|
|
|
|
|
if(chargingInfo[gun_index]->ConnectorPlugIn == NO &&
|