freertos.c 113 KB

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