freertos.c 110 KB

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