|
@@ -293,6 +293,7 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
device_status.collt_box_sta = 0;
|
|
device_status.collt_box_sta = 0;
|
|
|
device_status.run_sta = 0;
|
|
device_status.run_sta = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ device_status.upan_sta = 1;
|
|
|
device_status.camsta = 1;
|
|
device_status.camsta = 1;
|
|
|
while(1)
|
|
while(1)
|
|
|
{
|
|
{
|
|
@@ -357,11 +358,168 @@ void Stop_timer_Uart2(void)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void refresh_hmi_Component(struct tm tm)
|
|
|
|
|
+{
|
|
|
|
|
+ char *readinfo = makeJson_ReadInfo();
|
|
|
|
|
+ if(device_status.refresh_num==5)
|
|
|
|
|
+ {
|
|
|
|
|
+ device_status.refresh_num = 15;
|
|
|
|
|
+ DTU_Write("%s",readinfo);
|
|
|
|
|
+ //list_mem();
|
|
|
|
|
+ device_status.hmi_fresh = 1;
|
|
|
|
|
+ rt_thread_delay(100);
|
|
|
|
|
+ }
|
|
|
|
|
+ //在解析getinfo中清除超时
|
|
|
|
|
+ if(device_status.refresh_timeout==30)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_sprintf(device_status.sim,"1");
|
|
|
|
|
+ rt_sprintf(device_status.net,"1");
|
|
|
|
|
+ rt_sprintf(device_status.csq,"0");
|
|
|
|
|
+ device_status.upan_sta = 1;
|
|
|
|
|
+ device_status.camsta = 1;
|
|
|
|
|
+ device_status.link_sta=0;
|
|
|
|
|
+ device_status.refresh_timeout=0;
|
|
|
|
|
+ }
|
|
|
|
|
+ rt_free(readinfo);
|
|
|
|
|
+ device_status.refresh_num--;
|
|
|
|
|
+ device_status.refresh_timeout++;
|
|
|
|
|
+ if(device_status.version_type!=6)
|
|
|
|
|
+ {
|
|
|
|
|
+ HMI_WRITE("uploadSet.iccid.txt=\"%s\"",device_status.iccid);
|
|
|
|
|
+ if(strstr(device_status.mqttcfg1,"8.136.98.49")!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ HMI_WRITE("uploadSet.plt.val=%d",RESET);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(device_status.mqttcfg1,"120.27.222.26")!=NULL) {
|
|
|
|
|
+ HMI_WRITE("uploadSet.plt.val=%d",SET);
|
|
|
|
|
+ }
|
|
|
|
|
+ //HMI_WRITE("mqttcfg.mqtt1Message.txt=\"%s\"",device_status.mqttcfg1);
|
|
|
|
|
+ HMI_WRITE("uploadSet.t0.txt=\"%s\"",device_status.mqttcfg1);
|
|
|
|
|
+
|
|
|
|
|
+ //更新固件版本号
|
|
|
|
|
+ HMI_WRITE("debug.t3.txt=\"%s\"",device_status.driver);
|
|
|
|
|
+ //更新固件编译日期
|
|
|
|
|
+ HMI_WRITE("debug.t4.txt=\"%s\"",device_status.driver_compile);
|
|
|
|
|
+ //
|
|
|
|
|
+ HMI_WRITE("debug.t5.txt=\"%s\"",device_status.driver_bl);
|
|
|
|
|
+ HMI_WRITE("debug.t7.txt=\"%s\"",device_status.driver_compile);
|
|
|
|
|
+ //更新dtu/rtu版本
|
|
|
|
|
+ HMI_WRITE("debug.t9.txt=\"%s\"",device_status.driver_4g);
|
|
|
|
|
+ //更新时间
|
|
|
|
|
+ HMI_WRITE("menu.rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
|
|
+ HMI_WRITE("workSta.rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
|
|
+ HMI_WRITE("set.t0.txt=\"%d\"",tm.tm_hour);
|
|
|
|
|
+ HMI_WRITE("set.t1.txt=\"%d\"",tm.tm_min);
|
|
|
|
|
+ HMI_WRITE("set.t2.txt=\"%d\"",tm.tm_sec);
|
|
|
|
|
+ //更新电压
|
|
|
|
|
+ HMI_WRITE("workSta.vbat.txt=\"%s\"",device_status.voltage);
|
|
|
|
|
+ //更新电流
|
|
|
|
|
+ HMI_WRITE("workSta.power.txt=\"%s\"",device_status.power);
|
|
|
|
|
+ //更新温湿度数据
|
|
|
|
|
+ HMI_WRITE("workSta.envHum.val=%d",atoi(device_status.humidity));
|
|
|
|
|
+ HMI_WRITE("workSta.envTem.val=%d",atoi(device_status.tempture));
|
|
|
|
|
+ //更新电池状态
|
|
|
|
|
+ HMI_WRITE("workSta.batStatus.val=%d",device_status.bat_status);
|
|
|
|
|
+ //更新上仓门状态
|
|
|
|
|
+ HMI_WRITE("workSta.upStatus.val=%d",device_status.up_status);
|
|
|
|
|
+ //更新下仓门状态
|
|
|
|
|
+ HMI_WRITE("workSta.downStatus.val=%d",device_status.down_status);
|
|
|
|
|
+ //更新工作状态
|
|
|
|
|
+ HMI_WRITE("workSta.workStatus.val=%d",device_status.work_status);
|
|
|
|
|
+ //更新温控状态
|
|
|
|
|
+ HMI_WRITE("workSta.tempStatus.val=%d",device_status.temp_status);
|
|
|
|
|
+ //更新雨控状态
|
|
|
|
|
+ HMI_WRITE("workSta.rainStatus.val=%d",device_status.rain_status);
|
|
|
|
|
+ //更新光控状态
|
|
|
|
|
+ HMI_WRITE("workSta.sunStatus.val=%d",device_status.sun_status);
|
|
|
|
|
+ //更新收集时间
|
|
|
|
|
+ HMI_WRITE("sysSet.stime.val=%d",device_status.clt_time);
|
|
|
|
|
+ //更新加热时间
|
|
|
|
|
+ HMI_WRITE("workSta.heatTime.val=%d",device_status.heattime);
|
|
|
|
|
+ HMI_WRITE("sysSet.jtime.val=%d",device_status.heattime);
|
|
|
|
|
+ //
|
|
|
|
|
+ HMI_WRITE("sysSet.vol.val=%d",device_status.vol);
|
|
|
|
|
+ //更新加热时间和温度
|
|
|
|
|
+ HMI_WRITE("workSta.heatTem.val=%d",device_status.heattem);
|
|
|
|
|
+ HMI_WRITE("sysSet.jheat.val=%d",device_status.heatvalue);
|
|
|
|
|
+ //更新加热状态
|
|
|
|
|
+ HMI_WRITE("workSta.heatStatus.val=%d",device_status.heat_status);
|
|
|
|
|
+ //更新密码
|
|
|
|
|
+ HMI_WRITE("inputPasswd.pwdData.txt=\"8888\"");
|
|
|
|
|
+ //更新时间设置中的参数
|
|
|
|
|
+ //更新定时模式
|
|
|
|
|
+ HMI_WRITE("clockSet.timeSwitch.val=%d",device_status.timeSwitch);
|
|
|
|
|
+ //更新光控定时时长
|
|
|
|
|
+ HMI_WRITE("clockSet.sunBar.val=%d",device_status.sunBar);
|
|
|
|
|
+ //更新时控开始
|
|
|
|
|
+ HMI_WRITE("clockSet.startBar.val=%d",device_status.startBar);
|
|
|
|
|
+ //更新时控结束
|
|
|
|
|
+ HMI_WRITE("clockSet.stopBar.val=%d",device_status.stopBar);
|
|
|
|
|
+ //SIM卡状态
|
|
|
|
|
+ HMI_WRITE("workSta.bt0.val=%d",atoi(device_status.sim));
|
|
|
|
|
+ //ID
|
|
|
|
|
+ HMI_WRITE("menu.equipid.txt=\"%s\"",device_status.imei);
|
|
|
|
|
+ HMI_WRITE("menu.deviceId.txt=\"%s\"",device_status.deviceId);
|
|
|
|
|
+ //HMI_WRITE("workSta.equipid.txt=\"%s\"",device_status.imei);
|
|
|
|
|
+ //数据上传间隔
|
|
|
|
|
+ HMI_WRITE("uploadSet.datt.val=%d",device_status.dattim);
|
|
|
|
|
+ //语音音量
|
|
|
|
|
+ HMI_WRITE("sysSet.vol.val=%d",device_status.vol);
|
|
|
|
|
+ //更新熄屏时间
|
|
|
|
|
+ if(device_status.thsp<60) device_status.thsp = device_status.thsp * 60;
|
|
|
|
|
+ HMI_WRITE("thsp=%d",device_status.thsp);
|
|
|
|
|
+
|
|
|
|
|
+ if(strstr(device_status.link_ip,".")!=RT_NULL){
|
|
|
|
|
+ HMI_WRITE("menu.t0.txt=\"%s\"",device_status.link_ip);
|
|
|
|
|
+ }
|
|
|
|
|
+#if MATCH_DEVICE == 1
|
|
|
|
|
+ HMI_WRITE("menu.mode.val=%d",device_status.work_mode);
|
|
|
|
|
+ HMI_WRITE("menu.upan.val=%d",device_status.upan_sta);
|
|
|
|
|
+ HMI_WRITE("menu.alarm_tg.txt=\"%s\"",device_status.alarm_tg);
|
|
|
|
|
+ //更新有线连接状态
|
|
|
|
|
+ HMI_WRITE("menu.va_net.val=%d",0);
|
|
|
|
|
+#else
|
|
|
|
|
+ HMI_WRITE("menu.va_net.val=%d",device_status.link_sta);
|
|
|
|
|
+#endif
|
|
|
|
|
+ }
|
|
|
|
|
+ HMI_WRITE("menu.cam_sta.val=%d",device_status.camsta);
|
|
|
|
|
+ if(atoi(device_status.gps)==1){
|
|
|
|
|
+ HMI_WRITE("menu.gps_state.txt=\"定位成功:(%s)%d/%d\"",device_status.gps_state,device_status.gps_inuse,device_status.gps_view);
|
|
|
|
|
+ }else if(atoi(device_status.gps)==2){
|
|
|
|
|
+ HMI_WRITE("menu.gps_state.txt=\"定位成功:(基站)\"");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //更新联网状态
|
|
|
|
|
+ if(atoi(device_status.net)==1)
|
|
|
|
|
+ {
|
|
|
|
|
+ HMI_WRITE("menu.net.val=1");
|
|
|
|
|
+ HMI_WRITE("workSta.net.val=1");
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ #if MATCH_DEVICE == 0
|
|
|
|
|
+ HMI_WRITE("workSta.net.val=0");
|
|
|
|
|
+ HMI_WRITE("menu.net.val=0");
|
|
|
|
|
+ //更新CSQ
|
|
|
|
|
+ HMI_WRITE("menu.csq_value.txt=\"%s\"",device_status.csq);
|
|
|
|
|
+ HMI_WRITE("menu.va_csq.val=%d",atoi(device_status.csq));
|
|
|
|
|
+ HMI_WRITE("workSta.csq_value.txt=\"%s\"",device_status.csq);
|
|
|
|
|
+ #else
|
|
|
|
|
+ HMI_WRITE("workSta.net.val=1");
|
|
|
|
|
+ HMI_WRITE("menu.net.val=1");
|
|
|
|
|
+ HMI_WRITE("menu.va_csq.val=0");
|
|
|
|
|
+ #endif
|
|
|
|
|
+ }
|
|
|
|
|
+ if(atoi(device_status.csq)==0&&atoi(device_status.net)==1)
|
|
|
|
|
+ {
|
|
|
|
|
+ HMI_WRITE("menu.net.val=1");
|
|
|
|
|
+ HMI_WRITE("workSta.net.val=2");
|
|
|
|
|
+ }
|
|
|
|
|
+ /**********************************************************************/
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/***************************** 解析从屏幕收到的数据 begin **********************************/
|
|
/***************************** 解析从屏幕收到的数据 begin **********************************/
|
|
|
static void HMI_Decode(void)
|
|
static void HMI_Decode(void)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
time_t now = time(RT_NULL);
|
|
time_t now = time(RT_NULL);
|
|
|
static struct tm tm;
|
|
static struct tm tm;
|
|
|
gmtime_r(&now, &tm);
|
|
gmtime_r(&now, &tm);
|
|
@@ -369,151 +527,7 @@ static void HMI_Decode(void)
|
|
|
static char *var;
|
|
static char *var;
|
|
|
if(device_status.refresh_num==0) device_status.refresh_num = 10;
|
|
if(device_status.refresh_num==0) device_status.refresh_num = 10;
|
|
|
if(strstr(rx_buffer,"getFullData") != NULL){
|
|
if(strstr(rx_buffer,"getFullData") != NULL){
|
|
|
- char *readinfo = makeJson_ReadInfo();
|
|
|
|
|
- if(device_status.refresh_num==5)
|
|
|
|
|
- {
|
|
|
|
|
- device_status.refresh_num = 15;
|
|
|
|
|
- DTU_Write("%s",readinfo);
|
|
|
|
|
- //list_mem();
|
|
|
|
|
- device_status.hmi_fresh = 1;
|
|
|
|
|
- rt_thread_delay(100);
|
|
|
|
|
- }
|
|
|
|
|
- //在解析getinfo中清除超时
|
|
|
|
|
- if(device_status.refresh_timeout==30)
|
|
|
|
|
- {
|
|
|
|
|
- rt_sprintf(device_status.sim,"1");
|
|
|
|
|
- rt_sprintf(device_status.net,"1");
|
|
|
|
|
- rt_sprintf(device_status.csq,"0");
|
|
|
|
|
- device_status.camsta = 1;
|
|
|
|
|
- device_status.link_sta=0;
|
|
|
|
|
- device_status.refresh_timeout=0;
|
|
|
|
|
- }
|
|
|
|
|
- rt_free(readinfo);
|
|
|
|
|
- device_status.refresh_num--;
|
|
|
|
|
- device_status.refresh_timeout++;
|
|
|
|
|
- if(device_status.version_type!=6)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("uploadSet.iccid.txt=\"%s\"",device_status.iccid);
|
|
|
|
|
- if(strstr(device_status.mqttcfg1,"8.136.98.49")!=NULL)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("uploadSet.plt.val=%d",RESET);
|
|
|
|
|
- }
|
|
|
|
|
- else if (strstr(device_status.mqttcfg1,"120.27.222.26")!=NULL) {
|
|
|
|
|
- HMI_WRITE("uploadSet.plt.val=%d",SET);
|
|
|
|
|
- }
|
|
|
|
|
- //HMI_WRITE("mqttcfg.mqtt1Message.txt=\"%s\"",device_status.mqttcfg1);
|
|
|
|
|
- HMI_WRITE("uploadSet.t0.txt=\"%s\"",device_status.mqttcfg1);
|
|
|
|
|
-
|
|
|
|
|
- //更新固件版本号
|
|
|
|
|
- HMI_WRITE("debug.t3.txt=\"%s\"",device_status.driver);
|
|
|
|
|
- //更新固件编译日期
|
|
|
|
|
- HMI_WRITE("debug.t4.txt=\"%s\"",device_status.driver_compile);
|
|
|
|
|
- //
|
|
|
|
|
- HMI_WRITE("debug.t5.txt=\"%s\"",device_status.driver_bl);
|
|
|
|
|
- HMI_WRITE("debug.t7.txt=\"%s\"",device_status.driver_compile);
|
|
|
|
|
- //更新dtu/rtu版本
|
|
|
|
|
- HMI_WRITE("debug.t9.txt=\"%s\"",device_status.driver_4g);
|
|
|
|
|
- //更新时间
|
|
|
|
|
- HMI_WRITE("menu.rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
|
|
- HMI_WRITE("workSta.rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
|
|
- HMI_WRITE("set.t0.txt=\"%d\"",tm.tm_hour);
|
|
|
|
|
- HMI_WRITE("set.t1.txt=\"%d\"",tm.tm_min);
|
|
|
|
|
- HMI_WRITE("set.t2.txt=\"%d\"",tm.tm_sec);
|
|
|
|
|
- //更新电压
|
|
|
|
|
- HMI_WRITE("workSta.vbat.txt=\"%s\"",device_status.voltage);
|
|
|
|
|
- //更新电流
|
|
|
|
|
- HMI_WRITE("workSta.power.txt=\"%s\"",device_status.power);
|
|
|
|
|
- //更新温湿度数据
|
|
|
|
|
- HMI_WRITE("workSta.envHum.val=%d",atoi(device_status.humidity));
|
|
|
|
|
- HMI_WRITE("workSta.envTem.val=%d",atoi(device_status.tempture));
|
|
|
|
|
- //更新电池状态
|
|
|
|
|
- HMI_WRITE("workSta.batStatus.val=%d",device_status.bat_status);
|
|
|
|
|
- //更新上仓门状态
|
|
|
|
|
- HMI_WRITE("workSta.upStatus.val=%d",device_status.up_status);
|
|
|
|
|
- //更新下仓门状态
|
|
|
|
|
- HMI_WRITE("workSta.downStatus.val=%d",device_status.down_status);
|
|
|
|
|
- //更新工作状态
|
|
|
|
|
- HMI_WRITE("workSta.workStatus.val=%d",device_status.work_status);
|
|
|
|
|
- //更新温控状态
|
|
|
|
|
- HMI_WRITE("workSta.tempStatus.val=%d",device_status.temp_status);
|
|
|
|
|
- //更新雨控状态
|
|
|
|
|
- HMI_WRITE("workSta.rainStatus.val=%d",device_status.rain_status);
|
|
|
|
|
- //更新光控状态
|
|
|
|
|
- HMI_WRITE("workSta.sunStatus.val=%d",device_status.sun_status);
|
|
|
|
|
- //更新有线连接状态
|
|
|
|
|
- HMI_WRITE("menu.va_net.val=%d",device_status.link_sta);
|
|
|
|
|
- //更新CSQ
|
|
|
|
|
- HMI_WRITE("menu.csq_value.txt=\"%s\"",device_status.csq);
|
|
|
|
|
- HMI_WRITE("menu.va_csq.val=%d",atoi(device_status.csq));
|
|
|
|
|
- HMI_WRITE("workSta.csq_value.txt=\"%s\"",device_status.csq);
|
|
|
|
|
- //更新收集时间
|
|
|
|
|
- HMI_WRITE("sysSet.stime.val=%d",device_status.clt_time);
|
|
|
|
|
- //更新加热时间
|
|
|
|
|
- HMI_WRITE("workSta.heatTime.val=%d",device_status.heattime);
|
|
|
|
|
- HMI_WRITE("sysSet.jtime.val=%d",device_status.heattime);
|
|
|
|
|
- //
|
|
|
|
|
- HMI_WRITE("sysSet.vol.val=%d",device_status.vol);
|
|
|
|
|
- //更新加热时间和温度
|
|
|
|
|
- HMI_WRITE("workSta.heatTem.val=%d",device_status.heattem);
|
|
|
|
|
- HMI_WRITE("sysSet.jheat.val=%d",device_status.heatvalue);
|
|
|
|
|
- //更新加热状态
|
|
|
|
|
- HMI_WRITE("workSta.heatStatus.val=%d",device_status.heat_status);
|
|
|
|
|
- //更新密码
|
|
|
|
|
- HMI_WRITE("inputPasswd.pwdData.txt=\"8888\"");
|
|
|
|
|
- //更新时间设置中的参数
|
|
|
|
|
- //更新定时模式
|
|
|
|
|
- HMI_WRITE("clockSet.timeSwitch.val=%d",device_status.timeSwitch);
|
|
|
|
|
- //更新光控定时时长
|
|
|
|
|
- HMI_WRITE("clockSet.sunBar.val=%d",device_status.sunBar);
|
|
|
|
|
- //更新时控开始
|
|
|
|
|
- HMI_WRITE("clockSet.startBar.val=%d",device_status.startBar);
|
|
|
|
|
- //更新时控结束
|
|
|
|
|
- HMI_WRITE("clockSet.stopBar.val=%d",device_status.stopBar);
|
|
|
|
|
- //SIM卡状态
|
|
|
|
|
- HMI_WRITE("workSta.bt0.val=%d",atoi(device_status.sim));
|
|
|
|
|
- //ID
|
|
|
|
|
- HMI_WRITE("menu.equipid.txt=\"%s\"",device_status.imei);
|
|
|
|
|
- HMI_WRITE("menu.deviceId.txt=\"%s\"",device_status.deviceId);
|
|
|
|
|
- //HMI_WRITE("workSta.equipid.txt=\"%s\"",device_status.imei);
|
|
|
|
|
- //数据上传间隔
|
|
|
|
|
- HMI_WRITE("uploadSet.datt.val=%d",device_status.dattim);
|
|
|
|
|
- //语音音量
|
|
|
|
|
- HMI_WRITE("sysSet.vol.val=%d",device_status.vol);
|
|
|
|
|
- //更新熄屏时间
|
|
|
|
|
- if(device_status.thsp<60) device_status.thsp = device_status.thsp * 60;
|
|
|
|
|
- HMI_WRITE("thsp=%d",device_status.thsp);
|
|
|
|
|
- //
|
|
|
|
|
- HMI_WRITE("menu.t0.txt=\"%s\"",device_status.link_ip);
|
|
|
|
|
- }
|
|
|
|
|
- HMI_WRITE("menu.cam_sta.val=%d",device_status.camsta);
|
|
|
|
|
-
|
|
|
|
|
- if(atoi(device_status.gps)==1){
|
|
|
|
|
- HMI_WRITE("menu.gps_state.txt=\"定位成功:(%s)%d/%d\"",device_status.gps_state,device_status.gps_inuse,device_status.gps_view);
|
|
|
|
|
- }else if(atoi(device_status.gps)==2){
|
|
|
|
|
- HMI_WRITE("menu.gps_state.txt=\"定位成功:(基站)\"");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //更新联网状态
|
|
|
|
|
- if(atoi(device_status.net)==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("menu.net.val=1");
|
|
|
|
|
- HMI_WRITE("workSta.net.val=1");
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- #if MATCH_DEVICE == 0
|
|
|
|
|
- HMI_WRITE("workSta.net.val=0");
|
|
|
|
|
- HMI_WRITE("menu.net.val=0");
|
|
|
|
|
- #else
|
|
|
|
|
- HMI_WRITE("workSta.net.val=1");
|
|
|
|
|
- HMI_WRITE("menu.net.val=1");
|
|
|
|
|
- #endif
|
|
|
|
|
- }
|
|
|
|
|
- if(atoi(device_status.csq)==0&&atoi(device_status.net)==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("menu.net.val=1");
|
|
|
|
|
- HMI_WRITE("workSta.net.val=2");
|
|
|
|
|
- }
|
|
|
|
|
- /**********************************************************************/
|
|
|
|
|
|
|
+ refresh_hmi_Component(tm);
|
|
|
}
|
|
}
|
|
|
else if (strstr(rx_buffer,"getClockData")!=NULL) {
|
|
else if (strstr(rx_buffer,"getClockData")!=NULL) {
|
|
|
//更新定时模式
|
|
//更新定时模式
|
|
@@ -617,6 +631,26 @@ static void HMI_Decode(void)
|
|
|
LOG_I("停止一键测试!!!");
|
|
LOG_I("停止一键测试!!!");
|
|
|
device_status.auto_test_sw=0;
|
|
device_status.auto_test_sw=0;
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (strstr(rx_buffer,"putTest.switchCc=1")!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("推杆打开测试!!!");
|
|
|
|
|
+ ctr_Cold(ON);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(rx_buffer,"putTest.switchCc=0")!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("推杆关闭测试!!!");
|
|
|
|
|
+ ctr_Cold(OFF);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(rx_buffer,"putTest.shakeCc=1")!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("震动电机打开测试!!!");
|
|
|
|
|
+ ctr_Collect_Fan(ON);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (strstr(rx_buffer,"putTest.shakeCc=0")!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("震动电机关闭测试!!!");
|
|
|
|
|
+ ctr_Collect_Fan(OFF);
|
|
|
|
|
+ }
|
|
|
else if (strstr(rx_buffer,"turnzp")!=NULL) {
|
|
else if (strstr(rx_buffer,"turnzp")!=NULL) {
|
|
|
LOG_W("转仓!");
|
|
LOG_W("转仓!");
|
|
|
device_status.clear_status=2;
|
|
device_status.clear_status=2;
|
|
@@ -810,6 +844,56 @@ static void HMI_Decode(void)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //设置闹钟时间
|
|
|
|
|
+ else if (strstr(rx_buffer,"ALARM=")!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ char *var = strstr(rx_buffer,"=");
|
|
|
|
|
+ if (var == NULL) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ var ++;
|
|
|
|
|
+
|
|
|
|
|
+ // ===================== 修复:去掉末尾的 \r 或 换行 =====================
|
|
|
|
|
+ // 遍历字符串,把 \r \n 全部替换成结束符
|
|
|
|
|
+ for (int i = 0; var[i] != '\0'; i++) {
|
|
|
|
|
+ if (var[i] == '\r' || var[i] == '\n') {
|
|
|
|
|
+ var[i] = '\0';
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(var[6] != '\r') {
|
|
|
|
|
+ var[6] = '\0';
|
|
|
|
|
+ }
|
|
|
|
|
+ // 现在 var 只剩下干净的 6 位数字了
|
|
|
|
|
+ int len = strlen(var);
|
|
|
|
|
+ int is_valid = 1;
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 必须是 6 个字符(已经去掉\r)
|
|
|
|
|
+ if (len != 6) {
|
|
|
|
|
+ is_valid = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 2. 必须全部是数字 0-9
|
|
|
|
|
+ else {
|
|
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
|
|
+ if (!(var[i] >= '0' && var[i] <= '9')) {
|
|
|
|
|
+ is_valid = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验不通过:打印报错,不赋值
|
|
|
|
|
+ if (!is_valid) {
|
|
|
|
|
+ LOG_E("闹钟格式错误!必须是 6 位数字时间(如 150000),当前值:%s", var);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // ======================================================================
|
|
|
|
|
+
|
|
|
|
|
+ // 格式正确才赋值
|
|
|
|
|
+ LOG_I("设置闹钟时间:%s",var);
|
|
|
|
|
+ rt_sprintf(device_status.alarm_tg, "%s", var);
|
|
|
|
|
+ ef_set_env_blob("alarm_tg", &device_status.alarm_tg, sizeof(device_status.alarm_tg));
|
|
|
|
|
+ }
|
|
|
//设备编码设置
|
|
//设备编码设置
|
|
|
else if (strstr(rx_buffer,"deviceId=")!=NULL)
|
|
else if (strstr(rx_buffer,"deviceId=")!=NULL)
|
|
|
{
|
|
{
|
|
@@ -927,14 +1011,6 @@ static void HMI_Decode(void)
|
|
|
ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));
|
|
ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// time_t now;
|
|
|
|
|
-// time(&now);
|
|
|
|
|
-// static struct tm nowstamp;
|
|
|
|
|
-// nowstamp =*localtime(&now);
|
|
|
|
|
-// nowstamp.tm_hour = nowstamp.tm_hour - 8;
|
|
|
|
|
-// static rt_uint32_t nowstamp_num = 0;
|
|
|
|
|
-// nowstamp_num = mktime(&nowstamp);
|
|
|
|
|
-// device_status.light_over_tim = device_status.sunBar * 3600 + nowstamp_num;
|
|
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
LOG_E("参数设置异常(光控时长):%d!!!",atoi(value_str));
|
|
LOG_E("参数设置异常(光控时长):%d!!!",atoi(value_str));
|
|
@@ -1443,22 +1519,38 @@ static void HMI_Decode(void)
|
|
|
device_status.selfcheck_ws = 2;
|
|
device_status.selfcheck_ws = 2;
|
|
|
LOG_W("开始自检:%d",device_status.selfcheck_ws);
|
|
LOG_W("开始自检:%d",device_status.selfcheck_ws);
|
|
|
}
|
|
}
|
|
|
- }else if(strstr(rx_buffer,"haichong")!=NULL)
|
|
|
|
|
- {
|
|
|
|
|
- _485_play(sound122, 4);
|
|
|
|
|
- HMI_WRITE("sysTest.result.txt=\"害虫测试!\"");
|
|
|
|
|
-// ctr_Motor_Driver_Power(ON);
|
|
|
|
|
-// ctr_xmove(400,200);//旋转清虫
|
|
|
|
|
- //使用硬件定时器控制
|
|
|
|
|
- device_status.autotakepic = 10;
|
|
|
|
|
-
|
|
|
|
|
- }else if(strstr(rx_buffer,"yichong")!=NULL)
|
|
|
|
|
|
|
+ }else if(strstr(rx_buffer,"SwitchMode")!=NULL)
|
|
|
{
|
|
{
|
|
|
- _485_play(sound122, 4);
|
|
|
|
|
- HMI_WRITE("sysTest.result.txt=\"益虫测试!\"");
|
|
|
|
|
-// ctr_Motor_Driver_Power(ON);
|
|
|
|
|
-// ctr_xmove(400,200);//旋转清虫
|
|
|
|
|
- device_status.autotakepic = 11;
|
|
|
|
|
|
|
+ device_status.work_mode = !device_status.work_mode;
|
|
|
|
|
+ ef_set_env_blob("work_mode", &device_status.work_mode, sizeof(device_status.work_mode));
|
|
|
|
|
+ LOG_W("修改工作模式:%d",device_status.work_mode);
|
|
|
|
|
+ }else if(strstr(rx_buffer,"DeleteUimage")!=NULL){
|
|
|
|
|
+ char* temp = makeJsonRpc2_0("upan_delete_image", NULL, 1);
|
|
|
|
|
+ if(temp){
|
|
|
|
|
+ DTU_Write(temp);
|
|
|
|
|
+ free(temp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(strstr(rx_buffer,"MOVE_IMAGE")!=NULL){
|
|
|
|
|
+ char* temp = makeJsonRpc2_0("MOVE_IMAGE", NULL, 1);
|
|
|
|
|
+ if(temp){
|
|
|
|
|
+ DTU_Write(temp);
|
|
|
|
|
+ free(temp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(strstr(rx_buffer,"COPY_IMAGE")!=NULL){
|
|
|
|
|
+ cJSON *params = cJSON_CreateObject(); // params 子对象
|
|
|
|
|
+ cJSON_AddNumberToObject(params, "st", device_status.startBar); // st:20
|
|
|
|
|
+ cJSON_AddNumberToObject(params, "et", device_status.stopBar); // et:7
|
|
|
|
|
+ char* temp = makeJsonRpc2_0("COPY_IMAGE", params, 1);
|
|
|
|
|
+ if(temp){
|
|
|
|
|
+ DTU_Write(temp);
|
|
|
|
|
+ free(temp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(strstr(rx_buffer,"UMOUNT_UPAN")!=NULL){
|
|
|
|
|
+ char* temp = makeJsonRpc2_0("UMOUNT_UPAN", NULL, 1);
|
|
|
|
|
+ if(temp){
|
|
|
|
|
+ DTU_Write(temp);
|
|
|
|
|
+ free(temp);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1531,13 +1623,11 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
ctr_cangmen_down(OPEN);
|
|
ctr_cangmen_down(OPEN);
|
|
|
num_down_open--;
|
|
num_down_open--;
|
|
|
#if TG_MODULE ==1
|
|
#if TG_MODULE ==1
|
|
|
- if(rt_pin_read(CTR_UPC_LIMIT)==0){
|
|
|
|
|
|
|
+ if(rt_pin_read(CTR_UPC_LIMIT)==1){
|
|
|
ctr_cangmen_down(OFF);
|
|
ctr_cangmen_down(OFF);
|
|
|
Beep_Tip(2000);
|
|
Beep_Tip(2000);
|
|
|
- while(rt_pin_read(CTR_UPC_LIMIT)==0){
|
|
|
|
|
- ctr_cangmen_down(OPEN);
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ctr_cangmen_down(OPEN);
|
|
|
|
|
+ Beep_Tip(2000);
|
|
|
num_down_open = 200;
|
|
num_down_open = 200;
|
|
|
device_status.ctr_down_motor = 1;
|
|
device_status.ctr_down_motor = 1;
|
|
|
}
|
|
}
|
|
@@ -1741,11 +1831,13 @@ void Check_ParamConfig(void)
|
|
|
device_status.cul_time = 1;
|
|
device_status.cul_time = 1;
|
|
|
device_status.run_sta = 0;
|
|
device_status.run_sta = 0;
|
|
|
device_status.handle_bugger = 0; //默认排虫
|
|
device_status.handle_bugger = 0; //默认排虫
|
|
|
|
|
+ device_status.work_mode = 0;
|
|
|
sprintf(device_status.driver, "%s",VERSION_HK);
|
|
sprintf(device_status.driver, "%s",VERSION_HK);
|
|
|
sprintf(device_status.deviceId,"0");
|
|
sprintf(device_status.deviceId,"0");
|
|
|
rt_sprintf(device_status.tempture, "-15");
|
|
rt_sprintf(device_status.tempture, "-15");
|
|
|
rt_sprintf(device_status.humidity, "31");
|
|
rt_sprintf(device_status.humidity, "31");
|
|
|
rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
|
|
rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
|
|
|
|
|
+ rt_sprintf(device_status.alarm_tg,"220000");
|
|
|
ef_set_env_blob("iSave", &device_status.iSave, sizeof(device_status.iSave)); //
|
|
ef_set_env_blob("iSave", &device_status.iSave, sizeof(device_status.iSave)); //
|
|
|
ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
|
|
ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
|
|
@@ -1777,7 +1869,8 @@ void Check_ParamConfig(void)
|
|
|
ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta)); //
|
|
ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta)); //
|
|
|
ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
|
|
ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
|
|
|
ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
-
|
|
|
|
|
|
|
+ ef_set_env_blob("work_mode", &device_status.work_mode, sizeof(device_status.work_mode));
|
|
|
|
|
+ ef_set_env_blob("alarm_tg", &device_status.alarm_tg, sizeof(device_status.alarm_tg));
|
|
|
LOG_I("SOFTWARE VERSION:%s",device_status.driver);
|
|
LOG_I("SOFTWARE VERSION:%s",device_status.driver);
|
|
|
LOG_I("Default paramconf is:");
|
|
LOG_I("Default paramconf is:");
|
|
|
LOG_I("stime:%d",device_status.iSave);
|
|
LOG_I("stime:%d",device_status.iSave);
|
|
@@ -1790,6 +1883,7 @@ void Check_ParamConfig(void)
|
|
|
LOG_I("jheat:%d",device_status.heatvalue);
|
|
LOG_I("jheat:%d",device_status.heatvalue);
|
|
|
LOG_I("thsp:%d", device_status.thsp);
|
|
LOG_I("thsp:%d", device_status.thsp);
|
|
|
LOG_I("passwd:%d",device_status.passWord);
|
|
LOG_I("passwd:%d",device_status.passWord);
|
|
|
|
|
+ LOG_I("alarm_tg:%s",device_status.alarm_tg);
|
|
|
|
|
|
|
|
}//从easyflash读取参数配置
|
|
}//从easyflash读取参数配置
|
|
|
else if (device_status.iSave==FLASH_FLAG) {
|
|
else if (device_status.iSave==FLASH_FLAG) {
|
|
@@ -1835,6 +1929,8 @@ void Check_ParamConfig(void)
|
|
|
ef_get_env_blob("Power_Type",&device_status.Power_Type,sizeof(device_status.Power_Type),NULL); //供电类型
|
|
ef_get_env_blob("Power_Type",&device_status.Power_Type,sizeof(device_status.Power_Type),NULL); //供电类型
|
|
|
ef_get_env_blob("deviceId",&device_status.deviceId,sizeof(device_status.deviceId),NULL); //设备编码
|
|
ef_get_env_blob("deviceId",&device_status.deviceId,sizeof(device_status.deviceId),NULL); //设备编码
|
|
|
ef_get_env_blob("handle_bugger",&device_status.handle_bugger,sizeof(device_status.handle_bugger),NULL); //排虫
|
|
ef_get_env_blob("handle_bugger",&device_status.handle_bugger,sizeof(device_status.handle_bugger),NULL); //排虫
|
|
|
|
|
+ ef_get_env_blob("work_mode",&device_status.work_mode,sizeof(device_status.work_mode),NULL); //工作模式
|
|
|
|
|
+ ef_get_env_blob("alarm_tg",&device_status.alarm_tg,sizeof(device_status.alarm_tg),NULL); //闹钟
|
|
|
device_status.light_over_tim = device_status.sunBar * 3600; //光控计数
|
|
device_status.light_over_tim = device_status.sunBar * 3600; //光控计数
|
|
|
device_status.work_done = 0;
|
|
device_status.work_done = 0;
|
|
|
//工作完成标志位
|
|
//工作完成标志位
|
|
@@ -1849,7 +1945,7 @@ void Check_ParamConfig(void)
|
|
|
ResetParamDefault_DC();
|
|
ResetParamDefault_DC();
|
|
|
}
|
|
}
|
|
|
if(device_status.heatvalue==0) device_status.heatvalue = 100;
|
|
if(device_status.heatvalue==0) device_status.heatvalue = 100;
|
|
|
-
|
|
|
|
|
|
|
+ if(device_status.work_mode>1) device_status.work_mode = 0;
|
|
|
/*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
|
|
/*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
|
|
|
if(device_status.dtype!=7)
|
|
if(device_status.dtype!=7)
|
|
|
{
|
|
{
|
|
@@ -1916,6 +2012,7 @@ void Check_ParamConfig(void)
|
|
|
LOG_I("PowerType:%d",device_status.Power_Type);
|
|
LOG_I("PowerType:%d",device_status.Power_Type);
|
|
|
LOG_I("deviceId:%s",device_status.deviceId);
|
|
LOG_I("deviceId:%s",device_status.deviceId);
|
|
|
LOG_I("handle_bugger:%d",device_status.handle_bugger);
|
|
LOG_I("handle_bugger:%d",device_status.handle_bugger);
|
|
|
|
|
+ LOG_I("alarm_tg:%s",device_status.alarm_tg);
|
|
|
}
|
|
}
|
|
|
//RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
|
|
//RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
|
|
|
if(device_status.update_flag==1)
|
|
if(device_status.update_flag==1)
|
|
@@ -1931,14 +2028,9 @@ void Check_ParamConfig(void)
|
|
|
rt_sprintf(device_status.csq,"0");
|
|
rt_sprintf(device_status.csq,"0");
|
|
|
rt_sprintf(device_status.sim,"1");
|
|
rt_sprintf(device_status.sim,"1");
|
|
|
Sys_Motor_Task();
|
|
Sys_Motor_Task();
|
|
|
-#ifdef RT_USING_ALARM
|
|
|
|
|
- alarm_app_router();
|
|
|
|
|
-#endif
|
|
|
|
|
-#if MATCH_DEVICE== 0
|
|
|
|
|
|
|
+
|
|
|
ctr_router(ON);
|
|
ctr_router(ON);
|
|
|
-#else
|
|
|
|
|
- ctr_router(OFF);
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+
|
|
|
Hmi_Fresh();
|
|
Hmi_Fresh();
|
|
|
|
|
|
|
|
Control_clear();
|
|
Control_clear();
|
|
@@ -1965,17 +2057,9 @@ void Check_ParamConfig(void)
|
|
|
//超时时间为3分钟
|
|
//超时时间为3分钟
|
|
|
#if MATCH_DEVICE == 1
|
|
#if MATCH_DEVICE == 1
|
|
|
if(connect_num==60) //180
|
|
if(connect_num==60) //180
|
|
|
- {
|
|
|
|
|
- device_status.timeSwitch = 1;
|
|
|
|
|
- LOG_W("Time not set:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
|
|
- #if 0
|
|
|
|
|
- set_date(2020, 1, 1);
|
|
|
|
|
- set_time(0, 0, 0);
|
|
|
|
|
- #endif
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
#else
|
|
#else
|
|
|
if(connect_num==180) //180
|
|
if(connect_num==180) //180
|
|
|
|
|
+ #endif
|
|
|
{
|
|
{
|
|
|
device_status.timeSwitch = 0;
|
|
device_status.timeSwitch = 0;
|
|
|
LOG_W("Time not set:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
LOG_W("Time not set:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
@@ -1985,7 +2069,7 @@ void Check_ParamConfig(void)
|
|
|
#endif
|
|
#endif
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- #endif
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
connect_num = 0;
|
|
connect_num = 0;
|
|
|
while(atoi(device_status.net)==0)
|
|
while(atoi(device_status.net)==0)
|
|
@@ -1997,7 +2081,9 @@ void Check_ParamConfig(void)
|
|
|
connect_num++;
|
|
connect_num++;
|
|
|
if(connect_num>5) break;
|
|
if(connect_num>5) break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ #if MATCH_DEVICE == 1
|
|
|
|
|
+ device_status.timeSwitch = 1;
|
|
|
|
|
+ #endif
|
|
|
DTU_Write("%s",makeJson_Warn("turnon", "device_stm32"));
|
|
DTU_Write("%s",makeJson_Warn("turnon", "device_stm32"));
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
dtu_send_data_start();
|
|
dtu_send_data_start();
|