| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211 |
- #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
- */
- #include "beep.h"
- #include "hmi.h"
- #include "easyflash.h"
- #include "stdio.h"
- #include "sound.h"
- #include "dtu_uart2.h"
- #include "sht30_collect.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-打开
- #define PULES 1 //延时时间 ms
- //设备状态表结构体
- Device_Status_typedef device_status;
- Device_slide_typedef slide_para;
- 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;
- static rt_thread_t rt_slide = RT_NULL;
- /**************************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);
- }
- /**************************机器人********************************/
- void ctr_Motor_Robot(uint8_t status_ws)
- {
- unsigned int close_timeout = 0;
- unsigned int open_timeout = 0;
- rt_pin_mode(LIMIT_OPEN, PIN_MODE_INPUT);
- rt_pin_mode(LIMIT_CLOSE, PIN_MODE_INPUT);
- rt_pin_mode(Motor_Power, PIN_MODE_OUTPUT);
- rt_pin_mode(Motor_Direction_Button, PIN_MODE_INPUT);
- rt_pin_mode(Motor_Direction_Ctr, PIN_MODE_OUTPUT);
- rt_pin_write(Motor_Power,OFF);
- rt_pin_write(Motor_Direction_Ctr,ON);
- rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
- rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
- if(status_ws == ON)
- {
- //检测按键状态
- while(rt_pin_read(Motor_Direction_Button)==1)
- {
- if(rt_pin_read(LIMIT_CLOSE)==1)
- {
- rt_pin_write(Motor_Direction_Ctr,ON);
- close_timeout++;
- //打开电机驱动器电源,默认关闭
- rt_pin_write(Motor_Power,ON);
- if(close_timeout==2)
- {
- rt_pin_write(CLEAR_R,ON);
- rt_pin_write(CLEAR_L,OFF);
- rt_pin_write(Motor_Power,OFF);
- rt_thread_delay(20);
- rt_pin_write(Motor_Power,ON);
- }
- rt_thread_delay(20);
- if(close_timeout>500)
- {
- close_timeout = 600;
- rt_pin_write(Motor_Power,OFF);
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- }
- }
- else
- {
- close_timeout = 0;
- rt_pin_write(Motor_Power,OFF); //关闭驱动器电源
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- }
- rt_thread_delay(20);
- }
- rt_pin_write(Motor_Power,OFF);
- rt_thread_delay(1000*2);
- while(rt_pin_read(Motor_Direction_Button)==0)
- {
- if(rt_pin_read(LIMIT_OPEN)==1)
- {
- open_timeout ++;
- //打开电机驱动器电源,默认关闭
- if(open_timeout==2){
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,ON);
- }
- rt_pin_write(Motor_Power,ON);
- rt_pin_write(Motor_Direction_Ctr,OFF);
- if(open_timeout>500)
- {
- open_timeout = 600;
- rt_pin_write(Motor_Power,OFF);
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- }
- rt_thread_delay(20);
- }
- if(rt_pin_read(LIMIT_OPEN)==0)
- {
- open_timeout = 0;
- rt_pin_write(Motor_Power,OFF);
- rt_pin_write(CLEAR_R,OFF);
- rt_pin_write(CLEAR_L,OFF);
- }
- rt_thread_delay(20);
- close_timeout = 0;
- }
- open_timeout = 0;
- close_timeout = 0;
- }
- else {
- rt_pin_write(Motor_Power,OFF);
- }
- }
- /*************************吸虫塔*********************************/
- //吸虫电机
- 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 ctr_JD_Clear(uint8_t shake_sw)
- {
- rt_uint16_t turn_timeout = 0;
- rt_pin_mode(MOTOR_C_LIMIT,PIN_MODE_INPUT);
- ctr_cangmen_up(OFF); //清扫传送带的电机
- if(shake_sw==ON)
- {
- ctr_Heat(ON); //清洁风机
- Motor_shake(ON, 0);
- ctr_cangmen_up(OPEN); //打开清扫
- }
- else {
- Motor_shake(OFF, 0);
- ctr_cangmen_up(OPEN); //打开清扫
- }
- while(rt_pin_read(MOTOR_C_LIMIT)==0)
- {
- Motor_Juandai(ON);
- rt_thread_delay(50);
- turn_timeout++;
- if(turn_timeout==1000) break;
- }
- turn_timeout = 0;
- while(rt_pin_read(MOTOR_C_LIMIT)==1)
- {
- Motor_Juandai(ON);
- turn_timeout++;
- rt_thread_delay(50);
- if(turn_timeout==1000) break;
- }
- Motor_shake(OFF, 1);
- Motor_Juandai(OFF);
- ctr_cangmen_up(OFF); //关闭清扫
- ctr_Heat(OFF);
- }
- //工作任务流程
- 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)
- {
- 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
- *************************************************/
- void ctr_develop(void)
- {
- rt_kprintf("===============开始培养=================:%d\n",device_status.cul_time);
- //已经培养的时间-分钟
- device_status.stay_time = 0;
- rt_uint32_t ii = 0;
- while(device_status.develop_flag==1)
- {
- float stayedtime = 0.01;
- char stayed[5];
- stayedtime = (float)device_status.stay_time / 60.0;
- sprintf(stayed,"%0.02f",stayedtime);
- HMI_WRITE("workSta.staytime.txt=\"%s\"",stayed);
- ii++;
- LOG_I("developing...................................%d\n",ii);
- LOG_I("============================设定的培养温度:%d\n",device_status.heatvalue);
- LOG_I("============================培养仓实时温度:%d\n",device_status.pre_temp);
- if(device_status.pre_temp<(device_status.heatvalue-5))
- {
- //未制冷
- if(device_status.cold_status==0)
- {
- ctr_Heat(ON);
- }
- }
- else
- {
- ctr_Heat(OFF);
- }
- LOG_I("============================制冷开关:%d\n",device_status.cold_sw);
- if(device_status.cold_sw==1)
- {
- if(device_status.pre_temp>(device_status.heatvalue-10))
- {
- if(device_status.heat_status==0)
- {
- ctr_Cold(ON);
- }
- }
- else
- {
- ctr_Cold(OFF);
- }
- }
- if(ii%60==0)
- {
- device_status.stay_time++;
- if(device_status.stay_time / 60 == device_status.cul_time) device_status.develop_flag = 0;
- LOG_I("developed...................................%d分钟\n",device_status.stay_time);
- }
- if(device_status.box_temp>35)
- {
- ctr_Cool_Fan(ON);
- }
- else if (device_status.box_temp<30)
- {
- ctr_Cool_Fan(OFF);
- }
- rt_thread_delay(1000);
- }
- ctr_Cold(OFF);
- ctr_Heat(OFF);
- LOG_I("=========!!!培养完成!!!==========");
- }
- /*上仓门*/
- 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);
- rt_pin_write(Collect_fan_R,ON);
- rt_pin_write(Collect_fan_L,OFF);
- }
- if(status_up==CLOSE)
- {
- device_status.up_status = 0;
- rt_pin_write(Collect_fan_R,OFF);
- rt_pin_write(Collect_fan_L,OFF);
- rt_pin_write(Collect_fan_R,OFF);
- rt_pin_write(Collect_fan_L,ON);
- }
- 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;
- }
- }
- HMI_WRITE("sysTest.switchLamp.val=%d",device_status.lamp_status);
- return device_status.lamp_status;
- }
- //震动电机
- uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec)
- {
- static rt_uint16_t shake_i = 0;
- shake_i = atoi(device_status.power);
- LOG_I("震动电机待机电流:%d",shake_i);
- if(device_status.dtype==7&&shake_sec!=0)
- DTU_Write("drop");
- rt_pin_mode(SHAKE_SW, PIN_MODE_OUTPUT);
- if(status_shake==ON&&device_status.shake_ws==1)
- {
- rt_pin_write(SHAKE_SW,ON);
- if(device_status.dtype==3)
- {
- while(shake_sec--)
- {
- rt_thread_delay(100);
- if(shake_sec==20&&device_status.clear_status==0&&device_status.work_status==1&&atoi(device_status.power)-shake_i<100&&shake_i!=0&&shake_i<5000)
- {
- char * shake_warn = makeJson_Warn("电流不足", "震动电机");
- DTU_Write("%s",shake_warn);
- rt_free(shake_warn);
- }
- LOG_D("震动电机:%d",atoi(device_status.power));
- }
- }
- 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);
- HMI_WRITE("sysTest.switchFill.val=%d",ON);
- }
- else if(status_led==OFF){
- rt_pin_write(LED_SW,OFF);
- if(device_status.version_type==6)
- rt_pin_write(LED_P,OFF);
- HMI_WRITE("sysTest.switchPhoto.val=%d",OFF);
- HMI_WRITE("sysTest.switchFill.val=%d",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);
- 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);
- 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);
- rt_thread_delay(10);
- turn_cnt ++;
- if(turn_cnt==6000)
- {
- 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;
- }
- }
- 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);
- rt_thread_delay(10);
- turn_cnt ++;
- if(turn_cnt==3000)
- {
- 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;
- }
- }
- 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);
- HMI_WRITE("cangWei.rotateFlag.val=0");
- }
- /*************************************************
- 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);
- if(EN==0)
- {
- rt_pin_write(Motor_Power,0);
- }
- else{
- 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%
- }
- /*************************************************
- 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)
- {
- // rt_pin_write(CLEAR_R,ON);
- // rt_pin_write(CLEAR_L,OFF);
- Motor_Juandai(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);
- Motor_Juandai(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);
- Motor_Juandai(OFF);
- break;
- }
- else {
- break;
- }
- }
- Motor_Juandai(OFF);
- // rt_pin_write(CLEAR_R,OFF);
- // rt_pin_write(CLEAR_L,OFF);
- turn_timeout = 0;
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.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)
- {
- rt_pin_mode(ROUTER, PIN_MODE_OUTPUT);
- if(device_status.version_type==6)
- rt_pin_mode(ROUTER_P,PIN_MODE_OUTPUT);
- //rt_pin_mode(POWER_CLEAR, PIN_MODE_OUTPUT);
- if(status_router==ON)
- {
- rt_pin_write(ROUTER,ON);
- //
- #if LAMP_EN == 0
- if(device_status.version_type==6)
- rt_pin_write(ROUTER_P,ON);
- #endif
- }
- else {
- rt_pin_write(ROUTER,OFF);
- //
- #if LAMP_EN == 0
- if(device_status.version_type==6)
- rt_pin_write(ROUTER_P,OFF);
- #endif
- }
- }
- //清扫-推杆电机
- void ctr_TG_Clear(uint16_t clear_timeout)
- {
- #if 0
- int current_clear[200];
- int16_t Electric_current = atoi(device_status.power); //获取电机运动前的电流
- LOG_I("清扫电机待机:%d",Electric_current);
- #endif
- static uint16_t clear_count = 0;
- clear_count = clear_timeout;
- #if PWM_EN == 0
- rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
- rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
- #endif
- while(clear_count!=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
- clear_count--;
- rt_thread_delay(100);
- }
- #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(3000);
- clear_count = 0;
- while(clear_timeout!=clear_count)
- {
- #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
- // if(clear_count<200)
- // current_clear[clear_count] = atoi(device_status.power);
- clear_count++;
- rt_thread_delay(100);
- }
- #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 0
- bubblesort(current_clear,200);
- if(current_clear[199]-Electric_current <100&&device_status.work_status==1&&Electric_current!=0&&Electric_current<5000)
- {
- LOG_E("清扫电机电流不足:%d!",current_clear[199]);
- char *ctr_clear_warn = makeJson_Warn("电流不足","清扫电机");
- DTU_Write("%s",ctr_clear_warn);
- rt_free(ctr_clear_warn);
- }
- #endif
- rt_thread_delay(2000);
- device_status.clear_status = 0;
- HMI_WRITE("cangWei.rotateFlag.val=%d",0);
- HMI_WRITE("sysTest.switchClear.val=%d",0);
- }
- //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;
- 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)
- {
- delay_heat --;
- rt_kprintf("正在恒温加热!!!:%d",delay_heat);
- HMI_WRITE("workSta.g0.txt=\"正在恒温加热!!!:%d\"",delay_heat);
- rt_thread_delay(1000);
- }
- delay_heat = 60;
- //跳出FOR循环
- n = n + 60;
- }
- if(device_status.heattem < (device_status.heatvalue - 5)&&heat_flg == SET)
- {
- device_status.run_sta = 0;
- 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 = 10;
- 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)
- // {
- // UpLoad_Data(); //从加热开始每5分钟上传的数据
- // }
- }
- //如果触发异常退出加热
- 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);
- //关闭下仓门电机
- //ctr_cangmen_down(OFF);
- //关闭镇流器
- if(device_status.autotakepic==0)
- ctr_lamp(OFF,1);
- //关闭震动电机
- ctr_shake(OFF,0);
- //关闭加热
- ctr_Heat(ON);
- //关闭补光灯
- ctr_led(OFF);
- //关闭12V供电(海康相机,RTU)
- ctr_photo(OFF);
- }
- //拍照
- void HK_TakePhoto(void)
- {
- //打开补光灯
- DTU_Write("takephoto.mp3");
- rt_thread_delay(1000);
- 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(ON);
- //关闭制冷
- ctr_Cold(OFF); //补光灯
- //关闭补光灯
- ctr_led(OFF);
- //转盘复位
- // if(device_status.run_sta==0)
- // ctr_turn(0, 0);
- //滑台移动停止标志位为0
- slide_para.stop_flag = 0;
- }
- if(device_status.version_type!=6&&device_status.version_type!=7)
- {
- device_status.work_done = 1;
- //1.打开路由器供电
- if(device_status.power_status==1)
- {
- ctr_router(ON);
- ctr_RTU_DTU(ON);
- //2.打开相机供电
- ctr_photo(ON);
- }
- //3.关闭镇流器
- ctr_lamp(OFF,1);
- #if LAMP_EN == 1
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- #endif
- //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 LAMP_EN == 0
- ctr_Fan_PUT(OFF);
- ctr_Fan_IN(OFF);
- #endif
- if(device_status.version_type==4||device_status.version_type==41)
- {
- device_status.clear_status=1;
- }
- else if (device_status.version_type==1) {
- turnzp();
- }
- rt_thread_delay(1000);
- }
- else {
- if(device_status.power_status==1)
- {
- //1.打开路由器供电
- ctr_router(ON);
- 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);
- }
- }
- }
- //出厂前自检 0-开机自检 1-屏幕或指令下发手动自检
- void HardWare_Check(uint8_t boot)
- {
- if(boot==0&&device_status.version_type!=6)
- {
- //停止所有动作 -完成
- HardWare_Init(boot);
- }
- else {
- //停止所有动作
- //读取记录待机功耗(实测大概70mA)
- //(需减去屏幕的功耗大概120mA)
- //动作上仓门,读取功率值保存
- //动作下仓门,读取功率值保存
- //动作清扫,读取功率值保存
- //打开镇流器,读取功率值保存
- //打开海康相机供电,读取功率值保存
- //打开补光灯,读取功率值保存
- //打开路由器/RTU供电,读取功率值保存
- //打开加热,读取功率值保存
- }
- }
- //工作状态检测
- void WorkCheck(void)
- {
- //雨控检测,温控检测,电池电压检测
- while(device_status.rain_status==0&&device_status.temp_status==0&&device_status.bat_status==0)
- {
- //工作模式检测(RTC时间正常,1-时控/0-光控)(RTC时间异常强行使用光控)
- if(device_status.timeSwitch==1)
- {
- LOG_I("***********时控*****************");
- //如果开始和结束是同一天
- if(device_status.startBar<device_status.stopBar)
- {
- LOG_I("开始和结束是同一天");
- time_t now;
- time(&now);
- static struct tm nowtime; //现在
- static struct tm starttime; //开始
- static struct tm endtime; //结束
- //获取当前时间戳
- nowtime =*localtime(&now);
- nowtime.tm_hour = nowtime.tm_hour-8;
- //获取定时开始的时间戳
- starttime = *localtime(&now);
- starttime.tm_hour = device_status.startBar-8;
- starttime.tm_min = 0;
- starttime.tm_sec = 0;
- //获取定时结束的时间戳
- endtime = *localtime(&now);
- endtime.tm_hour = device_status.stopBar-8;
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- LOG_I("***工作结束在当天:现在时间:%d-开始时间:%d-结束时间:%d***",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
- //如果当前时间大于开始时间且小于结束时间,且没有开始工作
- if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&endtime))<0))
- {
- LOG_I("当前时间大于开始时间,小于结束时间,工作中!!!");
- device_status.work_status = 1;
- }
- //如果当前时间小于开始时间
- else if(difftime(mktime(&nowtime),mktime(&starttime))<0)
- {
- LOG_I("当前时间小于开始时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
- device_status.work_status = 0;
- }
- //当前时间大于结束时间
- else {
- LOG_I("当前时间大于结束时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
- device_status.work_status = 0;
- }
- #if LAMP_EN == 1
- //如果当前时间超过20点,未到21点
- if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+3600)<0))
- {
- LOG_I("3led:20~21");
- device_status.lamp_status = 1;
- device_status.lamp1_status = 0;
- device_status.lamp2_status = 0;
- }
- else if ((difftime(mktime(&nowtime), mktime(&starttime)+3600) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+7200)<0)) {
- LOG_I("3led:21~22");
- device_status.lamp1_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp2_status = 0;
- }
- else if ((difftime(mktime(&nowtime), mktime(&starttime)+7200) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+10800)<0)) {
- LOG_I("3led:22~23");
- device_status.lamp2_status = 1;
- device_status.lamp_status = 0;
- device_status.lamp1_status =0;
- }
- #endif
- }
- //如果结束时间是第二天
- else if (device_status.startBar>device_status.stopBar) {
- time_t now;
- time(&now);
- static struct tm nowtime; //现在
- static struct tm starttime; //开始
- static struct tm endtime; //结束
- //获取当前时间戳
- nowtime =*localtime(&now);
- nowtime.tm_hour = nowtime.tm_hour-8;
- //获取定时开始的时间戳
- starttime = *localtime(&now);
- starttime.tm_hour = device_status.startBar-8;
- starttime.tm_min = 0;
- starttime.tm_sec = 0;
- //获取定时结束的时间戳
- endtime = *localtime(&now);
- endtime.tm_hour = device_status.stopBar-8;
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- LOG_I("工作结束在第二天:现在时间:%d-开始时间:%d-结束时间:%d!!!",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
- //如果当前时间大于开始时间,且没有开始工作 ,注意时间戳日期加1
- if((difftime(mktime(&nowtime), mktime(&starttime)) > 0 ))
- {
- //获取定时结束的时间戳
- endtime = *localtime(&now); //将获取到的时间转换为时间戳
- endtime.tm_hour = device_status.stopBar-8; //这里需减8用于时区转换
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- device_status.work_status = 1;
- LOG_I("当前前时间大于开始时间,且没有开始工作");
- }
- //当前时间小于开始时间
- else if ((difftime(mktime(&nowtime), mktime(&starttime)) < 0))
- {
- //获取定时结束的时间戳
- endtime = *localtime(&now); //将获取到的时间转换为时间戳
- endtime.tm_hour = device_status.stopBar-8; //这里需减8用于时区转换
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- //如果当前时间戳小于结束时间戳
- if(difftime(mktime(&nowtime),mktime(&endtime)) < 0)
- {
- LOG_I("当前时间大于开始时间,且没有开始工作,当前时间小于结束时间的情况:计算工作时间:从当前时间工作第二天的结束时间");
- device_status.work_status = 1;
- }
- else
- {
- LOG_I("当前时间小于开始时间,且没有开始工作,不是重启引起的,即还没到开始时间");
- device_status.work_status = 0; //不在工作时间,待机
- }
- }
- }
- }
- else {
- LOG_I("光控定时模式!");
- /*
- 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);
- rt_kprintf("now stamp:%d\n",nowstamp_num);
- */
- if(device_status.sun_status==0&&device_status.light_over_tim!=0)
- {
- device_status.light_over_tim--;
- #if LAMP_EN == 1
- Led_Check(device_status.sunBar);
- #else
- device_status.work_status = 1;;
- LOG_I("光控定时,计时中>>>>>>>>>:%d",device_status.light_over_tim);
- #endif
- }
- else
- {
- if(device_status.test_flag==0)
- {
- ctr_lamp(OFF,1);
- #if LAMP_EN == 1
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- #endif
- }
- device_status.work_status = 0;
- if(device_status.light_over_tim==0&&device_status.sun_status==1) device_status.light_over_tim = device_status.sunBar * 3600;
- LOG_I("光控中,白天:%d!!!",device_status.sun_status);
- }
- }
- rt_thread_delay(1000);
- }
- LOG_I("雨控状态,温控状态,电压状态:%d-%d-%d",device_status.rain_status,device_status.temp_status,device_status.bat_status);
- device_status.work_status = 0;
- rt_thread_delay(1000);
- }
- #if 0
- void WorkTask_BZ(void)
- {
- if(device_status.ds==1)
- {
- //时间段判断
- //先判断第一个时间段
- time_t now;
- time(&now);
- static struct tm now_stamp; //现在
- static struct tm cul_sh1_stamp; //开始1
- static struct tm cul_eh1_stamp; //结束1
- static struct tm cul_sh2_stamp; //开始2
- static struct tm cul_eh2_stamp; //结束2
- static struct tm cul_sh3_stamp; //开始3
- static struct tm cul_eh3_stamp; //结束3
- now_stamp = *localtime(&now);
- //获取定时开始的时间戳
- cul_sh1_stamp = *localtime(&now);
- cul_sh1_stamp.tm_hour = device_status.collecting_sh1;
- cul_sh1_stamp.tm_min = 0;
- cul_sh1_stamp.tm_sec = 0;
- cul_sh2_stamp = *localtime(&now);
- cul_sh2_stamp.tm_hour = device_status.collecting_sh2;
- cul_sh2_stamp.tm_min = 0;
- cul_sh2_stamp.tm_sec = 0;
- cul_sh3_stamp = *localtime(&now);
- cul_sh3_stamp.tm_hour = device_status.collecting_sh3;
- cul_sh3_stamp.tm_min = 0;
- cul_sh3_stamp.tm_sec = 0;
- //获取定时结束的时间戳
- cul_eh1_stamp = *localtime(&now);
- cul_eh1_stamp.tm_hour = device_status.collecting_eh1;
- cul_eh1_stamp.tm_min = 0;
- cul_eh1_stamp.tm_sec = 0;
- cul_eh2_stamp = *localtime(&now);
- cul_eh2_stamp.tm_hour = device_status.collecting_eh2;
- cul_eh2_stamp.tm_min = 0;
- cul_eh2_stamp.tm_sec = 0;
- cul_eh3_stamp = *localtime(&now);
- cul_eh3_stamp.tm_hour = device_status.collecting_eh3;
- cul_eh3_stamp.tm_min = 0;
- cul_eh3_stamp.tm_sec = 0;
- LOG_I("采集时间1-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh1_stamp.tm_year+1900,cul_sh1_stamp.tm_mon+1,cul_sh1_stamp.tm_mday,cul_sh1_stamp.tm_hour,cul_sh1_stamp.tm_min,cul_sh1_stamp.tm_sec);
- LOG_I("采集时间2-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh2_stamp.tm_year+1900,cul_sh2_stamp.tm_mon+1,cul_sh2_stamp.tm_mday,cul_sh2_stamp.tm_hour,cul_sh2_stamp.tm_min,cul_sh2_stamp.tm_sec);
- LOG_I("采集时间3-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh3_stamp.tm_year+1900,cul_sh3_stamp.tm_mon+1,cul_sh3_stamp.tm_mday,cul_sh3_stamp.tm_hour,cul_sh3_stamp.tm_min,cul_sh3_stamp.tm_sec);
- LOG_I("结束时间1-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_eh1_stamp.tm_year+1900,cul_eh1_stamp.tm_mon+1,cul_eh1_stamp.tm_mday,cul_eh1_stamp.tm_hour,cul_eh1_stamp.tm_min,cul_eh1_stamp.tm_sec);
- LOG_I("结束时间2-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_eh2_stamp.tm_year+1900,cul_eh2_stamp.tm_mon+1,cul_eh2_stamp.tm_mday,cul_eh2_stamp.tm_hour,cul_eh2_stamp.tm_min,cul_eh2_stamp.tm_sec);
- LOG_I("结束时间3-%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_eh3_stamp.tm_year+1900,cul_eh3_stamp.tm_mon+1,cul_eh3_stamp.tm_mday,cul_eh3_stamp.tm_hour,cul_eh3_stamp.tm_min,cul_eh3_stamp.tm_sec);
- //此处判断,一个一个时间段判断,判断当前时间是否大于开始时间:
- //当前时间戳小于第一段开始时间戳
- if(difftime(mktime(&now_stamp), mktime(&cul_sh1_stamp)) < 0)
- {
- time_t now;
- time(&now);
- cul_sh1_stamp = *localtime(&now);
- cul_sh1_stamp.tm_hour = device_status.collecting_sh1;
- cul_sh1_stamp.tm_min = 0;
- cul_sh1_stamp.tm_sec = 0;
- now_stamp = *localtime(&now);
- LOG_I("======收集时间1:%04d年%02d月%02d日%02d时%02d分%02d秒.",cul_sh1_stamp.tm_year+1900,cul_sh1_stamp.tm_mon+1,cul_sh1_stamp.tm_mday,cul_sh1_stamp.tm_hour,cul_sh1_stamp.tm_min,cul_sh1_stamp.tm_sec);
- LOG_I("======未到收集时间1:%04d年%02d月%02d日%02d时%02d分%02d秒.",now_stamp.tm_year+1900,now_stamp.tm_mon+1,now_stamp.tm_mday,now_stamp.tm_hour,now_stamp.tm_min,now_stamp.tm_sec);
- LOG_D("run_sta:%d",device_status.run_sta);
- }
- //当前时间戳小于第二段结束 时间戳并且大于第1段结束时间戳
- if(difftime(mktime(&now_stamp), mktime(&cul_sh2_stamp)) < 0&&difftime(mktime(&now_stamp), mktime(&cul_eh1_stamp)) > 0)
- {
- time_t now;
- time(&now);
- cul_sh2_stamp = *localtime(&now);
- cul_sh2_stamp.tm_hour = device_status.collecting_sh2;
- cul_sh2_stamp.tm_min = 0;
- cul_sh2_stamp.tm_sec = 0;
- now_stamp = *localtime(&now);
- LOG_I("==============收集时间2:%04d年%02d月%02d日%02d时%02d分%02d秒.\n",cul_sh2_stamp.tm_year+1900,cul_sh2_stamp.tm_mon+1,cul_sh2_stamp.tm_mday,cul_sh2_stamp.tm_hour,cul_sh2_stamp.tm_min,cul_sh2_stamp.tm_sec);
- LOG_I("==============未到收集时间2:%04d年%02d月%02d日%02d时%02d分%02d秒.\n",now_stamp.tm_year+1900,now_stamp.tm_mon+1,now_stamp.tm_mday,now_stamp.tm_hour,now_stamp.tm_min,now_stamp.tm_sec);
- LOG_D("run_sta:%d",device_status.run_sta);
- }
- //如果当前 时间戳大于开始时间戳并且小于 结束时间戳
- if(difftime(mktime(&now_stamp), mktime(&cul_sh1_stamp)) >= 0&&difftime(mktime(&now_stamp), mktime(&cul_eh2_stamp)) < 0)
- {
- //转盘到涂凡士林位置
- if(device_status.run_sta==0)
- {
- LOG_I("start to collect!!!");
- DTU_Write("collect.mp3");
- ctr_turn(90,4);
- rt_thread_delay(2000);
- //涂凡士林
- ctr_Petroleum_jelly(10);
- rt_thread_delay(5000);
- }
- /*转盘到采集位置*/
- if(device_status.run_sta==4)
- ctr_turn(90,1);
- //只有开始和结束时刻不同的时间段,才有效
- if((difftime(mktime(&cul_eh1_stamp), mktime(&now_stamp)) > 0)||(difftime(mktime(&cul_eh2_stamp), mktime(&now_stamp)) > 0))
- {
- if((difftime(mktime(&cul_eh1_stamp), mktime(&now_stamp)) > 0)&& difftime(mktime(&now_stamp),mktime(&cul_sh1_stamp)) > 0)
- {
- device_status.work_status = 1;
- ctr_Collect_Fan(ON);
- //当前时间戳小于第一段结束时间戳
- while(difftime(mktime(&cul_eh1_stamp), mktime(&now_stamp))>0)
- {
- time(&now);
- now_stamp = *localtime(&now);
- cul_eh1_stamp = *localtime(&now);
- cul_eh1_stamp.tm_hour = device_status.collecting_eh1;
- cul_eh1_stamp.tm_min = 0;
- cul_eh1_stamp.tm_sec = 0;
- if(device_status.run_sta!=1) break;
- LOG_I("1===========采集风机启动,正在收集.....%d-%d",mktime(&now_stamp),mktime(&cul_eh1_stamp));
- rt_thread_mdelay(10000);
- }
- }
- else {
- device_status.work_status=0;
- ctr_Collect_Fan(OFF);
- LOG_I("未到收集1时间!");
- }
- if(difftime(mktime(&cul_eh2_stamp), mktime(&now_stamp)) > 0 && difftime(mktime(&now_stamp),mktime(&cul_sh2_stamp)) > 0)
- {
- device_status.work_status = 1;
- ctr_Collect_Fan(ON);
- while(difftime(mktime(&cul_eh2_stamp), mktime(&now_stamp))>0)
- {
- time(&now);
- now_stamp = *localtime(&now);
- cul_eh2_stamp = *localtime(&now);
- cul_eh2_stamp.tm_hour = device_status.collecting_eh2;
- cul_eh2_stamp.tm_min = 0;
- cul_eh2_stamp.tm_sec = 0;
- if(device_status.run_sta!=1) break;
- LOG_I("2===========采集风机启动,正在收集.....%d-%d",mktime(&now_stamp),mktime(&cul_eh2_stamp));
- rt_thread_mdelay(10000);
- }
- }
- else {
- device_status.work_status=0;
- ctr_Collect_Fan(OFF);
- LOG_I("未到收集2时间!");
- }
- }
- else
- {
- LOG_I("this collect time is 0s,The wait time cannot be negative!");
- }
- }
- if(device_status.run_sta==2)
- {
- ctr_Collect_Fan(OFF);
- device_status.develop_flag = 1;
- device_status.work_status = 2;
- ctr_develop(); //培养
- ctr_turn(90,3);
- }
- if(device_status.run_sta==3)
- {
- ctr_Collect_Fan(OFF);
- device_status.work_status = 3;
- device_status.autotakepic=1; //对焦拍照
- }
- //在培养之前再次确认时间戳
- time(&now);
- now_stamp = *localtime(&now);
- cul_eh2_stamp = *localtime(&now);
- cul_eh2_stamp.tm_hour = device_status.collecting_eh2;
- cul_eh2_stamp.tm_min = 0;
- cul_eh2_stamp.tm_sec = 0;
- //当前时间戳大于收集结束时间戳并且run_sta==1
- if(device_status.run_sta==1 && difftime(mktime(&now_stamp), mktime(&cul_eh2_stamp)) > 0)
- {
- ctr_Collect_Fan(OFF);
- LOG_I("===============collect ok,turn to drop!!!");
- device_status.develop_flag=1;
- device_status.work_status=2; //现在是培养
- DTU_Write("develop.mp3");
- if(device_status.run_sta==1)
- ctr_turn(90,2); /*转盘到培养位置*/
- rt_thread_delay(1000);
- ctr_shake(ON,device_status.shake_sec);
- rt_thread_delay(1000);
- ctr_develop(); //培养
- if(device_status.run_sta==2)
- ctr_turn(90,3); /*转盘到拍照位置*/
- rt_thread_delay(1000);
- device_status.work_status=3; //现在是拍照
- device_status.autotakepic=1; //对焦拍照
- while(device_status.autotakepic==0)
- {
- rt_thread_delay(1000);
- LOG_I("正在对焦拍照............");
- }
- device_status.work_status = 0; //待机
- DTU_Write("wait.mp3");
- LOG_I("=====================work finished==================");
- }
- rt_thread_delay(1000);
- }
- device_status.work_status = 0; //待机
- LOG_W("==================!!!设备已待机!!!===================");
- }
- #endif
- void WorkTask_BZYV2(void)
- {
- //打开胶带步进电机
- //等待采集结束
- //拍照
- //打开相机供电
- //打开补光灯
- //滑台归位
- //滑台启动
- if(device_status.ds==1){
- while(device_status.work_status ==0){
- rt_thread_delay(1000);
- LOG_W("等待设备进入工作");
- ctr_router(OFF);
- }
- while(device_status.work_status ==1){
- if(device_status.autotakepic==0){
- ctr_router(ON);
- }else{
- ctr_router(OFF);
- }
- rt_thread_delay(1000);
- }
- ctr_router(OFF);
- if(device_status.work_done==1){
- turnlimit(); //卷带电机转一圈
- slide_para.en_slide = 5; //滑台复位
- while(slide_para.en_slide!=0){
- LOG_D("等待电机完成复位!");
- rt_thread_delay(100);
- }
- device_status.autotakepic = 1; //相机自动对焦
- char *take_start = makeJson_Warn("start", "autofocus");
- DTU_Write(take_start);
- rt_free(take_start);
- device_status.work_done = 0;
- }
- }else{
- LOG_W("==================!!!设备已待机!!!===================");
- }
- }
- //工作任务流程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)
- {
- #if 0
- if(device_status.version_type==41&&atoi(device_status.power)<350)
- {
- LOG_W("相机电流不足!");
- char *ctr_hk_p_warn = makeJson_Warn("电流不足", "相机");
- DTU_Write("%s",ctr_hk_p_warn);
- rt_free(ctr_hk_p_warn);
- }
- #endif
- #if LAMP_EN == 0
- ctr_Fan_PUT(ON);
- #endif
- DTU_Write("workstart.mp3");
- }
- //1.打开灯管
- #if LAMP_EN == 1
- if(device_status.lamp_status==1)
- {
- ctr_lamp(ON,1);
- ctr_lamp(OFF,2);
- ctr_lamp(OFF,3);
- }
- else if (device_status.lamp1_status==1) {
- ctr_lamp(OFF,1);
- ctr_lamp(ON,2);
- ctr_lamp(OFF,3);
- }
- else if (device_status.lamp2_status==1) {
- ctr_lamp(OFF,1);
- ctr_lamp(OFF,2);
- ctr_lamp(ON,3);
- }
- #else
- ctr_lamp(ON,1);
- #endif
- LOG_I("打开灯管!!!");
- #if 0
- rt_thread_delay(2000);
- if(atoi(device_status.power)<450)
- {
- LOG_I("Current is:%d",atoi(device_status.power));
- if(atoi(device_status.power)>50&&atoi(device_status.power)<5000) //过滤电流检测芯片损坏导致电流异常
- {
- char* lamp_err_warn = makeJson_Warn("电流不足", "灯管");
- DTU_Write("%s",lamp_err_warn);
- rt_free(lamp_err_warn);
- }
- }
- #endif
- if(device_status.version_type!=5)
- {
- if(clt_time==0)
- {
- rt_thread_delay(5000); //待灯管启动再往下执行,否则会触发电机过流
- //2.打开上仓门
- rt_kprintf("打开上仓门!!!\n");
- device_status.ctr_up_motor = 1;
- }
- //3.收集
- clt_time = device_status.clt_time * 60;
- while(clt_time!=1)
- {
- #if LAMP_EN == 0
- ctr_Fan_IN(ON);
- #endif
- clt_time --;
- rt_thread_delay(1000);
- #if LAMP_EN == 0
- if(clt_time%30==0)
- ctr_Fan_PUT(OFF);
- #endif
- rt_kprintf("正在收集.....剩余时间:%d分-%d秒\n",device_status.clt_time,clt_time);
- HMI_WRITE("workSta.g0.txt=\"正在收集.....剩余时间:%d分-%d秒\"",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 LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- HMI_WRITE("workSta.g0.txt=\"异常退出\"");
- 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 LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- HMI_WRITE("workSta.g0.txt=\"异常退出\"");
- 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 LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- HMI_WRITE("workSta.g0.txt=\"异常退出\"");
- 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 LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- rt_kprintf("异常退出!!!\n");
- HMI_WRITE("workSta.g0.txt=\"异常退出\"");
- break;
- }
- #if LAMP_EN == 0
- ctr_Fan_IN(OFF);
- #endif
- //4.关闭上仓门
- device_status.ctr_up_motor = 2;
- rt_kprintf("关闭上仓门!!!\n");
- HMI_WRITE("workSta.g0.txt=\"关闭上仓门!\"");
- 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);
- }
- }
- //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");
- HMI_WRITE("workSta.g0.txt=\"等待下仓门打开!\"");
- }
- rt_thread_delay(3000);
- //关闭下仓门
- device_status.ctr_down_motor = 2;
- while(device_status.ctr_down_motor!=0)
- {
- rt_thread_delay(100);
- rt_kprintf("等待下仓门关闭!!!\n");
- HMI_WRITE("workSta.g0.txt=\"等待下仓门关闭!\"");
- }
- //2022-04-12add:
- LOG_I("打开上仓门!!!");
- HMI_WRITE("workSta.g0.txt=\"打开上仓门!\"");
- device_status.ctr_up_motor = 1;
- if(device_status.version_type==4||device_status.version_type==41)
- {
- //震动
- ctr_shake(ON, device_status.shake_sec);
- //补光&&拍照
- LOG_I("拍照!!!");
- HMI_WRITE("workSta.g0.txt=\"拍照!\"");
- HK_TakePhoto();
- //清扫
- device_status.clear_status=1;
- //清扫失效则使用震动
- //ctr_shake(ON, 100);
- }
- }
- else {
- //打开高压
- ctr_Heat(ON);
- //打开补光
- ctr_led(ON);
- LOG_I("打开补光!!");
- rt_pin_mode(CLEAR_L_LIMIT,PIN_MODE_INPUT);
- //2.翻转清虫
- while(rt_pin_read(CLEAR_L_LIMIT)==1) rt_thread_delay(20);
- rt_thread_delay(500);
- Hk_Take_io(); //触发海康相机拍照
- rt_thread_delay(500);
- ctr_turnv5(); //摆动清虫
- LOG_I("摆动清虫!");
- }
- }
- if(device_status.bat_status == 1 || device_status.temp_status == 1 || device_status.rain_status==1 || device_status.ds==0)
- {
- rt_kprintf("-------------------not work--------------------\n");
- device_status.work_status = 0;
- }
- //工作结束
- if(device_status.work_done==0&&device_status.work_status==0)
- {
- DTU_Write("workdone");
- HMI_WRITE("workSta.g0.txt=\"工作任务已完成!\"");
- ResetInit();
- }
- rt_kprintf("***not work-device status:%d\n",device_status.ds);
- }
- /*孢子仪多段定时功能函数
- * 循环判断定时的触发
- *
- */
- u_int8_t alarmCheck(u_int8_t starthour,u_int8_t endhour)
- {
- u_int8_t workflag = 0;
- if(starthour == endhour) return workflag;
- //雨控检测,温控检测,电池电压检测
- // while(1)
- // {
- // rt_thread_delay(1000);
- if(starthour < endhour)
- {
- LOG_D("开始和结束是同一天");
- time_t now;
- time(&now);
- static struct tm nowtime; //现在
- static struct tm starttime; //开始
- static struct tm endtime; //结束
- //获取当前时间戳
- nowtime =*localtime(&now);
- nowtime.tm_hour = nowtime.tm_hour-8;
- //获取定时开始的时间戳
- starttime = *localtime(&now);
- starttime.tm_hour = starthour-8;
- starttime.tm_min = 0;
- starttime.tm_sec = 0;
- //获取定时结束的时间戳
- endtime = *localtime(&now);
- endtime.tm_hour = endhour - 8;
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- LOG_D("***工作结束在当天:现在时间:%d-开始时间:%d-结束时间:%d***",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
- //如果当前时间大于开始时间且小于结束时间,且没有开始工作
- if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&endtime))<0))
- {
- LOG_D("当前时间大于开始时间,小于结束时间,工作中!!!");
- workflag = ON;
- }
- //如果当前时间小于开始时间
- else if(difftime(mktime(&nowtime),mktime(&starttime))<0)
- {
- LOG_D("当前时间小于开始时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
- workflag = OFF;
- }
- //当前时间大于结束时间
- else {
- LOG_D("当前时间大于结束时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
- workflag = OFF;
- }
- }
- //如果结束时间是第二天
- else if (starthour>endhour)
- {
- time_t now;
- time(&now);
- static struct tm nowtime; //现在
- static struct tm starttime; //开始
- static struct tm endtime; //结束
- //获取当前时间戳
- nowtime =*localtime(&now);
- nowtime.tm_hour = nowtime.tm_hour-8;
- //获取定时开始的时间戳
- starttime = *localtime(&now);
- starttime.tm_hour = starthour - 8;
- starttime.tm_min = 0;
- starttime.tm_sec = 0;
- //获取定时结束的时间戳
- endtime = *localtime(&now);
- endtime.tm_hour = endhour-8;
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- // LOG_I("工作结束在第二天:现在时间:%d-开始时间:%d-结束时间:%d!!!",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
- //如果当前时间大于开始时间,且没有开始工作 ,注意时间戳日期加1
- if((difftime(mktime(&nowtime), mktime(&starttime)) > 0 ))
- {
- //获取定时结束的时间戳
- endtime = *localtime(&now); //将获取到的时间转换为时间戳
- endtime.tm_hour = endhour - 8; //这里需减8用于时区转换
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- workflag = ON;
- // LOG_I("当前前时间大于开始时间,且没有开始工作");
- }
- //当前时间小于开始时间
- else if ((difftime(mktime(&nowtime), mktime(&starttime)) < 0))
- {
- //获取定时结束的时间戳
- endtime = *localtime(&now); //将获取到的时间转换为时间戳
- endtime.tm_hour = endhour - 8; //这里需减8用于时区转换
- endtime.tm_min = 0;
- endtime.tm_sec = 0;
- //如果当前时间戳小于结束时间戳
- if(difftime(mktime(&nowtime),mktime(&endtime)) < 0)
- {
- // LOG_I("当前时间大于开始时间,且没有开始工作,当前时间小于结束时间的情况:计算工作时间:从当前时间工作第二天的结束时间");
- workflag = ON;
- }
- else
- {
- // LOG_I("当前时间小于开始时间,且没有开始工作,不是重启引起的,即还没到开始时间");
- workflag = OFF; //不在工作时间,待机
- }
- }
- }
- return workflag;
- //}
- }
- /* 入口函数-工作状态检测 */
- 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)
- {
- while(alarmCheck(device_status.collecting_sh1,device_status.collecting_eh1) == ON)
- {
- if(device_status.collecting_sh2==device_status.collecting_eh2){
- device_status.work_done = 1;
- }else{
- device_status.work_done = 0;
- }
- device_status.work_status = 1;
- LOG_I("the alarm1 workflag was ON");
- rt_thread_delay(1000);
- }
- while(alarmCheck(device_status.collecting_sh2,device_status.collecting_eh2) == ON)
- {
- if(device_status.collecting_sh3==device_status.collecting_eh3){
- device_status.work_done = 1;
- }else{
- device_status.work_done = 0;
- }
- device_status.work_status = 1;
- LOG_I("the alarm2 workflag was ON");
- rt_thread_delay(1000);
- }
- while(alarmCheck(device_status.collecting_sh3,device_status.collecting_eh3) == ON)
- {
- device_status.work_done = 1;
- device_status.work_status = 1;
- LOG_I("the alarm3 workflag was ON");
- rt_thread_delay(1000);
- }
- //当前时间大于3段定时结束时间
- device_status.work_status = 0;
- rt_thread_delay(1000);
- }
- }
- /*入口函数-工作流程*/
- static void Work_Loop_thread_entry(void *parameter)
- {
- rt_thread_delay(1000);
- ResetInit();
- while(1)
- {
- if(device_status.dtype==7)
- {
- WorkTask_BZYV2();
- }
- if(device_status.version_type!=6&&device_status.dtype==3)
- {
- WorkTask();
- }
- if(device_status.version_type==6)
- {
- WorkTask_XCT();
- }
- rt_thread_delay(1000);
- }
- }
- /*入口函数清扫*/
- static void Control_Clear_thread_entry(void *parameter)
- {
- while(1)
- {
- #if ROBOT_EN ==1
- ctr_Motor_Robot(ON);
- rt_thread_delay(100);
- #else
- #if Color_EN ==1
- /*复位*/
- if(Read_Color_Key(KEY_RESET)==1)
- {
- ctr_Color_board(RESET, 1200);
- rt_thread_delay(5000);
- }
- #else
- if(device_status.clear_status==1)
- {
- if(ctr_clear(1200)==0)
- ctr_TG_Clear(400);
- }
- rt_thread_delay(100);
- #endif
- #endif
- }
- }
- /*入口函数加热*/
- static void Control_Heat_thread_entry(void *parameter)
- {
- uint16_t var_clear = 0;
- #if ROBOT_EN == 1
- static uint8_t key_on = 0;
- #else
- #if Color_EN == 0
- while(device_status.work_status==0)
- {
- rt_thread_delay(1000);
- }
- #endif
- #endif
- while(1)
- {
- #if ROBOT_EN == 1
- //磁悬浮供电
- //监测磁悬浮限位位置`
- LOG_D("Read 磁悬浮:%d",device_status.heattem);
- //等待10S
- if(device_status.heattem<30&&Read_Real_Voltage()/100>12) //磁悬浮处于关闭状态
- {
- key_on = 0;
- //发送触摸按钮信号
- rt_pin_mode(EMS_Dir, PIN_MODE_OUTPUT);
- rt_pin_write(EMS_Dir, 0);
- rt_thread_delay(50);
- rt_pin_write(EMS_Dir, 1);
- }
- else if (device_status.heattem<30&&Read_Real_Voltage()/100<12) {
- ctr_router(OFF);
- }
- if(device_status.heattem>40)
- {
- key_on = 1;
- rt_thread_delay(1000);
- LOG_D("Read 磁悬浮已打开:%d",device_status.heattem);
- }
- //磁悬浮供电
- //监测磁悬浮限位位置
- //根据位置确定是否 按下按钮+
- if(Read_Real_Voltage()/100<12&&key_on==1)
- {
- key_on = 0;
- rt_pin_mode(EMS_Dir, PIN_MODE_OUTPUT);
- rt_pin_write(EMS_Dir, 0);
- rt_thread_delay(50);
- rt_pin_write(EMS_Dir, 1);
- }
- #else
- #if Color_EN == 1
- /*黄板归位*/
- if(Read_Color_Key(KEY_BACK)==1)
- {
- LOG_W("黄板归位!");
- ctr_Color_board(CLOSE, 300);
- rt_thread_delay(5000);
- }
- #else
- 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
- {
- LOG_I("Not calorstat!");
- }
- if(device_status.work_status==1&&device_status.version_type==5)
- {
- var_clear++;
- if(var_clear==300)
- {
- var_clear = 0;
- ctr_cangmen_down(ON);
- rt_thread_mdelay(5000);
- ctr_cangmen_down(OFF);
- rt_thread_mdelay(500);
- ctr_cangmen_down(ON);
- rt_thread_mdelay(5000);
- ctr_cangmen_down(OFF);
- }
- }
- rt_thread_delay(1000);
- #endif
- #endif
- }
- }
- void slidelock();
- //滑台垂直方向开关
- uint8_t ctr_swz(uint8_t status_swz)
- {
- rt_pin_mode(SHAKE_SW, PIN_MODE_OUTPUT);
- if(status_swz == ON){
- rt_pin_write(SHAKE_SW,ON);
- }
- else if(status_swz == OFF){
- rt_pin_write(SHAKE_SW,OFF);
- }
- return status_swz;
- }
- //滑台在x轴上移动xdis um;xdis必须为2的整数倍
- uint16_t ctr_xmove(uint8_t xdir,uint32_t xdis,uint8_t pulse)
- {
- uint32_t j;
- uint32_t xtemp = 0;
- xtemp = xdis; //两个脉冲移动0.72度,轴方向上移动2um
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(HK_IO, ON); //引脚输出高使能有效
- rt_pin_mode(CTR_RO_LIMIT, PIN_MODE_OUTPUT); //CCW PB15 配置为输出模式
- rt_pin_mode(CTR_RC_LIMIT, PIN_MODE_OUTPUT); //CW PC6 配置为输出模式
- ctr_swz(OFF); //Z轴方向开关=震动开关:关
- rt_thread_delay(300);
- ctr_Collect_Fan(OFF);
- rt_thread_delay(300);
- ctr_lamp(ON,1); //镇流器关=X轴开关:开
- rt_thread_delay(300);
- if(xdir == 1){
- rt_pin_write(CTR_RC_LIMIT, ON); //CCW 置高
- for(j=0;j<xtemp;j++)
- {
- if(slide_para.stop_flag == 0){
- rt_pin_write(CTR_RO_LIMIT, OFF);
- rt_thread_delay(pulse);
- rt_pin_write(CTR_RO_LIMIT, ON);
- rt_thread_delay(pulse);
- }
- else{
- break;
- }
- }
- }
- else if(xdir == 0){
- rt_pin_write(CTR_RO_LIMIT, ON); //CCW 置高
- for(j=0;j<xtemp;j++)
- {
- if(slide_para.stop_flag == 0){
- rt_pin_write(CTR_RC_LIMIT, OFF);
- rt_thread_delay(pulse);
- rt_pin_write(CTR_RC_LIMIT, ON);
- rt_thread_delay(pulse);
- }
- else{
- break;
- }
- }
- }
- else{
- }
- slidelock();
- return xdis;
- }
- //滑台在y轴上移动ydis um;ydis必须为2的整数倍
- uint16_t ctr_ymove(uint8_t ydir,uint32_t ydis,uint8_t pulse)
- {
- uint32_t j;
- uint32_t ytemp = 0;
- ytemp = ydis; //两个脉冲移动0.72度,轴方向上移动2um
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(HK_IO, ON); //引脚输出高使能有效
- rt_pin_mode(CTR_RO_LIMIT, PIN_MODE_OUTPUT); //CCW PB15 配置为输出模式
- rt_pin_mode(CTR_RC_LIMIT, PIN_MODE_OUTPUT); //CW PC6 配置为输出模式
- ctr_swz(OFF); //Z轴方向开关=震动开关:关
- rt_thread_delay(300);
- ctr_lamp(OFF,1); //镇流器关=X轴开关:关
- rt_thread_delay(300);
- ctr_Collect_Fan(ON);
- rt_thread_delay(300);
- if(ydir == 0){
- rt_pin_write(CTR_RO_LIMIT, ON); //CCW 置高
- for(j=0;j<ytemp;j++)
- {
- rt_pin_write(CTR_RC_LIMIT, OFF);
- //rt_thread_delay(pulse);
- rt_hw_us_delay(500);
- rt_pin_write(CTR_RC_LIMIT, ON);
- rt_hw_us_delay(500);
- //rt_thread_delay(pulse);
- }
- }
- else if(ydir == 1){
- rt_pin_write(CTR_RC_LIMIT, ON); //CCW 置高
- for(j=0;j<ytemp;j++)
- {
- rt_pin_write(CTR_RO_LIMIT, OFF);
- rt_hw_us_delay(500);
- //rt_thread_delay(pulse);
- rt_pin_write(CTR_RO_LIMIT, ON);
- //rt_thread_delay(pulse);
- rt_hw_us_delay(500);
- }
- }
- slidelock();
- return ydis;
- }
- uint16_t ctr_zmove(uint8_t zdir,uint32_t zdis,uint8_t pulse)
- {
- uint32_t k;
- uint32_t ztemp = 0;
- ztemp = zdis;
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(HK_IO, ON); //引脚输出高使能有效
- rt_pin_mode(CTR_RO_LIMIT, PIN_MODE_OUTPUT); //CCW PB15 配置为输出模式
- rt_pin_mode(CTR_RC_LIMIT, PIN_MODE_OUTPUT); //CW PC6 配置为输出模式
- ctr_lamp(OFF,1); //镇流器关=X轴开关:关
- rt_thread_delay(300);
- ctr_Collect_Fan(OFF);
- rt_thread_delay(300);
- ctr_swz(ON); //Z轴方向开关=震动开关:开
- rt_thread_delay(300);
- if(zdir == 1){
- rt_pin_write(CTR_RC_LIMIT, ON); //FORWARD 配置
- for(k=0;k<ztemp;k++)
- {
- if(slide_para.stop_flag == 0){
- rt_pin_write(CTR_RO_LIMIT, OFF);
- rt_thread_delay(pulse);
- rt_pin_write(CTR_RO_LIMIT, ON);
- rt_thread_delay(pulse);
- }
- else{
- break;
- }
- }
- }
- else if(zdir == 0){
- rt_pin_write(CTR_RO_LIMIT, ON); //back配置
- for(k=0;k<ztemp;k++)
- {
- if(slide_para.stop_flag == 0){
- rt_pin_write(CTR_RC_LIMIT, OFF);
- rt_thread_delay(pulse);
- rt_pin_write(CTR_RC_LIMIT, ON);
- rt_thread_delay(pulse);
- }
- else{
- break;
- }
- }
- }
- else{
- }
- slidelock();
- return zdis;
- }
- //拍照运动,X轴走xdis,Z轴走xdis,Z轴间距dzdis
- uint32_t ctr_photodz(uint32_t xdis,uint32_t zdis,uint32_t dzdis,uint8_t pulse)
- {
- uint32_t i = 0,temp = 0;
- temp = zdis/(2*dzdis);
- for(i = 1;i <= temp;i++)
- { //一个循环Z轴移动2mm
- if(slide_para.stop_flag == 0){
- ctr_xmove(1,xdis,pulse); //滑台沿z轴远离原点移动2*dzdis um
- }
- else{
- break;
- }
- if(slide_para.stop_flag == 0){
- ctr_zmove(1,dzdis,pulse); //滑台沿x轴远离原点移动2*xdis um
- }
- else{
- break;
- }
- if(slide_para.stop_flag == 0){
- ctr_xmove(0,xdis,pulse); //滑台沿z轴靠近原点移动2*dzdis um
- }
- else{
- break;
- }
- if(slide_para.stop_flag == 0){
- ctr_zmove(1,dzdis,pulse); //滑台沿x轴远离原点移动2*xdis um
- }
- else{
- break;
- }
- }
- if(slide_para.stop_flag == 0){
- ctr_xmove(1,xdis,pulse); //滑台沿z轴远离原点移动2*dzdis um
- }
- slidelock();
- return dzdis;
- }
- //拍照运动,X轴走xdis,Z轴走zdis,X轴间距xzdis,
- uint32_t ctr_photodx(uint32_t xdis,uint32_t zdis,uint32_t dxdis,uint8_t pulse)
- {
- uint32_t i = 0,temp = 0;
- temp = xdis/(2*dxdis);
- for(i = 1;i <= temp;i++)
- { //一个循环X轴移动2mm
- if(slide_para.stop_flag == 0){
- ctr_zmove(1,zdis,pulse); //滑台沿z轴远离原点移动2*dzdis um
- }
- else{
- break;
- }
- if(slide_para.stop_flag == 0){
- ctr_xmove(1,dxdis,pulse); //滑台沿x轴远离原点移动2*xdis um
- }
- else{
- break;
- }
- if(slide_para.stop_flag == 0){
- ctr_zmove(0,zdis,pulse); //滑台沿z轴靠近原点移动2*dzdis um
- }
- else{
- break;
- }
- if(slide_para.stop_flag == 0){
- ctr_xmove(1,dxdis,pulse); //滑台沿x轴远离原点移动2*xdis um
- }
- else{
- break;
- }
- }
- if(slide_para.stop_flag == 0){
- ctr_zmove(1,zdis,pulse); //滑台沿z轴远离原点移动2*dzdis um
- }
- slidelock();
- return dxdis;
- }
- //归零位函数
- void movorgxz()
- {
- //x轴归零
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(HK_IO, ON); //引脚输出高使能有效
- rt_pin_mode(CTR_RO_LIMIT, PIN_MODE_OUTPUT); //CCW PB15 配置为输出模式
- rt_pin_mode(CTR_RC_LIMIT, PIN_MODE_OUTPUT); //CW PC6 配置为输出模式
- ctr_swz(OFF); //Z轴方向开关=震动开关:关
- rt_thread_delay(300);
- ctr_Collect_Fan(OFF);
- rt_thread_delay(300);
- ctr_lamp(ON,1); //镇流器关=X轴开关:开
- rt_thread_delay(300);
- rt_pin_mode(Motor_Direction_Button, PIN_MODE_INPUT); //GET_PIN(B,8)
- rt_pin_write(CTR_RC_LIMIT, ON); //CCW back配置
- uint32_t j;
- for(j=0;j<19500;j++) //多配置300个脉冲,保证肯定能归零;
- {
- rt_pin_write(CTR_RO_LIMIT, OFF);
- rt_thread_delay(PULES);
- rt_pin_write(CTR_RO_LIMIT, ON);
- rt_thread_delay(PULES);
- if( rt_pin_read(Motor_Direction_Button)==1){ //判断得到限位信号
- rt_thread_delay(300);
- if( rt_pin_read(Motor_Direction_Button)==1)
- break;
- }
- }
- rt_thread_delay(300);
- //z轴归零
- ctr_lamp(OFF,1); //镇流器关=X轴开关:开
- rt_thread_delay(300);
- ctr_Collect_Fan(OFF);
- rt_thread_delay(300);
- ctr_swz(ON); //Z轴方向开关=震动开关:关
- rt_thread_delay(300);
- rt_pin_mode(LIMIT_RESET, PIN_MODE_INPUT); //GET_PIN(C,13)
- rt_pin_write(CTR_RC_LIMIT, ON); //back配置
- uint32_t k;
- for(k=0;k<10500;k++) //多配置300个脉冲,保证肯定能归零;
- {
- rt_pin_write(CTR_RO_LIMIT, OFF);
- rt_thread_delay(PULES);
- rt_pin_write(CTR_RO_LIMIT, ON);
- rt_thread_delay(PULES);
- if(rt_pin_read(LIMIT_RESET)==1){ //判断得到限位信号
- rt_thread_delay(300);
- if(rt_pin_read(LIMIT_RESET)==1)
- break;
- }
- }
- rt_thread_delay(300);
- slidelock();
- }
- void movorgy()
- {
- //y轴归零
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(HK_IO, ON); //引脚输出高使能有效
- rt_pin_mode(CTR_RO_LIMIT, PIN_MODE_OUTPUT); //CCW PB15 配置为输出模式
- rt_pin_mode(CTR_RC_LIMIT, PIN_MODE_OUTPUT); //CW PC6 配置为输出模式
- ctr_swz(OFF); //Z轴方向开关=震动开关:关
- rt_thread_delay(300);
- ctr_lamp(OFF,1); //镇流器关=X轴开关:开
- rt_thread_delay(300);
- ctr_Collect_Fan(ON);
- rt_thread_delay(300);
- rt_pin_mode(LIMIT_OPEN, PIN_MODE_INPUT); //GET_PIN(B,8) 20230928,限位信号调整
- rt_pin_write(CTR_RC_LIMIT, ON); //CCW back配置
- if( rt_pin_read(LIMIT_OPEN)==0) {
- for(uint32_t j=0;j<19500;j++) //多配置300个脉冲,保证肯定能归零;
- {
- rt_pin_write(CTR_RO_LIMIT, OFF);
- rt_thread_delay(PULES);
- rt_pin_write(CTR_RO_LIMIT, ON);
- rt_thread_delay(PULES);
- if( rt_pin_read(LIMIT_OPEN)==1){ //判断得到限位信号
- rt_thread_delay(300);
- if( rt_pin_read(LIMIT_OPEN)==1)
- break;
- }
- }
- }
- rt_thread_delay(300);
- slidelock();
- }
- void slidelock()
- {
- ctr_lamp(ON,1); //镇流器关=X轴开关:开
- rt_thread_delay(100);
- ctr_swz(ON); //z
- rt_thread_delay(100);
- ctr_Collect_Fan(ON); //y
- rt_thread_delay(100);
- rt_pin_mode(HK_IO, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
- rt_pin_write(HK_IO, ON); //引脚输出高使能有效
- rt_thread_delay(100);
- }
- //限位开关判断函数
- void turnlimit(void)
- {
- Motor_shake(ON,0);
- static uint16_t turn_timeout = 0;
- rt_pin_mode(LIMIT_DOWN,PIN_MODE_INPUT);
- while(rt_pin_read(LIMIT_DOWN)==0)
- {
- rt_thread_delay(20);
- while(rt_pin_read(LIMIT_DOWN)==0)
- {
- //ctr_cangmen_down(CLOSE);
- rt_thread_delay(50);
- turn_timeout++;
- if(turn_timeout==100){
- char *translate = makeJson_Warn("translate","limit timeout");
- DTU_Write("%s",translate);
- rt_free(translate);
- break;
- }
- }
- break;
- }
- while(rt_pin_read(LIMIT_DOWN)==1)
- {
- rt_thread_delay(10);
- while(rt_pin_read(LIMIT_DOWN)==1)
- {
- turn_timeout++;
- rt_thread_delay(5);
- if(turn_timeout==1000){
- char *translate = makeJson_Warn("translate","limit timeout");
- DTU_Write("%s",translate);
- rt_free(translate);
- break;
- }
- }
- break;
- }
- while(rt_pin_read(LIMIT_DOWN)==0)
- {
- rt_thread_delay(20);
- if(rt_pin_read(LIMIT_DOWN)==0)
- {
- Motor_shake(OFF,0);
- break;
- }
- else {
- break;
- }
- }
- Motor_shake(OFF,0);
- turn_timeout = 0;
- char *translate = makeJson_Warn("translate","done");
- DTU_Write("%s",translate);
- rt_free(translate);
- // rt_thread_delay(1000);
- }
- void juandai_motor()
- {
- rt_pin_mode(LIMIT_DOWN, PIN_MODE_INPUT);
- // if(device_status.reel_motoren == ON){
- // turnlimit();
- // device_status.photo_en = 1;
- // device_status.reel_motoren = OFF;
- // device_status.reel_movstatus = 0; //卷带在转动一次后锁定,移植到风机工作后才能解除;
- // }
- }
- void slide_thread_entry(void *parameter)
- {
- char movend[] = "滑台运动结束";
- slide_para.pulse_period = 1; //默认滑台的脉宽为1ms
- while(1)
- {
- rt_thread_delay(100);
- switch(slide_para.en_slide){
- case 1:{
- ctr_xmove(slide_para.xdir,slide_para.xdis,slide_para.pulse_period);
- LOG_I("The slide's x movement was done ok");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.xdir = 1;
- slide_para.xdis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- rt_thread_delay(1000);
- char *photo = makeJson_Warn("movx","takephoto_done");
- LOG_I("%s",photo);
- DTU_Write("%s",photo);
- rt_free(photo);
- break;
- }
- case 2:{
- ctr_zmove(slide_para.zdir,slide_para.zdis,slide_para.pulse_period);
- rt_kprintf("The slide's z movement was done ok\n");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.zdir = 1;
- slide_para.zdis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- rt_thread_delay(1000);
- char *photo = makeJson_Warn("movz","takephoto_done");
- LOG_I("%s",photo);
- DTU_Write("%s",photo);
- rt_free(photo);
- break;
- }
- case 3:{
- ctr_photodz(slide_para.xdis,slide_para.zdis,slide_para.dzdis,slide_para.pulse_period);
- rt_kprintf("The slide's photo movement was done ok\n");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.xdir = 1;
- slide_para.zdir = 1;
- slide_para.xdis = 0;
- slide_para.zdis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- break;
- }
- case 4:{
- ctr_photodx(slide_para.xdis,slide_para.zdis,slide_para.dxdis,slide_para.pulse_period);
- rt_kprintf("The slide's photo movement was done ok\n");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.xdir = 1;
- slide_para.zdir = 1;
- slide_para.xdis = 0;
- slide_para.zdis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- break;
- }
- case 5:{
- movorgxz();
- rt_kprintf("The slide's movement of back to xz_original point was done ok\n");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.xdir = 1;
- slide_para.zdir = 1;
- slide_para.xdis = 0;
- slide_para.zdis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- break;
- }
- case 6:{
- ctr_ymove(slide_para.ydir,slide_para.ydis,slide_para.pulse_period);
- rt_kprintf("The slide's y movement was done ok\n");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.ydir = 1;
- slide_para.ydis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- break;
- }
- case 7:{
- movorgy();
- rt_kprintf("The slide's movement of back to y_original point was done ok\n");
- HMI_WRITE("sysTest.result.txt=\"%s\"",movend);
- slide_para.xdir = 1;
- slide_para.zdir = 1;
- slide_para.xdis = 0;
- slide_para.zdis = 0;
- slide_para.stop_flag = 0;
- slide_para.en_slide = OFF;
- break;
- }
- default:
- {
- slide_para.en_slide = OFF;
- slide_para.stop_flag = 0;
- break;
- }
- }
- }
- }
- /*清扫线程*/
- 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_heat(void)
- {
- /* 创建线程*/
- tid_heat = rt_thread_create("Control_Heat_thread_entry",
- Control_Heat_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 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)
- {
- /* 创建线程*/
- 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 Color_EN == 0
- if(tid_workloop!=RT_NULL)
- {
- rt_thread_startup(tid_workloop);
- }
- #endif
- return 0;
- }
- int slide_Fresh(void)
- {
- rt_err_t ret = RT_EOK;
- rt_slide = rt_thread_create("rt_slide",
- slide_thread_entry,
- RT_NULL,
- 2048,
- 7,
- 20);
- if (rt_slide != RT_NULL)
- {
- rt_thread_startup(rt_slide);
- rt_kprintf("the thread of rt_slide start ok\n");
- }
- else
- {
- ret = RT_ERROR;
- }
- return ret;
- }
- MSH_CMD_EXPORT(HardWare_Check,HardWare_Check<ON|OFF>);
- MSH_CMD_EXPORT(ctr_lamp,ctr_lamp<ON|OFF>);
- MSH_CMD_EXPORT(ctr_clear,ctr_clear<ON|OFF>);
- MSH_CMD_EXPORT(ctr_led,sample:ctr_led <ON|OFF>);
|