瀏覽代碼

2020.07.02 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/MessageHandler.c checkCompositeSchedule() period compare with maxProfile logic improve.
2. EVSE/Modularization/ocppfiles/MessageHandler.c CheckSystemValue() delete TxProfile file logic improve.

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 年之前
父節點
當前提交
30d1d55156
共有 1 個文件被更改,包括 88 次插入60 次删除
  1. 88 60
      EVSE/Modularization/ocppfiles/MessageHandler.c

+ 88 - 60
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -1758,18 +1758,27 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 		for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
 		{
 			if((txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit != -1) &&
-			   (txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod < durationReq))
+			   (txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod < durationReq) &&
+			   (txProfile.ChargingSchedule.Duration > 0))
 			{
 				if(maxProfile.ChargingProfileId != -1)
 				{
 					for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
 					{
-						if((txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod >= maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].StartPeriod) &&
-						   (maxProfile.ChargingSchedule.Duration > txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod))
+						if((txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod >= maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].StartPeriod))
 						{
-							tmpPeriod.StartPeriod = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod;
-							tmpPeriod.NumberPhases = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].NumberPhases;
-							tmpPeriod.Limit = (txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit>maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit?maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit:txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit);
+							if((maxProfile.ChargingSchedule.Duration > 0))
+							{
+								tmpPeriod.StartPeriod = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod;
+								tmpPeriod.NumberPhases = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].NumberPhases;
+								tmpPeriod.Limit = (txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit>maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit?maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit:txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit);
+							}
+							else
+							{
+								tmpPeriod.StartPeriod = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].StartPeriod;
+								tmpPeriod.NumberPhases = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].NumberPhases;
+								tmpPeriod.Limit = txProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit;
+							}
 						}
 
 						if(idxMaxPeriod == (limitMax-1))
@@ -1818,9 +1827,18 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 								{
 									if(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod >= maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].StartPeriod)
 									{
-										tmpPeriod.StartPeriod = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod;
-										tmpPeriod.NumberPhases = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].NumberPhases;
-										tmpPeriod.Limit = (defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit>maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit?maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit:defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit);
+										if((maxProfile.ChargingSchedule.Duration > 0))
+										{
+											tmpPeriod.StartPeriod = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod;
+											tmpPeriod.NumberPhases = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].NumberPhases;
+											tmpPeriod.Limit = (defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit>maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit?maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit:defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxTxPeriod].Limit);
+										}
+										else
+										{
+											tmpPeriod.StartPeriod = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod;
+											tmpPeriod.NumberPhases = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].NumberPhases;
+											tmpPeriod.Limit = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit;
+										}
 
 										if(tmpPeriod.Limit != compositeProfile->ChargingSchedule.ChargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].Limit)
 										{
@@ -1871,9 +1889,18 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 					{
 						if(defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod >= maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].StartPeriod)
 						{
-							tmpPeriod.StartPeriod = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod;
-							tmpPeriod.NumberPhases = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].NumberPhases;
-							tmpPeriod.Limit = (defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit>maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit?maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit:defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit);
+							if((maxProfile.ChargingSchedule.Duration > 0))
+							{
+								tmpPeriod.StartPeriod = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod;
+								tmpPeriod.NumberPhases = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].NumberPhases;
+								tmpPeriod.Limit = (defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit>maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit?maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].Limit:defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit);
+							}
+							else
+							{
+								tmpPeriod.StartPeriod = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].StartPeriod;
+								tmpPeriod.NumberPhases = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].NumberPhases;
+								tmpPeriod.Limit = defaultTxProfile.ChargingSchedule.ChargingSchedulePeriod[idxDefPeriod].Limit;
+							}
 
 							if(tmpPeriod.Limit != compositeProfile->ChargingSchedule.ChargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].Limit)
 							{
@@ -1926,7 +1953,8 @@ void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct St
 
 				if(idxMaxPeriod == (limitMax-1))
 				{
-					if(maxProfile.ChargingSchedule.Duration > compositeProfile->ChargingSchedule.ChargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].StartPeriod)
+					if((maxProfile.ChargingSchedule.Duration > compositeProfile->ChargingSchedule.ChargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].StartPeriod) &&
+					   (maxProfile.ChargingSchedule.Duration > 0))
 					{
 						tmpPeriod.StartPeriod = compositeProfile->ChargingSchedule.Duration;
 						tmpPeriod.NumberPhases = maxProfile.ChargingSchedule.ChargingSchedulePeriod[idxMaxPeriod].NumberPhases;
@@ -2260,6 +2288,19 @@ void CheckSystemValue(void)
 						statusModeChage[gun_index] = TRUE;
 					}
 
+					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
+					{
+						sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
+						if((access(filenmae,F_OK))!=-1)
+						{
+							DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
+
+							sprintf(str,"rm -f %s",filenmae);
+							system(str);
+						}
+
+					}
+
 			#if 1 // for TempStopTransaction
 					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
 					{
@@ -2294,6 +2335,17 @@ void CheckSystemValue(void)
 						statusModeChage[gun_index] = TRUE;
 					}
 
+					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
+					{
+						sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
+						if((access(filenmae,F_OK))!=-1)
+						{
+							DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
+							sprintf(str,"rm -f %s",filenmae);
+							system(str);
+						}
+					}
+
 			#if 1 // for TempStopTransaction
 					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
 					{
@@ -2328,6 +2380,17 @@ void CheckSystemValue(void)
 						statusModeChage[gun_index] = TRUE;
 					}
 
+					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
+					{
+						sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
+						if((access(filenmae,F_OK))!=-1)
+						{
+							DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
+							sprintf(str,"rm -f %s",filenmae);
+							system(str);
+						}
+					}
+
 		#if 1 // for TempStopTransaction
 					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
 					{
@@ -2362,6 +2425,18 @@ void CheckSystemValue(void)
 						statusModeChage[gun_index] = TRUE;
 					}
 
+					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
+					{
+						sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
+						if((access(filenmae,F_OK))!=-1)
+						{
+							DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
+
+							sprintf(str,"rm -f %s",filenmae);
+							system(str);
+						}
+					}
+
 			#if 1 // for TempStopTransaction
 					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP16Data->CpMsg.bits[gun_index].StopTransactionReq == 0))
 					{
@@ -2418,19 +2493,6 @@ void CheckSystemValue(void)
 						reqClockAlignMeter[gun_index] = 1;
 					}
 				}
-
-				if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
-				{
-					sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
-					if((access(filenmae,F_OK))!=-1)
-					{
-						DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
-
-						sprintf(str,"rm -f %s",filenmae);
-						system(str);
-					}
-
-				}
 			}// End for CHAdeMO
 		}
 		else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
@@ -2460,17 +2522,6 @@ void CheckSystemValue(void)
 						reqClockAlignMeter[gun_index] = 1;
 					}
 				}
-
-				if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
-				{
-					sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
-					if((access(filenmae,F_OK))!=-1)
-					{
-						DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
-						sprintf(str,"rm -f %s",filenmae);
-						system(str);
-					}
-				}
 			} // End for CCS
 		}
 		else if(gunType[gun_index] == 'G')
@@ -2499,17 +2550,6 @@ void CheckSystemValue(void)
 						reqClockAlignMeter[gun_index] = 1;
 					}
 				}
-
-				if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
-				{
-					sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
-					if((access(filenmae,F_OK))!=-1)
-					{
-						DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
-						sprintf(str,"rm -f %s",filenmae);
-						system(str);
-					}
-				}
 			}// End for GB
 		}
 		else
@@ -2538,18 +2578,6 @@ void CheckSystemValue(void)
 						reqClockAlignMeter[gun_index] = 1;
 					}
 				}
-
-				if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
-				{
-					sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
-					if((access(filenmae,F_OK))!=-1)
-					{
-						DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
-
-						sprintf(str,"rm -f %s",filenmae);
-						system(str);
-					}
-				}
 			}//End for AC
 		}