| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094 |
- #include <control.h>
- /*
- * Copyright (c) 2006-2020, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2020-05-30 Administrator the first version
- * 2025-06-26 RTC闹钟使用定时开启和关闭路由器供电
- */
- #include "beep.h"
- #include "hmi.h"
- #include "easyflash.h"
- #include "stdio.h"
- #include "sound.h"
- #include "dtu_uart2.h"
- #include "sht30_collect.h"
- #include <user_mb_app.h>
- #include <selfcheck.h>
- #define DBG_ENABLE
- #define DBG_COLOR
- #define DBG_TAG "control"
- #define DBG_LEVEL DBG_LOG
- #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
- //工作检测
- #define WORK_CHECK_THREAD_PRIORITY 23 //线程优先级
- #define WORK_CHECK_THREAD_STACK_SIZE 1024 //栈大小
- #define WORK_CHECK_THREAD_TIMESLICE 5 //时间片
- //工作流程
- #define WORK_LOOP_THREAD_PRIORITY 12 //线程优先级
- #define WORK_LOOP_THREAD_STACK_SIZE 2048 //栈大小
- #define WORK_LOOP_THREAD_TIMESLICE 5 //时间片
- #define PWM_EN 1 //0关闭,1-打开
- //设备状态表结构体
- Device_Status_typedef device_status;
- rt_thread_t tid_workloop = RT_NULL;
- rt_thread_t tid_wkstc = RT_NULL;
- rt_thread_t tid_ctr = RT_NULL;
- rt_thread_t tid_heat = RT_NULL;
- rt_thread_t tid_485_play = RT_NULL;
- rt_event_t event_485_play;
- extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
- /***************************************************************************/
- int thread_delete_workloop(void)
- {
- rt_err_t result;
- if(tid_workloop!=RT_NULL)
- {
- result = rt_thread_delete(tid_workloop);
- }
- return result;
- }
- int thread_restart_workloop(void)
- {
- rt_err_t result;
- result = Work_Loop_Task();
- return result;
- }
- /**************************1.0定制2000W*************************************/
- uint8_t ctr_Fan_PUT(uint8_t status_ws)
- {
- rt_pin_mode(FAN_P, PIN_MODE_OUTPUT);
- if(status_ws==ON)
- {
- rt_pin_write(FAN_P,ON);
- }
- else {
- rt_pin_write(FAN_P, OFF);
- }
- return 0;
- }
- uint8_t ctr_Fan_IN(uint8_t status_ws)
- {
- rt_pin_mode(FAN_I, PIN_MODE_OUTPUT);
- if(status_ws==ON)
- {
- rt_pin_write(FAN_I,ON);
- }
- else {
- rt_pin_write(FAN_I, OFF);
- }
- return 0;
- }
- /****************************5.0***********************************/
- void ctr_turnv5(void)
- {
- rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
- rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
- // 转出
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,OFF);
- rt_thread_mdelay(300);
- //停止
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- rt_thread_mdelay(300);
- //转入
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,ON);
- rt_thread_mdelay(300);
- //停止
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- rt_thread_mdelay(300);
- }
- /*************************吸虫塔*********************************/
- //吸虫电机
- uint8_t ctr_Motor_xichong(uint8_t status_ws)
- {
- rt_pin_mode(MOTOR1_CTR_PIN, PIN_MODE_OUTPUT);
- if(status_ws==ON)
- {
- rt_pin_write(MOTOR1_CTR_PIN,ON);
- }
- else {
- rt_pin_write(MOTOR1_CTR_PIN, OFF);
- }
- return 0;
- }
- uint8_t ctr_Camera_Power(uint8_t status_ws)
- {
- rt_pin_mode(MOTOR1_CTR_PIN, PIN_MODE_OUTPUT);
- if(status_ws==ON)
- {
- rt_pin_write(MOTOR1_CTR_PIN,ON);
- }
- else {
- rt_pin_write(MOTOR1_CTR_PIN, OFF);
- }
- return 0;
- }
- //吸附电机
- uint8_t ctr_Motor_xifu(uint8_t status_ws)
- {
- rt_pin_mode(MOTOR2_CTR_PIN, PIN_MODE_OUTPUT);
- if(status_ws==ON)
- {
- rt_pin_write(MOTOR2_CTR_PIN,ON);
- }
- else {
- rt_pin_write(MOTOR2_CTR_PIN, OFF);
- }
- return 0;
- }
- //工作任务流程
- void WorkTask_XCT(void)
- {
- while(device_status.work_status==1&&device_status.ds==1)
- {
- ctr_Motor_xifu(ON);
- //打开相机供电
- ctr_Camera_Power(ON);
- //ctr_Heat(ON); //清洁风机
- uint32_t photo_fre = 0;
- photo_fre = device_status.dattim * 60;
- while(photo_fre!=0)
- {
- photo_fre --;
- rt_thread_delay(1000);
- LOG_I("收集中,等待开始拍照:%d",photo_fre);
- }
- //卷带
- ctr_JD_Clear(OFF);
- //拍照
- HK_TakePhoto();
- //关闭吸附风机
- ctr_Motor_xifu(OFF);
- //关闭相机供电
- //ctr_Heat(OFF);
- ctr_Camera_Power(OFF);
- //卷带
- ctr_JD_Clear(ON);
- // rt_thread_delay(1000);
- // ctr_JD_Clear(ON);
- //震动
- Motor_shake(ON, device_status.shake_sec);
- }
- //关闭风机
- ctr_Motor_xichong(OFF);
- ctr_Motor_xifu(OFF);
- LOG_I("不在工作时间,未工作!!!");
- }
- /**********************************************************************/
- /*光控*/
- uint8_t In_Light_status(void)
- {
- rt_pin_mode(LIGHT_PIN,PIN_MODE_INPUT);
- return rt_pin_read(LIGHT_PIN);
- }
- /*雨控*/
- uint8_t In_Rain_status(void)
- {
- rt_pin_mode(RAIN_PIN,PIN_MODE_INPUT);
- return rt_pin_read(RAIN_PIN);
- }
- /*加热*/
- uint8_t ctr_Heat(uint8_t status_heat)
- {
- device_status.heat_status = status_heat;
- rt_pin_mode(Heat_Pin, PIN_MODE_OUTPUT);
- rt_pin_write(Heat_Pin,status_heat);
- return status_heat;
- }
- /*制冷*/
- uint8_t ctr_Cold(uint8_t status_cold)
- {
- device_status.cold_status = status_cold;
- rt_pin_mode(Cold_Pin, PIN_MODE_OUTPUT);
- rt_pin_write(Cold_Pin,status_cold);
- return status_cold;
- }
- /*相机供电*/
- void ctr_photo(uint8_t status_photo)
- {
- LOG_W("ctr_photo:%d",status_photo);
- rt_pin_mode(PHOTO,PIN_MODE_OUTPUT);
- rt_pin_write(PHOTO,status_photo);
- }
- /*************************************************
- Function: ctr_Cool_Fan
- Description: 散热风机的开关
- Calls:
- Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
- Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
- Input: ON-开,OFF-关
- Output: NULL
- Return: ON-开,OFF-关
- Others: NULL
- *************************************************/
- uint8_t ctr_Cool_Fan(uint8_t status_cool)
- {
- device_status.cool_fan_status = status_cool;
- rt_pin_mode(Cool_Fan_L, PIN_MODE_OUTPUT);
- rt_pin_mode(Cool_Fan_R, PIN_MODE_OUTPUT);
- if(status_cool==OFF)
- {
- rt_pin_write(Cool_Fan_L,OFF);
- rt_pin_write(Cool_Fan_R,OFF);
- }
- if(status_cool==ON)
- {
- rt_pin_write(Cool_Fan_L,ON);
- rt_pin_write(Cool_Fan_R,OFF);
- }
- return device_status.cool_fan_status;
- }
- /*************************************************
- Function: ctr_Collect_Fan
- Description: 采集风机的开关
- Calls:
- Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
- Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
- Input: ON-开,OFF-关
- Output: NULL
- Return: ON-开,OFF-关
- Others: NULL
- *************************************************/
- uint8_t ctr_Collect_Fan(uint8_t status_collect)
- {
- device_status.collect_fan_status = status_collect;
- rt_pin_mode(Collect_Fan, PIN_MODE_OUTPUT);
- if(status_collect==OFF)
- {
- rt_pin_write(Collect_Fan,OFF);
- }
- if(status_collect==ON)
- {
- rt_pin_write(Collect_Fan,ON);
- }
- return device_status.collect_fan_status;
- }
- /*************************************************
- Function: ctr_develop
- Description: 培养载玻片孢子
- Calls:
- Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
- Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
- Input: v=0(复位) v=90转90度
- Output: NULL
- Return: NULL
- Others: NULL
- *************************************************/
- /*上仓门*/
- uint8_t ctr_cangmen_up(uint8_t status_up)
- {
- rt_pin_mode(Collect_fan_R, PIN_MODE_OUTPUT);
- rt_pin_mode(Collect_fan_L, PIN_MODE_OUTPUT);
- if(status_up==OFF)
- {
- rt_pin_write(Collect_fan_R,ON);
- rt_pin_write(Collect_fan_L,ON);
- device_status.ctr_up_motor = 0;
- rt_thread_delay(1000);
- }
- if(status_up==OPEN)
- {
- device_status.up_status = 1;
- rt_pin_write(Collect_fan_R,OFF);
- rt_pin_write(Collect_fan_L,OFF);
- #if PCB_V1 == 1
- rt_pin_write(Collect_fan_R,ON);
- rt_pin_write(Collect_fan_L,OFF);
- #else
- rt_pin_write(Collect_fan_R,OFF);
- rt_pin_write(Collect_fan_L,ON);
- #endif
- }
- if(status_up==CLOSE)
- {
- device_status.up_status = 0;
- rt_pin_write(Collect_fan_R,OFF);
- rt_pin_write(Collect_fan_L,OFF);
- #if PCB_V1 == 1
- rt_pin_write(Collect_fan_R,OFF);
- rt_pin_write(Collect_fan_L,ON);
- #else
- rt_pin_write(Collect_fan_R,ON);
- rt_pin_write(Collect_fan_L,OFF);
- #endif
- }
- return device_status.up_status;
- }
- //下仓门
- uint8_t ctr_cangmen_down(uint8_t status_down)
- {
- rt_pin_mode(C_DOWN_R, PIN_MODE_OUTPUT);
- rt_pin_mode(C_DOWN_L, PIN_MODE_OUTPUT);
- if(status_down==OFF)
- {
- rt_pin_write(C_DOWN_R,ON);
- rt_pin_write(C_DOWN_L,ON);
- device_status.ctr_down_motor = 0;
- rt_thread_delay(1000);
- }
- if(status_down==OPEN)
- {
- device_status.down_status = 1;
- rt_pin_write(C_DOWN_R,OFF);
- rt_pin_write(C_DOWN_L,OFF);
- rt_pin_write(C_DOWN_R,ON);
- rt_pin_write(C_DOWN_L,OFF);
- }
- if(status_down==CLOSE)
- {
- device_status.down_status = 0;
- rt_pin_write(C_DOWN_R,OFF);
- rt_pin_write(C_DOWN_L,OFF);
- rt_pin_write(C_DOWN_R,OFF);
- rt_pin_write(C_DOWN_L,ON);
- }
- return device_status.down_status;
- }
- //镇流器
- uint8_t ctr_lamp(uint8_t status_lamp,uint8_t lamp_num)
- {
- rt_pin_mode(LAMP_SW, PIN_MODE_OUTPUT);
- rt_pin_mode(LAMP_1_SW, PIN_MODE_OUTPUT);
- rt_pin_mode(LAMP_2_SW, PIN_MODE_OUTPUT);
- if(status_lamp==ON)
- {
- switch(lamp_num){
- case 1:
- rt_pin_write(LAMP_SW,ON);
- device_status.lamp_status = status_lamp;
- break;
- case 2:
- rt_pin_write(LAMP_1_SW,ON);
- device_status.lamp_status = status_lamp;
- break;
- case 3:
- rt_pin_write(LAMP_2_SW,ON);
- device_status.lamp_status = status_lamp;
- break;
- default:
- break;
- }
- }
- else {
- switch(lamp_num){
- case 1:
- rt_pin_write(LAMP_SW,OFF);
- device_status.lamp_status = status_lamp;
- break;
- case 2:
- rt_pin_write(LAMP_1_SW,OFF);
- device_status.lamp1_status = status_lamp;
- break;
- case 3:
- rt_pin_write(LAMP_2_SW,OFF);
- device_status.lamp2_status = status_lamp;
- break;
- default:
- break;
- }
- }
- return device_status.lamp_status;
- }
- //震动电机
- uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec)
- {
- static rt_uint16_t shake_i = 0;
- if(device_status.dtype==7&&shake_sec!=0)
- DTU_Write("drop");
- rt_pin_mode(SHAKE_SW, PIN_MODE_OUTPUT);
- #if 0
- rt_pin_write(SHAKE_SW,ON);
- return 0;
- #endif
- if(status_shake==ON&&device_status.shake_ws==1)
- {
- if(device_status.dtype==3)
- {
- while(shake_sec--)
- {
- rt_pin_write(SHAKE_SW,ON);
- rt_thread_delay(50);
- rt_pin_write(SHAKE_SW,OFF);
- rt_thread_delay(1000);
- }
- }
- if(device_status.dtype==7) rt_thread_delay(shake_sec*1000);
- rt_pin_write(SHAKE_SW,OFF);
- HMI_WRITE("cangWei.switchShake.val=%d",0);
- }
- else
- {
- rt_pin_write(SHAKE_SW,OFF);
- HMI_WRITE("cangWei.switchShake.val=%d",0);
- }
- if(device_status.dtype==7)
- HMI_WRITE("sysTest.switchDrop.val=%d",OFF);
- return status_shake;
- }
- //补光
- uint8_t ctr_led(uint8_t status_led)
- {
- rt_pin_mode(LED_SW, PIN_MODE_OUTPUT);
- if(device_status.version_type==6)
- rt_pin_mode(LED_P, PIN_MODE_OUTPUT);
- if(status_led==ON)
- {
- rt_pin_write(LED_SW,ON);
- if(device_status.version_type==6)
- rt_pin_write(LED_P,ON);
- }
- else if(status_led==OFF){
- rt_pin_write(LED_SW,OFF);
- if(device_status.version_type==6)
- rt_pin_write(LED_P,OFF);
- }
- return status_led;
- }
- /*************************************************
- Function: ctr_turn
- Description: 转盘驱动
- Calls:
- Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
- Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
- Input: v=0(复位) v=90转90度
- Output: NULL
- Return: NULL
- Others: NULL
- *************************************************/
- void ctr_turn(uint8_t v,uint8_t sta)
- {
- DTU_Write("turn.mp3");
- LOG_I("================v===============:%d",v);
- rt_uint16_t turn_cnt = 0;
- rt_pin_mode(TURN_ZP_R, PIN_MODE_OUTPUT);
- rt_pin_mode(TURN_ZP_L, PIN_MODE_OUTPUT);
- rt_pin_mode(LIMIT_0, PIN_MODE_INPUT);
- rt_pin_mode(LIMIT_90, PIN_MODE_INPUT);
- //if(v==0&&rt_pin_read(LIMIT_0)==0) return; //如果在初始位置,则不再往下执行
- while(rt_pin_read(LIMIT_0)==0||rt_pin_read(LIMIT_90)==0)
- {
- rt_pin_write(TURN_ZP_R, ON);
- rt_pin_write(TURN_ZP_L, OFF);
- //Motor_shake(ON,0);
- turn_cnt ++;
- rt_thread_delay(100);
- if(turn_cnt==1000)
- {
- turn_cnt = 0;
- rt_pin_write(TURN_ZP_R, OFF);
- rt_pin_write(TURN_ZP_L, OFF);
- //Motor_shake(OFF,0);
- char *turn_warn =makeJson_Warn("未检测到限位", "转盘");
- DTU_Write("%s",turn_warn);
- rt_free(turn_warn);
- break;
- }
- }
- turn_cnt = 0;
- while(v==0&&rt_pin_read(LIMIT_0)==1)
- {
- rt_pin_write(TURN_ZP_R, ON);
- rt_pin_write(TURN_ZP_L, OFF);
- Motor_shake(ON,0);
- rt_thread_delay(200); //10 to 100
- turn_cnt ++;
- if(turn_cnt==300) //6000 to 600
- {
- turn_cnt = 0;
- // rt_pin_write(TURN_ZP_R, OFF);
- // rt_pin_write(TURN_ZP_L, OFF);
- // char *turn_warn =makeJson_Warn("超时", "转盘复位");
- // DTU_Write("%s",turn_warn);
- // rt_free(turn_warn);
- break;
- }
- }
- while(v==0&&rt_pin_read(LIMIT_0)==1)
- {
- rt_pin_write(TURN_ZP_R, ON);
- rt_pin_write(TURN_ZP_L, OFF);
- //Motor_shake(ON,0);
- rt_thread_delay(50); //10 to 50
- turn_cnt ++;
- if(turn_cnt==10) //6000 to 1200
- {
- turn_cnt = 0;
- rt_pin_write(TURN_ZP_R, OFF);
- rt_pin_write(TURN_ZP_L, OFF);
- //Motor_shake(OFF,0);
- char *turn_warn =makeJson_Warn("超时", "转盘复位");
- DTU_Write("%s",turn_warn);
- rt_free(turn_warn);
- break;
- }
- }
- turn_cnt = 0;
- while(v==90&&rt_pin_read(LIMIT_90)==1)
- {
- rt_pin_write(TURN_ZP_R, ON);
- rt_pin_write(TURN_ZP_L, OFF);
- //Motor_shake(ON,0);
- rt_thread_delay(200);
- turn_cnt ++;
- if(turn_cnt==150)
- {
- turn_cnt = 0;
- // rt_pin_write(TURN_ZP_R, OFF);
- // rt_pin_write(TURN_ZP_L, OFF);
- // char *turn_warn =makeJson_Warn("超时", "转盘");
- // DTU_Write(turn_warn);
- // rt_free(turn_warn);
- break;
- }
- }
- while(v==90&&rt_pin_read(LIMIT_90)==1)
- {
- // rt_pin_write(TURN_ZP_R, ON);
- // rt_pin_write(TURN_ZP_L, OFF);
- Motor_shake(ON,0);
- rt_thread_delay(50);
- turn_cnt ++;
- if(turn_cnt==10)
- {
- turn_cnt = 0;
- rt_pin_write(TURN_ZP_R, OFF);
- rt_pin_write(TURN_ZP_L, OFF);
- //Motor_shake(OFF,0);
- char *turn_warn =makeJson_Warn("超时", "转盘");
- DTU_Write(turn_warn);
- rt_free(turn_warn);
- break;
- }
- }
- if(sta!=0)
- {
- //保存位置
- device_status.run_sta = sta;
- ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
- }
- turn_cnt = 0;
- rt_pin_write(TURN_ZP_R, OFF);
- rt_pin_write(TURN_ZP_L, OFF);
- Motor_shake(OFF,0);
- HMI_WRITE("cangWei.rotateFlag.val=0");
- }
- /*
- *
- * */
- void ctr_Motor_Driver_Power(uint8_t status_ws)
- {
- rt_pin_mode(SHAKE_SW, PIN_MODE_OUTPUT);
- rt_pin_write(SHAKE_SW, status_ws);
- }
- /*************************************************
- Function: ctr_Motor_Driver
- Description: 步进电机驱动
- Calls:
- Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
- Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
- Input: 50000000
- Output: NULL
- Return: shake_sec
- Others: NULL
- *************************************************/
- void ctr_Motor_Driver(uint8_t EN,uint8_t DIR,rt_uint32_t pwm,rt_uint32_t time_out)
- {
- beep_init();
- rt_pin_mode(LIMIT_UP, PIN_MODE_INPUT);
- rt_pin_mode(LIMIT_DOWN, PIN_MODE_INPUT);
- rt_pin_mode(Motor_EN, PIN_MODE_OUTPUT);
- rt_pin_mode(Motor_DIR, PIN_MODE_OUTPUT);
- rt_pin_write(Motor_EN, EN);
- rt_pin_write(Motor_DIR, DIR);
- beep_set(pwm, pwm/2); //200kzh - 50%
- // while(DIR==1&&rt_pin_read(LIMIT_DOWN)==1)
- // {
- // if(time_out==0)
- // {
- // break;
- // }
- // rt_thread_delay(50);
- // time_out --;
- // }
- // while(DIR==0&&rt_pin_read(LIMIT_UP)==1)
- // {
- // if(time_out==0)
- // {
- // break;
- // }
- // rt_thread_delay(50);
- // time_out --;
- // }
- //rt_pin_write(Motor_EN, OFF);
- //if(device_status.autotakepic==0)
- //ctr_lamp(OFF, 1);
- // beep_set(0, 0); //200kzh - 50%
- rt_thread_delay(50);
- }
- /*************************************************
- Function: ctr_Petroleum_jelly
- Description: 涂凡士林
- Calls:
- Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
- Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
- Input: NULL
- Output: NULL
- Return: NULL
- Others: NULL
- *************************************************/
- void ctr_Petroleum_jelly(rt_uint32_t delay)
- {
- beep_init();
- pwm_on(2,50000);
- rt_thread_delay(delay*1000);
- pwm_off(2,0);
- rt_thread_delay(1000);
- pwm_on(3, 50000);
- rt_thread_delay(delay*1000);
- pwm_off(3,0);
- device_status.fsl_sw = 0;
- }
- //1.0转仓
- void turnzp(void)
- {
- static uint16_t turn_timeout = 0;
- // rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
- // rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
- rt_pin_mode(CLEAR_R_LIMIT,PIN_MODE_INPUT);
- // rt_pin_write(CLEAR_R,OFF);
- // rt_pin_write(CLEAR_L,OFF);
- while(rt_pin_read(CLEAR_R_LIMIT)==0)
- {
- rt_thread_delay(20);
- while(rt_pin_read(CLEAR_R_LIMIT)==0)
- {
- ctr_Collect_Fan(ON);
- rt_thread_delay(50);
- turn_timeout++;
- if(turn_timeout==600)
- {
- LOG_E("检测不到限位,电机强制停止");
- char *ctr_zp_limit_warn =makeJson_Warn("电流不足/限位超时","转盘电机");
- DTU_Write("%s",ctr_zp_limit_warn);
- rt_free(ctr_zp_limit_warn);
- break;
- }
- }
- break;
- }
- while(rt_pin_read(CLEAR_R_LIMIT)==1)
- {
- rt_thread_delay(20);
- while(rt_pin_read(CLEAR_R_LIMIT)==1)
- {
- // rt_pin_write(CLEAR_R,ON);
- // rt_pin_write(CLEAR_L,OFF);
- ctr_Collect_Fan(ON);
- rt_thread_delay(50);
- turn_timeout++;
- if(turn_timeout==600)
- {
- LOG_E("检测不到离开限位,电机或者限位开关异常,电机强制停止");
- char *ctr_zp_limit_warn =makeJson_Warn("检测不到离开限位,电机未启动或者限位开关故障","转盘电机");
- DTU_Write("%s",ctr_zp_limit_warn);
- rt_free(ctr_zp_limit_warn);
- break;
- }
- }
- break;
- }
- while(rt_pin_read(CLEAR_R_LIMIT)==0)
- {
- rt_thread_delay(20);
- if(rt_pin_read(CLEAR_R_LIMIT)==0)
- {
- // rt_pin_write(CLEAR_R,OFF);
- // rt_pin_write(CLEAR_L,OFF);
- ctr_Collect_Fan(OFF);
- break;
- }
- else {
- break;
- }
- }
- ctr_Collect_Fan(OFF);
- turn_timeout = 0;
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- rt_thread_delay(1000);
- }
- //清扫-常闭型限位开关
- //新结构使用推杆电机做清扫
- uint8_t ctr_clear(uint16_t status_clear)
- {
- static uint16_t clear_num = 0;
- #if PWM_EN == 0
- rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
- rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
- #endif
- rt_pin_mode(CLEAR_R_LIMIT,PIN_MODE_INPUT);
- rt_pin_mode(CLEAR_L_LIMIT,PIN_MODE_INPUT);
- /*************************************************************外接清扫
- rt_pin_mode(POWER_CLEAR, PIN_MODE_OUTPUT);
- rt_pin_write(POWER_CLEAR,ON);
- rt_thread_delay(1000*100);
- rt_pin_write(POWER_CLEAR,OFF);
- ************************************************************/
- //停止
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- if(status_clear==OFF||Read_Real_Voltage()/100<12) return 0;
- rt_thread_delay(100);
- //如果清扫位置在中间
- while(rt_pin_read(CLEAR_R_LIMIT)==0&&rt_pin_read(CLEAR_L_LIMIT)==0)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,OFF);
- #else
- Motor_Qingsao_R_PWM(ON);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_thread_delay(50);
- clear_num++;
- //已到达检测位置
- if(rt_pin_read(CLEAR_L_LIMIT)==1||rt_pin_read(CLEAR_R_LIMIT)==1)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_thread_delay(2000);
- break;
- }
- if(clear_num>=status_clear||atoi(device_status.power)>2000||(Read_Real_Voltage()/100)<12)
- {
- rt_kprintf("Clear Motor ERR:%d",atoi(device_status.power));
- //DTU_Write("%s",makeJson_Warn("Clear Motor ERR","device"));
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_free(makeJson_Warn("Clear Motor ERR","device"));
- if(Read_Real_Voltage()/100<12)
- {
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.val=%d",0);
- device_status.clear_status = 0;
- return 0;
- }
- break;
- }
- }
- clear_num = 0;
- //如果清扫位置在左侧
- while(rt_pin_read(CLEAR_R_LIMIT)==0)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,OFF);
- #else
- Motor_Qingsao_R_PWM(ON);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_thread_delay(50);
- clear_num++;
- if(clear_num>=status_clear||atoi(device_status.power)>2000||(Read_Real_Voltage()/100)<12)
- {
- rt_kprintf("Clear Motor ERR:%d",atoi(device_status.power));
- //DTU_Write("%s",makeJson_Warn("Clear Motor ERR","device"));
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_free(makeJson_Warn("Clear Motor ERR","device"));
- if(Read_Real_Voltage()/100<12)
- {
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.val=%d",0);
- device_status.clear_status = 0;
- return 0;
- }
- break;
- }
- }
- clear_num = 0;
- while(rt_pin_read(CLEAR_L_LIMIT)==1||rt_pin_read(CLEAR_R_LIMIT)==1||(Read_Real_Voltage()/100)<12)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- if(Read_Real_Voltage()/100<12)
- {
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.val=%d",0);
- device_status.clear_status = 0;
- return 0;
- }
- rt_thread_delay(2000);
- break;
- }
- while(rt_pin_read(CLEAR_L_LIMIT)==0)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(ON);
- #endif
- rt_thread_delay(50);
- clear_num++;
- if(clear_num>=status_clear||atoi(device_status.power)>2000||(Read_Real_Voltage()/100)<12)
- {
- rt_kprintf("Clear Motor ERR:%d",atoi(device_status.power));
- char * Clear_ERR = makeJson_Warn("Clear Motor ERR","device");
- //DTU_Write("%s",Clear_ERR);
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_free(Clear_ERR);
- if(Read_Real_Voltage()/100<12)
- {
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.val=%d",0);
- device_status.clear_status = 0;
- return 0;
- }
- break;
- }
- }
- while(rt_pin_read(CLEAR_L_LIMIT)==1||rt_pin_read(CLEAR_R_LIMIT)==1)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- rt_thread_delay(2000);
- break;
- }
- while(rt_pin_read(CLEAR_L_LIMIT)==1&&rt_pin_read(CLEAR_R_LIMIT)==1)
- {
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- if(device_status.version_type==41)
- {
- rt_kprintf("Clear Motor Limit Not Access:%d",atoi(device_status.power));
- char * Clear_ERR = makeJson_Warn("Clear Motor Limit Not Access","device");
- //DTU_Write("%s",Clear_ERR);
- rt_free(Clear_ERR);
- }
- return 0;
- }
- clear_num = 0;
- rt_thread_delay(2000);
- #if PWM_EN == 0
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- #else
- Motor_Qingsao_R_PWM(OFF);
- Motor_Qingsao_L_PWM(OFF);
- #endif
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.val=%d",0);
- device_status.clear_status = 0;
- return 1;
- }
- //路由器供电
- void ctr_router(uint8_t status_router)
- {
- LOG_W("ctr_router:%d",status_router);
- rt_pin_mode(ROUTER, PIN_MODE_OUTPUT);
- //rt_pin_mode(POWER_CLEAR, PIN_MODE_OUTPUT);
- if(status_router==ON)
- {
- rt_pin_write(ROUTER,ON);
- }
- else {
- rt_pin_write(ROUTER,OFF);
- }
- }
- void ctr_Motor_OP_3(uint8_t sw)
- {
- rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
- rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
- if(sw==ON)
- {
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,OFF);
- }else {
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,ON);
- }
- }
- //DTU,RTU供电
- void ctr_RTU_DTU(uint8_t status_rtu)
- {
- rt_pin_mode(RTU_DTU, PIN_MODE_OUTPUT);
- if(status_rtu==ON)
- {
- rt_pin_write(RTU_DTU,ON);
- }
- else
- {
- LOG_W("RTU电源复位!!!");
- rt_pin_write(RTU_DTU,OFF);
- }
- }
- //海康拍照
- void Hk_Take_io(void)
- {
- rt_pin_mode(HK_TAKE, PIN_MODE_OUTPUT);
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT);
- rt_pin_write(HK_TAKE, 1);
- rt_pin_write(HK_IO, 0);
- if(device_status.dtype==3)
- Beep_Tip(1000);
- if(device_status.dtype==7)
- rt_thread_mdelay(1000);
- rt_pin_write(HK_TAKE, 0);
- rt_pin_write(HK_IO, 1);
- }
- void calorstat(uint16_t heat_time)
- {
- //uint8_t heat_up_cnt = 0;
- uint16_t n = 0;
- uint16_t delay_heat = 60;
- FlagStatus heat_flg = RESET;
- device_status.heat_time_min = 0;
- device_status.run_sta = device_status.heattem; //初始化加热实时温度
- ctr_Heat(ON);
- // UpLoad_Data(); //开始加热时的第一条数据
- //恒温模式
- for(n=0;n < heat_time;n++)
- {
- if(device_status.heattem>device_status.heatvalue&&heat_flg==RESET)
- {
- heat_flg = SET;
- ctr_Heat(OFF);
- while(delay_heat!=0)
- {
- device_status.C01 &= ~(1<<1); //加热 正常
- delay_heat --;
- 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;
- }
- }
- delay_heat = 60;
- //跳出FOR循环
- n = n + 60;
- }
- if(device_status.heattem>device_status.run_sta + 1){
- device_status.run_sta = device_status.heattem;
- }
- if(device_status.heattem < (device_status.heatvalue - 5)&&heat_flg == SET)
- {
- //device_status.run_sta = device_status.heattem;
- ctr_Heat(ON);
- }
- else if (device_status.heattem>=device_status.heatvalue&&heat_flg==SET)
- {
- // if(heat_up_cnt==0)
- // {
- // UpLoad_Data(); //加热到设定温度的数据
- // heat_up_cnt = 1;
- // }
- //device_status.run_sta = device_status.heattem;
- ctr_Heat(OFF);
- }
- if((n % 60)==0)
- {
- device_status.heat_time_min = device_status.heat_time_min + 1;
- if(device_status.heat_time_min % 5 == 0) //加热5分钟温度低于50,判定加热故障
- {
- if(device_status.heattem<50) {
- device_status.C01 |= (1 << 1); // 第1位变为1,加热故障
- }else {
- device_status.C01 &= ~(1<<1); //加热 正常
- }
- }
- }
- //如果触发异常退出加热
- if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
- {
- rt_thread_delay(1000);
- if(device_status.bat_status == 1)
- {
- rt_kprintf("============================触发异常退出加热==========================");
- ctr_lamp(OFF,1);
- ctr_Heat(OFF);
- break;
- }
- }
- if(device_status.timeSwitch==0&&device_status.sun_status==1)
- {
- ctr_Heat(OFF);
- rt_kprintf("异常退出!!!\n");
- break;
- }
- rt_thread_delay(1000);
- rt_kprintf("=======正在加热======:%d-%d\n",n,heat_time);
- HMI_WRITE("workSta.g0.txt=\"正在加热!!!:%d-%d\"",n,heat_time);
- }
- ctr_Heat(OFF);
- //UpLoad_Data(); //加热结束的数据
- }
- //初始化所有控制驱动,关闭
- void HardWare_Init(uint8_t boot)
- {
- Beep_Tip(200);
- //关闭上仓门
- ctr_cangmen_up(OFF);
- if(device_status.dtype==3){
- //关闭下仓门电机
- ctr_cangmen_down(OFF);
- }
- //关闭镇流器
- if(device_status.autotakepic==0)
- ctr_lamp(OFF,1);
- //关闭震动电机
- ctr_shake(OFF,0);
- //关闭加热
- ctr_Heat(OFF);
- //关闭补光灯
- ctr_led(OFF);
- //关闭12V供电(海康相机,RTU)
- ctr_photo(OFF);
- //关闭清扫电机驱动
- ctr_clear(OFF);
- }
- //拍照
- void HK_TakePhoto(void)
- {
- //打开补光灯
- //DTU_Write("takephoto.mp3");
- rt_thread_delay(10000);
- rt_timer_start(timer_takephoto);
- char *takephotojson = makeJson_takephoto();
- DTU_Write("%s",takephotojson);
- rt_free(takephotojson);
- //吸虫塔
- if(device_status.version_type!=6)
- {
- ctr_led(ON);
- if(device_status.version_type==48)
- {
- rt_thread_delay(1000*60);
- }
- else {
- rt_thread_delay(1000*15);
- }
- }
- //触发海康相机拍照
- Hk_Take_io();
- if(device_status.version_type!=6)
- {
- rt_thread_delay(1000*45);
- }
- else {
- ctr_led(ON);
- rt_thread_delay(1000*19);
- }
- ctr_led(OFF);
- }
- //光控测试任务
- void SunTest(void)
- {
- rt_uint16_t ui_timeout_l = 0;
- //未检测到光照,一秒扫描等待,超时30S
- while(Read_Light_Voltage()<500)
- {
- ui_timeout_l ++;
- rt_thread_delay(1000);
- if(ui_timeout_l==30) break;
- }
- rt_thread_delay(3000);
- if(Read_Light_Voltage()<500)
- {
- device_status.sun_status = 0;//光控状态
- }
- if(Read_Light_Voltage()>500)
- {
- rt_thread_delay(1000);
- }
- rt_thread_delay(3000);
- if(Read_Light_Voltage()>500)
- {
- device_status.sun_status = 1;
- ctr_lamp(OFF,1);
- }
- HMI_WRITE("sysTest.switchSun.val=%d",0);
- device_status.sun_test = 0;
- device_status.work_status=0;
- }
- /*上电初始化*/
- void ResetInit(void)
- {
- if(device_status.dtype==7)
- {
- ctr_Motor_Driver(0, 0, 0, 0);
- //关闭电磁阀
- ctr_shake(OFF, 0);
- //关闭加热
- ctr_Heat(OFF);
- //关闭制冷
- ctr_Cold(OFF);
- //关闭补光灯
- ctr_led(OFF);
- //转盘复位
- if(device_status.run_sta==0)
- ctr_turn(0, 0);
- }
- if(device_status.version_type!=6&&device_status.version_type!=7)
- {
- device_status.work_done = 1;
- //1.打开路由器供电
- if(device_status.power_status==1)
- {
- #if MATCH_DEVICE ==0
- ctr_router(ON);
- #endif
- ctr_RTU_DTU(ON);
- //2.打开相机供电
- ctr_photo(ON);
- }
- //3.关闭镇流器
- ctr_lamp(OFF,1);
- //4.关闭震动电机
- ctr_shake(OFF, 0);
- //5.关闭加热
- ctr_Heat(OFF);
- //6.关闭补光灯
- ctr_led(OFF);
- if(device_status.bat_status==1||atoi(device_status.fuse_voltage)<1)
- {
- LOG_W("欠压!");
- return;
- }
- //7.关闭上仓门
- device_status.ctr_up_motor = 2;
- // while(device_status.ctr_up_motor!=0)
- // {
- // LOG_I("关闭上仓门...");
- // rt_thread_delay(100);
- // }
- //8.关闭下仓门
- device_status.ctr_down_motor = 2;
- while(device_status.ctr_down_motor!=0)
- {
- LOG_I("关闭下仓门....");
- rt_thread_delay(100);
- }
- //9.清扫
- if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
- {
- LOG_W("异常退出!!!\n");
- return;
- }
- if(device_status.version_type==4||device_status.version_type==41)
- {
- if(device_status.photo_ws==0) device_status.clear_status=1;
- while(device_status.clear_status==1){
- rt_thread_delay(1000);
- }
- }
- }
- else {
- if(device_status.power_status==1)
- {
- //1.打开路由器供电
- #if MATCH_DEVICE ==0
- ctr_router(ON);
- #endif
- ctr_RTU_DTU(ON);
- //2.打开相机供电
- ctr_photo(ON);
- }
- //5.关闭加热
- //6.关闭补光灯
- ctr_led(OFF);
- }
- }
- /*三色光源*/
- void Led_Check(uint8_t tp)
- {
- if(tp==3)
- {
- if(device_status.light_over_tim>2*3600)
- {
- device_status.work_status = 1;
- device_status.lamp_status = 1;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 0;
- LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
- }
- else if (device_status.light_over_tim>3600&&device_status.light_over_tim<7200) {
- device_status.work_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status = 1;
- device_status.lamp2_status = 0;
- LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
- }
- else if (device_status.light_over_tim<1*3600) {
- device_status.work_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 1;
- LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
- }
- }
- else if (tp==6) {
- if(device_status.light_over_tim>4*3600)
- {
- device_status.work_status = 1;
- device_status.lamp_status = 1;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 0;
- LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
- }
- else if (device_status.light_over_tim<14400&&device_status.light_over_tim>7200) {
- device_status.work_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status = 1;
- device_status.lamp2_status = 0;
- LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
- }
- else if (device_status.light_over_tim<7200) {
- device_status.work_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 1;
- LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
- }
- }
- else if (tp==9) {
- if(device_status.light_over_tim>6*3600)
- {
- device_status.work_status = 1;
- device_status.lamp_status = 1;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 0;
- LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
- }
- else if (device_status.light_over_tim<6*3600&&device_status.light_over_tim>3*3600) {
- device_status.work_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status = 1;
- device_status.lamp2_status = 0;
- LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
- }
- else if (device_status.light_over_tim<3*3600) {
- device_status.work_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 1;
- LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
- }
- }
- }
- void WorkCheck(void)
- {
- static rt_uint32_t light_timeout = 3600;
- while(device_status.ds == 1 &&
- device_status.rain_status == 0 &&
- device_status.temp_status == 0 &&
- device_status.bat_status == 0)
- {
- if(device_status.timeSwitch == 1) // 时控模式
- {
- LOG_I("***********时控*****************");
- time_t now;
- time(&now);
- struct tm now_tm = *localtime(&now);
- if(device_status.startBar == device_status.stopBar)
- {
- // 开始结束时间相同则24小时模式
- device_status.work_status = 1;
- rt_thread_delay(10000);
- LOG_I("时控模式:状态[%s] 当前时间:%02d:%02d:%02d 设置:%02d:00-%02d:00",
- device_status.work_status ? "工作" : "待机",
- now_tm.tm_hour, now_tm.tm_min, now_tm.tm_sec,
- device_status.startBar, device_status.stopBar);
- continue;
- }
- rt_uint32_t curr_sec = now_tm.tm_hour*3600 + now_tm.tm_min*60 + now_tm.tm_sec;
- rt_uint32_t start_sec = device_status.startBar * 3600;
- rt_uint32_t end_sec = device_status.stopBar * 3600;
- // 修复跨天判断逻辑
- if (start_sec < end_sec)
- {
- // 不跨天模式
- device_status.work_status = (curr_sec >= start_sec && curr_sec < end_sec) ? 1 : 0;
- }
- else
- {
- // 跨天模式
- device_status.work_status = (curr_sec >= start_sec || curr_sec < end_sec) ? 1 : 0;
- }
- LOG_I("时控模式:状态[%s] 当前时间:%02d:%02d:%02d 设置:%02d:00-%02d:00",
- device_status.work_status ? "工作" : "待机",
- now_tm.tm_hour, now_tm.tm_min, now_tm.tm_sec,
- device_status.startBar, device_status.stopBar);
- rt_thread_delay(10000);
- }
- else // 光控模式
- {
- LOG_I("光控定时模式!");
- if(device_status.sun_status == 0 && device_status.light_over_tim != 0)
- {
- device_status.light_over_tim--;
- light_timeout = 3600; // 重置超时计数器
- device_status.work_status = 1;
- LOG_I("光控定时,计时中>>>>>>>>>:%d",device_status.light_over_tim);
- }
- else
- {
- // 仅在白天递减超时计数器
- if(device_status.sun_status == 1 && light_timeout > 0) {
- light_timeout--;
- }
- device_status.work_status = 0;
- //没有在测试并且没有在自检
- if(device_status.test_flag==0 && device_status.selfcheck_ws==0)
- {
- ctr_lamp(OFF,1);
- }
- // 连续1小时白天后重置
- if(light_timeout == 0) {
- device_status.light_over_tim = 0;
- light_timeout = 3600; // 重置防止负数
- }
- // 白天且倒计时结束:重置夜晚时长
- if(device_status.light_over_tim == 0 &&
- device_status.sun_status == 1)
- {
- device_status.light_over_tim = device_status.sunBar * 3600;
- }
- }
- }
- rt_thread_delay(1000);
- }
- // 异常状态处理
- device_status.work_status = 0;
- rt_thread_delay(1000);
- }
- //工作任务流程s
- void WorkTask(void)
- {
- static int clt_time = 0; //收集时间差秒数
- static int heat_time = 0;
- LOG_I("工作状态:%d",device_status.work_status);
- LOG_I("开关机状态:%d",device_status.ds);
- while(device_status.work_status==1&&device_status.temp_status==0&&device_status.bat_status==0&&device_status.rain_status==0&&device_status.ds==1&&device_status.clear_status==0)
- {
- device_status.work_done = 0;
- if(clt_time==0)
- {
- DTU_Write("workstart.mp3");
- if(device_status.debug_ws==1)
- {
- time_t stamp=time(RT_NULL);
- static struct tm tm;
- gmtime_r(&stamp, &tm);
- rt_sprintf(device_status.stamp,"%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);
- char* debug_str = makeJson_Warn("Work start!", device_status.stamp);
- DTU_Write(debug_str);
- rt_free(debug_str);
- }
- }
- //1.打开灯管
- #if LAMP_EN == 1
- if(device_status.lamp_status==1&&device_status.sun_status==0) //光控状态不亮灯
- {
- ctr_lamp(ON,1);
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- }
- else if (device_status.lamp1_status==1&&device_status.sun_status==0) {
- ctr_lamp(OFF,1);
- ctr_lamp(ON,2);
- ctr_lamp(OFF,3);
- }
- else if (device_status.lamp2_status==1&&device_status.sun_status==0) {
- ctr_lamp(OFF,1);
- ctr_lamp(OFF,2);
- ctr_lamp(ON,3);
- }
- #else
- ctr_lamp(ON,1);
- #endif
- LOG_I("打开灯管!!!");
- if(device_status.version_type!=5)
- {
- rt_thread_delay(1000); //待灯管启动再往下执行,否则会触发电机过流
- //2.打开上仓门
- LOG_I("打开上仓门!!!");
- device_status.ctr_up_motor = 1;
- //3.收集
- clt_time = device_status.clt_time * 60;
- while(clt_time!=1)
- {
- #if 0//LAMP_EN == 0
- ctr_Fan_IN(ON);
- #endif
- clt_time --;
- rt_thread_delay(1000);
- #if 0//LAMP_EN == 0
- if(clt_time%30==0)
- ctr_Fan_PUT(OFF);
- #endif
- rt_kprintf("正在收集.....剩余时间:%d分-%d秒\n",device_status.clt_time,clt_time);
- //如果触发异常
- if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
- {
- ctr_lamp(OFF,1);
- #if LAMP_EN == 1
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- #endif
- #if 0//LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- break;
- }
- if(device_status.timeSwitch==0&&device_status.sun_status==1)
- {
- ctr_lamp(OFF,1);
- #if LAMP_EN == 1
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- #endif
- #if 0//LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- break;
- }
- }
- clt_time = 1;
- if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
- {
- ctr_lamp(OFF,1);
- #if LAMP_EN == 1
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- #endif
- #if 0//LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- break;
- }
- if(device_status.timeSwitch==0&&device_status.sun_status==1)
- {
- ctr_lamp(OFF,1);
- #if LAMP_EN == 1
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- #endif
- #if 0//LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- break;
- }
- #if 0//LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- //4.关闭上仓门
- device_status.ctr_up_motor = 2;
- rt_kprintf("关闭上仓门!!!\n");
- while(device_status.ctr_up_motor!=0)
- {
- rt_thread_delay(100);
- LOG_I("等待上仓门关闭!!!");
- }
- //5.加热
- if(device_status.heat_sw==0)
- {
- calorstat(device_status.heattime*60);
- }
- else {
- heat_time = device_status.heattime * 60;
- while(heat_time!=0)
- {
- heat_time--;
- LOG_I("正在加热状态!!!");
- rt_thread_delay(1000);
- }
- }
- #if TG_MODULE == 0
- //6.打开下仓门
- if(device_status.rain_status==0)
- {
- device_status.ctr_down_motor =1;
- }
- else {
- device_status.ctr_down_motor = 2;
- device_status.ctr_up_motor = 2;
- }
- //待下仓门完全打开
- while(device_status.ctr_down_motor!=0)
- {
- rt_thread_delay(100);
- rt_kprintf("等待下仓门打开!!!\n");
- }
- rt_thread_delay(3000);
- //关闭下仓门
- device_status.ctr_down_motor = 2;
- while(device_status.ctr_down_motor!=0)
- {
- rt_thread_delay(100);
- rt_kprintf("等待下仓门关闭!!!\n");
- }
- //2022-04-12add:
- LOG_I("打开上仓门!!!");
- device_status.ctr_up_motor = 1;
- #else
- //打开下仓门
- ctr_cangmen_down(OPEN);
- while(1)
- {
- if(rt_pin_read(CTR_UPC_LIMIT)==0) break;
- rt_thread_delay(50);
- }
- ctr_cangmen_down(OFF);
- rt_thread_delay(1000);
- #endif
- if(device_status.version_type==4||device_status.version_type==41)
- {
- //震动
- ctr_shake(ON, device_status.shake_sec);
- //补光&&拍照
- LOG_I("拍照!!!");
- device_status.photo_ws = 1;
- }
- #if TG_MODULE == 1
- while(device_status.photo_ws == 1)
- {
- rt_thread_delay(1000);
- LOG_I("等待拍照完成...");
- }
- while(device_status.clear_status==1)
- {
- rt_thread_delay(1000);
- LOG_I("等待清扫完成...");
- }
- device_status.ctr_down_motor =1;
- //待下仓门完全打开
- while(device_status.ctr_down_motor!=0)
- {
- rt_thread_delay(100);
- rt_kprintf("等待下仓门打开!!!\n");
- }
- rt_thread_delay(2000);
- device_status.photo_ws = 1;
- //关闭下仓门
- device_status.ctr_down_motor = 2;
- //待下仓门完全关闭
- while(device_status.ctr_down_motor!=0)
- {
- rt_thread_delay(100);
- rt_kprintf("等待下仓门关闭!!!\n");
- }
- device_status.ctr_up_motor = 1; //打开上仓门
- #endif
- }
- }
- if(device_status.bat_status == 1 || device_status.temp_status == 1 || device_status.rain_status==1 || device_status.ds==0)
- {
- LOG_I("-------------------not work--------------------");
- device_status.work_status = 0;
- }
- //工作结束
- if(device_status.work_done==0&&device_status.work_status==0)
- {
- DTU_Write("workdone");
- if (device_status.version_type==1) {
- turnzp(); //2024-03-21 :开机不再转仓
- }
- ResetInit();
- clt_time = 0;
- }
- rt_kprintf("***not work-device status:%d\n",device_status.ds);
- }
- void guanshan_on(void *args)
- {
- LOG_W("guanshan_on!");
- rt_event_send(event_485_play, 0x01);
- }
- static void pin_guangshan_bind(void)
- {
- /* PC14引脚为输入模式 */
- rt_pin_mode(GUANG_SHAN, PIN_MODE_INPUT);
- /* 绑定中断,下降沿模式,回调函数名为guanshan_on */
- rt_pin_attach_irq(GUANG_SHAN, PIN_IRQ_MODE_RISING, guanshan_on, RT_NULL);
- /* 使能中断 */
- rt_pin_irq_enable(GUANG_SHAN, PIN_IRQ_ENABLE);
- }
- static void pin_guangshan_unbind(void)
- {
- rt_pin_detach_irq(GUANG_SHAN);
- }
- #define PULES 1 //延时时间 ms 5.0测报灯电机归零延时使用
- void slidelock()
- {
- ctr_Motor_Driver_Power(ON); //电机驱动供电
- rt_thread_delay(10);
- rt_pin_mode(Motor_EN, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(Motor_EN, ON); //引脚输出高使能有效
- }
- /* 入口函数-工作状态检测 */
- static void Work_status_thread_entry(void *parameter)
- {
- static uint16_t sun_status_num = 120;
- //如果是光控定时,进行光控监测的消抖
- if(device_status.timeSwitch==0&&device_status.sun_status==0)
- {
- rt_kprintf("光控定时!!!\n");
- while(sun_status_num!=0)
- {
- sun_status_num--;
- rt_thread_delay(1000);
- rt_kprintf("开机光控检测:%d\n",sun_status_num);
- }
- device_status.light_over_tim = device_status.sunBar * 3600;
- device_status.test_flag = 0;
- }
- while(1)
- {
- WorkCheck();
- }
- }
- /*入口函数-工作流程*/
- static void Work_Loop_thread_entry(void *parameter)
- {
- rt_thread_delay(1000);
- ResetInit();
- rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
- while(1)
- {
- if(device_status.dtype==3)
- {
- WorkTask();
- }
- rt_thread_delay(1000);
- }
- }
- /*入口函数清扫*/
- static void Control_Clear_thread_entry(void *parameter)
- {
- while(1)
- {
- if(device_status.update_flag==1) break;
- if(device_status.clear_status==1)
- {
- if(device_status.version_type==41){
- ctr_TG_Clear(300);
- }else {
- ctr_TG_Clear(350);
- }
- }
- if(device_status.clear_status==2)
- {
- turnzp();
- device_status.clear_status = 0;
- }
- rt_thread_delay(100);
- }
- }
- /*入口函数,自检*/
- static void Control_Check_thread_entry(void *parameter)
- {
- static int total_seconds = 200;
- static int current_second = 0;
- static int process = 0;
- #if MATCH_DEVICE == 1
- rt_pin_mode(LED_P, PIN_MODE_OUTPUT);
- rt_pin_write(LED_P,ON);
- #endif
- device_status.C01 = 0;
- rt_thread_delay(10000);
- while(1)
- {
- if(device_status.update_flag==1) break;
- if(device_status.work_status==1&&device_status.heat_sw==1)
- {
- ctr_lamp(ON, 1);
- rt_thread_delay(10000);
- calorstat(device_status.heattime*60);
- }
- else
- {
- if(device_status.selfcheck_ws==2)
- {
- while(current_second <= total_seconds)
- {
- process = (current_second * 100) / total_seconds;
- device_status.process = process / 100.0;
- LOG_I("process:%d",process);
- HMI_WRITE("selfcheck.s106.val=%d",process);
- rt_thread_delay(1000);
- current_second++;
- if(device_status.selfcheck_ws==0)
- {
- HMI_WRITE("selfcheck.s106.val=100");
- break;
- }
- }
- HMI_WRITE("selfcheck.s106.val=100");
- }else {
- process = 0;
- current_second = 0;
- #if MATCH_DEVICE == 1
- if(device_status.rain_status==0)
- {
- rt_pin_mode(LED_P, PIN_MODE_OUTPUT);
- rt_pin_write(LED_P,ON);
- }
- //根据故障码 亮指示灯
- //灯管故障
- if(device_status.C01 & (1 << 0))
- {
- LOG_E("灯管故障!");
- //发送红灯常亮信号
- write_single_holding_register(0x01,0x00C2,0x0011,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //加热故障
- if(device_status.C01 & (1 << 1))
- {
- LOG_E("加热故障!");
- //发送红灯慢闪信号
- write_single_holding_register(0x01,0x00C2,0x0021,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //相机拍照故障
- if(device_status.C01 & (1 << 2))
- {
- LOG_E("拍照故障!");
- //发送红灯快闪信号
- write_single_holding_register(0x01,0x00C2,0x0031,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //补光灯故障
- if(device_status.C01 & (1 << 3))
- {
- LOG_E("补光灯故障!");
- //发送绿灯慢闪信号
- write_single_holding_register(0x01,0x00C2,0x0023,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //上仓门故障
- if(device_status.C01 & (1 << 8))
- {
- LOG_E("上仓门故障!");
- //发送黄灯常亮信号
- write_single_holding_register(0x01,0x00C2,0x0012,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //下仓门故障
- if(device_status.C01 & (1 << 9))
- {
- LOG_E("下仓门故障!");
- //发送黄灯慢闪信号
- write_single_holding_register(0x01,0x00C2,0x0022,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //清扫故障
- if(device_status.C01 & (1 << 10))
- {
- LOG_E("清扫故障!");
- //发送黄灯爆闪信号
- write_single_holding_register(0x01,0x00C2,0x0032,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- //通信故障
- if(device_status.C01 & (1 << 13))
- {
- LOG_E("通信故障!");
- //发送绿灯爆闪信号
- write_single_holding_register(0x01,0x00C2,0x0033,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- if(device_status.C01==0)
- {
- LOG_W("无故障!");
- //发送绿灯常亮信号
- write_single_holding_register(0x01,0x00C2,0x0013,1000);
- //延时10S
- rt_thread_delay(10000);
- }
- #endif
- }
- }
- rt_thread_delay(1000);
- }
- }
- static void thread_485_play_entry(void *param)
- {
- static USHORT sound105[] = {0x736F,0x756E,0x6431,0x3037};
- rt_uint32_t e;
- // 创建事件控制块
- event_485_play = rt_event_create("event", RT_IPC_FLAG_FIFO);
- if (event_485_play == RT_NULL)
- {
- LOG_E("Event create failed!");
- return;
- }
- while(1)
- {
- if(device_status.update_flag==1) break;
- //等待事件
- if(rt_event_recv(event_485_play, 0x01, RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, &e)==RT_EOK)
- {
- LOG_I("Interrupt occurred and processed.");
- _485_play(sound105, 4);
- //发送串口消息,通知JETSON计算卡进行拍照
- DTU_Write("{\"guangshan\":\"on\"}");
- }
- }
- }
- /*清扫线程*/
- int Control_clear(void)
- {
- /* 创建线程*/
- tid_ctr = rt_thread_create("Control_Clear_thread_entry",
- Control_Clear_thread_entry, RT_NULL,
- 2048, //2048
- 24, //23
- WORK_CHECK_THREAD_TIMESLICE); //5
- if(tid_ctr!=RT_NULL)
- {
- rt_thread_startup(tid_ctr);
- }
- return 0;
- }
- /*恒温加热线程*/
- int Control_Check(void)
- {
- /* 创建线程*/
- tid_heat = rt_thread_create("Control_Check_thread_entry",
- Control_Check_thread_entry, RT_NULL,
- 1024, //2048
- 25, //23
- WORK_CHECK_THREAD_TIMESLICE); //5
- if(tid_heat!=RT_NULL)
- {
- rt_thread_startup(tid_heat);
- }
- return 0;
- }
- int thread_485_play(void)
- {
- tid_485_play = rt_thread_create("thread_485play",
- thread_485_play_entry, RT_NULL,
- 1024, //1024
- 26, //23
- 5); //5
- if(tid_485_play!=RT_NULL)
- {
- rt_thread_startup(tid_485_play);
- }
- else {
- LOG_E("thread_485_play start failed!");
- }
- return 0;
- }
- /* 创建线程 -工作状态检测*/
- int Workstatus_check(void)
- {
- /* 创建线程*/
- tid_wkstc = rt_thread_create("work_status_check_thread",
- Work_status_thread_entry, RT_NULL,
- WORK_CHECK_THREAD_STACK_SIZE, //1024
- WORK_CHECK_THREAD_PRIORITY, //23
- WORK_CHECK_THREAD_TIMESLICE); //5
- if(tid_wkstc!=RT_NULL)
- {
- rt_thread_startup(tid_wkstc);
- }
- return 0;
- }
- /*工作流程线程*/
- int Work_Loop_Task(void)
- {
- rt_err_t result_loop = 0;
- /* 创建线程*/
- tid_workloop = rt_thread_create("work_loop_thread",
- Work_Loop_thread_entry, RT_NULL,
- WORK_LOOP_THREAD_STACK_SIZE, //2048
- WORK_LOOP_THREAD_PRIORITY, //12
- WORK_LOOP_THREAD_TIMESLICE); //5
- if(tid_workloop!=RT_NULL)
- {
- result_loop = rt_thread_startup(tid_workloop);
- }
- return result_loop;
- }
- #ifdef RT_USING_ALARM
- void alarm_callback_router_on(rt_alarm_t alarm, time_t timestamp)
- {
- LOG_W("alarm_callback_router_on.\n");
- ctr_router(ON);
- }
- void alarm_callback_router_off(rt_alarm_t alarm, time_t timestamp)
- {
- LOG_W("alarm_callback_router_off.\n");
- ctr_router(OFF);
- }
- void alarm_app_router(void)
- {
- struct rt_alarm_setup setup;
- struct rt_alarm * alarm_router_on = RT_NULL;
- if (alarm_router_on != RT_NULL)
- return;
- setup.flag = RT_ALARM_DAILY;
- setup.wktime.tm_hour = 23;
- setup.wktime.tm_min = 0;
- setup.wktime.tm_sec = 0;
- alarm_router_on = rt_alarm_create(alarm_callback_router_on, &setup);
- if(RT_NULL != alarm_router_on)
- {
- LOG_I("设置闹钟: %d:%d:%d",setup.wktime.tm_hour,setup.wktime.tm_min,setup.wktime.tm_sec);
- rt_alarm_start(alarm_router_on);
- }
- }
- #endif
- MSH_CMD_EXPORT(ctr_lamp,ctr_lamp<ON|OFF>);
- MSH_CMD_EXPORT(ctr_Heat,ctr_Heat<ON|OFF>);
- MSH_CMD_EXPORT(ctr_clear,ctr_clear<ON|OFF>);
- MSH_CMD_EXPORT(ctr_led,sample:ctr_led <ON|OFF>);
- //INIT_APP_EXPORT(Control_heat);
|