ソースを参照

[Improve][AW-CCS][Module_LcmControl.c]
2022-08-30 / EASON YANG
Action:
1. Improve: Distinguish display for ocpp 1.6 & 2.0.1 .

File:
1. Module_LcmControl.c
Action 1

LCM VERSION: V0.30

8009 2 年 前
コミット
307933fe04
1 ファイル変更358 行追加229 行削除
  1. 358 229
      EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

+ 358 - 229
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -2,7 +2,7 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2022-08-03
+ * Update on : 2022-08-30
  * Author : Folus Wen, Eason Yang
  * Version : V0.30
  *
@@ -103,10 +103,11 @@ enum TMR_IDX
 	TMR_IDX_STARTBUTTON,
 	TMR_IDX_7,
 	TMR_IDX_8,
-	TMR_IDX_SHOW_AUTH_RESULT
+	TMR_IDX_SHOW_AUTH_RESULT,
+	TMR_IDX_FINAL_COUNTER
 };
 
-struct timespec					startTime[AC_QUANTITY][TMR_IDX_SHOW_AUTH_RESULT];
+struct timespec					startTime[AC_QUANTITY][TMR_IDX_FINAL_COUNTER];
 
 #define TIME_ANIMATION_PLUGIN			1 // Unit: Second
 #define TIME_ANIMATION_BATTERY			1 // Unit: Second
@@ -132,7 +133,7 @@ int Uart1Fd;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.30", "2022-08-03", "REV.03.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.30", "2022-08-30", "REV.03.00"};
 
 //=======================================
 // Common routine
@@ -301,9 +302,16 @@ void getDateTimeString(char* result)
 	tbTarget.time = mktime(tmOrg);
 	tbTarget.timezone = 0;
 
-	if((timeOffset.scanedElement = sscanf((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[TimeOffset].ItemData, "%d:%d", &timeOffset.tz_hour, &timeOffset.tz_min)) == 2)
+	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+	{
+		if((timeOffset.scanedElement = sscanf((char*)ShmOCPP16Data->ConfigurationTable.CoreProfile[TimeOffset].ItemData, "%d:%d", &timeOffset.tz_hour, &timeOffset.tz_min)) == 2)
+		{
+			tbTarget.time += (timeOffset.tz_hour*3600) + (timeOffset.tz_min*60*(timeOffset.tz_hour>=0?1:-1));
+		}
+	}
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
-		tbTarget.time += (timeOffset.tz_hour*3600) + (timeOffset.tz_min*60*(timeOffset.tz_hour>=0?1:-1));
+		// OCPP 2.0.1
 	}
 
 	tmTarget = gmtime(&tbTarget.time);
@@ -335,6 +343,48 @@ uint8_t ocpp_get_isRemoteStartWait()
 	return result;
 }
 
+uint8_t ocpp_compare_reserve_id_with_user(uint8_t gun_index)
+{
+	uint8_t result = OFF;
+
+	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+	{
+		if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
+			result = ON;
+	}
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+	{
+		if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP20Data->ReserveNow[gun_index].idToken.idToken) == 0)
+			result = ON;
+	}
+
+	return result;
+}
+
+uint8_t ocpp_compare_reserve_id_with_remote_user(uint8_t gun_index)
+{
+	uint8_t result = OFF;
+
+	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+	{
+		if(strcmp((char*)ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, (char*)ShmOCPP16Data->ReserveNow[gun_index].IdTag) == 0)
+		{
+			result = ON;
+			memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag, ARRAY_SIZE(ShmOCPP16Data->RemoteStartTransaction[gun_index].IdTag));
+		}
+	}
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+	{
+		if(strcmp((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, (char*)ShmOCPP20Data->ReserveNow[gun_index].idToken.idToken) == 0)
+		{
+			result = ON;
+			memcpy(ShmSysConfigAndInfo->SysConfig.UserId, ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.UserId));
+		}
+	}
+
+	return result;
+}
+
 //=======================================
 // Function to page routine
 //=======================================
@@ -472,7 +522,7 @@ void page_authorizing(uint8_t gun_index)
 				setDisplayValue(TEXT_USER_ACCOUNT_BALANCE, DISAPPEAR);
 			}
 		}
-		else
+		else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 		{
 			// DISPLAY BY OCPP 2.0.1
 		}
