Эх сурвалжийг харах

2020-02-19 / Alston Lin

Actions
1. Updating DS60-120 fireware source code
Files
1. As follow commit history
Alston 5 жил өмнө
parent
commit
96e6b80e26

+ 36 - 36
EVSE/Modularization/Infypwr_PsuCommObj.c

@@ -40,13 +40,13 @@ struct Current_cmd_Proc Psu_cmd={
 		0x0E001C00,
 };
 
-#define DEBUG						1
+#define DEBUG_LIB						0
 
-void PRINTF_FUNC(char *string, ...);
+void PRINTF_LIB_FUNC(char *string, ...);
 
-void PRINTF_FUNC(char *string, ...)
+void PRINTF_LIB_FUNC(char *string, ...)
 {
-	if (DEBUG)
+	if (DEBUG_LIB)
 	{
 		va_list args;
 		char buffer[4096];
@@ -121,7 +121,7 @@ int InitCanBus()
 	struct sockaddr_can		addr0;
 
 	system("/sbin/ip link set can1 down");
-	system("/sbin/ip link set can1 type can bitrate 125000 restart-ms 100");
+	system("/sbin/ip link set can1 type can bitrate 500000 restart-ms 100");
 	system("/sbin/ip link set can1 up");
 
 	s0 = socket(PF_CAN, SOCK_RAW, CAN_RAW);
@@ -131,21 +131,21 @@ int InitCanBus()
    	if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct	timeval)) < 0)
 	{
 		#ifdef SystemLogMessage
-   		PRINTF_FUNC("Set SO_RCVTIMEO NG");
+   		PRINTF_LIB_FUNC("Set SO_RCVTIMEO NG");
 		#endif
 	}
 	nbytes=40960;
 	if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0)
 	{
 		#ifdef SystemLogMessage
-		PRINTF_FUNC("Set SO_RCVBUF NG");
+		PRINTF_LIB_FUNC("Set SO_RCVBUF NG");
 		#endif
 	}
 	nbytes=40960;
 	if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0)
 	{
 		#ifdef SystemLogMessage
-		PRINTF_FUNC("Set SO_SNDBUF NG");
+		PRINTF_LIB_FUNC("Set SO_SNDBUF NG");
 		#endif
 	}
 
@@ -184,8 +184,8 @@ void ReceiveDataFromCanBus()
             //if master id
             if(target == 0xF0)
             {
-                //PRINTF_FUNC("Get-INFYPWR-Msg : %08x - %02x%02x%02x%02x%02x%02x%02x%02x\n", frame.can_id,frame.data[0], frame.data[1], frame.data[2], frame.data[3],frame.data[4], frame.data[5], frame.data[6], frame.data[7]);
-                //PRINTF_FUNC("Get-INFYPWR-Msg : %08x cmd:%08x target:%02x group:%02x address:%02x\n", frame.can_id, intCmd, target, group, address);
+                //PRINTF_LIB_FUNC("Get-INFYPWR-Msg : %08x - %02x%02x%02x%02x%02x%02x%02x%02x\n", frame.can_id,frame.data[0], frame.data[1], frame.data[2], frame.data[3],frame.data[4], frame.data[5], frame.data[6], frame.data[7]);
+                //PRINTF_LIB_FUNC("Get-INFYPWR-Msg : %08x cmd:%08x target:%02x group:%02x address:%02x\n", frame.can_id, intCmd, target, group, address);
 
     			switch (intCmd)
     			{
@@ -239,7 +239,7 @@ void ReceiveDataFromCanBus()
         			        ((word) frame.data[0] * 256 ) + (word) frame.data[1],
         			        ((word) frame.data[2] * 256 ) + (word) frame.data[3]);
                     }
-                    //PRINTF_FUNC("INFYPWR_GET_VEXT_IAVAIL_MSG \n");
+                    //PRINTF_LIB_FUNC("INFYPWR_GET_VEXT_IAVAIL_MSG \n");
                         break;
 
                     case INFYPWR_GET_MISC_INFO_MSG:
@@ -250,7 +250,7 @@ void ReceiveDataFromCanBus()
         			        ((word) frame.data[0] * 256 ) + (word) frame.data[1],
         			        (((int) frame.data[4] << 24) + ((int) frame.data[5] << 16) + ((int) frame.data[6] << 8) + (int) frame.data[7])  & 0x00ffffff);
                     }
-                    //PRINTF_FUNC("INFYPWR_GET_MISC_INFO_MSG \n");
+                    //PRINTF_LIB_FUNC("INFYPWR_GET_MISC_INFO_MSG \n");
                         break;
 
 
@@ -350,7 +350,7 @@ bool InitialCommunication()
 
 	if(CanFd < 0)
 	{
-		PRINTF_FUNC("Init can bus fail.\n");
+		PRINTF_LIB_FUNC("Init can bus fail.\n");
 		return false;
 	}
 
@@ -361,7 +361,7 @@ bool InitialCommunication()
 	}
     else if(recFork > 0)
     {
-    	PRINTF_FUNC("fork fail\n");
+    	PRINTF_LIB_FUNC("fork fail\n");
     }
 
     return true;
@@ -380,7 +380,7 @@ void RequestModuleTotalMumbert(void)
 //void PsuAddressAssignment(byte phy_addr, char *serial_number, byte real_addr, byte group)
 void PsuAddressAssignment(byte phy_addr, byte group)
 {
-	PRINTF_FUNC("phy_addr = %d, group = %d \n", phy_addr, group);
+	PRINTF_LIB_FUNC("phy_addr = %d, group = %d \n", phy_addr, group);
 	uint cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_GROUP_ASSINGMENT_MSG | (phy_addr << 8) | INFYPWR_MASTER_TXID;
 
 	byte data[8];
@@ -393,7 +393,7 @@ void PsuAddressAssignment(byte phy_addr, byte group)
 void GetStatus(byte group, byte address)
 {
 	//如果用 group 發送 (該 group 內的模組會自動依序回應)
-	//PRINTF_FUNC("PSU_C_DLL : GetStatus. group = %x, address = %x \n", group, address);
+	//PRINTF_LIB_FUNC("PSU_C_DLL : GetStatus. group = %x, address = %x \n", group, address);
 	uint cmd;
 	byte data[8];
 
@@ -491,7 +491,7 @@ void SetMiscInfo(byte group, byte address, unsigned short CmdType, unsigned int
 	int cmd;
 	byte data[8];
 
-	//PRINTF_FUNC("cmd = %x \n", cmd);
+	//PRINTF_LIB_FUNC("cmd = %x \n", cmd);
 
 	memset(data, 0x00, ARRAY_SIZE(data));
 
@@ -513,13 +513,13 @@ void SetMiscInfo(byte group, byte address, unsigned short CmdType, unsigned int
     if(group == SET_GROUP_CMD)
     {
         cmd = INFYPWR_GROUP_CMD | INFYPWR_SET_MISC_INFO_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-        //PRINTF_FUNC("Module-onoff(g) :%08x - %d - %d \n",cmd, data[0],address);
+        //PRINTF_LIB_FUNC("Module-onoff(g) :%08x - %d - %d \n",cmd, data[0],address);
     }
     //如果是模組命令則找出模組對應到 (英飛源的ID)
     else
     {
         cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_MISC_INFO_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-        // PRINTF_FUNC("Modele-onoff(M) :%08x - %d - %d \n",cmd, data[0],address);
+        // PRINTF_LIB_FUNC("Modele-onoff(M) :%08x - %d - %d \n",cmd, data[0],address);
     }
 
 	SendCmdToPsu(cmd, data, sizeof(data));
@@ -527,7 +527,7 @@ void SetMiscInfo(byte group, byte address, unsigned short CmdType, unsigned int
 
 void GetPresentInputVol(byte group, byte address)
 {
-	//PRINTF_FUNC("PSU_C_DLL : GetPresentInputVol. group = %x, address = %x \n", group, address);
+	//PRINTF_LIB_FUNC("PSU_C_DLL : GetPresentInputVol. group = %x, address = %x \n", group, address);
 	//如果用 group 發送 (該 group 內的模組會自動依序回應)
 	uint cmd;
 	byte data[8];
@@ -570,7 +570,7 @@ void GetAvailableCap(byte group, byte address, short _outputVol)
 
 void GetPresentOutput(byte group, byte address)
 {
-	//PRINTF_FUNC("PSU_C_DLL : GetPresentOutput. group = %x, address = %x \n", group, address);
+	//PRINTF_LIB_FUNC("PSU_C_DLL : GetPresentOutput. group = %x, address = %x \n", group, address);
 	int cmd;
 	byte data[8];
 
@@ -597,13 +597,13 @@ void SetPresentOutput(byte group, byte address, float vol, float cur, float Avai
     //if (cur >= AvailableCur)
 	//cur = AvailableCur;
 
-	//if(vol == 0 && cur == 0)PRINTF_FUNC("output v=0 a =0 \n");
-    //PRINTF_FUNC("group = %d, address = %d, vol = %f, cur = %f \n", group, address, vol, cur);
+	//if(vol == 0 && cur == 0)PRINTF_LIB_FUNC("output v=0 a =0 \n");
+    //PRINTF_LIB_FUNC("group = %d, address = %d, vol = %f, cur = %f \n", group, address, vol, cur);
     //英飛源使用 0.001 精度
     uint vol2 =  vol * 100;
     uint cur2 =  cur * 100;
 
-    //PRINTF_FUNC("vol = %f, cur = %f, vol2 = %d, cur2 = %d \n", vol, cur, vol2, cur2);
+    //PRINTF_LIB_FUNC("vol = %f, cur = %f, vol2 = %d, cur2 = %d \n", vol, cur, vol2, cur2);
 
  	// 電壓
 	data[0] = (vol2 >> 24) & 0xff;
@@ -621,7 +621,7 @@ void SetPresentOutput(byte group, byte address, float vol, float cur, float Avai
 //    if(group == SET_GROUP_CMD)
 //    {
 //        cmd = INFYPWR_GROUP_CMD | INFYPWR_SET_GROUP_PERSENT_OUTPUT_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-//        //PRINTF_FUNC("setout(G) :%08x /n",cmd);
+//        //PRINTF_LIB_FUNC("setout(G) :%08x /n",cmd);
 //    }
 //    //如果是模組命令則找出模組對應到 (英飛源的ID)
 //    else
@@ -646,10 +646,10 @@ void SetPresentOutput(byte group, byte address, float vol, float cur, float Avai
 //        }
 //        */
 //        cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_MODULE_PERSENT_OUTPUT_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-//        //PRINTF_FUNC("setout(M) :%08x /n",cmd);
+//        //PRINTF_LIB_FUNC("setout(M) :%08x /n",cmd);
 //    }
 
-	PRINTF_FUNC("typecmd = %02x, addr = %02x ,vol = %d, tot_Amp = %f, need_cur = %d, \n",
+	PRINTF_LIB_FUNC("typecmd = %02x, addr = %02x ,vol = %d, tot_Amp = %f, need_cur = %d, \n",
 			group, address, vol2, AvailableCur, cur2);
 	SendCmdToPsu(cmd, data, sizeof(data));
 }
@@ -671,13 +671,13 @@ void EnableGreenLedFlash(byte group, byte address, byte value)
 //    if(group == SET_GROUP_CMD)
 //    {
 //        cmd = INFYPWR_GROUP_CMD | INFYPWR_SET_GREEN_KED_FLASH_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-//        //PRINTF_FUNC("Green Led Flash(g) :%08x - %d - %d \n",cmd, data[0],address);
+//        //PRINTF_LIB_FUNC("Green Led Flash(g) :%08x - %d - %d \n",cmd, data[0],address);
 //    }
 //    //如果是模組命令則找出模組對應到 (英飛源的ID)
 //    else
 //    {
 //        cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_GREEN_KED_FLASH_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-//        //PRINTF_FUNC("Green Led Flash(M) :%08x - %d - %d \n",cmd, data[0],address);
+//        //PRINTF_LIB_FUNC("Green Led Flash(M) :%08x - %d - %d \n",cmd, data[0],address);
 //    }
 
 	SendCmdToPsu(cmd, data, sizeof(data));
@@ -700,13 +700,13 @@ void EnableWalkInMode(byte group, byte address, byte value)
     if(group == SET_GROUP_CMD)
     {
         cmd = INFYPWR_GROUP_CMD | INFYPWR_SET_WALKIN_MODE_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-        //PRINTF_FUNC("WalkIn(g) :%08x - %d - %d \n",cmd, data[0],address);
+        //PRINTF_LIB_FUNC("WalkIn(g) :%08x - %d - %d \n",cmd, data[0],address);
     }
     //如果是模組命令則找出模組對應到 (英飛源的ID)
     else
     {
         cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_WALKIN_MODE_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-        // PRINTF_FUNC("WalkIn(M) :%08x - %d - %d \n",cmd, data[0],address);
+        // PRINTF_LIB_FUNC("WalkIn(M) :%08x - %d - %d \n",cmd, data[0],address);
     }
 
 	SendCmdToPsu(cmd, data, sizeof(data));
@@ -729,13 +729,13 @@ void EnableSleepMode(byte group, byte address, byte value)
     if(group == SET_GROUP_CMD)
     {
         cmd = INFYPWR_GROUP_CMD | INFYPWR_SET_SLEEP_MODE_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-        //PRINTF_FUNC("SleepMode(g) :%08x - %d - %d \n",cmd, data[0],address);
+        //PRINTF_LIB_FUNC("SleepMode(g) :%08x - %d - %d \n",cmd, data[0],address);
     }
     //如果是模組命令則找出模組對應到 (英飛源的ID)
     else
     {
         cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_SLEEP_MODE_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-         //PRINTF_FUNC("SleepMode(M) :%08x - %d - %d \n",cmd, data[0],address);
+         //PRINTF_LIB_FUNC("SleepMode(M) :%08x - %d - %d \n",cmd, data[0],address);
     }
 
 	SendCmdToPsu(cmd, data, sizeof(data));
@@ -770,7 +770,7 @@ void EnableOutputPower(byte group, byte address, byte value)
 	int cmd;
 	byte data[8];
 
-	//PRINTF_FUNC("cmd = %x \n", cmd);
+	//PRINTF_LIB_FUNC("cmd = %x \n", cmd);
 
 	memset(data, 0x00, ARRAY_SIZE(data));
 
@@ -786,13 +786,13 @@ void EnableOutputPower(byte group, byte address, byte value)
 //    if(group == SET_GROUP_CMD)
 //    {
 //        cmd = INFYPWR_GROUP_CMD | INFYPWR_SET_POWER_SWITCH_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-//        //PRINTF_FUNC("Module-onoff(g) :%08x - %d - %d \n",cmd, data[0],address);
+//        //PRINTF_LIB_FUNC("Module-onoff(g) :%08x - %d - %d \n",cmd, data[0],address);
 //    }
 //    //如果是模組命令則找出模組對應到 (英飛源的ID)
 //    else
 //    {
 //        cmd = INFYPWR_MODULE_CMD | INFYPWR_SET_POWER_SWITCH_MSG | (address << 8) | INFYPWR_MASTER_TXID;
-//        // PRINTF_FUNC("Modele-onoff(M) :%08x - %d - %d \n",cmd, data[0],address);
+//        // PRINTF_LIB_FUNC("Modele-onoff(M) :%08x - %d - %d \n",cmd, data[0],address);
 //    }
 
 	SendCmdToPsu(cmd, data, sizeof(data));

+ 1 - 1
EVSE/Projects/DS60-120/Apps/Config.h

@@ -10,7 +10,7 @@
 typedef unsigned char			byte;
 
 #define TOTAL_QUANTITY_GUN			4				//Max Count
-#define DEBUG						1
+#define DEBUG						0
 
 #define MODE_BOOT					0
 #define MODE_IDLE					1

+ 7 - 5
EVSE/Projects/DS60-120/Apps/FactoryConfig.c

@@ -102,7 +102,8 @@ int main(int argc,char *argv[])
 	 * TODO: Set factory default configuration
 	*/
 	//********** System **********// udhcpc -i eth1 -s ./dhcp_script/eth1.script
-	strcpy((char *)SysConfig.ModelName, "DSYE601J0ET2PH");
+	//
+	strcpy((char *)SysConfig.ModelName, "DSYE601J0EW2PH");
 	strcpy((char *)SysConfig.SerialNumber, "");
 
 	memset(SysConfig.SystemId, 0x00, sizeof(SysConfig.SystemId));
@@ -122,9 +123,10 @@ int main(int argc,char *argv[])
 	SysConfig.Ccs2PlugInTimes = 0;
 	SysConfig.ChademoPlugInTimes = 0;
 	//********** Charging **********//
+	SysConfig.RatingCurrent = 1200;			// 最大可輸出電流 120 A
 	SysConfig.MaxChargingEnergy = 0;
-	SysConfig.MaxChargingPower = 0;
-	SysConfig.MaxChargingCurrent = 0;
+	SysConfig.MaxChargingPower = 600; 		// 最大功率 : 跟著 model name 跑
+	SysConfig.MaxChargingCurrent = 1200;		// 最大可輸出電流 120 A
 	SysConfig.MaxChargingDuration = 0;
 	SysConfig.PhaseLossPolicy = 0;
 	for(unsigned char i = 0; i < 10; i++)
@@ -169,12 +171,12 @@ int main(int argc,char *argv[])
 	SysConfig.TelecomInterface.TelcomNetworkConn = 0;
 	strcpy((char *)SysConfig.chargePointVendor, "Phihong Technology");
 	//********** Backend **********//
-	SysConfig.BackendConnTimeout=300; //300 seconds
+	SysConfig.BackendConnTimeout = 300; //300 seconds
 	SysConfig.OfflinePolicy = 0;
 	SysConfig.OfflineMaxChargeEnergy = 0;
 	SysConfig.OfflineMaxChargeDuration = 0;
 	strcpy((char *) SysConfig.OcppServerURL, "ws://test.evsocket.phihong.com.cn:2012/ocpp/");
-	strcpy((char *) SysConfig.ChargeBoxId, "DemoDC");
+	strcpy((char *) SysConfig.ChargeBoxId, "DemoDC_Alston");
 
 	//copy default configuration to pointer
 	memcpy(ptr,&SysConfig,sizeof(struct SysConfigData));

+ 3 - 3
EVSE/Projects/DS60-120/Apps/Makefile

@@ -27,7 +27,7 @@ EvCommTask:
 	
 EventLoggingTask:
 	rm -f Module_EventLogging;
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o Module_EventLogging.o Module_EventLogging.c
+	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Module_EventLogging.o Module_EventLogging.c
 	$(CC) -o Module_EventLogging Module_EventLogging.o 	
 	cp -f Module_EventLogging ../Images/root	
 	
@@ -46,8 +46,8 @@ LcmControlTask:
 
 PrimaryCommTask:
 	rm -f Module_PrimaryComm; 
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o Module_PrimaryComm.o Module_PrimaryComm.c
-	$(CC) -O0 -g3 -Wall -c -fmessage-length=0 -o PrimaryComm.o PrimaryComm.c
+	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o Module_PrimaryComm.o Module_PrimaryComm.c
+	$(CC) -includeConfig.h -O0 -g3 -Wall -c -fmessage-length=0 -o PrimaryComm.o PrimaryComm.c
 	$(CC) -o Module_PrimaryComm Module_PrimaryComm.o PrimaryComm.o
 	cp -f Module_PrimaryComm ../Images/root	
 

+ 17 - 21
EVSE/Projects/DS60-120/Apps/Module_EvComm.c

@@ -38,7 +38,6 @@
 #define STOP				0
 #define YES					1
 #define NO					0
-#define DEMO 				0
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
@@ -867,7 +866,7 @@ void CANReceiver()
 						{
 							memcpy(ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
 							ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-							//PRINTF_FUNC("chademo ver. : %s\n", ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
+							PRINTF_FUNC("chademo ver. : %s\n", ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
 						}
 						else if (_chargingData[targetGun]->Type == _Type_CCS_2)
 						{
@@ -875,7 +874,7 @@ void CANReceiver()
 							{
 								memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, frame.data, ARRAY_SIZE(frame.data));
 								ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
-								//PRINTF_FUNC("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
+								PRINTF_FUNC("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
 							}
 						}
 					}
@@ -1038,12 +1037,6 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
 	float pow2 = 0, cur2 = 0;
 	float vol = 0;
 
-	chargingData_1->AvailableChargingPower = 300;
-	chargingData_2->AvailableChargingPower = 300;
-
-	chargingData_1->AvailableChargingCurrent = 500;
-	chargingData_2->AvailableChargingCurrent = 600;
-
 	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
 	{
 		pow1 = chargingData_1->DeratingChargingPower;
@@ -1165,7 +1158,6 @@ int main(int argc, char *argv[])
 	CANReceiver();
 
 	byte priorityLow = 1;
-#if (!DEMO)
 	while(CanFd)
 	{
 		for(byte _index = 0; _index < gun_count; _index++)
@@ -1197,7 +1189,9 @@ int main(int argc, char *argv[])
 			switch (_chargingData[_index]->SystemStatus)
 			{
 				case S_IDLE:
+				case S_RESERVATION:
 					_chargingData[_index]->PresentChargedEnergy = 0;
+					_chargingData[_index]->PresentChargingPower = 0;
 					_chargingData[_index]->GroundFaultStatus = GFD_WAIT;
 					_chargingData[_index]->StopChargeFlag = NO;
 					chargingTime[_index] = 0;
@@ -1214,6 +1208,7 @@ int main(int argc, char *argv[])
 					if (priorityLow == 1)
 					{
 						maxChargingCur[_index] = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent;
+						maxChargingPow = ShmSysConfigAndInfo->SysConfig.MaxChargingPower;
 					}
 					break;
 				case S_PREPARING_FOR_EV:
@@ -1384,23 +1379,26 @@ int main(int argc, char *argv[])
 				{
 					if (priorityLow == 1)
 					{
+						float maxVol, maxCur;
+
 						// ¼ÎºÝ¿é¥X¯à¤O
 						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
 						{
-							SetChargingPermission(_index, STOP,
-									_chargingData[_index]->DeratingChargingPower,
-									_chargingData[_index]->DeratingChargingCurrent,
-									_chargingData[_index]->MaximumChargingVoltage,
-									_chargingData[_index]->Evboard_id);
+							maxVol = _chargingData[_index]->MaximumChargingVoltage;
+							maxCur = _chargingData[_index]->DeratingChargingCurrent;
 						}
 						else
 						{
-							SetChargingPermission(_index, STOP,
+							maxVol = _chargingData[_index]->MaximumChargingVoltage;
+							maxCur = _chargingData[_index]->AvailableChargingCurrent;
+						}
+
+						GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
+						SetChargingPermission(_index, STOP,
 									_chargingData[_index]->AvailableChargingPower,
-									_chargingData[_index]->AvailableChargingCurrent,
-									_chargingData[_index]->MaximumChargingVoltage,
+									maxCur,
+									maxVol,
 									_chargingData[_index]->Evboard_id);
-						}
 					}
 				}
 					break;
@@ -1409,8 +1407,6 @@ int main(int argc, char *argv[])
 		priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
 		usleep(45000); //EV ¤pªO³q°T (50 ms)
 	}
-#else
-#endif
 	DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
 	return FAIL;
 }

+ 1 - 1
EVSE/Projects/DS60-120/Apps/Module_EventLogging.c

@@ -278,7 +278,7 @@ int main(void)
 		}
 
 		//check Info Status
-		for(ByteCount=0;ByteCount<8;ByteCount++)
+		for(ByteCount=0;ByteCount<29;ByteCount++)
 		{
 			if(ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount])
 			{

+ 69 - 20
EVSE/Projects/DS60-120/Apps/Module_InternalComm.c

@@ -36,6 +36,7 @@
 #define FAIL				-1
 #define YES					1
 #define NO					0
+#define TEN_MINUTES			600
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
@@ -76,12 +77,19 @@ byte gunCount = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
 struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 byte gfdChkFailCount[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
+bool _isOutputNoneMatch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+
 bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData);
 
 int Uart5Fd;
 char *relayRs485PortName = "/dev/ttyS5";
 unsigned short fanSpeedSmoothValue = 1000;
 
+bool isStopChargingCount = false;
+bool isSystemBooting = false;
+struct timeval _close_ac_contactor;
+
 struct timeval _priority_time;
 
 Ver ver;
@@ -241,9 +249,9 @@ void SetRtcData_Relay()
 	rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 	if (Config_Rtc_Data(Uart5Fd, Addr.Relay, &rtc) == PASS)
-		PRINTF_FUNC("SetRtc (RB) sucessfully. \n");
-	else
-		PRINTF_FUNC("SetRtc (RB) fail. \n");
+	{
+		//PRINTF_FUNC("SetRtc (RB) sucessfully. \n");
+	}
 }
 
 void SetRtcData_Fan()
@@ -278,9 +286,9 @@ void SetRtcData_Fan()
 	rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 	if (Config_Rtc_Data(Uart5Fd, Addr.Fan, &rtc) == PASS)
-		PRINTF_FUNC("SetRtc (FB) sucessfully. \n");
-	else
-		PRINTF_FUNC("SetRtc (FB) fail. \n");
+	{
+		//PRINTF_FUNC("SetRtc (FB) sucessfully. \n");
+	}
 }
 
 void SetModelName_Fan()
@@ -857,7 +865,7 @@ void SetK1K2RelayStatus(byte index)
 
 void SetParalleRelayStatus()
 {
-	if (gunCount >= 2 && ONE_CONNECTOR_USE == 0)
+	if (gunCount >= 2 && ONE_CONNECTOR_USE == NO)
 	{
 		if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING)
 		{
@@ -1233,16 +1241,28 @@ void CheckOutputPowerOverCarReq(byte index)
 
 void CheckOutputVolNoneMatchFire(byte index)
 {
-	if (_chargingData[index]->EvBatterytargetVoltage > 1500)
+	if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
+			(_chargingData[index]->Type == _Type_Chademo || _chargingData[index]->Type == _Type_CCS_2 || _chargingData[index]->Type == _Type_GB))
 	{
 		if ((_chargingData[index]->PresentChargingVoltage < _chargingData[index]->FireChargingVoltage - 300) ||
 				(_chargingData[index]->PresentChargingVoltage > _chargingData[index]->FireChargingVoltage + 300))
 		{
-			PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
-					_chargingData[index]->FireChargingVoltage, _chargingData[index]->EvBatterytargetVoltage);
-			DEBUG_ERROR("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
-					_chargingData[index]->FireChargingVoltage, _chargingData[index]->EvBatterytargetVoltage);
-			_chargingData[index]->StopChargeFlag = YES;
+			if (!_isOutputNoneMatch[index])
+			{
+				_isOutputNoneMatch[index] = YES;
+				gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
+			}
+			else
+			{
+				if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000)
+				{
+					PRINTF_FUNC("[Module_InternalComm]CheckOutputVolNoneMatchFire NG : pre = %f, fire = %f \n",
+					_chargingData[index]->PresentChargingVoltage, _chargingData[index]->FireChargingVoltage);
+					DEBUG_ERROR("[Module_InternalComm]CheckOutputVolNoneMatchFire NG : pre = %f, fire = %f \n",
+					_chargingData[index]->PresentChargingVoltage, _chargingData[index]->FireChargingVoltage);
+					_chargingData[index]->StopChargeFlag = YES;
+				}
+			}
 		}
 	}
 }
@@ -1292,7 +1312,7 @@ int main(void)
 		if (ShmRelayModuleData->SelfTest_Comp == NO)
 		{
 			GetFwAndHwVersion_Relay();
-			//SetRtcData_Relay();
+			SetRtcData_Relay();
 			sleep(1);
 		}
 
@@ -1300,7 +1320,7 @@ int main(void)
 		{
 			GetFwAndHwVersion_Fan();
 			SetModelName_Fan();
-			//SetRtcData_Fan();
+			SetRtcData_Fan();
 			sleep(1);
 			gettimeofday(&_priority_time, NULL);
 		}
@@ -1333,15 +1353,21 @@ int main(void)
 
 				if (_chargingData[i]->SystemStatus == S_BOOTING	||
 					(_chargingData[i]->SystemStatus >= S_PREPARNING && _chargingData[i]->SystemStatus <= S_COMPLETE) ||
-					(_chargingData[i]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[i]->SystemStatus <= S_CCS_PRECHARGE_ST1))
+					(_chargingData[i]->SystemStatus >= S_CCS_PRECHARGE_ST0 && _chargingData[i]->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
+					(ShmSysConfigAndInfo->SysInfo.PageIndex >= _LCM_AUTHORIZING && ShmSysConfigAndInfo->SysInfo.PageIndex <= _LCM_WAIT_FOR_PLUG))
 				{
 					_chargingData[i]->IsReadyToCharging = YES;
 					isCharging = true;
 
 					if (_chargingData[i]->SystemStatus == S_CHARGING)
+					{
 						CheckOutputPowerOverCarReq(i);
-
-					CheckOutputVolNoneMatchFire(i);
+						CheckOutputVolNoneMatchFire(i);
+					}
+					else
+					{
+						_isOutputNoneMatch[i] = NO;
+					}
 				}
 				else
 					_chargingData[i]->IsReadyToCharging = NO;
@@ -1350,8 +1376,7 @@ int main(void)
 			GetGfdAdc();
 
 			// 橋接 relay
-			if (gunCount > 1 && ONE_CONNECTOR_USE == NO)
-				SetParalleRelayStatus();
+			SetParalleRelayStatus();
 
 			// 搭上 AC Contactor
 			if (isCharging)
@@ -1359,6 +1384,26 @@ int main(void)
 			else
 				outputRelay.relay_event.bits.AC_Contactor = NO;
 
+//			if (isCharging)
+//			{
+//				isStopChargingCount = false;
+//				outputRelay.relay_event.bits.AC_Contactor = YES;
+//			}
+//			else
+//			{
+//				if (!isStopChargingCount)
+//				{
+//					gettimeofday(&_close_ac_contactor, NULL);
+//					isStopChargingCount = true;
+//				}
+//				else
+//				{
+//					if (!isSystemBooting ||
+//						(outputRelay.relay_event.bits.AC_Contactor == YES && GetTimeoutValue(_close_ac_contactor) / 1000 >= (TEN_MINUTES * 1000)))
+//						outputRelay.relay_event.bits.AC_Contactor = NO;
+//				}
+//			}
+
 			// 搭上/鬆開 Relay
 			// 放開 Relay 之前要先確認輸出的電壓電流是否已經降到某個值
 			if(IsNoneMatchRelayStatus())
@@ -1403,6 +1448,10 @@ int main(void)
 			{
 				GetFanSpeed();
 				gettimeofday(&_priority_time, NULL);
+//				printf("ShmFanModuleData->PresentFan1Speed = %d \n", ShmFanModuleData->PresentFan1Speed);
+//				printf("ShmFanModuleData->PresentFan2Speed = %d \n", ShmFanModuleData->PresentFan2Speed);
+//				printf("ShmFanModuleData->PresentFan3Speed = %d \n", ShmFanModuleData->PresentFan3Speed);
+//				printf("ShmFanModuleData->PresentFan4Speed = %d \n", ShmFanModuleData->PresentFan4Speed);
 				if (isCharging)
 				{
 					if (ShmFanModuleData->PresentFan1Speed < MAX_FAN_SPEED ||

+ 2 - 1
EVSE/Projects/DS60-120/Apps/Module_LcmContro.h

@@ -32,6 +32,8 @@
 #define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
 #define PASS				1
 #define FAIL				-1
+#define YES					1
+#define NO					0
 
 typedef unsigned char 			byte;
 
@@ -62,7 +64,6 @@ byte _gunIndex = 0;
 byte _idlePageRotate = 1;
 bool _backend_conn_status = false;
 bool _wifi_conn_status = false;
-bool _net_conn_status = false;
 
 // LCM - HW
 byte _everyPageRollChange = 0;

+ 35 - 29
EVSE/Projects/DS60-120/Apps/Module_LcmControl.c

@@ -536,6 +536,18 @@ void ChangeRemainTime(int sec)
 	DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
 }
 
+void ChangeChargingEnergyValue(float energy)
+{
+	byte cmd[10];
+	byte value[10];
+
+	memset(cmd, 0x00, sizeof(cmd));
+
+	sprintf((char *) value, "%.1f kWh", energy);
+	string2ByteArray(value, cmd);
+	DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
+}
+
 void ChangeChargingPowerValue(float pow)
 {
 	byte cmd[10];
@@ -624,7 +636,8 @@ void RefreshPageAnimation(byte value)
 				}
 
 				ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-				if (_chargingInfoData[index]->SystemStatus == S_IDLE)
+				if (_chargingInfoData[index]->SystemStatus == S_IDLE ||
+						_chargingInfoData[index]->SystemStatus == S_RESERVATION)
 				{
 					if(value == 0)
 					{
@@ -666,46 +679,32 @@ void RefreshPageAnimation(byte value)
 void RefreshConnStatus()
 {
 	// Wifi priority is higher than Ethernet
-	if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == 0x01)
+	if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES)
 	{
-		if (!_wifi_conn_status)
-		{
-			_wifi_conn_status = true;
-			ChangeDisplay2Value(__wifi_status, _wifi_connect);
-			ChangeDisplay2Value(__ethernet_status, _disappear);
-		}
+		_wifi_conn_status = true;
+		ChangeDisplay2Value(__wifi_status, _wifi_connect);
+		ChangeDisplay2Value(__ethernet_status, _disappear);
 	}
 	else
 	{
-		if(_wifi_conn_status)
-		{
-			_wifi_conn_status = false;
-			ChangeDisplay2Value(__wifi_status, _disappear);
-		}
+		_wifi_conn_status = false;
+		ChangeDisplay2Value(__wifi_status, _disappear);
 	}
 
 	if (!_wifi_conn_status)
 	{
-		if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == PASS)
+		if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
 		{
-			if(!_net_conn_status)
-			{
-				_net_conn_status = true;
-				ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
-			}
+			ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
 		}
 		else
 		{
-			if(_net_conn_status)
-			{
-				_net_conn_status = false;
-				ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
-			}
+			ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
 		}
 	}
 
 	// ³s½u¨ì«á¥x
-	if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == 0x01)
+	if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES)
 		ChangeDisplay2Value(__conn_status, _connect);
 	else
 		ChangeDisplay2Value(__conn_status, _disconnect);
@@ -761,9 +760,12 @@ void ProcessPageInfo()
 					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
 					{
 						ChangeBattMapAndValue(_LCM_CHARGING, _chargingInfoData[i]->EvBatterySoc);
-						if (_chargingInfoData[i]->RemainChargingDuration > 0)
+						if (_chargingInfoData[i]->RemainChargingDuration >= 0)
 							ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
-						ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
+						if (_chargingInfoData[i]->PresentChargingPower >= 0)
+							ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
+						if (_chargingInfoData[i]->PresentChargedEnergy >= 0)
+							ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
 
 						if (strcmp((char *)_chargingInfoData[i]->StartUserId, "") == 0)
 							ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
@@ -776,9 +778,12 @@ void ProcessPageInfo()
 					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
 					{
 						ChangeBattMapAndValue(_LCM_COMPLETE, _chargingInfoData[i]->EvBatterySoc);
-						if (_chargingInfoData[i]->RemainChargingDuration > 0)
+						if (_chargingInfoData[i]->RemainChargingDuration >= 0)
 							ChangeRemainTime(_chargingInfoData[i]->RemainChargingDuration);
-						ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
+						if (_chargingInfoData[i]->PresentChargingPower >= 0)
+							ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
+						if (_chargingInfoData[i]->PresentChargedEnergy >= 0)
+							ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
 					}
 				}
 			}
@@ -796,6 +801,7 @@ void ProcessPageInfo()
 				}
 
 				if (_chargingInfoData[index]->SystemStatus == S_IDLE ||
+						_chargingInfoData[index]->SystemStatus == S_RESERVATION ||
 						_chargingInfoData[index]->SystemStatus == S_BOOTING)
 				{
 					// QR Code ³B²z

+ 102 - 97
EVSE/Projects/DS60-120/Apps/Module_PsuComm.c

@@ -383,7 +383,7 @@ void GetPsuRequestCallback(byte phy_id, char *serial_number)
 		if (ShmPsuData->Work_Step >= _TEST_LINE_STEP && ShmPsuData->Work_Step <= _TEST_COMPLETE)
 		{
 			// 已經進入火線上的驗證動作
-			ShmPsuData->NeedBackTest = YES;
+			//ShmPsuData->NeedBackTest = YES;
 		}
 		else if (ShmPsuData->Work_Step == _WORK_CHARGING)
 		{
@@ -579,15 +579,15 @@ void SaveAvailableCapCallback(byte address, unsigned short maxv, unsigned short
     		    for (int loop = 0; loop < ShmPsuData->PsuGroup[groupIndex].GroupPresentPsuQuantity; loop++)
     		    {
     		    	// 降載
-    		    	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
-    		    			ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_COMP)
-    		    	{
-    		    		if (ShmPsuData->PsuGroup[group].PsuModule[index].FireWireIndex == group)
-    		    		{
-    		    			power_derating += ShmPsuData->PsuGroup[group].PsuModule[index].AvailablePower;
-    		    			current_derating += ShmPsuData->PsuGroup[group].PsuModule[index].AvailableCurrent;
-    		    		}
-    		    	}
+//    		    	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
+//    		    			ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_COMP)
+//    		    	{
+//    		    		if (ShmPsuData->PsuGroup[group].PsuModule[index].FireWireIndex == group)
+//    		    		{
+//    		    			power_derating += ShmPsuData->PsuGroup[group].PsuModule[index].AvailablePower;
+//    		    			current_derating += ShmPsuData->PsuGroup[group].PsuModule[index].AvailableCurrent;
+//    		    		}
+//    		    	}
 
     		        power += ShmPsuData->PsuGroup[groupIndex].PsuModule[loop].AvailablePower;
     			    current += ShmPsuData->PsuGroup[groupIndex].PsuModule[loop].AvailableCurrent;
@@ -914,6 +914,7 @@ int main(void)
 			case ASSIGN_START:
 			{
 				PRINTF_FUNC("== PSU == ASSIGN_COMP \n");
+				sleep(5);
 				gettimeofday(&_id_assign_time, NULL);
 				ShmPsuData->Work_Step = ASSIGN_COMP;
 			}
@@ -955,8 +956,8 @@ int main(void)
 				}
 
 				priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
-				// 等待 15
-				if (GetTimeoutValue(_id_assign_time) >= 15000000)
+				// 等待 10
+				if (GetTimeoutValue(_id_assign_time) >= 10000000)
 				{
 					ShmPsuData->Work_Step = ENABLE_POW;
 					PRINTF_FUNC("INFYPWR Num = %d \n", ShmPsuData->SystemPresentPsuQuantity);
@@ -986,6 +987,8 @@ int main(void)
 				if (ShmPsuData->PsuGroup[0].GroupPresentPsuQuantity <= 0)
 				{
 					sleep(1);
+					// 顯示錯誤
+					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuNoResource = YES;
 					continue;
 				}
 
@@ -1000,14 +1003,12 @@ int main(void)
 					gettimeofday(&_chk_cap_time, NULL);
 				}
 
+				// 初始化、關閉所有的模塊
+				//EnableOutputPower(0, NONE_CARE_ADDRESS, SWITCH_OFF);
 				for (byte groupIndex = 0; groupIndex < ShmPsuData->GroupCount; groupIndex++)
 				{
 					GetStatus(groupIndex, NONE_CARE_ADDRESS);
 					usleep(cmdDelayTime);
-
-					//infypwr v1.9 (如果沒回也沒差)
-					//GetVextAndIavail(SET_MODULE_CMD, NONE_CARE_ADDRESS);
-					//usleep(cmdDelayTime);
 				}
 
 				for (byte psuCount = 0; psuCount < ShmPsuData->SystemPresentPsuQuantity; psuCount++)
@@ -1060,7 +1061,7 @@ int main(void)
 
 				if (time > 1000)
 				{
-					for (byte psuCount = 0; psuCount < ShmPsuData->SystemPresentPsuQuantity; psuCount++)
+					for (byte psuCount = 0; psuCount < ShmPsuData->GroupCount; psuCount++)
 					{
 						GetAvailableCap(psuCount, NONE_CARE_ADDRESS,  0);
 					}
@@ -1081,44 +1082,44 @@ int main(void)
     					GetMiscInfo(SET_GROUP_CMD, 0, MISC_REQCMD_PFC_BOARD_TMP);
     					usleep(cmdDelayTime);
     					*/
-						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_GET_NEW_CAP)
-						{
-							if (groupIndex != ShmSysConfigAndInfo->SysInfo.CurGunSelected)
-							{
-								if (chargingInfo[groupIndex]->SystemStatus >= S_CHARGING &&	chargingInfo[groupIndex]->SystemStatus <= S_COMPLETE)
-								{
-									if (chargingInfo[groupIndex]->DeratingChargingCurrent < chargingInfo[groupIndex]->AvailableChargingCurrent)
-									{
-										// 車端需求電流降低至降載的電流
-										PRINTF_FUNC("Smart Charging : index = %d, EvBatterytargetCurrent = %f, DeratingChargingCurrent = %f \n",
-										groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent, chargingInfo[groupIndex]->DeratingChargingCurrent);
-
-										if ((chargingInfo[groupIndex]->EvBatterytargetCurrent <= chargingInfo[groupIndex]->DeratingChargingCurrent) ||
-											deratingKeepCount >= DERATING)
-										{
-											// 車端降載完成
-											PRINTF_FUNC("=============Smart Charging : _REASSIGNED_MAIN============= Step 3 \n");
-											ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_MAIN;
-										}
-										else
-										{
-											deratingKeepCount++;
-										}
-									}
-								}
-							}
-						}
-						else
-							deratingKeepCount = 0;
-
-						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_MAIN)
-						{
-							PRINTF_FUNC("=============Smart Charging : _REASSIGNED_ADJUST============= Step 4 \n");
-							//重新分配模組
-							ReAssignedResource();
-							gettimeofday(&_derating_time, NULL);
-							ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_ADJUST;
-						}
+//						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_GET_NEW_CAP)
+//						{
+//							if (groupIndex != ShmSysConfigAndInfo->SysInfo.CurGunSelected)
+//							{
+//								if (chargingInfo[groupIndex]->SystemStatus >= S_CHARGING &&	chargingInfo[groupIndex]->SystemStatus <= S_COMPLETE)
+//								{
+//									if (chargingInfo[groupIndex]->DeratingChargingCurrent < chargingInfo[groupIndex]->AvailableChargingCurrent)
+//									{
+//										// 車端需求電流降低至降載的電流
+//										PRINTF_FUNC("Smart Charging : index = %d, EvBatterytargetCurrent = %f, DeratingChargingCurrent = %f \n",
+//										groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent, chargingInfo[groupIndex]->DeratingChargingCurrent);
+//
+//										if ((chargingInfo[groupIndex]->EvBatterytargetCurrent <= chargingInfo[groupIndex]->DeratingChargingCurrent) ||
+//											deratingKeepCount >= DERATING)
+//										{
+//											// 車端降載完成
+//											PRINTF_FUNC("=============Smart Charging : _REASSIGNED_MAIN============= Step 3 \n");
+//											ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_MAIN;
+//										}
+//										else
+//										{
+//											deratingKeepCount++;
+//										}
+//									}
+//								}
+//							}
+//						}
+//						else
+//							deratingKeepCount = 0;
+//
+//						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_MAIN)
+//						{
+//							PRINTF_FUNC("=============Smart Charging : _REASSIGNED_ADJUST============= Step 4 \n");
+//							//重新分配模組
+//							ReAssignedResource();
+//							gettimeofday(&_derating_time, NULL);
+//							ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_ADJUST;
+//						}
 
 						gettimeofday(&_workModePriority_time, NULL);
 					}
@@ -1127,28 +1128,32 @@ int main(void)
 					usleep(cmdDelayTime);
 					//GetVextAndIavail(SET_MODULE_CMD, 0);
 
-					if (carReqVol != chargingInfo[groupIndex]->EvBatterytargetVoltage)
+					if (chargingInfo[groupIndex]->EvBatterytargetVoltage > 0 &&
+							carReqVol != chargingInfo[groupIndex]->EvBatterytargetVoltage)
 					{
 						carReqVol = chargingInfo[groupIndex]->EvBatterytargetVoltage;
 						DEBUG_INFO("ev need vol = %f \n", chargingInfo[groupIndex]->EvBatterytargetVoltage);
 					}
 
-					if (carReqCur != chargingInfo[groupIndex]->EvBatterytargetCurrent)
+					if (chargingInfo[groupIndex]->EvBatterytargetCurrent > 0 &&
+							carReqCur != chargingInfo[groupIndex]->EvBatterytargetCurrent)
 					{
 						carReqCur = chargingInfo[groupIndex]->EvBatterytargetCurrent;
 						DEBUG_INFO("ev need cur = %f \n", chargingInfo[groupIndex]->EvBatterytargetCurrent);
 					}
 
-					if (evseOutVol != chargingInfo[groupIndex]->FireChargingVoltage)
+					if (chargingInfo[groupIndex]->FireChargingVoltage > 0 &&
+							evseOutVol != chargingInfo[groupIndex]->FireChargingVoltage)
 					{
 						evseOutVol = chargingInfo[groupIndex]->FireChargingVoltage;
-						PRINTF_FUNC("evse output vol = %f \n",	chargingInfo[groupIndex]->FireChargingVoltage);
+						PRINTF_FUNC("groupIndex = %d, evse output vol = %f \n", groupIndex,	chargingInfo[groupIndex]->FireChargingVoltage);
 					}
 
-					if (evseOutCur != chargingInfo[groupIndex]->PresentChargingCurrent)
+					if (chargingInfo[groupIndex]->PresentChargingCurrent > 0 &&
+							evseOutCur != chargingInfo[groupIndex]->PresentChargingCurrent)
 					{
 						evseOutCur = chargingInfo[groupIndex]->PresentChargingCurrent;
-						PRINTF_FUNC("evse output cur = %f \n", chargingInfo[groupIndex]->PresentChargingCurrent);
+						PRINTF_FUNC("groupIndex = %d, evse output cur = %f \n", groupIndex, chargingInfo[groupIndex]->PresentChargingCurrent);
 					}
 
 					// 針對各槍當前狀態,傳送需要回傳的資料指令
@@ -1158,42 +1163,42 @@ int main(void)
 					{
 						if (ShmPsuData->PsuGroup[groupIndex].GroupAvailableCurrent > 0)
 						{
-							if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_ADJUST &&
-									ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_COMP )
-							{
-								// 如果車端要求的電流超過降載,則以降載電流為主
-								if (chargingInfo[groupIndex]->EvBatterytargetCurrent >= chargingInfo[groupIndex]->DeratingChargingCurrent)
-								{
-									chargingInfo[groupIndex]->EvBatterytargetCurrent = chargingInfo[groupIndex]->DeratingChargingCurrent;
-								}
-
-								if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_ADJUST)
-								{
-									deratingTime = GetTimeoutValue(_derating_time) / 1000;
-									if (deratingTime > 3000)
-									{
-										deratingTime = 0;
-										PRINTF_FUNC("=============Smart Charging : _REASSIGNED_RELAY============= Step 5 \n");
-										ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY;
-									}
-
-									for(int i = 0; i < ShmPsuData->PsuGroup[groupIndex].GroupPresentPsuQuantity; i++)
-									{
-										PRINTF_FUNC("*********_REASSIGNED_ADJUST : groupIndex = %d, outputCur = %d, outputVol = %d \n",
-											groupIndex,
-										ShmPsuData->PsuGroup[groupIndex].PsuModule[i].PresentOutputCurrent,
-										ShmPsuData->PsuGroup[groupIndex].PsuModule[i].PresentOutputVoltage);
-									}
-								}
-
-								// 該充電槍的目標電壓與目標電流
-								SetPresentOutput(groupIndex, NONE_CARE_ADDRESS,
-										chargingInfo[groupIndex]->EvBatterytargetVoltage,
-										chargingInfo[groupIndex]->EvBatterytargetCurrent,
-										chargingInfo[groupIndex]->DeratingChargingCurrent);
-								usleep(cmdDelayTime);
-							}
-							else
+//							if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_ADJUST &&
+//									ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_COMP )
+//							{
+//								// 如果車端要求的電流超過降載,則以降載電流為主
+//								if (chargingInfo[groupIndex]->EvBatterytargetCurrent >= chargingInfo[groupIndex]->DeratingChargingCurrent)
+//								{
+//									chargingInfo[groupIndex]->EvBatterytargetCurrent = chargingInfo[groupIndex]->DeratingChargingCurrent;
+//								}
+//
+//								if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag == _REASSIGNED_ADJUST)
+//								{
+//									deratingTime = GetTimeoutValue(_derating_time) / 1000;
+//									if (deratingTime > 3000)
+//									{
+//										deratingTime = 0;
+//										PRINTF_FUNC("=============Smart Charging : _REASSIGNED_RELAY============= Step 5 \n");
+//										ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY;
+//									}
+//
+//									for(int i = 0; i < ShmPsuData->PsuGroup[groupIndex].GroupPresentPsuQuantity; i++)
+//									{
+//										PRINTF_FUNC("*********_REASSIGNED_ADJUST : groupIndex = %d, outputCur = %d, outputVol = %d \n",
+//											groupIndex,
+//										ShmPsuData->PsuGroup[groupIndex].PsuModule[i].PresentOutputCurrent,
+//										ShmPsuData->PsuGroup[groupIndex].PsuModule[i].PresentOutputVoltage);
+//									}
+//								}
+//
+//								// 該充電槍的目標電壓與目標電流
+//								SetPresentOutput(groupIndex, NONE_CARE_ADDRESS,
+//										chargingInfo[groupIndex]->EvBatterytargetVoltage,
+//										chargingInfo[groupIndex]->EvBatterytargetCurrent,
+//										chargingInfo[groupIndex]->DeratingChargingCurrent);
+//								usleep(cmdDelayTime);
+//							}
+//							else
 							{
 								// 該充電槍的目標電壓與目標電流
 								SetPresentOutput(groupIndex, NONE_CARE_ADDRESS,

+ 69 - 16
EVSE/Projects/DS60-120/Apps/ReadCmdline.c

@@ -54,6 +54,7 @@ struct CHAdeMOData				*ShmCHAdeMOData;
 struct CcsData					*ShmCcsData;
 struct FanModuleData			*ShmFanModuleData;
 struct RelayModuleData			*ShmRelayModuleData;
+struct PsuData 					*ShmPsuData;
 
 struct ChargingInfoData 		*_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 int gunCount = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
@@ -177,6 +178,15 @@ int InitShareMemory()
    		result = FAIL;
    	}
 
+   	if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData),	IPC_CREAT | 0777)) < 0)
+   	{
+   		result = FAIL;
+   	}
+   	else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+   	{
+   		result = FAIL;
+   	}
+
     return result;
 }
 
@@ -284,6 +294,10 @@ void GetFwVerProc(char *v1)
 	{
 		printf("FAN Version = %s \n", ShmSysConfigAndInfo->SysInfo.FanModuleFwRev);
 	}
+	else if (strcmp(v1, "dc") == 0)
+	{
+		printf("DC Main Version = %s \n", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
+	}
 }
 
 void FwUpdateFlagProc()
@@ -348,6 +362,46 @@ void SetFanSpeed(char *v1)
 	ShmFanModuleData->TestFanSpeed = speed;
 }
 
+void GetPsuInformation(char *v1)
+{
+	printf("*************************************************\n");
+	if(strcmp(v1, "count") == 0)
+	{
+		for (int i = 0; i < 4; i++)
+		{
+			printf("Group Index = %d, Module Count = %d \n", i, ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity);
+		}
+	}
+	else if(strcmp(v1, "ver") == 0)
+	{
+		for (int i = 0; i < ShmPsuData->GroupCount; i++)
+		{
+			for (int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++)
+			{
+				printf("Group Index = %d, Psu Index = %d, Version = %s \n",
+					i, j, ShmPsuData->PsuGroup[i].PsuModule[j].FwVersion);
+			}
+		}
+	}
+	else if(strcmp(v1, "cap") == 0)
+	{
+		for (int i = 0; i < ShmPsuData->GroupCount; i++)
+		{
+			printf("Group Index = %d, MaxCur = %d, Power = %d \n",
+					i, ShmPsuData->PsuGroup[i].GroupAvailableCurrent, ShmPsuData->PsuGroup[i].GroupAvailablePower);
+		}
+	}
+	else if (strcmp(v1, "output") == 0)
+	{
+		for (int i = 0; i < ShmPsuData->GroupCount; i++)
+		{
+			printf("Group Index = %d, OutputV = %d, OutputC = %d \n",
+					i, ShmPsuData->PsuGroup[i].GroupPresentOutputVoltage, ShmPsuData->PsuGroup[i].GroupPresentOutputCurrent);
+		}
+	}
+	printf("*************************************************\n");
+}
+
 static int get_char()
 {
     fd_set rfds;
@@ -529,7 +583,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
     		    {
     		        printf ("First Ground Fault State (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
     		        printf ("Wait K1K2 = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
-    		        sleep(3);
+    		        sleep(5);
     		        //EV done
     		        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_CHARGING;
     		    }
@@ -691,13 +745,11 @@ int main(void)
 
 			// 槍狀態
 			RunStatusProc(newString[1], newString[2]);
-			continue;
 		}
 		else if(strcmp(newString[0], "card") == 0)
 		{
 			// 刷卡狀態
 			RunCardProc(newString[1], newString[2]);
-			continue;
 		}
 		else if(strcmp(newString[0], "gun") == 0)
 		{
@@ -706,7 +758,6 @@ int main(void)
 
 			// 插槍狀態
 			RunGunPlugitProc(newString[1], newString[2]);
-			continue;
 		}
 		else if(strcmp(newString[0], "lock") == 0)
 		{
@@ -715,19 +766,16 @@ int main(void)
 
 			// 插槍狀態
 			GetGunLockStatusProc(newString[1], newString[2]);
-			continue;
 		}
 		else if(strcmp(newString[0], "sysid") == 0)
 		{
 			// 測試 sys id
 			SetSystemIDProc();
-			continue;
 		}
 		else if(strcmp(newString[0], "self") == 0)
 		{
 			// CSU 自我檢測狀態
 			RunSelfProc(newString[1]);
-			continue;
 		}
 		else if(strcmp(newString[0], "ver") == 0)
 		{
@@ -735,19 +783,16 @@ int main(void)
 				continue;
 			// 取 FW 版號
 			GetFwVerProc(newString[1]);
-			continue;
 		}
 		else if (strcmp(newString[0], "update") == 0)
 		{
 			// 更新
 			FwUpdateFlagProc(newString[1]);
-			continue;
 		}
 		else if (strcmp(newString[0], "ac") == 0)
 		{
 			// AC contactor 狀態
 			CheckAcStatus(newString[1]);
-			continue;
 		}
 		else if (strcmp(newString[0], "cable") == 0)
 		{
@@ -755,7 +800,6 @@ int main(void)
 				continue;
 			// cable check pass
 			SetCableChkStatus(newString[1], newString[2]);
-			continue;
 		}
 		else if (strcmp(newString[0], "pow") == 0)
 		{
@@ -763,24 +807,34 @@ int main(void)
 				continue;
 			// cable check pass
 			SetPowerValue(newString[1], newString[2]);
-			continue;
 		}
 		else if(strcmp(newString[0], "select") == 0)
 		{
 			// 取得當前選的槍號
 			GetGunSelectedNum(newString[1]);
-			continue;
 		}
 		else if(strcmp(newString[0], "fan") == 0)
 		{
 			// 設定風扇速度
 			SetFanSpeed(newString[1]);
-			continue;
+		}
+		else if(strcmp(newString[0], "psu") == 0)
+		{
+			//如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
+			if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
+			{
+				printf ("PSU : Param fail..Please retry again......\n");
+				continue;
+			}
+
+			// 取得 PSU 資訊
+			GetPsuInformation(newString[1]);
 		}
 		else if(strcmp(newString[0], "strchg") == 0)
 		{
 			//如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
-			if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 || strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
+			if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
+					strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
 			{
 				printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
 				continue;
@@ -788,7 +842,6 @@ int main(void)
 
 			// 槍狀態
 			RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
-			continue;
 		}
 
 		printf ("%s\n", msg);

+ 2 - 0
EVSE/Projects/DS60-120/Apps/kill.sh

@@ -5,6 +5,8 @@ pkill Module_InternalComm
 pkill Module_EventLogging
 pkill Module_EvComm
 pkill Module_PsuComm
+pkill Module_4g
+pkill Module_Wifi
 pkill OcppBackend
 pkill main
 

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 317 - 135
EVSE/Projects/DS60-120/Apps/main.c


+ 1 - 1
EVSE/Projects/define.h

@@ -40,7 +40,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define CHAdeMO_QUANTITY	1
 #define CCS_QUANTITY		1
 #define GB_QUANTITY		0
-#define AC_QUANTITY		1	
+#define AC_QUANTITY		0	
 #define PSU_QUANTITY		2
 #define ONE_CONNECTOR_USE	0
 

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно