Ver Fonte

2020-03-17 / Alston Lin

Actions
1. Update DS60 firmware source code.

Files
1. As follow commit history.
Alston há 5 anos atrás
pai
commit
1dfa01703a

+ 23 - 19
EVSE/Projects/DS60-120/Apps/Config.h

@@ -10,7 +10,7 @@
 typedef unsigned char			byte;
 
 #define TOTAL_QUANTITY_GUN			4				//Max Count
-#define DEBUG						0
+#define DEBUG						1
 
 #define MODE_BOOT					0
 #define MODE_IDLE					1
@@ -76,7 +76,6 @@ enum _GUN_TYPE
 	_Type_Chademo = 		0,
 	_Type_CCS_2,
 	_Type_GB,
-
 };
 
 enum _LCM_INDEX
@@ -101,17 +100,15 @@ enum _SELF_TEST_SEQ
 	_STEST_PSU_DETECT = 0x02,
 	_STEST_PSU_CAP = 0x03,
 	_STEST_FAIL = 0x04,
-	_STEST_COMPLETE = 0xFE,
+	_STEST_COMPLETE = 0xEE,
 };
 
 enum _MODULE_PSU_WORK_STEP
 {
-	ASSIGN_START 	= 			0,
-	ASSIGN_COMP 	= 			1,
-	ENABLE_POW		=			2,
-	_TEST_LINE_STEP 	= 		3,
-	_TEST_POWER_STEP 	= 		4,
-	_TEST_COMPLETE 		= 		5,
+	INITIAL_START 		= 			0,
+	GET_PSU_COUNT 		= 			1,
+	GET_SYS_CAP			=			2,
+	BOOTING_COMPLETE 	= 			3,
 
 	_WORK_CHARGING 	= 			10,
 
@@ -135,16 +132,17 @@ enum _SYS_AUTHORIZE_MODE
 
 enum _REASSIGNED_RESOURCE_STEP
 {
-	_REASSIGNED_NONE = 			0,	//
-	_REASSIGNED_PREPARE = 		1,	// 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
-	_REASSIGNED_GET_NEW_CAP = 	2,	// 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
-	_REASSIGNED_MAIN = 			3,  // 重新分配 PSU
-	_REASSIGNED_ADJUST = 		4,	// 模塊重新分配完成
-	_REASSIGNED_RELAY = 		5,	// 切斷橋接的 Relay
-	_REASSIGNED_COMP = 			6,	// 完成
-	_REASSIGNED_M_RELAY = 		7,	// 搭接橋接的 Relay
-	_REASSIGNED_M_MAIN = 		8,	// 重新分配 PSU (最大充)
-	_REASSIGNED_M_GET_NEW_CAP = 9	// 取得新的 CAP 並通知車端
+	_REASSIGNED_NONE = 				0,	//
+	_REASSIGNED_PREPARE_M_TO_A =	1,	// 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
+	_REASSIGNED_GET_NEW_CAP = 		2,	// 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
+	_REASSIGNED_ADJUST_M_TO_A = 	3,	// 模塊重新分配完成
+	_REASSIGNED_RELAY_M_TO_A =		4,	// 切斷橋接的 Relay
+
+	_REASSIGNED_PREPARE_A_TO_M = 	11,
+	_REASSIGNED_ADJUST_A_TO_M = 	12, // 模塊升壓
+	_REASSIGNED_RELAY_A_TO_M = 		13,	// 搭接橋接的 Relay
+	_REASSIGNED_WAITING = 			14,
+	_REASSIGNED_COMP = 				15
 };
 
 enum _MAIN_CHARGING_MODE
@@ -153,4 +151,10 @@ enum _MAIN_CHARGING_MODE
 	_MAIN_CHARGING_MODE_AVER = 1,
 };
 
+enum _EXTRA_ERR_PROCESS
+{
+	_EXTRA_ERR_PROCESS_NONE = 0,
+	_EXTRA_ERR_PROCESS_INUVP = 1
+};
+
 #endif /* CONFIG_H_ */

+ 13 - 0
EVSE/Projects/DS60-120/Apps/Ev_Comm.c

@@ -56,6 +56,19 @@ void GetFirmwareVersion(byte gun_index, byte toId)
 	SendCmdToEvboard(id, data, 0);
 }
 
+void SyncRtcInfo(byte gun_index, byte toId, int epoch)
+{
+	int id = PackageIdCmd(Ev_Cmd.sync_rtc_info + toId);
+	byte data[8];
+
+	data[0] = epoch & 0xff;
+	data[1] = (epoch >> 8) & 0xff;
+	data[2] = (epoch >> 16) & 0xff;
+	data[3] = (epoch >> 24) & 0xff;
+
+	SendCmdToEvboard(id, data, 4);
+}
+
 void GetHardwareVersion(byte gun_index, byte toId)
 {
 	int id = PackageIdCmd(Ev_Cmd.get_hardware_ver + toId);

+ 9 - 8
EVSE/Projects/DS60-120/Apps/FactoryConfig.c

@@ -123,10 +123,10 @@ int main(int argc,char *argv[])
 	SysConfig.Ccs2PlugInTimes = 0;
 	SysConfig.ChademoPlugInTimes = 0;
 	//********** Charging **********//
-	SysConfig.RatingCurrent = 1200;			// 最大可輸出電流 120 A
+	SysConfig.RatingCurrent = 200;			// 最大可輸出電流
 	SysConfig.MaxChargingEnergy = 0;
-	SysConfig.MaxChargingPower = 600; 		// 最大功率 : 跟著 model name 跑
-	SysConfig.MaxChargingCurrent = 1200;		// 最大可輸出電流 120 A
+	SysConfig.MaxChargingPower = 60; 		// 最大功率 : 跟著 model name 跑
+	SysConfig.MaxChargingCurrent = 200;		// 最大可輸出電流
 	SysConfig.MaxChargingDuration = 0;
 	SysConfig.PhaseLossPolicy = 0;
 	for(unsigned char i = 0; i < 10; i++)
@@ -136,12 +136,10 @@ int main(int argc,char *argv[])
 	//********** Network **********//
 	strcpy((char *)SysConfig.FtpServer, "");
 	SysConfig.Eth0Interface.EthDhcpClient = 0;
-	strcpy((char *) SysConfig.Eth0Interface.EthMacAddress, "AA:BB:CC:DD:EE:FF");
 	strcpy((char *) SysConfig.Eth0Interface.EthIpAddress, "192.168.1.10");
 	strcpy((char *) SysConfig.Eth0Interface.EthSubmaskAddress, "255.255.255.0");
 	strcpy((char *) SysConfig.Eth0Interface.EthGatewayAddress, "192.168.1.254");
 	SysConfig.Eth1Interface.EthDhcpClient = 0;
-	strcpy((char *) SysConfig.Eth1Interface.EthMacAddress, "AA:BB:CC:DD:EE:FF");
 	strcpy((char *) SysConfig.Eth1Interface.EthIpAddress, "192.168.0.10");
 	strcpy((char *) SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
 	strcpy((char *) SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
@@ -158,7 +156,8 @@ int main(int argc,char *argv[])
 	SysConfig.AthInterface.WifiNetworkConn = 0;
 	strcpy((char *) SysConfig.TelecomInterface.TelcomModelName, "");
 	strcpy((char *) SysConfig.TelecomInterface.TelcomSoftwareVer, "");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "Internet");
+	//strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "Internet");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "");
 	SysConfig.TelecomInterface.TelcomRssi = 0;
 	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, " ");
 	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, " ");
@@ -175,8 +174,10 @@ int main(int argc,char *argv[])
 	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_Alston");
+	//strcpy((char *) SysConfig.OcppServerURL, "ws://test.evsocket.phihong.com.cn:2012/ocpp/");
+	//strcpy((char *) SysConfig.ChargeBoxId, "DemoDC_Alston");
+	strcpy((char *) SysConfig.OcppServerURL, "");
+	strcpy((char *) SysConfig.ChargeBoxId, "");
 
 	//copy default configuration to pointer
 	memcpy(ptr,&SysConfig,sizeof(struct SysConfigData));

+ 113 - 78
EVSE/Projects/DS60-120/Apps/Module_EvComm.c

@@ -77,6 +77,7 @@ struct Ev_Board_Cmd Ev_Cmd={
 		0x00001100,
 
 		0x00001200,
+		0x00001400,
 		0x00001500,
 };
 
@@ -136,16 +137,16 @@ int DiffTimeb(struct timeb ST, struct timeb ET)
 
 void PRINTF_FUNC(char *string, ...)
 {
-	if (DEBUG)
-	{
-		va_list args;
-		char buffer[4096];
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-		va_start(args, string);
-		vsnprintf(buffer, sizeof(buffer), string, args);
-		va_end(args);
+	if (DEBUG)
 		printf("%s \n", buffer);
-	}
+	else
+		DEBUG_INFO("%s \n", buffer);
 }
 
 //=================================
@@ -364,6 +365,8 @@ void AddrAssignment(byte *data)
 	memcpy(target_number, data, sizeof(target_number));
 	index = *(data + 4);
 
+	if (gun_count == 1)
+		index = 0x01;
 	if (CheckUniqNumber(index))
 	{
 		PRINTF_FUNC("EV board id = %x \n", index);
@@ -944,7 +947,7 @@ void CANReceiver()
 					{
 						// 車端要求停止
 						// frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
-						PRINTF_FUNC("NOTIFICATION_EV_STOP -----------------------------\n");
+						PRINTF_FUNC("NOTIFICATION_EV_STOP err level = %d-----------------------------\n", frame.data[0]);
 						if (frame.data[0] == 0x02)
 						{
 							AbnormalStopAnalysis(targetGun, frame.data + 1);
@@ -1003,31 +1006,17 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
 	float pow2 = 0, cur2 = 0;
 	float vol = 0;
 
-	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-	{
-		pow1 = chargingData_1->DeratingChargingPower;
-		cur1 = chargingData_1->DeratingChargingCurrent;
-	}
-	else
-	{
-		pow1 = chargingData_1->AvailableChargingPower;
-		cur1 = chargingData_1->AvailableChargingCurrent;
-	}
+	pow1 = chargingData_1->AvailableChargingPower;
+	cur1 = chargingData_1->AvailableChargingCurrent;
+
 	vol = chargingData_1->MaximumChargingVoltage;
 	GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
 	GetMaxPowerMethod(&pow1);
 
-	if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-	{
-		pow2 = chargingData_2->DeratingChargingPower;
-		cur2 = chargingData_2->DeratingChargingCurrent;
-	}
-	else
-	{
-		pow2 = chargingData_2->AvailableChargingPower;
-		cur2 = chargingData_2->AvailableChargingCurrent;
-	}
+	pow2 = chargingData_2->AvailableChargingPower;
+	cur2 = chargingData_2->AvailableChargingCurrent;
 	vol = chargingData_2->MaximumChargingVoltage;
+
 	GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
 	GetMaxPowerMethod(&pow2);
 
@@ -1068,6 +1057,28 @@ void GetMaxPowerMethod(float *pow)
 		*pow = maxChargingPow;
 }
 
+time_t GetRtcInfoForEpoch()
+{
+	struct timeb csuTime;
+	struct tm *tmCSU;
+	struct tm t;
+	time_t result;
+
+	ftime(&csuTime);
+	tmCSU = localtime(&csuTime.time);
+
+	t.tm_year = tmCSU->tm_year;
+	t.tm_mon = tmCSU->tm_mon;
+	t.tm_mday = tmCSU->tm_mday;
+	t.tm_hour = tmCSU->tm_hour;
+	t.tm_min = tmCSU->tm_min;
+	t.tm_sec = tmCSU->tm_sec;
+	t.tm_isdst = -1;
+	result = mktime(&t);
+
+	return result;
+}
+
 byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
 {
 	byte result = NO;
@@ -1075,7 +1086,7 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
 	if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == 0x01)
 	{
 		// 012251
-		*(reason + 5) = 0;
+		*(reason + 5)  = 0;
 		*(reason + 4)  = 1;
 		*(reason + 3)  = 2;
 		*(reason + 2)  = 2;
@@ -1083,29 +1094,56 @@ byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
 		*(reason + 0)  = 1;
 		result = YES;
 	}
-	else if (_chargingData[gunIndex]->Type == _Type_Chademo &&
-			ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == 0x01)
+
+	if (_chargingData[gunIndex]->Type == _Type_Chademo)
 	{
-		// 011012
-		*(reason + 5) = 0;
-		*(reason + 4) = 1;
-		*(reason + 3) = 1;
-		*(reason + 2) = 0;
-		*(reason + 1) = 1;
-		*(reason + 0) = 2;
-		result = YES;
+		if (ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayDrivingFault == YES)
+		{
+			// 011012
+			*(reason + 5) = 0;
+			*(reason + 4) = 1;
+			*(reason + 3) = 1;
+			*(reason + 2) = 0;
+			*(reason + 1) = 1;
+			*(reason + 0) = 2;
+			result = YES;
+		}
+		else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.ChademoOutputUVPFail == YES)
+		{
+			// 012289
+			*(reason + 5) = 0;
+			*(reason + 4) = 1;
+			*(reason + 3) = 2;
+			*(reason + 2) = 2;
+			*(reason + 1) = 8;
+			*(reason + 0) = 9;
+			result = YES;
+		}
 	}
-	else if (_chargingData[gunIndex]->Type == _Type_CCS_2 &&
-			ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault == 0x01)
+	else if (_chargingData[gunIndex]->Type == _Type_CCS_2)
 	{
-		// 011014
-		*(reason + 5) = 0;
-		*(reason + 4) = 1;
-		*(reason + 3) = 1;
-		*(reason + 2) = 0;
-		*(reason + 1) = 1;
-		*(reason + 0) = 4;
-		result = YES;
+		if (ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsOutputRelayDrivingFault == YES)
+		{
+			// 011014
+			*(reason + 5) = 0;
+			*(reason + 4) = 1;
+			*(reason + 3) = 1;
+			*(reason + 2) = 0;
+			*(reason + 1) = 1;
+			*(reason + 0) = 4;
+			result = YES;
+		}
+		else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsOutputUVPFail == YES)
+		{
+			// 012288
+			*(reason + 5) = 0;
+			*(reason + 4) = 1;
+			*(reason + 3) = 2;
+			*(reason + 2) = 2;
+			*(reason + 1) = 8;
+			*(reason + 0) = 8;
+			result = YES;
+		}
 	}
 
 	return result;
@@ -1131,6 +1169,7 @@ int main(int argc, char *argv[])
 	CANReceiver();
 
 	byte priorityLow = 1;
+	time_t rtc = GetRtcInfoForEpoch();
 	while(CanFd)
 	{
 		for(byte _index = 0; _index < gun_count; _index++)
@@ -1141,6 +1180,7 @@ int main(int argc, char *argv[])
 				if (_chargingData[_index]->Type == _Type_Chademo &&
 						ShmCHAdeMOData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
 				{
+					SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
 					GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
 					GetHardwareVersion(_index, _chargingData[_index]->Evboard_id);
 				}
@@ -1149,6 +1189,7 @@ int main(int argc, char *argv[])
 					if (ShmCcsData->CommProtocol == 0x01 &&
 						ShmCcsData->V2GMessage_DIN70121[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
 					{
+						SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
 						GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
 						GetHardwareVersion(_index, _chargingData[_index]->Evboard_id);
 					}
@@ -1180,20 +1221,29 @@ int main(int argc, char *argv[])
 
 					if (priorityLow == 1)
 					{
-						maxChargingCur[_index] = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent;
-						maxChargingPow = ShmSysConfigAndInfo->SysConfig.MaxChargingPower;
+						maxChargingCur[_index] = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
+						maxChargingPow = (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10);
 					}
 					break;
+				case S_PREPARNING:
+				{
+					// 設定當前輸出
+					if (gun_count == 1)
+						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
+					else if (gun_count == 2)
+						SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
+				}
+					break;
 				case S_PREPARING_FOR_EV:
 				{
 					// 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
 					GetOutputReq(_index, _chargingData[_index]->Evboard_id);
 
-					//PRINTF_FUNC("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
-					//PRINTF_FUNC("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
-					//PRINTF_FUNC("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
-					//PRINTF_FUNC("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
-					//PRINTF_FUNC("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
+//					PRINTF_FUNC("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
+//					PRINTF_FUNC("PresentChargingCurrent = %f \n", _chargingData[_index]->PresentChargingCurrent);
+//					PRINTF_FUNC("AvailableChargingPower = %f \n", _chargingData[_index]->AvailableChargingPower);
+//					PRINTF_FUNC("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
+//					PRINTF_FUNC("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
 
 					// 設定當前輸出
 					if (gun_count == 1)
@@ -1205,19 +1255,12 @@ int main(int argc, char *argv[])
 					{
 						float maxVol, maxCur;
 						// 樁端輸出能力
-						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-						{
-							maxVol = _chargingData[_index]->MaximumChargingVoltage;
-							maxCur = _chargingData[_index]->DeratingChargingCurrent;
-						}
-						else
-						{
-							maxVol = _chargingData[_index]->MaximumChargingVoltage;
-							maxCur = _chargingData[_index]->AvailableChargingCurrent;
-						}
+						maxVol = _chargingData[_index]->MaximumChargingVoltage;
+						maxCur = _chargingData[_index]->AvailableChargingCurrent;
+
 						GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
 
-						PRINTF_FUNC("To EV Max_Vol = %f, Cap_Cur = %f \n", maxVol, maxCur);
+						PRINTF_FUNC("To EV_%d Max_Vol = %f, Cap_Cur = %f, Cap_Pow = %f \n", _index, maxVol, maxCur, _chargingData[_index]->AvailableChargingPower);
 						SetChargingPermission(_index, START,
 						_chargingData[_index]->AvailableChargingPower,
 								maxCur,
@@ -1354,16 +1397,8 @@ int main(int argc, char *argv[])
 						float maxVol, maxCur;
 
 						// 樁端輸出能力
-						if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag != _REASSIGNED_NONE)
-						{
-							maxVol = _chargingData[_index]->MaximumChargingVoltage;
-							maxCur = _chargingData[_index]->DeratingChargingCurrent;
-						}
-						else
-						{
-							maxVol = _chargingData[_index]->MaximumChargingVoltage;
-							maxCur = _chargingData[_index]->AvailableChargingCurrent;
-						}
+						maxVol = _chargingData[_index]->MaximumChargingVoltage;
+						maxCur = _chargingData[_index]->AvailableChargingCurrent;
 
 						GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
 						SetChargingPermission(_index, STOP,

+ 2 - 0
EVSE/Projects/DS60-120/Apps/Module_EvComm.h

@@ -27,6 +27,7 @@ extern struct Ev_Board_Cmd
 	int download_finish;				// 0x00001100
 
 	int isolation_status;				// 0x00001200
+	int sync_rtc_info;					// 0x00001400
 	int evse_precharge_info;			// 0x00001500
 }Ev_Cmd;
 
@@ -42,6 +43,7 @@ struct timeval _id_assign_time;
 void SetTargetAddr(byte *target_number, byte index);
 
 void GetFirmwareVersion(byte gun_index, byte toId);
+void SyncRtcInfo(byte gun_index, byte toId, int epoch);
 void GetHardwareVersion(byte gun_index, byte toId);
 void SetChargingPermission(byte gun_index, byte permissionStatus, short aOutputPw, short aOutputVol, short aOutputCur, byte toId);
 void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2);

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

@@ -78,16 +78,16 @@ int DiffTimeb(struct timeb ST, struct timeb ET)
 
 void PRINTF_FUNC(char *string, ...)
 {
-	if (DEBUG)
-	{
-		va_list args;
-		char buffer[4096];
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-		va_start(args, string);
-		vsnprintf(buffer, sizeof(buffer), string, args);
-		va_end(args);
+	if (DEBUG)
 		printf("%s \n", buffer);
-	}
+	else
+		DEBUG_INFO("%s \n", buffer);
 }
 
 //=================================
@@ -248,7 +248,7 @@ int main(void)
 		}
 
 		//check Alarm Status
-		for(ByteCount=0;ByteCount<11;ByteCount++)
+		for(ByteCount=0;ByteCount<12;ByteCount++)
 		{
 			if(ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount] != ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount])
 			{

+ 174 - 85
EVSE/Projects/DS60-120/Apps/Module_InternalComm.c

@@ -37,6 +37,8 @@
 #define YES					1
 #define NO					0
 #define TEN_MINUTES			600
+#define ENV_TEMP_MIN		45
+#define ENV_TEMP_MAX		50
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
@@ -44,9 +46,10 @@ struct FanModuleData			*ShmFanModuleData;
 struct RelayModuleData			*ShmRelayModuleData;
 struct CHAdeMOData				*ShmCHAdeMOData;
 struct CcsData					*ShmCcsData;
+struct PsuData 					*ShmPsuData;
 
 #define VIN_MAX_VOLTAGE		250	// 大於該值 : OVP
-#define VIN_MIN_VOLTAGE		170	// 小於該值 : UVP
+#define VIN_MIN_VOLTAGE		150	// 小於該值 : UVP
 #define VIN_DROP_VOLTAGE	150	// 小於該值 : ac drop
 
 #define VOUT_MAX_VOLTAGE	750
@@ -55,6 +58,7 @@ struct CcsData					*ShmCcsData;
 
 #define MAX_FAN_SPEED		13500
 #define MIN_FAN_SPEED		2800
+#define NORMAL_FAN_SPEED	7000
 
 // GFD Status
 #define GFD_IDLE			0
@@ -164,16 +168,16 @@ unsigned short MaxValue(unsigned short value1, unsigned short value2)
 
 void PRINTF_FUNC(char *string, ...)
 {
-	if (DEBUG)
-	{
-		va_list args;
-		char buffer[4096];
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-		va_start(args, string);
-		vsnprintf(buffer, sizeof(buffer), string, args);
-		va_end(args);
+	if (DEBUG)
 		printf("%s \n", buffer);
-	}
+	else
+		DEBUG_INFO("%s \n", buffer);
 }
 
 //==========================================
@@ -305,28 +309,26 @@ void GetPresentInputVol()
 	if (Query_Present_InputVoltage(Uart5Fd, Addr.Relay, &inputVoltage) == PASS)
 	{
 		// resolution : 0.1
-		//PRINTF_FUNC("InputVoltageR = %f \n", inputVoltage.L1N_L12);
-		//PRINTF_FUNC("InputVoltageS = %f \n", inputVoltage.L2N_L23);
-		//PRINTF_FUNC("InputVoltageT = %f \n", inputVoltage.L3N_L31);
-
-		ShmRelayModuleData->InputL1Volt = inputVoltage.L1N_L12;
-		ShmRelayModuleData->InputL2Volt = inputVoltage.L2N_L23;
-		ShmRelayModuleData->InputL3Volt = inputVoltage.L3N_L31;
+		ShmSysConfigAndInfo->SysInfo.InputVoltageR = ShmRelayModuleData->InputL1Volt = inputVoltage.L1N_L12;
+		ShmSysConfigAndInfo->SysInfo.InputVoltageS = ShmRelayModuleData->InputL2Volt = inputVoltage.L2N_L23;
+		ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData->InputL3Volt = inputVoltage.L3N_L31;
 
 		//********************************************************************************************************//
 		// VIN < 170
 		if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = 0x01;
-		}
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
+		else
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
+
 		if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = 0x01;
-		}
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
+		else
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
+
 		if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = 0x01;
-		}
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
+		else
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
 
 		//********************************************************************************************************//
 		// VIN > 250
@@ -506,7 +508,6 @@ void CheckK1K2RelayOutput(byte index)
 				else
 					_chargingData[index]->RelayKPK2Status = NO;
 			}
-
 		}
 	}
 	else if (index == 1)
@@ -529,6 +530,9 @@ void CheckK1K2RelayOutput(byte index)
 		ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
 	else
 		ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = NO;
+
+//	PRINTF_FUNC("Check Relay Output. index = %d, RelayKPK2Status = %d, BridgeRelayStatus = %d \n",
+//			index, _chargingData[index]->RelayKPK2Status, ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus);
 }
 
 void GetGfdAdc()
@@ -547,6 +551,8 @@ void GetGfdAdc()
 				{
 					DEBUG_ERROR("GFD Fail. index = %d, R = %d, Vol = %d \n",
 							i, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
+					PRINTF_FUNC("GFD Fail. index = %d, R = %d, Vol = %d \n",
+							i, gfd_adc.Resister_conn1, gfd_adc.voltage_conn1);
 				}
 			}
 			else if (i == 1)
@@ -556,6 +562,8 @@ void GetGfdAdc()
 				{
 					DEBUG_ERROR("GFD Fail. index = %d, R = %d, Vol = %d \n",
 							i, gfd_adc.Resister_conn2, gfd_adc.voltage_conn2);
+					PRINTF_FUNC("GFD Fail. index = %d, R = %d, Vol = %d \n",
+							i, gfd_adc.Resister_conn2, gfd_adc.voltage_conn2);
 				}
 			}
 		}
@@ -863,9 +871,19 @@ void SetK1K2RelayStatus(byte index)
 	}
 }
 
+void CheckPhaseLossStatus(byte index)
+{
+	if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES)
+	{
+		_chargingData[index]->StopChargeFlag = YES;
+	}
+}
+
 void SetParalleRelayStatus()
 {
-	if (gunCount >= 2 && ONE_CONNECTOR_USE == NO)
+	if (gunCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
 	{
 		if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING)
 		{
@@ -877,33 +895,49 @@ void SetParalleRelayStatus()
 		}
 		else
 		{
-			// 單槍充電中 - 搭上橋接
-			if((_chargingData[0]->IsReadyToCharging == YES && _chargingData[1]->IsReadyToCharging == NO) ||
-					(_chargingData[0]->IsReadyToCharging == NO && _chargingData[1]->IsReadyToCharging == YES))
+			if (_chargingData[0]->IsReadyToCharging == YES ||
+					_chargingData[1]->IsReadyToCharging == YES)
 			{
-				if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY)
+				// ************需考慮在切換中 - 切開 relay 與搭回 relay 的時機點************
+				if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
 				{
-					if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
-						outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-					else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
-						outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
+					if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_M_TO_A)
+					{
+						// 最大充 - 搭上橋接
+						if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
+							outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
+						else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
+							outputRelay.relay_event.bits.Gun1_Parallel_P = YES;
+					}
+					else
+					{
+						// 平均充 - 不搭
+						if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
+							outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
+						else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
+							outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
+					}
 				}
-				else
+				else if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
 				{
-					if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
-						outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
-					else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
-						outputRelay.relay_event.bits.Gun1_Parallel_P = YES;
+					if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_A_TO_M)
+					{
+						// 平均充 - 不搭
+						if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
+							outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
+						else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
+							outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
+					}
+					else
+					{
+						// 最大充 - 搭上橋接
+						if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
+							outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
+						else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
+							outputRelay.relay_event.bits.Gun1_Parallel_P = YES;
+					}
 				}
 			}
-			else
-			{
-				// 雙槍充電中~ 不搭橋接
-				if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
-					outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
-				else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
-					outputRelay.relay_event.bits.Gun1_Parallel_N = NO;
-			}
 		}
 	}
 }
@@ -979,6 +1013,23 @@ int InitShareMemory()
 		result = FAIL;
 	}
 
+	//creat ShmPsuData
+	if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData),  0777)) < 0)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmPsuData NG \n");
+		#endif
+		result = FAIL;
+	}
+	else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmat ShmPsuData NG \n");
+		#endif
+		result = FAIL;
+	}
+	memset(ShmPsuData,0,sizeof(struct PsuData));
+
 	if(CHAdeMO_QUANTITY > 0)
 	{
 		if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData),	IPC_CREAT | 0777)) < 0)
@@ -1226,7 +1277,9 @@ void CheckOutputPowerOverCarReq(byte index)
 	float carV = _chargingData[index]->EvBatterytargetVoltage;
 
 	if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
-			(_chargingData[index]->Type == _Type_Chademo || _chargingData[index]->Type == _Type_CCS_2 || _chargingData[index]->Type == _Type_GB))
+			(_chargingData[index]->Type == _Type_Chademo ||
+				_chargingData[index]->Type == _Type_CCS_2 ||
+				_chargingData[index]->Type == _Type_GB))
 	{
 		if (fireV >= (carV + (carV * 0.1)))
 		{
@@ -1242,7 +1295,9 @@ void CheckOutputPowerOverCarReq(byte index)
 void CheckOutputVolNoneMatchFire(byte index)
 {
 	if (_chargingData[index]->EvBatterytargetVoltage > 1500 &&
-			(_chargingData[index]->Type == _Type_Chademo || _chargingData[index]->Type == _Type_CCS_2 || _chargingData[index]->Type == _Type_GB))
+			(_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))
@@ -1256,17 +1311,45 @@ void CheckOutputVolNoneMatchFire(byte index)
 			{
 				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);
+					PRINTF_FUNC("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f \n",
+							index, _chargingData[index]->PresentChargingVoltage, _chargingData[index]->FireChargingVoltage);
+					DEBUG_ERROR("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f \n",
+							index, _chargingData[index]->PresentChargingVoltage, _chargingData[index]->FireChargingVoltage);
 					_chargingData[index]->StopChargeFlag = YES;
 				}
 			}
 		}
