From: QQY <979527038@qq.com> Date: Wed, 15 Nov 2023 08:30:27 +0000 (+0800) Subject: 局放支持热插拔 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=edbca3246e092608231741e3d5b6b454cc9cec59;p=zd%2Fzd-mcu.git 局放支持热插拔 --- diff --git a/STM32/code/mcu_com/mcu_com.h b/STM32/code/mcu_com/mcu_com.h index ead8def8..373f386b 100644 --- a/STM32/code/mcu_com/mcu_com.h +++ b/STM32/code/mcu_com/mcu_com.h @@ -242,5 +242,5 @@ void Mqtt_send_modbus(uint8_t type, uint8_t sun_type, uint8_t *data, uint8_t Dat void send_mcuSoftWare_Version(void); void Mqtt_Proactive_Escalation_battery(void); void Mqtt_Proactive_Escalation(void); - +void McuCom_Sensor_Send_State(uint8_t cmd_type); #endif diff --git a/STM32/code/new_sensor/partial_discharge.c b/STM32/code/new_sensor/partial_discharge.c index a5888bd4..6fcbc920 100644 --- a/STM32/code/new_sensor/partial_discharge.c +++ b/STM32/code/new_sensor/partial_discharge.c @@ -45,11 +45,8 @@ Partial_Discharge_Cmd_Contr_t Partial_Discharge_Cmd_Contr; uint8_t rec_buf[256]={0}; extern BYTE AppLora_JuFang_Flag; extern short jufangdata; -// uint8_t tev_buf[ATLAS_MAX_LEN]; -// uint8_t ult_buf[ATLAS_MAX_LEN]; uint8_t Cmd_Discharge[20]={0}; -// uint8_t tev_buf[24][256]={0}; -// uint8_t ult_buf[24][255]={0}; + static DWORD Partial_Discharge_Time = 0; /*************************************************************************** | Function Source Code |**************************************************************************/ @@ -168,43 +165,6 @@ void Partial_Discharge_Get_Alarm_Data(Partial_Discharge_Alarm_Data_t *data) Partial_Discharge_Alarm.data.updata=false; } } -///*************************************************************************** -//** Function name: Partial_Discharge_Get_Atlase_Data -//** Descriptions: »ñȡͼÆ× -//** input parameters: Partial_Discharge_Atlas.tev_data.data£¬Partial_Discharge_Atlas.tev_data.len -//** output parameters: data£ºÊý¾Ý£¬len£ºÊý¾Ý³¤¶È -//** Returned value: null -//***************************************************************************/ -//void Partial_Discharge_Get_Atlase_Data(Partial_Discharge_Subtype_E type, uint8_t*data,uint8_t *len) -//{ -// switch(type) -// { -// int i; -// case TEV_TYPE://µØµç²¨Í¼Æ× -// if(Partial_Discharge_Contr.updata.atlas_tev==true) -// { -// data=tev_buf; -// *len=Partial_Discharge_Atlas.tev_data.len; -// for(i=1;iPartial_Discharge_Atlas.cmd_ctrl.tev_send_num) -// { -// Partial_Discharge_Atlas.tev_finish=true; -// } -// break; -// -// case ULT_TYPE://³¬Éù²¨ -// if(Partial_Discharge_Atlas.cmd_ctrl.cur_ult_send_numPartial_Discharge_Atlas.cmd_ctrl.ult_send_num) -// { -// Partial_Discharge_Atlas.ult_finish=true; -// } -// break; -// } -// Partial_Discharge_Atlas_Cmd_Packet(type); -// -//} -///*************************************************************************** -//** Function name: Partial_Discharge_Atlas_Send_Contr -//** Descriptions: ¼ì²âͼÆ×״̬ -//** input parameters: atlas_process£ºÍ¼Æ×¼ì²â״̬ -//** output parameters: null -//** Returned value: null -//***************************************************************************/ -//void Partial_Discharge_Atlas_Send_Contr(void ) -//{ -// switch(Partial_Discharge_Atlas.atlas_process) -// { -// //³õʼ»¯Ê±ÅжϽøÈëÄĸöͼÆ×µÄ¼ì²â -// case ATLAS_INIT: -// if(Partial_Discharge_Atlas.tev_enable==true) -// { -// Partial_Discharge_Atlas.atlas_process=ATLAS_TEV_TEST;//µØµç²¨Í¼Æ× -// } -// else -// { -// Partial_Discharge_Atlas.atlas_process=ATLAS_ULT_TEST;//³¬Éù²¨Í¼Æ× -// } -// break; -// //ͼÆ×ÕýÔÚ¼ì²â£¬½«×´Ì¬ÖÃΪµÈ´ýÍê³É£¬²¢ÇÒ·¢Ë͵±Ç°ÃüÁî -// case ATLAS_TEV_TEST: -// Partial_Discharge_Atlas.atlas_process=ATLAS_TEV_TEST_WAIT_FINISH; -// Partial_Discharge_Atlas_Send_Cmd(TEV_TYPE); -// Partial_Discharge_Atlas.cmd_ctrl.cmd_type=TEV_TYPE; -// break; -// //µÈ´ýÍê³É£¬Åжϵ±Ç°Í¼Æ×ÊÇ·ñÍê³É£¬Ã»ÓÐÍê³É¼ÌÐø·¢ËÍÃüÁÈç¹ûÍê³ÉÅжÏÁíÍâÒ»¸öÊÇ·ñʹÄÜ£¬ÊÇ·ñ½øÈëϸöͼÆ× -// case ATLAS_TEV_TEST_WAIT_FINISH: -// if(Partial_Discharge_Atlas.tev_finish==true) -// { -// Partial_Discharge_Atlas.tev_finish=false; -// -// if(Partial_Discharge_Atlas.ult_enable==true) -// { -// Partial_Discharge_Atlas.atlas_process=ATLAS_ULT_TEST; -// } -// else -// { -// Partial_Discharge_Atlas.atlas_process=ATLAS_TEV_TEST; -// } -// } -// else -// { -// Partial_Discharge_Atlas_Send_Cmd(TEV_TYPE); -// Partial_Discharge_Atlas.cmd_ctrl.cmd_type=TEV_TYPE; -// } -// break; -// case ATLAS_ULT_TEST: -// Partial_Discharge_Atlas.atlas_process=ATLAS_TEV_TEST_WAIT_FINISH; -// Partial_Discharge_Atlas_Send_Cmd(ULT_TYPE); -// Partial_Discharge_Atlas.cmd_ctrl.cmd_type=ULT_TYPE; -// break; -// case ATLAS_ULT_TEST_WAIT_FINISH: -// if(Partial_Discharge_Atlas.ult_finish==true) -// { -// Partial_Discharge_Atlas.atlas_process=ATLAS_INIT; -// // Partial_Discharge_Atlas.ult_enable=false; -// //Partial_Discharge_Atlas.ult_finish=false; -// } -// else -// { -// Partial_Discharge_Atlas_Send_Cmd(ULT_TYPE); -// Partial_Discharge_Atlas.cmd_ctrl.cmd_type=ULT_TYPE; -// } -// break; -// } -//} /*************************************************************************** ** Function name: Partial_Discharge_Cmd ** Descriptions: ·¢ËÍÃüÁî @@ -506,7 +270,6 @@ void Partical_Discharge_Alarm_Analyse(Partial_Discharge_Alarm_Recive_Data* alarm Partial_Discharge_Alarm.data.updata=true; Md_RegisterData.State_Register2 |=(1<<11); Partial_Discharge_Sensor.data.alarm=0x01; - // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ break; case ULT_ALARM://³¬Éù²¨±¨¾¯ @@ -514,8 +277,7 @@ void Partical_Discharge_Alarm_Analyse(Partial_Discharge_Alarm_Recive_Data* alarm Partial_Discharge_Atlas.ult_enable=true; Partial_Discharge_Alarm.data.updata=true; Md_RegisterData.State_Register2 |=(1<<10); - Partial_Discharge_Sensor.data.alarm=0x02; - // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ + Partial_Discharge_Sensor.data.alarm=0x02; break; case UNION_ARAM://ÁªºÏ±¨¾¯ @@ -524,7 +286,6 @@ void Partical_Discharge_Alarm_Analyse(Partial_Discharge_Alarm_Recive_Data* alarm Partial_Discharge_Atlas.ult_enable=true; Partial_Discharge_Alarm.data.updata=true; Partial_Discharge_Sensor.data.alarm=0x03; - // Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_SENSOR;//¾Ö·½Êý¾Ý״̬ break; default: break; @@ -545,8 +306,8 @@ void Partical_Discharge_Sensor_Analyse(Partial_Discharge_Sensor_Recive_Data *da uint16_t crc16=0; crc16=ModBusCRC16((uint8_t*)data,sizeof(Partial_Discharge_Sensor_Recive_Data)-sizeof(crc16)); if(crc16==data->crc16) - { - //Partial_Discharge_Atlas.atlas_process=ATLAS_INIT; + { + Partial_Discharge_Time = HAL_GetTick(); Partial_Discharge_Sensor.data.tev_data = data->tev;//µØµç²¨Êý¾Ý Partial_Discharge_Sensor.data.ult_data = data->ult;//³¬Éù²¨Êý¾Ý @@ -556,77 +317,6 @@ void Partical_Discharge_Sensor_Analyse(Partial_Discharge_Sensor_Recive_Data *da jufangdata = big_to_littles_uint16(data->tev.tev_peak); AppLora_JuFang_Flag = 1; } - -///*************************************************************************** -//** Function name: AtlasData_Copy_Buf -//** Descriptions: ½«Í¼Æ×Êý¾Ý´æÈëÈ«¾ÖÊý×é -//** input parameters: buf£ºÄ¿±êÊý×é data£ºÔ´Êý×é len£»×ª´æ³¤¶È -//** output parameters: p -//** Returned value: null -//***************************************************************************/ -//void AtlasData_Copy_Buf(uint8_t* buf,uint8_t* data,uint8_t len) -//{ -// static uint16_t count=0; -// uint8_t *p=buf; -// count=(Partial_Discharge_Atlas.cmd_ctrl.cur_tev_send_num-1)*READ_RECODE_LEN_MAX*2; -// memcpy(p+count,data,len); -//} - -///*************************************************************************** -//** Function name: Partical_Discharge_Atlas_Analyse -//** Descriptions: ͼÆ×½âÎö -//** input parameters: data£ºÍ¼Æ×Êý¾Ý -//** output parameters: Partial_Discharge_Atlas.tev_finish£º·¢ËÍÍê³É±êÖ¾ -//** Returned value: null -//***************************************************************************/ -//void Partical_Discharge_Atlas_Analyse(uint8_t *data) -//{ -// uint8_t *p,len=0; -// uint16_t crc16,pack_crc16; -// Partial_Discharge_Atlas_Receive_PackHead packHead; -// Partial_Discharge_Atlas_Receive_PackHead *head; -// p=data; -// head=(Partial_Discharge_Atlas_Receive_PackHead*)data; -// //Êý¾Ý°ü³¤¶È -// len=head->responce_len+sizeof(packHead); -// crc16=ModBusCRC16(data,len-sizeof(crc16)); -// pack_crc16=*(p+len-2)+(*(p+len-1)<<8); -// if(pack_crc16==crc16) -// { -// switch(Partial_Discharge_Atlas.cmd_ctrl.cmd_type) -// { -// case TEV_TYPE://µØµç²¨Í¼Æ× -// memcpy(Partial_Discharge_Atlas.tev_data.data,p+sizeof(packHead),head->file_len-1); -// Partial_Discharge_Atlas.tev_data.len=head->file_len-1; -// Partial_Discharge_Atlas.cmd_ctrl.tev_record_need_len-=READ_RECODE_LEN_MAX; -// AtlasData_Copy_Buf(tev_buf,Partial_Discharge_Atlas.tev_data.data,Partial_Discharge_Atlas.tev_data.len); -// -// //½âÎö´ÎÊýÍê³É£¬¸üÐÂ״̬ -// if(Partial_Discharge_Atlas.cmd_ctrl.cur_tev_send_num>=Partial_Discharge_Atlas.cmd_ctrl.tev_send_num) -// { -// Partial_Discharge_Contr.updata.atlas_tev=true;//µØµç²¨Êý¾Ý¸üР-// Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_ALARM;//¾Ö·½±¨¾¯ -// memset(rec_buf,0,sizeof(rec_buf)); -// } -// break; -// -// case ULT_TYPE://³¬Éù²¨Í¼Æ× -// memcpy(Partial_Discharge_Atlas.ult_data.data,p+sizeof(packHead),head->file_len-1); -// Partial_Discharge_Atlas.ult_data.len=head->file_len-1; -// -// Partial_Discharge_Atlas.cmd_ctrl.tev_record_need_len-=READ_RECODE_LEN_MAX; -// AtlasData_Copy_Buf(ult_buf,Partial_Discharge_Atlas.ult_data.data,Partial_Discharge_Atlas.ult_data.len); -// if(Partial_Discharge_Atlas.cmd_ctrl.cur_ult_send_num>=Partial_Discharge_Atlas.cmd_ctrl.ult_send_num) -// { -// Partial_Discharge_Contr.updata.atlas_ult=true;//³¬Éù²¨Êý¾Ý¸üР-// Partial_Discharge_Contr.cmd_state=PARTICAL_DISCHARGE_ALARM;//¾Ö·½±¨¾¯ -// memset(rec_buf,0,sizeof(rec_buf)); -// } -// break; -// } -// } -//} - /*************************************************************************** ** Function name: Partial_Discharge_Self_Test_Receive ** Descriptions: ¾Ö·½½ÓÊÜ×Ô¼ì @@ -698,6 +388,31 @@ void Partial_Discharge_Receive_Analyse(void) } } /*************************************************************************** +** Function name: Partial_Discharge_Link_Check +** Descriptions: ¼ì²é¾Ö·ÅÁ¬½Ó +** input parameters: null +** output parameters: null +** Returned value: null +***************************************************************************/ +static void Partial_Discharge_Link_Check(void) +{ + DWORD now; + + now = HAL_GetTick(); + if((now - Partial_Discharge_Time) > 60 *1000) + {//Èç¹û¾Ö·ÅÒ»·ÖÖÓδÊÕµ½Êý¾Ý£¬ÏÔʾ¹ÊÕÏ + Mcu_to_Arm_state.sensor_state |=(1<<1); + Md_RegisterData.State_Register2 |=(1<<0); + Partial_Discharge_Contr.state = PARTICAL_DISCHARGE_SELF_TEST;//×Ô¼ì״̬ + Partial_Discharge_Sensor.arm_config.self_test_state = false;//×Ô¼ìʧ°Ü + PARTICAL_DISCHARGE_Self_test_Process(); + } else + { + return; + } + +} +/*************************************************************************** ** Function name: Partial_Discharge_Receive ** Descriptions: ½ÓÊÕ ** input parameters: null @@ -707,8 +422,9 @@ void Partial_Discharge_Receive_Analyse(void) void Partial_Discharge_Receive(void) { - WkReadSFifo(PARITIAL_CHARGE_PORT4,rec_buf, sizeof(rec_buf)); + WkReadSFifo(PARITIAL_CHARGE_PORT4, rec_buf, sizeof(rec_buf)); Partial_Discharge_Receive_Analyse(); + Partial_Discharge_Link_Check(); } /*************************************************************************** @@ -720,7 +436,7 @@ void Partial_Discharge_Receive(void) ***************************************************************************/ void Partial_Discharge_Set_Enable(uint8_t value) { - Partial_Discharge_Contr.enable =value; + Partial_Discharge_Contr.enable = value; } /*************************************************************************** @@ -787,6 +503,8 @@ void PARTICAL_DISCHARGE_Self_test_Process(void) case PARTICAL_DISCHARGE_CHECK_SELF_END://×Ô¼ì½áÊø Mcu_to_Arm_state.sensor_state |=(1<<1); Md_RegisterData.State_Register2 |=(1<<0); + + Partial_Discharge_Contr.test_state = PARTICAL_DISCHARGE_START_SELS_TEST;//¿ªÊ¼×Ô¼ì break; } } @@ -800,7 +518,7 @@ void PARTICAL_DISCHARGE_Self_test_Process(void) ***************************************************************************/ void Task_Partial_Discharge(void) { - static DWORD last_split_eng_tim = 0; + static DWORD last_split_eng_tim = 0; DWORD now; now = HAL_GetTick(); if ((DWORD)(now - last_split_eng_tim) > 1000) diff --git a/STM32/code/new_sensor/partial_discharge.h b/STM32/code/new_sensor/partial_discharge.h index 54c4cf06..7314d241 100644 --- a/STM32/code/new_sensor/partial_discharge.h +++ b/STM32/code/new_sensor/partial_discharge.h @@ -349,6 +349,7 @@ extern Partial_Discharge_Sensor_t Partial_Discharge_Sensor; //Êä³ö½Ó¿Ú void Partial_Discharge_Init(void); void Task_Partial_Discharge(void); +void PARTICAL_DISCHARGE_Self_test_Process(void); void Partial_Discharge_Set_Enable(uint8_t value); void Partial_Discharge_Get_Updata(Partial_Discharge_Updata_t *updata); void Partial_Discharge_Get_Alarm_Data(Partial_Discharge_Alarm_Data_t *data); diff --git a/STM32/code/new_sensor/wireless_temp.c b/STM32/code/new_sensor/wireless_temp.c index ceffaace..4bcf2def 100644 --- a/STM32/code/new_sensor/wireless_temp.c +++ b/STM32/code/new_sensor/wireless_temp.c @@ -210,6 +210,7 @@ static void Wireless_Temp_Check_Link(void) { DWORD now; BOOL flag = false; + int num = 0; now = HAL_GetTick(); @@ -217,8 +218,8 @@ static void Wireless_Temp_Check_Link(void) { if((DWORD)(now - Wireless_Temp_Time[i]) > 300*1000) { -// printf("enter Wireless_Temp_Check_Link failed\r\n"); flag = true; + num ++; Wireless_Temp_Info.data.temp[i] = 0; Wireless_Temp_Info.data.state[i] = false; if(i < 16){Md_RegisterData.WirelessTemp_State[0]&=~(1<