|
@@ -87,6 +87,7 @@
|
|
|
#define RESET_TIMEOUT 10
|
|
|
#define OCPP_COST_REQ_INTERVAL 5
|
|
|
#define DISPENSER_RECONNECTE_TIME 30
|
|
|
+#define DISPENSER_AUTH_COMP_TIME 3
|
|
|
#define FORCE_BALANCE_TIME 5
|
|
|
|
|
|
char *valid_Internet[2] = {"8.8.8.8", "180.76.76.76"};
|
|
@@ -154,6 +155,7 @@ struct timeb startChargingTime[CONNECTOR_QUANTITY];
|
|
|
struct timeb endChargingTime[CONNECTOR_QUANTITY];
|
|
|
|
|
|
struct timeval _ConnectorAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
+struct timeval _ConnectorAuthorizeFail_Time[CONNECTOR_QUANTITY];
|
|
|
struct timeval _DispenserAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
int chargingTime[CONNECTOR_QUANTITY];
|
|
|
|
|
@@ -174,7 +176,7 @@ bool isModelNameMatch = true;
|
|
|
|
|
|
//int rfidFd = -1;
|
|
|
//char* rfidPortName = "/dev/ttyS2";
|
|
|
-char* fwVersion = "D0.06.00.0000.00";
|
|
|
+char* fwVersion = "D0.07.00.0000.00";
|
|
|
|
|
|
sqlite3 *localDb;
|
|
|
bool isDb_ready;
|
|
@@ -3119,39 +3121,27 @@ void PowerCabinetAuthorizingSettingInitial(void)
|
|
|
ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.BackendAuthorized = false;
|
|
|
}
|
|
|
|
|
|
-void FouceAnnounceAccountBalance(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
+void FouceAnnounceAccountBalance(unsigned char index)
|
|
|
{
|
|
|
- switch(AuthorizeSrc)
|
|
|
+ if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AnnounceBalance)
|
|
|
{
|
|
|
- case _AuthorizeSrc_Local:
|
|
|
- for(int i = 0; i < 2; i++)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].ConnectorID[i] != 0)
|
|
|
- {
|
|
|
- unsigned char ConnectorIndex = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].ConnectorID[i] - 1;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AnnounceBalance = true;
|
|
|
|
|
|
- if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AnnounceBalance)
|
|
|
- {
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AnnounceBalance = true;
|
|
|
-
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].AccountBalance = 0;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AccountBalanceRequest = true;
|
|
|
- PRINTF_FUNC("Force Announce Account Balance To Dispenser %d Connector %d", index + 1, ConnectorIndex + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- case _AuthorizeSrc_Remote:
|
|
|
- if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AnnounceBalance)
|
|
|
- {
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AnnounceBalance = true;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AccountBalance = 0;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AccountBalanceRequest = true;
|
|
|
+ PRINTF_FUNC("Force Announce Account Balance To Connector %d", index + 1);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AccountBalance = 0;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AccountBalanceRequest = true;
|
|
|
- PRINTF_FUNC("Force Announce Account Balance To Connector %d", index + 1);
|
|
|
- }
|
|
|
- break;
|
|
|
+void CleanConnectorUserIdAndPrice(unsigned char index)
|
|
|
+{
|
|
|
+ if(chargingInfo[index]->SystemStatus == S_IDLE)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("*********** Connector id %d Clean UserId & UserPrice ***********", index + 1);
|
|
|
+ memset(chargingInfo[index]->StartUserId, 0x00, 32);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].UserPrice = 0;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AccountBalance = -6553500;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AnnounceBalance = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3161,33 +3151,23 @@ void AuthorizingSettingInitial(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
|
|
|
PRINTF_FUNC("*********** %s id %d Authorize Initial ***********", str_auth_src[AuthorizeSrc], index + 1);
|
|
|
|
|
|
+ // to be fixed
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus = _AuthorizeStatus_Idle;
|
|
|
+
|
|
|
switch(AuthorizeSrc)
|
|
|
{
|
|
|
case _AuthorizeSrc_Local:
|
|
|
memset(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].UserId, 0x00, 32);
|
|
|
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].AuthorizeStatus = _AuthorizeStatus_Idle;
|
|
|
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].Setting.bits.AuthorizeRequest = false;
|
|
|
- for(int i = 0; i < 2; i++)
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].ConnectorID[i] != 0)
|
|
|
- {
|
|
|
- unsigned char ConnectorIndex = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].ConnectorID[i] - 1;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus = _AuthorizeStatus_Idle;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequest = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.SwipeRfidConfirm = false;
|
|
|
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AuthorizeRequestType != _AuthorizeSrc_None)
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** Connector id %d AuthorizeReqClean ***********", ConnectorIndex + 1);
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_None;
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType != _AuthorizeSrc_None)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("*********** Connector id %d AuthorizeReqClean ***********", index + 1);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_None;
|
|
|
|
|
|
- if(chargingInfo[ConnectorIndex]->SystemStatus == S_IDLE)
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** Connector id %d Clean UserId & UserPrice ***********", ConnectorIndex + 1);
|
|
|
- memset(chargingInfo[ConnectorIndex]->StartUserId, 0x00, 32);
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].UserPrice = 0;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].AccountBalance = -6553500;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AnnounceBalance = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ CleanConnectorUserIdAndPrice(index);
|
|
|
}
|
|
|
break;
|
|
|
case _AuthorizeSrc_Remote:
|
|
@@ -3195,6 +3175,7 @@ void AuthorizingSettingInitial(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus = _AuthorizeStatus_Idle;
|
|
|
ShmOCPP16Data->CsMsg.bits[index].RemoteStartTransactionReq = false;
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.RemoteStartRequest = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.RemoteStartConfirm = false;
|
|
|
chargingInfo[index]->RemoteStartFlag = false;
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType != _AuthorizeSrc_None)
|
|
@@ -3202,14 +3183,7 @@ void AuthorizingSettingInitial(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
PRINTF_FUNC("*********** Connector id %d AuthorizeReqClean ***********", index + 1);
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_None;
|
|
|
|
|
|
- if(chargingInfo[index]->SystemStatus == S_IDLE)
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** Connector id %d Clean UserId & UserPrice ***********", index + 1);
|
|
|
- memset(chargingInfo[index]->StartUserId, 0x00, 32);
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].UserPrice = 0;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AccountBalance = -6553500;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AnnounceBalance = false;
|
|
|
- }
|
|
|
+ CleanConnectorUserIdAndPrice(index);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -3222,10 +3196,12 @@ void SetAuthorizingTarget(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
{
|
|
|
case _AuthorizeSrc_Local:
|
|
|
valid = true;
|
|
|
- PRINTF_FUNC("*********** Dispenser id %d Local Authorize ***********", index + 1);
|
|
|
+ unsigned char dispenser = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].ParentDispensetIndex;
|
|
|
+ PRINTF_FUNC("*********** Connector id %d RFID Authorize ***********", index + 1);
|
|
|
memset(ShmSysConfigAndInfo->SysConfig.UserId, 0x00, 32);
|
|
|
- memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].UserId, 32);
|
|
|
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].AuthorizeStatus = _AuthorizeStatus_Wait;
|
|
|
+ memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].UserId, 32);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus = _AuthorizeStatus_Wait;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].AuthorizeStatus = _AuthorizeStatus_Busy;
|
|
|
break;
|
|
|
case _AuthorizeSrc_Remote:
|
|
|
valid = true;
|
|
@@ -3250,25 +3226,17 @@ void SetConnectorAuthorizeOK(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
switch(AuthorizeSrc)
|
|
|
{
|
|
|
case _AuthorizeSrc_Local:
|
|
|
- for(int i = 0; i < 2; i++)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == S_IDLE)
|
|
|
{
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].ConnectorID[i] != 0)
|
|
|
- {
|
|
|
- unsigned char ConnectorIndex = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].ConnectorID[i] - 1;
|
|
|
-
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].GeneralChargingData.SystemStatus == S_IDLE)
|
|
|
- {
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_Local;
|
|
|
- memcpy(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].GeneralChargingData.StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, 32);
|
|
|
- PRINTF_FUNC("*********** Connector id %d LocalAuthorize OK ***********", ConnectorIndex + 1);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType = _AuthorizeSrc_Local;
|
|
|
+ memcpy(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId, ShmSysConfigAndInfo->SysConfig.UserId, 32);
|
|
|
+ PRINTF_FUNC("*********** Connector id %d LocalAuthorize OK ***********", index + 1);
|
|
|
|
|
|
- if(!ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.BackendAuthorized)
|
|
|
- {
|
|
|
- // authorized without backend need to trigger announce AccountBalance
|
|
|
- //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].AccountBalance = 0;
|
|
|
- //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AccountBalanceRequest = true;
|
|
|
- }
|
|
|
- }
|
|
|
+ if(!ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.BackendAuthorized)
|
|
|
+ {
|
|
|
+ // authorized without backend need to trigger announce AccountBalance
|
|
|
+ //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].AccountBalance = 0;
|
|
|
+ //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[ConnectorIndex].Parameter.bits.AccountBalanceRequest = true;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -3297,26 +3265,14 @@ void AuthorizeTimeoutProcess(void)
|
|
|
{
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus)
|
|
|
{
|
|
|
- case _AuthorizeStatus_Pass:
|
|
|
- if(GetTimeoutValue(_ConnectorAuthorizing_Time[index]) / uSEC_VAL >= FORCE_BALANCE_TIME)
|
|
|
- {
|
|
|
- FouceAnnounceAccountBalance(index, _AuthorizeSrc_Remote);
|
|
|
- }
|
|
|
-
|
|
|
- if(GetTimeoutValue(_ConnectorAuthorizing_Time[index]) / uSEC_VAL >= _connectionTimeout)
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** Connector id %d Plug In Timeout ***********\n", index + 1);
|
|
|
- AuthorizingSettingInitial(index, _AuthorizeSrc_Remote);
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
case _AuthorizeStatus_Fail:
|
|
|
- FouceAnnounceAccountBalance(index, _AuthorizeSrc_Remote);
|
|
|
+ FouceAnnounceAccountBalance(index);
|
|
|
|
|
|
- if(GetTimeoutValue(_ConnectorAuthorizing_Time[index]) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT)
|
|
|
+ if(GetTimeoutValue(_ConnectorAuthorizeFail_Time[index]) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT)
|
|
|
{
|
|
|
PRINTF_FUNC("*********** Connector id %d Authorized Return ***********", index + 1);
|
|
|
- AuthorizingSettingInitial(index, _AuthorizeSrc_Remote);
|
|
|
+ AuthorizingSettingInitial(index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequestType);
|
|
|
+ CleanConnectorUserIdAndPrice(index);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -3328,25 +3284,14 @@ void AuthorizeTimeoutProcess(void)
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].AuthorizeStatus)
|
|
|
{
|
|
|
case _AuthorizeStatus_Pass:
|
|
|
- if(GetTimeoutValue(_DispenserAuthorizing_Time[index]) / uSEC_VAL >= FORCE_BALANCE_TIME)
|
|
|
- {
|
|
|
- FouceAnnounceAccountBalance(index, _AuthorizeSrc_Local);
|
|
|
- }
|
|
|
-
|
|
|
- if(GetTimeoutValue(_DispenserAuthorizing_Time[index]) / uSEC_VAL >= _connectionTimeout)
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** Dispenser id %d Plug In Timeout ***********\n", index + 1);
|
|
|
- AuthorizingSettingInitial(index, _AuthorizeSrc_Local);
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
case _AuthorizeStatus_Fail:
|
|
|
- FouceAnnounceAccountBalance(index, _AuthorizeSrc_Local);
|
|
|
-
|
|
|
- if(GetTimeoutValue(_DispenserAuthorizing_Time[index]) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT)
|
|
|
+ if(GetTimeoutValue(_DispenserAuthorizing_Time[index]) / uSEC_VAL >= DISPENSER_AUTH_COMP_TIME)
|
|
|
{
|
|
|
PRINTF_FUNC("*********** Dispenser id %d Authorized Return ***********", index + 1);
|
|
|
- AuthorizingSettingInitial(index, _AuthorizeSrc_Local);
|
|
|
+
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].AuthorizeStatus = _AuthorizeStatus_Idle;
|
|
|
+ memset(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].UserId, 0x00, 32);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].Setting.bits.AuthorizeTargetID = 0;
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -3361,11 +3306,13 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
{
|
|
|
char *str_auth_src[] = {AUTHORIZE_SRC_NONE_DEV, AUTHORIZE_SRC_LOCAL_DEV, AUTHORIZE_SRC_REMOTE_DEV};
|
|
|
BOOL FindRemoteStartRequest = false;
|
|
|
+ unsigned char dispenser = 0;
|
|
|
|
|
|
AuthorizeTimeoutProcess();
|
|
|
|
|
|
if(!ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.StartAuthorize)
|
|
|
{
|
|
|
+ // remote start check
|
|
|
for(int index = 0; index < GENERAL_GUN_QUANTITY; index++)
|
|
|
{
|
|
|
if(ShmOCPP16Data->CsMsg.bits[index].RemoteStartTransactionReq == true)
|
|
@@ -3380,16 +3327,19 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
|
|
|
if(!FindRemoteStartRequest)
|
|
|
{
|
|
|
+ // local rfid authorize check
|
|
|
for(int index = 0; index < GENERAL_GUN_QUANTITY; index++)
|
|
|
{
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].AuthorizeStatus == _AuthorizeStatus_Idle)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].AuthorizeStatus == _AuthorizeStatus_Idle)
|
|
|
{
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].Setting.bits.AuthorizeRequest &&
|
|
|
- strlen((char *)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].UserId) > 0)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequest)
|
|
|
{
|
|
|
- SetAuthorizingTarget(index, _AuthorizeSrc_Local);
|
|
|
- ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[index].Setting.bits.AuthorizeRequest = false;
|
|
|
- break;
|
|
|
+ dispenser = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].ParentDispensetIndex;
|
|
|
+ if(strlen((char *)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].UserId) > 0)
|
|
|
+ {
|
|
|
+ SetAuthorizingTarget(index, _AuthorizeSrc_Local);
|
|
|
+ }
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].Parameter.bits.AuthorizeRequest = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -3405,7 +3355,7 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc)
|
|
|
{
|
|
|
case _AuthorizeSrc_Local:
|
|
|
- AuthorizeStatus = &ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[target].AuthorizeStatus;
|
|
|
+ AuthorizeStatus = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[target].AuthorizeStatus;
|
|
|
break;
|
|
|
case _AuthorizeSrc_Remote:
|
|
|
AuthorizeStatus = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[target].AuthorizeStatus;
|
|
@@ -3443,63 +3393,73 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmOCPP16Data->OcppConnStatus)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc == _AuthorizeSrc_Remote)
|
|
|
{
|
|
|
- if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf)
|
|
|
- {
|
|
|
- BOOL accept = false;
|
|
|
- if(strcmp((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted") == EQUAL)
|
|
|
- {
|
|
|
- accept = true;
|
|
|
- }
|
|
|
-
|
|
|
- PRINTF_FUNC("*********** %s id %d OCPP Authorize %s ***********",
|
|
|
- str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1, accept ? "OK" : "NG");
|
|
|
- *AuthorizeStatus = accept ? _AuthorizeStatus_Pass : _AuthorizeStatus_Fail;
|
|
|
- ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.BackendAuthorized = true;
|
|
|
- }
|
|
|
+ PRINTF_FUNC("*********** %s %d Remote Authorize OK ***********",
|
|
|
+ str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
+ *AuthorizeStatus = _AuthorizeStatus_Pass;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.BackendAuthorized = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING)
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** %s id %d No Charging ***********",
|
|
|
- str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
- *AuthorizeStatus = _AuthorizeStatus_Fail;
|
|
|
- }
|
|
|
- else if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
+ if(ShmOCPP16Data->OcppConnStatus)
|
|
|
{
|
|
|
- // set authorize pass when offline policy is free charge
|
|
|
- PRINTF_FUNC("*********** %s id %d Free Charging OK ***********",
|
|
|
- str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
- *AuthorizeStatus = _AuthorizeStatus_Pass;
|
|
|
+ if(ShmOCPP16Data->SpMsg.bits.AuthorizeConf)
|
|
|
+ {
|
|
|
+ BOOL accept = false;
|
|
|
+ if(strcmp((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted") == EQUAL)
|
|
|
+ {
|
|
|
+ accept = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ PRINTF_FUNC("*********** %s id %d OCPP Authorize %s ***********",
|
|
|
+ str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1, accept ? "OK" : "NG");
|
|
|
+ *AuthorizeStatus = accept ? _AuthorizeStatus_Pass : _AuthorizeStatus_Fail;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.BackendAuthorized = true;
|
|
|
+ }
|
|
|
}
|
|
|
- else if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST)
|
|
|
+ else
|
|
|
{
|
|
|
- BOOL find = false;
|
|
|
-
|
|
|
- // check white list
|
|
|
- for(int i = 0; i < 10; i++)
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("*********** %s id %d No Charging ***********",
|
|
|
+ str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
+ *AuthorizeStatus = _AuthorizeStatus_Fail;
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
|
|
|
+ {
|
|
|
+ // set authorize pass when offline policy is free charge
|
|
|
+ PRINTF_FUNC("*********** %s id %d Free Charging OK ***********",
|
|
|
+ str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
+ *AuthorizeStatus = _AuthorizeStatus_Pass;
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST)
|
|
|
{
|
|
|
- if (strcmp((char *)ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[i], "") != EQUAL)
|
|
|
+ BOOL find = false;
|
|
|
+
|
|
|
+ // check white list
|
|
|
+ for(int i = 0; i < 10; i++)
|
|
|
{
|
|
|
- if (strcmp((char *)ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[i], (char *)ShmSysConfigAndInfo->SysConfig.UserId) == EQUAL)
|
|
|
+ if (strcmp((char *)ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[i], "") != EQUAL)
|
|
|
{
|
|
|
- find = true;
|
|
|
- break;
|
|
|
+ if (strcmp((char *)ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[i], (char *)ShmSysConfigAndInfo->SysConfig.UserId) == EQUAL)
|
|
|
+ {
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- PRINTF_FUNC("*********** %s id %d White Card %s ***********",
|
|
|
- str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1, find ? "OK" : "NG");
|
|
|
- *AuthorizeStatus = find ? _AuthorizeStatus_Pass : _AuthorizeStatus_Fail;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- PRINTF_FUNC("*********** %s id %d Invalid Policy ***********",
|
|
|
- str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
- *AuthorizeStatus = _AuthorizeStatus_Fail;
|
|
|
+ PRINTF_FUNC("*********** %s id %d White Card %s ***********",
|
|
|
+ str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1, find ? "OK" : "NG");
|
|
|
+ *AuthorizeStatus = find ? _AuthorizeStatus_Pass : _AuthorizeStatus_Fail;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("*********** %s id %d Invalid Policy ***********",
|
|
|
+ str_auth_src[ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc], target + 1);
|
|
|
+ *AuthorizeStatus = _AuthorizeStatus_Fail;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -3513,16 +3473,20 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
{
|
|
|
SetConnectorAuthorizeOK(target, ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ gettimeofday(&_ConnectorAuthorizeFail_Time[target], NULL);
|
|
|
+ }
|
|
|
|
|
|
switch(ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc)
|
|
|
{
|
|
|
case _AuthorizeSrc_Local:
|
|
|
+ dispenser = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[target].ParentDispensetIndex;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser].AuthorizeStatus = *AuthorizeStatus;
|
|
|
// update dispenser authorizing timeout (local start)
|
|
|
gettimeofday(&_DispenserAuthorizing_Time[target], NULL);
|
|
|
break;
|
|
|
case _AuthorizeSrc_Remote:
|
|
|
- // update connector authorizing timeout (remote start)
|
|
|
- gettimeofday(&_ConnectorAuthorizing_Time[target], NULL);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -6121,44 +6085,20 @@ int main(void)
|
|
|
//if(isDetectPlugin())
|
|
|
if(IsConnectorAuthorizeSuccess(gun_index))
|
|
|
{
|
|
|
- if(chargingInfo[gun_index]->ConnectorPlugIn &&
|
|
|
- chargingInfo[gun_index]->IsAvailable &&
|
|
|
- chargingInfo[gun_index]->SystemStatus == S_IDLE &&
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteStatus == _CRS_Preparing)
|
|
|
+ if(chargingInfo[gun_index]->IsAvailable &&
|
|
|
+ chargingInfo[gun_index]->SystemStatus == S_IDLE)
|
|
|
{
|
|
|
- AddPlugInTimes(gun_index);
|
|
|
- ChangeGunSelectByIndex(gun_index);
|
|
|
- PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
|
|
|
- setChargerMode(gun_index, MODE_REASSIGN_CHECK);
|
|
|
-
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Local)
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Remote)
|
|
|
{
|
|
|
- AuthorizingSettingInitial(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].ParentDispensetIndex, _AuthorizeSrc_Local);
|
|
|
+ PRINTF_FUNC("Connector %d remote start charging", gun_index + 1);
|
|
|
}
|
|
|
- else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Remote)
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Local)
|
|
|
{
|
|
|
- AuthorizingSettingInitial(gun_index, _AuthorizeSrc_Remote);
|
|
|
+ PRINTF_FUNC("Connector %d swipe rfid start charging", gun_index + 1);
|
|
|
}
|
|
|
- continue;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.NeedCleanAuthorizeInfo)
|
|
|
- {
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.StartWaitPlug = false;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.NeedCleanAuthorizeInfo = false;
|
|
|
-
|
|
|
- PRINTF_FUNC("Connector %d Stop Wait Plug In", gun_index + 1);
|
|
|
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Local)
|
|
|
- {
|
|
|
- AuthorizingSettingInitial(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].ParentDispensetIndex, _AuthorizeSrc_Local);
|
|
|
- }
|
|
|
- else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Remote)
|
|
|
- {
|
|
|
- AuthorizingSettingInitial(gun_index, _AuthorizeSrc_Remote);
|
|
|
- }
|
|
|
- }
|
|
|
+ setChargerMode(gun_index, MODE_AUTHORIZING);
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -6236,6 +6176,73 @@ int main(void)
|
|
|
ReleaseAlarmCode(gun_index);
|
|
|
}
|
|
|
break;
|
|
|
+ case S_AUTHORIZING:
|
|
|
+ if(isModeChange(gun_index))
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("S_AUTHORIZING================================== %x \n", gun_index);
|
|
|
+ ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
|
|
|
+ ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
|
|
|
+ StopSystemTimeoutDet();
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable = false;
|
|
|
+ gettimeofday(&_ConnectorAuthorizing_Time[gun_index], NULL);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(GetTimeoutValue(_ConnectorAuthorizing_Time[gun_index]) / uSEC_VAL >= FORCE_BALANCE_TIME)
|
|
|
+ {
|
|
|
+ FouceAnnounceAccountBalance(gun_index);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Remote)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.RemoteStartConfirm)
|
|
|
+ {
|
|
|
+ // sync with dispenser
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.RemoteStartConfirm = false;
|
|
|
+ gettimeofday(&_ConnectorAuthorizing_Time[gun_index], NULL);
|
|
|
+ PRINTF_FUNC("Sync with Connector %d through remote start", gun_index + 1);
|
|
|
+ FouceAnnounceAccountBalance(gun_index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType == _AuthorizeSrc_Local)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.SwipeRfidConfirm)
|
|
|
+ {
|
|
|
+ // sync with dispenser
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.SwipeRfidConfirm = false;
|
|
|
+ gettimeofday(&_ConnectorAuthorizing_Time[gun_index], NULL);
|
|
|
+ PRINTF_FUNC("Sync with Connector %d through swipe rfid", gun_index + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(GetTimeoutValue(_ConnectorAuthorizing_Time[gun_index]) / uSEC_VAL >= _connectionTimeout)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("*********** Connector id %d Plug In Timeout ***********\n", index + 1);
|
|
|
+ setChargerMode(gun_index, MODE_IDLE);
|
|
|
+ AuthorizingSettingInitial(gun_index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(chargingInfo[gun_index]->ConnectorPlugIn &&
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteStatus == _CRS_Preparing)
|
|
|
+ {
|
|
|
+ AddPlugInTimes(gun_index);
|
|
|
+ ChangeGunSelectByIndex(gun_index);
|
|
|
+ PRINTF_FUNC("index = %d, CardNumber = %s \n", gun_index, chargingInfo[gun_index]->StartUserId);
|
|
|
+ setChargerMode(gun_index, MODE_REASSIGN_CHECK);
|
|
|
+ AuthorizingSettingInitial(gun_index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType);
|
|
|
+ }
|
|
|
+ else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.NeedCleanAuthorizeInfo)
|
|
|
+ {
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.StartWaitPlug = false;
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.NeedCleanAuthorizeInfo = false;
|
|
|
+
|
|
|
+ PRINTF_FUNC("*********** Connector id %d User Stop Plug In ***********\n", index + 1);
|
|
|
+ setChargerMode(gun_index, MODE_IDLE);
|
|
|
+ AuthorizingSettingInitial(gun_index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.AuthorizeRequestType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
case S_REASSIGN_CHECK:
|
|
|
{
|
|
|
if (isModeChange(gun_index))
|
|
@@ -6738,6 +6745,7 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //if((chargingInfo[gun_index]->ConnectorPlugIn == NO || ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable == false || ShmOCPP16Data->MsMsg.bits.ResetReq) &&
|
|
|
if((chargingInfo[gun_index]->ConnectorPlugIn == NO || ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable == false) &&
|
|
|
ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
|
|
|
{
|