+		else
+			_isOutputNoneMatch[index] = NO;
 	}
 }
 
+void GetPsuTempForFanSpeed()
+{
+	char temp = 0;
+	for (byte index = 0; index < ShmPsuData->GroupCount; index++)
+	{
+		for (byte count = 0; count < ShmPsuData->PsuGroup[index].GroupPresentPsuQuantity; count++)
+		{
+			if (temp < ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp)
+				temp = ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp;
+		}
+	}
+
+	if (ShmFanModuleData->TestFanSpeed == NORMAL_FAN_SPEED)
+	{
+		if (temp >= ENV_TEMP_MAX)
+			ShmFanModuleData->TestFanSpeed = MAX_FAN_SPEED;
+	}
+	else if (ShmFanModuleData->TestFanSpeed == MAX_FAN_SPEED)
+	{
+		if (temp <= ENV_TEMP_MIN)
+			ShmFanModuleData->TestFanSpeed = NORMAL_FAN_SPEED;
+	}
+	else
+		ShmFanModuleData->TestFanSpeed = NORMAL_FAN_SPEED;
+}
+
 int main(void)
 {
 	if(InitShareMemory() == FAIL)
@@ -1288,7 +1371,7 @@ int main(void)
 
 	if(Uart5Fd < 0)
 	{
-		printf ("open port error. \n");
+		PRINTF_FUNC("(Internal) open port error. \n");
 		return 0;
 	}
 
@@ -1348,6 +1431,9 @@ int main(void)
 				// 依據當前各槍的狀態選擇 搭上/放開 Relay
 				SetK1K2RelayStatus(i);
 
+				if (ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy == YES)
+					CheckPhaseLossStatus(i);
+
 				if (_chargingData[i]->SystemStatus == S_IDLE)
 					gfdChkFailCount[i] = 0;
 
@@ -1384,25 +1470,25 @@ 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;
-//				}
-//			}
+			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 之前要先確認輸出的電壓電流是否已經降到某個值
@@ -1446,12 +1532,14 @@ int main(void)
 		{
 			if (GetTimeoutValue(_priority_time) / 1000 >= 1000)
 			{
+				GetPsuTempForFanSpeed();
+
 				GetFanSpeed();
+				//				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);
 				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 ||
@@ -1464,6 +1552,14 @@ int main(void)
 						ShmFanModuleData->SetFan3Speed = MAX_FAN_SPEED;
 						ShmFanModuleData->SetFan4Speed = MAX_FAN_SPEED;
 					}
+
+					if (ShmFanModuleData->TestFanSpeed > 0)
+					{
+						ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
+						ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
+						ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
+						ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
+					}
 				}
 				else
 				{
@@ -1479,13 +1575,6 @@ int main(void)
 					}
 				}
 
-				if (ShmFanModuleData->TestFanSpeed > 0)
-				{
-					ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
-					ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
-					ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
-					ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
-				}
 				//PRINTF_FUNC("set fan = %d \n", ShmFanModuleData->SetFan1Speed);
 				SetFanModuleSpeed();
 			}

+ 46 - 39
EVSE/Projects/DS60-120/Apps/Module_LcmControl.c

@@ -51,16 +51,16 @@ char* getTimeString(void)
 
 void PRINTF_FUNC(char *string, ...)
 {
-	if (DEBUG)
-	{
-		va_list args;
-		char buffer[4096];
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-		va_start(args, string);
-		vsnprintf(buffer, sizeof(buffer), string, args);
-		va_end(args);
+	if (DEBUG)
 		printf("%s \n", buffer);
-	}
+	else
+		DEBUG_INFO("%s \n", buffer);
 }
 
 //==========================================
@@ -166,7 +166,7 @@ void ReadMsgFromLcm(byte *msg, byte readLen)
 				case CMD_REGISTER:
 				{
 					// 頁面
-					_currentPage = (unsigned short) (*(msg + 6) << 8) + (unsigned short) *(msg + 7);
+					strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
 				}
 				break;
 			}
@@ -184,9 +184,6 @@ void ReadMsgFromLcm(byte *msg, byte readLen)
 //			}
 		}
 	}
-
-//	for (byte idx = 0; idx < len; idx++)
-//		PRINTF_FUNC("[system_command]-RX: %X\n", *(msg + idx));
 }
 
 //================================================
@@ -506,10 +503,11 @@ void ChangeBattMapAndValue(short page, int soc)
 			ChangeDisplay2Value(__batt_map, _battery_soc_100);
 	}
 
-	byte cmd[4];
-	byte value[4];
+	byte cmd[5];
+	byte value[5];
 
 	memset(cmd, 0x00, sizeof(cmd));
+	memset(value, 0x00, sizeof(value));
 	sprintf((char *)value, "%d%%", soc);
 	string2ByteArray(value, cmd);
 	DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
