freertos.c 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : freertos.c
  5. * Description : Code for freertos applications
  6. ******************************************************************************
  7. * This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * Copyright (c) 2019 STMicroelectronics International N.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted, provided that the following conditions are met:
  18. *
  19. * 1. Redistribution of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of other
  25. * contributors to this software may be used to endorse or promote products
  26. * derived from this software without specific written permission.
  27. * 4. This software, including modifications and/or derivative works of this
  28. * software, must execute solely and exclusively on microcontroller or
  29. * microprocessor devices manufactured by or for STMicroelectronics.
  30. * 5. Redistribution and use of this software other than as permitted under
  31. * this license is void and will automatically terminate your rights under
  32. * this license.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  37. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  38. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  39. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  40. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  42. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  45. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* USER CODE END Header */
  50. /* Includes ------------------------------------------------------------------*/
  51. #include "FreeRTOS.h"
  52. #include "task.h"
  53. #include "main.h"
  54. #include "cmsis_os.h"
  55. #include <stdlib.h>
  56. #include <math.h>
  57. /* Private includes ----------------------------------------------------------*/
  58. /* USER CODE BEGIN Includes */
  59. #include "spi.h"
  60. #include "tim.h"
  61. #include "TerminalSlave485.h"
  62. #include "TerminalSlave485_jt808.h"
  63. #include "KeySlave485.h"
  64. #include "CollectMaster485.h"
  65. #include "ScreenMaster485.h"
  66. #include "Elec_Seal.h"
  67. #include "Dwin.h"
  68. #include "func_queue_record.h"
  69. #include "DS1302.h"
  70. #include "Data_deal.h"
  71. #include "DS1302Drv.h"
  72. #include "usart.h"
  73. #include <string.h> //memset函数
  74. #include "func_spi_w25qxx.h"
  75. /* USER CODE END Includes */
  76. /* Private typedef -----------------------------------------------------------*/
  77. /* USER CODE BEGIN PTD */
  78. /* USER CODE END PTD */
  79. /* Private define ------------------------------------------------------------*/
  80. /* USER CODE BEGIN PD */
  81. /* USER CODE END PD */
  82. /* Private macro -------------------------------------------------------------*/
  83. /* USER CODE BEGIN PM */
  84. void DisplayRunInfo(uint32_t FunDebugCode000);
  85. void DisplaySensorInfo(void);
  86. void DisplayValveInfo(void);
  87. //void formatStr(uint16_t bufTextCang01_IO[],uint8_t Cang02_IO[],uint8_t cangNum);
  88. int formatStr(uint16_t *bufTextCang02_IO000, uint8_t *Cang02_IO000, uint8_t cangNum);
  89. int formatStrCang01(uint16_t *bufTextCang01_IO000, uint8_t *Cang01_IO000, uint8_t cangNum); //可以显示兼容的老式协议
  90. static int FRAM_cnt = 0;
  91. uint8_t vt_disp_type=0;
  92. uint32_t cntUsage = 0; //统计cpu利用率
  93. /* USER CODE END PM */
  94. /* Private variables ---------------------------------------------------------*/
  95. /* USER CODE BEGIN Variables */
  96. osThreadId Uart2_CommHandle;
  97. osThreadId Usart1_TerminalHandle; ////Task_Usart1_Terminal
  98. osThreadId Data_ProcessHandle;
  99. osThreadId DispSensorData_Handle;
  100. osThreadId VoicePlay_Handle; //语音播报任务
  101. osThreadId Task_GetCPU_Usage_Handle; //
  102. osThreadId task_record_Handle; //记录任务
  103. /* 互斥信号量句柄 */
  104. SemaphoreHandle_t xSemaphore_uart4 = NULL; //串口4 语音播报器与按键接在一个总线上
  105. unsigned char scrData[32];
  106. uint16_t bufText00[256];
  107. uint16_t bufText01Password[256];
  108. uint32_t totalRunTimeCnt; //累计运行时间
  109. uint16_t bufTextCang01_IO[256];
  110. uint16_t bufTextCang02_IO[256];
  111. uint16_t bufTextCang03_IO[256];
  112. uint16_t bufTextCang04_IO[256];
  113. uint16_t bufTextSensorInfo[1024]; //模拟量类的传感器信息 温度 液位 压力等
  114. uint8_t Cang01_IO[64];
  115. uint8_t Cang02_IO[64];
  116. uint8_t Cang03_IO[64];
  117. uint8_t Cang04_IO[64];
  118. uint8_t (*ptrIO_EachCang)[64];
  119. uint8_t Cang05_IO[64];
  120. uint8_t Cang06_IO[64];
  121. uint8_t Cang07_IO[64];
  122. uint8_t Cang08_IO[64];
  123. sT2C_ALL_Sensor_Data_Each_Cang *pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data01;
  124. //uint8_t CangNum_tskUart3=1;
  125. /* USER CODE END Variables */
  126. /* Private function prototypes -----------------------------------------------*/
  127. /* USER CODE BEGIN FunctionPrototypes */
  128. void ControllerConfig_Init(void)
  129. {
  130. // uint8_t t000;
  131. int i000;
  132. uni_float uni_flo001_init;
  133. extern float Zero_Of_LiquidMeter[8]; //8个仓的雷达液位计零点参数
  134. extern sT2C_RemoteCaliDat T2C_RemoteCaliDat001;
  135. //滑动窗口采样时间10--900秒(2字节);液位波动2--10mm(2字节),是否启用(2字节)。选用哪一个仓位的液位计进行稳油判断(0--7)(1字节)。
  136. CabinetNumForWenYou = FM25L16B_ReadByte(ADDR_Auto_OilStatic_Judgement + 7);
  137. ; //读取用于稳油判断的液位计的仓位号
  138. //运行总时间
  139. totalRunTimeCnt = (FM25L16B_ReadByte(ADDR_TotalRunTime + 0) << 24) + (FM25L16B_ReadByte(ADDR_TotalRunTime + 1) << 16) + (FM25L16B_ReadByte(ADDR_TotalRunTime + 2) << 8) + (FM25L16B_ReadByte(ADDR_TotalRunTime + 3));
  140. if (CabinetNumForWenYou > 8)
  141. { //异常处理机制 如果仓位号>8则强制其为1,并且
  142. CabinetNumForWenYou = 1;
  143. FM25L16B_WriteByte(ADDR_Auto_OilStatic_Judgement + 6, CabinetNumForWenYou);
  144. }
  145. Config_info_all.Config_fun_id = FM25L16B_ReadByte(ADDR_Config_fun_id);
  146. if (Config_info_all.Config_fun_id == 0xff)
  147. {
  148. Config_info_all.Config_fun_id = 0;
  149. //FM25L16B_WriteByte(7,Config_info_all.Config_fun_id);
  150. FM25L16B_WriteByte(ADDR_Config_fun_id, Config_info_all.Config_fun_id);
  151. }
  152. Baseval_ID = FM25L16B_ReadByte(ADDR_Baseval_ID);
  153. if ((Baseval_ID != 1) && (Baseval_ID != 2)) //一般采集板的加装不会超过2个
  154. {
  155. Baseval_ID = 1; //默认一个初始化
  156. FM25L16B_WriteByte(ADDR_Baseval_ID, Baseval_ID);
  157. }
  158. StoreNumber = FM25L16B_ReadByte(ADDR_StoreNumber);
  159. if ((StoreNumber <= 0) || (StoreNumber > 8))
  160. {
  161. StoreNumber = 3; //默认3仓
  162. FM25L16B_WriteByte(ADDR_StoreNumber, StoreNumber);
  163. }
  164. all_Store = StoreNumber;
  165. Config_info_all.All_number = all_Store;
  166. Config_info_all.Collection_id = Baseval_ID;
  167. Config_info_all.ManHole_Big_info = FM25L16B_ReadByte(ADDR_ManHole_Big_info);
  168. if ((Config_info_all.ManHole_Big_info == 0xFF) || (Config_info_all.ManHole_Big_info == 0))
  169. {
  170. Config_info_all.ManHole_Big_info = 0x03;
  171. FM25L16B_WriteByte(ADDR_ManHole_Big_info, Config_info_all.ManHole_Big_info);
  172. }
  173. Config_info_all.ManHole_small_info = FM25L16B_ReadByte(ADDR_ManHole_small_info);
  174. if ((Config_info_all.ManHole_small_info == 0xFF) || (Config_info_all.ManHole_small_info == 0))
  175. {
  176. Config_info_all.ManHole_small_info = 0x03;
  177. FM25L16B_WriteByte(ADDR_ManHole_small_info, Config_info_all.ManHole_small_info);
  178. }
  179. Config_info_all.Dump_info = FM25L16B_ReadByte(ADDR_Dump_info);
  180. if ((Config_info_all.Dump_info == 0xFF) || (Config_info_all.Dump_info == 0))
  181. {
  182. Config_info_all.Dump_info = 0x03;
  183. FM25L16B_WriteByte(ADDR_Dump_info, Config_info_all.Dump_info);
  184. }
  185. Config_info_all.HaiDiFa_info = FM25L16B_ReadByte(ADDR_Foot_info);
  186. if ((Config_info_all.HaiDiFa_info == 0xFF) || (Config_info_all.HaiDiFa_info == 0))
  187. {
  188. Config_info_all.HaiDiFa_info = 0x03;
  189. FM25L16B_WriteByte(ADDR_Foot_info, Config_info_all.HaiDiFa_info);
  190. }
  191. Config_info_all.Auto_Seal_Time = (FM25L16B_ReadByte(ADDR_AutoSealed_Time + 0) << 8) | FM25L16B_ReadByte(ADDR_AutoSealed_Time + 1);
  192. if ((Config_info_all.Auto_Seal_Time == 0xFFFF) || (Config_info_all.Auto_Seal_Time == 0))
  193. {
  194. Config_info_all.Auto_Seal_Time = 300; //自动施封----对应于5分钟,300秒
  195. // FM25L16B_WriteByte(14,(Config_info_all.Auto_Seal_Time>>8)&0xFF);
  196. // FM25L16B_WriteByte(15,Config_info_all.Auto_Seal_Time&0xFF);
  197. FM25L16B_WriteByte(ADDR_AutoSealed_Time + 0, (Config_info_all.Auto_Seal_Time >> 8) & 0xFF);
  198. FM25L16B_WriteByte(ADDR_AutoSealed_Time + 1, Config_info_all.Auto_Seal_Time & 0xFF);
  199. }
  200. if ((Config_info_all.Config_fun_id & 0x20) == 0x20) //断电保存 掉电保存电子铅封状态;下次上电自动读取
  201. {
  202. if (FM25L16B_ReadByte(ADDR_Auto_sealedOK_ID) != 0x00)
  203. {
  204. Full_Oil_allinfo.Auto_sealedOK_ID = FM25L16B_ReadByte(ADDR_Auto_sealedOK_ID);
  205. }
  206. //Full_Oil_allinfo.Break_sealing_Id=~Full_Oil_allinfo.Auto_sealedOK_ID;
  207. if (FM25L16B_ReadByte(ADDR_Break_sealing_Id) != 0x00)
  208. {
  209. Full_Oil_allinfo.Break_sealing_Id = FM25L16B_ReadByte(ADDR_Break_sealing_Id);
  210. }
  211. }
  212. // //读取车牌号
  213. // t000=FM25L16B_ReadByte(30);
  214. //
  215. //
  216. // //省域代码,一个汉字2字节
  217. // CarLicensePlate[0]=CarLicCodeArray[t000][6];
  218. // CarLicensePlate[1]=CarLicCodeArray[t000][7];
  219. //
  220. // //字母及数字代码
  221. // CarLicensePlate[2]=FM25L16B_ReadByte(31);
  222. // CarLicensePlate[3]=FM25L16B_ReadByte(32);
  223. // CarLicensePlate[4]=FM25L16B_ReadByte(33);
  224. // CarLicensePlate[5]=FM25L16B_ReadByte(34);
  225. // CarLicensePlate[6]=FM25L16B_ReadByte(35);
  226. // CarLicensePlate[7]=FM25L16B_ReadByte(36);
  227. //读取车牌号
  228. // t000=FM25L16B_ReadByte(ADDR_CarPlate_Number+0);
  229. //省域代码,一个汉字2字节
  230. CarLicensePlate[0] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 0); //CarLicCodeArray[t000][6];
  231. CarLicensePlate[1] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 1); //CarLicCodeArray[t000][7];
  232. //字母及数字代码
  233. CarLicensePlate[2] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 2);
  234. CarLicensePlate[3] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 3);
  235. CarLicensePlate[4] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 4);
  236. CarLicensePlate[5] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 5);
  237. CarLicensePlate[6] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 6);
  238. CarLicensePlate[7] = FM25L16B_ReadByte(ADDR_CarPlate_Number + 7);
  239. __nop();
  240. //读取调试状态;确定是否执行某些命令
  241. // dbgArray[0]=FM25L16B_ReadByte(37);
  242. // dbgArray[1]=FM25L16B_ReadByte(38);
  243. //
  244. //
  245. //
  246. //
  247. // dbgArray[2]=FM25L16B_ReadByte(39);
  248. // dbgArray[3]=FM25L16B_ReadByte(40);
  249. // dbgArray[4]=FM25L16B_ReadByte(41);
  250. // dbgArray[5]=FM25L16B_ReadByte(42);
  251. // dbgArray[6]=FM25L16B_ReadByte(43);
  252. // dbgArray[7]=FM25L16B_ReadByte(43);//未实现,保留用所以同上一行
  253. dbgArray[0] = FM25L16B_ReadByte(ADDR_DebugControll + 0);
  254. dbgArray[1] = FM25L16B_ReadByte(ADDR_DebugControll + 1);
  255. dbgArray[2] = FM25L16B_ReadByte(ADDR_DebugControll + 2);
  256. dbgArray[3] = FM25L16B_ReadByte(ADDR_DebugControll + 3);
  257. dbgArray[4] = FM25L16B_ReadByte(ADDR_DebugControll + 4);
  258. dbgArray[5] = FM25L16B_ReadByte(ADDR_DebugControll + 5);
  259. dbgArray[6] = FM25L16B_ReadByte(ADDR_DebugControll + 6);
  260. dbgArray[7] = FM25L16B_ReadByte(ADDR_DebugControll + 7);
  261. //读取8个仓的液位计零点参数 转换为int16类型,以便发送给采集器
  262. for (i000 = 0; i000 < 8; i000++)
  263. {
  264. uni_flo001_init.array_u8[3] = FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter + 0 + i000 * 4);
  265. uni_flo001_init.array_u8[2] = FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter + 1 + i000 * 4);
  266. uni_flo001_init.array_u8[1] = FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter + 2 + i000 * 4);
  267. uni_flo001_init.array_u8[0] = FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter + 3 + i000 * 4);
  268. OffsetYewei[i000] = uni_flo001_init.flo_Data; //(FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0)<<8) + FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);
  269. Zero_Of_LiquidMeter[i000] = uni_flo001_init.flo_Data; //
  270. }
  271. __nop();
  272. //读取8个仓的罐容表零点参数 转换为int16类型,以便发送给采集器
  273. for (i000 = 0; i000 < 8; i000++)
  274. {
  275. uni_flo001_init.array_u8[3] = FM25L16B_ReadByte(ADDR_Zero_Of_TankCapacity + 0 + i000 * 4);
  276. uni_flo001_init.array_u8[2] = FM25L16B_ReadByte(ADDR_Zero_Of_TankCapacity + 1 + i000 * 4);
  277. uni_flo001_init.array_u8[1] = FM25L16B_ReadByte(ADDR_Zero_Of_TankCapacity + 2 + i000 * 4);
  278. uni_flo001_init.array_u8[0] = FM25L16B_ReadByte(ADDR_Zero_Of_TankCapacity + 3 + i000 * 4);
  279. OffsetTankCapacity[i000] = uni_flo001_init.flo_Data; //(FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0)<<8) + FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);
  280. }
  281. __nop();
  282. //读取膨胀系数
  283. for (i000 = 0; i000 < 8; i000++)
  284. {
  285. uni_flo001_init.array_u8[3] = FM25L16B_ReadByte(ADDR_OiLType_Data + 0 + i000 * 4);
  286. uni_flo001_init.array_u8[2] = FM25L16B_ReadByte(ADDR_OiLType_Data + 1 + i000 * 4);
  287. uni_flo001_init.array_u8[1] = FM25L16B_ReadByte(ADDR_OiLType_Data + 2 + i000 * 4);
  288. uni_flo001_init.array_u8[0] = FM25L16B_ReadByte(ADDR_OiLType_Data + 3 + i000 * 4);
  289. if(uni_flo001_init.flo_Data<10 || uni_flo001_init.flo_Data>10000)
  290. uni_flo001_init.flo_Data=2000;
  291. ExpansionRatio[i000] = uni_flo001_init.flo_Data; //(FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0)<<8) + FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);
  292. }
  293. __NOP();
  294. //读取数据显示来源
  295. uni_flo001_init.array_u8[3] = FM25L16B_ReadByte(ADDR_DataSource_LiquidoMeter + 0 + 0 * 4);
  296. uni_flo001_init.array_u8[2] = FM25L16B_ReadByte(ADDR_DataSource_LiquidoMeter + 1 + 0 * 4);
  297. uni_flo001_init.array_u8[1] = FM25L16B_ReadByte(ADDR_DataSource_LiquidoMeter + 2 + 0 * 4);
  298. uni_flo001_init.array_u8[0] = FM25L16B_ReadByte(ADDR_DataSource_LiquidoMeter + 3 + 0 * 4);
  299. data_Src_To_Disp = uni_flo001_init.u32Dat; //(FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0)<<8) + FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);
  300. __NOP();
  301. addr_ext_controllBoard = (FM25L16B_ReadByte(ADDR_Extended_ContBoard + 0) << 24) + (FM25L16B_ReadByte(ADDR_Extended_ContBoard + 1) << 16) +
  302. (FM25L16B_ReadByte(ADDR_Extended_ContBoard + 2) << 8) + (FM25L16B_ReadByte(ADDR_Extended_ContBoard + 3));
  303. __NOP();
  304. FM25L16B_Read_N_Bytes(ADDR_RunAn_AlarmThreshold, T2C_RemoteCaliDat001.PayLoadData, 44);
  305. //解析8个浮点数数据
  306. for (i000 = 0; i000 < 11; i000++)
  307. {
  308. //下边4行代码顺序是反的 终端发过来的数据为1=0x3f800000
  309. uni_flo001_init.array_u8[3] = T2C_RemoteCaliDat001.PayLoadData[0 + i000 * 4];
  310. uni_flo001_init.array_u8[2] = T2C_RemoteCaliDat001.PayLoadData[1 + i000 * 4];
  311. uni_flo001_init.array_u8[1] = T2C_RemoteCaliDat001.PayLoadData[2 + i000 * 4];
  312. uni_flo001_init.array_u8[0] = T2C_RemoteCaliDat001.PayLoadData[3 + i000 * 4];
  313. AlarmArrayData[i000] = uni_flo001_init.flo_Data;
  314. }
  315. __nop();
  316. AlarmOfPressureThreshold_Upper = AlarmArrayData[0];
  317. AlarmOfPressureThreshold_Lower = AlarmArrayData[1];
  318. AlarmOfTempeThreshold_Upper = AlarmArrayData[2];
  319. AlarmOfTempeThreshold_Lower = AlarmArrayData[3];
  320. BiasOfTempe = AlarmArrayData[4];
  321. PressureWindowsSpan = AlarmArrayData[5];
  322. PressurePositiveThreshold = AlarmArrayData[6];
  323. PressureNegativeThreshold = AlarmArrayData[7];
  324. BiasOfPressure = AlarmArrayData[8];
  325. AlgType = (uint32_t)AlarmArrayData[9];
  326. FM25L16B_Read_N_Bytes(ADDR_USART1_RE_TIMEOUT, T2C_RemoteCaliDat001.PayLoadData, 4);
  327. for (i000 = 0; i000 < 1; i000++)
  328. {
  329. //下边4行代码顺序是反的 终端发过来的数据为1=0x3f800000
  330. uni_flo001_init.array_u8[3] = T2C_RemoteCaliDat001.PayLoadData[0 + i000 * 4];
  331. uni_flo001_init.array_u8[2] = T2C_RemoteCaliDat001.PayLoadData[1 + i000 * 4];
  332. uni_flo001_init.array_u8[1] = T2C_RemoteCaliDat001.PayLoadData[2 + i000 * 4];
  333. uni_flo001_init.array_u8[0] = T2C_RemoteCaliDat001.PayLoadData[3 + i000 * 4];
  334. AlarmArrayData[i000] = uni_flo001_init.flo_Data;
  335. }
  336. if (AlarmArrayData[0] > 60)
  337. {
  338. usart_timeout = (uint32_t)AlarmArrayData[0];
  339. }
  340. vt_disp_type = FM25L16B_ReadByte(ADDR_DISP_VT_TYPE);
  341. flag_En_BlankSeal = FM25L16B_ReadByte(ADDR_Enable_BlankSeal);
  342. // 开机初始化读取,SensorScanParam
  343. jt808_InitSensorScanParam();
  344. }
  345. /* USER CODE END FunctionPrototypes */
  346. void Task_Usart2_Collector(void const *argument);
  347. void Task_Usart1_Terminal(void const *argument); //终端数据处理任务
  348. void Task_Usart3_LCD_Update(void const *argument);
  349. void Task_Uart4_VoicePlay(void const *argument);
  350. void Task_GetCPU_Usage(void const *argument);
  351. void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
  352. #define TASK_BIT_1 0x01
  353. #define TASK_BIT_2 0x02
  354. #define TASK_BIT_3 0x04
  355. #define TASK_BIT_ALL (TASK_BIT_1|TASK_BIT_2|TASK_BIT_2)
  356. EventGroupHandle_t xCreatedEventGroup=NULL;
  357. static void AppObjCreate (void)
  358. {
  359. /* 创建事件标志组 */
  360. xCreatedEventGroup = xEventGroupCreate();
  361. if(xCreatedEventGroup == NULL)
  362. {
  363. /* 没有创建成功,用户可以在这里加入创建失败的处理机制 */
  364. printf("create event failure!\n");
  365. }
  366. }
  367. /**
  368. * @brief FreeRTOS initialization
  369. * @param None
  370. * @retval None
  371. */
  372. void MX_FREERTOS_Init(void)
  373. {
  374. /* USER CODE BEGIN Init */
  375. /* USER CODE END Init */
  376. /* USER CODE BEGIN RTOS_MUTEX */
  377. /* add mutexes, ... */
  378. /* USER CODE END RTOS_MUTEX */
  379. /* USER CODE BEGIN RTOS_SEMAPHORES */
  380. /* add semaphores, ... */
  381. /* USER CODE END RTOS_SEMAPHORES */
  382. /* USER CODE BEGIN RTOS_TIMERS */
  383. /* start timers, add new ones, ... */
  384. /* USER CODE END RTOS_TIMERS */
  385. /* Create the thread(s) */
  386. /* definition and creation of Uart_Comm */
  387. //osThreadDef(Uart_Comm, Task_Usart_GetAllSensorData, osPriorityAboveNormal, 0, 512);
  388. osThreadDef(Uart2_Comm, Task_Usart2_Collector, osPriorityAboveNormal, 0, 512 * 2); //20200106李伟更改
  389. Uart2_CommHandle = osThreadCreate(osThread(Uart2_Comm), NULL);
  390. osThreadDef(Uart_Terminal, Task_Usart1_Terminal, osPriorityNormal, 0, 512 * 2); //终端数据通信任务
  391. Usart1_TerminalHandle = osThreadCreate(osThread(Uart_Terminal), NULL);
  392. osThreadDef(task_record, func_record_queue_main, osPriorityBelowNormal, 0, 512 * 16);
  393. task_record_Handle = osThreadCreate(osThread(task_record), NULL);
  394. /* definition and creation of Data_Process */
  395. osThreadDef(Data_Process, Task_Usart3_LCD_Update, osPriorityNormal, 0, 512 * 4);
  396. Data_ProcessHandle = osThreadCreate(osThread(Data_Process), NULL);
  397. /* USER CODE BEGIN RTOS_THREADS */
  398. /* add threads, ... */
  399. // osThreadDef(VoicePlay_Process, Task_Uart4_VoicePlay, osPriorityNormal, 0, 512*2);
  400. // VoicePlay_Handle = osThreadCreate(osThread(VoicePlay_Process), NULL);
  401. //osPriorityNormal osPriorityHigh
  402. osThreadDef(GetCPU_Usage_Process, Task_GetCPU_Usage, osPriorityHigh, 0, 512 * 2);
  403. Task_GetCPU_Usage_Handle = osThreadCreate(osThread(GetCPU_Usage_Process), NULL);
  404. AppObjCreate();
  405. /* USER CODE END RTOS_THREADS */
  406. /* USER CODE BEGIN RTOS_QUEUES */
  407. /* add queues, ... */
  408. /* USER CODE END RTOS_QUEUES */
  409. }
  410. /* USER CODE BEGIN Header_Task_Usart_GetAllSensorData */
  411. uint8_t ReadTime[17];
  412. uint8_t TimeBuf[7] = {0x20,0x21,0x12,0x29,0x13,0x28,0x55};
  413. /**
  414. * @brief Function implementing the Uart_Comm thread.串口通信任务--接收来自终端、采集器的数据
  415. 终端为串口1;采集器为串口2;迪文屏为串口3;按键板为串口4
  416. 另外定时将零点参数下发给采集器,用于Vt修正
  417. * @param argument: Not used
  418. * @retval None
  419. */
  420. uint8_t CMD_LDYW[8]={0x01,0x04,0x0a,0x0f,0x00,0x02};
  421. #define COMM_LEVEL_FILTER_MAX_NUM 30
  422. float e2;
  423. float laterval;
  424. uni_YeweiToPlatForm uni_YeweiToPlatFormt;
  425. /* USER CODE END Header_Task_Usart_GetAllSensorData */
  426. void Task_Usart2_Collector(void const *argument)
  427. {
  428. uint16_t ModbusCRC,ModbusCRC_Check;
  429. int count=0;
  430. int retry;
  431. float flo_Data=0;
  432. /* Infinite loop */
  433. int i001 = 0;
  434. tmrForRemoteCali=SPAN_RemoteCali_INTERVAL;
  435. e2=0;
  436. laterval=0;
  437. IO_Date.IO_unload_switch |= 1;
  438. // uint8_t keyVal=0;
  439. while (1)
  440. {
  441. if (tmrForRemoteCali == 0)
  442. {
  443. ModbusCRC = Key_CRC16(CMD_LDYW, 6);
  444. CMD_LDYW[7] = ModbusCRC >> 8;
  445. CMD_LDYW[6] = ModbusCRC & 0xff;
  446. CollectMaster485_Send_Data(CMD_LDYW, 8);
  447. for (retry = 0; retry < 25; ++retry)
  448. {
  449. if (usart2_rx_flag == True)
  450. break;
  451. osDelay(15);
  452. }
  453. if (usart2_rx_flag == True)
  454. {
  455. usart2_rx_flag = False;
  456. if (USART2_RX_BUF[1] == 0x04)
  457. {
  458. ModbusCRC = Key_CRC16(USART2_RX_BUF, USART2_RX_BUF[2] + 3);
  459. ModbusCRC_Check = USART2_RX_BUF[USART2_RX_BUF[2] + 4];
  460. ModbusCRC_Check = (ModbusCRC_Check << 8) | USART2_RX_BUF[USART2_RX_BUF[2] + 3];
  461. if (ModbusCRC == ModbusCRC_Check)
  462. {
  463. uni_YeweiToPlatFormt.farray[0] = USART2_RX_BUF[4];
  464. uni_YeweiToPlatFormt.farray[1] = USART2_RX_BUF[3];
  465. uni_YeweiToPlatFormt.farray[2] = USART2_RX_BUF[6];
  466. uni_YeweiToPlatFormt.farray[3] = USART2_RX_BUF[5];
  467. if ((flo_Data == 0.0) || (abs((flo_Data - uni_YeweiToPlatFormt.flo_Data) * 1000) < 5))
  468. {
  469. uni_YeweiToPlatFormt.flo_Data = uni_YeweiToPlatFormt.flo_Data * 1000.0 - OffsetTankCapacity[0];
  470. T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[0] = ExpansionRatio[0]-uni_YeweiToPlatFormt.flo_Data;
  471. if ((uni_YeweiToPlatFormt.flo_Data < Zero_Of_LiquidMeter[0]) && (IO_Date.IO_unload_switch))
  472. {
  473. if (count < COMM_LEVEL_FILTER_MAX_NUM)
  474. {
  475. ++count;
  476. }
  477. }
  478. else
  479. {
  480. count = 0;
  481. }
  482. e2 = e2 + laterval - uni_YeweiToPlatFormt.flo_Data;
  483. // i001++;
  484. // if(i001++>300)
  485. {
  486. i001 = 0;
  487. if ((e2) < -500)
  488. IO_Date.IO_unload_switch |= 1;
  489. }
  490. laterval = uni_YeweiToPlatFormt.flo_Data;
  491. if (count >= COMM_LEVEL_FILTER_MAX_NUM)
  492. {
  493. HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_RESET);
  494. e2 = 0;
  495. }
  496. else
  497. {
  498. HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
  499. }
  500. }
  501. flo_Data = uni_YeweiToPlatFormt.flo_Data;
  502. }
  503. }
  504. }
  505. }
  506. #if 0
  507. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  508. //continue;
  509. if (En_XieYouFa_OverSample && (tmrForRemoteCali == 0))
  510. { ///针对0x13数据帧特殊处理 解决加油站采样1L左右的油品不破封的问题---开始
  511. //按照老的格式读取之前的阀门状态----多个阀门状态或运算之后进行铅封业务运算
  512. ReadCollect_ValveState_64Byte(0x000003, Collector_Get_Valve_OldFormat, 0x0002, 0x0000, 0x0000);
  513. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  514. //HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);
  515. //osDelay(SPAN_ControllerAndCollector_INTERVAL_100);
  516. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_1);
  517. Parse_0x0013_Data();
  518. Test_get_state(); //
  519. Break_Seal(); //破封检测 Elect_cover();////电子铅封系统处理
  520. } ///针对0x13数据帧特殊处理 解决加油站采样1L左右的油品不破封的问题---结束
  521. ///*
  522. if ((Read_Collect485_Flag) && (tmrForRemoteCali == 0))
  523. {
  524. Read_Collect485_Flag = False;
  525. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  526. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_1);
  527. ReadAllStoreValue(); //读取传感器数据
  528. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_1);
  529. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  530. //HAL_Delay(20);
  531. CollectData_Transform_UsefullData();
  532. //if (PlatformCalibrat.Restart_Controller == False)
  533. // HAL_GPIO_TogglePin(GPIOC, DWI_Pin);
  534. // ds1302_Get_Time(ReadTime);
  535. // KeySlave485_Send_Data(ReadTime,17);
  536. //HAL_Delay(20);
  537. }
  538. //if(((i00Data%2)==0) && (tmrForRemoteCali==0))//非标定模式
  539. if (tmrForRemoteCali == 0) //非标定模式 收到0x3901进入标定模式,保持20s 将资源留给标定命令
  540. {
  541. //if((i00task_usart3%3)==0)
  542. {
  543. Elect_cover(); ////电子铅封系统处理
  544. }
  545. #if 0
  546. if (StartUpdate_Screen_Flag == True) //1S更新一次小屏状态
  547. {
  548. StartUpdate_Screen_Flag = False;
  549. Dispaly_CarAndValveState();
  550. }
  551. #endif
  552. Test_get_state(); //实时获取阀门状态------------标定数据
  553. }
  554. Immediate_Processing_Function(); //来自按键串口或者终端的标定数据处理
  555. if (flag_Seal_Break == 1)
  556. {
  557. //xSemaphoreTake(xSemaphore_uart4, portMAX_DELAY);
  558. Send_alarm10S(); //破封报警发送
  559. //xSemaphoreGive(xSemaphore_uart4);
  560. flag_Seal_Break = 0;
  561. }
  562. //*/
  563. if (i001 >= 10)
  564. {
  565. ; //MX_UART4_Init();
  566. i001 = 0;
  567. //ds1302_Read_Time();//有问题 待调试
  568. //DS1302_get_all();
  569. }
  570. //if(1==10)
  571. if (En_XieYouFa_OverSample && (tmrForRemoteCali == 0))
  572. { ///针对0x13数据帧特殊处理 解决加油站采样1L左右的油品不破封的问题---开始
  573. //按照老的格式读取之前的阀门状态----多个阀门状态或运算之后进行铅封业务运算
  574. ReadCollect_ValveState_64Byte(0x000003, Collector_Get_Valve_OldFormat, 0x0002, 0x0000, 0x0000);
  575. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  576. //HAL_Delay(SPAN_ControllerAndCollector_INTERVAL);
  577. //osDelay(SPAN_ControllerAndCollector_INTERVAL_100);
  578. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_1);
  579. Parse_0x0013_Data();
  580. Test_get_state(); //
  581. Break_Seal(); //破封检测 Elect_cover();////电子铅封系统处理
  582. } ///针对0x13数据帧特殊处理 解决加油站采样1L左右的油品不破封的问题---结束
  583. #endif
  584. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_1);
  585. osDelay(40); //阻塞时间
  586. }
  587. /* USER CODE END Task_Usart2_Collector */
  588. }
  589. /* USER CODE BEGIN Header_Task_LCD_Update */
  590. /**
  591. * @brief Function implementing the Data_Process thread.
  592. * @param argument: Not used
  593. 在屏幕上显示运行信息
  594. * @retval None
  595. */
  596. /* USER CODE END Header_Task_LCD_Update */
  597. uint16_t bufText00[256];
  598. uint16_t bufText01Password[256];
  599. char msg000[256] = "罐车安全智能监控系统杭州嘉隆物联网科技有限公司";
  600. //char Beijing_title[256]=" 海底阀-卸油阀-人孔盖-排沉阀-有无油 ";//北京部队试用阀门标题栏
  601. //char arrValve_title01[256]=" 底阀,卸油阀,人孔盖,小孔盖,管道油,底阀余油";// 阀门标题栏
  602. char arrValve_title01[256] = " 海底阀 右卸油阀 左卸油阀 管道油"; // 阀门标题栏
  603. //char arrValve_title02[256]="海底阀1卸油阀1卸油阀2人孔盖1卸尽否1卸尽否2";//新疆鑫长宇 阀门标题栏
  604. //char arrValve_title02[256]=" 海底阀1卸油阀1人孔盖1小孔盖1卸尽否1 ";//新疆鑫长宇 阀门标题栏
  605. //char arrValve_title02[256]=" 海底阀 卸油阀 人孔盖 小孔盖 管道油 壁挂油 回收口 底阀油 ";//内蒙古项目 阀门标题栏
  606. #if 0
  607. char arrValve_title02[256] = " 海底阀 卸油阀 人孔盖 小孔盖 管道油"; //中岚项目 阀门标题栏
  608. #else
  609. char arrValve_title02[256] = " 空高(mm) 液位(mm) 液位告警值(mm)";
  610. #endif
  611. uint32_t tick001;
  612. extern uint8_t flag_Sw_DisplaySensorData;
  613. //extern uint8_t Usart2_ErrorTimes,chkRetCaiJiBan;
  614. /*
  615. 人机接口任务---主要是进行数据的业务层运算,刷新信息显示。
  616. */
  617. void Task_Usart3_LCD_Update(void const *argument)
  618. {
  619. uint16_t i00task_usart3 = 0; //,i002=0;
  620. int i001_DataTask, Len000;
  621. /* USER CODE BEGIN Task_Usart3_LCD_Update */
  622. ControllerConfig_Init();
  623. Init_Dwin_Signal();
  624. osDelay(50);
  625. Restart_LCD();
  626. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  627. osDelay(50);
  628. WrDwinCmd32(0x0084, 0x5A010000 | 0); //开机logo
  629. osDelay(500);
  630. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  631. //在启动界面上显示版本号
  632. //bufText01Password[0] = ADDR_DWIN_Text05;
  633. //WrDwinBuf(ADDR_DWIN_Text05_SP, bufText01Password, 1, 0);
  634. Len000 = sprintf((char *)bufText01Password, "硬件版本:%s,软件版本:%s;\r\nSN:%s.", Version_hardware, Version_software, product_ID);
  635. WrDwinBuf(ADDR_DWIN_Text05, bufText01Password, Len000, 1);
  636. osDelay(1000);//
  637. //HAL_Delay(300);
  638. //WrDwinCmd32(0x0084, 0x5A010000 | 0); //开机logo
  639. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  640. WrDwinCmd16(0x0082, 0x6464); //开机屏亮
  641. Data_From_Server_0x6401_001.res001_u8 = 0x00; //显示服务器数据
  642. osDelay(300);
  643. Lcd_Init();
  644. HAL_GPIO_WritePin(GPIOE, BEEP_Pin, GPIO_PIN_RESET);
  645. osDelay(1000); //HAL_Delay(1000);
  646. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //复位看门狗sp706
  647. HAL_GPIO_WritePin(GPIOE, BEEP_Pin, GPIO_PIN_SET);
  648. // HAL_GPIO_WritePin(GPIOE, BEEP_Pin, GPIO_PIN_RESET);
  649. // HAL_Delay(1000);
  650. // HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//复位看门狗sp706
  651. // HAL_GPIO_WritePin(GPIOE, BEEP_Pin, GPIO_PIN_SET);
  652. //李伟更改-----发布状态下,不在屏幕上显示密码 20210609
  653. if (ShowPassword_JieFeng_En == 1)
  654. {
  655. bufText01Password[0] = ADDR_DWIN_Text01; //显示文本命令
  656. WrDwinBuf(ADDR_DWIN_Text01_SP, bufText01Password, 1, 0);
  657. bufText01Password[0] = ADDR_DWIN_SensorInfo; //显示模拟量类传感器信息
  658. WrDwinBuf(ADDR_DWIN_SensorInfo_SP, bufText01Password, 1, 0);
  659. bufText01Password[0] = ADDR_DWIN_Text02;
  660. WrDwinBuf(ADDR_DWIN_Text02_SP, bufText01Password, 1, 0);
  661. bufText01Password[0] = ADDR_DWIN_Text03_sysInfo;
  662. WrDwinBuf(ADDR_DWIN_Text03_SP, bufText01Password, 1, 0);
  663. bufText01Password[0] = ADDR_DWIN_Text04;
  664. WrDwinBuf(ADDR_DWIN_Text04_SP, bufText01Password, 1, 0);
  665. //显示汉字
  666. memcpy(bufText01Password, msg000, 64); //
  667. WrDwinBuf(ADDR_DWIN_Text01, bufText01Password, 80, 1);
  668. WrDwinBuf(ADDR_DWIN_Text02, bufText01Password, 80, 1);
  669. WrDwinBuf(ADDR_DWIN_Text03_sysInfo, bufText01Password, 80, 1);
  670. WrDwinBuf(ADDR_DWIN_Text04, bufText01Password, 80, 1);
  671. }
  672. else
  673. {
  674. #if 0
  675. for (i001_DataTask = 0; i001_DataTask < 3; i001_DataTask++)
  676. {
  677. bufText01Password[0] = 0xff00; //隐藏文本命令
  678. WrDwinBuf(ADDR_DWIN_Text01_SP, bufText01Password, 1, 0);
  679. WrDwinBuf(ADDR_DWIN_Text02_SP, bufText01Password, 1, 0);
  680. HAL_Delay(200);
  681. WrDwinBuf(ADDR_DWIN_Text03_SP, bufText01Password, 1, 0);
  682. WrDwinBuf(ADDR_DWIN_Text04_SP, bufText01Password, 1, 0);
  683. WrDwinBuf(ADDR_DWIN_SensorInfo_SP, bufText01Password, 1, 0); //隐藏模拟量类传感器信息
  684. // HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  685. }
  686. #endif
  687. }
  688. //系统运行信息隐藏或者显示
  689. if (flag_Sw_DispSysInfo == 0)
  690. {
  691. bufText01Password[0] = 0xff00; //隐藏文本命令
  692. WrDwinBuf(ADDR_DWIN_Text03_SP, bufText01Password, 1, 0);
  693. HAL_Delay(10);
  694. }
  695. else
  696. {
  697. //bufText01Password[0] = ADDR_DWIN_Text03_sysInfo;
  698. //WrDwinBuf(ADDR_DWIN_Text03_SP, bufText01Password, 1, 0);
  699. }
  700. if (DisplaySensorData_En == 0)
  701. { //隐藏模拟量类的传感器显示控件
  702. bufText01Password[0] = 0xff00; //隐藏文本命令
  703. WrDwinBuf(ADDR_DWIN_SensorInfo_SP, bufText01Password, 1, 0);
  704. HAL_Delay(10);
  705. }
  706. else
  707. { //显示模拟量类的传感器显示控件
  708. bufText01Password[0] = ADDR_DWIN_SensorInfo;
  709. WrDwinBuf(ADDR_DWIN_SensorInfo_SP, bufText01Password, 1, 0);
  710. osDelay(30);
  711. bufText01Password[0] = ADDR_DWIN_SensorInfo;
  712. WrDwinBuf(ADDR_DWIN_SensorInfo_SP, bufText01Password, 1, 0);
  713. }
  714. //禁止打印命令创鑫微电子
  715. PrintBuff[0] = 0x1b;
  716. PrintBuff[1] = 0x64;
  717. PrintBuff[2] = 0x00;
  718. KeySlave485_Send_Data((uint8_t *)PrintBuff, 3);
  719. memset(PrintBuff, 0, sizeof(PrintBuff));
  720. //济南打印机HOE公司
  721. PrintBuff[0] = 0x03; //
  722. PrintBuff[1] = 0xaa;
  723. KeySlave485_Send_Data((uint8_t *)PrintBuff, 2);
  724. osDelay(50);
  725. //禁止打印命令;济南打印机HOE公司
  726. // PrintBuff[0]=0x03;//
  727. // PrintBuff[1]=0xaa;
  728. // KeySlave485_Send_Data((uint8_t *)PrintBuff,2);
  729. //如果仓数为2 则将2仓的阀门顺序拷贝之1仓,因为有多处使用1仓标题进行显示
  730. // if((StoreNumber==2) || (StoreNumber==3))
  731. {
  732. // memset((char *)arrValve_title01, 0, sizeof(arrValve_title01));
  733. // memcpy(arrValve_title01, arrValve_title02, sizeof(arrValve_title02));
  734. }
  735. //显示标题栏
  736. memset(bufTextCang01_IO, ' ', sizeof(bufTextCang01_IO));
  737. //Len000 = sprintf((char *)bufTextCang01_IO + 16 * 0, "%s", arrValve_title01); // %02d\r\n
  738. Len000 = sprintf((char *)bufTextCang01_IO, "%s", arrValve_title02);
  739. memset((char *)bufTextCang01_IO + Len000, 0, sizeof(bufTextCang01_IO) - Len000);
  740. ; //taskENTER_CRITICAL();
  741. ; //
  742. WrDwinBuf(ADDR_DWIN_Title_IO,&bufTextCang01_IO[0],Len000,1);
  743. ; //taskEXIT_CRITICAL();
  744. osDelay(350);
  745. tmrForPrinter = 15000; //启动定时器,15s内只能打印一次
  746. pT2C_SetupData->Reserved_parameters_4 = 2.0f; //迪文屏显示来自采集器的数据
  747. //pT2C_SetupData->Reserved_parameters_4=1.0f;//迪文屏默认显示来自平台的数据 而不是采集器的数据
  748. //56454的车默认p3=3;54021的车默认p3=1;
  749. pT2C_SetupData->Reserved_parameters_3 = 1.0f; //温度传感器取第1个点的温度
  750. i00task_usart3=5;
  751. Full_Oil_allinfo.Car_state_disp=-1;
  752. Jump_page_id(Run_mode_key_info.current_page);
  753. /* Infinite loop */
  754. while (1)
  755. {
  756. i00task_usart3++;
  757. if (i00task_usart3 > 1000)
  758. {
  759. i00task_usart3 = 0;
  760. }
  761. // //if(((i00Data%2)==0) && (tmrForRemoteCali==0))//非标定模式
  762. // if(tmrForRemoteCali==0)//非标定模式 收到0x3901进入标定模式,保持20s 将资源留给标定命令
  763. // {
  764. //
  765. // if((i00task_usart3%3)==0)
  766. // {
  767. // Elect_cover();////电子铅封系统处理
  768. // }
  769. //
  770. //
  771. // if(StartUpdate_Screen_Flag ==True)//1S更新一次小屏状态
  772. // {
  773. // StartUpdate_Screen_Flag =False;
  774. // Dispaly_CarAndValveState();
  775. // }
  776. //
  777. // Test_get_state(); //实时获取阀门状态------------标定数据
  778. // }
  779. //Read_REAL_Time();//获取迪文屏时间,刷新至全局变量
  780. //HAL_Delay(10);
  781. //Read_REAL_Time();//获取迪文屏时间,刷新至全局变量
  782. //if(i00Data>=1*2)//给屏幕发送指令,刷新传感器的数值显示
  783. #if 0
  784. ValStateConvertTo91();
  785. #endif
  786. if (StartUpdate_Screen_Flag == True) //1S更新一次小屏状态
  787. {
  788. StartUpdate_Screen_Flag = False;
  789. Dispaly_CarAndValveState();
  790. }
  791. if ((i00task_usart3 % 2) == 0)
  792. {
  793. //偶数的时候显示模拟量类传感器信息--开始
  794. if ((DisplaySensorData_En) && (flag_Sw_DisplaySensorData == 1))
  795. {
  796. DisplaySensorInfo(); //显示运行信息(传感器信息 温度 压力 液位 密度 V20等参数)
  797. }
  798. } //偶数的时候显示模拟量类传感器信息--开始
  799. if ((i00task_usart3 % 20) == 1)
  800. {
  801. //指示灯1 表明系统正在运行
  802. //HAL_GPIO_TogglePin(GPIOE, LED1_Pin);
  803. //显示阀门类信息、运行信息--开始
  804. // if(((i00Data%10)==5) && (Usart2_ErrorTimes==0))
  805. // {//清除异常标志
  806. // WrDwinCmd16(ADDR_DWIN_StateYiChang_HaiDiFa,0x00);//底阀异常
  807. // WrDwinCmd16(ADDR_DWIN_StateYiChang_XieYouFa,0x00);//卸油阀异常
  808. // }
  809. tick001 = HAL_GetTick(); //
  810. //FunDebugCode=DebugFun_Version;//
  811. DisplayRunInfo(FunDebugCode); //显示运行信息(功能码解码之后信息、功能码信息等)
  812. //osDelay(50);
  813. //DisplayValveInfo(); //显示阀门类传感器信息
  814. //李伟修改 20210419 强制屏幕唤醒 并且跳到相应的图形页面-----开始
  815. //if(Lcd_sleep_flag ==2)//唤醒休眠
  816. //if(1==1)
  817. #if 0
  818. if (tmrForKeyPad > 10) //如果有按键操作则强制唤醒休眠
  819. {
  820. Lcd_sleep_flag = 3;
  821. //HAL_Delay(LCD_TimeOfWake);//
  822. // osDelay(LCD_TimeOfWake);
  823. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  824. WrDwinCmd16(0x0082, 0x6464); //亮度调节0x0000~0x6464
  825. //HAL_Delay(LCD_TimeOfWake);//
  826. // osDelay(LCD_TimeOfWake);
  827. Jump_page_id(Run_mode_key_info.current_page);
  828. //HAL_Delay(LCD_TimeOfWake);//
  829. // osDelay(LCD_TimeOfWake);
  830. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  831. }
  832. #endif
  833. //李伟修改 20210419 强制屏幕唤醒 并且跳到相应的图形页面-----结束
  834. } //显示阀门类信息、运行信息--结束
  835. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_3);
  836. osDelay(40);
  837. //osDelay(100 * 3); //阻塞延时,根据情况调节 20
  838. }
  839. /* USER CODE END Task_Usart3_LCD_Update */
  840. }
  841. /* USER CODE BEGIN Header_Task_Usart1_Terminal */
  842. /**
  843. * @brief Function implementing the Data_Process thread.
  844. * @param argument: Not used
  845. * @retval None
  846. */
  847. /* USER CODE END Header_Task_Usart1_Terminal */
  848. uint8_t keyValTsk01 = 0;
  849. void Task_Usart1_Terminal(void const *argument)
  850. {
  851. /* USER CODE BEGIN Task_Usart1_Terminal */
  852. int i_task01 = 0;
  853. #if IR_ROM1 == 0x8000000
  854. i_task01=sprintf((char*)&USART1_TX_BUF[0],"App01 %s %s\r\n",__DATE__,__TIME__);
  855. #else
  856. i_task01=sprintf((char*)&USART1_TX_BUF[0],"App02 %s %s\r\n",__DATE__,__TIME__);
  857. #endif
  858. //i_task01=sprintf((char*)&USART1_TX_BUF[0],"App01起始地址0x08000000\r\n");
  859. TerminalSlave485_Send_Data(USART1_TX_BUF,i_task01);
  860. osDelay(100);
  861. i_task01=0;
  862. /* Infinite loop */
  863. while (1)
  864. { //while(1)
  865. // if (usart1_rx_flag)
  866. {
  867. Data_analysis(); //终端数据--串口1
  868. }
  869. i_task01++;
  870. if (i_task01 > 8000)
  871. {
  872. i_task01 = 0;
  873. }
  874. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  875. if (i_task01 % 10 == 0) //调节按键灵敏度 键盘的灵敏度
  876. { //调节按键灵敏度 键盘的灵敏度
  877. keyValTsk01 = Get_keyvalue();
  878. if (keyValTsk01 != 0)
  879. { //if(keyValTsk01!=0)
  880. Mode_key_pageID();
  881. if (FnKey == F2_and_key4)
  882. { //强制复位
  883. FnKey = 0;
  884. Reboot_System();
  885. } //强制复位
  886. } //if(keyValTsk01!=0)
  887. } //调节按键灵敏度 键盘的灵敏度
  888. xEventGroupSetBits(xCreatedEventGroup, TASK_BIT_2);
  889. osDelay(10); //阻塞延时,根据情况调节------保证每秒钟可以接收4帧数据,50*Nms休眠时间
  890. // xy,新透传,41串口透传,模拟F3轮询传感器,构建数据
  891. if(Pass41SensorScanParam.enable && i_task01 % 100 == 99)
  892. {
  893. jt808_DoInternalSensorScanAndPost();
  894. }
  895. } //while(1)
  896. /* USER CODE END Task_Usart1_Terminal */
  897. }
  898. #if USE_TIME_FRAM
  899. void fram_time_read(SDateTime * p_datetime)
  900. {
  901. FM25L16B_Read_N_Bytes(FRAM_ADDR_TIME_record, (uint8_t *)p_datetime, sizeof(SDateTime));
  902. return;
  903. }
  904. void ds1302_time_init(SDateTime datetime)
  905. {
  906. uint8_t buf[32] = {0};
  907. buf[1] = datetime.year%100 ; //年
  908. buf[2] = datetime.month; //月
  909. buf[3] = datetime.day; //日
  910. buf[4] = datetime.hour; //时
  911. buf[5] = datetime.min; //分
  912. buf[6] = datetime.sec&0x7f; //秒,屏蔽秒的第7位,避免超出59
  913. ds1302_Write_Time(buf);
  914. }
  915. void fram_time_write(SDateTime datetime)
  916. {
  917. datetime.min++;
  918. FM25L16B_Write_N_Bytes(FRAM_ADDR_TIME_record, (uint8_t *)&datetime, sizeof(SDateTime));
  919. return;
  920. }
  921. #endif
  922. /* USER CODE BEGIN Header_Task_GetCPU_Usage */
  923. /**
  924. * @brief Function implementing the Data_Process thread.
  925. * @param argument: Not used
  926. * @retval None
  927. */
  928. /* USER CODE END Header_Task_GetCPU_Usage */
  929. SDateTime m_datetime;
  930. void Task_GetCPU_Usage(void const *argument)
  931. {
  932. /* USER CODE BEGIN Task_GetCPU_Usage */
  933. char hour=0xff;
  934. char min=0xff;
  935. int count;
  936. int i_task01;
  937. EventBits_t uxBits;
  938. ds1302_Init();
  939. #if USE_TIME_FRAM
  940. fram_time_read(&m_datetime);
  941. ds1302_time_init(m_datetime);
  942. #endif //======USE_TIME_FRAM=============
  943. UNUSED(min);
  944. count=0;
  945. /* Infinite loop */
  946. while (1)
  947. {
  948. //DispRunInfo();//显示运行信息
  949. cntUsage++;
  950. osDelay(500); //阻塞延时,根据情况调节
  951. //2022-9-13, xy, 这里RTC时钟是按每分钟去读取一下RTC芯片校时的,但实在没必要如此频繁,优化成每小时
  952. if(m_datetime.hour!=hour)
  953. {
  954. ds1302_SynTime(&m_datetime);
  955. hour = m_datetime.hour;
  956. }
  957. //add boly 20221019
  958. if(m_datetime.min!=min)
  959. {
  960. #if USE_TIME_FRAM
  961. fram_time_write(m_datetime);
  962. min = m_datetime.min;
  963. #endif //==============USE_TIME_FRAM====================
  964. #if 0
  965. m_datetime.day++;
  966. ds1302_time_init(m_datetime);
  967. #endif
  968. }
  969. //end boly
  970. uxBits = xEventGroupWaitBits(xCreatedEventGroup, /* 事件标志组句柄 */
  971. TASK_BIT_ALL, /* 等待TASK_BIT_ALL被设置 */
  972. pdTRUE, /* 退出前TASK_BIT_ALL被清除,这里是TASK_BIT_ALL都被设置才表示“退出”*/
  973. pdTRUE, /* 设置为pdTRUE表示等待TASK_BIT_ALL都被设置*/
  974. 500); /* 等待延迟时间 */
  975. if((uxBits & TASK_BIT_ALL) == TASK_BIT_ALL)
  976. {
  977. count=0;
  978. }
  979. else
  980. {
  981. //int txlen=sprintf(USART1_TX_BUF,"uxBits=%x count=%d\r\n",uxBits,count);
  982. //TerminalSlave485_Send_Data(USART1_TX_BUF,txlen);
  983. ++count;
  984. }
  985. if(count<40)
  986. {
  987. HAL_GPIO_TogglePin(GPIOC, DWI_Pin);
  988. HAL_GPIO_TogglePin(GPIOE, LED1_Pin);
  989. }
  990. else
  991. {
  992. i_task01=sprintf((char*)&USART1_TX_BUF[0],"system should reboot %x\r\n",uxBits);
  993. TerminalSlave485_Send_Data(USART1_TX_BUF,i_task01);
  994. }
  995. __nop();
  996. if(usart_timeout && usart_timeout<usart_timesec)
  997. {
  998. Reboot_System();
  999. }
  1000. }
  1001. /* USER CODE END Task_GetCPU_Usage */
  1002. }
  1003. /* USER CODE BEGIN Header_Data_Task */
  1004. /**
  1005. * @brief Function implementing the Data_Process thread.
  1006. * @param argument: Not used
  1007. * @retval None
  1008. */
  1009. /* USER CODE END Header_Data_Task */
  1010. //void Get_Cpu_Usage_Task(void const * argument)
  1011. //{
  1012. // /* USER CODE BEGIN Data_Task */
  1013. //
  1014. //
  1015. // //HAL_Delay(1000);
  1016. //
  1017. // /* Infinite loop */
  1018. // while(1)
  1019. // {
  1020. //
  1021. // //DispRunInfo();//显示运行信息
  1022. // osDelay(10); //阻塞延时,根据情况调节
  1023. //
  1024. // cntUsage++;
  1025. //
  1026. //
  1027. //
  1028. // }
  1029. // /* USER CODE END Data_Task */
  1030. //}
  1031. /* USER CODE BEGIN Header_Data_Task */
  1032. /**
  1033. * @brief Function implementing the Data_Process thread.
  1034. * @param argument: Not used
  1035. * @retval None
  1036. */
  1037. char SpeakerBuff[64 + 64]; //可以播放24个汉字,48个英文字母
  1038. uint16_t crc000, LenToSpk, LenOfMsg, i000_Voice;
  1039. /* USER CODE END Header_Data_Task */
  1040. #include "Data_deal.h" //CRC16_MODBUS函数
  1041. int LenVoi000;
  1042. void Task_Uart4_VoicePlay(void const *argument)
  1043. {
  1044. /* USER CODE BEGIN Task_Uart4_VoicePlay */
  1045. //HAL_Delay(1000);
  1046. i000_Voice = 1;
  1047. /* Infinite loop */
  1048. while (1)
  1049. {
  1050. //HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1051. //HAL_Delay(20);
  1052. if (flag_Uart4_Busy == 1)
  1053. {
  1054. continue;
  1055. }
  1056. if (flag_Sw_VoicePlay == 0) //语音播报通过按键关闭
  1057. {
  1058. continue;
  1059. }
  1060. xSemaphoreTake(xSemaphore_uart4, portMAX_DELAY);
  1061. //李伟修改 20210626
  1062. //语音报警
  1063. memset(SpeakerBuff, 0, sizeof(SpeakerBuff));
  1064. SpeakerBuff[0] = 0x03;
  1065. SpeakerBuff[1] = 0x10;
  1066. SpeakerBuff[2] = 0x00;
  1067. SpeakerBuff[3] = 0x33;
  1068. SpeakerBuff[4] = 0x00;
  1069. SpeakerBuff[5] = 0x08;
  1070. SpeakerBuff[6] = 0x11;
  1071. SpeakerBuff[7] = 0x00;
  1072. SpeakerBuff[8] = 0x01;
  1073. // SpeakerBuff[9]=0x03;
  1074. // SpeakerBuff[10]=0x03;
  1075. #if (VoicePlay_En)
  1076. switch (i000_Voice)
  1077. {
  1078. case 1: //1仓播报数据
  1079. //if(ValState01 & GPIO_PIN_0)//1仓人孔大盖
  1080. LenOfMsg = 0;
  1081. LenVoi000 = 9;
  1082. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1083. // LenOfMsg=sprintf(SpeakerBuff+LenVoi000,"%2d仓",i000_Voice);
  1084. // LenVoi000=LenVoi000+LenOfMsg;//strlen();
  1085. // Cang01_IO[0]=0x01;
  1086. // Cang01_IO[1]=0x01;
  1087. // Cang01_IO[2]=0x01;
  1088. // Cang01_IO[13]=0x01;
  1089. if (Cang01_IO[0 + 7] == 0x01) //1仓海底阀
  1090. {
  1091. LenOfMsg = sprintf(SpeakerBuff + 9, "一仓海底阀未关!");
  1092. LenVoi000 = 9 + LenOfMsg; //strlen();
  1093. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1094. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1095. __nop();
  1096. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1097. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1098. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1099. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1100. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1101. //HAL_Delay(1000);
  1102. osDelay(1000);
  1103. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1104. //HAL_Delay(1000);
  1105. osDelay(1000);
  1106. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1107. }
  1108. //if(ValState01 & GPIO_PIN_1)//1仓卸油阀
  1109. //Cang01_IO[1]=0x01;
  1110. if (Cang01_IO[1 + 7] == 0x01) //1仓
  1111. {
  1112. LenOfMsg = sprintf(SpeakerBuff + 9, "一仓卸油阀未关!");
  1113. LenVoi000 = 9 + LenOfMsg; //strlen();
  1114. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1115. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1116. __nop();
  1117. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1118. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1119. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1120. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1121. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1122. //HAL_Delay(1000);
  1123. osDelay(1000);
  1124. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1125. //HAL_Delay(1000);
  1126. osDelay(1000);
  1127. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1128. }
  1129. //if(ValState01 & GPIO_PIN_2)//1仓人孔大盖
  1130. //Cang01_IO[2]=0x01;
  1131. if (Cang01_IO[2 + 7] == 0x01) //1仓
  1132. {
  1133. LenOfMsg = sprintf(SpeakerBuff + 9, "一仓人孔盖未关!");
  1134. LenVoi000 = 9 + LenOfMsg; //strlen();
  1135. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1136. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1137. __nop();
  1138. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1139. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1140. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1141. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1142. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1143. //HAL_Delay(1000);
  1144. osDelay(1000);
  1145. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1146. //HAL_Delay(1000);
  1147. osDelay(1000);
  1148. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1149. }
  1150. //if(ValState01 & GPIO_PIN_3)//1仓排尘阀----索引为13专门表示排沉阀
  1151. if (Cang01_IO[13] == 0x01) //1仓
  1152. {
  1153. LenOfMsg = sprintf(SpeakerBuff + 9, "一仓排沉阀未关!");
  1154. LenVoi000 = 9 + LenOfMsg; //strlen();
  1155. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1156. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1157. __nop();
  1158. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1159. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1160. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1161. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1162. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1163. //HAL_Delay(1000);
  1164. osDelay(1000);
  1165. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1166. //HAL_Delay(1000);
  1167. osDelay(1000);
  1168. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1169. }
  1170. /*
  1171. LenOfMsg=sprintf(SpeakerBuff+LenVoi000,"未关....");
  1172. LenVoi000=LenVoi000+LenOfMsg;//strlen();
  1173. //LenOfMsg=sprintf(SpeakerBuff+9,"%2d仓海底阀未关",5);
  1174. LenToSpk=LenVoi000;//9+LenOfMsg-0;
  1175. //更新数据长度
  1176. SpeakerBuff[6]=LenToSpk+2;//LenOfMsg+2+0;//加上2字节的crc
  1177. __nop();
  1178. crc000=CRC16_MODBUS((unsigned char*)SpeakerBuff,LenToSpk);
  1179. SpeakerBuff[LenToSpk]=crc000 >>8;
  1180. SpeakerBuff[LenToSpk+1]=crc000 & 0x00ff;
  1181. //03 10 00 33 00 08 10 00 01 20 35 B2 D6 BA A3 B5 D7 B7 A7 CE B4 B9 D8 A5 08 --5仓海底阀未关
  1182. //03 10 00 33 00 08 11 00 01 D2 BB B2 D6 C8 CB BF D7 B8 C7 CE B4 B9 D8 82 4E 一仓人孔盖未关
  1183. //if(ValState01 & 0x0f)
  1184. if(LenVoi000>=23)//至少有一组阀门未关则发送播报语音
  1185. {//任何一个阀门未关闭时才发送数据
  1186. KeySlave485_Send_Data((uint8_t *)SpeakerBuff,LenToSpk+2);
  1187. memset(&SpeakerBuff[9],0,sizeof(SpeakerBuff)-9);
  1188. }//任何一个阀门未关闭时才发送数据
  1189. */
  1190. __nop();
  1191. break;
  1192. case 2: //2仓数据播报
  1193. ///////////////
  1194. LenOfMsg = 0;
  1195. LenVoi000 = 9;
  1196. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1197. // LenOfMsg=sprintf(SpeakerBuff+LenVoi000,"%2d仓",i000_Voice);
  1198. // LenVoi000=LenVoi000+LenOfMsg;//strlen();
  1199. //
  1200. //if(ValState02 & GPIO_PIN_0)//2仓
  1201. if (Cang02_IO[0 + 7] == 0x01) //2仓海底阀
  1202. {
  1203. // LenOfMsg=sprintf(SpeakerBuff+LenVoi000,"海底阀");
  1204. // LenVoi000=LenVoi000+LenOfMsg;//strlen();
  1205. LenOfMsg = sprintf(SpeakerBuff + 9, "二仓海底阀未关");
  1206. LenVoi000 = 9 + LenOfMsg; //strlen();
  1207. memset(&SpeakerBuff[LenVoi000], 0, sizeof(SpeakerBuff) - LenVoi000);
  1208. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1209. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1210. __nop();
  1211. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1212. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1213. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1214. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1215. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1216. //HAL_Delay(1000);
  1217. osDelay(1000);
  1218. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1219. //HAL_Delay(1000);
  1220. osDelay(1000);
  1221. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1222. }
  1223. //if(ValState02 & GPIO_PIN_1)//2仓人孔小盖
  1224. if (Cang02_IO[1 + 7] == 0x01) //2仓卸油阀
  1225. {
  1226. // LenOfMsg=sprintf(SpeakerBuff+LenVoi000,"卸油阀");
  1227. // LenVoi000=LenVoi000+LenOfMsg;
  1228. LenOfMsg = sprintf(SpeakerBuff + 9, "二仓卸油阀未关。");
  1229. LenVoi000 = 9 + LenOfMsg; //strlen();
  1230. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1231. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1232. __nop();
  1233. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1234. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1235. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1236. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1237. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1238. //HAL_Delay(1000);
  1239. osDelay(1000);
  1240. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1241. //HAL_Delay(1000);
  1242. osDelay(1000);
  1243. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1244. }
  1245. //if(ValState02 & GPIO_PIN_2)//2仓人孔大盖
  1246. if (Cang02_IO[2 + 7] == 0x01) //2仓
  1247. {
  1248. LenOfMsg = sprintf(SpeakerBuff + 9, "二仓人孔盖未关.");
  1249. LenVoi000 = 9 + LenOfMsg; //strlen();
  1250. memset(&SpeakerBuff[LenVoi000], 0, sizeof(SpeakerBuff) - LenVoi000);
  1251. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1252. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1253. __nop();
  1254. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1255. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1256. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1257. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1258. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1259. //HAL_Delay(1000);
  1260. osDelay(1000);
  1261. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1262. //HAL_Delay(1000);
  1263. osDelay(1000);
  1264. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1265. /*
  1266. LenOfMsg=0;
  1267. LenVoi000=9;
  1268. // LenOfMsg=sprintf(SpeakerBuff+0+LenVoi000,"人孔盖,");
  1269. // LenVoi000=LenVoi000+LenOfMsg;
  1270. memset(&SpeakerBuff[9],0,sizeof(SpeakerBuff)-9);
  1271. //LenOfMsg=sprintf(SpeakerBuff+9,"二仓人孔盖未关!!!!");
  1272. LenOfMsg=sprintf(SpeakerBuff+9,"二仓人孔盖未关");
  1273. LenVoi000=9+LenOfMsg;//strlen();
  1274. LenToSpk=LenVoi000;//9+LenOfMsg-0;
  1275. SpeakerBuff[6]=LenToSpk+2;//LenOfMsg+2+0;//加上2字节的crc
  1276. __nop();
  1277. crc000=CRC16_MODBUS((unsigned char*)SpeakerBuff,LenToSpk);
  1278. SpeakerBuff[LenToSpk]=crc000 >>8;
  1279. SpeakerBuff[LenToSpk+1]=crc000 & 0x00ff;
  1280. KeySlave485_Send_Data((uint8_t *)SpeakerBuff,LenToSpk+2);
  1281. memset(&SpeakerBuff[9],0,sizeof(SpeakerBuff)-9);
  1282. HAL_Delay(1000);
  1283. HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//看门狗sp706
  1284. HAL_Delay(1000);
  1285. HAL_GPIO_TogglePin(GPIOC, DWI_Pin);//看门狗sp706
  1286. */
  1287. }
  1288. //
  1289. // if(ValState02 & GPIO_PIN_3)//2仓人孔大盖
  1290. // {
  1291. // LenOfMsg=sprintf(SpeakerBuff+9,"%2d仓卸油阀未关",i000_Voice);
  1292. // }
  1293. if (Cang02_IO[13] == 0x01) //2仓
  1294. {
  1295. // LenOfMsg=sprintf(SpeakerBuff+0+LenVoi000,"排沉阀");
  1296. // LenVoi000=LenVoi000+LenOfMsg;
  1297. LenOfMsg = sprintf(SpeakerBuff + 9, "二仓排沉阀未关!");
  1298. LenVoi000 = 9 + LenOfMsg; //strlen();
  1299. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1300. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1301. __nop();
  1302. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1303. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1304. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1305. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1306. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1307. //HAL_Delay(1000);
  1308. osDelay(1000);
  1309. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1310. //HAL_Delay(1000);
  1311. osDelay(1000);
  1312. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1313. }
  1314. /*
  1315. LenOfMsg=sprintf(SpeakerBuff+LenVoi000,"未关!!!");
  1316. LenVoi000=LenVoi000+LenOfMsg;//strlen();
  1317. LenToSpk=LenVoi000;//9+LenOfMsg-0;
  1318. //更新数据长度
  1319. SpeakerBuff[6]=LenToSpk+2+0;//加上2字节的crc
  1320. __nop();
  1321. crc000=CRC16_MODBUS((unsigned char*)SpeakerBuff,LenToSpk);
  1322. SpeakerBuff[LenToSpk]=crc000 >>8;
  1323. SpeakerBuff[LenToSpk+1]=crc000 & 0x00ff;
  1324. //03 10 00 33 00 08 10 00 01 20 35 B2 D6 BA A3 B5 D7 B7 A7 CE B4 B9 D8 A5 08 --5仓海底阀未关
  1325. //03 10 00 33 00 08 11 00 01 D2 BB B2 D6 C8 CB BF D7 B8 C7 CE B4 B9 D8 82 4E 一仓人孔盖未关
  1326. //if(ValState02 & 0x0f)
  1327. if(LenVoi000>=23)//至少有一组阀门未关则发送播报语音
  1328. {//任何一个阀门未关闭时才发送数据
  1329. KeySlave485_Send_Data((uint8_t *)SpeakerBuff,LenToSpk+2);
  1330. memset(&SpeakerBuff[9],0,sizeof(SpeakerBuff)-9);
  1331. }
  1332. */
  1333. __nop();
  1334. break;
  1335. case 3:
  1336. ///////////////
  1337. LenOfMsg = 0;
  1338. LenVoi000 = 9;
  1339. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1340. if (ValState03 & GPIO_PIN_0) //1仓人孔大盖
  1341. {
  1342. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓人孔大盖未关", i000_Voice);
  1343. LenVoi000 = 9 + LenOfMsg; //strlen();
  1344. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1345. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1346. __nop();
  1347. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1348. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1349. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1350. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1351. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1352. //HAL_Delay(1000);
  1353. osDelay(1000);
  1354. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1355. //HAL_Delay(1000);
  1356. osDelay(1000);
  1357. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1358. }
  1359. if (ValState03 & GPIO_PIN_1) //1仓人孔小盖
  1360. {
  1361. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓人孔小盖未关", i000_Voice);
  1362. LenVoi000 = 9 + LenOfMsg; //strlen();
  1363. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1364. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1365. __nop();
  1366. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1367. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1368. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1369. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1370. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1371. //HAL_Delay(1000);
  1372. osDelay(1000);
  1373. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1374. //HAL_Delay(1000);
  1375. osDelay(1000);
  1376. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1377. }
  1378. if (ValState03 & GPIO_PIN_2) //3仓海底阀
  1379. {
  1380. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓海底阀紧急切断阀未关!", i000_Voice);
  1381. //LenOfMsg=sprintf(SpeakerBuff+9,"3仓海底阀未关!");
  1382. LenVoi000 = 9 + LenOfMsg; //strlen();
  1383. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1384. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1385. __nop();
  1386. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1387. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1388. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1389. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1390. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1391. //HAL_Delay(1000);
  1392. osDelay(1000);
  1393. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1394. //HAL_Delay(1000);
  1395. osDelay(1000);
  1396. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1397. }
  1398. if (ValState03 & GPIO_PIN_3) //1仓人孔大盖
  1399. {
  1400. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓卸油阀未关!", i000_Voice);
  1401. LenVoi000 = 9 + LenOfMsg; //strlen();
  1402. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1403. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1404. __nop();
  1405. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1406. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1407. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1408. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1409. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1410. //HAL_Delay(1000);
  1411. osDelay(1000);
  1412. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1413. //HAL_Delay(1000);
  1414. osDelay(1000);
  1415. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1416. }
  1417. /*
  1418. LenToSpk=9+LenOfMsg-0;
  1419. //更新数据长度
  1420. SpeakerBuff[6]=LenOfMsg+2+0;//加上2字节的crc
  1421. __nop();
  1422. crc000=CRC16_MODBUS((unsigned char*)SpeakerBuff,LenToSpk);
  1423. SpeakerBuff[LenToSpk]=crc000 >>8;
  1424. SpeakerBuff[LenToSpk+1]=crc000 & 0x00ff;
  1425. //03 10 00 33 00 08 10 00 01 20 35 B2 D6 BA A3 B5 D7 B7 A7 CE B4 B9 D8 A5 08 --5仓海底阀未关
  1426. //03 10 00 33 00 08 11 00 01 D2 BB B2 D6 C8 CB BF D7 B8 C7 CE B4 B9 D8 82 4E 一仓人孔盖未关
  1427. if(ValState03 & 0x0f)
  1428. {//任何一个阀门未关闭时才发送数据
  1429. KeySlave485_Send_Data((uint8_t *)SpeakerBuff,LenToSpk+2);
  1430. }*/
  1431. __nop();
  1432. break;
  1433. case 4:
  1434. ///////////////
  1435. LenOfMsg = 0;
  1436. LenVoi000 = 9;
  1437. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1438. if (ValState04 & GPIO_PIN_0) //1仓人孔大盖
  1439. {
  1440. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓人孔盖未关!!", i000_Voice);
  1441. LenVoi000 = 9 + LenOfMsg; //strlen();
  1442. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1443. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1444. __nop();
  1445. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1446. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1447. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1448. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1449. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1450. //HAL_Delay(1000);
  1451. osDelay(1000);
  1452. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1453. //HAL_Delay(1000);
  1454. osDelay(1000);
  1455. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1456. }
  1457. if (ValState04 & GPIO_PIN_1) //1仓人孔小盖
  1458. {
  1459. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓人孔小盖未关!!", i000_Voice);
  1460. LenVoi000 = 9 + LenOfMsg; //strlen();
  1461. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1462. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1463. __nop();
  1464. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1465. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1466. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1467. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1468. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1469. //HAL_Delay(1000);
  1470. osDelay(1000);
  1471. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1472. //HAL_Delay(1000);
  1473. osDelay(1000);
  1474. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1475. }
  1476. if (ValState04 & GPIO_PIN_2) //4仓
  1477. {
  1478. LenOfMsg = 0;
  1479. LenVoi000 = 9;
  1480. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1481. //LenOfMsg=sprintf(SpeakerBuff+9,"%2d仓海底阀未关",i000_Voice);
  1482. //LenOfMsg=sprintf(SpeakerBuff+9,"四仓海底阀未关 !");
  1483. LenOfMsg = sprintf(SpeakerBuff + 9, "四仓海底阀未关,,,,");
  1484. LenVoi000 = 9 + LenOfMsg; //strlen();
  1485. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1486. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1487. __nop();
  1488. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1489. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1490. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1491. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1492. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1493. //HAL_Delay(1000);
  1494. osDelay(1000);
  1495. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1496. //HAL_Delay(1000);
  1497. osDelay(1000);
  1498. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1499. }
  1500. if (ValState04 & GPIO_PIN_3) //1仓人孔大盖
  1501. {
  1502. LenOfMsg = sprintf(SpeakerBuff + 9, "%2d仓卸油阀未关", i000_Voice);
  1503. LenVoi000 = 9 + LenOfMsg; //strlen();
  1504. LenToSpk = LenVoi000; //9+LenOfMsg-0;
  1505. SpeakerBuff[6] = LenToSpk + 2; //LenOfMsg+2+0;//加上2字节的crc
  1506. __nop();
  1507. crc000 = CRC16_MODBUS((unsigned char *)SpeakerBuff, LenToSpk);
  1508. SpeakerBuff[LenToSpk] = crc000 >> 8;
  1509. SpeakerBuff[LenToSpk + 1] = crc000 & 0x00ff;
  1510. KeySlave485_Send_Data((uint8_t *)SpeakerBuff, LenToSpk + 2);
  1511. memset(&SpeakerBuff[9], 0, sizeof(SpeakerBuff) - 9);
  1512. //HAL_Delay(1000);
  1513. osDelay(1000);
  1514. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1515. //HAL_Delay(1000);
  1516. osDelay(1000);
  1517. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1518. }
  1519. /*
  1520. LenToSpk=9+LenOfMsg-0;
  1521. //更新数据长度
  1522. SpeakerBuff[6]=LenOfMsg+2+0;//加上2字节的crc
  1523. __nop();
  1524. crc000=CRC16_MODBUS((unsigned char*)SpeakerBuff,LenToSpk);
  1525. SpeakerBuff[LenToSpk]=crc000 >>8;
  1526. SpeakerBuff[LenToSpk+1]=crc000 & 0x00ff;
  1527. //03 10 00 33 00 08 10 00 01 20 35 B2 D6 BA A3 B5 D7 B7 A7 CE B4 B9 D8 A5 08 --5仓海底阀未关
  1528. //03 10 00 33 00 08 11 00 01 D2 BB B2 D6 C8 CB BF D7 B8 C7 CE B4 B9 D8 82 4E 一仓人孔盖未关
  1529. if(ValState03 & 0x0f)
  1530. {//任何一个阀门未关闭时才发送数据
  1531. KeySlave485_Send_Data((uint8_t *)SpeakerBuff,LenToSpk+2);
  1532. }*/
  1533. __nop();
  1534. break;
  1535. default:
  1536. break;
  1537. }
  1538. i000_Voice++;
  1539. //if(i000_Voice>4)//
  1540. if (i000_Voice > StoreNumber) //
  1541. {
  1542. i000_Voice = 1;
  1543. }
  1544. #endif
  1545. xSemaphoreGive(xSemaphore_uart4);
  1546. osDelay(3 * 1000); //阻塞延时,根据情况调节
  1547. }
  1548. /* USER CODE END Task_Uart4_VoicePlay */
  1549. }
  1550. /* Private application code --------------------------------------------------*/
  1551. /* USER CODE BEGIN Application */
  1552. /*
  1553. 显示运行信息(功能码信息、车牌号,版本号等)
  1554. */
  1555. int Len_AnHuiKaiLe;
  1556. uint32_t ValveNum000; //j001,
  1557. float KaiLeTemp = 16, KaiLePressture = 98.1; //安徽开乐演示用
  1558. int Len001RunInfo_disp=-1;
  1559. uint32_t bak_fundebug=0;
  1560. void DisplayRunInfo(uint32_t FunDebugCode000)
  1561. {
  1562. int Len000RunInfo, Len001RunInfo;
  1563. int i000;
  1564. FRAM_cnt++;
  1565. if (FRAM_cnt > 60)
  1566. {
  1567. FRAM_cnt = 0;
  1568. //提高寿命 每分钟写入一次
  1569. FM25L16B_WriteByte(ADDR_TotalRunTime + 0, totalRunTimeCnt >> 24);
  1570. FM25L16B_WriteByte(ADDR_TotalRunTime + 1, totalRunTimeCnt >> 16);
  1571. FM25L16B_WriteByte(ADDR_TotalRunTime + 2, totalRunTimeCnt >> 8);
  1572. FM25L16B_WriteByte(ADDR_TotalRunTime + 3, totalRunTimeCnt & 0xff);
  1573. }
  1574. if (FunDebugCode000 > 80000)
  1575. { //按键功能码>90000 ----开始 if(FunDebugCode>90000)
  1576. //memset(bufText01Password,0,sizeof(bufText01Password));
  1577. switch (FunDebugCode000)
  1578. {
  1579. case DebugFun_LCD_SleepTime:
  1580. memset((char *)bufText01Password + 0, 0, sizeof(bufText01Password));
  1581. Len000RunInfo = sprintf((char *)bufText01Password + 0, "LCD Sleep Time=");
  1582. FM25L16B_Read_N_Bytes(ADDR_SleepTime_ScreenDwin, (uint8_t *)bufText01Password + Len000RunInfo, 32);
  1583. Len001RunInfo = sprintf((char *)bufText01Password + Len000RunInfo + 32, ".code=%5d.\r\n", FunDebugCode);
  1584. Len001RunInfo = Len001RunInfo + Len000RunInfo;
  1585. break;
  1586. case Set_Level_Alarm_Sensor001:
  1587. case Set_Level_Alarm_Sensor002:
  1588. case Set_Level_Alarm_Sensor003:
  1589. case Set_Level_Alarm_Sensor011:
  1590. case Set_Level_Alarm_Sensor012:
  1591. case Set_Level_Alarm_Sensor013:
  1592. case Set_Level_Alarm_Sensor021:
  1593. case Set_Level_Alarm_Sensor022:
  1594. case Set_Level_Alarm_Sensor023:
  1595. case Set_Level_Alarm_Sensor031:
  1596. case Set_Level_Alarm_Sensor032:
  1597. case Set_Level_Alarm_Sensor033:
  1598. bak_fundebug=FunDebugCode000;
  1599. FunDebugCode=0;
  1600. input_ArrFunDebugCode[0]=0;
  1601. input_ArrFunDebugCode[1]=0;
  1602. input_ArrFunDebugCode[2]=0;
  1603. input_ArrFunDebugCode[3]=0;
  1604. input_ArrFunDebugCode[4]=0;
  1605. break;
  1606. case DebugFun_DS1302Time:
  1607. break;
  1608. case DebugFun_CarLicensePlate:
  1609. memset((char *)bufText01Password + 0, 0, sizeof(bufText01Password));
  1610. Len000RunInfo = sprintf((char *)bufText01Password + 0, "Che Pai Hao Ma=");
  1611. FM25L16B_Read_N_Bytes(ADDR_CarPlate_Number, (uint8_t *)bufText01Password + Len000RunInfo, 16);
  1612. Len000RunInfo = sprintf((char *)bufText01Password + Len000RunInfo + 16, ".code=%5d.\r\n", FunDebugCode);
  1613. WrDwinBuf(ADDR_DWIN_Text03_sysInfo, bufText01Password, Len000RunInfo, 1); //重启之前显示车牌号
  1614. break;
  1615. case DebugFun_Sw_VoicePlay: //切换语音播报功能
  1616. //FM25L16B_Read_N_Bytes(ADDR_CarPlate_Number,(uint8_t *)bufText01Password+0,16);
  1617. if (flag_Sw_VoicePlay)
  1618. {
  1619. flag_Sw_VoicePlay = 0;
  1620. Len001RunInfo = sprintf((char *)bufText01Password + 16, "语音播报被关闭.code=%5d.\r\n", FunDebugCode);
  1621. Len001RunInfo = 16 + Len001RunInfo;
  1622. }
  1623. else
  1624. {
  1625. flag_Sw_VoicePlay = 1;
  1626. Len001RunInfo = sprintf((char *)bufText01Password + 16, "语音播报被打开.code=%5d.\r\n", FunDebugCode);
  1627. Len001RunInfo = 16 + Len001RunInfo;
  1628. }
  1629. FunDebugCode = 0; //
  1630. break;
  1631. case DebugFun_Sw_ValveRaw: //切换阀门的原始数据或者汉字数据
  1632. //FM25L16B_Read_N_Bytes(ADDR_CarPlate_Number,(uint8_t *)bufText01Password+0,16);
  1633. if (flag_ShowValveRaw)
  1634. {
  1635. flag_ShowValveRaw = 0;
  1636. Len001RunInfo = sprintf((char *)bufText01Password + 16, "将显示阀门的解码数据.code=%5d.\r\n", FunDebugCode);
  1637. Len001RunInfo = 16 + Len001RunInfo;
  1638. memset(bufTextCang01_IO, ' ', sizeof(bufTextCang01_IO)); //清除原有的较长的信息
  1639. WrDwinBuf(ADDR_DWIN_Cang01_IO, &bufTextCang01_IO[0], 124, 1);
  1640. HAL_Delay(50); //
  1641. WrDwinBuf(ADDR_DWIN_Cang02_IO, &bufTextCang01_IO[0], 124, 1);
  1642. }
  1643. else
  1644. {
  1645. flag_ShowValveRaw = 1;
  1646. Len001RunInfo = sprintf((char *)bufText01Password + 16, "将显示阀门原始数字数据.code=%5d.\r\n", FunDebugCode);
  1647. Len001RunInfo = 16 + Len001RunInfo;
  1648. }
  1649. FunDebugCode = 0; //
  1650. break;
  1651. case DebugFun_Sw_DisplaySensorData:
  1652. if (flag_Sw_DisplaySensorData)
  1653. {
  1654. flag_Sw_DisplaySensorData = 0;
  1655. Len001RunInfo = sprintf((char *)bufText01Password + 16, "将不显示模拟量传感器数据.code=%5d.\r\n", FunDebugCode);
  1656. Len001RunInfo = 16 + Len001RunInfo;
  1657. }
  1658. else
  1659. {
  1660. flag_Sw_DisplaySensorData = 1;
  1661. Len001RunInfo = sprintf((char *)bufText01Password + 16, "将显示模拟量传感器数据.code=%5d.\r\n", FunDebugCode);
  1662. Len001RunInfo = 16 + Len001RunInfo;
  1663. }
  1664. FunDebugCode = 0; //
  1665. break;
  1666. case DebugFun_Refresh_Title_IO: //强制刷新一次阀门名称显示
  1667. Len001RunInfo = sprintf((char *)bufText01Password + 16, "强制刷新一次阀门名称显示.code=%5d.\r\n", FunDebugCode);
  1668. Len001RunInfo = 16 + Len001RunInfo;
  1669. memset(bufTextCang01_IO, ' ', sizeof(bufTextCang01_IO));
  1670. //Len000=sprintf((char*)bufTextCang01_IO+16*0," 海底阀-卸油阀-人孔盖-小孔盖-有无油 ");// %02d\r\n
  1671. Len000RunInfo = sprintf((char *)bufTextCang01_IO + 16 * 0, "%s", arrValve_title01); // %02d\r\n
  1672. memset((char *)bufTextCang01_IO + Len000RunInfo, 0, sizeof(bufTextCang01_IO) - Len000RunInfo);
  1673. //taskENTER_CRITICAL();
  1674. ; // WrDwinBuf(ADDR_DWIN_Title_IO,&bufTextCang01_IO[0],Len000RunInfo,1);
  1675. //taskEXIT_CRITICAL();
  1676. FunDebugCode = 0; //
  1677. //
  1678. //
  1679. // memset(bufTextCang01_IO,' ',sizeof(bufTextCang01_IO));
  1680. // Len000RunInfo=sprintf((char*)bufTextCang01_IO+16*0,"%s",arrValve_title01);// %02d\r\n
  1681. // memset((char*)bufTextCang01_IO+Len000RunInfo,0,sizeof(bufTextCang01_IO)-Len000RunInfo);
  1682. // WrDwinBuf(ADDR_DWIN_Title_IO,&bufTextCang01_IO[0],Len000RunInfo,1);
  1683. break;
  1684. case DebugFun_Sw_DispSysInfo: //切换是否显示系统运行信息
  1685. if (flag_Sw_DispSysInfo)
  1686. {
  1687. flag_Sw_DispSysInfo = 0;
  1688. Len001RunInfo = sprintf((char *)bufText01Password + 16, "将不显示系统运行信息.code=%5d.\r\n", FunDebugCode);
  1689. Len001RunInfo = 16 + Len001RunInfo;
  1690. }
  1691. else
  1692. {
  1693. flag_Sw_DispSysInfo = 1;
  1694. Len001RunInfo = sprintf((char *)bufText01Password + 16, "将显示系统运行信息.code=%5d.\r\n", FunDebugCode);
  1695. Len001RunInfo = 16 + Len001RunInfo;
  1696. }
  1697. //系统运行信息隐藏或者显示
  1698. if (flag_Sw_DispSysInfo == 0)
  1699. {
  1700. bufText01Password[0] = 0xff00; //隐藏文本命令
  1701. WrDwinBuf(ADDR_DWIN_Text03_SP, bufText01Password, 1, 0);
  1702. HAL_Delay(10);
  1703. }
  1704. else
  1705. {
  1706. bufText01Password[0] = ADDR_DWIN_Text03_sysInfo;
  1707. WrDwinBuf(ADDR_DWIN_Text03_SP, bufText01Password, 1, 0);
  1708. }
  1709. FunDebugCode = 0; //
  1710. break;
  1711. case DebugFun_Set_BlankSeal_Enable:
  1712. flag_En_BlankSeal=1;
  1713. FunDebugCode=0;
  1714. break;
  1715. case DebugFun_Set_BlankSeal_Disable:
  1716. flag_En_BlankSeal=0;
  1717. FunDebugCode=0;
  1718. break;
  1719. #if KeyPad_Set_SealState_En
  1720. /////////////////////////////强制注入电子铅封的状态----开始
  1721. case DebugFun_Set_Cang_NUM01_Seal: //强制施封----同时显示施封破封
  1722. Full_Oil_allinfo.Break_sealing_Id = 0xff; //
  1723. Full_Oil_allinfo.Auto_sealedOK_ID = 0xff;
  1724. FunDebugCode = 0; //Full_Oil_allinfo.Break_sealing_Id
  1725. break;
  1726. case DebugFun_Set_Cang_NUM02_Seal: //强制施封
  1727. Full_Oil_allinfo.Break_sealing_Id = 0x00; //
  1728. Full_Oil_allinfo.Auto_sealedOK_ID = 0xff;
  1729. FunDebugCode = 0; //Full_Oil_allinfo.Break_sealing_Id
  1730. break;
  1731. case DebugFun_Set_Cang_NUM01_Broken: //强制破封
  1732. Full_Oil_allinfo.Break_sealing_Id = 0xff; //
  1733. Full_Oil_allinfo.Auto_sealedOK_ID = 0x00;
  1734. FunDebugCode = 0; //Full_Oil_allinfo.Break_sealing_Id
  1735. break;
  1736. case DebugFun_Set_Cang_NUM01_JieFeng: //强制解封
  1737. Full_Oil_allinfo.Break_sealing_Id = 0x00; //
  1738. Full_Oil_allinfo.Auto_sealedOK_ID = 0x00;
  1739. FunDebugCode = 0; //Full_Oil_allinfo.Break_sealing_Id
  1740. break;
  1741. #endif
  1742. /////////////////////////////强制注入电子铅封的状态----结束
  1743. case DebugFun_Set_Cang_NUM01: //手动设定为N仓N阀门
  1744. case DebugFun_Set_Cang_NUM02:
  1745. case DebugFun_Set_Cang_NUM03:
  1746. case DebugFun_Set_Cang_NUM04:
  1747. case DebugFun_Set_Cang_NUM05:
  1748. case DebugFun_Set_Cang_NUM06:
  1749. case DebugFun_Set_Cang_NUM07:
  1750. case DebugFun_Set_Cang_NUM08:
  1751. // Config_info_all.All_number =01;// UART4_RX_BUF[4];
  1752. // StoreNumber = Config_info_all.All_number;
  1753. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1754. //
  1755. // Config_info_all.ManHole_Big_info =01;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1756. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1757. //
  1758. // Config_info_all.ManHole_small_info =01;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1759. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1760. //
  1761. //
  1762. // Config_info_all.Dump_info =01;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1763. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1764. //
  1765. // Config_info_all.HaiDiFa_info =01;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1766. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1767. //
  1768. // all_Store = StoreNumber;
  1769. // Go_homepage();//回到首页
  1770. // FunDebugCode=0;//
  1771. //
  1772. // break;
  1773. //
  1774. //
  1775. // case DebugFun_Set_Cang_NUM02: //手动设定为2仓2阀门
  1776. // Config_info_all.All_number =02;// UART4_RX_BUF[4];
  1777. // StoreNumber = Config_info_all.All_number;
  1778. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1779. //
  1780. // Config_info_all.ManHole_Big_info =02;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1781. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1782. //
  1783. // Config_info_all.ManHole_small_info =02;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1784. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1785. //
  1786. //
  1787. // Config_info_all.Dump_info =02;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1788. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1789. //
  1790. // Config_info_all.HaiDiFa_info =02;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1791. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1792. //
  1793. // all_Store = StoreNumber;
  1794. // Go_homepage();//回到首页
  1795. // FunDebugCode=0;//
  1796. //
  1797. // break;
  1798. //
  1799. // case DebugFun_Set_Cang_NUM03: //手动设定为3仓3阀门
  1800. // Config_info_all.All_number =03;// UART4_RX_BUF[4];
  1801. // StoreNumber = Config_info_all.All_number;
  1802. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1803. //
  1804. // Config_info_all.ManHole_Big_info =03;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1805. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1806. //
  1807. // Config_info_all.ManHole_small_info =03;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1808. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1809. //
  1810. //
  1811. // Config_info_all.Dump_info =03;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1812. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1813. //
  1814. // Config_info_all.HaiDiFa_info =03;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1815. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1816. //
  1817. // all_Store = StoreNumber;
  1818. // Go_homepage();//回到首页
  1819. // FunDebugCode=0;//
  1820. //
  1821. // break;
  1822. // case DebugFun_Set_Cang_NUM04: //手动设定为4仓4阀门
  1823. // Config_info_all.All_number =04;// UART4_RX_BUF[4];
  1824. // StoreNumber = Config_info_all.All_number;
  1825. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1826. //
  1827. // Config_info_all.ManHole_Big_info =04;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1828. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1829. //
  1830. // Config_info_all.ManHole_small_info =04;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1831. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1832. //
  1833. //
  1834. // Config_info_all.Dump_info =04;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1835. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1836. //
  1837. // Config_info_all.HaiDiFa_info =04;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1838. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1839. //
  1840. // all_Store = StoreNumber;
  1841. // Go_homepage();//回到首页
  1842. // FunDebugCode=0;//
  1843. //
  1844. // break;
  1845. // case DebugFun_Set_Cang_NUM05: //手动设定为5仓5阀门
  1846. // Config_info_all.All_number =05;// UART4_RX_BUF[4];
  1847. // StoreNumber = Config_info_all.All_number;
  1848. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1849. //
  1850. // Config_info_all.ManHole_Big_info =05;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1851. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1852. //
  1853. // Config_info_all.ManHole_small_info =05;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1854. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1855. //
  1856. //
  1857. // Config_info_all.Dump_info =05;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1858. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1859. //
  1860. // Config_info_all.HaiDiFa_info =05;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1861. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1862. //
  1863. // all_Store = StoreNumber;
  1864. // Go_homepage();//回到首页
  1865. // FunDebugCode=0;//
  1866. //
  1867. // break;
  1868. // case DebugFun_Set_Cang_NUM06: //手动设定为6仓6阀门
  1869. // Config_info_all.All_number =06;// UART4_RX_BUF[4];
  1870. // StoreNumber = Config_info_all.All_number;
  1871. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1872. //
  1873. // Config_info_all.ManHole_Big_info =06;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1874. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1875. //
  1876. // Config_info_all.ManHole_small_info =06;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1877. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1878. //
  1879. //
  1880. // Config_info_all.Dump_info =06;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1881. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1882. //
  1883. // Config_info_all.HaiDiFa_info =06;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1884. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1885. //
  1886. // all_Store = StoreNumber;
  1887. // Go_homepage();//回到首页
  1888. // FunDebugCode=0;//
  1889. //
  1890. // break;
  1891. // case DebugFun_Set_Cang_NUM07: //手动设定为7仓7阀门
  1892. // Config_info_all.All_number =07;// UART4_RX_BUF[4];
  1893. // StoreNumber = Config_info_all.All_number;
  1894. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1895. //
  1896. // Config_info_all.ManHole_Big_info =07;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1897. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1898. //
  1899. // Config_info_all.ManHole_small_info =07;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1900. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1901. //
  1902. //
  1903. // Config_info_all.Dump_info =07;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1904. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1905. //
  1906. // Config_info_all.HaiDiFa_info =07;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1907. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1908. //
  1909. // all_Store = StoreNumber;
  1910. // Go_homepage();//回到首页
  1911. // FunDebugCode=0;//
  1912. //
  1913. // break;
  1914. // case DebugFun_Set_Cang_NUM08: //手动设定为8仓8阀门
  1915. // Config_info_all.All_number =8;// UART4_RX_BUF[4];
  1916. // StoreNumber = Config_info_all.All_number;
  1917. // FM25L16B_WriteByte(ADDR_StoreNumber,StoreNumber);
  1918. //
  1919. // Config_info_all.ManHole_Big_info =8;// UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1920. // FM25L16B_WriteByte(ADDR_ManHole_Big_info,Config_info_all.ManHole_Big_info);
  1921. //
  1922. // Config_info_all.ManHole_small_info =8;// UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1923. // FM25L16B_WriteByte(ADDR_ManHole_small_info,Config_info_all.ManHole_small_info);
  1924. //
  1925. //
  1926. // Config_info_all.Dump_info =8;// UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1927. // FM25L16B_WriteByte(ADDR_Dump_info,Config_info_all.Dump_info);
  1928. //
  1929. // Config_info_all.HaiDiFa_info =8;// UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1930. // FM25L16B_WriteByte(ADDR_Foot_info,Config_info_all.HaiDiFa_info);
  1931. //
  1932. // all_Store = StoreNumber;
  1933. // Go_homepage();//回到首页
  1934. // FunDebugCode=0;//
  1935. ValveNum000 = FunDebugCode - 98100;
  1936. if (ValveNum000 > 8)
  1937. {
  1938. ValveNum000 = 8;
  1939. }
  1940. if (ValveNum000 == 0)
  1941. {
  1942. ValveNum000 = 2;
  1943. }
  1944. Config_info_all.All_number = (uint8_t)ValveNum000; // UART4_RX_BUF[4];
  1945. StoreNumber = Config_info_all.All_number;
  1946. FM25L16B_WriteByte(ADDR_StoreNumber, StoreNumber);
  1947. Config_info_all.ManHole_Big_info = (uint8_t)ValveNum000; // UART4_RX_BUF[5];//人孔盖信息(大盖)bit7标定大盖有没有 1没有 0有
  1948. FM25L16B_WriteByte(ADDR_ManHole_Big_info, Config_info_all.ManHole_Big_info);
  1949. Config_info_all.ManHole_small_info = (uint8_t)ValveNum000; // UART4_RX_BUF[6];//小盖单独标定,bit7标定大盖有没有 1没有 0有
  1950. FM25L16B_WriteByte(ADDR_ManHole_small_info, Config_info_all.ManHole_small_info);
  1951. Config_info_all.Dump_info = (uint8_t)ValveNum000; // UART4_RX_BUF[7];//卸油阀标定bit7=0常规一仓一个,bit7=1特殊一仓两个
  1952. FM25L16B_WriteByte(ADDR_Dump_info, Config_info_all.Dump_info);
  1953. Config_info_all.HaiDiFa_info = (uint8_t)ValveNum000; // UART4_RX_BUF[8];//底阀标定bit7=0气阀,bit7=1特殊485(日后可能会改)
  1954. FM25L16B_WriteByte(ADDR_Foot_info, Config_info_all.HaiDiFa_info);
  1955. all_Store = StoreNumber;
  1956. Go_homepage(); //回到首页
  1957. // memset(bufTextCang01_IO,' ',sizeof(bufTextCang01_IO));
  1958. // Len000RunInfo=sprintf((char*)bufTextCang01_IO+16*0,"%s",arrValve_title01);// %02d\r\n
  1959. // memset((char*)bufTextCang01_IO+Len000RunInfo,0,sizeof(bufTextCang01_IO)-Len000RunInfo);
  1960. // WrDwinBuf(ADDR_DWIN_Title_IO,&bufTextCang01_IO[0],Len000RunInfo,1);
  1961. FunDebugCode = 0; //
  1962. break;
  1963. case DebugFun__Restart_ContBoard00: //复位 //立即重启
  1964. Reboot_System();
  1965. break;
  1966. case DebugFun__Restart_ContBoard01: //复位 //可以取消的重启
  1967. //FM25L16B_Read_N_Bytes(ADDR_CarPlate_Number,(uint8_t *)bufText01Password+0,16);
  1968. // memset(bufText01Password,0,sizeof(bufText01Password));
  1969. // sprintf((char*)bufText01Password+16*0,"系统即将重启...F1键取消重启.code=%5d.\r\n",FunDebugCode);
  1970. // WrDwinBuf(ADDR_DWIN_Text03_sysInfo,bufText01Password,44,1);//重启之前显示信息
  1971. i000 = 0;
  1972. flag_exitReset = 0;
  1973. while (i000 < 100) //10s取消重启时间
  1974. {
  1975. i000++;
  1976. osDelay(100);
  1977. HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  1978. //查询按键终止
  1979. if (flag_exitReset == 1)
  1980. {
  1981. memset(bufText01Password, 0, sizeof(bufText01Password));
  1982. Len000RunInfo = sprintf((char *)bufText01Password + 16 * 0, "重启取消.code=%5d.\r\n", FunDebugCode);
  1983. WrDwinBuf(ADDR_DWIN_Text03_sysInfo, bufText01Password, Len000RunInfo, 1); //重启之前显示信息
  1984. break;
  1985. }
  1986. else
  1987. {
  1988. memset(bufText01Password, 0, sizeof(bufText01Password));
  1989. Len000RunInfo = sprintf((char *)bufText01Password + 16 * 0, "系统即将重启...F1键取消重启.code=%5d.%5d.\r\n", FunDebugCode, 10 - i000 / 10);
  1990. WrDwinBuf(ADDR_DWIN_Text03_sysInfo, bufText01Password, Len000RunInfo, 1); //重启之前显示信息
  1991. //return;
  1992. }
  1993. }
  1994. if (flag_exitReset == 1)
  1995. { //终止复位
  1996. FunDebugCode = 0;
  1997. break;
  1998. }
  1999. Reboot_System();
  2000. break;
  2001. case DebugFun_Clear_Valve_Info: //
  2002. //强制清除各仓的显示信息,避免乱码无法消除----因为正常只有39字符,原始数字较长,所以后边有残余
  2003. memset((char *)bufText01Password + 0, 0, sizeof(bufText01Password));
  2004. Len000RunInfo = sprintf((char *)bufText01Password + 0, "手动清除各仓显示阀门信息=%s", product_ID);
  2005. // FM25L16B_Read_N_Bytes(ADDR_CarPlate_Number,(uint8_t *)bufText01Password+0,16);
  2006. //
  2007. Len001RunInfo = sprintf((char *)bufText01Password + Len000RunInfo, "product_ID=%s.code=%5d.\r\n", product_ID, FunDebugCode);
  2008. Len001RunInfo = Len001RunInfo + Len001RunInfo;
  2009. memset(bufTextCang01_IO, ' ', sizeof(bufTextCang01_IO));
  2010. WrDwinBuf(ADDR_DWIN_Cang01_IO, &bufTextCang01_IO[0], 124, 1);
  2011. WrDwinBuf(ADDR_DWIN_Cang02_IO, &bufTextCang01_IO[0], 124, 1);
  2012. break;
  2013. // case DebugFun_Show_product_ID://显示ID编号
  2014. // memset((char*)bufText01Password+0,0,sizeof(bufText01Password));
  2015. // Len000=sprintf((char*)bufText01Password+0,"product_ID=%s",product_ID);
  2016. //
  2017. // Len001=sprintf((char*)bufText01Password+Len000,"product_ID=%s.code=%5d.\r\n",product_ID,FunDebugCode);
  2018. // Len001=Len001+Len001;
  2019. //
  2020. // break;
  2021. // case DebugFun_Show_Terminal://显示来自终端的命令
  2022. //
  2023. //
  2024. // break;
  2025. // case DebugFun_DS1302Time://显示ds1302时间信息
  2026. // memset(bufText01Password,0,sizeof(bufText01Password));
  2027. // DS1302_timeRead();
  2028. // Len001=sprintf((char*)bufText01Password,"系统运行中.tick=%08X,%08d.code=%5d.DS1302=%02X%02X%02X;%02X%02X%02X%02X%02X.\r\n",tick001,tick001,FunDebugCode,
  2029. // time_buf_reg[0],time_buf_reg[1],time_buf_reg[2],time_buf_reg[3],time_buf_reg[4],time_buf_reg[5],time_buf_reg[6],time_buf_reg[7]);
  2030. //
  2031. //// DS1302_get_all();
  2032. //// sprintf((char*)bufText01Password,"系统运行中.tick=%08X,%08d.code=%5d.DS1302=%02X%02X%02X;%02X%02X%02X%02X%02X.\r\n",tick001,tick001,FunDebugCode,
  2033. //// tableDS1302[0],tableDS1302[1],tableDS1302[2],tableDS1302[3],tableDS1302[4],tableDS1302[5],tableDS1302[6],tableDS1302[0]);
  2034. //
  2035. // break;
  2036. default:
  2037. //FM25L16B_Read_N_Bytes(ADDR_VersionOf_LCD,(uint8_t *)bufText01Password+0,32);
  2038. Len001RunInfo = sprintf((char *)bufText01Password, "系统运行中.tick=%08X,%08d.未识别code=%5d.\r\n", tick001, tick001, FunDebugCode);
  2039. memset((char *)bufText01Password + Len001RunInfo, 0, sizeof(bufText01Password) - Len001RunInfo);
  2040. break;
  2041. }
  2042. ; //FunDebugCode=DebugFun_Show_Terminal;
  2043. } //按键功能码>90000 ----结束 if(FunDebugCode>90000)
  2044. else
  2045. { //功能码范围在00--90000之间--开始
  2046. memset(bufText01Password, ' ', sizeof(bufText01Password));
  2047. //sprintf((char*)bufText01Password,"系统运行中.tick=%08X,%08d.\r\n",tick001,tick001);
  2048. if (FunDebugCode000 == 0)
  2049. {
  2050. Len001RunInfo = 0;//sprintf((char *)bufText01Password, "系统运行中.tick=%08X,%08u.默认配置code=%5d.CPU=%d.\r\n", tick001, totalRunTimeCnt, FunDebugCode000, cntUsage); //tick001/1000 cntUsage chkRetCaiJiBan Usart2_ErrorTimes
  2051. //cntUsage+=10;
  2052. #if (En_AnHuiKaiLe == 1)
  2053. Len_AnHuiKaiLe = sprintf((char *)bufText01Password + Len001RunInfo, "温度:%4.2f ℃,压力:%4.2f kPa.\r\n", KaiLeTemp + (tick001 % 20) * 0.0001, KaiLePressture + (tick001 % 20) * 0.00001);
  2054. Len001RunInfo = Len001RunInfo + Len_AnHuiKaiLe;
  2055. #endif
  2056. if (Collect485.Collect_CommError == True)
  2057. { //采集器掉线故障
  2058. Len_AnHuiKaiLe = sprintf((char *)bufText01Password + Len001RunInfo, "采集器断线:%06d.\r\n", Usart2_ErrorTimes);
  2059. Len001RunInfo = Len001RunInfo + Len_AnHuiKaiLe;
  2060. }
  2061. if (cntUsage > 0xefffffff)
  2062. {
  2063. cntUsage = 0;
  2064. }
  2065. memset((char *)bufText01Password + Len001RunInfo, 0, sizeof(bufText01Password) - Len001RunInfo);
  2066. }
  2067. else
  2068. { //1--90000之间的功能码--开始
  2069. //xy, 2022-12, 这里利用迪文屏,显示一些信息方便于测试者观察
  2070. switch (FunDebugCode000)
  2071. {
  2072. case 12111:
  2073. Len001RunInfo = sprintf((char *)bufText01Password, "KZB,version: %s,%d",
  2074. IR_ROM1==0x8000000 ? "app1":"app2",
  2075. Version_Soft[7]
  2076. );
  2077. break;
  2078. case 12555:
  2079. Len001RunInfo = sprintf((char *)bufText01Password, "flash, F|W|R: %d|%d|%d",
  2080. func_record_queue_flash_get(),
  2081. queue_record_obj.wr_cnt,
  2082. queue_record_obj.rd_cnt
  2083. );
  2084. break;
  2085. default:
  2086. Len001RunInfo = sprintf((char *)bufText01Password, "系统运行中.tick=%08X,%08d.未定义code=%5d.CPU=%d.\r\n", tick001, tick001 / 1000, FunDebugCode000, cntUsage);
  2087. break;
  2088. }
  2089. } //1--90000之间的功能码--结束
  2090. } //功能码范围在0--90000之间----结束
  2091. //taskENTER_CRITICAL();
  2092. if(Len001RunInfo==0)
  2093. Len001RunInfo=1;
  2094. if((Len001RunInfo!=Len001RunInfo_disp) || (Len001RunInfo_disp!=1))
  2095. {
  2096. WrDwinBuf(ADDR_DWIN_Text03_sysInfo, bufText01Password, Len001RunInfo, 1); //显示功能码以及对应的功能解析
  2097. Len001RunInfo_disp=Len001RunInfo;
  2098. }
  2099. //taskEXIT_CRITICAL();
  2100. totalRunTimeCnt++;
  2101. __nop();
  2102. }
  2103. void DisplayValveInfo(void)
  2104. {
  2105. //int i000;
  2106. int Len000Valve, Len002, Len003;
  2107. if (DebugFun__Restart_ContBoard01 != FunDebugCode) //只要不是重启命令就定时刷新屏幕信息
  2108. { //显示阀门开关信息--开始
  2109. //WrDwinBuf(ADDR_DWIN_Text04,&bufText01Password[0],44,1);
  2110. #if 0
  2111. if (FRAM_cnt % 5 == 0) //显示标题栏
  2112. { ////显示标题栏
  2113. ///*
  2114. //显示标题栏
  2115. memset(bufTextCang01_IO, ' ', sizeof(bufTextCang01_IO));
  2116. //Len000Valve=sprintf((char*)bufTextCang01_IO+16*0,"%s",arrValve_title01);// %02d\r\n
  2117. Len000Valve = sprintf((char *)bufTextCang01_IO + 16 * 0, "海底阀 卸油阀 人孔盖 小孔盖 管道油"); // %02d\r\n
  2118. memset((char *)bufTextCang01_IO + Len000Valve, 0, sizeof(bufTextCang01_IO) - Len000Valve);
  2119. //sprintf((char*)bufTextCang01_IO+16*0,"仓%d:--测试关-----关-----关-----关-----关---%d",StoreNumber,FRAM_cn);//
  2120. taskENTER_CRITICAL();
  2121. ; //WrDwinBuf(ADDR_DWIN_Title_IO,&bufTextCang01_IO[0],Len000Valve,1);
  2122. taskEXIT_CRITICAL();
  2123. //
  2124. // taskENTER_CRITICAL();
  2125. // //WrDwinBuf(ADDR_DWIN_Cang01_IO,&bufTextCang01_IO[0],Len002,1);
  2126. // memset(bufTextCang01_IO,' ',sizeof(bufTextCang01_IO));
  2127. // Len000Valve=sprintf((char*)bufTextCang01_IO+16*0,"海底阀 卸油阀 人孔盖 小孔盖 管道油");// %02d\r\n
  2128. // memset((char*)bufTextCang01_IO+Len000Valve,0,sizeof(bufTextCang01_IO)-Len000Valve);
  2129. // //sprintf((char*)bufTextCang01_IO+16*0,"仓%d:--测试关-----关-----关-----关-----关---%d",StoreNumber,FRAM_cn);//
  2130. // ;//
  2131. // WrDwinBuf(ADDR_DWIN_Title_IO,&bufTextCang01_IO[0],Len000Valve,1);
  2132. // taskEXIT_CRITICAL();
  2133. __nop();
  2134. //*/
  2135. } ////显示标题栏
  2136. #endif
  2137. ////第1--2仓阀门状态显示--开始
  2138. if (FRAM_cnt % 2 == 0)
  2139. { //第1--2仓阀门状态显示--开始
  2140. // if((ShowCang02_IO_EN==0) || (StoreNumber==1))
  2141. // {//如果禁止仓2显示 或者只有一个仓位则隐藏仓2的信息显示 //隐藏第二仓信息
  2142. //
  2143. // bufText01Password[0]=0xff00;//隐藏文本命令
  2144. // WrDwinBuf(ADDR_DWIN_Cang02_IO_SP,bufText01Password,1,0);
  2145. // WrDwinBuf(ADDR_DWIN_Cang03_IO_SP,bufText01Password,1,0);
  2146. // WrDwinBuf(ADDR_DWIN_Cang04_IO_SP,bufText01Password,1,0);
  2147. //
  2148. // }
  2149. // else
  2150. //显示第1仓信息
  2151. if(memcmp(ValStateArr_0x20_Cang01,Cang01_IO,64))
  2152. {
  2153. memset(bufTextCang01_IO, ' ', sizeof(bufTextCang01_IO));
  2154. Len002 = formatStr(bufTextCang01_IO, Cang01_IO, 1);
  2155. memset(bufTextCang01_IO + Len002, ' ', sizeof(bufTextCang01_IO) - Len002);
  2156. WrDwinBuf(ADDR_DWIN_Cang01_IO, &bufTextCang01_IO[0], Len002, 1);
  2157. memcpy(ValStateArr_0x20_Cang01,Cang01_IO,64);
  2158. }
  2159. // HAL_Delay(50);
  2160. //if(FRAM_cn%5==2)
  2161. if (StoreNumber >= 2)
  2162. {
  2163. if (memcmp(ValStateArr_0x20_Cang02, Cang02_IO, 64))
  2164. {
  2165. Len003 = formatStr(bufTextCang02_IO, Cang02_IO, 2);
  2166. memset(bufTextCang02_IO + Len003, ' ', sizeof(bufTextCang02_IO) - Len003);
  2167. // taskENTER_CRITICAL();
  2168. WrDwinBuf(ADDR_DWIN_Cang02_IO, &bufTextCang02_IO[0], Len003 + 0, 1); // 40
  2169. memcpy(ValStateArr_0x20_Cang02,Cang02_IO,64);
  2170. }
  2171. // taskEXIT_CRITICAL();
  2172. // HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  2173. // HAL_Delay(50);
  2174. }
  2175. } ////第1--2仓阀门状态显示--结束
  2176. if (StoreNumber >= 3)
  2177. { //如果存在3仓
  2178. if (FRAM_cnt % 2 == 1)
  2179. { ////第3--4仓阀门状态显示--开始
  2180. if (3 <= StoreNumber)
  2181. {
  2182. if (memcmp(ValStateArr_0x20_Cang03, Cang03_IO, 64))
  2183. {
  2184. Len003 = formatStr(bufTextCang03_IO, Cang03_IO, 3);
  2185. memset(bufTextCang03_IO + Len003, ' ', sizeof(bufTextCang03_IO) - Len003);
  2186. // taskENTER_CRITICAL();
  2187. WrDwinBuf(ADDR_DWIN_Cang03_IO, &bufTextCang03_IO[0], Len003, 1);
  2188. memcpy(ValStateArr_0x20_Cang03,Cang03_IO,64);
  2189. // taskEXIT_CRITICAL();
  2190. // HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  2191. // HAL_Delay(50);
  2192. }
  2193. }
  2194. //if(FRAM_cn%5==4)
  2195. if (4 == StoreNumber)
  2196. { // if(4==StoreNumber)
  2197. if (memcmp(ValStateArr_0x20_Cang04, Cang04_IO, 64))
  2198. {
  2199. Len003 = formatStr(bufTextCang04_IO, Cang04_IO, 4);
  2200. memset(bufTextCang04_IO + Len003, ' ', sizeof(bufTextCang04_IO) - Len003);
  2201. // taskENTER_CRITICAL();
  2202. WrDwinBuf(ADDR_DWIN_Cang04_IO, &bufTextCang04_IO[0], Len003, 1);
  2203. memcpy(ValStateArr_0x20_Cang04,Cang04_IO,64);
  2204. // taskEXIT_CRITICAL();
  2205. // HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
  2206. }
  2207. // HAL_Delay(50);
  2208. } // if(4==StoreNumber)
  2209. } ////第3--4仓阀门状态显示--结束
  2210. } //如果存在3仓
  2211. } ////显示阀门开关信息--结束
  2212. }
  2213. //格式化模拟量类传感器信息
  2214. int formatStrSensor(uint16_t *bufTextCang01_IO000, float *flo_data, uint8_t cangNum)
  2215. {
  2216. //int j001,Len001;//Len002
  2217. sprintf((char *)bufTextCang01_IO000, "T=%4.2f;", *flo_data); //Stor[0].Temperature
  2218. // if(Usart2_ErrorTimes>=Max_Usart2_ErrorTime)//485总线没有数据传输,默认从机有问题,6S
  2219. // {
  2220. // Collect485.Collect_CommError=True;
  2221. // WrDwinCmd16(ADDR_DWIN_StateYiChang_HaiDiFa,0xff);//底阀异常
  2222. // WrDwinCmd16(ADDR_DWIN_StateYiChang_XieYouFa,0xff);//卸油阀异常
  2223. //
  2224. // }
  2225. __nop();
  2226. return 0;
  2227. }
  2228. #define IO_NUM_Of_Cang01 4 //1仓开关数量
  2229. #define IO_NUM_Of_Cang02 6 //2仓开关数量
  2230. int j001_Cang01, Len001_Cang01; //Len002
  2231. int formatStrCang01(uint16_t *bufTextCang01_IO000, uint8_t *Cang01_IO000, uint8_t cangNum)
  2232. {
  2233. //sprintf((char*)bufTextCang01_IO+16*0,"仓1:非-开-关-非-非-非-非-非-非-非");// %02d\r\n
  2234. __nop();
  2235. //Len001=sprintf((char*)bufTextCang01_IO000+16*0,"仓%d:--关-----关-----关-----关-----关---",cangNum);// %02d\r\n
  2236. /*for(j001=0;j001<5;j001++)
  2237. {
  2238. if(j001<4)
  2239. {//前边4个位开关状态,第五个位有油无油
  2240. switch (Cang01_IO[j001+7])
  2241. {
  2242. case 0x00:
  2243. sprintf((char*)bufTextCang01_IO+4+j001*7," 关 ");
  2244. break;
  2245. case 0x01:
  2246. sprintf((char*)bufTextCang01_IO+4+j001*7," 开 ");
  2247. break;
  2248. case 0x03:
  2249. sprintf((char*)bufTextCang01_IO+4+j001*7," 异常 ");
  2250. break;
  2251. default:
  2252. sprintf((char*)bufTextCang01_IO+4+j001*7," 异常 ");
  2253. break;
  2254. }
  2255. }//前边4个字节为开关状态,第4个为有油无油
  2256. else
  2257. {//显示有油无油
  2258. switch (Cang01_IO[j001+7])
  2259. {
  2260. case 0x00:
  2261. sprintf((char*)bufTextCang01_IO+4+j001*7,"无油 ");
  2262. break;
  2263. case 0x01:
  2264. sprintf((char*)bufTextCang01_IO+4+j001*7,"有油 ");
  2265. break;
  2266. case 0x03:
  2267. sprintf((char*)bufTextCang01_IO+4+j001*7," 异常 ");
  2268. break;
  2269. default:
  2270. sprintf((char*)bufTextCang01_IO+4+j001*7," 异常 ");
  2271. break;
  2272. }
  2273. }//显示有油无油
  2274. }*/
  2275. if (DebugFun_Disp_Valve_Info_Bit == FunDebugCode) //直接显示阀门的原始数据----兼容之前的老板本协议,0xA1为帧标志
  2276. { //直接显示阀门的原始数据
  2277. //sprintf((char*)bufTextCang01_IO000+0+0*3,"仓%02d",cangNum);
  2278. sprintf((char *)bufTextCang01_IO000 + 0 + 0 * 3, "全部");
  2279. for (j001_Cang01 = 0; j001_Cang01 < 16; j001_Cang01++)
  2280. {
  2281. //sprintf((char*)bufTextCang01_IO000+4+j001*3,"%02X ",Array_Of_IO_0xA1[j001+5]);
  2282. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 3, "%02X ", Array_Of_IO_0xA1[j001_Cang01 + 5]);
  2283. }
  2284. Len001_Cang01 = j001_Cang01 * 2 + 4;
  2285. return Len001_Cang01;
  2286. } //直接显示阀门的原始数据----兼容之前的老板本协议,0xA1为帧标志
  2287. //flag_ShowValveRaw=1;
  2288. if (flag_ShowValveRaw == 1) //直接显示阀门的原始数据----64字节长度的新协议
  2289. { //直接显示阀门的原始数据
  2290. sprintf((char *)bufTextCang01_IO000 + 0 + 0 * 3, "仓%d:", cangNum);
  2291. for (j001_Cang01 = 0; j001_Cang01 < 20; j001_Cang01++)
  2292. { //直接显示阀门的原始数据
  2293. //sprintf((char*)bufTextCang01_IO000+4+j001*3,"%02X ",Cang01_IO000[j001+18]);
  2294. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 3, "%02X ", *(Cang01_IO000 + j001_Cang01 + 18));
  2295. }
  2296. Len001_Cang01 = j001_Cang01 * 3 + 4;
  2297. } //直接显示阀门的原始数据----64字节长度的新协议
  2298. else
  2299. { //解析阀门的开关状态--开始
  2300. Len001_Cang01 = sprintf((char *)bufTextCang01_IO000 + 16 * 0, "仓%d:", cangNum);
  2301. for (j001_Cang01 = 0; j001_Cang01 < IO_NUM_Of_Cang01; j001_Cang01++)
  2302. { //显示第一仓5个阀门的状态--开始
  2303. if (j001_Cang01 < 4)
  2304. { //前边3个字节代表开关状态:海底阀,卸油阀,人孔大盖,第五个为有油无油(00=无油,01=有油)
  2305. switch (*(Cang01_IO000 + j001_Cang01 + 18))
  2306. {
  2307. case 0x00:
  2308. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 关 ");
  2309. break;
  2310. case 0x01:
  2311. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 开 ");
  2312. break;
  2313. case 0x03:
  2314. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 异常 ");
  2315. break;
  2316. default:
  2317. //sprintf((char*)bufTextCang01_IO000+4+j001*7," 未知 ");
  2318. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 关 ");
  2319. break;
  2320. }
  2321. } //前边3个字节为开关状态
  2322. /*
  2323. else if(j001==3)//迪文屏上的排沉阀
  2324. {
  2325. switch (Cang01_IO[13])//索引为13的位置为第1个排尘阀
  2326. {
  2327. case 0x00:
  2328. sprintf((char*)bufTextCang01_IO+4+j001*7," 关 ");
  2329. break;
  2330. case 0x01:
  2331. sprintf((char*)bufTextCang01_IO+4+j001*7," 开 ");
  2332. break;
  2333. case 0x03:
  2334. sprintf((char*)bufTextCang01_IO+4+j001*7," 异常 ");
  2335. break;
  2336. default:
  2337. sprintf((char*)bufTextCang01_IO+4+j001*7," 异常 ");
  2338. break;
  2339. }
  2340. }
  2341. */
  2342. else if (j001_Cang01 == 4) //卸油阀的光电传感器输出,表示管道余油
  2343. { //显示有油无油
  2344. switch (*(Cang01_IO000 + j001_Cang01 + 18))
  2345. {
  2346. case 0x00:
  2347. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, "无油 ");
  2348. break;
  2349. case 0x01:
  2350. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, "有油 ");
  2351. break;
  2352. case 0x03:
  2353. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 异常 ");
  2354. break;
  2355. default:
  2356. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 异常 ");
  2357. break;
  2358. }
  2359. } //显示有油无油
  2360. else if (j001_Cang01 == 5) //海底阀的浮球探测--表示底阀存在余油
  2361. { //海底阀的浮球探测--表示底阀存在余油
  2362. switch (*(Cang01_IO000 + j001_Cang01 + 18))
  2363. {
  2364. case 0x00:
  2365. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, "无油 ");
  2366. break;
  2367. case 0x01:
  2368. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, "有油 ");
  2369. break;
  2370. case 0x03:
  2371. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 异常 ");
  2372. break;
  2373. default:
  2374. sprintf((char *)bufTextCang01_IO000 + 4 + j001_Cang01 * 7, " 异常 ");
  2375. break;
  2376. }
  2377. } //海底阀的浮球探测--表示底阀存在余油
  2378. Len001_Cang01 = 4 + j001_Cang01 * 7;
  2379. } //显示第一仓5个阀门的状态--结束
  2380. } //解析阀门的开光状态--结束
  2381. //memset(bufTextCang01_IO+40,0,sizeof(bufTextCang01_IO)-40);
  2382. return Len001_Cang01;
  2383. }
  2384. //阀门信息格式化解码
  2385. int formatStr(uint16_t *bufTextCang02_IO000, uint8_t *Cang02_IO000, uint8_t cangNum)
  2386. {
  2387. int j001, Len001;
  2388. uint8_t sensorValue;
  2389. //sprintf((char*)bufTextCang02_IO+16*0,"仓2:异-开-关-开-关-开-关-开-关-开 %02d\r\n",FRAM_cn);
  2390. __nop();
  2391. /*Len001=sprintf((char*)bufTextCang02_IO000+16*0,"仓%u:异-开-关-开-关-开-关-开-关-开",cangNum);// %02d\r\n
  2392. for(j001=0;j001<5;j001++)
  2393. {
  2394. switch (Cang02_IO[j001+7])
  2395. {
  2396. case 0x00:
  2397. sprintf((char*)bufTextCang02_IO+4+j001*7," 关 ");
  2398. break;
  2399. case 0x01:
  2400. sprintf((char*)bufTextCang02_IO+4+j001*7," 开 ");
  2401. break;
  2402. case 0x03:
  2403. sprintf((char*)bufTextCang02_IO+4+j001*7," 异常 ");
  2404. break;
  2405. default:
  2406. sprintf((char*)bufTextCang02_IO+4+j001*7," 异常 ");
  2407. break;
  2408. }
  2409. }*/
  2410. if (flag_ShowValveRaw == 1) //直接显示阀门的原-始数据
  2411. { //直接显示阀门的原始数据
  2412. Len001 = sprintf((char *)bufTextCang02_IO000 + 16 * 0, "仓%u:", cangNum);
  2413. for (j001 = 0; j001 < 20; j001++)
  2414. {
  2415. //sprintf((char*)bufTextCang02_IO000+4+j001*3,"%02X ",Cang02_IO000[j001+18]);
  2416. sprintf((char *)bufTextCang02_IO000 + 4 + j001 * 3, "%02X ", *(Cang02_IO000 + j001 + 18));
  2417. }
  2418. Len001 = 4 + j001 * 3;
  2419. } //直接显示阀门的原始数据
  2420. else
  2421. { //解析阀门的开关状态,转换为汉字--开始
  2422. Len001 = sprintf((char *)bufTextCang02_IO000 + 16 * 0, "仓%u:", cangNum);
  2423. for (j001 = 0; j001 < IO_NUM_Of_Cang01; j001++)
  2424. { //解析5个阀门的状态,--开始
  2425. #if 1
  2426. switch(j001)
  2427. {
  2428. case 0:
  2429. case 1:
  2430. sensorValue=*(Cang02_IO000 + j001 + 18); //底阀 左卸油阀
  2431. break;
  2432. case 2:
  2433. sensorValue=*(Cang02_IO000 + 11 + 18); //右卸油阀
  2434. break;
  2435. case 3:
  2436. sensorValue=*(Cang02_IO000 + 4 + 18); //管道油
  2437. break;
  2438. default:
  2439. break;
  2440. }
  2441. #else
  2442. sensorValue=*(Cang02_IO000 + j001 + 18);
  2443. #endif
  2444. if (j001 < (IO_NUM_Of_Cang01-1))
  2445. { //前边4个字节代表开关状态:海底阀,卸油阀,人孔大盖,人孔小盖,第1个为有油无油(00=无油,01=有油)
  2446. switch (sensorValue) //Cang02_IO000[j001+18]
  2447. {
  2448. case 0x00:
  2449. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, " 关 ");
  2450. break;
  2451. case 0x01:
  2452. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, " 开 ");
  2453. break;
  2454. case 0x03:
  2455. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, " 异常 ");
  2456. break;
  2457. default:
  2458. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, " 异常 ");
  2459. break;
  2460. }
  2461. } //前边4个字节代表开关状态:海底阀,卸油阀,人孔大盖,人孔小盖,第1个为有油无油(00=无油,01=有油)
  2462. /*
  2463. else if(j001==3)//迪文屏上的排尘阀
  2464. {
  2465. switch (Cang02_IO[13])//索引为13的位置为第1个排尘阀
  2466. {
  2467. case 0x00:
  2468. sprintf((char*)bufTextCang02_IO+4+j001*7," 关 ");
  2469. break;
  2470. case 0x01:
  2471. sprintf((char*)bufTextCang02_IO+4+j001*7," 开 ");
  2472. break;
  2473. case 0x03:
  2474. sprintf((char*)bufTextCang02_IO+4+j001*7," 异常 ");
  2475. break;
  2476. default:
  2477. sprintf((char*)bufTextCang02_IO+4+j001*7," 异常 ");
  2478. break;
  2479. }
  2480. }*/
  2481. else
  2482. { //显示有油无油
  2483. switch (sensorValue) //(Cang02_IO000[j001+18])
  2484. {
  2485. case 0x00:
  2486. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, "无油 ");
  2487. break;
  2488. case 0x01:
  2489. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, "有油 ");
  2490. break;
  2491. case 0x03:
  2492. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, " 异常 ");
  2493. break;
  2494. default:
  2495. Len001 += sprintf((char *)bufTextCang02_IO000 + Len001, " 异常 ");
  2496. break;
  2497. }
  2498. } //显示有油无油
  2499. //Len001 = 4 + j001 * 7;
  2500. } //解析5个阀门的状态,--开始
  2501. } //解析阀门的开关状态,转换为汉字--开始
  2502. __nop();
  2503. return Len001;
  2504. }
  2505. /*
  2506. 显示模拟量类的传感器信息------温度 液位 压力 Vt V20等参数
  2507. */
  2508. void DisplaySensorInfo(void)
  2509. {
  2510. // float f000;
  2511. int i;
  2512. int Len002, Len003;
  2513. static int CangNum_tskUart3;
  2514. float Ht_t[8];
  2515. //pT2C_SetupData->Reserved_parameters_4=1.0;
  2516. CangNum_tskUart3++;
  2517. if (CangNum_tskUart3 > StoreNumber)
  2518. {
  2519. CangNum_tskUart3 = 1; //
  2520. }
  2521. if (CangNum_tskUart3 == 1)
  2522. {
  2523. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data01;
  2524. }
  2525. if (CangNum_tskUart3 == 2)
  2526. {
  2527. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data02;
  2528. }
  2529. if (CangNum_tskUart3 == 3)
  2530. {
  2531. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data03;
  2532. }
  2533. if (CangNum_tskUart3 == 4)
  2534. {
  2535. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data04;
  2536. }
  2537. Vt_Local_Disp = pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[5];
  2538. Ht_t[0] = T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[0];
  2539. Ht_t[1] = T2C_ALL_Sensor_Data02.MoniLiang_Data_Every_Cang[0];
  2540. Ht_t[2] = T2C_ALL_Sensor_Data03.MoniLiang_Data_Every_Cang[0];
  2541. Ht_t[3] = T2C_ALL_Sensor_Data04.MoniLiang_Data_Every_Cang[0];
  2542. if(vt_disp_type==0)
  2543. {
  2544. Vt_Local[0] = T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[5];
  2545. Vt_Local[1] = T2C_ALL_Sensor_Data02.MoniLiang_Data_Every_Cang[5];
  2546. Vt_Local[2] = T2C_ALL_Sensor_Data03.MoniLiang_Data_Every_Cang[5];
  2547. Vt_Local[3] = T2C_ALL_Sensor_Data04.MoniLiang_Data_Every_Cang[5];
  2548. Tempe_For_V20[0] = T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[3];
  2549. Tempe_For_V20[1] = T2C_ALL_Sensor_Data02.MoniLiang_Data_Every_Cang[3];
  2550. Tempe_For_V20[2] = T2C_ALL_Sensor_Data03.MoniLiang_Data_Every_Cang[3];
  2551. Tempe_For_V20[3] = T2C_ALL_Sensor_Data04.MoniLiang_Data_Every_Cang[3];
  2552. V20_Local[0] = Vt_Local[0] * (1 + (20 - Tempe_For_V20[0]) * ExpansionRatio[0]);
  2553. V20_Local[1] = Vt_Local[1] * (1 + (20 - Tempe_For_V20[1]) * ExpansionRatio[1]);
  2554. V20_Local[2] = Vt_Local[2] * (1 + (20 - Tempe_For_V20[2]) * ExpansionRatio[2]);
  2555. V20_Local[3] = Vt_Local[3] * (1 + (20 - Tempe_For_V20[3]) * ExpansionRatio[3]);
  2556. }
  2557. else
  2558. {
  2559. for(i=0;i<4;++i)
  2560. {
  2561. Vt_Local[i] = T2C_SetupData[i].Capacity_Vt;
  2562. V20_Local[i] = T2C_SetupData[i].Capacity_V20;
  2563. }
  2564. }
  2565. Len003=0;
  2566. #if 0
  2567. memset(bufTextSensorInfo,0,256);
  2568. for(i=0;i<StoreNumber;++i)
  2569. {
  2570. switch (i)
  2571. {
  2572. case 0:
  2573. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data01;
  2574. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "一");
  2575. break;
  2576. case 1:
  2577. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data02;
  2578. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "二");
  2579. break;
  2580. case 2:
  2581. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data03;
  2582. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "三");
  2583. break;
  2584. case 3:
  2585. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data04;
  2586. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "四");
  2587. break;
  2588. default:
  2589. break;
  2590. }
  2591. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "仓: V20 % 8.1f ",
  2592. V20_Local[i]);
  2593. if(i==1 || i==3)
  2594. {
  2595. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "\r\n");
  2596. }
  2597. }
  2598. WrDwinBuf(ADDR_DWIN_SensorInfo, &bufTextSensorInfo[0], Len003, 1);
  2599. return;
  2600. if (Auto_sealedOK_ID_bak != Full_Oil_allinfo.Auto_sealedOK_ID)
  2601. {
  2602. for (i = 0; i < 4; ++i)
  2603. {
  2604. if ((Auto_sealedOK_ID_bak & (1<<i)) != (Full_Oil_allinfo.Auto_sealedOK_ID & (1<<i)))
  2605. {
  2606. if (Auto_sealedOK_ID_bak & (1<<i))
  2607. {
  2608. V20_Seal[i] = V20_Local[i];
  2609. Vt_Seal[i] = Vt_Local[i];
  2610. Ht_Seal[i] = Ht_t[i];
  2611. }
  2612. else
  2613. {
  2614. V20_Break[i] = V20_Local[i];
  2615. Vt_Break[i] = Vt_Local[i];
  2616. Ht_Break[i] = Ht_t[i];
  2617. }
  2618. }
  2619. }
  2620. Auto_sealedOK_ID_bak=Full_Oil_allinfo.Auto_sealedOK_ID;
  2621. }
  2622. #endif
  2623. switch (CangNum_tskUart3)
  2624. {
  2625. case 1:
  2626. V20_Local_Disp = V20_Local[0];
  2627. Vt_Local_Disp = Vt_Local[0];
  2628. break;
  2629. case 2:
  2630. V20_Local_Disp = V20_Local[1];
  2631. Vt_Local_Disp = Vt_Local[1];
  2632. break;
  2633. case 3:
  2634. V20_Local_Disp = V20_Local[2];
  2635. Vt_Local_Disp = Vt_Local[2];
  2636. break;
  2637. case 4:
  2638. V20_Local_Disp = V20_Local[3];
  2639. Vt_Local_Disp = Vt_Local[3];
  2640. break;
  2641. default:
  2642. V20_Local_Disp = V20_Local[0];
  2643. Vt_Local_Disp = Vt_Local[0];
  2644. break;
  2645. }
  2646. //taskENTER_CRITICAL();
  2647. //显示模拟量类传感器信息----开始
  2648. memset(bufTextSensorInfo, ' ', sizeof(bufTextSensorInfo));
  2649. // Stor[0].Temperature=123.34;
  2650. // Len002=formatStrSensor(bufTextSensorInfo,&Stor[0].Temperature,1);
  2651. // memset(bufTextSensorInfo+Len002,' ',sizeof(bufTextSensorInfo)-Len002);
  2652. //Len003=sprintf((char*)bufTextSensorInfo+Len002,"仓%d:--模拟量传感器信息-----关---%d",StoreNumber,Len002);// %02d\r\n
  2653. //
  2654. // Len003=sprintf((char*)bufTextSensorInfo+Len002,"仓数:%d,Vt01:%5.2f;--模拟量传感器信息-----关---%d",
  2655. // StoreNumber,Vt_Local,Len002);// %02d\r\n
  2656. /* Len003=sprintf((char*)bufTextSensorInfo+Len002,"仓数:%d;液位:%5.4f;%5.4f;Vt01:%5.2f;--模拟量传感器信息-----关---%d",
  2657. StoreNumber,
  2658. T2C_MoniLiang_Data_Cang1to4.MoniLiang_DataOfCang_1to4[0],
  2659. T2C_MoniLiang_Data_Cang1to4.MoniLiang_DataOfCang_1to4[11],
  2660. Vt_Local,Len002);// %02d\r\n
  2661. */
  2662. Len002 = 0;
  2663. //Len003=sprintf((char*)bufTextSensorInfo+Len002,"仓号:%d;h:%5.4f;T:%5.4f;T1,%5.4f;T2:%5.4f;T3:%5.4f;Vt:%5.4f;V20:%5.2f;--模拟量-----关---%d",
  2664. // StoreNumber,
  2665. // T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[0],
  2666. // T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[1],
  2667. // T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[2],
  2668. // T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[3],
  2669. // T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[4],
  2670. // T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[5],
  2671. // Vt_Local,Len002);// %02d\r\n
  2672. //Len003=sprintf((char*)bufTextSensorInfo+Len002,"仓号:%d;h:%5.4f;T:%5.4f;T1,%5.4f;T2:%5.4f;T3:%5.4f;Vt:%5.4f;V20:%5.2f;长度:%d",
  2673. // CangNum_tskUart3,
  2674. // pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[0],
  2675. // pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[1],
  2676. // pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[2],
  2677. // pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[3],
  2678. // pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[4],
  2679. // pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[5],
  2680. // Vt_Local_Disp,Len002);// %02d\r\n
  2681. ; //V20_Local_Disp+=10000.1301*CangNum_tskUart3;
  2682. //if(Config_info_all.Config_fun_id&0xC0)
  2683. {
  2684. Len003 = sprintf((char *)bufTextSensorInfo, "仓%d:",CangNum_tskUart3);
  2685. }
  2686. #if 0
  2687. if(Config_info_all.Config_fun_id&0x80) //液位
  2688. {
  2689. Len003 += sprintf((char *)bufTextSensorInfo + Len003, "h:%5.4f;Vt:%5.2f L;V20:%5.2f L\r\n",
  2690. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[0], //液位Pre:%5.2f
  2691. Vt_Local_Disp, //采集板查表计算的Vt
  2692. V20_Local_Disp);
  2693. }
  2694. if(Config_info_all.Config_fun_id&0x40) //压力
  2695. {
  2696. Len003 += sprintf((char *)bufTextSensorInfo + Len003, "Pressure:%5.4f\r\n",
  2697. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[6]);
  2698. }
  2699. #else
  2700. // if(Config_info_all.Config_fun_id&0x80) //液位
  2701. {
  2702. float disp_level, air_high, real_high;
  2703. real_high = ExpansionRatio[CangNum_tskUart3-1];
  2704. air_high = real_high - pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[0];
  2705. if(air_high > real_high) air_high = real_high;
  2706. disp_level = real_high - air_high;
  2707. Len003 += sprintf((char *)bufTextSensorInfo + Len003, " %5.1f %5.1f %.1f",
  2708. air_high,
  2709. disp_level,
  2710. Zero_Of_LiquidMeter[CangNum_tskUart3-1]);
  2711. }
  2712. WrDwinBuf(0x1A00+0x100*CangNum_tskUart3, &bufTextSensorInfo[0],Len003, 1);
  2713. return;
  2714. #endif
  2715. #if 0
  2716. Len003 = sprintf((char *)bufTextSensorInfo + Len002, "仓号:%d;h:%5.4f;Ta:%5.2f;T1,%5.2f ℃;T2:%5.2f;T3:%5.2f;\r\nVt:%5.2f L;V20:%5.2f L;\r\n",
  2717. CangNum_tskUart3,
  2718. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[0], //液位Pre:%5.2f
  2719. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[1], //平均温度
  2720. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[2], //温度1
  2721. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[3], //温度2
  2722. pT2C_ALL_Sensor_Data_Disp->MoniLiang_Data_Every_Cang[4], //温度3
  2723. Vt_Local_Disp, //采集板查表计算的Vt
  2724. V20_Local_Disp); // %02d\r\n ,V20_Local_Disp
  2725. #endif
  2726. if (FunDebugCode == 0)
  2727. {
  2728. // //整车参数
  2729. // Len002=sprintf((char*)bufTextSensorInfo+Len003,"Qx:%3.2f;Qy:%3.2f;Qz,%3.2f;电量:%3.2f;\r\n",
  2730. //
  2731. // pT2C_ALL_Sensor_WholeCar->tiltXYZ[0], //倾角
  2732. // pT2C_ALL_Sensor_WholeCar->tiltXYZ[1], //
  2733. // pT2C_ALL_Sensor_WholeCar->tiltXYZ[2], //
  2734. // pT2C_ALL_Sensor_WholeCar->BeiDianDianLiang //电量
  2735. // );// %02d\r\n
  2736. //整车参数
  2737. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "Qx:%3.2f ;Qy:%3.2f;\r\n",
  2738. pT2C_ALL_Sensor_WholeCar->tiltXYZ[0], //倾角
  2739. pT2C_ALL_Sensor_WholeCar->tiltXYZ[1]); // %02d\r\n
  2740. }
  2741. else
  2742. {
  2743. // memset((char*)bufText01Password+0,0,sizeof(bufText01Password));
  2744. // Len000=sprintf((char*)bufText01Password+0,"膨胀系数=");
  2745. // //FM25L16B_Read_N_Bytes(ADDR_OiLType_Data,(uint8_t *)bufText01Password+Len000,32);
  2746. // Len002=sprintf((char*)bufText01Password+Len000,"%6.5f,%6.5f,%6.5f,%6.5f",
  2747. // ExpansionRatio[0],ExpansionRatio[1],ExpansionRatio[2],ExpansionRatio[3]);
  2748. switch (FunDebugCode)
  2749. {
  2750. case DebugFun_SW_ExpansionRatio: //显示膨胀系数
  2751. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "膨胀系数s1:%6.5f;s2:%6.5f;s3,%6.5f;s4,%6.5f;\r\n",
  2752. ExpansionRatio[0], ExpansionRatio[1], ExpansionRatio[2], ExpansionRatio[3]); //
  2753. break;
  2754. case DebugFun_SW_ExtAddr_ControllBoard: //显示扩展地址
  2755. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "控制板扩展地址:%08X;\r\n",
  2756. addr_ext_controllBoard); //
  2757. break;
  2758. case DebugFun_SW_ValveState_PoFeng0x13: //显示破封时的阀门状态
  2759. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "破封阀门状态0x13:%02X%02X;%02X%02X;%02X%02X;%02X%02X;\r\n",
  2760. ValStateArr_PoFeng_0x13[5], ValStateArr_PoFeng_0x13[6], ValStateArr_PoFeng_0x13[7], ValStateArr_PoFeng_0x13[8],
  2761. ValStateArr_PoFeng_0x13[9], ValStateArr_PoFeng_0x13[10], ValStateArr_PoFeng_0x13[11], ValStateArr_PoFeng_0x13[12]); //
  2762. break;
  2763. case DebugFun_SW_ValveState_PoFeng0x20: //显示破封时的阀门状态
  2764. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "破封阀门状态0x20:%02X%02X;%02X%02X;%02X%02X;%02X%02X;\r\n",
  2765. ValStateArr_PoFeng_0x20[18 + 0], ValStateArr_PoFeng_0x20[18 + 1], ValStateArr_PoFeng_0x20[18 + 2], ValStateArr_PoFeng_0x20[18 + 3],
  2766. ValStateArr_PoFeng_0x20[18 + 4], ValStateArr_PoFeng_0x20[18 + 5], ValStateArr_PoFeng_0x20[18 + 6], ValStateArr_PoFeng_0x20[18 + 7]); //
  2767. break;
  2768. case DebugFun_SW_ExtAddr_IO_OnOff_Group: //显示扩展地址
  2769. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "U32阀门开关:%08X;%08X;%08X;%08X;\r\n",
  2770. IO_OnOff_State01, IO_OnOff_State02, IO_OnOff_State03, IO_OnOff_State04); //
  2771. break;
  2772. case DebugFun_Set_Enable_ReSeal: //允许重复施封
  2773. //FunDebugCode = 0;
  2774. Config_info_all.Config_fun_id |= 0x08; //UART4_RX_BUF[2];//功能配置ID
  2775. FM25L16B_WriteByte(ADDR_Config_fun_id, Config_info_all.Config_fun_id);
  2776. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "允许重复施封:%08X;%08X;%08X;%08X;%02X\r\n",
  2777. IO_OnOff_State01, IO_OnOff_State02, IO_OnOff_State03, IO_OnOff_State04, Config_info_all.Config_fun_id); //
  2778. break;
  2779. case DebugFun_Set_Disable_ReSeal: //禁止重复施封
  2780. //FunDebugCode = 0;
  2781. Config_info_all.Config_fun_id &= (~0x08); //功能配置ID
  2782. FM25L16B_WriteByte(ADDR_Config_fun_id, Config_info_all.Config_fun_id);
  2783. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "禁止重复施封!%08X;%08X;%08X;%08X;%02X;\r\n",
  2784. IO_OnOff_State01, IO_OnOff_State02, IO_OnOff_State03, IO_OnOff_State04,
  2785. Config_info_all.Config_fun_id); //
  2786. break;
  2787. case DebugFun_SW_ExtAddr_IO_Exception_Group: //显示扩展地址
  2788. Len002 = sprintf((char *)bufTextSensorInfo + Len003, "U32阀门异常:%08X;%08X;%08X;%08X;%02X;\r\n",
  2789. IO_Exception_State01, IO_Exception_State02, IO_Exception_State03, IO_Exception_State04,
  2790. Config_info_all.Config_fun_id); //
  2791. break;
  2792. default:
  2793. // Len002=sprintf((char*)bufTextSensorInfo+Len003,"膨胀系数s1:%6.5f;s2:%6.5f;s3,%6.5f;s4,%6.5f;\r\n",
  2794. // ExpansionRatio[0],ExpansionRatio[1],ExpansionRatio[2],ExpansionRatio[3]);//
  2795. __NOP();
  2796. break;
  2797. }
  2798. }
  2799. //显示来自平台的数据
  2800. if (data_Src_To_Disp != 0)
  2801. {
  2802. }
  2803. if(Run_mode_key_info.current_page==Run_mode_key_info.Liquid_id)
  2804. {
  2805. memset(bufTextSensorInfo,0,256);
  2806. Len003 = sprintf((char *)bufTextSensorInfo, " 体积Vt(L) 液位ht(m) 体积V20(L)\r\n");
  2807. WrDwinBuf(ADDR_DWIN_SensorInfoAll, &bufTextSensorInfo[0],Len003, 1);
  2808. for(i=0;i<StoreNumber;++i)
  2809. {
  2810. Len003=0;
  2811. memset(bufTextSensorInfo,0,256);
  2812. switch (i)
  2813. {
  2814. case 0:
  2815. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data01;
  2816. Len003 = sprintf((char *)bufTextSensorInfo, "一");
  2817. break;
  2818. case 1:
  2819. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data02;
  2820. Len003 = sprintf((char *)bufTextSensorInfo, "二");
  2821. break;
  2822. case 2:
  2823. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data03;
  2824. Len003 = sprintf((char *)bufTextSensorInfo, "三");
  2825. break;
  2826. case 3:
  2827. pT2C_ALL_Sensor_Data_Disp = &T2C_ALL_Sensor_Data04;
  2828. Len003 = sprintf((char *)bufTextSensorInfo, "四");
  2829. break;
  2830. default:
  2831. break;
  2832. }
  2833. #if 0
  2834. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "仓装油: 体积Vt:% 7.1f L;液位ht:%1.4f m;体积V20:% 7.1f L;\r\n",
  2835. Vt_Seal[i], //采集板查表计算的Vt
  2836. Ht_Seal[i], //液位Pre:%5.2f
  2837. V20_Seal[i]);
  2838. Len003 += sprintf((char *)bufTextSensorInfo+Len003, " 卸油: 体积Vt:% 7.1f L;液位ht:%1.4f m;体积V20:% 7.1f L;\r\n",
  2839. Vt_Break[i], //采集板查表计算的Vt
  2840. Ht_Break[i], //液位Pre:%5.2f
  2841. V20_Break[i]);
  2842. #else
  2843. Len003 += sprintf((char *)bufTextSensorInfo+Len003, "仓装油: % 8.1f \t% 7.4f \t% 8.1f\r\n",
  2844. Vt_Seal[i], //采集板查表计算的Vt
  2845. Ht_Seal[i], //液位Pre:%5.2f
  2846. V20_Seal[i]);
  2847. Len003 += sprintf((char *)bufTextSensorInfo+Len003, " 卸油: % 8.1f \t% 7.4f \t% 8.1f\r\n",
  2848. Vt_Break[i], //采集板查表计算的Vt
  2849. Ht_Break[i], //液位Pre:%5.2f
  2850. V20_Break[i]);
  2851. #endif
  2852. WrDwinBuf(ADDR_DWIN_SensorInfoAll+(i+1)*0x100, &bufTextSensorInfo[0],Len003, 1);
  2853. }
  2854. memset(bufTextSensorInfo,0,256);
  2855. Len002 = sprintf((char *)bufTextSensorInfo, "倾角 x轴:%3.2f ; y轴:%3.2f;\r\n",
  2856. pT2C_ALL_Sensor_WholeCar->tiltXYZ[0], //倾角
  2857. pT2C_ALL_Sensor_WholeCar->tiltXYZ[1]); // %02d\r\n
  2858. WrDwinBuf(ADDR_DWIN_SensorInfoAll+(i+1)*0x100, &bufTextSensorInfo[0],Len002, 1);
  2859. }
  2860. else
  2861. {
  2862. WrDwinBuf(ADDR_DWIN_SensorInfo, &bufTextSensorInfo[0], Len002 + Len003, 1);
  2863. }
  2864. }
  2865. /* USER CODE END Application */
  2866. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/