zhunk 9 месяцев назад
Родитель
Сommit
855590ff44

+ 10 - 6
Application_CBD/applications/control.c

@@ -1474,7 +1474,7 @@ void calorstat(uint16_t heat_time)
     uint16_t delay_heat = 60;
     FlagStatus heat_flg = RESET;
     device_status.heat_time_min = 0;
-    device_status.run_sta = device_status.heattem;      //初始化加热实时温度
+    device_status.heat_tem_max = device_status.heattem;      //初始化加热实时温度
     ctr_Heat(ON);
 //    UpLoad_Data();      //开始加热时的第一条数据
     //恒温模式
@@ -1490,8 +1490,8 @@ void calorstat(uint16_t heat_time)
                 rt_kprintf("正在恒温加热!!!:%d",delay_heat);
                 HMI_WRITE("workSta.g0.txt=\"正在恒温加热!!!:%d\"",delay_heat);
                 rt_thread_delay(1000);
-                if(device_status.heattem>device_status.run_sta + 1){
-                    device_status.run_sta = device_status.heattem;
+                if(device_status.heattem>device_status.heat_tem_max + 1){
+                    device_status.heat_tem_max = device_status.heattem;
                 }
                 //如果触发异常退出加热
                 if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
@@ -1512,7 +1512,7 @@ void calorstat(uint16_t heat_time)
         }
         if(device_status.heattem < (device_status.heatvalue - 5)&&heat_flg == SET)
         {
-            device_status.run_sta = device_status.heattem;
+            device_status.heat_tem_max = device_status.heattem;
             ctr_Heat(ON);
         }
         else if (device_status.heattem>=device_status.heatvalue&&heat_flg==SET)
@@ -1522,7 +1522,7 @@ void calorstat(uint16_t heat_time)
 //                UpLoad_Data();      //加热到设定温度的数据
 //                heat_up_cnt = 1;
 //            }
-            device_status.run_sta = device_status.heattem;
+            device_status.heat_tem_max = device_status.heattem;
             ctr_Heat(OFF);
         }
         if((n % 60)==0)
@@ -1733,7 +1733,7 @@ void ResetInit(void)
            }else{
                device_status.run_sta = 112;     //收虫
            }
-            #endif
+           #endif
     }
     else {
         if(device_status.power_status==1)
@@ -2717,6 +2717,10 @@ static void Control_Clear_thread_entry(void *parameter)
             ///if(ctr_clear(1200)==0)
             ctr_TG_Clear(500);  //2025-1021,由400修改为500,解决金朵推杆慢导致行程走不完
         }
+        if(device_status.clear_status==2){
+            turnzp();
+            device_status.clear_status=0;
+        }
         rt_thread_delay(100);
         #endif
         #endif

+ 5 - 4
Application_CBD/applications/control.h

@@ -26,12 +26,12 @@
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led0.40(2000W)"       //水稻
 #else
-    #define VERSION_HK          "1.61.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "1.61.40(2000W)"         //4.0水稻
+    #define VERSION_HK          "1.63.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.63.40(2000W)"         //4.0水稻
 #endif
 
-#define VERSION_ZP          "1.61.1(ZP)"            //1.0转盘
-#define VERSION_GK          "1.61.1(GK)"            //1.0高空
+#define VERSION_ZP          "1.63.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.63.1(GK)"            //1.0高空
 
 #define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
 #define VERSION_Robot       "1.0(robot)"            //展厅机器人
@@ -48,6 +48,7 @@ typedef struct  _packed
     uint8_t dtype;           //设备类型?7-孢子仪,3-测报灯
     /*孢子仪*/
     uint8_t run_sta;              //转盘的位置:0原始;1收集;2培养;3拍照;4凡士林,其他-测试
+    uint8_t heat_tem_max;         //恒温加热达到的最大温度
     uint8_t cul_time;             //培养时间
     uint8_t stay_time;            //已培养时间
     uint8_t pre_temp;             //培养仓温度

+ 16 - 3
Application_CBD/applications/dtu_uart2.c

@@ -878,10 +878,10 @@ char * makeJson()
         rt_sprintf(utos, "%d",device_status.down_status);
         cJSON_AddStringToObject(pSubJson,"dnds",utos);
         //加热仓温度
-        if(device_status.run_sta>device_status.heattem)
+        if(device_status.heat_tem_max>device_status.heattem)
         {
-            rt_sprintf(utos, "%d",device_status.run_sta);
-            device_status.run_sta = 0;
+            rt_sprintf(utos, "%d",device_status.heat_tem_max);
+            device_status.heat_tem_max = 0;
         }
         else {
             rt_sprintf(utos, "%d",device_status.heattem);
@@ -1120,6 +1120,7 @@ int parseDtu(char *json_string)
     cJSON* JSONRPC = NULL;
     cJSON* METHOD = NULL;
     cJSON* PARAMS = NULL;
+    cJSON* RESULT = NULL;
     LOG_D("parse:%s\n",json_string);
     cJSON *root = cJSON_Parse(json_string);
     if(!root)
@@ -1133,6 +1134,7 @@ int parseDtu(char *json_string)
           JSONRPC = cJSON_GetObjectItem(root,"jsonrpc");
           METHOD = cJSON_GetObjectItem(root,"method");
           PARAMS = cJSON_GetObjectItem(root,"params");
+          RESULT = cJSON_GetObjectItem(root,"result");
           if (JSONRPC != NULL && METHOD != NULL && METHOD->type == cJSON_String) {
               // 使用 strcmp 比较字符串
               if (strcmp(METHOD->valuestring, "upgradehmi") == 0) {
@@ -1161,6 +1163,17 @@ int parseDtu(char *json_string)
               }
 
           }
+          if(JSONRPC!=NULL){
+                if(RESULT!=NULL&&RESULT->type==cJSON_String)
+                {
+                    if(strcmp(RESULT->valuestring,"success")==0){
+                        if(device_status.C01==100){
+                            device_status.C01 = 0;
+                            Stop_timer_Uart2();
+                        }
+                    }
+                }
+          }
           item_cmd = cJSON_GetObjectItem(root,"cmd");
           item_checkself = cJSON_GetObjectItem(root,"selfcheck");
           photolink = cJSON_GetObjectItem(root,"photolink");

+ 31 - 80
Application_CBD/applications/hmi.c

@@ -45,6 +45,8 @@ static char msg_pool[512];
 
 static char rx_buffer[HMI_UART_RXBUFFER_SIZE + 1];
 
+static rt_bool_t uart2_timeout_flag = RT_FALSE;
+
 void list_mem(void);
 int mb_master_samlpe();
 /**/
@@ -260,84 +262,7 @@ void process_hex_payload(const char* hex_str, int req_id) {
 
     DTU_Write(progress_json);
 }
-#if 0
-// 处理HEX数据包
-void process_hex_payload(const char* hex_str, int req_id)
-{
-    if (!hex_str) return;
-    uint8_t binary_data[JSON_CHUNK_SIZE];
-    int data_len = fast_hex_to_bin(hex_str, binary_data, JSON_CHUNK_SIZE);
-
-    if (data_len <= 0) {
-        LOG_E("HEX转换失败\n");
-        return;
-    }
-
-    // 检查缓冲区是否足够
-    if (recv_write_pos + data_len > RECV_BUFFER_SIZE) {
-        LOG_E("接收缓冲区已满\n");
-        return;
-    }
-
-    // 复制到接收缓冲区
-    memcpy(recv_buffer + recv_write_pos, binary_data, data_len);
-    recv_write_pos += data_len;
-    bytes_received += data_len;
-
-    rt_kprintf("收到数据: %d字节, 累计: %d/%d\n",
-               data_len, bytes_received, total_file_size);
-
-    uint32_t available = recv_write_pos - recv_read_pos;
-    while (available >= 4096) {
-            // 发送4096字节到HMI
-            if (send_raw_to_hmi(recv_buffer + recv_read_pos, 4096) != 0) {
-                LOG_E("发送到HMI失败");
-                return;
-            }
-
-            // 更新读取位置
-            recv_read_pos += 4096;
-            available -= 4096;
-
-            LOG_I("已发送 4096 字节,缓冲剩余: %d 字节", available);
-            return;
-    }
-
-    // 3. 如果缓冲区有剩余数据,且所有数据已接收完成
-        if (bytes_received >= total_file_size && total_file_size > 0 && available > 0) {
-            // 发送剩余数据
-            if (send_raw_to_hmi(recv_buffer + recv_read_pos, available) != 0) {
-                LOG_E("发送最后一包失败");
-                return;
-            }
-
-            LOG_I("发送最后一包: %d 字节,升级完成!", available);
-
-            // 重置缓冲区
-            recv_read_pos = 0;
-            recv_write_pos = 0;
 
-            // 发送完成通知
-            char complete_json[256];
-            rt_snprintf(complete_json, sizeof(complete_json),
-                       "{\"jsonrpc\":\"2.0\",\"method\":\"upgrade_complete\","
-                       "\"params\":{\"total\":%d},\"id\":%d}",
-                       total_file_size, req_id);
-
-            DTU_Write(complete_json);
-            return;
-        }
-    // 发送进度响应
-    int progress = total_file_size > 0 ? (bytes_received * 100 / total_file_size) : 0;
-    char progress_json[256];
-    rt_snprintf(progress_json, sizeof(progress_json),
-               "{\"jsonrpc\":\"2.0\",\"method\":\"upgradehmi\","
-               "\"params\":{\"received\":%d,\"total\":%d,\"progress\":%d},\"id\":%d}",
-               bytes_received, total_file_size, progress, req_id);
-
-    DTU_Write(progress_json);
-}
-#endif
 
 /*入口函数*/
 static void Hmi_thread_entry(void *parameter)
@@ -387,6 +312,7 @@ static void t_uart2_callback(void *parameter)
 {
     HMI_WRITE("sysSet.va0.txt=\"指令超时,请重试...\"");
     LOG_I("t_uart2_callback");
+    uart2_timeout_flag = RT_TRUE;
 }
 
 void Start_timer_Uart2(void)
@@ -402,6 +328,19 @@ void Start_timer_Uart2(void)
 
 }
 
+void Stop_timer_Uart2(void)
+{
+
+    if(timer_uart2!=RT_NULL){
+        rt_timer_stop(timer_uart2);
+    }
+    else
+    {
+        LOG_E("timer_uart2 stop Failed!");
+    }
+
+}
+
 /***************************** 解析从屏幕收到的数据 begin **********************************/
 static void HMI_Decode(void)
 {
@@ -1714,10 +1653,23 @@ static void Ctr_Mortor_entry(void* parameter)
         time(&time_reset12V);
         static struct tm alarm_reset12V;
         alarm_reset12V =*localtime(&time_reset12V);
-        if((alarm_reset12V.tm_hour)==8&&(alarm_reset12V.tm_min==19)&&(alarm_reset12V.tm_sec==50))
+        if((alarm_reset12V.tm_hour)==8&&(alarm_reset12V.tm_min==18)&&(alarm_reset12V.tm_sec==00))
+        {
+            char *rep = makeJsonRpc2_0("reboot",NULL, 1);
+            if(rep){
+                device_status.C01 = 100;
+                DTU_Write(rep);
+                //启动超时定时器
+                Start_timer_Uart2();
+                free(rep);
+            }
+            rt_thread_delay(1000);
+        }
+        if(uart2_timeout_flag==RT_TRUE)
         {
+            uart2_timeout_flag = RT_FALSE;
             ctr_RTU_DTU(OFF);
-            rt_thread_delay(1000*10);
+            rt_thread_delay(1000*30);
             ctr_RTU_DTU(ON);
         }
         #endif
@@ -1946,7 +1898,6 @@ static void Ctr_Mortor_entry(void* parameter)
                 device_status.run_sta=0;
             }
         }
-
         //一键测试
         if(device_status.auto_test_sw==1)
         {

+ 1 - 0
Application_CBD/applications/hmi.h

@@ -94,4 +94,5 @@ void Debug_log_ON(void);
 void bubblesort(int a[], int n);
 
 int delete_hmi_thread(void);
+void Stop_timer_Uart2(void);
 #endif /* APPLICATIONS_INC_HMI_H_ */

+ 1 - 1
Application_CBD/applications/main.c

@@ -120,7 +120,7 @@ static void idle_hook(void)
     if((alarm_new.tm_hour)==8&&(alarm_new.tm_min==00)&&(alarm_new.tm_sec==0))
     {
         if (device_status.version_type==1) {
-            turnzp();  //2024-03-21 :开机不再转仓
+            device_status.clear_status=2 ;  //2024-03-21 :开机不再转仓
         }
     }
     if((alarm_new.tm_hour)==8&&(alarm_new.tm_min==20)&&(alarm_new.tm_sec==0))

+ 15 - 1
Application_CBD/readme.md

@@ -1,5 +1,19 @@
+# 2026-01-29 更新说明
+	#define VERSION_HK          "1.63.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.63.40(2000W)"         //4.0水稻
+	#define VERSION_ZP          "1.63.1(ZP)"            //1.0转盘
+	#define VERSION_GK          "1.63.1(GK)"            //1.0高空
+	1. 修复恒温加热和北大荒测报灯的收虫模式运行使用同一变量导致收虫仓运行异常;
+
+# 2026-01-23 更新说明
+	#define VERSION_HK          "1.62.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.62.40(2000W)"         //4.0水稻
+	#define VERSION_ZP          "1.62.1(ZP)"            //1.0转盘
+	#define VERSION_GK          "1.62.1(GK)"            //1.0高空
+	1. 定时重启RTU时间修改为8:18,触发方式调整为软重启,RTU无响应时执行硬重启,硬重启时间由10S改为30S;
+	2. 在空闲钩子函数中执行转仓取消,改为修改标志位触发;
 # 2025-12-08 更新说明
-#define VERSION_HK          "1.61.41(HK)"            //4.0海康-1200W
+	#define VERSION_HK          "1.61.41(HK)"            //4.0海康-1200W
     #define VERSION_HK_2000W    "1.61.40(2000W)"         //4.0水稻
 	#define VERSION_ZP          "1.61.1(ZP)"            //1.0转盘
 	#define VERSION_GK          "1.61.1(GK)"            //1.0高空