@@ -815,7 +813,7 @@ void ProcessPageInfo()
 
 void Initialization()
 {
-	strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
+	//strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
 
 	bool isPass = false;
 	byte count = 5;
@@ -863,40 +861,49 @@ int main(void)
 //	return 0;
 	while(_port != -1)
 	{
-		//DemoFunction();
-
-		// Warning 處理
-		if(curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
+		if (strlen((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev) != 0 ||
+				ShmSysConfigAndInfo->SysInfo.LcmHwRev[0] != '\0')
 		{
-			changeWarningPriority = 0;
-			ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
-			curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
-			ChangeWarningFunc();
+			GetCurrentPage();
+			sleep(1);
 		}
-		else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0)
+		else
 		{
-			// 當有兩頁 Warning 則每隔三秒改變一次
-			if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
-				ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
-			else
+			//DemoFunction();
+
+			// Warning 處理
+			if(curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
+			{
+				changeWarningPriority = 0;
 				ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
+				curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
+				ChangeWarningFunc();
+			}
+			else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0)
+			{
+				// 當有兩頁 Warning 則每隔三秒改變一次
+				if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
+					ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
+				else
+					ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
 
-			ChangeWarningFunc();
-		}
+				ChangeWarningFunc();
+			}
 
-		// 頁面資訊處理
-		ProcessPageInfo();
+			// 頁面資訊處理
+			ProcessPageInfo();
 
-		// 網路 - wifi - 連線訊號處理
-		RefreshConnStatus();
+			// 網路 - wifi - 連線訊號處理
+			RefreshConnStatus();
 
-		// 換頁處理
-		ChangeCurPage();
+			// 換頁處理
+			ChangeCurPage();
 
-		RefreshPageAnimation(_everyPageRollChange);
+			RefreshPageAnimation(_everyPageRollChange);
 
-		changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
-		usleep(100000);
+			changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
+			usleep(100000);
+		}
 	}
 
 	CloseCommunicationLcmPort();

+ 8 - 8
EVSE/Projects/DS60-120/Apps/Module_PrimaryComm.c

@@ -97,16 +97,16 @@ int DiffTimeb(struct timeb ST, struct timeb ET)
 
 void PRINTF_FUNC(char *string, ...)
 {
-	if (DEBUG)
-	{
-		va_list args;
-		char buffer[4096];
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-		va_start(args, string);
-		vsnprintf(buffer, sizeof(buffer), string, args);
-		va_end(args);
+	if (DEBUG)
 		printf("%s \n", buffer);
-	}
+	else
+		DEBUG_INFO("%s \n", buffer);
 }
 //=================================
 // Common routine

Diff do ficheiro suprimidas por serem muito extensas
+ 348 - 504
EVSE/Projects/DS60-120/Apps/Module_PsuComm.c


+ 7 - 48
EVSE/Projects/DS60-120/Apps/Module_PsuComm.h

@@ -32,60 +32,19 @@
 #include	"../../define.h"
 #include 	<stdbool.h>
 
-
 typedef unsigned char 		byte;
-typedef unsigned short 		word;
+typedef unsigned short 	word;
 typedef unsigned int 		unit;
 
-#define SELF_TEST_VOL				1600
-#define SELF_TEST_CUR				10
-#define ZERO_VOL					0
-#define ZERO_CUR					0
-#define NONE_CARE_ADDRESS			0
-#define SWITCH_ON		2
-#define SWITCH_OFF		0
-
-
-#define SET_MODULE_CMD              0
-#define SET_GROUP_CMD              1
-
-enum _FIRMWARE_TYPE
-{
-	_Fw_pri_app = 		0,
-	_Fw_sec_app,
-	_Fw_pri_bootload,
-	_Fw_sec_bootload
-};
-
-struct _RecordPsuData
-{
-	byte 				_phy_addr;
-	char 				_serial_num[32];
-	byte 				_fire_index;
-
-};
-
 unsigned char _gunCount = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
 struct ChargingInfoData *chargingInfo[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-bool rework = false;
-
-struct timeval _id_assign_time;
-struct timeval _chk_output_time;
-bool isCheckOutputTimeStart = false;
-
-byte _curCheckPsuIndexForFireLine = 0x00;
-struct _RecordPsuData recordPsuData[PSU_QUANTITY];
 
-struct timeval _chk_cap_time;
-bool _chkTotalCapStart = false;
-
-bool isUpgradeFlag = false;
-
-struct timeval _workModePriority_time;
+struct timeval _cmdSubPriority_time;
+byte _getCapDelayCount;
+struct timeval _averageComp_time;
 struct timeval _derating_time;
-int deratingTime = 0;
+
+struct timeval _test_time;
 
 int connector_1[] = {0};
-int connector_2[] = {1};
-int conn_1_count = 0;
-int conn_2_count = 0;
+int connector_2[] = {1, 2};

+ 42 - 33
EVSE/Projects/DS60-120/Apps/ReadCmdline.c

@@ -203,6 +203,8 @@ void RunStatusProc(char *v1, char *v2)
 	{
 		// get
 		printf ("index = %x, status = %x (%d)\n", _index, _chargingData[_index]->SystemStatus, _chargingData[_index]->IsAvailable);
+		printf ("SystemTimeoutFlag = %d, PageIndex = %d\n",
+				ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag, ShmSysConfigAndInfo->SysInfo.PageIndex);
 	}
 	else
 	{
@@ -248,15 +250,14 @@ void RunGunPlugitProc(char *v1, char *v2)
 
 void GetGunLockStatusProc(char *v1, char *v2)
 {
-	if (strcmp(v1, "0") == 0)
+	int _index = atoi(v1);
+	if (!FindChargingInfoData(_index, &_chargingData[0]))
 	{
-		printf("Gun Locked Status = %x \n", _chargingData[0]->GunLocked);
+		printf("FindChargingInfoData error\n");
+		return;
 	}
 
-	if (strcmp(v1, "1") == 0)
-	{
-		printf("Gun Locked Status = %x \n", _chargingData[1]->GunLocked);
-	}
+	printf("Gun Locked Status = %x \n", _chargingData[_index]->GunLocked);
 }
 
 void SetSystemIDProc()
@@ -283,8 +284,8 @@ void GetFwVerProc(char *v1)
 	}
 	else if (strcmp(v1, "1") == 0)
 	{
-		printf("Ev board 2 FW Version = %s \n", ShmCHAdeMOData->evse[1].version);
 		printf("Ev board 2 FW Version = %s \n", ShmCcsData->V2GMessage_DIN70121->version);
+		printf("Ev board 2 FW Version = %s \n", ShmCHAdeMOData->evse[1].version);
 	}
 	else if (strcmp(v1, "rb") == 0)
 	{
@@ -327,20 +328,15 @@ void SetCableChkStatus(char *v1, char *v2)
 
 void SetPowerValue(char *v1, char *v2)
 {
-//	int _index = atoi(v1);
-//	if (!FindChargingInfoData(_index, &_chargingData[0])) {
-//		printf("FindChargingInfoData error\n");
-//		return;
-//	}
-//
-//	if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-//		// get
-//		printf("index = %x, max cur = %f\n", _index,
-//				_chargingData[_index]->MaxChargingCurrentForTest);
-//	} else {
-//		// set
-//		_chargingData[_index]->MaxChargingCurrentForTest = atoi(v2);
-//	}
+	int _index = atoi(v1);
+	float _Current = atof(v2);
+	if (!FindChargingInfoData(_index, &_chargingData[0]))
+	{
+		printf ("FindChargingInfoData error\n");
+		return;
+	}
+
+	_chargingData[_index]->EvBatterytargetCurrent = _Current * 10;
 }
 
 void GetGunSelectedNum(char *v1)
@@ -434,7 +430,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 {
 	int _GunIndex = atoi(v1);
 	float _Voltage = atof(v2);
-	int _Current = atoi(v3);
+	float _Current = atof(v3);
 	unsigned char PreviousSystemStatus = 0xff;
 	int ch = 0;
 
@@ -444,9 +440,10 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 		return;
 	}
 
-    printf ("ReqVoltage = %f, ReqCurrent = %d\n", _Voltage,_Current);
+    printf ("ReqVoltage = %f, ReqCurrent = %f\n", _Voltage, _Current);
 
-    if(_Voltage > 1000 || _Voltage < 150){
+    if(_Voltage > 1000 || _Voltage < 50)
+    {
 
         printf ("Input Voltage over range\n");
         return;
@@ -530,7 +527,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
         	        PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
 
         	        printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
-        	        printf ("ReqVoltage = %f, ReqCurrent = %d\n", _Voltage,_Current);
+        	        printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage,_Current);
 
         	    }
     		    //清除 main timeout 機制
@@ -610,14 +607,14 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
         	    {
         	        PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
 
-        	        printf ("[UnconditionalCharge - S_CHARGING]\n");
+        	        //充電電壓電流
+        	        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
+        	        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _Voltage;
+        	        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _Current;
+        	        _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
 
+        	        printf ("[UnconditionalCharge - S_CHARGING]\n");
         	    }
-    		    //充電電壓電流
-    		    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
-    		    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _Voltage;
-    		    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _Current;
-    		    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
 
     		    //ev task do this
     		    _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingPower = ((float)((_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage / 10) * (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingCurrent / 10)) / 1000);
@@ -707,6 +704,14 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 
 }
 
+void test()
+{
+	printf("L1 = %d, L2 = %d, L3 = %d \n", ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP,
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP,
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP);
+	printf("ExtraErrProcess = %d \n", ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess);
+}
+
 int main(void)
 {
 	if(InitShareMemory() == FAIL)
@@ -843,6 +848,10 @@ int main(void)
 			// 取得 PSU 資訊
 			GetPsuInformation(newString[1]);
 		}
+		else if(strcmp(newString[0], "test") == 0)
+		{
+			test();
+		}
 		else if(strcmp(newString[0], "strchg") == 0)
 		{
 			//如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
@@ -856,8 +865,8 @@ int main(void)
 			// 槍狀態
 			RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
 		}
-
-		printf ("%s\n", msg);
+		else
+			printf ("%s\n", msg);
 		usleep(100000);
 	}
 

+ 1 - 11
EVSE/Projects/DS60-120/Apps/internalComm.c

@@ -48,7 +48,7 @@ int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char*
 	tcflush(fd,TCIOFLUSH);
 	if(write(fd, cmd, cmd_len) >= cmd_len)
 	{
-		usleep(10000);
+		usleep(30000);
 		len = read(fd, rx, 512);
 	}
 	else
@@ -205,11 +205,6 @@ unsigned char Query_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpe
 	unsigned char chksum = 0x00;
 	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
 
-//		for (int i = 0; i < 7; i++)
-//			printf("tx = %x \n", tx[i]);
-//		for (int i = 0; i < len; i++)
-//			printf("rx = %x \n", rx[i]);
-
 	if(len > 6)
 	{
 		if (len < 6+(rx[4] | rx[5]<<8))
@@ -454,12 +449,7 @@ unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSp
 		chksum ^= tx[6+idx];
 	tx[14] = chksum;
 
-//		for(int i = 0; i < 15; i++)
-//			printf ("tx = %x \n", tx[i]);
-
 	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-//	for(int i = 0; i < len; i++)
-//				printf ("rx = %x \n", rx[i]);
 	if(len > 6)
 	{
 		if (len < 6+(rx[4] | rx[5]<<8))

Diff do ficheiro suprimidas por serem muito extensas
+ 380 - 134
EVSE/Projects/DS60-120/Apps/main.c


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

@@ -44,8 +44,7 @@ enum Timeout_flag
 	Timeout_Preparing = 				6,
 	Timeout_EvChargingDet = 			7,
 	Timeout_EvseChargingDet = 			8,
-	Timeout_WaitforCompleteDet = 		9,
-
+	Timeout_EvseCompleteDet = 			9,
 	Timeout_ForCcsPrechargeDet = 		10,
 	Timeout_ReturnToChargingGunDet = 	11
 };

BIN
EVSE/Projects/DS60-120/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/DS60-120/Images/MLO


BIN
EVSE/Projects/DS60-120/Images/am335x-evm.dtb


BIN
EVSE/Projects/DS60-120/Images/ramdisk.gz


BIN
EVSE/Projects/DS60-120/Images/u-boot.img


BIN
EVSE/Projects/DS60-120/Images/zImage


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff