Browse Source

2020-01-09/Eason Yang
1.Change main.c Reason: added OCPP logic
2.Change main.h Reason: added variable for intercomm
3.Change Module_EventLogging.c Reason: fixed string
4.Change Module_InternalComm.c Reason: added gunplugtime and rotatory switch message
5.Change Module_InternalComm.h Reason: added gunplugtime command

8009 5 năm trước cách đây
mục cha
commit
dc00215006

+ 2 - 0
EVSE/Projects/AW-Regular/Apps/Module_AlarmDetect.c

@@ -608,6 +608,7 @@ int main(void)
 			//=====================================
 			// Current DC leak detection
 			//=====================================
+			/*
 			if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.InputAlarmCode & ALARM_CURRENT_LEAK_DC)
 			{
 				if(Alarm_Counter[gun_index].Dc_Leak > FILTER_SPEC)
@@ -634,6 +635,7 @@ int main(void)
 					DEBUG_INFO("ALARM_CURRENT_LEAK_DC : recover \r\n");
 				}
 			}
+			*/
 
 			//=====================================
 			// MCU self test fail detection

+ 3 - 3
EVSE/Projects/AW-Regular/Apps/Module_EventLogging.c

@@ -276,7 +276,7 @@ int main(void)
 						memcpy(EventCodeTmp,FaultStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
 						if(((tmp>>BitCount)&0x01)==0)//Recovered
 						{
-							EventCodeTmp[0]=1;
+							EventCodeTmp[0]='1';
 							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]&=~(1<<BitCount);
 						}
 						else
@@ -301,7 +301,7 @@ int main(void)
 						memcpy(EventCodeTmp,AlarmStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
 						if(((tmp>>BitCount)&0x01)==0)//Recovered
 						{
-							EventCodeTmp[0]=1;
+							EventCodeTmp[0]='1';
 							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]&=(0<<BitCount);
 						}
 						else
@@ -326,7 +326,7 @@ int main(void)
 						memcpy(EventCodeTmp,InfoStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
 						if(((tmp>>BitCount)&0x01)==0)//Recovered
 						{
-							EventCodeTmp[0]=1;
+							EventCodeTmp[0]='1';
 							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]&=(0<<BitCount);
 						}
 						else

+ 56 - 5
EVSE/Projects/AW-Regular/Apps/Module_InternalComm.c

@@ -198,7 +198,7 @@ int InitShareMemory()
 		result = FAIL;
 	}
 
