浏览代码

Merge branch 'master' of https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x

2020-01-02 / Kathy Yeh [Module_OcppBackend]1. modify  logic : a. Transaction Related Message not Accepted by Central System b. Offline Transaction c. csu trigger DataTransferReq
Kathy_Yeh 5 年之前
父节点
当前提交
6768312824
共有 2 个文件被更改,包括 115 次插入7 次删除
  1. 106 3
      EVSE/Modularization/WebService.c
  2. 9 4
      EVSE/rootfs/var/www/head.php

+ 106 - 3
EVSE/Modularization/WebService.c

@@ -77,6 +77,28 @@ int StoreLogMsg(const char *fmt, ...) {
 
 	return rc;
 }
+int WriteLogMsg(const char *fmt, ...) {
+	char Buf[4096 + 256];
+	char buffer[4096];
+	time_t CurrentTime;
+	struct tm *tm;
+	va_list args;
+
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
+
+	memset(Buf, 0, sizeof(Buf));
+	CurrentTime = time(NULL);
+	tm = localtime(&CurrentTime);
+	sprintf(Buf,
+			"echo \"[%04d.%02d.%02d %02d:%02d:%02d WebService] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+			tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
+			tm->tm_min, tm->tm_sec, buffer, tm->tm_year + 1900, tm->tm_mon + 1);
+	system(Buf);
+
+	return rc;
+}
 #endif
 
 int DiffTimeb(struct timeb ST, struct timeb ET) {
@@ -186,6 +208,7 @@ int InitShareMemory() {
 	//creat ShmSysConfigAndInfo
 	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey,
 			sizeof(struct SysConfigAndInfo), 0777)) < 0) {
+			printf("%s\n","InitShareMemory Error");
 	#ifdef SystemLogMessage
 		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
 	#endif
@@ -272,7 +295,9 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 // Main process
 //================================================
 int main(int argc, char *argv[]) {
+	int InitShMry = 1;
 	if (InitShareMemory() == FAIL) {
+		InitShMry = 0;
 		#ifdef SystemLogMessage
 		DEBUG_ERROR("InitShareMemory NG\n");
 		#endif
@@ -585,7 +610,7 @@ int main(int argc, char *argv[]) {
 		if (strcmp(argv[1], "aaa") == 0) {
 			struct SysConfigData 	SysConfig;
 		//system
-		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "DSLU122110T1P0");
+		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "AWLU770100T1P0D");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber, "SerialNumber");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemId, "1234567890");
 		strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemDateTime, "2019-12-31 23:59:59");
