|
@@ -142,13 +142,14 @@ struct RelayModuleData *ShmRelayModuleData[2];
|
|
|
struct LedModuleData *ShmLedModuleData;
|
|
|
struct OCPP16Data *ShmOCPP16Data;
|
|
|
|
|
|
-struct ChargingInfoData *chargingInfo[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY + GENERAL_GUN_QUANTITY];
|
|
|
+struct ChargingInfoData *chargingInfo[CONNECTOR_QUANTITY];
|
|
|
struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
|
|
|
-struct timeb startChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
-struct timeb endChargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
+struct timeb startChargingTime[CONNECTOR_QUANTITY];
|
|
|
+struct timeb endChargingTime[CONNECTOR_QUANTITY];
|
|
|
|
|
|
struct timeval _ConnectorAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
struct timeval _DispenserAuthorizing_Time[CONNECTOR_QUANTITY];
|
|
|
+int chargingTime[CONNECTOR_QUANTITY];
|
|
|
|
|
|
|
|
|
byte _gunIndex = 0;
|
|
@@ -167,7 +168,7 @@ bool isModelNameMatch = true;
|
|
|
|
|
|
|
|
|
|
|
|
-char* fwVersion = "V0.02.00.0000.00";
|
|
|
+char* fwVersion = "D0.04.00.0000.00";
|
|
|
|
|
|
sqlite3 *localDb;
|
|
|
bool isDb_ready;
|
|
@@ -1091,8 +1092,8 @@ void InitEthernet()
|
|
|
system(tmpbuf);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ InitialDispenserDhcpServerConfig();
|
|
|
+ StartDispenserDhcpServer();
|
|
|
|
|
|
pid_t pid = fork();
|
|
|
uint8_t cnt_pingDNS_Fail;
|
|
@@ -1388,6 +1389,9 @@ void InitialShareMemoryInfo()
|
|
|
sprintf((char *) ShmSysConfigAndInfo->SysInfo.Relay2ModuleHwRev, " ");
|
|
|
sprintf((char *) ShmSysConfigAndInfo->SysInfo.Relay2ModuleFwRev, " ");
|
|
|
sprintf((char *) ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, " ");
|
|
|
+ sprintf((char *) ShmSysConfigAndInfo->SysInfo.LedModuleFwRev, " ");
|
|
|
+ sprintf((char *) ShmSysConfigAndInfo->SysInfo.Connector1FwRev, " ");
|
|
|
+ sprintf((char *) ShmSysConfigAndInfo->SysInfo.Connector2FwRev, " ");
|
|
|
ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp = 0;
|
|
|
ShmSysConfigAndInfo->SysInfo.SystemCriticalTemp = 0;
|
|
|
ShmSysConfigAndInfo->SysInfo.PsuAmbientTemp = 0;
|
|
@@ -1465,7 +1469,7 @@ int Initialization()
|
|
|
|
|
|
|
|
|
|
|
|
- for (byte count = 0; count < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; count++)
|
|
|
+ for (byte count = 0; count < CONNECTOR_QUANTITY; count++)
|
|
|
{
|
|
|
chargingInfo[count]->RemoteStartFlag = NO;
|
|
|
|
|
@@ -3105,6 +3109,10 @@ void PowerCabinetAuthorizingSettingInitial(void)
|
|
|
|
|
|
void AuthorizingSettingInitial(unsigned char index, unsigned char AuthorizeSrc)
|
|
|
{
|
|
|
+ char *str_auth_src[] = {AUTHORIZE_SRC_NONE_DEV, AUTHORIZE_SRC_LOCAL_DEV, AUTHORIZE_SRC_REMOTE_DEV};
|
|
|
+
|
|
|
+ PRINTF_FUNC("*********** %s id %d Authorize Initial ***********", str_auth_src[AuthorizeSrc], index + 1);
|
|
|
+
|
|
|
switch(AuthorizeSrc)
|
|
|
{
|
|
|
case _AuthorizeSrc_Local:
|
|
@@ -3404,12 +3412,12 @@ void PowerCabinetAuthorizeProcess(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[target].AuthorizeStatus != _AuthorizeStatus_Busy)
|
|
|
+ if(*AuthorizeStatus != _AuthorizeStatus_Busy)
|
|
|
{
|
|
|
|
|
|
ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizingCompleted = true;
|
|
|
|
|
|
- if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[target].AuthorizeStatus == _AuthorizeStatus_Pass)
|
|
|
+ if(*AuthorizeStatus == _AuthorizeStatus_Pass)
|
|
|
{
|
|
|
SetConnectorAuthorizeOK(target, ShmSysConfigAndInfo->SysInfo.CabinetSetting.bits.AuthorizeSrc);
|
|
|
}
|
|
@@ -3623,7 +3631,7 @@ bool CheckConnectorTypeStatus()
|
|
|
result = false;
|
|
|
|
|
|
|
|
|
- for(int i = 0; i < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; i++)
|
|
|
+ for(int i = 0; i < CONNECTOR_QUANTITY; i++)
|
|
|
{
|
|
|
chargingInfo[i] = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].GeneralChargingData;
|
|
|
chargingInfo[i]->Index = 0xFF;
|
|
@@ -4382,15 +4390,15 @@ void OcppStartTransation(byte gunIndex)
|
|
|
byte _OcppGunIndex = gunIndex;
|
|
|
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
- PRINTF_FUNC("IdTag = %s \n", ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
|
|
|
+ PRINTF_FUNC("Gun: %d, OCPP Start Transation Index: %d, IdTag = %s \n", chargingInfo[gunIndex]->Index, _OcppGunIndex, ShmOCPP16Data->StartTransaction[_OcppGunIndex].IdTag);
|
|
|
ShmOCPP16Data->CpMsg.bits[_OcppGunIndex].StartTransactionReq = YES;
|
|
|
}
|
|
|
|
|
@@ -4399,15 +4407,15 @@ void OcppStopTransation(byte gunIndex)
|
|
|
byte _OcppGunIndex = gunIndex;
|
|
|
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
- PRINTF_FUNC("IdTag = %s \n", ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
|
|
|
+ PRINTF_FUNC("OCPP Start Transation Index: %d, IdTag = %s \n", _OcppGunIndex, ShmOCPP16Data->StopTransaction[_OcppGunIndex].IdTag);
|
|
|
ShmOCPP16Data->CpMsg.bits[_OcppGunIndex].StopTransactionReq = YES;
|
|
|
}
|
|
|
|
|
@@ -5065,22 +5073,22 @@ void InitialDHCP()
|
|
|
|
|
|
void InitialDispenserDhcpServerConfig(void)
|
|
|
{
|
|
|
- system("echo 'start 192.168.100.10' > /etc/udhcpd.conf");
|
|
|
- system("echo 'end 192.168.100.20' >> /etc/udhcpd.conf");
|
|
|
- system("echo 'interface eth1' >> /etc/udhcpd.conf");
|
|
|
- system("echo 'opt dns 8.8.8.8' >> /etc/udhcpd.conf");
|
|
|
- system("echo 'option subnet 255.255.255.0' >> /etc/udhcpd.conf");
|
|
|
- system("echo 'opt router 192.168.100.1' >> /etc/udhcpd.conf");
|
|
|
- system("echo 'option domain local' >> /etc/udhcpd.conf");
|
|
|
- system("echo 'option lease 86400' >> /etc/udhcpd.conf");
|
|
|
+ system("echo 'start 192.168.100.10' > /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'end 192.168.100.20' >> /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'interface eth1' >> /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'opt dns 8.8.8.8' >> /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'option subnet 255.255.255.0' >> /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'opt router 192.168.100.1' >> /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'option domain local' >> /etc/udhcpd_eth1.conf");
|
|
|
+ system("echo 'option lease 86400' >> /etc/udhcpd_eth1.conf");
|
|
|
|
|
|
usleep(1000);
|
|
|
}
|
|
|
|
|
|
void StartDispenserDhcpServer(void)
|
|
|
{
|
|
|
- system("killall udhcpd");
|
|
|
- system("/usr/sbin/udhcpd /etc/udhcpd.conf > /dev/null &");
|
|
|
+ system("pgrep -f \"udhcpd /etc/udhcpd_eth1.conf\" | xargs kill");
|
|
|
+ system("/usr/sbin/udhcpd /etc/udhcpd_eth1.conf > /dev/null &");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -5432,10 +5440,16 @@ int main(void)
|
|
|
|
|
|
gettimeofday(&_cmdMainPriority_time, NULL);
|
|
|
|
|
|
- PRINTF_FUNC("Gun 1: %d(%s), Gun 2: %d(%s), OCPP: %s",
|
|
|
- chargingInfo[0]->SystemStatus, chargingInfo[0]->IsAvailable ? "Operative" : "Inoperative",
|
|
|
- chargingInfo[1]->SystemStatus, chargingInfo[1]->IsAvailable ? "Operative" : "Inoperative",
|
|
|
+ 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");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if(ShmSysConfigAndInfo->SysWarningInfo.Level == 2)
|
|
@@ -5489,6 +5503,7 @@ int main(void)
|
|
|
PRINTF_FUNC("S_IDLE================================== %x \n", gun_index);
|
|
|
chargingInfo[gun_index]->PresentChargedDuration = 0;
|
|
|
chargingInfo[gun_index]->RemainChargingDuration = 0;
|
|
|
+ chargingTime[gun_index] = 0;
|
|
|
strcpy((char *)chargingInfo[gun_index]->StartDateTime, "");
|
|
|
strcpy((char *)chargingInfo[gun_index]->StopDateTime, "");
|
|
|
strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
|
|
@@ -5580,7 +5595,14 @@ int main(void)
|
|
|
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);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -5931,6 +5953,31 @@ int main(void)
|
|
|
ftime(&endChargingTime[gun_index]);
|
|
|
chargingInfo[gun_index]->PresentChargedDuration = DiffTimeb(startChargingTime[gun_index], endChargingTime[gun_index]);
|
|
|
|
|
|
+
|
|
|
+ chargingInfo[gun_index]->PresentChargingPower = ((float)((chargingInfo[gun_index]->PresentChargingVoltage) * (chargingInfo[gun_index]->PresentChargingCurrent)) / 1000);
|
|
|
+
|
|
|
+ if (chargingTime[gun_index] == 0 || chargingTime[gun_index] > chargingInfo[gun_index]->PresentChargedDuration)
|
|
|
+ {
|
|
|
+ chargingTime[gun_index] = chargingInfo[gun_index]->PresentChargedDuration;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int passTime = chargingInfo[gun_index]->PresentChargedDuration - chargingTime[gun_index];
|
|
|
+
|
|
|
+ if(passTime > 0)
|
|
|
+ {
|
|
|
+ float changingPow = (chargingInfo[gun_index]->PresentChargingPower) * passTime / 3600;
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
|
|
|
+ {
|
|
|
+ chargingInfo[gun_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
|
|
|
+ }
|
|
|
+
|
|
|
+ chargingInfo[gun_index]->PresentChargedEnergy += changingPow;
|
|
|
+ chargingInfo[gun_index]->PowerConsumption += changingPow;
|
|
|
+ chargingTime[gun_index] = chargingInfo[gun_index]->PresentChargedDuration;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (chargingInfo[gun_index]->Type == _Type_Chademo)
|
|
|
{
|
|
|
if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
|