فهرست منبع

[Improve][Modularization][Module_OcppBackend]

2021.02.17 / Folus Wen

Actions:
1. Idtag expired time valid default result change to PASS.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 4 سال پیش
والد
کامیت
ff25f4d610

+ 4 - 2
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -3067,7 +3067,7 @@ int getStartStop(uint8_t *start, uint8_t *stop)
 
 int isOvertNow(uint8_t *start)
 {
-	int result = YES;
+	int result = NO;
 	struct tm tmStart;
 	struct timeb tbStart;
 
@@ -3082,10 +3082,12 @@ int isOvertNow(uint8_t *start)
 
 		if(DiffTimebWithNowSec(tbStart) <= 0)
 			result = NO;
+		else
+			result = YES;
 	}
 	else
 	{
-		DEBUG_WARN("Start date parsing error.\r\n");
+		DEBUG_WARN("Start date parsing error.\n");
 	}
 
 	return result;

+ 49 - 47
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -520,7 +520,7 @@ int getStartStop(uint8_t *start, uint8_t *stop)
 
 int isOvertNow(uint8_t *start)
 {
-	int result = YES;
+	int result = NO;
 	struct tm tmStart;
 	struct timeb tbStart;
 
@@ -535,10 +535,12 @@ int isOvertNow(uint8_t *start)
 
 		if(DiffTimebWithNowSec(tbStart) <= 0)
 			result = NO;
+		else
+			result = YES;
 	}
 	else
 	{
-		DEBUG_WARN("Start date parsing error.\r\n");
+		DEBUG_WARN("Start date parsing error.\n");
 	}
 
 	return result;
@@ -3551,42 +3553,42 @@ S_FAULT                 =12
 				{
 					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == 1) // //0: unplug, 1: Plug-in
 					{
-						currentStatus = 1; //OCPP Status: Preparing
+						currentStatus = Preparing; //OCPP Status: Preparing
 					}
 					else
 					{
-						currentStatus = 0; //OCPP Status: Available
+						currentStatus = Available; //OCPP Status: Available
 					}
 				}
 				else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
 				          ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
 						) //S_PRECHARGE
 				{
-					currentStatus = 1; //OCPP Status: Preparing
+					currentStatus = Preparing; //OCPP Status: Preparing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
 				{
-					currentStatus = 2; //OCPP Status: Charging
+					currentStatus = Charging; //OCPP Status: Charging
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
-					currentStatus = 5; //OCPP Status: Finishing
+					currentStatus = Finishing; //OCPP Status: Finishing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING   ---> SuspendedEV
 				{
-					currentStatus = 4; //OCPP Status: SuspendedEV
+					currentStatus = SuspendedEV; //OCPP Status: SuspendedEV
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //  ---> Unavailable
 				{
-					currentStatus = 7; //OCPP Status: Unavailable
+					currentStatus = Unavailable; //OCPP Status: Unavailable
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT   ---> Faulted
 				{
-					currentStatus = 8; //OCPP Status: Faulted
+					currentStatus = Faulted; //OCPP Status: Faulted
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) //    ---> Reserved
 				{
-					currentStatus = 6; //OCPP Status: Reserved
+					currentStatus = Reserved; //OCPP Status: Reserved
 				}
 			} //end of the same index
 		}//end of for CHAdeMO_QUANTITY
@@ -3612,42 +3614,42 @@ S_FAULT                 =12
 
 					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == 1) //0: unplug, 1: Plug-in
 					{
-						currentStatus = 1; //OCPP Status: Preparing
+						currentStatus = Preparing; //OCPP Status: Preparing
 					}
 					else
 					{
-						currentStatus = 0; //OCPP Status: Available
+						currentStatus = Available; //OCPP Status: Available
 					}
 				}
 				else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
 				          ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
 						) //S_PRECHARGE
 				{
-					currentStatus = 1; //OCPP Status: Preparing
+					currentStatus = Preparing; //OCPP Status: Preparing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
 				{
-					currentStatus = 2; //OCPP Status: Charging
+					currentStatus = Charging; //OCPP Status: Charging
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
-					currentStatus = 5; //OCPP Status: Finishing
+					currentStatus = Finishing; //OCPP Status: Finishing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING  ---> SuspendedEV
 				{
-					currentStatus = 4; //OCPP Status: SuspendedEV
+					currentStatus = SuspendedEV; //OCPP Status: SuspendedEV
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //   ---> Unavailable
 				{
-					currentStatus = 7; //OCPP Status : Unavailable
+					currentStatus = Unavailable; //OCPP Status : Unavailable
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT   ---> Faulted
 				{
-					currentStatus = 8; //OCPP Status: Faulted
+					currentStatus = Faulted; //OCPP Status: Faulted
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) //   ---> Reserved
 				{
-					currentStatus = 6; //OCPP Status: Reserved
+					currentStatus = Reserved; //OCPP Status: Reserved
 				}
 			} //end of the same index
 		} // end of for CCS_QUANTITY
@@ -3672,42 +3674,42 @@ S_FAULT                 =12
 
 					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == 1) // //0: unplug, 1: Plug-in
 					{
-						currentStatus = 1; //OCPP Status: Preparing
+						currentStatus = Preparing; //OCPP Status: Preparing
 					}
 					else
 					{
-						currentStatus = 0; //OCPP Status: Available
+						currentStatus = Available; //OCPP Status: Available
 					}
 				}
 				else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
 				          ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
 						) //S_PRECHARGE
 				{
-					currentStatus = 1; //OCPP Status: Preparing
+					currentStatus = Preparing; //OCPP Status: Preparing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
 				{
-					currentStatus = 2; //OCPP Status: Charging
+					currentStatus = Charging; //OCPP Status: Charging
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
-					currentStatus = 5; //OCPP Status: Finishing
+					currentStatus = Finishing; //OCPP Status: Finishing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING  ---> SuspendedEV
 				{
-					currentStatus = 4; //OCPP Status: SuspendedEV
+					currentStatus = SuspendedEV; //OCPP Status: SuspendedEV
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //  ---> Unavailable
 				{
-					currentStatus = 7; //OCPP Status: Unavailable
+					currentStatus = Unavailable; //OCPP Status: Unavailable
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT   ---> Faulted
 				{
-					currentStatus = 8; //OCPP Status: Faulted
+					currentStatus = Faulted; //OCPP Status: Faulted
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) //   ---> Reserved
 				{
-					currentStatus = 6; //OCPP Status: Reserved
+					currentStatus = Reserved; //OCPP Status: Reserved
 				}
 			} //end of the same index
 		} // end of for GB_QUANTITY
@@ -3725,11 +3727,11 @@ S_FAULT                 =12
 
 					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == 1) // //0: unplug, 1: Plug-in
 					{
-						currentStatus = 1; //OCPP Status: Preparing
+						currentStatus = Preparing; //OCPP Status: Preparing
 					}
 					else
 					{
-						currentStatus = 0; //OCPP Status: Available
+						currentStatus = Available; //OCPP Status: Available
 					}
 				}
 				else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
@@ -3737,31 +3739,31 @@ S_FAULT                 =12
 				) //S_PRECHARGE
 
 				{
-					currentStatus = 1; //OCPP Status: Preparing
+					currentStatus = Preparing; //OCPP Status: Preparing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
 				{
-					currentStatus = 2; //OCPP Status: Charging
+					currentStatus = Charging; //OCPP Status: Charging
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
 				{
-					currentStatus = 5; //OCPP Status: Finishing
+					currentStatus = Finishing; //OCPP Status: Finishing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING  ---> SuspendedEV
 				{
-					currentStatus = 4; //OCPP Status: SuspendedEV
+					currentStatus = SuspendedEV; //OCPP Status: SuspendedEV
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) //  ---> Unavailable
 				{
-					currentStatus = 7; //OCPP Status: Unavailable
+					currentStatus = Unavailable; //OCPP Status: Unavailable
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT   ---> Faulted
 				{
-					currentStatus = 8; //OCPP Status: Faulted
+					currentStatus = Faulted; //OCPP Status: Faulted
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) //   ---> Reserved
 				{
-					currentStatus = 6; //OCPP Status: Reserved
+					currentStatus = Reserved; //OCPP Status: Reserved
 				}
 			} //end of the same index
 		}
@@ -3785,40 +3787,40 @@ S_FAULT                 =12
 				{
 					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_B) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_C) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_D))
 					{
-						currentStatus = 1; //OCPP Status: Preparing
+						currentStatus = Preparing; //OCPP Status: Preparing
 					}
 					else
 					{
-						currentStatus = 0; //OCPP Status: Available
+						currentStatus = Available; //OCPP Status: Available
 					}
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
 				{
-					currentStatus = 1; //OCPP Status: Preparing
+					currentStatus = Preparing; //OCPP Status: Preparing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
 				{
-					currentStatus = 2; //OCPP Status: Charging
+					currentStatus = Charging; //OCPP Status: Charging
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
 				{
-					currentStatus = 5; //OCPP Status: Finishing
+					currentStatus = Finishing; //OCPP Status: Finishing
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING   ---> SuspendedEV
 				{
-					currentStatus = 4; //OCPP Status: SuspendedEV
+					currentStatus = SuspendedEV; //OCPP Status: SuspendedEV
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //   ---> Unavailable
 				{
-					currentStatus = 7; //OCPP Status: Unavailable
+					currentStatus = Unavailable; //OCPP Status: Unavailable
 				}
 				else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT   ---> Faulted
 				{
-					currentStatus = 8; //OCPP Status: Faulted
+					currentStatus = Faulted; //OCPP Status: Faulted
 				}
 				else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) //    ---> Reserved
 				{
-					currentStatus = 6; //OCPP Status: Reserved
+					currentStatus = Reserved; //OCPP Status: Reserved
 				}
 			}//end of the same index
 

+ 115 - 1
EVSE/Projects/AW-CCS/Apps/Module_Debug.c

@@ -40,6 +40,8 @@
 
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
+struct OCPP16Data				*ShmOCPP16Data;
+struct OCPP20Data				*ShmOCPP20Data;
 struct Charger					*ShmCharger;
 
 int StoreLogMsg(const char *fmt, ...)
@@ -113,6 +115,30 @@ int InitShareMemory()
 		result = FAIL;
 	}
 
+	// Initial ShmOCPP16Data
+	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+
+	// Initial ShmOCPP20Data
+	if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+
 	//Initial ShmCharger
 	if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), 0777)) < 0)
 	{
@@ -165,6 +191,7 @@ int main(void)
 		memset(cmd, 0x00, ARRAY_SIZE(cmd));
 		printf("\n ============== Debug main menu ==================");
 		printf("\n  info: List charger status info.");
+		printf("\n  test: Charger test command.");
 		printf("\n  exit: Exit Module_Debug_Test.");
 		printf("\n =================================================");
 		printf("\n  Please input debug command: ");
@@ -195,14 +222,33 @@ int main(void)
 
 					gun_index = gun_index<AC_QUANTITY?gun_index:0;
 
+					printf("\n  CSU u-boot version: %s", ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev);
+					printf("\n  CSU kernel version: %s", ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev);
+					printf("\n  CSU rootfs version: %s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
+					printf("\n --------------------------------------------------");
 					printf("\n  Charger connector plug times: %d", ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes);
+					printf("\n --------------------------------------------------");
 					printf("\n  CP positive voltage: %.2f", ShmCharger->gun_info[gun_index].PilotVoltage.PilotVoltagePositive);
 					printf("\n  CP negative voltage: %.2f", ShmCharger->gun_info[gun_index].PilotVoltage.PilotVoltageNegative);
+					printf("\n --------------------------------------------------");
 					printf("\n  CSU to MCU legacyRequest: %d", ShmCharger->gun_info[gun_index].legacyRequest.isLegacyRequest);
 					printf("\n  CSU to MCU relay on request: %d", ShmCharger->gun_info[gun_index].legacyRequest.isRelayOn);
+					printf("\n --------------------------------------------------");
 					printf("\n  Charger charging mode BS/HLC: %d", ShmCharger->gun_info[gun_index].chargingMode);
+					printf("\n --------------------------------------------------");
 					printf("\n  Charger input voltage L1: %.2f", ShmCharger->gun_info[gun_index].inputVoltage.L1N_L12);
-					printf("\n  CSU output current L1: %.2f", ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[0]);
+					printf("\n  Charger input voltage L2: %.2f", ShmCharger->gun_info[gun_index].inputVoltage.L2N_L23);
+					printf("\n  Charger input voltage L3: %.2f", ShmCharger->gun_info[gun_index].inputVoltage.L3N_L31);
+					printf("\n --------------------------------------------------");
+					printf("\n  CSU output current L1: %.2f", ShmCharger->gun_info[gun_index].outputCurrent.L1N_L12[gun_index]);
+					printf("\n  CSU output current L2: %.2f", ShmCharger->gun_info[gun_index].outputCurrent.L2N_L23[gun_index]);
+					printf("\n  CSU output current L3: %.2f", ShmCharger->gun_info[gun_index].outputCurrent.L3N_L31[gun_index]);
+					printf("\n --------------------------------------------------");
+					printf("\n  CSU power consumption L1: %.2f", (ShmCharger->gun_info[gun_index].powerConsumption[0].power_consumption/100.0));
+					printf("\n  CSU power consumption L2: %.2f", (ShmCharger->gun_info[gun_index].powerConsumption[1].power_consumption/100.0));
+					printf("\n  CSU power consumption L3: %.2f", (ShmCharger->gun_info[gun_index].powerConsumption[2].power_consumption/100.0));
+					printf("\n  CSU power total consumption: %.2f", (ShmCharger->gun_info[gun_index].powerConsumptionTotal.power_consumption/100.0));
+					printf("\n --------------------------------------------------");
 					printf("\n  CSU temperature: %d", ShmCharger->gun_info[gun_index].temperature.point[0]);
 
 					wait();
@@ -213,7 +259,9 @@ int main(void)
 					scanf("%d", &gun_index);
 					printf("\n  MCU info.\n\n");
 
+					gun_index = gun_index<AC_QUANTITY?gun_index:0;
 
+					printf("\n  Firmware version: %s", ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 					wait();
 				}
@@ -224,6 +272,72 @@ int main(void)
 				}
 			}while(!isExit);
 		}
+		else if(strcmp(cmd, "test") == 0)
+		{
+			int gun_index;
+
+			memset(cmd, 0x00, ARRAY_SIZE(cmd));
+			printf("\n ***************** Info menu *********************");
+			printf("\n  start: start charging session");
+			printf("\n  stop: stop charging session");
+			printf("\n  operative: enable charger gun");
+			printf("\n  inoperative: disable charger gun");
+			printf("\n  exit: exit to previous menu.");
+			printf("\n *************************************************");
+			printf("\n  Please input command: ");
+			scanf("%s", &cmd[0]);
+
+			if(strcmp(cmd, "start") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = ON;
+			}
+			else if(strcmp(cmd, "stop") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = ON;
+			}
+			else if(strcmp(cmd, "operative") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+				{
+					sprintf((char*)ShmOCPP16Data->ChangeAvailability[gun_index].Type, "Operative");
+					ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = ON;
+				}
+				else
+				{
+					sprintf((char*)(char*)ShmOCPP20Data->ChangeAvailability[gun_index].operationalStatus, "Operative");
+					ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = ON;
+				}
+			}
+			else if(strcmp(cmd, "inoperative") == 0)
+			{
+				printf("\n  Please input gun index: ");
+				scanf("%d", &gun_index);
+
+				if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+				{
+					sprintf((char*)ShmOCPP16Data->ChangeAvailability[gun_index].Type, "Inoperative");
+					ShmOCPP16Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = ON;
+				}
+				else
+				{
+					sprintf((char*)(char*)ShmOCPP20Data->ChangeAvailability[gun_index].operationalStatus, "Inoperative");
+					ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityReq = ON;
+				}
+			}
+			else if(strcmp(cmd, "exit") == 0)
+			{
+				printf("\n  Exit to previous.\n\n");
+			}
+		}
 		else if(strcmp(cmd, "exit") == 0)
 		{
 			printf("\n  exit program.\n\n");

+ 4 - 3
EVSE/Projects/AW-CCS/Apps/Module_InternalComm.c

@@ -1966,16 +1966,17 @@ int main(void)
 					ShmCharger->gun_info[gun_index].acCcsInfo.CpNegativeVoltage = ShmCharger->gun_info[gun_index].PilotVoltage.PilotVoltageNegative;					
 					ShmCharger->gun_info[gun_index].acCcsInfo.CpPresentPWMDuty = ShmCharger->gun_info[gun_index].primaryMcuState.current_limit;
 					
-					if(ShmCharger->gun_info[gun_index].primaryMcuState.relayState.relay_status[0][0]>0)
+					if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state)
 					{
 						ShmCharger->gun_info[gun_index].acCcsInfo.OutputRelayStatus = ON;
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].RelayK1K2Status = ON;
 					}
 					else
 					{
-						ShmCharger->gun_info[gun_index].acCcsInfo.OutputRelayStatus = OFF;	
+						ShmCharger->gun_info[gun_index].acCcsInfo.OutputRelayStatus = OFF;
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].RelayK1K2Status = OFF;
 					}					
 
-
 					failCount[gun_index] = 0;
 				}
 				else

+ 34 - 1
EVSE/Projects/AW-CCS/Apps/main.c

@@ -675,6 +675,33 @@ void ocpp_copy_userid_to_starttransaction(uint8_t gun_index)
 	}
 }
 
+uint8_t ocpp_get_starttransaction_result(uint8_t gun_index)
+{
+	uint8_t result = PASS;
+
+	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
+	{
+		if((strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Blocked")==0) ||
+		   (strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Expired")==0) ||
+		   (strcmp((char*)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid")==0))
+			result = NO;
+	}
+	else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
+	{
+		if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Blocked")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Expired")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Invalid")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NoCredit")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAllowedTypeEVSE")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAtThisLocation")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "NotAtThisTime")==0) ||
+		   (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, "Unknown")==0))
+			result = NO;
+	}
+
+	return result;
+}
+
 uint8_t ocpp_get_smartcharging_profileId(uint8_t gun_index)
 {
 	uint8_t result = 0;
@@ -3026,6 +3053,7 @@ void checkReset()
 				sprintf((char*)ShmOCPP16Data->Reset.ResponseStatus, "Accepted");
 				ShmOCPP16Data->MsMsg.bits.ResetConf = ON;
 
+				DEBUG_INFO("%s reset request by OCPP.\n", ShmOCPP16Data->Reset.Type);
 				if(strcmp((char*)ShmOCPP16Data->Reset.Type, "Hard") == 0)
 				{
 					system("sync");
@@ -3054,8 +3082,10 @@ void checkReset()
 				sprintf((char*)ShmOCPP20Data->Reset.Response_status, "Accepted");
 				ShmOCPP20Data->MsMsg.bits.ResetConf = ON;
 
+				DEBUG_INFO("%s reset request by OCPP.\n", ShmOCPP20Data->Reset.type);
 				if(strcmp((char*)ShmOCPP20Data->Reset.type, "Immediate") == 0)
 				{
+
 					system("sync");
 					sleep(5);
 					system("reboot -f");
@@ -4343,7 +4373,8 @@ int main(void)
 
 					if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
 					   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
-					   ocpp_get_remotestop(gun_index)||
+					   ocpp_get_remotestop(gun_index) ||
+					   (ocpp_get_connection_status() && !ocpp_get_starttransaction_result(gun_index)) ||
 					   ((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState != CP_STATE_C) ||
 					   ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && !ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn) ||
 					   ocpp_get_reset_req() ||
@@ -4734,6 +4765,7 @@ int main(void)
 					   (ShmCharger->gun_info[gun_index].isAuthPassEnd) ||
 					   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
 					   ocpp_get_remotestop(gun_index) ||
+					   (ocpp_get_connection_status() && !ocpp_get_starttransaction_result(gun_index)) ||
 					   ((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) && ocpp_get_StopTransactionOnEVSideDisconnect()) ||
 					   ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && !ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn) ||
 					   ocpp_get_reset_req() ||
@@ -4920,6 +4952,7 @@ int main(void)
 						   !ocpp_get_remotestop(gun_index) &&
 						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].schedule.isTriggerStop != ON) &&
 						   !ocpp_get_reset_req() &&
+						   ocpp_get_starttransaction_result(gun_index) &&
 						   !(ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60))) &&
 						   !(ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedEnergy >= ((float)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy))) &&
 						   !(!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy != OFF_POLICY_NOCHARGE) && ((ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration > 0) ? (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration*60)) : (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration > 0) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargedDuration >= (ShmSysConfigAndInfo->SysConfig.MaxChargingDuration*60)))) &&