瀏覽代碼

2020.11.02 / Wendell
Actions:
1. DO360 V0.04 release for second charger for Audi

Files:
1. As follow by commit history

Image version : V0.04.XX.XXXX.XX

Wendell 4 年之前
父節點
當前提交
4e379740d0

二進制
EVSE/Projects/DO360/Apps/FactoryConfig


二進制
EVSE/Projects/DO360/Apps/Module_EvComm


+ 20 - 2
EVSE/Projects/DO360/Apps/Module_EvComm.c

@@ -1101,6 +1101,7 @@ void ConnectorTypeBindingHandler(unsigned char dispenserIndex, unsigned char *ty
 	{
 		unsigned char gunIndex = ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenserIndex].ConnectorID[i] - 1;
 		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].ParentDispensetIndex = dispenserIndex;
+		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].GeneralChargingData.Index = gunIndex;
 		ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gunIndex].GeneralChargingData.Type = type[i];
 	}
 }
@@ -1426,7 +1427,6 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
                 if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus >= _CRS_Preparing &&
                     ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus <= _CRS_Charging)
                 {
-
                     if(!ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.PermissionRequest)
                     {
                         ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].Parameter.bits.PermissionRequest = true;
@@ -1444,6 +1444,7 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
                     // keep wait
                 }
                 break;
+
             case S_CHARGING:
                 if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Preparing ||
                     ShmSysConfigAndInfo->SysInfo.ConnectorInfo[packet->Header.id - 1].RemoteStatus == _CRS_Charging)
@@ -1456,6 +1457,16 @@ unsigned char ChargingPermissionHandler(struct PACKET_STRUCTURE *packet, unsigne
                     PRINTF_FUNC("Dispenser index %d connector id %d remote status not in charging mode", dispenserIndex, packet->Header.id);
                 }
                 break;
+
+            case S_IDLE:
+            case S_TERMINATING:
+            case S_COMPLETE:
+            case S_ALARM:
+            case S_RESERVATION:
+            case S_MAINTAIN:
+                permission = _DAS_NotAllowed;
+                break;
+
             default:
                 break;
 	    }
@@ -1746,7 +1757,14 @@ void InitDispenserInfo(void)
 {
 	for(int i = 0; i < GENERAL_GUN_QUANTITY; i++)
 	{
-		memset(&ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i], 0x00, sizeof(struct ConnectorInfoData));
+		//memset(&ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i], 0x00, sizeof(struct ConnectorInfoData));
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].RemoteStatus = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].Enable = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].ReadyToCharge = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].ParentDispensetIndex = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].Parameter.Value = 0;
+	    ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].AuthorizeStatus = 0;
+	    memset(&ShmSysConfigAndInfo->SysInfo.ConnectorInfo[i].WarningInfo, 0x00, sizeof(struct WARNING_CODE_INFO));
 	}
 	memset(&ShmSysConfigAndInfo->SysInfo.DispenserInfo, 0x00, sizeof(struct DispenserInfoData));
 }

二進制
EVSE/Projects/DO360/Apps/Module_EventLogging


二進制
EVSE/Projects/DO360/Apps/Module_InternalComm


二進制
EVSE/Projects/DO360/Apps/Module_LcmControl


二進制
EVSE/Projects/DO360/Apps/Module_PrimaryComm


二進制
EVSE/Projects/DO360/Apps/Module_PsuComm


+ 0 - 6
EVSE/Projects/DO360/Apps/Module_PsuComm.c

@@ -884,8 +884,6 @@ void GetPresentOutputFCallback(byte group, float outVol, float outCur)
 
 					_cur_buf /= 10;
 					chargingInfo[count]->PresentChargingCurrent = _cur_buf;
-
-					chargingInfo[count]->PresentChargingPower = ((float)((chargingInfo[count]->PresentChargingVoltage) * (chargingInfo[count]->PresentChargingCurrent)) / 1000);
 				}
 			}
 
@@ -901,8 +899,6 @@ void GetPresentOutputFCallback(byte group, float outVol, float outCur)
 
 				_cur_buf /= 10;
 				chargingInfo[group]->PresentChargingCurrent = _cur_buf;
-
-				chargingInfo[group]->PresentChargingPower = ((float)((chargingInfo[group]->PresentChargingVoltage) * (chargingInfo[group]->PresentChargingCurrent)) / 1000);
 			}
 		}
 		else
@@ -916,8 +912,6 @@ void GetPresentOutputFCallback(byte group, float outVol, float outCur)
 
 			_cur_buf /= 10;
 			chargingInfo[group]->PresentChargingCurrent = _cur_buf;
-
-			chargingInfo[group]->PresentChargingPower = ((float)((chargingInfo[group]->PresentChargingVoltage) * (chargingInfo[group]->PresentChargingCurrent)) / 1000);
 		}
 }
 

二進制
EVSE/Projects/DO360/Apps/ReadCmdline


二進制
EVSE/Projects/DO360/Apps/main


+ 77 - 30
EVSE/Projects/DO360/Apps/main.c

@@ -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];
 
 // for initial index to check EV board type is correct
 byte _gunIndex = 0;
@@ -167,7 +168,7 @@ bool isModelNameMatch = true;
 
 //int rfidFd = -1;
 //char* rfidPortName = "/dev/ttyS2";
-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);
 
 	// DO360 DHCP Server
-	//InitialDispenserDhcpServerConfig();
-	//StartDispenserDhcpServer();
+	InitialDispenserDhcpServerConfig();
+	StartDispenserDhcpServer();
 
 	pid_t pid = fork();
 	uint8_t cnt_pingDNS_Fail;
@@ -1388,6 +1389,9 @@ void InitialShareMemoryInfo()
 	sprintf((char *) ShmSysConfigAndInfo->SysInfo.Relay2ModuleHwRev, " ");		//DO360 RC2
 	sprintf((char *) ShmSysConfigAndInfo->SysInfo.Relay2ModuleFwRev, " ");		//DO360 RC2
 	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()
 	//rfidFd = InitialRfidPort();
 
 //	int pinOut[2] = { 116, 115 };
-	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)
                     {
                         // authorize completed
                         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;
 
 		//DO360 charging info default setting
-		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;
 
 	// 如果有 AC 槍,而現在是 DC 第二把槍進入充電
-	if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount == 1 && gunIndex == 1)
-		_OcppGunIndex = 2;
+//	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;
 
 	// 如果有 AC 槍,而現在是 DC 第二把槍進入充電
-	if (ShmSysConfigAndInfo->SysConfig.AcConnectorCount == 1 && gunIndex == 1)
-		_OcppGunIndex = 2;
+//	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");
+
+//			PRINTF_FUNC("Gun 1: %d(%d), Gun 2: %d(%d), Gun 3: %d(%d), Gun 4: %d(%d)",
+//                chargingInfo[0]->Index, chargingInfo[0]->Type,
+//                chargingInfo[1]->Index, chargingInfo[1]->Type,
+//                chargingInfo[2]->Index, chargingInfo[2]->Type,
+//                chargingInfo[3]->Index, chargingInfo[3]->Type);
 		}
 
 		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]);
 
+                    // 計算 Power
+                    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)

二進制
EVSE/Projects/DO360/Images/ramdisk.gz