Ver código fonte

[Add][AX80][main]

2022.01.03 / Folus Wen

Actions:
1. When WIFI can not access internet & ocpp server over 5 minutes, CSU will reset WIFI/4G module.

Files:
1. As follow commit history

Image version: D0.01.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 anos atrás
pai
commit
a1ce7c2c33

+ 84 - 51
EVSE/Projects/AX80/Apps/LCM/Module_LcmControl.c

@@ -2,9 +2,9 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2021-12-20
+ * Update on : 2021-12-24
  * Author : Folus Wen, Eason Yang
- * Version : V0.24
+ * Version : V0.25
  *
  */
 
@@ -58,7 +58,6 @@ void setPriceFromWebsite(float monry_rate);
 void setAuthorizationPage(uint8_t gun_index);
 float getPresentFinalCost(uint8_t gun_index);
 void setGunPluginAnimation(uint8_t gun_index);
-void setPresentChargedEnergy(uint8_t gun_index);
 void setPresentChargedgPower(uint8_t gun_index);
 void setPlugAndChargeAnimation(uint8_t gun_index);
 void setPresentChargedDuration(uint8_t gun_index);
@@ -72,6 +71,7 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode);
 void setQRcodeContent(char *input, uint8_t length, uint8_t mode);
 void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode);
 void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode);
+void setPresentChargedEnergy(uint8_t gun_index, uint8_t system_mode);
 void setMarqueeControl(uint16_t address, uint8_t gun_index, uint8_t type);
 void setCurrencyAndUnitFromBackend(uint8_t type_price,uint8_t type_currency_unit, uint8_t gun_index);
 
@@ -85,7 +85,7 @@ enum TMR_IDX
 	TMR_IDX_PLUGIN,
 	TMR_IDX_ALARM,
 	TMR_IDX_PRICE,
-	TMR_IDX_5,
+	TMR_IDX_REFRESH_INFO,
 	TMR_IDX_6,
 	TMR_IDX_7,
 	TMR_IDX_8,
@@ -100,6 +100,7 @@ struct timespec					startTime[AC_QUANTITY][TMR_IDX_SHOW_AUTH_RESULT];
 #define TIME_ANIMATION_ALARM			5 // Unit: Second
 #define TIME_REFRESH_TIME				5 // Unit: Second
 #define TIME_AUTH_RESULT_TIME			5 // Unit: Second
+#define TIME_REFRESH_INFO				3 // Unit: Second
 
 //=======================================
 // Declare Variable
@@ -113,7 +114,7 @@ int Uart1Fd;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.24", "2021-12-14", "REV.02.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.25", "2021-12-24", "REV.02.00"};
 
 //=======================================
 // Common routine
@@ -420,6 +421,7 @@ void page_preparing(uint8_t gun_index, uint8_t system_mode)
 		else
 		{
 			setConnectionAnimation(gun_index, system_mode);
+			setPresentChargedEnergy(gun_index, system_mode);
 		}
 	}
 	else
@@ -435,12 +437,15 @@ void page_preparing(uint8_t gun_index, uint8_t system_mode)
 			setPresentConnectionTimeout(gun_index);
 			setConnectionAnimation(gun_index, system_mode);
 			setGunPluginAnimation(gun_index);