@@ -551,7 +601,7 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 				setParkingFeeTitle(ON);
 				setFinalCostTitle(ON);
 			}
-			else
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
 				// DISPLAY BY OCPP 2.0.1
 			}
@@ -574,10 +624,17 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 			}
 		}
 
-		if((getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_INFO]) >= TIME_REFRESH_INFO) || (strcmp((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, runningCost) != 0))
+		if((getDiffSecNow(startTime[gun_index][TMR_IDX_REFRESH_INFO]) >= TIME_REFRESH_INFO) || (ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16?(strcmp((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description, runningCost) != 0):YES))
 		{
 			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.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+			{
+				memcpy((char*) runningCost,(char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description,ARRAY_SIZE(ShmOCPP16Data->Cost.RunningCost[gun_index].description));
+			}
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+			{
+				// OCPP 2.0.1
+			}
 
 			if((ShmSysConfigAndInfo->SysInfo.OcppConnStatus == ON))
 			{
@@ -587,7 +644,7 @@ void page_charging(uint8_t gun_index, uint8_t system_mode)
 					setRunningCost(gun_index, SESSION_FEE);
 					setRunningCost(gun_index, OCCUPANCY_FEE);
 				}
-				else
+				else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 				{
 					// DISPLAY BY OCPP 2.0.1
 				}
@@ -682,7 +739,7 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 				}
 			}
 		}
-		else
+		else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 		{
 			// DISPLAY BY OCPP 2.0.1
 		}
@@ -707,7 +764,7 @@ void page_complete(uint8_t gun_index, uint8_t system_mode)
 			setParkingFeeTitle(ON);
 			setFinalCostTitle(ON);
 		}
-		else
+		else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 		{
 			// DISPLAY BY OCPP 2.0.1
 		}
@@ -787,7 +844,7 @@ void page_terminating(uint8_t gun_index, uint8_t system_mode)
 				setParkingFeeTitle(ON);
 				setFinalCostTitle(ON);
 			}
-			else
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
 				// DISPLAY BY OCPP 2.0.1
 			}
@@ -1456,7 +1513,7 @@ void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode)
 					}
 				}
 			}
-			else
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
 				// DISPLAY BY OCPP 2.0.1
 			}
@@ -1492,49 +1549,63 @@ void setUserPrice(uint8_t type)
 		case CONNECTION_FEE:
 			break;
 		case CURRENT_RATE:
-			if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Current Rate:") > 0)
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				// APPEAR PRICE ICON
-				setDisplayValue(ICON_PRICE, APPEAR);
-
-				// APPEAR PRICE TEXT
-				strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
-				split((char**)splitString, tmp, Symbol);
-				memcpy(input_data, splitString[1], strlen(splitString[1]));
-				length = strlen(input_data);
-				trim_string(input_data,length);
-				memcpy(output_data ,input_data, strlen(input_data));
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRICE, output_data, ARRAY_SIZE(output_data));
+				if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Current Rate:") > 0)
+				{
+					// APPEAR PRICE ICON
+					setDisplayValue(ICON_PRICE, APPEAR);
+
+					// APPEAR PRICE TEXT
+					strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
+					split((char**)splitString, tmp, Symbol);
+					memcpy(input_data, splitString[1], strlen(splitString[1]));
+					length = strlen(input_data);
+					trim_string(input_data,length);
+					memcpy(output_data ,input_data, strlen(input_data));
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_PRICE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
+				{
+					// DISAPPEAR PRICE ICON AND PRICE TEXT
+					setDisplayValue(ICON_PRICE, DISAPPEAR);
+					setDisplayValue(TEXT_PRICE, DISAPPEAR);
+				}
 			}
-			else
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				// DISAPPEAR PRICE ICON AND PRICE TEXT
-				setDisplayValue(ICON_PRICE, DISAPPEAR);
-				setDisplayValue(TEXT_PRICE, DISAPPEAR);
+				// OCPP 2.0.1
 			}
 			break;
 		case OCCUPANCY_FEE:
 			break;
 		case ACCOUNT_BALANCE:
-			if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Account Balance:") > 0)
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				// APPEAR ACCOUNT BALANCE ICON
-				setDisplayValue(ICON_USER_ACCOUNT_BALANCE, APPEAR);
-
-				// APPEAR ACCOUNT BALANCE TEXT
-				strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
-				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_USER_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
+				if(strstr((char *)ShmOCPP16Data->Cost.SetUserPrice.price, "Account Balance:") > 0)
+				{
+					// APPEAR ACCOUNT BALANCE ICON
+					setDisplayValue(ICON_USER_ACCOUNT_BALANCE, APPEAR);
+
+					// APPEAR ACCOUNT BALANCE TEXT
+					strcpy((char*)tmp,(char *)ShmOCPP16Data->Cost.SetUserPrice.price);
+					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_USER_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
+				{
+					// DISAPPEAR BALANCE ICON AND BALANCE TEXT
+					setDisplayValue(ICON_USER_ACCOUNT_BALANCE, DISAPPEAR);
+					setDisplayValue(TEXT_USER_ACCOUNT_BALANCE, DISAPPEAR);
+				}
 			}
-			else
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				// DISAPPEAR BALANCE ICON AND BALANCE TEXT
-				setDisplayValue(ICON_USER_ACCOUNT_BALANCE, DISAPPEAR);
-				setDisplayValue(TEXT_USER_ACCOUNT_BALANCE, DISAPPEAR);
+				// OCPP 2.0.1
 			}
 			break;
 		default:
@@ -1565,144 +1636,170 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
 		case CONNECTION_FEE:
 			break;
 		case SESSION_FEE:
-
-			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
-			{
-				setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
-
-				strcpy((char*)session_empty, "$ -----");
-				string2ByteArray(session_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
-			}
-			else
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				double chargingCost = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+				if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
 
-				if(!is_error(jsonDescription))
+					strcpy((char*)session_empty, "$ -----");
+					string2ByteArray(session_empty, output_data);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+					double chargingCost = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+
+					if(!is_error(jsonDescription))
 					{
-						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
-					}
+						if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+						{
+							chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+						}
 
-					if(chargingCost> 0)
-						sprintf((char*)output_data, "$ %.2f", chargingCost);
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(chargingCost> 0)
+							sprintf((char*)output_data, "$ %.2f", chargingCost);
+						else
+							sprintf((char*)output_data, "$ -----");
 
-					// APPEAR COST ICON
-					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+						// APPEAR COST ICON
+						setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
 			}
-			break;
-		case OCCUPANCY_FEE:
-
-			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
-
-				strcpy((char*)occupancy_empty, "$ -----");
-				string2ByteArray(occupancy_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+				// OCPP 2.0.1
 			}
-			else
+			break;
+		case OCCUPANCY_FEE:
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				double parkingCost = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+				if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
 
-				if(!is_error(jsonDescription))
+					strcpy((char*)occupancy_empty, "$ -----");
+					string2ByteArray(occupancy_empty, output_data);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					double parkingCost = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+
+					if(!is_error(jsonDescription))
 					{
-						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
-					}
+						if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+						{
+							parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+						}
 
-					if(parkingCost > 0)
-						sprintf((char*)output_data, "$ %.2f", parkingCost);
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(parkingCost > 0)
+							sprintf((char*)output_data, "$ %.2f", parkingCost);
+						else
+							sprintf((char*)output_data, "$ -----");
 
-					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+						setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
 			}
-			break;
-		case TOTAL_COST:
-			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
-
-				strcpy((char*)cost_empty, "$ -----");
-				string2ByteArray(cost_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+				// OCPP 2.0.1
 			}
-			else
+			break;
+		case TOTAL_COST:
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				double chargingCost = 0;
-				double parkingCost = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+				if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
 
-				if(!is_error(jsonDescription))
+					strcpy((char*)cost_empty, "$ -----");
+					string2ByteArray(cost_empty, output_data);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
-					{
-						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
-					}
+					double chargingCost = 0;
+					double parkingCost = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
 
-					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					if(!is_error(jsonDescription))
 					{
-						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
-					}
+						if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+						{
+							chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+						}
 
-					if((chargingCost + parkingCost) > 0)
-						sprintf((char*)output_data, "$ %.2f", (chargingCost + parkingCost));
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+						{
+							parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+						}
 
-					// APPEAR COST ICON
-					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+						if((chargingCost + parkingCost) > 0)
+							sprintf((char*)output_data, "$ %.2f", (chargingCost + parkingCost));
+						else
+							sprintf((char*)output_data, "$ -----");
+
+						// APPEAR COST ICON
+						setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
+			}
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+			{
+				// OCPP 2.0.1
 			}
 			break;
 		case ACCOUNT_BALANCE:
-			if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
+				if(ShmOCPP16Data->StopTransaction[gun_index].TransactionId != ShmOCPP16Data->Cost.FinalCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
 
-				strcpy((char*)balance_empty, "$ -----");
-				string2ByteArray(balance_empty, output_data);
+					strcpy((char*)balance_empty, "$ -----");
+					string2ByteArray(balance_empty, output_data);
 
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
-			}
-			else
-			{
-				double accountBalance = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
-
-				if(!is_error(jsonDescription))
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"accountBalance") != NULL)
+					double accountBalance = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.FinalCost[gun_index].description);
+
+					if(!is_error(jsonDescription))
 					{
-						accountBalance += json_object_get_double(json_object_object_get(jsonDescription,"accountBalance"));
-					}
+						if(json_object_object_get(jsonDescription,"accountBalance") != NULL)
+						{
+							accountBalance += json_object_get_double(json_object_object_get(jsonDescription,"accountBalance"));
+						}
 
-					if(accountBalance > 0)
-						sprintf((char*)output_data, "$ %.2f", accountBalance);
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(accountBalance > 0)
+							sprintf((char*)output_data, "$ %.2f", accountBalance);
+						else
+							sprintf((char*)output_data, "$ -----");
 
 
-					// APPEAR COST ICON
-					setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
+						// APPEAR COST ICON
+						setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
+			}
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+			{
+				// OCPP 2.0.1
 			}
 			break;
 		default:
@@ -1731,111 +1828,129 @@ void setRunningCost(uint8_t gun_index, uint8_t type)
 		case CONNECTION_FEE:
 			break;
 		case SESSION_FEE:
-			if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
-			{
-				setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
-
-				strcpy((char*)session_empty, "$ -----");
-				string2ByteArray(session_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
-			}
-			else
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				double chargingCost = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+				if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
 
-				if(!is_error(jsonDescription))
+					strcpy((char*)session_empty, "$ -----");
+					string2ByteArray(session_empty, output_data);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+					double chargingCost = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+
+					if(!is_error(jsonDescription))
 					{
-						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
-					}
+						if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+						{
+							chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+						}
 
-					if(chargingCost> 0)
-						sprintf((char*)output_data, "$ %.2f", chargingCost);
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(chargingCost> 0)
+							sprintf((char*)output_data, "$ %.2f", chargingCost);
+						else
+							sprintf((char*)output_data, "$ -----");
 
-					// APPEAR COST ICON
-					setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+						// APPEAR COST ICON
+						setDisplayValue(ICON_CHARGING_SESSION_FEE, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_SESSION_FEE, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
 			}
-
-			break;
-		case OCCUPANCY_FEE:
-			if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
-
-				strcpy((char*)occupancy_empty, "$ -----");
-				string2ByteArray(occupancy_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+				// OCPP 2.0.1
 			}
-			else
+			break;
+		case OCCUPANCY_FEE:
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				double parkingCost = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+				if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
 
-				if(!is_error(jsonDescription))
+					strcpy((char*)occupancy_empty, "$ -----");
+					string2ByteArray(occupancy_empty, output_data);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					double parkingCost = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+
+					if(!is_error(jsonDescription))
 					{
-						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
-					}
+						if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+						{
+							parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+						}
 
-					if(parkingCost > 0)
-						sprintf((char*)output_data, "$ %.2f", parkingCost);
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(parkingCost > 0)
+							sprintf((char*)output_data, "$ %.2f", parkingCost);
+						else
+							sprintf((char*)output_data, "$ -----");
 
-					setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+						setDisplayValue(ICON_CHARGING_PARKING_FEE, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_PARKING_FEE, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
 			}
-
-			break;
-		case TOTAL_COST:
-			if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 			{
-				setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
-
-				strcpy((char*)cost_empty, "$ -----");
-				string2ByteArray(cost_empty, output_data);
-				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+				// OCPP 2.0.1
 			}
-			else
+			break;
+		case TOTAL_COST:
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 			{
-				double chargingCost = 0;
-				double parkingCost = 0;
-				jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
+				if(ShmOCPP16Data->StartTransaction[gun_index].ResponseTransactionId != ShmOCPP16Data->Cost.RunningCost[gun_index].txId)
+				{
+					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
 
-				if(!is_error(jsonDescription))
+					strcpy((char*)cost_empty, "$ -----");
+					string2ByteArray(cost_empty, output_data);
+					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+				}
+				else
 				{
-					if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
-					{
-						chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
-					}
+					double chargingCost = 0;
+					double parkingCost = 0;
+					jsonDescription = json_tokener_parse((char*)ShmOCPP16Data->Cost.RunningCost[gun_index].description);
 
-					if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+					if(!is_error(jsonDescription))
 					{
-						parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
-					}
+						if(json_object_object_get(jsonDescription,"chargingFee") != NULL)
+						{
+							chargingCost += json_object_get_double(json_object_object_get(jsonDescription,"chargingFee"));
+						}
 
-					if((chargingCost + parkingCost) > 0)
-						sprintf((char*)output_data, "$ %.2f", (chargingCost + parkingCost));
-					else
-						sprintf((char*)output_data, "$ -----");
+						if(json_object_object_get(jsonDescription,"parkingFee") != NULL)
+						{
+							parkingCost += json_object_get_double(json_object_object_get(jsonDescription,"parkingFee"));
+						}
 
-					// APPEAR COST ICON
-					setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
-					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+						if((chargingCost + parkingCost) > 0)
+							sprintf((char*)output_data, "$ %.2f", (chargingCost + parkingCost));
+						else
+							sprintf((char*)output_data, "$ -----");
+
+						// APPEAR COST ICON
+						setDisplayValue(ICON_CHARGING_TOTAL_COST, APPEAR);
+						lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_CHARGING_TOTAL_COST, output_data, ARRAY_SIZE(output_data));
+					}
+					json_object_put(jsonDescription);
 				}
