|
@@ -126,9 +126,9 @@ void StartDispenserDhcpServer(void);
|
|
|
void _SelfTestTimeout(void);
|
|
|
void CheckConnectionTimeout(void);
|
|
|
|
|
|
-#define DEBUG_INFO_MSG(format, args...) PRINTF_FUNC("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-#define DEBUG_WARN_MSG(format, args...) PRINTF_FUNC("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
-#define DEBUG_ERROR_MSG(format, args...) PRINTF_FUNC("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
+#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)
|
|
|
+#define DEBUG_ERROR_MSG(format, args...) StoreLogMsg_1("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
struct StatusCodeData *ShmStatusCodeData;
|
|
@@ -168,7 +168,7 @@ bool isModelNameMatch = true;
|
|
|
|
|
|
//int rfidFd = -1;
|
|
|
//char* rfidPortName = "/dev/ttyS2";
|
|
|
-char* fwVersion = "D0.04.00.0000.00";
|
|
|
+char* fwVersion = "D0.05.00.0000.00";
|
|
|
|
|
|
sqlite3 *localDb;
|
|
|
bool isDb_ready;
|
|
@@ -375,7 +375,7 @@ void PRINTF_FUNC(char *string, ...)
|
|
|
vsnprintf(buffer, sizeof(buffer), string, args);
|
|
|
va_end(args);
|
|
|
|
|
|
- printf("%s \n", buffer);
|
|
|
+ DEBUG_INFO_MSG("%s \n", buffer);
|
|
|
}
|
|
|
|
|
|
long long DiffTimebWithNow(struct timeb ST)
|
|
@@ -1472,6 +1472,8 @@ int Initialization()
|
|
|
for (byte count = 0; count < CONNECTOR_QUANTITY; count++)
|
|
|
{
|
|
|
chargingInfo[count]->RemoteStartFlag = NO;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[count].Parameter.bits.RemoteStartRequest = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[count].Parameter.bits.RemoteStopRequest = false;
|
|
|
//
|
|
|
// if (chargingInfo[count]->Type == _Type_Chademo)
|
|
|
// {
|
|
@@ -1498,16 +1500,16 @@ int Initialization()
|
|
|
strcpy((char *)ShmOCPP16Data->StatusNotification[count].ErrorCode, "NoError");
|
|
|
}
|
|
|
|
|
|
- for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.AcConnectorCount; count++)
|
|
|
- {
|
|
|
- ac_chargingInfo[count]->RemoteStartFlag = NO;
|
|
|
+// for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.AcConnectorCount; count++)
|
|
|
+// {
|
|
|
+// ac_chargingInfo[count]->RemoteStartFlag = NO;
|
|
|
|
|
|
- if (ac_chargingInfo[count]->Type == _Type_AC)
|
|
|
- {
|
|
|
- ac_chargingInfo[count]->SelfTest_Comp = NO;
|
|
|
- strcpy((char *)ShmOCPP16Data->StatusNotification[count + ShmSysConfigAndInfo->SysConfig.TotalConnectorCount].ErrorCode, "NoError");
|
|
|
- }
|
|
|
- }
|
|
|
+// if (ac_chargingInfo[count]->Type == _Type_AC)
|
|
|
+// {
|
|
|
+// ac_chargingInfo[count]->SelfTest_Comp = NO;
|
|
|
+// strcpy((char *)ShmOCPP16Data->StatusNotification[count + ShmSysConfigAndInfo->SysConfig.TotalConnectorCount].ErrorCode, "NoError");
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
PRINTF_FUNC("Initialization OK \n");
|
|
|
return PASS;
|
|
@@ -3137,6 +3139,8 @@ void AuthorizingSettingInitial(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
memset(ShmOCPP16Data->RemoteStartTransaction[index].IdTag, 0x00, 20);
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus = _AuthorizeStatus_Idle;
|
|
|
ShmOCPP16Data->CsMsg.bits[index].RemoteStartTransactionReq = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.RemoteStartRequest = false;
|
|
|
+ chargingInfo[index]->RemoteStartFlag = false;
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType != _AuthorizeSrc_None)
|
|
|
{
|
|
@@ -3203,6 +3207,7 @@ void SetConnectorAuthorizeOK(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_Remote;
|
|
|
memcpy(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, 32);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.RemoteStartRequest = true;
|
|
|
PRINTF_FUNC("*********** Connector id %d RemoteAuthorize OK***********", index + 1);
|
|
|
}
|
|
|
break;
|
|
@@ -3282,6 +3287,7 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
{
|
|
|
SetAuthorizingTarget(index, _AuthorizeSrc_Remote);
|
|
|
ShmOCPP16Data->CsMsg.bits[index].RemoteStartTransactionReq = false;
|
|
|
+ chargingInfo[index]->RemoteStartFlag = true;
|
|
|
FindRemoteStartRequest = true;
|
|
|
break;
|
|
|
}
|
|
@@ -4389,16 +4395,9 @@ void OcppStartTransation(byte gunIndex)
|
|
|
{
|
|
|
byte _OcppGunIndex = gunIndex;
|
|
|
|
|
|
- // 如果有 AC 槍,而現在是 DC 第二把槍進入充電
|
|
|
-// if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount == 1 && gunIndex == 1)
|
|
|
-// _OcppGunIndex = 2;
|
|
|
-
|
|
|
- if(strcmp((char *)chargingInfo[gunIndex]->StartUserId, "") == EQUAL)
|
|
|
- strcpy((char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag, (char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
|
|
|
- else
|
|
|
- strcpy((char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
|
|
|
+ strcpy((char *)ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
|
|
|
|
|
|
- PRINTF_FUNC("Gun: %d, OCPP Start Transation Index: %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
|
|
|
+ PRINTF_FUNC("Gun index %d, OCPP Start Transation Index %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
|
|
|
ShmOCPP16Data->CpMsg.bits[_OcppGunIndex].StartTransactionReq = YES;
|
|
|
}
|
|
|
|
|
@@ -4406,19 +4405,14 @@ void OcppStopTransation(byte gunIndex)
|
|
|
{
|
|
|
byte _OcppGunIndex = gunIndex;
|
|
|
|
|
|
- // 如果有 AC 槍,而現在是 DC 第二把槍進入充電
|
|
|
-// if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount == 1 && gunIndex == 1)
|
|
|
-// _OcppGunIndex = 2;
|
|
|
-
|
|
|
- if(strcmp((char *)chargingInfo[gunIndex]->StartUserId, "") == EQUAL)
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag, (char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
|
|
|
- else
|
|
|
- strcpy((char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
|
|
|
+ strcpy((char *)ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag, (char *)chargingInfo[gunIndex]->StartUserId);
|
|
|
|
|
|
- PRINTF_FUNC("OCPP Start Transation Index: %d, IdTag = %s \n", _OcppGunIndex, ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
|
|
|
+ PRINTF_FUNC("Gun index %d, OCPP Stop Transation Index %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
|
|
|
ShmOCPP16Data->CpMsg.bits[_OcppGunIndex].StopTransactionReq = YES;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// no use
|
|
|
bool OcppRemoteStop(byte gunIndex)
|
|
|
{
|
|
|
byte acDirIndex = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
|
|
@@ -4584,16 +4578,36 @@ void ChkOcppStatus(byte gunIndex)
|
|
|
if (ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorReq == YES)
|
|
|
{
|
|
|
ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorReq = NO;
|
|
|
- if (chargingInfo[gunIndex]->SystemStatus >= S_REASSIGN_CHECK &&
|
|
|
- chargingInfo[gunIndex]->SystemStatus <= S_CHARGING)
|
|
|
+
|
|
|
+ if(chargingInfo[gunIndex]->SystemStatus == S_PREPARNING ||
|
|
|
+ chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EV ||
|
|
|
+ chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EVSE ||
|
|
|
+ chargingInfo[gunIndex]->SystemStatus == S_CHARGING)
|
|
|
{
|
|
|
// 充電中,需停止充電
|
|
|
strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "UnlockCommand");
|
|
|
- ChargingTerminalProcess(gunIndex);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].Parameter.bits.UnlockStopRequest = true;
|
|
|
+ PRINTF_FUNC("********** OcppUnlockStop Gun %d **********\n", gunIndex);
|
|
|
}
|
|
|
+
|
|
|
strcpy((char *)ShmOCPP16Data->UnlockConnector[gunIndex].ResponseStatus, "Unlocked");
|
|
|
ShmOCPP16Data->CsMsg.bits[gunIndex].UnlockConnectorConf = YES;
|
|
|
}
|
|
|
+
|
|
|
+ if (ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq == YES)
|
|
|
+ {
|
|
|
+ ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq = NO;
|
|
|
+
|
|
|
+ if(chargingInfo[gunIndex]->SystemStatus == S_PREPARNING ||
|
|
|
+ chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EV ||
|
|
|
+ chargingInfo[gunIndex]->SystemStatus == S_PREPARING_FOR_EVSE ||
|
|
|
+ chargingInfo[gunIndex]->SystemStatus == S_CHARGING)
|
|
|
+ {
|
|
|
+ strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "Remote");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].Parameter.bits.RemoteStopRequest = true;
|
|
|
+ PRINTF_FUNC("********** OcppRemoteStop Gun %d **********\n", gunIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
bool CheckBackendChargingTimeout(byte gunIndex)
|
|
@@ -5440,10 +5454,10 @@ int main(void)
|
|
|
|
|
|
gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
|
|
|
- PRINTF_FUNC("Gun 1(%d): %d(%s), Gun 2(%d): %d(%s), OCPP: %s",
|
|
|
- chargingInfo[0]->Index, chargingInfo[0]->SystemStatus, chargingInfo[0]->IsAvailable ? "Operative" : "Inoperative",
|
|
|
- chargingInfo[1]->Index, chargingInfo[1]->SystemStatus, chargingInfo[1]->IsAvailable ? "Operative" : "Inoperative",
|
|
|
- ShmOCPP16Data->OcppConnStatus ? "On" : "Off");
|
|
|
+// PRINTF_FUNC("Gun 1(%d): %d(%s), Gun 2(%d): %d(%s), OCPP: %s",
|
|
|
+// chargingInfo[0]->Index, chargingInfo[0]->SystemStatus, chargingInfo[0]->IsAvailable ? "Operative" : "Inoperative",
|
|
|
+// chargingInfo[1]->Index, chargingInfo[1]->SystemStatus, chargingInfo[1]->IsAvailable ? "Operative" : "Inoperative",
|
|
|
+// ShmOCPP16Data->OcppConnStatus ? "On" : "Off");
|
|
|
|
|
|
// PRINTF_FUNC("Gun 1: %d(%d), Gun 2: %d(%d), Gun 3: %d(%d), Gun 4: %d(%d)",
|
|
|
// chargingInfo[0]->Index, chargingInfo[0]->Type,
|
|
@@ -5481,9 +5495,17 @@ int main(void)
|
|
|
CheckErrorOccurStatus(gun_index);
|
|
|
ChkOcppStatus(gun_index);
|
|
|
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable == false)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.TimeoutStopRequest)
|
|
|
{
|
|
|
- setChargerMode(gun_index, MODE_IDLE);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.TimeoutStopRequest = false;
|
|
|
+
|
|
|
+ if(chargingInfo[gun_index]->SystemStatus == S_PREPARNING ||
|
|
|
+ chargingInfo[gun_index]->SystemStatus == S_PREPARING_FOR_EV ||
|
|
|
+ chargingInfo[gun_index]->SystemStatus == S_PREPARING_FOR_EVSE ||
|
|
|
+ chargingInfo[gun_index]->SystemStatus == S_CHARGING)
|
|
|
+ {
|
|
|
+ ChargingTerminalProcess(gun_index);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//PRINTF_FUNC("index = %d, ErrorCode = %s \n", gun_index, ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
|
|
@@ -5496,6 +5518,8 @@ int main(void)
|
|
|
{
|
|
|
// clean PermissionRequest flag
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PermissionRequest = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.RemoteStopRequest = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = true;
|
|
|
|
|
|
if (chargingInfo[gun_index]->SystemStatus == S_IDLE &&
|
|
|
isModeChange(gun_index))
|
|
@@ -5690,6 +5714,7 @@ int main(void)
|
|
|
if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
StopSystemTimeoutDet();
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = false;
|
|
|
}
|
|
|
|
|
|
bool isRessign = false;
|
|
@@ -5792,10 +5817,10 @@ int main(void)
|
|
|
setChargerMode(gun_index, MODE_PREPARE_FOR_EV);
|
|
|
}
|
|
|
|
|
|
- if (isEvBoardStopChargeFlag(gun_index) == YES || OcppRemoteStop(gun_index) == YES)
|
|
|
+ if (isEvBoardStopChargeFlag(gun_index) == YES)
|
|
|
{
|
|
|
// 板端或後臺要求停止
|
|
|
- PRINTF_FUNC("EvBoardStop: %d, OcppStop: %d \n", isEvBoardStopChargeFlag(gun_index), OcppRemoteStop(gun_index));
|
|
|
+ PRINTF_FUNC("********** EvBoardStop Gun %d (S_PREPARNING)**********\n", gun_index);
|
|
|
ChargingTerminalProcess(gun_index);
|
|
|
}
|
|
|
|
|
@@ -5843,10 +5868,10 @@ int main(void)
|
|
|
setChargerMode(gun_index, MODE_CHARGING);
|
|
|
}
|
|
|
|
|
|
- if (isEvBoardStopChargeFlag(gun_index) == YES ||
|
|
|
- OcppRemoteStop(gun_index) == YES)
|
|
|
+ if (isEvBoardStopChargeFlag(gun_index) == YES)
|
|
|
{
|
|
|
// 板端或後臺要求停止
|
|
|
+ PRINTF_FUNC("********** EvBoardStop Gun %d (S_PREPARING_FOR_EV)**********\n", gun_index);
|
|
|
ChargingTerminalProcess(gun_index);
|
|
|
}
|
|
|
|
|
@@ -5924,8 +5949,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isEvBoardStopChargeFlag(gun_index) == YES ||
|
|
|
- OcppRemoteStop(gun_index) == YES)
|
|
|
+ if (isEvBoardStopChargeFlag(gun_index) == YES)
|
|
|
{
|
|
|
// 板端或後臺要求停止
|
|
|
ChargingTerminalProcess(gun_index);
|
|
@@ -6041,7 +6065,6 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
if (isEvBoardStopChargeFlag(gun_index) ||
|
|
|
- OcppRemoteStop(gun_index) ||
|
|
|
CheckBackendChargingTimeout(gun_index) ||
|
|
|
CheckBackendChargingEnergy(gun_index) ||
|
|
|
strcmp((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid") == EQUAL)
|
|
@@ -6175,8 +6198,17 @@ int main(void)
|
|
|
ChangeStartOrStopDateTime(NO, gun_index);
|
|
|
}
|
|
|
|
|
|
- //if(chargingInfo[gun_index]->ConnectorPlugIn == NO &&
|
|
|
if(GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) >= 10000000)
|
|
|
+ {
|
|
|
+ if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC ("********** Gun %d psu is releasable **********\n", gun_index);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(chargingInfo[gun_index]->ConnectorPlugIn == NO &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
|
|
|
{
|
|
|
setChargerMode(gun_index, MODE_IDLE);
|
|
|
}
|