+			setPresentChargedEnergy(gun_index, system_mode);
 		}
 	}
 }
 
 void page_charging(uint8_t gun_index, uint8_t system_mode)
 {
+	static char runningCost[256] = {0};
+
 	if((getCurrentPage() != SYSTEM_SCREEN_CHARGING) && (!ShmCharger->isAuthrizing && !ShmCharger->isGetAuthResult))
 	{
 		setCurrentPage(SYSTEM_SCREEN_CHARGING);
@@ -451,37 +456,44 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 	{
 		setConnectionAnimation(gun_index, system_mode);
 		setPresentChargedDuration(gun_index);
-		setPresentChargedEnergy(gun_index);
 		setPresentChargedgPower(gun_index);
 
-		if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
-		{
-			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
-			{
-				setRunningCost(gun_index, TOTAL_COST);
-			}
-			else
-			{
-				// DISPLAY BY OCPP 2.0.1
-			}
-		}
-		else
+		if((getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_INFO]) >= TIME_REFRESH_INFO) || (strcmp((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, runningCost) != 0))
 		{
-			if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
+			setPresentChargedEnergy(gun_index, system_mode);
+			memcpy((char*) runningCost,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description,ARRAY_SIZE(ShmOCPP16Data->Cost.RunningCost[gun_index].description));
+
+			if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
 			{
-				setDisplayValue(ICON_CHARGING_COST, APPEAR);
-				setPresentFinalCost(getPresentFinalCost(gun_index));
+				if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+				{
+					setRunningCost(gun_index, TOTAL_COST);
+				}
+				else
+				{
+					// DISPLAY BY OCPP 2.0.1
+				}
 			}
 			else
 			{
-				// User spend cost
-				setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
-				setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
+				if(ShmSysConfigAndInfo->SysConfig.BillingData.isBilling == ON)
+				{
+					setDisplayValue(ICON_CHARGING_COST, APPEAR);
+					setPresentFinalCost(getPresentFinalCost(gun_index));
+				}
+				else
+				{
+					// User spend cost
+					setDisplayValue(ICON_CHARGING_COST, DISAPPEAR);
+					setDisplayValue(TEXT_CHARGING_COST, DISAPPEAR);
 
-				// User account balance
-				setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
-				setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
+					// User account balance
+					setDisplayValue(ICON_COMPLETE_WALLET, DISAPPEAR);
+					setDisplayValue(TEXT_REMAINING_ACCOUNT_BALANCE, DISAPPEAR);
+				}
 			}
+
+			refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
 		}
 	}
 }
@@ -513,7 +525,7 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 	}
 
 	setPresentChargedDuration(gun_index);
-	setPresentChargedEnergy(gun_index);
+	setPresentChargedEnergy(gun_index, system_mode);
 
 	if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
 	{
@@ -562,7 +574,7 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
 	else
 	{
 		setPresentChargedDuration(gun_index);
-		setPresentChargedEnergy(gun_index);
+		setPresentChargedEnergy(gun_index, system_mode);
 		setPresentChargedgPower(gun_index);
 
 		if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
@@ -1435,28 +1447,33 @@ void setRunningCost(uint8_t gun_index, uint8_t type)
 			}
 			else
 			{
-				if((strstr((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, "Total Cost:") > 0))
+				if(strlen((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description) > 0)
 				{
-					// APPEAR COST ICON
-					setDisplayValue(ICON_CHARGING_COST, APPEAR);
+					if((strstr((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, "Total Cost:") > 0))
+					{
+						// APPEAR COST ICON
+						setDisplayValue(ICON_CHARGING_COST, APPEAR);
 
-					// APPEAR COST TEXT
-					strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
-					split((char**)splitString, tmp, Symbol);
-					memcpy(input_data, splitString[3], strlen(splitString[3]));
-					length = strlen(input_data);
-					trim_string(input_data,length);
-					memcpy(output_data ,input_data, strlen(input_data));
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
-				}
-				else
-				{
-					setDisplayValue(ICON_CHARGING_COST, APPEAR);
+						// APPEAR COST TEXT
+						strcpy((char*)tmp,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+						split((char**)splitString, tmp, Symbol);
+						memcpy(input_data, splitString[3], strlen(splitString[3]));
+						length = strlen(input_data);
+						trim_string(input_data,length);
+						memcpy(output_data ,input_data, strlen(input_data));
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+					}
+					else
+					{
+						setDisplayValue(ICON_CHARGING_COST, APPEAR);
 
-					strcpy((char*)cost_empty, "-----");
-					string2ByteArray(cost_empty, output_data);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+						strcpy((char*)cost_empty, "-----");
+						string2ByteArray(cost_empty, output_data);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_COST, output_data, ARRAY_SIZE(output_data));
+					}
 				}
+				else
+				{}
 			}
 
 			break;
@@ -1954,7 +1971,7 @@ void setPresentChargedgPower(uint8_t gun_index)
 //=======================================
 // Setting Present Charging [ Energy ]
 //=======================================
-void setPresentChargedEnergy(uint8_t gun_index)
+void setPresentChargedEnergy(uint8_t gun_index, uint8_t system_mode)
 {
 	uint8_t data[16];
 	uint8_t energy[16];
@@ -1962,9 +1979,22 @@ void setPresentChargedEnergy(uint8_t gun_index)
 	memset(data, 0x00, ARRAY_SIZE(data));
 	memset(energy, 0x00, ARRAY_SIZE(energy));
 
-	sprintf((char *)energy, "%.4f kWh", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
-	string2ByteArray(energy, data);
-	lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_ENERGY, data, ARRAY_SIZE(data));
+	switch(system_mode)
+	{
+		case SYS_MODE_PREPARING:
+			sprintf((char *)energy, "%s kWh", "0.0000");
+			string2ByteArray(energy, data);
+			lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_ENERGY, data, ARRAY_SIZE(data));
+			break;
+		case SYS_MODE_CHARGING:
+		case SYS_MODE_TERMINATING:
+		case SYS_MODE_COMPLETE:
+		default:
+			sprintf((char *)energy, "%.3f0 kWh", ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy);
+			string2ByteArray(energy, data);
+			lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_ENERGY, data, ARRAY_SIZE(data));
+			break;
+	}
 }
 
 //=======================================
@@ -2080,17 +2110,20 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode)
 				setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
 				CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
 				refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
 			}
 			else
 			{
 				setDisplayValue(ICON_PREPARING_PLUG_ARROW, PLUGIN_ARROW_1);
 				GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
 				refreshStartTimer(&startTime[gun_index][TMR_IDX_PLUGIN]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
 			}
 			break;
 		case SYS_MODE_CHARGING:
 			setDisplayValue(ICON_CHARGING_ANIMATION, CONNECTION_FLASHING_1);
 			refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
+			refreshStartTimer(&startTime[gun_index][TMR_IDX_REFRESH_INFO]);
 			CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
 			break;
 		case SYS_MODE_TERMINATING:

+ 213 - 201
EVSE/Projects/AX80/Apps/main.c

@@ -35,6 +35,7 @@
 #define TIMEOUT_SPEC_POWERSAVING_LED_STATUS		120
 #define TIMEOUT_SPEC_CEHCK_POWER_CONSUMPTION	15
 #define TIMEOUT_SPEC_UPGRADE					300
+#define TIMEOUT_SPEC_RESET_WIFI_MODULE			300
 
 //==========================
 // GPIO constant define
@@ -451,6 +452,202 @@ int getEth0MacAddress()
 	return result;
 }
 
+char* getSystemModeName(unsigned char mode)
+{
+	char* result;
+
+	switch(mode)
+	{
+		case SYS_MODE_BOOTING:
+			result = "booting";
+			break;
+		case SYS_MODE_IDLE:
+			result = "idle";
+			break;
+		case SYS_MODE_AUTHORIZING:
+			result = "authorizing";
+			break;
+		case SYS_MODE_PREPARING:
+			result = "preparing";
+			break;
+		case SYS_MODE_CHARGING:
+			result = "charging";
+			break;
+		case SYS_MODE_TERMINATING:
+			result = "terminating";
+			break;
+		case SYS_MODE_COMPLETE:
+			result = "complete";
+			break;
+		case SYS_MODE_ALARM:
+			result = "alarm";
+			break;
+		case SYS_MODE_FAULT:
+			result = "fault";
+			break;
+		case SYS_MODE_MAINTAIN:
+			result = "maintain";
+			break;
+		case SYS_MODE_RESERVATION:
+			result = "reservation";
+			break;
+		case SYS_MODE_BOOKING:
+			result = "booking";
+			break;
+		case SYS_MODE_DEBUG:
+			result = "debug";
+			break;
+		case SYS_MODE_UPDATE:
+			result = "upgrade";
+			break;
+		default:
+			result = "unknown";
+			break;
+	}
+
+	return result;
+}
+
+void setChargerMode(unsigned char gun_index, unsigned char mode)
+{
+	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus = ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus;
+	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus = mode;
+
+	DEBUG_INFO("Gun-%02d mode switch from %s to %s\n", gun_index, getSystemModeName(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus), getSystemModeName(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus));
+}
+
+unsigned char isMode(unsigned char gun_index, unsigned char mode)
+{
+	return ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == mode)?YES:NO);
+}
+
+unsigned char isModeChange(unsigned char gun_index)
+{
+	unsigned char result = NO;
+
+	if(!isMode(gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus))
+	{
+		result = YES;
+
+		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus = ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus;
+	}
+
+	return result;
+}
+
+int isGpioInitialized(unsigned int gpio)
+{
+	int result = FAIL;
+	char gpioPath[64];
+
+	sprintf(gpioPath, "/sys/class/gpio/gpio%d/value", gpio);
+	if((access(gpioPath, F_OK)) != -1)
+	{
+		result = PASS;
+	}
+
+	return result;
+}
+
+void gpio_set_value(unsigned int gpio, unsigned int value)
+{
+	int fd;
+	char buf[256];
+
+	sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
+	fd = open(buf, O_WRONLY);
+	if (fd < 0)
+	{
+		DEBUG_ERROR("GPIO-%d set %d fail.\n", gpio, value);
+	    return;
+	}
+
+	if (value)
+		write(fd, "1", 2);
+	else
+	    write(fd, "0", 2);
+
+	close(fd);
+}
+
+int gpio_get_value(unsigned int gpio)
+{
+    int fd;
+    char buf[256];
+    char ch;
+    int8_t result = FAIL;
+
+    sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
+    fd = open(buf, O_RDONLY);
+    if (fd < 0)
+    {
+        DEBUG_ERROR("GPIO-%d get fail\n", gpio);
+        return result;
+    }
+
+    read(fd, &ch, 1);
+    if (ch != '0')
+        result = 1;
+    else
+        result = 0;
+
+    close(fd);
+
+    return result;
+}
+
+int presentChargedEnergyClear(unsigned char gun_index)
+{
+	int result = FAIL;
+
+	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
+	memset(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod)*sizeof(float));
+	result = PASS;
+
+	return result;
+}
+
+float presentChargedEnergyTotal(unsigned char gun_index)
+{
+	float result = 0.0f;
+
+	for(int idx=0;idx<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod);idx++)
+	{
+		result += ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[idx];
+	}
+
+	return result;
+}
+
+int presentChargedEnergyUpdate(unsigned char gun_index)
+{
+	int result = FAIL;
+	time_t CurrentTime;
+	struct tm *tm;
+
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+
+	if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount==1)
+	{
+		// Resolution: 0.0001 kwh
+		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[tm->tm_hour] += (((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/10000.0) - presentChargedEnergyTotal(gun_index);
+
+	}
+	else
+	{
+		// Resolution: 0.0001 kwh
+		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[tm->tm_hour] += ((((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/10000.0) +
+																											(((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/10000.0) +
+																											(((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/10000.0))
+																											- presentChargedEnergyTotal(gun_index);
+	}
+
+	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = presentChargedEnergyTotal(gun_index);
+
+	return result;
+}
+
 //======================================================
 // OCPP routine
 //======================================================
@@ -2532,6 +2729,22 @@ void InitEthernet()
 						}
 					}
 				}
+
+				if(!ShmSysConfigAndInfo->SysInfo.OcppConnStatus &&
+				   (((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) || (((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON)))))
+				{
+					if(getDiffSecNow(startTime[0][TMR_IDX_RESET_WIFI]) > TIMEOUT_SPEC_RESET_WIFI_MODULE)
+					{
+						DEBUG_WARN("WIFI/4G module reset.\n");
+						gpio_set_value(GPIO_OUT_RST_4G_WIFI, ON);
+						sleep(1);
+						gpio_set_value(GPIO_OUT_RST_4G_WIFI, OFF);
+					}
+				}
+				else
+				{
+					refreshStartTimer(&startTime[0][TMR_IDX_RESET_WIFI]);
+				}
 			}
 			else
 			{
@@ -2644,205 +2857,6 @@ int Initialization(uint8_t gun_index)
 	return result;
 }
 
-//=====================================================
-// Common routine
-//=====================================================
-char* getSystemModeName(unsigned char mode)
-{
-	char* result;
-
-	switch(mode)
-	{
-		case SYS_MODE_BOOTING:
-			result = "booting";
-			break;
-		case SYS_MODE_IDLE:
-			result = "idle";
-			break;
-		case SYS_MODE_AUTHORIZING:
-			result = "authorizing";
-			break;
-		case SYS_MODE_PREPARING:
-			result = "preparing";
-			break;
-		case SYS_MODE_CHARGING:
-			result = "charging";
-			break;
-		case SYS_MODE_TERMINATING:
-			result = "terminating";
-			break;
-		case SYS_MODE_COMPLETE:
-			result = "complete";
-			break;
-		case SYS_MODE_ALARM:
-			result = "alarm";
-			break;
-		case SYS_MODE_FAULT:
-			result = "fault";
-			break;
-		case SYS_MODE_MAINTAIN:
-			result = "maintain";
-			break;
-		case SYS_MODE_RESERVATION:
-			result = "reservation";
-			break;
-		case SYS_MODE_BOOKING:
-			result = "booking";
-			break;
-		case SYS_MODE_DEBUG:
-			result = "debug";
-			break;
-		case SYS_MODE_UPDATE:
-			result = "upgrade";
-			break;
-		default:
-			result = "unknown";
-			break;
-	}
-
-	return result;
-}
-
-void setChargerMode(unsigned char gun_index, unsigned char mode)
-{
-	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus = ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus;
-	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus = mode;
-
-	DEBUG_INFO("Gun-%02d mode switch from %s to %s\n", gun_index, getSystemModeName(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus), getSystemModeName(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus));
-}
-
-unsigned char isMode(unsigned char gun_index, unsigned char mode)
-{
-	return ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == mode)?YES:NO);
-}
-
-unsigned char isModeChange(unsigned char gun_index)
-{
-	unsigned char result = NO;
-
-	if(!isMode(gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus))
-	{
-		result = YES;
-
-		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus = ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus;
-	}
-
-	return result;
-}
-
-int isGpioInitialized(unsigned int gpio)
-{
-	int result = FAIL;
-	char gpioPath[64];
-
-	sprintf(gpioPath, "/sys/class/gpio/gpio%d/value", gpio);
-	if((access(gpioPath, F_OK)) != -1)
-	{
-		result = PASS;
-	}
-
-	return result;
-}
-
-void gpio_set_value(unsigned int gpio, unsigned int value)
-{
-	int fd;
-	char buf[256];
-
-	sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
-	fd = open(buf, O_WRONLY);
-	if (fd < 0)
-	{
-		DEBUG_ERROR("GPIO-%d set %d fail.\n", gpio, value);
-	    return;
-	}
-
-	if (value)
-		write(fd, "1", 2);
-	else
-	    write(fd, "0", 2);
-
-	close(fd);
-}
-
-int gpio_get_value(unsigned int gpio)
-{
-    int fd;
-    char buf[256];
-    char ch;
-    int8_t result = FAIL;
-
-    sprintf(buf, "/sys/class/gpio/gpio%d/value", gpio);
-    fd = open(buf, O_RDONLY);
-    if (fd < 0)
-    {
-        DEBUG_ERROR("GPIO-%d get fail\n", gpio);
-        return result;
-    }
-
-    read(fd, &ch, 1);
-    if (ch != '0')
-        result = 1;
-    else
-        result = 0;
-
-    close(fd);
-
-    return result;
-}
-
-int presentChargedEnergyClear(unsigned char gun_index)
-{
-	int result = FAIL;
-
-	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = 0;
-	memset(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod)*sizeof(float));
-	result = PASS;
-
-	return result;
-}
-
-float presentChargedEnergyTotal(unsigned char gun_index)
-{
-	float result = 0.0f;
-
-	for(int idx=0;idx<ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod);idx++)
-	{
-		result += ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[idx];
-	}
-
-	return result;
-}
-
-int presentChargedEnergyUpdate(unsigned char gun_index)
-{
-	int result = FAIL;
-	time_t CurrentTime;
-	struct tm *tm;
-
-	CurrentTime = time(NULL);
-	tm=localtime(&CurrentTime);
-
-	if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount==1)
-	{
-		// Resolution: 0.0001 kwh
-		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[tm->tm_hour] += (((float)(ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption - ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption_at_start))/10000.0) - presentChargedEnergyTotal(gun_index);
-
-	}
-	else
-	{
-		// Resolution: 0.0001 kwh
-		ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].presentChargedEnergyPeriod[tm->tm_hour] += ((((float)(ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption_at_start))/10000.0) +
-																											(((float)(ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption_at_start))/10000.0) +
-																											(((float)(ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption - ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption_at_start))/10000.0))
-																											- presentChargedEnergyTotal(gun_index);
-	}
-
-	ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy = presentChargedEnergyTotal(gun_index);
-
-	return result;
-}
-
 //===============================================
 // Get firmware version
 //===============================================
@@ -4845,8 +4859,6 @@ void checkRfidAuthrize()
 	}
 }
 
-
-
 //======================================================
 // Main process
 //======================================================

+ 1 - 1
EVSE/Projects/AX80/Apps/main.h

@@ -234,7 +234,7 @@ enum TIMER_IDX
 	TMR_IDX_CHECK_POWER_CONSUMPTION,
 	TMR_IDX_LCM_POWER_CONSUMPTION,
 	TMR_IDX_UPGRADE,
-	TMR_IDX_16,
+	TMR_IDX_RESET_WIFI,
 	TMR_IDX_17,
 	TMR_IDX_18,
 	TMR_IDX_19,