Przeglądaj źródła

2020-11-26 / Alston Lin

Actions
1. Remove the under voltage protection
2. When upgradeing, the status change to S_UPDATE
3. Change the PHY reset sequence
4. If configured to output 0A, then limit psu to output 1A
5. System Optimization

Files
1. As follow commit history
Alston 4 lat temu
rodzic
commit
dc87c97953

+ 68 - 126
EVSE/Projects/DS60-120/Apps/Module_EvComm.c

@@ -54,27 +54,7 @@ struct PsuData 					*ShmPsuData;
 byte gun_count;
 int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-float _pow_1 = 0;
-float _cur_1 = 0;
-float _pow_2 = 0;
-float _cur_2 = 0;
-
-float _outVol_1 = 0;
-float _outCur_1 = 0;
-float _outVol_2 = 0;
-float _outCur_2 = 0;
-
-float _maxVol_1 = 0;
-float _cap_cur_1 = 0;
-float _cap_pw_1	= 0;
-float _maxVol_2 = 0;
-float _cap_cur_2 = 0;
-float _cap_pw_2	= 0;
-
-float _max_battery_vol_1 = 0;
-float _max_battery_vol_2 = 0;
-float _real_1_pow = 0;
-float _real_2_pow = 0;
+float LogInfo[2][10];
 
 // 限制最大充電電壓,因應不同 type 槍線來限制
 // Chademo : 500V, 125A,
@@ -86,7 +66,7 @@ double gbVol = 7500;
 float maxChargingVol[2] = { 0, 0 };			// 限制最大充電電壓,如依照模塊則填上 0
 // 限制最大充電電流與能量透過 Web
 float maxChargingCur[2] = { 0, 0 };			// 限制最大充電電流,如依照模塊則填上 0
-float maxChargingPow = 0;							// 限制最大充電能量,如依照模塊則填上 0
+float maxChargingPow = 0;					// 限制最大充電能量,如依照模塊則填上 0
 
 // 槍資訊
 struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
@@ -2820,17 +2800,6 @@ void CANReceiver()
 						{
 							if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121)
 							{
-//								for (byte _vCount = 0, _vPoint = 0; _vCount < frame.can_dlc; _vCount++)
-//								{
-//									if (_vCount % 2 == 0 && _vCount != 0)
-//									{
-//										ver[_vCount + _vPoint] = 0x2E;
-//										_vPoint++;
-//									}
-//
-//									ver[_vCount + _vPoint] = frame.data[_vCount];
-//								}
-
 								memcpy(ver, frame.data, frame.can_dlc);
 								memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
 								ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
@@ -2919,23 +2888,6 @@ void CANReceiver()
 						_chargingData[targetGun]->EvBatteryMaxVoltage = (((short) frame.data[4] << 8) + (short) frame.data[3]) / 10;
 						//_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
 						//_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
-						if (targetGun == 0)
-						{
-							if (_max_battery_vol_1 != _chargingData[targetGun]->EvBatteryMaxVoltage)
-							{
-								_max_battery_vol_1 = _chargingData[targetGun]->EvBatteryMaxVoltage;
-								PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", targetGun, _chargingData[targetGun]->EvBatteryMaxVoltage);
-							}
-						}
-						else if (targetGun == 1)
-						{
-							if (_max_battery_vol_2 != _chargingData[targetGun]->EvBatteryMaxVoltage)
-							{
-								_max_battery_vol_2 = _chargingData[targetGun]->EvBatteryMaxVoltage;
-								PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", targetGun, _chargingData[targetGun]->EvBatteryMaxVoltage);
-							}
-						}
-
 
 						if (_chargingData[targetGun]->Type == _Type_Chademo)
 						{
@@ -3068,17 +3020,21 @@ void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, stru
 
 	cur2 = (chargingData_2->PresentChargingCurrent * 10);
 
+
 	if (
-		(_outVol_1 >= vol1 + CHK_VOL_RANGE) || (_outVol_1 <= vol1 - CHK_VOL_RANGE) ||
-		(_outVol_2 >= vol2 + CHK_VOL_RANGE) || (_outVol_2 <= vol2 - CHK_VOL_RANGE) ||
-		(_outCur_1 >= cur1 + CHK_CUR_RANGE) || (_outCur_1 <= cur1 - CHK_CUR_RANGE) ||
-		(_outCur_2 >= cur2 + CHK_CUR_RANGE) || (_outCur_2 <= cur2 - CHK_CUR_RANGE)
+		(LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] >= vol1 + CHK_VOL_RANGE) || (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] <= vol1 - CHK_VOL_RANGE) ||
+		(LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] >= cur1 + CHK_CUR_RANGE) || (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] <= cur1 - CHK_CUR_RANGE) ||
+		(LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] >= vol2 + CHK_VOL_RANGE) || (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] <= vol2 - CHK_VOL_RANGE) ||
+		(LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) || (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
 		)
 	{
 		PRINTF_FUNC("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f \n",
 			vol1 / 10, cur1 / 10, vol2 / 10, cur2 / 10);
 
-		_outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
+		LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] = vol1;
+		LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] = cur1;
+		LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] = vol2;
+		LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] = cur2;
 	}
 
 	SetPresentOutputPower(vol1, cur1, vol2, cur2);
@@ -3106,7 +3062,7 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
 			float maxCur = 0;
 			maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
 
-			if (maxCur * 10 <= cur1 - 10)
+			if (maxCur * 10 <= cur1)
 			{
 				//PRINTF_FUNC("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
 				cur1 = maxCur * 10;
@@ -3130,7 +3086,7 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
 			float maxCur = 0;
 			maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
 
-			if (maxCur * 10 <= cur2 - 10)
+			if (maxCur * 10 <= cur2)
 			{
 				//PRINTF_FUNC("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
 				cur2 = maxCur * 10;
@@ -3138,18 +3094,21 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
 		}
 	}
 
-	if ((_pow_1 <= pow1 - 0.5 || _pow_1 >= pow1 + 0.5) ||
-		(_cur_1 <= cur1 - 0.5 || _cur_1 >= cur1+ 0.5) ||
-		(_pow_2 <=  pow2 - 0.5 || _pow_2 >=  pow2 + 0.5) ||
-		(_cur_2 <=  cur2 - 0.5 || _cur_2 >=  cur2 + 0.5))
+	if ((LogInfo[0][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 0.5 || LogInfo[0][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 0.5) ||
+		(LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] <= cur1 - 0.5 || LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] >= cur1+ 0.5) ||
+		(LogInfo[1][EV_LOG_OUTPUT_CAP_POW] <=  pow2 - 0.5 || LogInfo[1][EV_LOG_OUTPUT_CAP_POW] >=  pow2 + 0.5) ||
+		(LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <=  cur2 - 0.5 || LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >=  cur2 + 0.5))
 	{
 		PRINTF_FUNC("----------------------------------------------------- \n");
 		PRINTF_FUNC("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f \n",
 				pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
 		PRINTF_FUNC("----------------------------------------------------- \n");
 
-		_pow_1 = pow1; _cur_1 = cur1; _pow_2 = pow2; _cur_2 = cur2;
-		chargingData_1->RealMaxCurrent = _cur_1;
+		LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
+		LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
+		LogInfo[1][EV_LOG_OUTPUT_CAP_POW] = pow2;
+		LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] = cur2;
+		chargingData_1->RealMaxCurrent = cur1;
 		chargingData_1->RealMaxPower = pow1;
 
 		if (gun_count == 2)
@@ -3588,12 +3547,16 @@ int main(int argc, char *argv[])
 						_chargingData[_index]->ChargingFee = 0.0;
 						_chargingData[_index]->EvBatterySoc = 0;
 						_chargingData[_index]->EvBatteryStartSoc = 0;
-						_chargingData[_index]->PresentChargingVoltage = 0;
-						_chargingData[_index]->PresentChargingCurrent = 0;
 						_chargingData[_index]->EvBatteryMaxVoltage = 0;
 						_chargingData[_index]->ChargingProfilePower = -1;
 						_chargingData[_index]->ChargingProfileCurrent = -1;
 
+						if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
+						{
+							_chargingData[_index]->PresentChargingVoltage = 0;
+							_chargingData[_index]->PresentChargingCurrent = 0;
+						}
+
 						chargingTime[_index] = 0;
 						SendErrorCount[_index] = 0;
 
@@ -3604,22 +3567,11 @@ int main(int argc, char *argv[])
 								ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10 < maxChargingPow)
 							maxChargingPow = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
 
-						if (_index == 0)
-						{
-							_maxVol_1 = 0;
-							_cap_cur_1 = 0;
-							_cap_pw_1	= 0;
-							_max_battery_vol_1 = 0;
-							_real_1_pow = 0;
-						}
-						else if (_index == 1)
-						{
-							_maxVol_2 = 0;
-							_cap_cur_2 = 0;
-							_cap_pw_2 = 0;
-							_max_battery_vol_2 = 0;
-							_real_2_pow = 0;
-						}
+						LogInfo[_index][EV_LOG_EVSE_MAX_VOL] = 0;
+						LogInfo[_index][EV_LOG_EVSE_MAX_CUR] = 0;
+						LogInfo[_index][EV_LOG_MAX_BATT_VOL] = 0;
+						LogInfo[_index][EV_LOG_REAL_CAP_POW] = 0;
+						LogInfo[_index][EV_LOG_SOC] = 0;
 					}
 					break;
 				case S_PREPARNING:
@@ -3639,12 +3591,6 @@ int main(int argc, char *argv[])
 					// 開始確認車端是否同意開始充電 : 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);
-
 					// 設定當前輸出
 					if (gun_count == 1)
 						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
@@ -3660,29 +3606,14 @@ int main(int argc, char *argv[])
 
 						GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
 
-						if (_index == 0)
+						if (LogInfo[_index][EV_LOG_EVSE_MAX_VOL] != maxVol ||
+								LogInfo[_index][EV_LOG_EVSE_MAX_CUR] != maxCur)
 						{
-							if (_maxVol_1 != maxVol || _cap_cur_1 != maxCur ||
-									_cap_pw_1 != _chargingData[_index]->AvailableChargingPower)
-							{
-								_maxVol_1 = maxVol; _cap_cur_1 = maxCur;
-								_cap_pw_1 = _chargingData[_index]->AvailableChargingPower;
+							LogInfo[_index][EV_LOG_EVSE_MAX_VOL] = maxVol;
+							LogInfo[_index][EV_LOG_EVSE_MAX_CUR] = maxCur;
 
-								PRINTF_FUNC("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f \n",
-									_index, maxVol / 10, maxCur / 10, _chargingData[_index]->AvailableChargingPower / 10);
-							}
-						}
-						else if (_index == 1)
-						{
-							if (_maxVol_2 != maxVol || _cap_cur_2 != maxCur ||
-									_cap_pw_2 != _chargingData[_index]->AvailableChargingPower)
-							{
-								_maxVol_2 = maxVol; _cap_cur_2 = maxCur;
-								_cap_pw_2 = _chargingData[_index]->AvailableChargingPower;
-
-								PRINTF_FUNC("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f \n",
-									_index, maxVol / 10, maxCur / 10, _chargingData[_index]->AvailableChargingPower / 10);
-							}
+							PRINTF_FUNC("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f \n",
+								_index, maxVol / 10, maxCur / 10, _chargingData[_index]->AvailableChargingPower / 10);
 						}
 
 						_chargingData[_index]->RealMaxVoltage = maxVol;
@@ -3720,6 +3651,19 @@ int main(int argc, char *argv[])
 						else if (gun_count == 2)
 							SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
 					}
+
+					if (LogInfo[_index][EV_LOG_MAX_BATT_VOL] != _chargingData[_index]->EvBatteryMaxVoltage)
+					{
+						LogInfo[_index][EV_LOG_MAX_BATT_VOL] = _chargingData[_index]->EvBatteryMaxVoltage;
+						PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", _index, _chargingData[_index]->EvBatteryMaxVoltage);
+					}
+
+					if (LogInfo[_index][EV_LOG_SOC] != _chargingData[_index]->EvBatterySoc)
+					{
+						LogInfo[_index][EV_LOG_SOC] = _chargingData[_index]->EvBatterySoc;
+						PRINTF_FUNC("index = %d, SOC = %d \n", _index, _chargingData[_index]->EvBatterySoc);
+					}
+
 					// 持續通知 Isolation 測試狀態
 					if (priorityLow == 1)
 					{
@@ -3749,26 +3693,12 @@ int main(int argc, char *argv[])
 										_chargingData[_index]->RealRatingPower > 0) ||
 										(GetTimeoutValue(_chk_ratingPower_timeout[_index]) / 1000) > 14000)
 								{
-									if (_index == 0)
-									{
-										if (_real_1_pow != _chargingData[_index]->RealRatingPower)
-										{
-											_real_1_pow = _chargingData[_index]->RealRatingPower;
-											PRINTF_FUNC("Conn %d, RealRatingPower = %d \n",
-														_index, _chargingData[_index]->RealRatingPower);
-										}
-									}
-									else if (_index == 1)
+									if (LogInfo[_index][EV_LOG_REAL_CAP_POW] != _chargingData[_index]->RealRatingPower)
 									{
-										if (_real_2_pow != _chargingData[_index]->RealRatingPower)
-										{
-											_real_2_pow = _chargingData[_index]->RealRatingPower;
-											PRINTF_FUNC("Conn %d, RealRatingPower = %d \n",
-														_index, _chargingData[_index]->RealRatingPower);
-										}
+										LogInfo[_index][EV_LOG_REAL_CAP_POW] = _chargingData[_index]->RealRatingPower;
+										PRINTF_FUNC("Conn %d, RealRatingPower = %d \n",
+											_index, _chargingData[_index]->RealRatingPower);
 									}
-
-									//_result = GFD_PASS;
 								}
 								else
 									_result = GFD_WAIT;
@@ -3816,6 +3746,18 @@ int main(int argc, char *argv[])
 					// 開始確認車端是否同意開始充電
 					GetOutputReq(_index, _chargingData[_index]->Evboard_id);
 
+					if (LogInfo[_index][EV_LOG_MAX_BATT_VOL] != _chargingData[_index]->EvBatteryMaxVoltage)
+					{
+						LogInfo[_index][EV_LOG_MAX_BATT_VOL] = _chargingData[_index]->EvBatteryMaxVoltage;
+						PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", _index, _chargingData[_index]->EvBatteryMaxVoltage);
+					}
+
+					if (LogInfo[_index][EV_LOG_SOC] != _chargingData[_index]->EvBatterySoc)
+					{
+						LogInfo[_index][EV_LOG_SOC] = _chargingData[_index]->EvBatterySoc;
+						PRINTF_FUNC("index = %d, SOC = %d \n", _index, _chargingData[_index]->EvBatterySoc);
+					}
+
 					// 設定當前輸出
 					if (gun_count == 1)
 						SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);

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

@@ -75,5 +75,18 @@ enum Receieve_PSU_msgf
 	ACK_EVSE_PRECHAGE_INFO = 			0x08001500,
 };
 
+enum EV_LOG_INDEX
+{
+	EV_LOG_OUTPUT_CAP_POW = 0,
+	EV_LOG_OUTPUT_CAP_CUR = 1,
+	EV_LOG_NOW_OUTPUT_VOL = 2,
+	EV_LOG_NOW_OUTPUT_CUR = 3,
+	EV_LOG_EVSE_MAX_VOL = 	4,
+	EV_LOG_EVSE_MAX_CUR = 	5,
+	EV_LOG_MAX_BATT_VOL	= 	6,
+	EV_LOG_REAL_CAP_POW	= 	7,
+	EV_LOG_SOC = 			8
+};
+
 #endif /* MODULE_EVCOMM_H_ */
 

+ 56 - 3
EVSE/Projects/DS60-120/Apps/Module_EventLogging.c

@@ -46,6 +46,7 @@ int StoreLogMsg(const char *fmt, ...);
 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define EVENT_INFO(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 
 int StoreLogMsg(const char *fmt, ...)
 {
@@ -82,6 +83,52 @@ int StoreLogMsg(const char *fmt, ...)
 	return rc;
 }
 
+int StoreEventLogMsg(const char *fmt, ...)
+{
+	char Buf[4096+256];
+	char buffer[4096];
+	time_t CurrentTime;
+	struct tm *tm;
+	struct timeval tv;
+	va_list args;
+
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
+
+	memset(Buf,0,sizeof(Buf));
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
+	{
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/EventLog/[%04d.%02d]%s_%s_EventLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
+					buffer,
+					tm->tm_year+1900,tm->tm_mon+1,
+					ShmSysConfigAndInfo->SysConfig.ModelName,
+					ShmSysConfigAndInfo->SysConfig.SerialNumber);
+	}
+	else
+	{
+		sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/EventLog/[%04d.%02d]EventLog",
+					tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
+					buffer,
+					tm->tm_year+1900,tm->tm_mon+1);
+	}
+
+#ifdef SystemLogMessage
+	system(Buf);
+#endif
+
+#ifdef ConsloePrintLog
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
+#endif
+
+	return rc;
+}
+
 int DiffTimeb(struct timeb ST, struct timeb ET)
 {
 	//return milli-second
@@ -338,8 +385,10 @@ int main(void)
 							DEBUG_INFO("Fault Code = %s\n", EventCodeTmp);
 							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] |= (1<<BitCount);
 							AddFaultCodeToBuf(EventCodeTmp);
-							DB_Insert_Record(localDb, EventCodeTmp);
 						}
+
+						EVENT_INFO("%s\n", EventCodeTmp);
+						DB_Insert_Record(localDb, EventCodeTmp);
 					}
 				}
 			}
@@ -369,8 +418,10 @@ int main(void)
 							DEBUG_INFO("Alarm Code = %s\n", EventCodeTmp);
 							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] |= (1<<BitCount);
 							AddFaultCodeToBuf(EventCodeTmp);
-							DB_Insert_Record(localDb, EventCodeTmp);
 						}
+
+						EVENT_INFO("%s\n", EventCodeTmp);
+						DB_Insert_Record(localDb, EventCodeTmp);
 					}
 				}
 			}
@@ -400,8 +451,10 @@ int main(void)
 							DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
 							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1<<BitCount);
 							AddFaultCodeToBuf(EventCodeTmp);
-							DB_Insert_Record(localDb, EventCodeTmp);
 						}
+
+						EVENT_INFO("%s\n", EventCodeTmp);
+						DB_Insert_Record(localDb, EventCodeTmp);
 					}
 				}
 			}

+ 8 - 3
EVSE/Projects/DS60-120/Apps/Module_InternalComm.c

@@ -1925,9 +1925,6 @@ void GetPsuTempForFanSpeed()
 
 void GetFanSpeedByFunction()
 {
-	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
-		return;
-
 	// 風控修改 :
 	// ******************************************************* //
 	//
@@ -1967,6 +1964,14 @@ void GetFanSpeedByFunction()
 	if (temp > 70)
 		_temp_diff = temp - 70;
 
+	// debug mode 直接印出資訊後離開
+	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
+	{
+//		printf("Fan Speed Information: power = %f, _maxPower = %d, temp = %d -- _pw_rate = %f, _temp_rate = %f, _temp_diff = %d \n",
+//				power, _maxPower, temp, _pw_rate, _temp_rate, _temp_diff);
+		return;
+	}
+
 	ShmFanModuleData->TestFanSpeed = (((50 * _pw_rate * _temp_rate) + (0.5 * _temp_diff)) / 100) * MAX_FAN_SPEED;
 
 	if (ShmFanModuleData->TestFanSpeed > MAX_FAN_SPEED)

+ 3 - 2
EVSE/Projects/DS60-120/Apps/Module_LcmControl.c

@@ -1024,10 +1024,11 @@ void ProcessPageInfo()
 {
 	_page_reload = IsPageReloadChk();
 
+	// ÀH´¡§Y¥R - ¥i¬Ù²¤¸Ó«ö¶s
 	if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE)
 	{
 		ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
-		if (_totalCount >= 2)
+		if (_totalCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
 			ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
 		else
 			ChangeDisplay2Value(__sel_gun_btn, _disappear);
@@ -1089,7 +1090,7 @@ void ProcessPageInfo()
 					break;
 				}
 
-				if (isCharging)
+				if (isCharging && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
 				{
 					ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
 				}

+ 12 - 22
EVSE/Projects/DS60-120/Apps/Module_PsuComm.c

@@ -23,6 +23,7 @@
 #define CMD_DELAY_TIME 		25000
 #define LOG_VOL_GAP			50
 #define LOG_CUR_GAP			5
+#define PSU_MIN_OUTPUT_CUR	1
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
@@ -1630,7 +1631,7 @@ int main(void)
 									}
 								}
 
-								PRINTF_FUNC("Index = %d, DividChargingCurrent = %f \n", groupIndex, chargingInfo[groupIndex]->DividChargingCurrent);
+								PRINTF_FUNC("Index = %d, DividChargingCurrent = %.1f \n", groupIndex, chargingInfo[groupIndex]->DividChargingCurrent);
 							}
 							else
 							{
@@ -1745,6 +1746,9 @@ int main(void)
 											chargingInfo[groupIndex]->MaxChargingToAverPassFlag == 0)
 										{
 											chargingInfo[groupIndex]->MaxChargingToAverPassFlag = 1;
+
+											if(chargingInfo[groupIndex]->EvBatterytargetCurrent <= PSU_MIN_OUTPUT_CUR)
+												chargingInfo[groupIndex]->EvBatterytargetCurrent = PSU_MIN_OUTPUT_CUR;
 											PresentOutputVol(groupIndex, targetVol, (chargingInfo[groupIndex]->EvBatterytargetCurrent * 10)); Await();
 
 											PresentOutputVol(reassignIndex, targetVol, CHK_CUR_RANGE); Await();
@@ -1774,33 +1778,16 @@ int main(void)
 							else if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_RELAY_M_TO_A)
 							{
 								//PRINTF_FUNC("set out (%d) value = %f******** 3 \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent);
+								if(chargingInfo[groupIndex]->EvBatterytargetCurrent <= PSU_MIN_OUTPUT_CUR)
+									chargingInfo[groupIndex]->EvBatterytargetCurrent = PSU_MIN_OUTPUT_CUR;
 								PresentOutputVol(groupIndex,
 									(chargingInfo[groupIndex]->EvBatterytargetVoltage * 10),
 									(chargingInfo[groupIndex]->EvBatterytargetCurrent * 10)); Await();
 							}
 							else if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
 							{
-								//PRINTF_FUNC("set out (sys) value = %f, smart step = %d******** 4 \n",
-								//	chargingInfo[groupIndex]->EvBatterytargetCurrent, ShmSysConfigAndInfo->SysInfo.ReAssignedFlag);
-								// 該充電槍的目標電壓與目標電流
-
-								//sdlu
-//								if ((chargingInfo[groupIndex]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-//										chargingInfo[groupIndex]->SystemStatus <= S_CCS_PRECHARGE_ST1))
-//								{
-//									PresentOutputVol(SYSTEM_CMD,
-//										(chargingInfo[groupIndex]->EvBatterytargetVoltage * 10),
-//										0);
-//								}
-//								else
-//								{
-//									PresentOutputVol(SYSTEM_CMD,
-//										(chargingInfo[groupIndex]->EvBatterytargetVoltage * 10) - 100,
-//										(chargingInfo[groupIndex]->EvBatterytargetCurrent * 10));
-//								}
-
-//								printf("groupIndex = %d, EvBatterytargetCurrent = %f \n", groupIndex,
-//									(chargingInfo[groupIndex]->EvBatterytargetCurrent * 10));
+								if(chargingInfo[groupIndex]->EvBatterytargetCurrent <= PSU_MIN_OUTPUT_CUR)
+									chargingInfo[groupIndex]->EvBatterytargetCurrent = PSU_MIN_OUTPUT_CUR;
 
 								PresentOutputVol(SYSTEM_CMD,
 									(chargingInfo[groupIndex]->EvBatterytargetVoltage * 10),
@@ -2006,6 +1993,9 @@ int main(void)
 								else
 								{
 									//PRINTF_FUNC("set out (%d) value = %f******** 7 \n", groupIndex, chargingInfo[groupIndex]->EvBatterytargetCurrent);
+									if(chargingInfo[groupIndex]->EvBatterytargetCurrent <= PSU_MIN_OUTPUT_CUR)
+										chargingInfo[groupIndex]->EvBatterytargetCurrent = PSU_MIN_OUTPUT_CUR;
+
 									PresentOutputVol(groupIndex,
 										(chargingInfo[groupIndex]->EvBatterytargetVoltage * 10),
 										(chargingInfo[groupIndex]->EvBatterytargetCurrent * 10)); Await();

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

@@ -435,7 +435,7 @@ void CreateOneError(char *v1)
 {
 	int value = atoi(v1);
 
-	ShmPrimaryMcuData->InputDet.bits.EmergencyButton = value;
+	ShmStatusCodeData->FaultCode.FaultEvents.bits.ChademoOutputRelayWelding = value;
 	//ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = value;
 	//ShmSysConfigAndInfo->SysConfig.BillingData.isBilling = value;
 }

+ 164 - 65
EVSE/Projects/DS60-120/Apps/main.c

@@ -53,7 +53,7 @@
 #define		UPGRADE_PRI			0x04
 #define		UPGRADE_AC			0x05
 #define		UPGRADE_LED			0x06
-#define		SYSTEM_MIN_VOL		150
+#define		SYSTEM_MIN_VOL		80
 #define 	MIN_OUTPUT_CUR		0
 #define		AC_OUTPUT_VOL		220
 
@@ -154,7 +154,7 @@ bool isModelNameMatch = true;
 
 int rfidFd = -1;
 char* rfidPortName = "/dev/ttyS2";
-char* fwVersion = "V1.04.00.0000.00";
+char* fwVersion = "V1.05.00.0000.00";
 
 sqlite3 *localDb;
 bool isDb_ready;
@@ -235,7 +235,7 @@ int InitComPort(byte target)
 	tios.c_iflag = 0;
 	tios.c_oflag = 0;
 	tios.c_cc[VMIN]=0;
-	tios.c_cc[VTIME]=(unsigned char)1;
+	tios.c_cc[VTIME]=(unsigned char)5;
 	tios.c_lflag=0;
 	tcflush(fd, TCIFLUSH);
 	ioctl (fd, TCSETS, &tios);
@@ -1019,6 +1019,9 @@ int isReachableInternet()
 
 void InitEthernet()
 {
+	system("ifconfig eth0 down");// eth0 down
+	system("ifconfig eth1 down");// eth1 down
+	sleep(2);
 	char tmpbuf[256];
 	// /sbin/ifconfig eth0 192.168.1.10 netmask 255.255.255.0 down
 	system("echo 1 > /sys/class/gpio/gpio110/value");//reset PHY
@@ -3482,7 +3485,6 @@ void KillTask()
 	system("killall Module_EventLogging");
 	system("killall Module_PrimaryComm");
 	system("killall Module_EvComm");
-	system("killall Module_LcmControl");
 	system("killall Module_InternalComm");
 	system("killall Module_PsuComm");
 	//system("killall OcppBackend &");
@@ -3490,6 +3492,16 @@ void KillTask()
 	system("killall Module_Wifi &");
 }
 
+void KillTaskExceptPrimary()
+{
+	ChangeLcmByIndex(_LCM_FIX);
+	system("killall Module_EvComm");
+	system("killall Module_InternalComm");
+	system("killall Module_PsuComm");
+	system("killall Module_4g &");
+	system("killall Module_Wifi &");
+}
+
 void KillAllTask()
 {
 	ChangeLcmByIndex(_LCM_FIX);
@@ -4059,6 +4071,11 @@ void CheckFwUpdateFunction()
 	{
 		DEBUG_INFO_MSG("ftp : update start. \n");
 		KillTask();
+		for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
+		{
+			setChargerMode(gun_index, MODE_UPDATE);
+		}
+
 		byte updateResult = CheckUpdateProcess();
 
 		if (updateResult == PASS)
@@ -4069,7 +4086,7 @@ void CheckFwUpdateFunction()
 			KillAllTask();
 			ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = NO;
 			sleep(5);
-			system("/root/main &");
+			system("/usr/bin/run_evse_restart.sh");
 			return;
 		}
 		else
@@ -4114,7 +4131,7 @@ void CheckFwUpdateFunction()
 				strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
 				ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
 				sleep(5);
-				system("/root/main &");
+				system("/usr/bin/run_evse_restart.sh");
 				return;
 			}
 			else
@@ -4206,7 +4223,7 @@ void CheckOcppStatus()
 				ShmOCPP16Data->MsMsg.bits.ResetConf = YES;
 				sleep(3);
 				system("killall OcppBackend &");
-				KillTask();
+				KillAllTask();
 				system("/usr/bin/run_evse_restart.sh");
 			}
 		}
@@ -4530,6 +4547,10 @@ int DB_Open(sqlite3 *db)
 						   "`occurDatetime` TEXT NOT NULL, "
 					       "`statusCode` INTEGER NOT NULL, unique(occurDatetime,statusCode) on conflict replace);";
 
+	char* createrebootSql="CREATE TABLE IF NOT EXISTS `reboot_record` ( "
+							   "`idx` INTEGER PRIMARY KEY AUTOINCREMENT, "
+							   "`rebootDatetime` TEXT NOT NULL, unique(rebootDatetime) on conflict replace);";
+
 	if(sqlite3_open(DB_FILE, &db))
 	{
 		result = FAIL;
@@ -4570,6 +4591,16 @@ int DB_Open(sqlite3 *db)
 			PRINTF_FUNC( "Opened local record table successfully\n");
 		}
 
+		if (sqlite3_exec(db, createrebootSql, 0, 0, &errMsg) != SQLITE_OK)
+		{
+			result = FAIL;
+			PRINTF_FUNC( "Create reboot record table error message: %s\n", errMsg);
+		}
+		else
+		{
+			PRINTF_FUNC( "Opened reboot record table successfully\n");
+		}
+
 		sqlite3_close(db);
 	}
 
@@ -4710,6 +4741,49 @@ int DB_Get_Operactive(sqlite3 *db, uint8_t gun_index)
 	return result;
 }
 
+int DB_Reboot_Record(sqlite3 *db)
+{
+	int result = PASS;
+	char* errMsg = NULL;
+	char insertSql[256];
+
+	sprintf(insertSql, "insert into reboot_record(rebootDatetime) values(CURRENT_TIMESTAMP);");
+
+	if(sqlite3_open(DB_FILE, &db))
+	{
+		result = FAIL;
+		PRINTF_FUNC( "Can't open database: %s\n", sqlite3_errmsg(db));
+		sqlite3_close(db);
+	}
+	else
+	{
+		PRINTF_FUNC( "Local charging record database open successfully.\n");
+		if (sqlite3_exec(db, insertSql, 0, 0, &errMsg) != SQLITE_OK)
+		{
+			result = FAIL;
+			PRINTF_FUNC( "Insert reboot record error message: %s\n", errMsg);
+		}
+		else
+		{
+			PRINTF_FUNC( "Insert reboot record successfully\n");
+		}
+
+		sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
+		if (sqlite3_exec(db, insertSql, 0, 0, &errMsg) != SQLITE_OK)
+		{
+			result = FAIL;
+			PRINTF_FUNC( "delete reboot record error message: %s\n", errMsg);
+		}
+		else
+		{
+			PRINTF_FUNC( "delete reboot record successfully\n");
+		}
+
+		sqlite3_close(db);
+	}
+
+	return result;
+}
 //===============================================
 // Config process
 //===============================================
@@ -4831,6 +4905,18 @@ void StopProcessingLoop()
 	{
 		CheckFactoryConfigFunction();
 		CheckFwUpdateFunction();
+		if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2)
+		{
+			ChkPrimaryStatus();
+			if (ShmSysConfigAndInfo->SysWarningInfo.Level == 0)
+			{
+				PRINTF_FUNC("Soft reboot for retry self-tets (Primary). \n");
+				KillAllTask();
+				sleep(3);
+				system("/usr/bin/run_evse_restart.sh");
+				return;
+			}
+		}
 		sleep(1);
 	}
 }
@@ -5227,7 +5313,7 @@ int main(void)
 				PRINTF_FUNC("Soft reboot for retry self-tets. \n");
 				sleep(3);
 				system("killall OcppBackend &");
-				KillTask();
+				KillAllTask();
 				system("/usr/bin/run_evse_restart.sh");
 			}
 		}
@@ -5236,9 +5322,14 @@ int main(void)
 		{
 			ChargingAlarmProcess(gun_index);
 		}
-		ChangeLcmByIndex(_LCM_FIX);
+		//ChangeLcmByIndex(_LCM_FIX);
 		sleep(3);
-		KillTask();
+		if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2)
+		{
+			KillTaskExceptPrimary();
+		}
+		else
+			KillTask();
 		StopProcessingLoop();
 	}
 	else
@@ -5264,6 +5355,7 @@ int main(void)
 		{
 			chargingInfo[_index]->IsAvailable = DB_Get_Operactive(localDb, _index);
 		}
+		DB_Reboot_Record(localDb);
 	}
 
 	ChangeLcmByIndex(_LCM_IDLE);
@@ -5360,6 +5452,8 @@ int main(void)
 						PRINTF_FUNC("================= S_IDLE (%x) ================  \n", gun_index);
 						chargingInfo[gun_index]->PresentChargedDuration = 0;
 						chargingInfo[gun_index]->RemainChargingDuration = 0;
+						chargingInfo[gun_index]->PresentChargingVoltage = 0;
+						chargingInfo[gun_index]->PresentChargingCurrent = 0;
 						strcpy((char *)chargingInfo[gun_index]->StartDateTime, "");
 						strcpy((char *)chargingInfo[gun_index]->StopDateTime, "");
 						strcpy((char *)chargingInfo[gun_index]->StartUserId, "");
@@ -5631,11 +5725,19 @@ int main(void)
 					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (錯誤)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingAlarmProcess(gun_index);
 					}
 					else if (isEvBoardNormalStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (正常)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingTerminalProcess(gun_index);
 					}
 					else if (OcppRemoteStop(gun_index) == YES ||
@@ -5687,11 +5789,19 @@ int main(void)
 					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (錯誤)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingAlarmProcess(gun_index);
 					}
 					else if (isEvBoardNormalStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (正常)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingTerminalProcess(gun_index);
 					}
 					else if (OcppRemoteStop(gun_index) == YES ||
@@ -5778,11 +5888,19 @@ int main(void)
 					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (錯誤)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingAlarmProcess(gun_index);
 					}
 					else if (isEvBoardNormalStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (正常)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingTerminalProcess(gun_index);
 					}
 					else if (OcppRemoteStop(gun_index) == YES ||
@@ -5822,13 +5940,13 @@ int main(void)
 							// GFD 錯誤停止
 							RecordAlarmCode(gun_index, "012234");
 						}
-						else if (((chargingInfo[gun_index]->EvBatterytargetVoltage * 10) > 0 && chargingInfo[gun_index]->EvBatterytargetVoltage < SYSTEM_MIN_VOL) ||
-								(chargingInfo[gun_index]->PresentChargedDuration >= 10 && chargingInfo[gun_index]->PresentChargingVoltage < SYSTEM_MIN_VOL))
-						{
-							// UVP
-							RecordAlarmCode(gun_index, "012289");
-							ChargingTerminalProcess(gun_index);
-						}
+//						else if (((chargingInfo[gun_index]->EvBatterytargetVoltage * 10) > 0 && chargingInfo[gun_index]->EvBatterytargetVoltage < SYSTEM_MIN_VOL) ||
+//								(chargingInfo[gun_index]->PresentChargedDuration >= 10 && chargingInfo[gun_index]->PresentChargingVoltage < SYSTEM_MIN_VOL))
+//						{
+//							// UVP
+//							RecordAlarmCode(gun_index, "012289");
+//							ChargingTerminalProcess(gun_index);
+//						}
 						else if (chargingInfo[gun_index]->GroundFaultStatus == GFD_WARNING)
 						{
 							// GFD 警告
@@ -5842,14 +5960,14 @@ int main(void)
 							// GFD 錯誤停止
 							RecordAlarmCode(gun_index, "012236");
 						}
-						else if (isPrechargeStatus_gb(gun_index) == 10 &&
-								(((chargingInfo[gun_index]->EvBatterytargetVoltage * 10) > 0 && chargingInfo[gun_index]->EvBatterytargetVoltage < SYSTEM_MIN_VOL) ||
-								(chargingInfo[gun_index]->PresentChargedDuration >= 10 && chargingInfo[gun_index]->PresentChargingVoltage < SYSTEM_MIN_VOL)))
-						{
-							// UVP
-							RecordAlarmCode(gun_index, "012290");
-							ChargingTerminalProcess(gun_index);
-						}
+//						else if (isPrechargeStatus_gb(gun_index) == 10 &&
+//								(((chargingInfo[gun_index]->EvBatterytargetVoltage * 10) > 0 && chargingInfo[gun_index]->EvBatterytargetVoltage < SYSTEM_MIN_VOL) ||
+//								(chargingInfo[gun_index]->PresentChargedDuration >= 10 && chargingInfo[gun_index]->PresentChargingVoltage < SYSTEM_MIN_VOL)))
+//						{
+//							// UVP
+//							RecordAlarmCode(gun_index, "012290");
+//							ChargingTerminalProcess(gun_index);
+//						}
 						else if (chargingInfo[gun_index]->GroundFaultStatus == GFD_WARNING)
 						{
 							// GFD 警告
@@ -5863,13 +5981,13 @@ int main(void)
 							// GFD 錯誤停止
 							RecordAlarmCode(gun_index, "012235");
 						}
-						else if (((chargingInfo[gun_index]->EvBatterytargetVoltage * 10) > 0 && chargingInfo[gun_index]->EvBatterytargetVoltage < SYSTEM_MIN_VOL) ||
-								(chargingInfo[gun_index]->PresentChargedDuration >= 10 && chargingInfo[gun_index]->PresentChargingVoltage < SYSTEM_MIN_VOL))
-						{
-							// UVP
-							RecordAlarmCode(gun_index, "012288");
-							ChargingTerminalProcess(gun_index);
-						}
+//						else if (((chargingInfo[gun_index]->EvBatterytargetVoltage * 10) > 0 && chargingInfo[gun_index]->EvBatterytargetVoltage < SYSTEM_MIN_VOL) ||
+//								(chargingInfo[gun_index]->PresentChargedDuration >= 10 && chargingInfo[gun_index]->PresentChargingVoltage < SYSTEM_MIN_VOL))
+//						{
+//							// UVP
+//							RecordAlarmCode(gun_index, "012288");
+//							ChargingTerminalProcess(gun_index);
+//						}
 						else if (chargingInfo[gun_index]->GroundFaultStatus == GFD_WARNING)
 						{
 							// GFD 警告
@@ -5880,11 +5998,19 @@ int main(void)
 					if (isEvBoardStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (錯誤)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingAlarmProcess(gun_index);
 					}
 					else if (isEvBoardNormalStopChargeFlag(gun_index) == YES)
 					{
 						// 板端要求停止 (正常)
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
+						}
 						ChargingTerminalProcess(gun_index);
 					}
 					else if (OcppRemoteStop(gun_index) == YES ||
@@ -5907,6 +6033,11 @@ int main(void)
 				{
 					if (isModeChange(gun_index))
 					{
+						if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
+						{
+							strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
+						}
+
 						if (chargingInfo[gun_index]->SystemStatus == S_ALARM)
 						{
 							PRINTF_FUNC("================== S_ALARM (%x) ================ \n", gun_index);
@@ -5923,20 +6054,12 @@ int main(void)
 						{
 							PRINTF_FUNC("================== S_TERMINATING (%x) ================ \n", gun_index);
 						}
+
 						StopGunInfoTimeoutDet(gun_index);
 					}
 
 					if (chargingInfo[gun_index]->Type == _Type_Chademo)
 					{
-						// 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
-						if (isEvStopCharging_chademo(gun_index) == YES)
-						{
-							if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
-							{
-								strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
-							}
-						}
-
 						if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
 						{
 							// GFD 錯誤停止
@@ -5951,15 +6074,6 @@ int main(void)
 					else if (chargingInfo[gun_index]->Type == _Type_GB)
 					{
 						//PRINTF_FUNC("************ GB lock Status = %d, status = %d \n", isEvStopCharging_gb(gun_index), isPrechargeStatus_gb(gun_index));
-						// 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
-						if (isEvStopCharging_gb(gun_index) == YES)
-						{
-							if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
-							{
-								strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
-							}
-						}
-
 						if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
 						{
 							// GFD 錯誤停止
@@ -5973,15 +6087,6 @@ int main(void)
 					}
 					else if (chargingInfo[gun_index]->Type == _Type_CCS_2)
 					{
-						// 非車端的停止 : 需等待小板送出停止指令,讓車端解除槍
-						if (isEvStopCharging_ccs(gun_index) == YES)
-						{
-							if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
-							{
-								strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "Local");
-							}
-						}
-
 						if (chargingInfo[gun_index]->GroundFaultStatus == GFD_FAIL)
 						{
 							// GFD 錯誤停止
@@ -5994,12 +6099,6 @@ int main(void)
 						}
 					}
 
-					// 車端的停止
-					if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL)
-					{
-						strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
-					}
-
 					if (chargingInfo[gun_index]->SystemStatus == S_ALARM)
 					{
 						if(chargingInfo[gun_index]->ConnectorPlugIn == NO &&