|
|
@@ -27,7 +27,7 @@
|
|
|
#include <shell.h>
|
|
|
#include "dtu_uart2.h"
|
|
|
#include <fal.h>
|
|
|
-#define HMI_THREAD_PRIORITY 24 //线程优先级
|
|
|
+#define HMI_THREAD_PRIORITY 5 //线程优先级
|
|
|
#define HMI_THREAD_STACK_SIZE 2048 //线程栈空间大小
|
|
|
#define HMI_THREAD_TIMESLICE 10 //时间片
|
|
|
|
|
|
@@ -146,7 +146,8 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
/***************************** 解析从屏幕收到的数据 begin **********************************/
|
|
|
static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
{
|
|
|
- char *var;
|
|
|
+ char *var=NULL;
|
|
|
+ rt_free(var);
|
|
|
if(device_status.refresh_num==0) device_status.refresh_num = 10;
|
|
|
if(strstr(rx_buffer,"getFullData") != NULL){
|
|
|
time_t now = time(RT_NULL);
|
|
|
@@ -168,6 +169,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
rt_sprintf(device_status.sim,"1");
|
|
|
rt_sprintf(device_status.net,"1");
|
|
|
rt_sprintf(device_status.csq,"0");
|
|
|
+ device_status.link_sta=0;
|
|
|
device_status.refresh_timeout=0;
|
|
|
}
|
|
|
rt_free(readinfo);
|
|
|
@@ -212,8 +214,11 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
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);
|
|
|
@@ -340,39 +345,26 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
//打开灯管
|
|
|
else if (strstr(rx_buffer,"putTest.switchLamp=1")!=NULL)
|
|
|
{
|
|
|
+ device_status.test_flag=1;
|
|
|
rt_kprintf("Open Lamp!\n");
|
|
|
ctr_lamp(ON,1);
|
|
|
- }
|
|
|
- #if LAMP_EN == 1
|
|
|
- else if (strstr(rx_buffer,"putTest.switchLamp1=1")!=NULL)
|
|
|
- {
|
|
|
- rt_kprintf("Open Lamp1!\n");
|
|
|
+ #if LAMP_EN == 1
|
|
|
ctr_lamp(ON,2);
|
|
|
- }
|
|
|
- else if (strstr(rx_buffer,"putTest.switchLamp2=1")!=NULL)
|
|
|
- {
|
|
|
- rt_kprintf("Open Lamp2!\n");
|
|
|
ctr_lamp(ON,3);
|
|
|
+ #endif
|
|
|
}
|
|
|
- #endif
|
|
|
+
|
|
|
//关闭灯管
|
|
|
else if (strstr(rx_buffer,"putTest.switchLamp=0")!=NULL)
|
|
|
{
|
|
|
+ device_status.test_flag=0;
|
|
|
rt_kprintf("Close Lamp1!\n");
|
|
|
ctr_lamp(OFF,1);
|
|
|
- }
|
|
|
- #if LAMP_EN == 1
|
|
|
- else if (strstr(rx_buffer,"putTest.switchLamp1=0")!=NULL)
|
|
|
- {
|
|
|
- rt_kprintf("Close Lamp2!\n");
|
|
|
+ #if LAMP_EN == 1
|
|
|
ctr_lamp(OFF,2);
|
|
|
- }
|
|
|
- else if (strstr(rx_buffer,"putTest.switchLamp2=0")!=NULL)
|
|
|
- {
|
|
|
- rt_kprintf("Close Lamp2!\n");
|
|
|
ctr_lamp(OFF,3);
|
|
|
+ #endif
|
|
|
}
|
|
|
- #endif
|
|
|
//关闭加热
|
|
|
else if(strstr(rx_buffer,"putTest.switchHeat=0")!=NULL) {
|
|
|
device_status.heat_status = 0;
|
|
|
@@ -420,19 +412,21 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
{
|
|
|
#if LAMP_EN == 0
|
|
|
device_status.sunBar=atoi(sun_str);
|
|
|
- #endif
|
|
|
- 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;
|
|
|
ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
|
|
|
+ #else
|
|
|
+ rt_kprintf("光控定时设置失败!!!,三光源模式!!\n");
|
|
|
+ #endif
|
|
|
+// 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 {
|
|
|
- rt_kprintf("参数设置异常!!!");
|
|
|
+ rt_kprintf("参数设置异常(光控时长):%d!!!%d",atoi(sun_str));
|
|
|
}
|
|
|
//时控开始时间
|
|
|
strncpy(start_str,var+2,2);
|
|
|
@@ -442,7 +436,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常!!!");
|
|
|
+ rt_kprintf("参数设置异常(开始):%d!!!",atoi(start_str));
|
|
|
}
|
|
|
//
|
|
|
strncpy(stop_str,var+4,2);
|
|
|
@@ -452,10 +446,10 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常!!!");
|
|
|
+ rt_kprintf("参数设置异常(结束):%d!!!",atoi(stop_str));
|
|
|
}
|
|
|
//
|
|
|
- strncpy(timeswitch_str,var+6,2);
|
|
|
+ strncpy(timeswitch_str,var+7,2);
|
|
|
if(atoi(timeswitch_str) >= 0 && atoi(timeswitch_str) <= 1)
|
|
|
{
|
|
|
#if LAMP_EN == 0
|
|
|
@@ -464,9 +458,10 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
#endif
|
|
|
}
|
|
|
else {
|
|
|
- rt_kprintf("参数设置异常!!!");
|
|
|
+ rt_kprintf("参数设置异常(模式):%d!!!",atoi(timeswitch_str));
|
|
|
}
|
|
|
MA_save();
|
|
|
+ rt_free(var);
|
|
|
rt_kprintf("工作时间参数已保存:模式-%d,光控时间-%d,时控开始时间-%d,时控结束时间-%d\n",device_status.timeSwitch,device_status.sunBar,device_status.startBar,device_status.stopBar);
|
|
|
}
|
|
|
else if (strstr(rx_buffer,"saveSystemSet")!=NULL) {
|
|
|
@@ -507,7 +502,8 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
else {
|
|
|
rt_kprintf("参数设置失败!!!\n");
|
|
|
}
|
|
|
- //MA_save();
|
|
|
+ MA_save();
|
|
|
+ rt_free(var);
|
|
|
rt_kprintf("系统设置已保存:收集时间-%d,加热时间-%d,加热温度-%d,音量-%d,自动关屏-%d\n",device_status.clt_time,device_status.heattime,device_status.heatvalue,device_status.vol,device_status.thsp);
|
|
|
}
|
|
|
else if (strstr(rx_buffer,"rtc_h=")!=NULL) {
|
|
|
@@ -556,6 +552,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
else {
|
|
|
rt_kprintf("设置失败!!!\n");
|
|
|
}
|
|
|
+ rt_free(var);
|
|
|
rt_kprintf("数据上传设置:%d\n",device_status.dattim);
|
|
|
}
|
|
|
//光控测试
|
|
|
@@ -581,6 +578,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
else {
|
|
|
rt_kprintf("设置失败!!!\n");
|
|
|
}
|
|
|
+ rt_free(var);
|
|
|
rt_kprintf("震动时间设置:%d\n",device_status.shake_sec);
|
|
|
}
|
|
|
//恢复出厂设置电池
|
|
|
@@ -687,6 +685,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
else if(strstr(rx_buffer,"DisplayPower")!=RT_NULL)
|
|
|
{
|
|
|
HMI_WRITE("sysTest.sysTest_power.txt=\"%s\"",device_status.power);
|
|
|
+// HMI_WRITE("sysTest.switchHeat.val=%d",device_status.heat_status);
|
|
|
}
|
|
|
//立即上传
|
|
|
else if(strstr(rx_buffer,"uploaddata")!=RT_NULL)
|
|
|
@@ -730,7 +729,7 @@ static void HMI_Decode(char *cmd,uint8_t cmd_len)
|
|
|
//入口函数-电机控制及
|
|
|
static void Ctr_Mortor_entry(void* parameter)
|
|
|
{
|
|
|
- rt_uint32_t limit_current = 3000; //推杆电击限制电流1A
|
|
|
+ //rt_uint32_t limit_current = 3000; //推杆电击限制电流1A
|
|
|
rt_uint32_t rtc_err_cnt = 0;
|
|
|
static rt_uint16_t power_current = 0;
|
|
|
static rt_uint16_t num_up_open = 200; //20s
|
|
|
@@ -768,12 +767,13 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
ctr_cangmen_up(OPEN);
|
|
|
num_up_open--;
|
|
|
//如果未工作且上仓门电机电流大于1A,立即停止,记录到Flash,上报预警
|
|
|
- if(atoi(device_status.power)>limit_current)
|
|
|
- {
|
|
|
- ctr_cangmen_up(OFF);
|
|
|
- num_up_open = 200;
|
|
|
- rt_kprintf("*************************上仓门电机打开堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
- }
|
|
|
+ //2022-03-14-add:&&atoi(device_status.power)<8000
|
|
|
+// if(atoi(device_status.power)>limit_current&&atoi(device_status.power)<8000)
|
|
|
+// {
|
|
|
+// ctr_cangmen_up(OFF);
|
|
|
+// num_up_open = 200;
|
|
|
+// rt_kprintf("*************************上仓门电机打开堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
+// }
|
|
|
if (num_up_open == 0)
|
|
|
{
|
|
|
ctr_cangmen_up(OFF);
|
|
|
@@ -784,12 +784,13 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
{
|
|
|
ctr_cangmen_up(CLOSE);
|
|
|
num_up_close --;
|
|
|
- if(atoi(device_status.power)>limit_current)
|
|
|
- {
|
|
|
- ctr_cangmen_up(OFF);
|
|
|
- num_up_close = 200;
|
|
|
- rt_kprintf("************************上仓门电机关闭堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
- }
|
|
|
+ //2022-03-14:&&atoi(device_status.power)<8000
|
|
|
+// if(atoi(device_status.power)>limit_current&&atoi(device_status.power)<8000)
|
|
|
+// {
|
|
|
+// ctr_cangmen_up(OFF);
|
|
|
+// num_up_close = 200;
|
|
|
+// rt_kprintf("************************上仓门电机关闭堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
+// }
|
|
|
|
|
|
if (num_up_close == 0)
|
|
|
{
|
|
|
@@ -805,17 +806,17 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
}
|
|
|
ctr_cangmen_down(OPEN);
|
|
|
num_down_open--;
|
|
|
- if(atoi(device_status.power)>limit_current)
|
|
|
- {
|
|
|
- ctr_cangmen_down(OFF);
|
|
|
- num_down_open = 200;
|
|
|
- rt_kprintf("*************************下仓门电机打开堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
- }
|
|
|
+// if(atoi(device_status.power)>limit_current)
|
|
|
+// {
|
|
|
+// ctr_cangmen_down(OFF);
|
|
|
+// num_down_open = 200;
|
|
|
+// rt_kprintf("*************************下仓门电机打开堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
+// }
|
|
|
//如果关闭仓门1S后检测不到电流增大,则判定为异常
|
|
|
- if (atoi(device_status.power)<(power_current+100)&&num_down_open==190&&device_status.work_status==1) {
|
|
|
- DTU_Write("%s",makeJson_Warn("Down Motor OPEN ERR","device_Down_TG"));
|
|
|
- rt_free(makeJson_Warn("Down Motor OPEN ERR","device_Down_TG"));
|
|
|
- }
|
|
|
+// if (atoi(device_status.power)<(power_current+100)&&num_down_open==190&&device_status.work_status==1) {
|
|
|
+// DTU_Write("%s",makeJson_Warn("Down Motor OPEN ERR","device_Down_TG"));
|
|
|
+// rt_free(makeJson_Warn("Down Motor OPEN ERR","device_Down_TG"));
|
|
|
+// }
|
|
|
if (num_down_open == 0)
|
|
|
{
|
|
|
ctr_cangmen_down(OFF);
|
|
|
@@ -830,17 +831,18 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
}
|
|
|
ctr_cangmen_down(CLOSE);
|
|
|
num_down_close--;
|
|
|
- if(atoi(device_status.power)>limit_current)
|
|
|
- {
|
|
|
- ctr_cangmen_down(OFF);
|
|
|
- num_down_close = 200;
|
|
|
- rt_kprintf("*************************下仓门电机关闭堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
- }
|
|
|
+ //2022-03-14-add:&&atoi(device_status.power)<8000
|
|
|
+// if(atoi(device_status.power)>limit_current&&atoi(device_status.power)<8000)
|
|
|
+// {
|
|
|
+// ctr_cangmen_down(OFF);
|
|
|
+// num_down_close = 200;
|
|
|
+// rt_kprintf("*************************下仓门电机关闭堵转!!!**********************%d\n",atoi(device_status.power));
|
|
|
+// }
|
|
|
//如果关闭仓门1S后检测不到电流增大,则判定为异常
|
|
|
- if (atoi(device_status.power)<(power_current+100)&&num_down_close==190&&device_status.work_status==1) {
|
|
|
- DTU_Write("%s",makeJson_Warn("Down Motor CLOSE ERR","device_Down_TG"));
|
|
|
- rt_free(makeJson_Warn("Down Motor CLOSE ERR","device_Down_TG"));
|
|
|
- }
|
|
|
+// if (atoi(device_status.power)<(power_current+100)&&num_down_close==190&&device_status.work_status==1) {
|
|
|
+// DTU_Write("%s",makeJson_Warn("Down Motor CLOSE ERR","device_Down_TG"));
|
|
|
+// rt_free(makeJson_Warn("Down Motor CLOSE ERR","device_Down_TG"));
|
|
|
+// }
|
|
|
if (num_down_close == 0)
|
|
|
{
|
|
|
ctr_cangmen_down(OFF);
|
|
|
@@ -958,6 +960,8 @@ void Check_ParamConfig(void)
|
|
|
device_status.ds = 1; //设备状态
|
|
|
device_status.version_type = 41; //版本类型
|
|
|
device_status.update_flag = 0;
|
|
|
+ rt_sprintf(device_status.tempture, "26");
|
|
|
+ rt_sprintf(device_status.humidity, "31");
|
|
|
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("stime", &device_status.clt_time, sizeof(device_status.clt_time));
|
|
|
@@ -975,6 +979,8 @@ void Check_ParamConfig(void)
|
|
|
ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
|
ef_set_env_blob("dattim",&device_status.dattim,sizeof(device_status.dattim)); //上传时间
|
|
|
ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
+ ef_set_env_blob("env_t",&device_status.tempture,sizeof(device_status.tempture)); //温度
|
|
|
+ ef_set_env_blob("env_h",&device_status.humidity,sizeof(device_status.humidity)); //湿度
|
|
|
if(device_status.version_type==1)
|
|
|
{
|
|
|
sprintf(device_status.driver, "%s",VERSION_ZP);
|
|
|
@@ -1004,7 +1010,7 @@ void Check_ParamConfig(void)
|
|
|
ef_get_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch), NULL); //模式
|
|
|
ef_get_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar), NULL); //光控时间
|
|
|
ef_get_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime), NULL); //加热时间
|
|
|
- ef_get_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue), NULL); //加热温度
|
|
|
+ ef_get_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue), NULL); //加热温度
|
|
|
ef_get_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws), NULL); //震动开关
|
|
|
ef_get_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec), NULL); //震动时间
|
|
|
ef_get_env_blob("tph", &device_status.tph, sizeof(device_status.tph), NULL); //高温保护
|
|
|
@@ -1012,13 +1018,15 @@ void Check_ParamConfig(void)
|
|
|
ef_get_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim), NULL); //数据上传间隔
|
|
|
ef_get_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp), NULL); //熄屏时间
|
|
|
ef_get_env_blob("passWord",&device_status.passWord,sizeof(device_status.passWord),NULL); //密码
|
|
|
- ef_get_env_blob("imei",&device_status.imei,sizeof(device_status.imei),NULL); //IMEI
|
|
|
- ef_get_env_blob("iccid",&device_status.iccid,sizeof(device_status.iccid),NULL); //ICCID
|
|
|
+ ef_get_env_blob("imei",&device_status.imei,sizeof(device_status.imei),NULL); //IMEI
|
|
|
+ ef_get_env_blob("iccid",&device_status.iccid,sizeof(device_status.iccid),NULL); //ICCID
|
|
|
ef_get_env_blob("lat",&device_status.lat,sizeof(device_status.lat),NULL);
|
|
|
ef_get_env_blob("lng",&device_status.lng,sizeof(device_status.lng),NULL);
|
|
|
ef_get_env_blob("ds",&device_status.ds,sizeof(device_status.ds),NULL); //开关机状态
|
|
|
+ ef_get_env_blob("env_t",&device_status.tempture,sizeof(device_status.tempture),NULL); //环境温度
|
|
|
+ ef_get_env_blob("env_h",&device_status.humidity,sizeof(device_status.humidity),NULL); //环境湿度
|
|
|
ef_get_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type),NULL); //版本类型
|
|
|
- ef_get_env_blob("driver_bl",&device_status.driver_bl,sizeof(device_status.driver_bl),NULL); //BL版本号 进BL的时候存储到FLASH
|
|
|
+ ef_get_env_blob("driver_bl",&device_status.driver_bl,sizeof(device_status.driver_bl),NULL); //BL版本号 进BL的时候存储到FLASH
|
|
|
device_status.light_over_tim = device_status.sunBar * 3600; //光控计数
|
|
|
device_status.work_done = 0;
|
|
|
//工作完成标志位
|
|
|
@@ -1053,6 +1061,8 @@ void Check_ParamConfig(void)
|
|
|
}
|
|
|
else if (device_status.version_type==6)
|
|
|
{
|
|
|
+ rt_pin_mode(HK_5000W_P, PIN_MODE_OUTPUT);
|
|
|
+ rt_pin_write(HK_5000W_P,ON);
|
|
|
rt_sprintf(device_status.driver, "%s",VERSION_XCT);
|
|
|
}
|
|
|
if(device_status.iccid[0]!=8)
|
|
|
@@ -1080,6 +1090,7 @@ void Check_ParamConfig(void)
|
|
|
rt_kprintf("thsp:%d\n", device_status.thsp);
|
|
|
rt_kprintf("密码:%d\n",device_status.passWord);
|
|
|
rt_kprintf("数据上传间隔:%d\n",device_status.dattim);
|
|
|
+ rt_kprintf("温湿度数据:%d-%d\n",atoi(device_status.tempture),atoi(device_status.humidity));
|
|
|
}
|
|
|
rt_kprintf("当前时间:%04d-%02d-%02d %02d:%02d:%02d\n",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
//RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
|
|
|
@@ -1101,7 +1112,9 @@ void Check_ParamConfig(void)
|
|
|
Control_clear();
|
|
|
dtu_data_play();
|
|
|
sht30_collect();
|
|
|
+#if SENSOR_EN==1
|
|
|
mb_master_samlpe();
|
|
|
+#endif
|
|
|
uint16_t connect_num=0;
|
|
|
//等待联网,
|
|
|
while(atoi(device_status.net)==1)
|
|
|
@@ -1124,6 +1137,7 @@ void Check_ParamConfig(void)
|
|
|
if(tm.tm_year>=2021)
|
|
|
break;
|
|
|
}
|
|
|
+ if(device_status.version_type==6) device_status.timeSwitch = 1;
|
|
|
DTU_Write("%s",makeJson_Warn("turnon", "device_stm32"));
|
|
|
}
|
|
|
}
|