Przeglądaj źródła

2020-01-21 / Kathy Yeh
1. modify error : compare AC /DC

Kathy_Yeh 5 lat temu
rodzic
commit
8226091a3e
1 zmienionych plików z 49 dodań i 61 usunięć
  1. 49 61
      EVSE/Modularization/ocppfiles/MessageHandler.c

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

@@ -44,6 +44,8 @@
 
 
 
+
+
 #define PASS				1
 #define FAIL				-1
 
@@ -104,7 +106,7 @@ static int UnknownKeynum = 0;
 //===============================
 // Gun Total  Numbers
 //===============================
-//#define  gunTotalNumber (strstr(ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL) ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY
+//#define  gunTotalNumber (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY
 static int gunTotalNumber=0;
 
 //===============================
@@ -1024,7 +1026,7 @@ int InitShareMemory()
     /****************************** For TEST ************************************************/
 	//inital settings
 
-   	gunTotalNumber = (strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL) ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY;
+   	gunTotalNumber = (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') ? (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY): AC_QUANTITY;
 
 	memset(ShmOCPP16Data->StatusNotification,0,sizeof(struct StructStatusNotification)*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY));
 
@@ -1187,7 +1189,7 @@ void CheckSystemValue(void)
 	//==============================================
 	if(isUpdateRequest == TRUE )
 	{
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for(int gun_index=0;gun_index < (CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY) ;gun_index++)
 			{
@@ -1317,7 +1319,7 @@ void CheckSystemValue(void)
 		// Charger status report
 		//==============================================
 		/* Check Mode Change */
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -1408,7 +1410,7 @@ void CheckSystemValue(void)
 	if((server_sign == TRUE) &&  ((time((time_t*)NULL) - clientTime.MeterValues[gun_index])> (atoi((const char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[MeterValueSampleInterval].ItemData)- 1 ) ) )
 	{
 		//check Transaction active
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -1552,7 +1554,7 @@ void CheckSystemValue(void)
 		{
 			//check Transaction active
 
-			if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+			if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 			{
 				for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 				{
@@ -1761,7 +1763,7 @@ int sendBootNotificationRequest(void)
 
 
     //check Transaction active
-    if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+    if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
     {
     	for (int index = 0; index < CHAdeMO_QUANTITY; index++)
     	{
@@ -2077,7 +2079,7 @@ int sendStartTransactionRequest(int gun_index)
 	strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].Timestamp, buf);
 	strcpy((char *)ShmOCPP16Data->StartTransaction[gun_index].IdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
 
-	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	{
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
@@ -2207,7 +2209,7 @@ S_FAULT                 =12
     */
 
 	//check Transaction active
-	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	{
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
@@ -2453,7 +2455,7 @@ int sendStopTransactionRequest(int gun_index)
 	strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (const char *)ShmSysConfigAndInfo->SysConfig.UserId/*ShmOCPP16Data->Authorize.IdTag*/);
 
 	//ENERGY_ACTIVE_IMPORT_REGISTER
-	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	{
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
@@ -2614,7 +2616,7 @@ int sendStopTransactionRequest(int gun_index)
 		//Current.Export
 
 		idx_sample=1;
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -2672,7 +2674,7 @@ int sendStopTransactionRequest(int gun_index)
 
 		//Energy.Active.Export.Interval
 		idx_sample=2;
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -2730,7 +2732,7 @@ int sendStopTransactionRequest(int gun_index)
 
 		//Power.Active.Export
 		idx_sample=3;
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -2788,7 +2790,7 @@ int sendStopTransactionRequest(int gun_index)
 
 		//Voltage
 		idx_sample=4;
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -2845,7 +2847,7 @@ int sendStopTransactionRequest(int gun_index)
 
 		//SoC
 		idx_sample=5;
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -2994,7 +2996,7 @@ int sendMeterValuesRequest(int gun_index)
 
 		idx_sample=0;
 		//********************************(1)Current.Export************************************************/
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -3053,7 +3055,7 @@ int sendMeterValuesRequest(int gun_index)
 #if 0
 		idx_sample=1;
 		//****************************************************(2)Energy.Active.Export.Register*********************************************/
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -3114,7 +3116,7 @@ int sendMeterValuesRequest(int gun_index)
 
     	idx_sample=1;
     	//****************************************************(3)Energy.Active.Export.Interval*********************************************/
-    	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+    	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
     	{
     		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
     	    {
@@ -3174,7 +3176,7 @@ int sendMeterValuesRequest(int gun_index)
 
     	idx_sample=2;
 		//********************************(4)Power.Active.Export************************************************/
-    	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+    	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
     	{
     		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
     		{
@@ -3233,7 +3235,7 @@ int sendMeterValuesRequest(int gun_index)
 
 		idx_sample=3;
 		//***********************************************(5)VOLTAGE******************************************************/
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -3288,48 +3290,34 @@ int sendMeterValuesRequest(int gun_index)
 			ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Unit
 		);
 
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			idx_sample=4;
 			//sampledValue = NULL;
 			//***********************************************(6)SOC******************************************************/
-			if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
-				for (int index = 0; index < CHAdeMO_QUANTITY; index++)
-				{
-					if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
-					{
-						sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );
-					}
-				}
-
-				for (int index = 0; index < CCS_QUANTITY; index++)
+				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
 				{
-					if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
-					{
-						sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc );
-					}
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );
 				}
+			}
 
-				for (int index = 0; index < GB_QUANTITY; index++)
+			for (int index = 0; index < CCS_QUANTITY; index++)
+			{
+				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
 				{
-					if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
-					{
-						sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc );
-					}
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc );
 				}
 			}
-			else
+
+			for (int index = 0; index < GB_QUANTITY; index++)
 			{
-				for (int index = 0; index < AC_QUANTITY; index++)
+				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
 				{
-					if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
-					{
-						sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc );
-					}
+					sprintf((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Value, "%d" ,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc );
 				}
-
-			}//END FOR AC ELSE
+			}
 
 
 			strcpy((char *)ShmOCPP16Data->MeterValues[gun_index].MeterValue[idx_transaction].SampledValue[idx_sample].Context, ReadingContextStr[ReadingContext_Sample_Periodic]);
@@ -3911,7 +3899,7 @@ int handleCancelReservationRequest(char *uuid, char *payload)
 
 	 //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
 	 //check Transaction active
-	 if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	 if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	 {
 		 for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		 {
@@ -4076,7 +4064,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 	if(strcmp((const char *)typeStr, AvailabilityTypeStr[Inoperative]) == 0)
 	{
 	    //check Transaction active
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -4172,7 +4160,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
 	    //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
 	    //check Transaction active
 
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -7079,7 +7067,7 @@ int handleRemoteStartRequest(char *uuid, char *payload)
 	    //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault  8: Reserved
 
 		//check Transaction active
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -7350,7 +7338,7 @@ int handleRemoteStopTransactionRequest(char *uuid, char *payload)
 	        {
 				//check Transaction active
 
-				if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 				{
 					for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 					{
@@ -7534,7 +7522,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 	if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/))
 	{
 		//check Transaction active
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -7722,7 +7710,7 @@ int handleReserveNowTransactionRequest(char *uuid, char *payload)
 	else if(connectorIdInt == 0)
 	{
 
-	  if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	  if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	  {
 			//check Transaction active
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
@@ -7905,7 +7893,7 @@ int handleResetRequest(char *uuid, char *payload)
 	if(strcmp(typestr, ResetTypeStr[Hard])==0)
 	{
 	   //check Transaction active
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			{
@@ -7957,7 +7945,7 @@ int handleResetRequest(char *uuid, char *payload)
 	 else if(strcmp(typestr, ResetTypeStr[Soft])==0)
 	 {
 	     //check Transaction active
-		 if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		 if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		 {
 			 for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 			 {
@@ -8052,7 +8040,7 @@ int handleSendLocalListRequest(char *uuid, char *payload)
 	}
 
 
-	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	{
 		//check Charge Point state
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
@@ -9364,7 +9352,7 @@ int handleUnlockConnectorRequest(char *uuid, char *payload)
 	else
 	{
 	  //check Transaction active
-	  if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	  if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	  {
 		  for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		  {
@@ -12347,7 +12335,7 @@ int ftpFile(char *location, char *user, char *password, int port, char *path, ch
 
 int SettingChargingRecord(int target, int transactionId)
 {
-	if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+	if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 	{
 		for (int index = 0; index < CHAdeMO_QUANTITY; index++)
 		{
@@ -12868,7 +12856,7 @@ void SetOcppConnStatus(uint8_t status)
 
 	if(status == FALSE)
 	{
-		if(strstr((const char *)ShmSysConfigAndInfo->SysConfig.ModelName ,"DC") != NULL)
+		if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
 		{
 			SystemInitial = CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY;
 		}