@@ -897,6 +922,14 @@ int main(int argc, char *argv[]) {
 		struct json_object *OcppServerURL;
 		struct json_object *ChargeBoxId;
 
+		/* log for debug charginginfodata start*/
+//		#ifdef SystemLogMessage
+			WriteLogMsg("ModelName:%s",(char *)&ShmSysConfigAndInfo->SysConfig.ModelName);
+			WriteLogMsg("connectorType1:%d",connectorType1);
+			WriteLogMsg("connectorType2:%d",connectorType2);
+			WriteLogMsg("connectorType3:%d",connectorType3);
+//		#endif
+		/* log for debug charginginfodata end*/
 
 
 //		array_obj = json_object_new_array();
@@ -1046,6 +1079,30 @@ int main(int argc, char *argv[]) {
 				CHAdeMOGunQty++;
 			}
 			else if(connectorType1 == 4){//AC
+		/* log for debug charginginfodata start*/
+//		#ifdef SystemLogMessage
+			WriteLogMsg("PresentChargingVoltage[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
+			WriteLogMsg("PresentChargingCurrent[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
+			WriteLogMsg("PresentChargingPower[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
+			WriteLogMsg("PresentChargedEnergy[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedEnergy);
+			WriteLogMsg("PresentChargedDuration[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedDuration);
+			WriteLogMsg("RemainChargingDuration[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].RemainChargingDuration);
+			WriteLogMsg("EvBatteryMaxVoltage[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatteryMaxVoltage);
+			WriteLogMsg("EvBatterytargetVoltage[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetVoltage);
+			WriteLogMsg("EvBatterySoc[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterySoc);
+			WriteLogMsg("SystemStatus[0]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].SystemStatus);
+			WriteLogMsg("Index[0]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Index);
+			WriteLogMsg("Type[0]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Type);
+			WriteLogMsg("type_index[0]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].type_index);
+			WriteLogMsg("EvBatterytargetCurrent[0]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetCurrent);
+			WriteLogMsg("CardNumber[0]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].CardNumber);
+			WriteLogMsg("StartUserId[0]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartUserId);
+			WriteLogMsg("StartDateTime[0]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartDateTime);
+			WriteLogMsg("StopDateTime[0]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StopDateTime);
+			WriteLogMsg("StartMethod[0]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartMethod);
+			WriteLogMsg("ConnectorTemp[0]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].ConnectorTemp);
+//		#endif
+		/* log for debug charginginfodata end*/
 				PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
 				PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
 				PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
@@ -1140,6 +1197,30 @@ int main(int argc, char *argv[]) {
 				CHAdeMOGunQty++;
 			}
 			else if(connectorType2 == 4){//AC
+		/* log for debug charginginfodata start*/
+//		#ifdef SystemLogMessage
+			WriteLogMsg("PresentChargingVoltage[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
+			WriteLogMsg("PresentChargingCurrent[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
+			WriteLogMsg("PresentChargingPower[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
+			WriteLogMsg("PresentChargedEnergy[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedEnergy);
+			WriteLogMsg("PresentChargedDuration[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedDuration);
+			WriteLogMsg("RemainChargingDuration[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].RemainChargingDuration);
+			WriteLogMsg("EvBatteryMaxVoltage[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatteryMaxVoltage);
+			WriteLogMsg("EvBatterytargetVoltage[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetVoltage);
+			WriteLogMsg("EvBatterySoc[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterySoc);
+			WriteLogMsg("SystemStatus[1]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].SystemStatus);
+			WriteLogMsg("Index[1]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Index);
+			WriteLogMsg("Type[1]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Type);
+			WriteLogMsg("type_index[1]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].type_index);
+			WriteLogMsg("EvBatterytargetCurrent[1]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetCurrent);
+			WriteLogMsg("CardNumber[1]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].CardNumber);
+			WriteLogMsg("StartUserId[1]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartUserId);
+			WriteLogMsg("StartDateTime[1]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartDateTime);
+			WriteLogMsg("StopDateTime[1]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StopDateTime);
+			WriteLogMsg("StartMethod[1]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartMethod);
+			WriteLogMsg("ConnectorTemp[1]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].ConnectorTemp);
+//		#endif
+		/* log for debug charginginfodata end*/
 				PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
 				PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
 				PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
@@ -1234,6 +1315,30 @@ int main(int argc, char *argv[]) {
 				CHAdeMOGunQty++;
 			}
 			else if(connectorType3 == 4){//AC
+		/* log for debug charginginfodata start*/
+//		#ifdef SystemLogMessage
+			WriteLogMsg("PresentChargingVoltage[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
+			WriteLogMsg("PresentChargingCurrent[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
+			WriteLogMsg("PresentChargingPower[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
+			WriteLogMsg("PresentChargedEnergy[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedEnergy);
+			WriteLogMsg("PresentChargedDuration[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedDuration);
+			WriteLogMsg("RemainChargingDuration[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].RemainChargingDuration);
+			WriteLogMsg("EvBatteryMaxVoltage[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatteryMaxVoltage);
+			WriteLogMsg("EvBatterytargetVoltage[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetVoltage);
+			WriteLogMsg("EvBatterySoc[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterySoc);
+			WriteLogMsg("SystemStatus[2]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].SystemStatus);
+			WriteLogMsg("Index[2]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Index);
+			WriteLogMsg("Type[2]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Type);
+			WriteLogMsg("type_index[2]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].type_index);
+			WriteLogMsg("EvBatterytargetCurrent[2]:%f",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetCurrent);
+			WriteLogMsg("CardNumber[2]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].CardNumber);
+			WriteLogMsg("StartUserId[2]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartUserId);
+			WriteLogMsg("StartDateTime[2]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartDateTime);
+			WriteLogMsg("StopDateTime[2]:%s",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StopDateTime);
+			WriteLogMsg("StartMethod[2]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].StartMethod);
+			WriteLogMsg("ConnectorTemp[2]:%d",ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].ConnectorTemp);
+//		#endif
+		/* log for debug charginginfodata end*/
 				PresentChargingVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
 				PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
 				PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
@@ -1302,7 +1407,6 @@ int main(int argc, char *argv[]) {
 		OcppServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL);
 		ChargeBoxId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
 
-
 		//system
 		json_object_object_add(jobj1,"ModelName",ModelName);
 		json_object_object_add(jobj1,"SerialNumber",SerialNumber);
@@ -1491,7 +1595,6 @@ int main(int argc, char *argv[]) {
 		json_object_object_add(jobj4,"ChargeBoxId",ChargeBoxId);
 		printf("%s\n", json_object_to_json_string(jobj4));
 		json_object_put(jobj4);
-
 	}
 	//	for(;;)
 	//	{

+ 9 - 4
EVSE/rootfs/var/www/head.php

@@ -5,11 +5,11 @@
 <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
 <?php
 	ini_set('error_reporting', E_ERROR | E_WARNING | E_PARSE);
-			if(file_exists("/Storage/settings")){
-				exec("cp /Storage/settings settings");
-			}
+	if(file_exists("/Storage/settings")){
+		exec("cp /Storage/settings settings");
+	}
 	$json = json_decode(file_get_contents("settings"), true);
-	
+
 	include 'valid.php';
 	$valid = new Valid;
 	//=======================================
@@ -36,6 +36,11 @@
 		echo "Something went wrong on machine";
 		exit;
 	}
+	if(trim($output[0])=="InitShareMemory Error"){
+		echo '<script>alert("InitShareMemory Error");</script>';
+		echo "InitShareMemory Error";
+		exit;
+	}
 	$model=json_decode(trim($output[0]))->{'ModelName'};
 	if(substr($model,0,1)=="A"){
 		if(substr($model,10,1)=="E" || substr($model,10,1)=="W" || substr($model,10,1)=="T" || substr($model,10,1)=="U"){