-	//Initial ShmOcppModuleKey
+	//Initial ShmCharger
 	if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), IPC_CREAT | 0777)) < 0)
 	{
 		#ifdef SystemLogMessage
@@ -711,6 +711,7 @@ unsigned char Query_AC_MCU_Status(unsigned char fd, unsigned char targetAddr, Ac
 			Ret_Buf->meter_state = rx[16];
 			Ret_Buf->pp_state = rx[17];
 			Ret_Buf->rating_current = rx[18];
+			Ret_Buf->rotatory_switch = rx[19];
 
 			result = PASS;
 		}
@@ -1261,6 +1262,37 @@ unsigned char Config_AC_MCU_LEGACY_REQUEST(unsigned char fd, unsigned char targe
 	return result;
 }
 
+unsigned char Query_AC_GUN_PLUGIN_TIMES(unsigned char fd, unsigned char targetAddr, Gun_Plugin_Times *Ret_Buf)
+{
+	unsigned char result = FAIL;
+	unsigned char tx[7] = {0xaa, 0x00, targetAddr, CMD_CONFIG_GUN_PLUGIN_TIMES, 0x00, 0x00, 0x00};
+	unsigned char rx[512];
+	unsigned char chksum = 0x00;
+	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+
+	if(len > 0)
+	{
+		if(len < 6+(rx[4] | rx[5]<<8))
+			return result;
+
+		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
+		{
+			chksum ^= rx[6+idx];
+		}
+
+		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
+		   (rx[2] == tx[1]) &&
+		   (rx[1] == tx[2]) &&
+		   (rx[3] == tx[3]))
+		{
+			Ret_Buf-> GunPluginTimes = ((uint32_t)rx[6] | (((uint32_t)rx[7])<<8) | (((uint32_t)rx[8])<<16) | (((uint32_t)rx[9])<<24));
+			result = PASS;
+		}
+	}
+
+	return result;
+}
+
 unsigned char Config_AC_MaxCurrent_And_CpPwmDuty(unsigned char fd, unsigned char targetAddr, Ac_Primary_Mcu_Cp_Pwm_Duty*Set_Buf)
 {
 	unsigned char result = FAIL;
@@ -1526,7 +1558,7 @@ int main(void)
 				memcpy(ShmCharger->evseId.serial_number, ShmSysConfigAndInfo->SysConfig.SerialNumber, ARRAY_SIZE(ShmCharger->evseId.serial_number));
 				if(Config_Serial_Number(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->evseId))
 				{
-					DEBUG_INFO("MCU-%d set serial number OK...\r\n");
+					DEBUG_INFO("MCU-%d set serial number : %.12s\r\n",gun_index,ShmCharger->evseId.serial_number);
 					ShmCharger->gun_info[gun_index].mcuFlag.isSetSerialNumberPass = PASS;
 
 					failCount[gun_index] = 0;
@@ -1549,7 +1581,7 @@ int main(void)
 				memcpy(ShmCharger->evseId.model_name, ShmSysConfigAndInfo->SysConfig.ModelName, ARRAY_SIZE(ShmCharger->evseId.model_name));
 				if(Config_Model_Name(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->evseId))
 				{
-					DEBUG_INFO("MCU-%d set model name OK...\r\n");
+					DEBUG_INFO("MCU-%d set model name : %.14s\r\n",gun_index,ShmCharger->evseId.model_name);
 					ShmCharger->gun_info[gun_index].mcuFlag.isSetModelNamePass = PASS;
 
 					failCount[gun_index] = 0;
@@ -1601,6 +1633,25 @@ int main(void)
 					failCount[gun_index]++;
 			}
 
+			//===============================
+			// Query gun plug-in times
+			//===============================
+			if(Query_AC_GUN_PLUGIN_TIMES(Uart1Fd, (gun_index>0?ADDR_AC_PRIMARY_2:ADDR_AC_PRIMARY_1), &ShmCharger->gun_info[gun_index].gunPluginTimes) == PASS)
+			{
+				DEBUG_INFO("MCU-%d get gun plugin times : %.2f\r\n", gun_index, (float)ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes);
+
+				ShmSysConfigAndInfo->SysConfig.AcPlugInTimes = (float)ShmCharger->gun_info[gun_index].gunPluginTimes.GunPluginTimes;
+
+				failCount[gun_index] = 0;
+			}
+			else
+			{
+
+				DEBUG_WARN("MCU-%d get gun plugin times fail...%d\r\n", gun_index, failCount[gun_index]);
+				if(failCount[gun_index]<1000)
+					failCount[gun_index]++;
+			}
+
 			//===============================
 			// Query temperature
 			//===============================
@@ -1635,6 +1686,7 @@ int main(void)
 				DEBUG_INFO("MCU-%d get Meter State : %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.meter_state);
 				DEBUG_INFO("MCU-%d get PP State : %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.pp_state);
 				DEBUG_INFO("MCU-%d get Rating Current : %.2f\r\n", gun_index, (float)ShmCharger->gun_info[gun_index].primaryMcuState.rating_current);
+				DEBUG_INFO("MCU-%d get Rotatory switch : %d\r\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.rotatory_switch);
 
 				ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState = ShmCharger->gun_info[gun_index].primaryMcuState.cp_state;
 				ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotDuty = (ShmCharger->gun_info[gun_index].primaryMcuState.current_limit>51?(unsigned char)((ShmCharger->gun_info[gun_index].primaryMcuState.current_limit/2.5)+64):(unsigned char)(ShmCharger->gun_info[gun_index].primaryMcuState.current_limit/0.6));
@@ -1887,7 +1939,6 @@ int main(void)
 				tmMcu.tm_sec = ShmCharger->gun_info[gun_index].rtc.sec;
 				mcuTime.time = mktime(&tmMcu);
 
-
 				if(ShmCharger->gun_info[gun_index].bleConfigData.isLogin && !ShmOCPP16Data->OcppConnStatus)
 				{
 					if(abs(DiffTimeb(csuTime, mcuTime)) > 10000)
@@ -2043,7 +2094,7 @@ int main(void)
 				}
 			}
 		}
-		sleep(3);
+		usleep(100000);
 	}
 
 	return FAIL;

+ 2 - 1
EVSE/Projects/AW-Regular/Apps/Module_InternalComm.h

@@ -1,7 +1,7 @@
 /*
  * Module_InternalComm.h
  *
- *  Created on: 2019Ś~8¤ë28¤é
+ *  Created on: 2019?8?28?
  *      Author: USER
  */
 
@@ -44,6 +44,7 @@ enum MESSAGE_COMMAND
 	CMD_CONFIG_AC_LED = 0x88,
 	CMD_CONFIG_CURRENT_LINIT = 0x89,
 	CMD_CONFIG_MCU_MODE = 0x8A,
+	CMD_CONFIG_GUN_PLUGIN_TIMES = 0x2D,
 
 	CMD_UPDATE_START = 0xe0,
 	CMD_UPDATE_ABOARD = 0xe1,

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 461 - 355
EVSE/Projects/AW-Regular/Apps/main.c


+ 32 - 2
EVSE/Projects/AW-Regular/Apps/main.h

@@ -127,6 +127,21 @@
 #define LED_ACTION_DEBUG            	12
 #define LED_ACTION_ALL_OFF          	13
 
+#define START_METHOD_MANUAL 			0
+#define START_METHOD_RFID	 			1
+#define START_METHOD_BACKEND 			2
+#define START_METHOD_BLE	 			3
+
+#define AUTH_MODE_PH_RFID				0
+#define AUTH_MODE_OCPP					1
+#define AUTH_MODE_PH_BACKEND			2
+#define AUTH_MODE_FREEMODE				3
+
+#define OFF_POLICY_LOCALLIST			0
+#define OFF_POLICY_PH_RFID				1
+#define OFF_POLICY_FREEMODE				2
+#define OFF_POLICY_NOCHARGE				3
+
 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
@@ -245,14 +260,15 @@ typedef struct AC_PRIMARY_MCU
 {
 	unsigned char cp_state;
 	unsigned int  current_limit;
-	unsigned int  cp_voltage_positive;
-	unsigned int  cp_voltage_negtive;
+	float cp_voltage_positive;
+	float cp_voltage_negtive;
 	unsigned char locker_state;
 	unsigned char relay_state;
 	unsigned char shutter_state;
 	unsigned char meter_state;
 	unsigned char pp_state;
 	unsigned char rating_current;
+	unsigned char rotatory_switch;
 }Ac_Primary_Mcu;
 
 typedef struct AC_PRIMARY_MCU_ALARM
@@ -357,6 +373,18 @@ typedef struct FW_UPGRADE_INFO
 	char location[384];
 }Fw_Upgrade_Info;
 
+typedef struct GUN_PLUGIN_TIMES
+{
+	uint32_t GunPluginTimes;
+
+}Gun_Plugin_Times;
+
+typedef struct INTERNAL_SYSTEM_STATUS
+{
+	unsigned char SystemStatus;
+	unsigned char PreviousSystemStatus;
+}Internal_Sysyem_status;
+
 typedef struct GUN_INFO
 {
 	Ver 											ver;
@@ -376,6 +404,8 @@ typedef struct GUN_INFO
 	Ac_Primary_Mcu_Cp_Pwm_Duty						primaryMcuCp_Pwn_Duty;
 	Other_Alarm_Code								otherAlarmCode;
 	Pilot_Voltage									PilotVoltage;
+	Gun_Plugin_Times								gunPluginTimes;
+	Internal_Sysyem_status							internalSystemStatus;
 }Gun_Info;
 
 struct Charger

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác