|
@@ -128,6 +128,10 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
struct rx_msg msg;
|
|
struct rx_msg msg;
|
|
|
rt_err_t result;
|
|
rt_err_t result;
|
|
|
rt_uint32_t rx_length;
|
|
rt_uint32_t rx_length;
|
|
|
|
|
+ if(device_status.dtype==3){
|
|
|
|
|
+ device_status.collt_box_sta = 0;
|
|
|
|
|
+ device_status.run_sta = 0;
|
|
|
|
|
+ }
|
|
|
while(1)
|
|
while(1)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -648,13 +652,40 @@ static void HMI_Decode(void)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ else if(strstr(rx_buffer,"putTest.Testpaichong")!=NULL){
|
|
|
|
|
+ if(device_status.collt_box_sta==0){
|
|
|
|
|
+ device_status.collt_box_sta = 111;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"请等待当前执行完成再进行操作\"");
|
|
|
|
|
+ }
|
|
|
|
|
+ LOG_I("排虫测试!");
|
|
|
|
|
+ }
|
|
|
//排虫
|
|
//排虫
|
|
|
else if(strstr(rx_buffer,"putTest.paichong")!=NULL){
|
|
else if(strstr(rx_buffer,"putTest.paichong")!=NULL){
|
|
|
- device_status.vol = 111;
|
|
|
|
|
|
|
+ if(device_status.run_sta == 0){
|
|
|
|
|
+ device_status.run_sta = 111;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"请等待当前执行完成再进行操作\"");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
LOG_I("开始排虫!");
|
|
LOG_I("开始排虫!");
|
|
|
|
|
+ device_status.handle_bugger = 0;
|
|
|
|
|
+ ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(strstr(rx_buffer,"putTest.shouchong")!=NULL){
|
|
|
|
|
+ if(device_status.run_sta == 0){
|
|
|
|
|
+ device_status.run_sta = 112;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"请等待当前执行完成再进行操作\"");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LOG_I("开始收虫!");
|
|
|
|
|
+ device_status.handle_bugger = 1;
|
|
|
|
|
+ ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
}
|
|
}
|
|
|
//设备编码设置
|
|
//设备编码设置
|
|
|
- else if (strstr(rx_buffer,"deviceId=")!=NULL) {
|
|
|
|
|
|
|
+ else if (strstr(rx_buffer,"deviceId=")!=NULL)
|
|
|
|
|
+ {
|
|
|
char value_str[20];
|
|
char value_str[20];
|
|
|
memset(value_str,0,sizeof(value_str));
|
|
memset(value_str,0,sizeof(value_str));
|
|
|
LOG_I("设备编码 长度:%d",strlen(rx_buffer));
|
|
LOG_I("设备编码 长度:%d",strlen(rx_buffer));
|
|
@@ -665,13 +696,21 @@ static void HMI_Decode(void)
|
|
|
var = strstr(rx_buffer,"=");
|
|
var = strstr(rx_buffer,"=");
|
|
|
var ++;
|
|
var ++;
|
|
|
strncpy(value_str,var,16); //设备编码为16位
|
|
strncpy(value_str,var,16); //设备编码为16位
|
|
|
- rt_sprintf(device_status.deviceId,"%s",value_str);
|
|
|
|
|
- ef_set_env_blob("deviceId", &device_status.deviceId, sizeof(device_status.deviceId));
|
|
|
|
|
- LOG_I("解析到设备编码:%s",device_status.deviceId);
|
|
|
|
|
- char *device_id = makeJson_Config_BDH(device_status.deviceId);
|
|
|
|
|
- //发送json到RTU
|
|
|
|
|
- DTU_Write("%s",device_id);
|
|
|
|
|
- rt_free(device_id);
|
|
|
|
|
|
|
+ if(strstr(value_str,"0000000000000000")!=RT_NULL){
|
|
|
|
|
+ char *config_reset = makeJson_Config_Reset();
|
|
|
|
|
+ //发送json到RTU
|
|
|
|
|
+ DTU_Write("%s",config_reset);
|
|
|
|
|
+ rt_free(config_reset);
|
|
|
|
|
+ //恢复RTU的默认配置参数
|
|
|
|
|
+ }else{
|
|
|
|
|
+ rt_sprintf(device_status.deviceId,"%s",value_str);
|
|
|
|
|
+ ef_set_env_blob("deviceId", &device_status.deviceId, sizeof(device_status.deviceId));
|
|
|
|
|
+ LOG_I("解析到设备编码:%s",device_status.deviceId);
|
|
|
|
|
+ char *device_id = makeJson_Config_BDH(device_status.deviceId);
|
|
|
|
|
+ //发送json到RTU
|
|
|
|
|
+ DTU_Write("%s",device_id);
|
|
|
|
|
+ rt_free(device_id);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//定时设置
|
|
//定时设置
|
|
|
else if (strstr(rx_buffer,"saveClockSet=")!=NULL) {
|
|
else if (strstr(rx_buffer,"saveClockSet=")!=NULL) {
|
|
@@ -1527,7 +1566,8 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
{
|
|
{
|
|
|
ctr_Petroleum_jelly(10);
|
|
ctr_Petroleum_jelly(10);
|
|
|
}
|
|
}
|
|
|
- if(device_status.vol==111){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(device_status.collt_box_sta==111){
|
|
|
ctr_Fan_IN(ON); //推杆电机收缩(供电打开,复位)
|
|
ctr_Fan_IN(ON); //推杆电机收缩(供电打开,复位)
|
|
|
num_tg_init--;
|
|
num_tg_init--;
|
|
|
if(num_tg_init%10==0)
|
|
if(num_tg_init%10==0)
|
|
@@ -1536,28 +1576,51 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
|
|
HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
|
|
|
ctr_Fan_PUT(ON);
|
|
ctr_Fan_PUT(ON);
|
|
|
num_tg_init = 200;
|
|
num_tg_init = 200;
|
|
|
- device_status.vol=112;
|
|
|
|
|
|
|
+ device_status.collt_box_sta=112;
|
|
|
}
|
|
}
|
|
|
- }else if(device_status.vol==112){
|
|
|
|
|
|
|
+ }else if(device_status.collt_box_sta==112){
|
|
|
num_tg_open--;
|
|
num_tg_open--;
|
|
|
if(num_tg_open%10==0)
|
|
if(num_tg_open%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"开始执行排虫:%d\"",num_tg_open/10);
|
|
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"开始执行排虫:%d\"",num_tg_open/10);
|
|
|
if(num_tg_open==0){
|
|
if(num_tg_open==0){
|
|
|
HMI_WRITE("sysTest.result.txt=\"排虫复位中\"");
|
|
HMI_WRITE("sysTest.result.txt=\"排虫复位中\"");
|
|
|
ctr_Fan_PUT(OFF);
|
|
ctr_Fan_PUT(OFF);
|
|
|
num_tg_open = 200;
|
|
num_tg_open = 200;
|
|
|
- device_status.vol=113;
|
|
|
|
|
|
|
+ device_status.collt_box_sta=113;
|
|
|
}
|
|
}
|
|
|
- }else if(device_status.vol==113){
|
|
|
|
|
|
|
+ }else if(device_status.collt_box_sta==113){
|
|
|
num_tg_init--;
|
|
num_tg_init--;
|
|
|
if(num_tg_init%10==0)
|
|
if(num_tg_init%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
|
|
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
|
|
|
if(num_tg_init==0){
|
|
if(num_tg_init==0){
|
|
|
HMI_WRITE("sysTest.result.txt=\"排虫机执行已完成!\"");
|
|
HMI_WRITE("sysTest.result.txt=\"排虫机执行已完成!\"");
|
|
|
ctr_Fan_PUT(OFF);
|
|
ctr_Fan_PUT(OFF);
|
|
|
ctr_Fan_IN(OFF);
|
|
ctr_Fan_IN(OFF);
|
|
|
num_tg_init = 200;
|
|
num_tg_init = 200;
|
|
|
- device_status.vol=0;
|
|
|
|
|
|
|
+ device_status.collt_box_sta=0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(device_status.run_sta==111){//收虫
|
|
|
|
|
+ ctr_Fan_IN(ON); //推杆电机收缩(供电打开,复位)
|
|
|
|
|
+ num_tg_init--;
|
|
|
|
|
+ if(num_tg_init%10==0)
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
|
|
|
|
|
+ if(num_tg_init==0){
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
|
|
|
|
|
+ ctr_Fan_IN(OFF);
|
|
|
|
|
+ num_tg_init = 200;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(device_status.run_sta==112){
|
|
|
|
|
+ ctr_Fan_PUT(ON);
|
|
|
|
|
+ num_tg_open--;
|
|
|
|
|
+ if(num_tg_open%10==0)
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"开始执行排虫:%d\"",num_tg_open/10);
|
|
|
|
|
+ if(num_tg_open==0){
|
|
|
|
|
+ HMI_WRITE("sysTest.result.txt=\"排虫中...\"");
|
|
|
|
|
+ ctr_Fan_PUT(OFF);
|
|
|
|
|
+ num_tg_open = 200;
|
|
|
|
|
+ device_status.run_sta=0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1746,7 +1809,7 @@ void Check_ParamConfig(void)
|
|
|
device_status.heat_sw =0;
|
|
device_status.heat_sw =0;
|
|
|
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; //默认排虫
|
|
|
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");
|
|
@@ -1782,6 +1845,7 @@ void Check_ParamConfig(void)
|
|
|
ef_set_env_blob("collecting_eh2",&device_status.collecting_eh2,sizeof(device_status.collecting_eh2)); //采集时间
|
|
ef_set_env_blob("collecting_eh2",&device_status.collecting_eh2,sizeof(device_status.collecting_eh2)); //采集时间
|
|
|
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));
|
|
|
|
|
|
|
|
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:");
|
|
@@ -1838,6 +1902,7 @@ void Check_ParamConfig(void)
|
|
|
ef_get_env_blob("run_sta",&device_status.run_sta,sizeof(device_status.run_sta),NULL); //运行状态
|
|
ef_get_env_blob("run_sta",&device_status.run_sta,sizeof(device_status.run_sta),NULL); //运行状态
|
|
|
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); //排虫
|
|
|
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;
|
|
|
//工作完成标志位
|
|
//工作完成标志位
|
|
@@ -1928,6 +1993,7 @@ void Check_ParamConfig(void)
|
|
|
LOG_I("孢子仪采集时间:[%d-%d,%d-%d]",device_status.collecting_sh1,device_status.collecting_eh1,device_status.collecting_sh2,device_status.collecting_eh2);
|
|
LOG_I("孢子仪采集时间:[%d-%d,%d-%d]",device_status.collecting_sh1,device_status.collecting_eh1,device_status.collecting_sh2,device_status.collecting_eh2);
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
//RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
|
|
//RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
|
|
|
if(device_status.update_flag==1)
|
|
if(device_status.update_flag==1)
|
|
@@ -2047,7 +2113,8 @@ void ResetParamDefault(void)
|
|
|
ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
|
|
ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
|
|
|
ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); //震动开关
|
|
ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); //震动开关
|
|
|
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)); //震动时间
|
|
|
-
|
|
|
|
|
|
|
+ device_status.handle_bugger = 0;
|
|
|
|
|
+ ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
}
|
|
}
|
|
|
else if(device_status.dtype==7)
|
|
else if(device_status.dtype==7)
|
|
|
{
|
|
{
|
|
@@ -2094,6 +2161,8 @@ void ResetParamDefault_DC(void)
|
|
|
device_status.passWord = 8888;
|
|
device_status.passWord = 8888;
|
|
|
device_status.timeSwitch = 0;
|
|
device_status.timeSwitch = 0;
|
|
|
device_status.Power_Type = 0;
|
|
device_status.Power_Type = 0;
|
|
|
|
|
+ device_status.handle_bugger = 0;
|
|
|
|
|
+ ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
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("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));
|