freertos.c 121 KB

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