-				json_object_put(jsonDescription);
 			}
-
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+			{
+				// OCPP 2.0.1
+			}
 			break;
 		case ACCOUNT_BALANCE:
 			break;
@@ -1892,7 +2007,7 @@ void setQRCodeReceipt(uint8_t gun_index)
 	{
 		TransactionId = ShmOCPP16Data->StopTransaction[gun_index].TransactionId;
 	}
-	else
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
 	{
 		// TO DO OCPP 2.0
 	}
@@ -2480,14 +2595,28 @@ void setMarqueeControl(uint16_t address, uint8_t gun_index, uint8_t type)
 	switch(type)
 	{
 		case DEFAULE_PRICE:
-			sprintf((char *)Content, "%s", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
-			string2ByteArray(Content,data);
-			lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, (address+3), data, ARRAY_SIZE(data));
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+			{
+				sprintf((char *)Content, "%s", (char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[DefaultPrice].ItemData);
+				string2ByteArray(Content,data);
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, (address+3), data, ARRAY_SIZE(data));
+			}
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+			{
+				// OCPP 2.0.1
+			}
 			break;
 		case SET_USER_PRICE:
-			sprintf((char *)Content, "%s", (char *)ShmOCPP16Data->Cost.SetUserPrice.price);
-			string2ByteArray(Content,data);
-			lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, (address+3), data, ARRAY_SIZE(data));
+			if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+			{
+				sprintf((char *)Content, "%s", (char *)ShmOCPP16Data->Cost.SetUserPrice.price);
+				string2ByteArray(Content,data);
+				lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, (address+3), data, ARRAY_SIZE(data));
+			}
+			else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+			{
+				// OCPP 2.0.1
+			}
 			break;
 		case FINAL_COST:
 			break;
@@ -3276,7 +3405,7 @@ int main(void)
 				}
 				else if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus == SYS_MODE_RESERVATION)) && (ShmCharger->gun_info[ShmCharger->gun_selectd].resultAuthorization == VALIDATED_RFID))
 				{
-					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus == SYS_MODE_RESERVATION) && (strcmp((char*)ShmSysConfigAndInfo->SysConfig.UserId, (char*)ShmOCPP16Data->ReserveNow[ShmCharger->gun_selectd].IdTag) != 0))
+					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus == SYS_MODE_RESERVATION) && (ocpp_compare_reserve_id_with_user(ShmCharger->gun_selectd) != YES))
 					{
 						page_idle(ShmCharger->gun_selectd, ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus);
 					}