瀏覽代碼

2022-03-04/Jerry Wang
Action:
1. Modify clock-aligned meterValue timestamp to show the interval startTime(previous sampled time).

File:
1. EVSE/Modularization/ocpp20/MessageHandler.c
--> Action 1

Jerry Wang 3 年之前
父節點
當前提交
770dada5f0
共有 1 個文件被更改,包括 14 次插入1 次删除
  1. 14 1
      EVSE/Modularization/ocpp20/MessageHandler.c

+ 14 - 1
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -8138,7 +8138,20 @@ int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
 	t = time(NULL);
 	/*UTC time and date*/
 	tm = gmtime(&t);
-	strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
+
+	if(dataType == ReadingContextEnumType_Sample_Clock)
+	{
+		struct tm *tmTarget;
+		struct timeb tbTarget;
+		tbTarget.time = mktime(tm);
+		tbTarget.time -= (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value));
+		tmTarget = gmtime(&tbTarget.time);
+		strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tmTarget);
+	}
+	else
+	{
+		strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
+	}
 	strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
 
 	//DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);