소스 검색

2020-06-02 / Kathy Yeh
1. modify ChangeAvailability issue: connector is 0 & in charging mode, reply status should be scheduled.

Kathy_Yeh 4 년 전
부모
커밋
af1aa4011e
1개의 변경된 파일196개의 추가작업 그리고 9개의 파일을 삭제
  1. 196 9
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 196 - 9
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -5839,10 +5839,131 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 	if(strcmp((const char *)typeStr, AvailabilityTypeStr[Inoperative]) == 0)
 	{
+		
+			//----------------------gunIndex is 0  ------------------------------------------------//
+		if(gunIndex  == 0)
+		{
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
+			{
+				for(int i=0; i < gunTotalNumber; i++)
+				{
+					for (int index = 0; index < CHAdeMO_QUANTITY; index++)
+					{
+						if (gunType[i] == 'J')
+						{
+							if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
+							{
+								sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+								goto end;
+							}
+							else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+									(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+									(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+									(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+									(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE))  // S_CHARGING
+							{
+								sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
+								goto end;
+							}
+						}
+					}//END FOR CHAdeMO_QUANTITY
+
+					for (int index = 0; index < CCS_QUANTITY; index++)
+					{
+						if ((gunType[i] == 'U')||(gunType[i] == 'E'))
+						{
+							if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
+							{
+									sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+									goto end;
+							}
+								else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+										(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+										(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+										(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+										(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
+							{
+									sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
+									goto end;
+							}
+						}
+					}//END FOR CCS_QUANTITY
+
+					for (int index = 0; index < GB_QUANTITY; index++)
+					{
+						if (gunType[i] == 'G')
+						{
+							if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
+							{
+									sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+									goto end;
+							}
+							else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+									(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+									(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+									(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+									(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
+							{
+									sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
+									goto end;
+							}
+						}
+					}// END FOR GB_QUANTITY
+
+					for (int index = 0; index < AC_QUANTITY; index++)
+					{
+						if ((gunType[i] > '0')&&(gunType[i] <= '9'))
+						{
+							if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
+							{
+									sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+									goto end;
+							}
+							else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
+									(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
+									(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+									(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
+									(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
+							{
+									sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
+									goto end;
+							}
+						}
+					}//END FOR AC_QUANTITY
+				}// END FOR gunTotalNumber
+			}
+			else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
+			{
+				for(int i=0; i < gunTotalNumber; i++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
+					{
+						sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+						goto end;
+					}
+					else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
+						(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
+					{
+						sprintf(comfirmstr, "%s", AvailabilityStatusStr[Scheduled] );
+						goto end;
+					}
+				}
+			}
+
+			sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
+			goto end;
+		}
+
+
+		//----------------------gunIndex is not 0  ------------------------------------------------//
+		
 	    //check Transaction active
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
-			if ((gunIndex  == 0) || ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J')))
+			if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
 			{
 				if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
 				{
@@ -5869,7 +5990,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < CCS_QUANTITY; index++)
 		{
-			if ((gunIndex  == 0)||  ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))))
+			if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
 			{
 				if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
 				{
@@ -5896,7 +6017,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < GB_QUANTITY; index++)
 		{
-			if ((gunIndex  == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G')))
+			if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
 			{
 				if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
 				{
@@ -5925,7 +6046,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < AC_QUANTITY; index++)
 		{
-			if ((gunIndex  == 0) || ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))))
+			if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
 			{
 				if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
 				{
@@ -5955,11 +6076,77 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 	if(strcmp((const char *)typeStr, AvailabilityTypeStr[Operative]) == 0)
 	{
-	    //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
+		//----------------------gunIndex is 0  ------------------------------------------------//
+		if(gunIndex  == 0)
+		{
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
+			{
+				for(int i=0; i < gunTotalNumber; i++)
+				{
+					for (int index = 0; index < CHAdeMO_QUANTITY; index++)
+					{
+						if ((gunType[i] == 'J' ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT))  //S_FAULT   //(((gunIndex  == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J')) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+						{
+							sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+							goto end;
+						}
+					}//END FOR CHAdeMO_QUANTITY
+
+					for (int index = 0; index < CCS_QUANTITY; index++)
+					{
+						if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT//(((gunIndex  == 0)|| ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
+						{
+							sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+							goto end;
+						}
+					}//END FOR CCS_QUANTITY
+
+					for (int index = 0; index < GB_QUANTITY; index++)
+					{
+						if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT  //(((gunIndex  == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G')))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
+						{
+							//ShmOCPP16Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = 1;
+							sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+							goto end;
+						}
+					}// END FOR GB_QUANTITY
+
+					for (int index = 0; index < AC_QUANTITY; index++)
+					{
+						if (((gunType[i] > '0')&&(gunType[i] <= '9')) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT))  //S_FAULT // (((gunIndex  == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+						{
+							sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+							goto end;
+						}
+					}//END FOR CHAdeMO_QUANTITY
+
+				}// END FOR gunTotalNumber
+			}
+			else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
+			{
+				for(int i=0; i < gunTotalNumber; i++)
+				{
+					for (int index = 0; index < AC_QUANTITY; index++)
+					{
+						if (((gunType[i] > '0')&&(gunType[i] <= '9')) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT))  //S_FAULT // (((gunIndex  == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+						{
+							sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
+							goto end;
+						}
+					}//END FOR CHAdeMO_QUANTITY
+
+				} // END FOR gunTotalNumber
+			}
+
+			sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
+			goto end;
+		}
+
+		//----------------------gunIndex is not 0  ------------------------------------------------//
 	    //check Transaction active
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0) || ((gunIndex > 0) && (gunType[gunIndex-1] == 'J'))) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+			if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
@@ -5968,7 +6155,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < CCS_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0) || ((gunIndex > 0) && ((gunType[gunIndex - 1] == 'U') || (gunType[gunIndex - 1] == 'E')))) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
+			if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
@@ -5977,7 +6164,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < GB_QUANTITY; index++)
 		{
-			if (((gunIndex  == 0) || ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
+			if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;
@@ -5986,7 +6173,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 
 		for (int index = 0; index < AC_QUANTITY; index++)
 		{
-			if( ((gunIndex  == 0) || ((gunIndex > 0) && ((gunType[gunIndex-1] > '0') && (gunType[gunIndex-1] <= '9')))) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
+			if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT))  //S_FAULT
 			{
 				sprintf(comfirmstr, "%s", AvailabilityStatusStr[Accepted] );
 				goto end;