| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064 | 
							- #include <rtthread.h>
 
- #include "buffer.h"
 
- #include "button.h"
 
- #include "ring_buffer.h"
 
- #include "flash.h"
 
- #include <stdlib.h>
 
- #include "usart.h"
 
- #include "plan.h"
 
- #include "rtc.h"
 
- #include "weight.h"
 
- #include "ad.h"
 
- #include "display.h"
 
- #include "stm32f1xx_hal.h"
 
- unsigned char  isWeight = 0;
 
- static unsigned char WeightConst_RecFlag1 = 0;         //正在接收重量标志 0xF0处理完成
 
- static unsigned char WeightConst_RecWeightPoint1 = 0;  //接收重量指针
 
- static unsigned char WeightConst_RecWeightData1[250];  //接收重量临时表
 
- static unsigned char WeightConst_Drop=0; //抛弃数据
 
- static unsigned char WeightConst_WeightCount = 0;        //重量数
 
- static signed short WeightConst_WeightMax = -32768;         //最大重量
 
- static signed short WeightConst_WeightMin = 32767;     //最小重量
 
- signed long WeightConst_WeightCurTem = 0;      //当前临时重量
 
- unsigned char WeightConst_WeightCurTemZF = 1;     //当前临时重量正负,用TMRII
 
- unsigned char WeightConst_WeightWS = 0;   //小数位数
 
- unsigned char WeightConst_Weight_ZWS = 0;   //整数位数
 
- signed short WeightConst_WeightLast;   //上次按键重量   1S一次
 
- signed short WeightConst_WeightCur;   //当前重量   1S一次
 
- signed short WeightConst_WeightOK;   //OK重量   1S一次
 
- static unsigned char WeightConst_WeightCurCount = 0;        //重量计数,用于每15秒取一次重量
 
- static signed short WeightConst_WeightCurTemLast = 0;      //上次临时重量
 
- static unsigned short WeightConst_RecWeight_he1 = 0;  //校验重量准确性
 
- static unsigned short WeightConst_RecWeight_he2 = 0;  //校验重量准确性
 
- static unsigned short WeightConst_RecWeight_he3 = 0;  //校验重量准确性
 
- static signed short WeightConst_WeightCur_last1=0;
 
- static signed short WeightConst_WeightCur_last2=0;
 
- static signed short WeightConst_WeightCur_last3=0;
 
- static long WeightConst_WeightSum = 0;  //当前重量总和
 
- unsigned char WeightConst_oksum = 0;     //符合目标重量数
 
- unsigned char WeightConst_allsum = 0;    //总重量值数
 
- static unsigned char WeightConst_uoksum = 0;
 
- static unsigned char WeightConst_foksum = 0;
 
- static unsigned char WeightConst_uallsum = 0;
 
- unsigned char WeightConst_AutoSingleNSecondNum[30][3];    //自动跳转每秒值的数组
 
- unsigned char WeightConst_AutoSingleNSecondPoint = 0;     //自动跳转的每秒的当前指针
 
- static unsigned char WeightConst_WeightTargetTpo = 65;           //自动跳转的权重阀值固定为65%
 
- static unsigned char WeightConst_autotpo = 0;                    //自动跳转的权重阀值
 
- union timeweight_t  timeweight;
 
- rt_sem_t weight_lock = RT_NULL;
 
- unsigned long mypow(unsigned char x,unsigned char y) {
 
-     unsigned long z;
 
-     if (y==0) z=1;
 
-     else  z=x;
 
-     for (int i=1; i<y; i++)
 
-         z = z*x;
 
-     return z;
 
- }
 
- void weight_usart_Init(UART_HandleTypeDef* uartHandle)
 
- {
 
- 	extern unsigned char WeightConst_TQ;
 
- 	extern unsigned char  iscowweight;
 
- 	if ((uartHandle->Instance==USART1) || 
 
- 		  (uartHandle->Instance==USART2 && (WeightConst_BLE==1 || WeightConst_BLE==3)))
 
- 	{
 
- 			if (WeightConst_TQ==1)
 
- 			{
 
- 				 uartHandle->Init.BaudRate = 9600;
 
- 			//	uartHandle->Init.StopBits    = UART_STOPBITS_2;	 //停止位1位		
 
- 			}
 
- 			else if (WeightConst_TQ==7)
 
- 			{
 
- 				 //RCC_PCLK2Config(RCC_HCLK_Div2);	
 
- 				 uartHandle->Init.BaudRate = 600;
 
- 			}
 
- 			else if (WeightConst_TQ==4)			
 
- 				 uartHandle->Init.BaudRate = 19200;
 
- 			else if (WeightConst_TQ==8)
 
- 				 uartHandle->Init.BaudRate = 38400;
 
- //			else if (WeightConst_TQ==9)
 
- //				 uartHandle->Init.BaudRate = 1200;
 
- 			else if (WeightConst_TQ==9)
 
- 			{
 
- 					uartHandle->Init.BaudRate    = 9600;
 
- 					uartHandle->Init.Parity      = UART_PARITY_NONE;
 
- 					uartHandle->Init.WordLength  = UART_WORDLENGTH_8B; //8位数据
 
- 				//	uartHandle->Init.StopBits    = UART_STOPBITS_2;	 //停止位2位  海丰需要 
 
-           uartHandle->Init.StopBits    = UART_STOPBITS_1;	 //停止位1位
 
- 			}
 
- 			else if (WeightConst_TQ==10)
 
- 			{
 
- 					uartHandle->Init.BaudRate    = 9600;
 
- 					uartHandle->Init.Parity      = UART_PARITY_NONE;
 
- 					uartHandle->Init.WordLength  = UART_WORDLENGTH_8B; //8位数据
 
- 					uartHandle->Init.StopBits    = UART_STOPBITS_1;	 //停止位1位		
 
- 			}
 
- 			else
 
- 				 uartHandle->Init.BaudRate = 9600;		
 
- 			if (iscowweight==1	){
 
- 					uartHandle->Init.BaudRate    = 19200;
 
- 					uartHandle->Init.Parity      = UART_PARITY_NONE;
 
- 					uartHandle->Init.WordLength  = UART_WORDLENGTH_9B; //8位数据
 
- 					uartHandle->Init.StopBits    = UART_STOPBITS_1;	 //停止位1位		
 
- 			}		
 
-   }
 
- //	else if ((uartHandle->Instance==USART3) && (iscowweight==1))
 
- //	{
 
- //		 uartHandle->Init.BaudRate = 19200;
 
- //		 uartHandle->Init.Parity = UART_PARITY_EVEN; 
 
- //		 uartHandle->Init.WordLength  = UART_WORDLENGTH_9B; //8位数据
 
- //		 uartHandle->Init.StopBits    = UART_STOPBITS_1;	 //停止位1位
 
- //	}
 
- }
 
- static void setWeightSM() {  // 设定合计重量
 
-     if 	((WeightConst_WeightCurTem > (WeightConst_WeightCurTemLast+1000) ||
 
-             (WeightConst_WeightCurTem < (WeightConst_WeightCurTemLast - 1000) && WeightConst_WeightCurTem!=32768))
 
-             && WeightConst_RecWeight_he3 < 3)
 
-     {
 
-         WeightConst_WeightCurTem = WeightConst_WeightCurTemLast;
 
-         WeightConst_RecWeight_he3 ++;
 
-     }
 
-     else //if (WeightConst_WeightCurTem>-32768)
 
-     {
 
-         WeightConst_WeightCurTemLast = WeightConst_WeightCurTem;
 
-         WeightConst_RecWeight_he3 = 0;
 
- 			
 
-         rt_sem_take(weight_lock, RT_WAITING_FOREVER);
 
-         if (WeightConst_WeightMax < WeightConst_WeightCurTem)	WeightConst_WeightMax = WeightConst_WeightCurTem; //修改最大重量
 
-         if (WeightConst_WeightMin > WeightConst_WeightCurTem)	WeightConst_WeightMin = WeightConst_WeightCurTem; //修改最小重量
 
-         WeightConst_WeightSum = WeightConst_WeightSum + WeightConst_WeightCurTem; //  重量和
 
-         WeightConst_WeightCount++; // 重量采样数	
 
- 		   	WeightConst_allsum++;
 
- 		  	rt_sem_release(weight_lock);
 
- 			
 
-         //判断是否在范围内
 
-         if(pf_comp.data.autosecond>0 &&  WeightConst_WeightHaveBegin==1) { //跳转时间大于0
 
-             if ((WeightConst_WeightCurTem>WeightConst_WeightTargetAllowMin &&
 
-                     WeightConst_WeightCurTem<WeightConst_WeightTargetAllowMax && WeightConst_ChanCheShu>1)
 
-                     || (WeightConst_WeightCurTem>WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==0 && WeightConst_ChanCheShu==1)) //大目标  为正,且当前值小于大目标
 
-             {
 
-                 if ((WeightConst_SBType==4||WeightConst_SBType==6) && WeightConst_Stop==0 && isn==0) {
 
-   									rt_event_send(&display_event, EVENT_Stop);
 
-                     WeightConst_Stop=1;
 
-                 }
 
-                 WeightConst_oksum++;
 
-                 WeightConst_WeightOK=WeightConst_WeightCurTem;
 
-             }
 
-             //WeightConst_WeightTargetAllow
 
-             if ((WeightConst_WeightCurTem>WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==0)
 
-                     ||(WeightConst_WeightCurTem<WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==1))
 
-             {
 
-                 alarm_on();
 
-                 //----------------------------if (WeightConst_SBType==5) ControlPlay(2, 1);
 
-             }
 
-             else if ((WeightConst_WeightCurTem < WeightConst_WeightTargetAllowMin && pf_comp.data.addorout == 0)
 
-                      || (WeightConst_WeightCurTem > WeightConst_WeightTargetAllowMin && pf_comp.data.addorout == 1))
 
-             {
 
-                 //----------------------------if (WeightConst_SBType==5) ControlPlay(2, 0);
 
-                alarm_off();
 
-             }
 
-         }
 
-         
 
-     }
 
-     HAL_GPIO_TogglePin(led_GPIO_Port, led_Pin);
 
- }
 
- void sendWeight() {
 
-     /* key0 协议 34字节(上报实时重量):0x7E 0x20 0x01 0xF0 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01     1位起始位 + 1位长度 + 1位源地址 + 1位命令 + 28位重量(四段) + 1帧编号 + 1校验
 
-      */
 
-     if (rb_full_count(RecWeightQueue) > 28) {
 
-         unsigned char buf[34] ;
 
-         unsigned char CRCNum=0;
 
-         buf[0]= 0x7E;
 
-         buf[1]= 0x20;
 
-         buf[2]= XbeeConst_DeviceAddress;
 
-         buf[3]= 0xF0;
 
-         for (int i=0; i <28; i++) buf[i+4]= rb_remove(RecWeightQueue);
 
-         buf[32] = XbeeConst_FrameNum ++;
 
- 			  HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR3, buf[32]);	
 
-         for (int i=0; i< 33; i++)  CRCNum+=buf[i];
 
-         buf[33]= 0xff - CRCNum;
 
-         for (int i=0; i <(int)(sizeof(buf)/sizeof(unsigned char)); i++)
 
-             rb_push_insert(SendWeightQueue,buf[i]);
 
-     }
 
- }
 
- void sendEIDWeight(unsigned char * eidbuf, signed short WeightCur) {
 
-     /* key6 协议 34字节(上报电子称重):0x7E 0x0D 0x01 0xF6 0x00 0x00 0x00 0x00 0x00 0x00 0x00   1位起始位 + 1位长度 + 1位源地址 + 1位命令 + 7位耳标 + 2位重量 + 1帧编号 + 1校验
 
-      */
 
- 	 unsigned char buf[15] ;
 
-         unsigned char CRCNum=0;
 
- 	  if( eidbuf[0] == 5 &&  WeightCur>20){		 
 
-         buf[0]= 0x7E;
 
-         buf[1]= 0x0D;
 
-         buf[2]= XbeeConst_DeviceAddress;
 
-         buf[3]= 0xF6;
 
-         for (int i=0; i <7; i++) buf[i+4]= eidbuf[i+1];
 
-         buf[11]= (WeightCur>>8) &0xFF;
 
- 			  buf[12]= WeightCur &0xFF;
 
-         buf[13] = XbeeConst_FrameNum ++;
 
- 			  HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR3, buf[13]);
 
-         for (int i=0; i< 14; i++)  CRCNum+=buf[i];
 
-         buf[14]= 0xff - CRCNum;
 
-         for (int i=0; i <(int)(sizeof(buf)/sizeof(unsigned char)); i++)
 
-             rb_push_insert(SendWeightQueue,buf[i]);
 
- 		}  
 
- }
 
- void CheckWeightthread(void) {
 
-     while (1) {			
 
- 			if (WeightConst_DELAYON>0)        //搅拌延时
 
- 			{
 
- 					WeightConst_DELAYTIME ++;
 
- 				  HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR5, WeightConst_DELAYTIME);	
 
- 					if (WeightConst_DELAYTIME >  (pf_comp.data.delaytime * 60))  //10 &&pf_comp.data.delaytime>0 )
 
- 					{
 
- 							write_Flash("begintime", &TimeConst, sizeof(TimeConst));											
 
- //							WeightConst_WeightBegin = WeightConst_WeightCur;					
 
- //              write_Flash("beginweight", &WeightConst_WeightBegin, sizeof(WeightConst_WeightBegin)); 
 
- 							pf_comp.data.delaytime = 0;
 
- 						  WeightConst_DELAYTIME = 0;
 
- 						  WeightConst_DELAYON = 0;
 
- 					  	HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR4, 0);	
 
- 						  HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR5, 0);	
 
- 						  HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR6, 0);	
 
- 						  rt_sem_release(pop_product_sem);//弹出最新内容
 
- 					}
 
- 			}
 
- 		//	else {
 
- 		//		WeightConst_DELAYTIME = 0;
 
- 		 //  	WeightConst_DELAYON=0;
 
- 	//		}
 
- 			
 
- 			if ( WeightConst_allsum > 0) {
 
- 			  rt_sem_take(weight_lock, RT_WAITING_FOREVER);
 
-         if (WeightConst_WeightCount>2) {
 
-             WeightConst_WeightSum = WeightConst_WeightSum - WeightConst_WeightMin; //  重量和 减去最小值
 
-             WeightConst_WeightSum = WeightConst_WeightSum - WeightConst_WeightMax; //  重量和 减去最大值
 
-             WeightConst_WeightCount = WeightConst_WeightCount - 2;
 
-         }
 
-         WeightConst_WeightCur = WeightConst_WeightSum / WeightConst_WeightCount;
 
- 		  	
 
- 				
 
-         if (WeightConst_WeightCurCount >= 0x0F) {  //15秒准备发送后台重
 
- 					  rt_sem_take(setTIME_lock, RT_WAITING_FOREVER);
 
- 					  timeweight.Buffer[3] =TimeConst.Buffer[0];
 
- 					  timeweight.Buffer[4] =TimeConst.Buffer[1];
 
- 					  timeweight.Buffer[5] =TimeConst.Buffer[2];
 
- 					  timeweight.Buffer[6] =TimeConst.Buffer[3];
 
- 					  rt_sem_release(setTIME_lock);
 
- 					  timeweight.data.Weight = WeightConst_WeightCur;
 
- 					  timeweight.data.WeightWS = WeightConst_WeightWS;
 
- 					  timeweight.data.WeightRun = WeightConst_Product_Run; 
 
- 				  	timeweight.data.reserved = 0;
 
- 						ts_pushArrary(&ts_weightdb, timeweight.Buffer, 7);
 
-             WeightConst_WeightCur_last3 = WeightConst_WeightCur_last2;
 
-             WeightConst_WeightCur_last2 = WeightConst_WeightCur_last1;
 
-             WeightConst_WeightCur_last1 = WeightConst_WeightCur;
 
- //            if (WeightConst_WeightCur<0)
 
- //                rb_push_insert(RecWeightQueue, (0<<7) | (WeightConst_WeightWS<<6>>1));//这边有问题,需要修改
 
- //            else
 
- //                rb_push_insert(RecWeightQueue, (0<<7) | (WeightConst_WeightWS<<6>>1));//这边有问题,需要修改
 
-             WeightConst_WeightCurCount=0;
 
-         }
 
- 				rt_sem_release(weight_lock);
 
-         if (WeightConst_AutoSingleNSecondPoint>=pf_comp.data.autosecond || WeightConst_AutoSingleNSecondPoint>=30)
 
-             WeightConst_AutoSingleNSecondPoint = 0;
 
-         WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][0] = WeightConst_oksum;
 
-         WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][1] = WeightConst_allsum;
 
-         if (//( WeightConst_WeightMax - WeightConst_WeightMin)>WeightConst_WeightTargetAllow && 
 
- 					   WeightConst_WeightCur > WeightConst_WeightTargetAllowMax
 
-                 &&  pf_comp.data.autosecond>0 &&  WeightConst_WeightHaveBegin==1)
 
-             WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][2] = 1;
 
-         else
 
-             WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][2] = 0;
 
-         WeightConst_WeightSum = 0;
 
-         WeightConst_WeightCount = 0;        //重量数
 
-         WeightConst_WeightMax = -32768;         //最大重量
 
-         WeightConst_WeightMin = 32767;     //最小重量
 
-         WeightConst_AutoSingleNSecondPoint++;
 
-         WeightConst_uoksum = 0;
 
-         WeightConst_uallsum = 0;
 
-         WeightConst_foksum = 0;
 
-         for (int CheckWeight_i = 0; CheckWeight_i < pf_comp.data.autosecond; CheckWeight_i++) {
 
-             WeightConst_uoksum = WeightConst_uoksum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][0];
 
-             WeightConst_uallsum = WeightConst_uallsum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][1];
 
-             WeightConst_foksum = WeightConst_foksum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][2];
 
-         }
 
-         if (WeightConst_uallsum == 0)
 
-             WeightConst_uallsum = 100;   //如果没接称,allsum有可能为0,此处进行保护
 
-         WeightConst_autotpo = WeightConst_uoksum * 100 / WeightConst_uallsum;  //合理停留秒数内接收到的符合跳转的数据占总接收数据的百分比
 
-         if (WeightConst_autotpo > 100) WeightConst_autotpo = 0;     //对百分比进行保护
 
-         if ((WeightConst_autotpo > WeightConst_WeightTargetTpo)
 
-                 || (WeightConst_foksum>(pf_comp.data.autosecond>>1) && pf_comp.data.JMP)  
 
-            )       //触发自动按键
 
-         {
 
-             for (int CheckWeight_i = 0; CheckWeight_i < 30; CheckWeight_i++) {
 
-                 WeightConst_AutoSingleNSecondNum[CheckWeight_i][0]=0;
 
-                 WeightConst_AutoSingleNSecondNum[CheckWeight_i][1]=0;
 
-                 WeightConst_AutoSingleNSecondNum[CheckWeight_i][2]=0;
 
-             }
 
-             if (WeightConst_DELAYON == 0 && delayKeying == 0)
 
- 						{			
 
- 							rt_sem_release(delay_key_sem); 								
 
- 							sendkey1(0xF1, 0);
 
- 						}
 
-             button_state.b1 = 1; //5秒内禁止按1键
 
-         }
 
-         WeightConst_oksum = 0;
 
-         WeightConst_allsum = 0;
 
-         WeightConst_uoksum = 0;
 
-         WeightConst_uallsum = 0;
 
-         WeightConst_foksum = 0;
 
-        // sendWeight(); //检查是否需要保存实时重量
 
- 			}
 
- 			WeightConst_WeightCurCount++;
 
- 			
 
- 			
 
-       if (WeightConst_Product_Run > 0)
 
- 		  {
 
- 				if (WeightConst_Nextfeed[0] == 0x20){
 
- 					if (findNextplan()>0) 
 
- 						rt_event_send(&display_event, EVENT_Next);
 
- 				}
 
- 						
 
- 				if (WeightConst_Product_Run_time < 65535 && WeightConst_Product_Run_time>0 && pf_comp.data.addorout==0)
 
- 						WeightConst_Product_Run_time++;		  
 
- 			//	else 
 
- 			//		WeightConst_Product_Run_time = 0;
 
- 				HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR3, WeightConst_Product_Run_time);	
 
- 			}
 
- 			rt_thread_mdelay(998);
 
-     }
 
- }
 
- static void P_300G0() {
 
-     //	02 20 2D 20 20 20 36 37 2E 30 6B 67 03   -67.0KG
 
-     //  02 20 20 20 20 20 36 37 2E 36 6B 7F 03
 
-     //  02 2B 30 30 30 30 30 30 33 03
 
-     if (WeightConst_RecWeightPoint1>39) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) //TDI300G0
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 12 && WeightConst_RecWeightData1[0] == 0x02) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 3] >= 0x30 && WeightConst_RecWeightData1[ReadWeight_i + 3] <= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem + (WeightConst_RecWeightData1[ReadWeight_i + 3] - 0x30) * mypow(10, 6 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     } else if (WeightConst_RecWeightData1[ReadWeight_i + 3] == 0x2E) {
 
-                         WeightConst_WeightWS = 6 - ReadWeight_i; //设置小数位数
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
-                     }
 
-                 }
 
-                 if (WeightConst_RecWeightData1[2] == 0x2D)	WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else
 
-             WeightConst_RecWeightPoint1++;
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x02)
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_300G1() {
 
-     //	02 2D 20 20 20 36 37 2E 30 6B 67 03   -67.0KG
 
-     //  02 20 20 20 20 32 2E 33 30 6B 67 03
 
-     if (WeightConst_RecWeightPoint1>39) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) //TDI300G0
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 11 && WeightConst_RecWeightData1[0] == 0x02) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 2] >= 0x30 && WeightConst_RecWeightData1[ReadWeight_i + 2] <= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem + (WeightConst_RecWeightData1[ReadWeight_i + 2] - 0x30) * mypow(10, 6 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     } else if (WeightConst_RecWeightData1[ReadWeight_i + 2] == 0x2E) {
 
-                         WeightConst_WeightWS = 6 - ReadWeight_i; //设置小数位数
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
-                     }
 
-                 }
 
-                 if (WeightConst_RecWeightData1[1] == 0x2D)	WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else
 
-             WeightConst_RecWeightPoint1++;
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x02)
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_TDI200I() {
 
-     //02 2B 30 30 30 30 30 30 33 03
 
-     //02 +/-	十万 万 千 百 十 个	小数点位数	03
 
-     if (WeightConst_RecWeightPoint1>39) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 9 && WeightConst_RecWeightData1[0] == 0x02) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 2] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 2]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 2] - 0x30) * mypow(10, 6 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                     WeightConst_WeightWS = WeightConst_RecWeightData1[8] - 0x30; //设置小数位数
 
-                 }
 
-                 if (WeightConst_RecWeightData1[1] != 0x2B)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else
 
-             WeightConst_RecWeightPoint1++;
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x02)
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_XK3190_C8() {
 
-     //兼容XK3118K9
 
-     //02 2D 30 30 30 31 32 30 31 03
 
-     //02 2D 30 30 30 31 32 30 31 31 46 03
 
-     //02 +/- 0  1  2  3  4	5 点位数	 03
 
-     if (WeightConst_RecWeightPoint1>39) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 11 && WeightConst_RecWeightData1[0] == 0x02) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 2] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 2]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 2] - 0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                 }
 
-                 WeightConst_WeightWS = WeightConst_RecWeightData1[8] - 0x30; //设置小数位数
 
-                 if (WeightConst_WeightWS==1)
 
-                 {
 
-                     WeightConst_WeightWS = 0;
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem/10;
 
-                 }
 
-                 if (WeightConst_RecWeightData1[1] != 0x2B)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x03) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x02)
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_AWH_30_SA() {
 
-     //展会   //53 54 2C 47 53 2C 2B 20 20 30 2E 38 37 36 6B 67 0d 0a
 
-     if (WeightConst_RecWeightPoint1>39) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 17) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 7] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 7]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 7] - 0x30) * mypow(10, 6 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     } else if (WeightConst_RecWeightData1[ReadWeight_i + 7] == 0x2E) {
 
-                         WeightConst_WeightWS = 6 - ReadWeight_i; //设置小数位数
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
-                     }
 
-                 }
 
-                 if (WeightConst_RecWeightData1[6] != 0x2b)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             WeightConst_RecFlag1 = 0x00;
 
-         } else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_digi() {
 
- //2E 44 30 2D 20 20 2D 33 36 30 30 30 39 09 
 
- //2E 44 30 2D 20 33 39 32 32 30 30 30 42 09 
 
- //2E 44 30 74 54 6F 74 61 6C 20 57 65 69 67 68 74 20 38 09 
 
-     if (WeightConst_RecWeightPoint1>140) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecFlag1 != 0xF0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x09 &&
 
-             WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-10] == 0x2D) //英展电子秤
 
-         {      
 
- 						WeightConst_WeightWS = 0;
 
- 						WeightConst_Weight_ZWS = 0;
 
-             WeightConst_WeightCurTem = 0;
 
-             WeightConst_WeightCurTemZF = 0;
 
- 						for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
- 								if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i] >= 0x30
 
- 												&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i]	<= 0x39) {
 
- 										WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
- 																							 + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
- 										WeightConst_Weight_ZWS++;
 
- 								} else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i] == 0x2D)  
 
- 									 WeightConst_WeightCurTemZF = 1;
 
- 						
 
- 						}
 
- 						if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
- 						setWeightSM();
 
- 						WeightConst_RecFlag1 = 0x00;
 
- 						WeightConst_Drop = 0; //开始抛弃数据
 
- 				}
 
- 				WeightConst_RecWeightPoint1 = 0; //指针还原
 
- 		} else {
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x09) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             WeightConst_RecFlag1 = 0x00;
 
-         } 
 
- 				else WeightConst_RecWeightPoint1++;
 
- 		}
 
- }
 
- static void P_AWT_ZM303() {
 
-     //展会   //20 20 20 20 20 31 37 34 20 6B 67 20 47 0D 0A
 
-     //3D 2D 30 30 30 30 36 34 28 6B 67 29 0D 0A
 
-     if (WeightConst_RecWeightPoint1>50) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 13 && WeightConst_RecWeightData1[0] == 0x3D) {
 
-                 //3D 2D 30 30 30 30 36 34 28 6B 67 29 0D 0A
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 2] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 2]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 2] - 0x30) 
 
- 															                     * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                 }
 
-                 if (WeightConst_RecWeightData1[1] == 0x2D)  WeightConst_WeightCurTemZF = 1;
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 0; //开始抛弃数据
 
-             }
 
-             else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-6]==0x20 &&
 
-                      WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-5]==0x6B ) {
 
-                 //20 20 20 20 20 31 37 34 20 6B 67 20 47 0D 0A
 
- 								//20 20 20 20 20 2D 31 38 20 6B 67 20 47 0D 0A
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 -12 + ReadWeight_i ] >= 0x30
 
-                             && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 -12 + ReadWeight_i ]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 -12 + ReadWeight_i ] - 0x30)
 
-                                                    * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                     else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 -12 + ReadWeight_i ] == 0x2D)
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 0; //开始抛弃数据
 
-             }
 
-             else if (WeightConst_RecWeightPoint1 == 43 && WeightConst_RecWeightData1[0] == 0x31) {
 
-                 //	31 2C 53 54 2C 20 20 20 20 20 20 20 2D 32 35 2C 20 20 20 20 20 20 20 20 20 20 20 30 2C 20 20 20 20 20 20 20 20 20 30 2C 6B 67 0D 0A
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 9] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 9]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 9] - 0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                     else if (WeightConst_RecWeightData1[ReadWeight_i + 9] == 0x2D)
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 0; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
- 				else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x09 &&
 
-             WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-10] == 0x2D) //英展电子秤
 
-         {      
 
- 						WeightConst_WeightWS = 0;
 
- 						WeightConst_Weight_ZWS = 0;
 
-             WeightConst_WeightCurTem = 0;
 
-             WeightConst_WeightCurTemZF = 0;
 
- 						for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
- 								if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i] >= 0x30
 
- 												&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i]	<= 0x39) {
 
- 										WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
- 																							 + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
- 										WeightConst_Weight_ZWS++;
 
- 								} else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 9 + ReadWeight_i] == 0x2D)  
 
- 									 WeightConst_WeightCurTemZF = 1;
 
- 						
 
- 						}
 
- 						if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
- 						setWeightSM();
 
- 						WeightConst_RecFlag1 = 0x00;
 
- 						WeightConst_Drop = 0; //开始抛弃数据
 
- 				} else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             WeightConst_RecFlag1 = 0x00;
 
-         } 
 
- 				else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x09 ) //英展电子秤
 
-         {      
 
- 						WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             WeightConst_RecFlag1 = 0x00;
 
- 				}
 
- 				else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_T_2000() {
 
- //    55 53 2C 47 53 20 20 20 20 32 2E 37 32 6B 67 0D 0A 2.72  不稳定
 
- //    53 54 2C 47 53 20 20 20 20 32 2E 34 33 6B 67 0D 0A 2.43  稳定
 
- //    55 53 2C 47 53 2D 20 20 20 30 2E 33 38 6B 67 0D 0A -0.38  不稳定
 
- //             77 6E 30 30 30 30 38 33 33 35 6B 67 0D 0A 
 
-     if (WeightConst_RecWeightPoint1>40) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A ||
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x0D) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 >= 12) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
- 							  if (WeightConst_RecWeightPoint1==12) {
 
- 									for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
- 											if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 9] >= 0x30
 
- 															&& WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 9]	<= 0x39) {
 
- 													WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
- 																										 + (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 9] - 0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
- 													WeightConst_Weight_ZWS++;
 
- 											} else if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 90] == 0x2E) {
 
- 													WeightConst_WeightWS = 5 - ReadWeight_i; //设置小数位数
 
- 													WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
- 											}
 
- 									}
 
- 								} else if (WeightConst_RecWeightPoint1>=13) {
 
- 									for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
- 											if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 10] >= 0x30
 
- 															&& WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 10]	<= 0x39) {
 
- 													WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
- 																										 + (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 10] - 0x30) * mypow(10, 6 - ReadWeight_i); //计算重量,无小数位的
 
- 													WeightConst_Weight_ZWS++;
 
- 											} else if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 10] == 0x2E) {
 
- 													WeightConst_WeightWS = 6 - ReadWeight_i; //设置小数位数
 
- 													WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
- 											}
 
- 									}
 
- 								}
 
-                 if (WeightConst_RecWeightData1[3] == 0x2D)
 
- 											WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 0; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_HF() {
 
- //    01 10 00 01 00 02 04 00 00 17 9C 3D FA 01 10 00 01 00 02 10 08
 
- //    02 10 00 01 00 02 04 08 00 00 A2 BE FE 02 10 00 01 00 02 10 3B
 
- //    03 10 00 01 00 02 04 08 00 00 A4 3A 00 03 10 00 01 00 02 10 3B
 
-     if (WeightConst_RecWeightPoint1>140) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecFlag1 != 0xF0) //上一条完整数据没有处理完
 
-     {
 
-         if ((WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]&0xf0) == 0x10 &&
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x02 &&
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-2] == 0x00 &&
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-3] == 0x01 &&
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-4] == 0x00 &&
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-5] == 0x10 &&
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-6] == XbeeConst_DeviceAddress) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-19] == XbeeConst_DeviceAddress)
 
-             {
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 WeightConst_WeightCurTem = ((WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-11]<<16)
 
-                                             |
 
-                                             (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-10]<<8)
 
-                                             |
 
-                                             WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-9]);
 
-                 if ((WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-12]&0x08) == 0x08)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 0; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- static void P_E_2000() {
 
- //    3D 30 30 30 30 31 30 30 0D 0A
 
- //    3D 2D 30 30 30 31 30 30 0D 0A
 
-     if (WeightConst_RecWeightPoint1>40) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0D) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 > 9) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)] >= 0x30
 
-                             && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)] - 0x30)
 
-                                                    * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                 }
 
-                 if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-7] == 0x2D)
 
-                 {
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                     WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             WeightConst_RecFlag1 = 0x00;
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x53 &&
 
-                  WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x47 &&
 
-                  WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-2] == 0x2C) {
 
-             WeightConst_RecWeightData1[0] = 0x2C;
 
-             WeightConst_RecWeightData1[1] = 0x47;
 
-             WeightConst_RecWeightData1[2] = 0x53;
 
-             WeightConst_RecWeightPoint1 = 2; //指针还原
 
-             WeightConst_RecFlag1 = 0x00;
 
-             WeightConst_Drop = 0;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_TMI_II() {
 
-     //23 03 BD 18 00 2D 34 37 39 38 0A 00 0D 00 00 00 00 00 00 00 00 00 00 00 AF BA 04    -   4  7  9  8   //波特率19200
 
-     //23 03 02 18 00 20 2D 31 38 32 0A 00 0D 00 00 00 00 00 00 00 00 00 00 00 7D FE 04
 
-     //23 03 03 18 00 20 2D 31 38 32 0A 00 0D 00 00 00 00 00 00 00 00 00	00 00 D4 A3 04
 
-     //23 03 04 18 00 20 2D 31 38 32 0A 00 0D 00 00 00 00 00 00 00 00 00 00 00 92 03 04           -182
 
-     WeightConst_RecWeightPoint1++;
 
-     if (WeightConst_RecWeightPoint1>53) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightPoint1>=1 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x03 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]==0x23) {
 
-         WeightConst_RecWeightData1[0] = 0x23;
 
-         WeightConst_RecWeightData1[1] = 0x03;
 
-         WeightConst_RecWeightPoint1 = 1; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x04 ||
 
-                 WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x00) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1 == 26 && WeightConst_RecWeightData1[0] == 0x23 && WeightConst_RecWeightData1[1] == 0x03
 
-                     && WeightConst_RecWeightData1[10] == 0x0A) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 5] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 5]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 5] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     } else if (WeightConst_RecWeightData1[ReadWeight_i + 5] == 0x2D) {
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                     }
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-         }
 
-     }
 
-     /*
 
-     else
 
-     	{
 
-     		if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x04 || WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x00) //英展电子秤
 
-     		{
 
-     			WeightConst_Drop = 0;
 
-     			WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     		} else {
 
-     			WeightConst_Drop++;
 
-     			WeightConst_RecWeightPoint1++;
 
-     		}
 
-     	}*/
 
- }
 
- static void P_TMI_III() {
 
-     //0x20 0x2d 0x31 0x34 0x32 0x0d  -142
 
-     //2D 33 36 35 34 0D
 
-     
 
-     if (WeightConst_RecWeightPoint1>17) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0D) //英展电子秤
 
-         {
 
-             if (WeightConst_RecWeightPoint1>10 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x29 &&
 
-                     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-4] == 0x28 )
 
-             {   //3D 30 30 30 30 30 30 36 28 6B 67 29 0D 0A
 
-                 //3D 2D 30 30 30 30 36 34 28 6B 67 29 0D 0A
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(9-ReadWeight_i)] >= 0x30
 
-                             && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(9-ReadWeight_i)]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(9-ReadWeight_i)] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     };
 
-                 }
 
-                 if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-11] == 0x2D && WeightConst_WeightCurTemZF==0)
 
-                 {
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                     WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             /*else if (WeightConst_RecWeightPoint1>10 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x67 &&
 
-             WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-2] == 0x6B )
 
-             {
 
-             	  //77 6E 2D 30 30 30 30 30 35 31 6B 67 0D 0A
 
-             WeightConst_WeightCurTem = 0;
 
-             WeightConst_WeightCurTemZF = 0;
 
-             WeightConst_WeightWS = 0;
 
-             WeightConst_Weight_ZWS = 0;
 
-             for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
-             if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(7-ReadWeight_i)] >= 0x30
 
-                 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(7-ReadWeight_i)]	<= 0x39) {
 
-             WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                        + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(7-ReadWeight_i)] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
-             WeightConst_Weight_ZWS++;
 
-             };
 
-             }
 
-             if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-10] == 0x2D && WeightConst_WeightCurTemZF==0)
 
-             {
 
-             WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-             WeightConst_WeightCurTemZF = 1;
 
-             }
 
-             setWeightSM();
 
-             WeightConst_RecFlag1 = 0x00;
 
-             WeightConst_Drop = 1; //开始抛弃数据
 
-             }*/
 
-             else if (WeightConst_RecWeightPoint1>4 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] != 0x20) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)] >= 0x30
 
-                             && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                     else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-(5-ReadWeight_i)] == 0x2D)
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 if (WeightConst_RecWeightPoint1>6 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-7] == 0x2D && WeightConst_WeightCurTemZF==0)
 
-                 {
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                     WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         } else {
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0D) //英展电子秤
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x20 ||
 
-                  WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x30 ||
 
-                  WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x3D ||
 
-                  WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x2D)
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_EZ4300() {
 
-     //82 2D A0 A0 A0 B1 39 8D   库恩表头出来是7位数据,8位是校验位,将数据的高位去掉,则得到下面正确的数据
 
-     //02 2D 20 20 20 31 39 0D
 
-     if (WeightConst_RecWeightPoint1>10) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1) & 0x7F;
 
-         
 
- 			if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x02)
 
-         {
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-             WeightConst_Drop = 0;
 
-         }
 
- 				
 
- 				else if (WeightConst_RecWeightPoint1 >= 7 && WeightConst_RecWeightData1[0] == 0x02 && WeightConst_RecWeightData1[6] != 0x20) {
 
- 						WeightConst_WeightCurTem = 0;
 
- 						WeightConst_WeightWS = 0;
 
- 						WeightConst_Weight_ZWS = 0;
 
- 						for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
- 								if (WeightConst_RecWeightData1[ReadWeight_i + 2] >= 0x30
 
- 												&& WeightConst_RecWeightData1[ReadWeight_i + 2]	<= 0x39) {
 
- 										WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
- 																							 + (WeightConst_RecWeightData1[ReadWeight_i + 2] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
- 										WeightConst_Weight_ZWS++;
 
- 								}
 
- 								WeightConst_WeightWS = 0;
 
- 						}
 
- 						if (WeightConst_RecWeightData1[1] == 0x2D)	WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
- 						setWeightSM();
 
- 						WeightConst_RecFlag1 = 0x00;
 
- 						WeightConst_Drop = 0; //开始抛弃数据
 
- 						WeightConst_RecWeightPoint1 = 0; //指针还原
 
- 				}
 
- 				else WeightConst_RecWeightPoint1++;						
 
-         
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1)& 0x7F;
 
-         if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0D)
 
-         {
 
-             WeightConst_Drop = 0;
 
-             WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         }
 
-         else if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x02)
 
-         {
 
-             WeightConst_RecWeightData1[0] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1];
 
-             WeightConst_RecWeightPoint1 = 1;
 
-             WeightConst_RecFlag1 = 0x00;
 
-             WeightConst_Drop = 0;
 
-         }
 
-         else {
 
-             WeightConst_Drop++;
 
-             WeightConst_RecWeightPoint1++;
 
-         }
 
-     }
 
- }
 
- static void P_TQ() {
 
- //	7E 7E F0 10 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AB FE
 
- //  7E 7E F0 10 00 00 00 00 00 00 00 03 04 00 00 00 00 00 03 04 F2 FE
 
- //  7E 7E F0 10 01 00 00 00 00 00 00 06 08 80 00 00 00 00 06 08 63 FE
 
- //  7E 7E FF 10 01 00 00 00 00 00 00 06 08 80 00 00 00 00 06 08 54 FE
 
-     if (WeightConst_RecWeightPoint1>43) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightPoint1>=1 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x7E && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]==0x7E) {
 
-         WeightConst_RecWeightData1[0] = 0x7E;
 
-         WeightConst_RecWeightData1[1] = 0x7E;
 
-         WeightConst_RecWeightPoint1 = 1; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<44) {
 
-             if (WeightConst_RecWeightPoint1 >= 21 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-21]==0x7E
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-20]==0x7E
 
-                     && (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-19]==0xF0 || WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-19]==0xFF)
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-17]!=0x55) {
 
-                 WeightConst_RecWeight_he2 = 0;
 
-                 WeightConst_RecWeight_he1 = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]
 
-                                             + WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] * 256;  //判断接收到的重量协议是否正确
 
-                 for(int i=0; i<18; i++)  WeightConst_RecWeight_he2 += WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-2-i];
 
-                 WeightConst_RecWeight_he2 = ~WeightConst_RecWeight_he2+1;
 
-                 if (WeightConst_RecWeight_he1==WeightConst_RecWeight_he2)
 
-                 {
 
-                     WeightConst_WeightCurTem = 0;
 
-                     WeightConst_WeightWS = 0;
 
-                     WeightConst_Weight_ZWS = 0;
 
-                     for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                         if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 7] <= 0x09) {
 
-                             WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                        + (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 7]) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                             WeightConst_Weight_ZWS++;
 
-                         }
 
-                     }
 
-                     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-8] == 0x80)
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                     WeightConst_WeightWS = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1 - 16]; //设置小数位数
 
-                     setWeightSM();
 
-                 }
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             } else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- static void P_XL10000() {
 
- //	02 2A 30 20 30 30 30 32 32 30 30 30 30 30 30 30 0D 33
 
-     if (WeightConst_RecWeightPoint1>38) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] & 0x7F;
 
-     if (WeightConst_RecWeightPoint1>=3 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x02 ) {
 
-         WeightConst_RecWeightData1[0] = 0x02;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<38) {
 
-             if (WeightConst_RecWeightPoint1 >= 17	&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-17]==0x02
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]==0x0D)
 
-             {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 4] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 4]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 4] - 0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                 }
 
-                 if ((WeightConst_RecWeightData1[2] & 0x02) == 0x02)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 WeightConst_WeightWS = 0; //设置小数位数
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             } else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- static void XK3190_A27E() {
 
- //	77 6E 30 30 30 30 30 36 31 35 6B 67 0D 0A   615  boudrate=1200
 
- //  77 6E 2D 30 30 30 30 30 36 35 6B 67 0D 0A   -65
 
-     //  77 6E 2D 30 30 30 31 32 20 6B 67 0D 0A
 
-     //  77 6E 30 30 30 30 31 2E 32 6B 67 0D 0A
 
-     if (WeightConst_RecWeightPoint1>37) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if ((WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]==0x77 &&
 
-             WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x6E) ||
 
-                 (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]==0x77 &&
 
-             WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x77))		{
 
-         WeightConst_RecWeightData1[0] = 0x77;
 
-         WeightConst_RecWeightData1[1] = 0x6E;
 
-         WeightConst_RecWeightPoint1 = 1; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<15) {
 
-             if (WeightConst_RecWeightPoint1 >= 12
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1]==0x0D
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x0A) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 if (WeightConst_RecWeightPoint1 == 13)
 
-                 {
 
-                     for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
-                         if (WeightConst_RecWeightData1[ReadWeight_i+3] >= 0x30
 
-                                 && WeightConst_RecWeightData1[ReadWeight_i+3]	<= 0x39) {
 
-                             WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                        + (WeightConst_RecWeightData1[ReadWeight_i+3] - 0x30) * mypow(10, 6 - ReadWeight_i); //计算重量,无小数位的
 
-                             WeightConst_Weight_ZWS++;
 
-                         } else if (WeightConst_RecWeightData1[ReadWeight_i + 3] == 0x2E) {
 
-                             WeightConst_WeightWS = 6 - ReadWeight_i; //设置小数位数
 
-                             WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
-                         }
 
-                     }
 
-                 }
 
-                 else if(WeightConst_RecWeightPoint1 == 12)
 
-                 {
 
-                     for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) {
 
-                         if (WeightConst_RecWeightData1[ReadWeight_i+3] >= 0x30
 
-                                 && WeightConst_RecWeightData1[ReadWeight_i+3]	<= 0x39) {
 
-                             WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                        + (WeightConst_RecWeightData1[ReadWeight_i+3] - 0x30) * mypow(10, 4 - ReadWeight_i); //计算重量,无小数位的
 
-                             WeightConst_Weight_ZWS++;
 
-                         } else if (WeightConst_RecWeightData1[ReadWeight_i + 2] == 0x2E) {
 
-                             WeightConst_WeightWS = 6 - ReadWeight_i; //设置小数位数
 
-                             WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
-                         }
 
-                     }
 
-                     //if (WeightConst_WeightWS == 0) WeightConst_WeightCurTem = WeightConst_WeightCurTem / 10;
 
-                 }
 
-                 if (WeightConst_RecWeightData1[2] == 0x2D)
 
-                     WeightConst_WeightCurTemZF = 1;
 
-                 else WeightConst_WeightCurTemZF = 0;
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 //WeightConst_WeightWS = 0; //设置小数位数
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             } else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- static void P_NEWLabel() {
 
- //	57 20 FC 01 29 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 C4 00 88 00 80 00 00 00 00 00 08 40 44 8C 00
 
-     //  20 20 20 20 20 20 20 4E 45 54 20 57 45 49 47 48 54 20 20 20 20 20 20 20 54 4F 54 41 4C 20 57 45 49 47
 
-     //  48 54 3A 20 20 20 20 20 20 20 20 31 35 20 58 80 5C
 
-     //4F 54 41 4C 20 57 45 49 47 48 54 3A 20 20 20 20 20 20 20 20 31 35 20
 
-     // 16 17 18 19 20 21
 
- //波特率  115200
 
-     WeightConst_RecWeightPoint1++;
 
-     if (WeightConst_RecWeightPoint1>60) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x4F) {
 
-         WeightConst_RecWeightData1[0] = 0x4F;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         //	if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x74
 
-         //	&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x68
 
-         //		&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-2] == 0x67) //英展电子秤
 
-         {
 
-             //C9 74 2D 35 38 31 30 80 00 00 54 6F 74 61 6C 20 77 65 69 67 68 74
 
-             //	if (WeightConst_RecWeightPoint1 == 22 && WeightConst_RecWeightData1[0] == 0xC9 && WeightConst_RecWeightData1[22] == 0x74) {
 
-             //		if (WeightConst_RecWeightPoint1 == 6 && WeightConst_RecWeightData1[0] == 0x02) {
 
-             if (WeightConst_RecWeightPoint1 == 21 && WeightConst_RecWeightData1[0] == 0x4F  && WeightConst_RecWeightData1[1] == 0x54 && WeightConst_RecWeightData1[2] == 0x41) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 7; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 16] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 16]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 16] - 0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     } else if (WeightConst_RecWeightData1[ReadWeight_i + 16] == 0x2D) {
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                     }
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-         }
 
-     }
 
- }
 
- static void P_PTM() {
 
- //	02 30 30 54 4F 54 41 4C 20 57 45 49 47 48 54 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4B 67 20 20 20 20 20 38 54 20 80 81 81 38 3E 03
 
- //波特率  38400
 
-     WeightConst_RecWeightPoint1++;
 
-     if (WeightConst_RecWeightPoint1>68) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x02) {
 
-         WeightConst_RecWeightData1[0] = 0x02;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         //	if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x74
 
-         //	&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-1] == 0x68
 
-         //		&& WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-2] == 0x67) //英展电子秤
 
-         {
 
-             //C9 74 2D 35 38 31 30 80 00 00 54 6F 74 61 6C 20 77 65 69 67 68 74
 
-             //	if (WeightConst_RecWeightPoint1 == 22 && WeightConst_RecWeightData1[0] == 0xC9 && WeightConst_RecWeightData1[22] == 0x74) {
 
-             //		if (WeightConst_RecWeightPoint1 == 6 && WeightConst_RecWeightData1[0] == 0x02) {
 
-             if (WeightConst_RecWeightPoint1 == 48 && WeightConst_RecWeightData1[0] == 0x02 && WeightConst_RecWeightData1[48] == 0x03) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 35] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 35]	<= 0x39) {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + 35] - 0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     } else if (WeightConst_RecWeightData1[ReadWeight_i + 35] == 0x2D) {
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                     }
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF==1) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-             }
 
-         }
 
-     }
 
- }
 
- static void P_XDNZ_BC02() {
 
- //	02 22 32 20 30 30 30 30 30 33 30 30 30 30 30 30 0D   -3
 
- //  02 22 30 20 30 30 30 30 34 38 30 30 30 30 30 30 0D   48
 
- //  02 22 30 20 30 30 30 30 36 34 30 30 30 30 30 30 0D   64
 
-     if (WeightConst_RecWeightPoint1>33) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] & 0x7F;
 
-     if (WeightConst_RecWeightPoint1>=1 && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x02) {
 
-         WeightConst_RecWeightData1[0] = 0x02;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<34) {
 
-             if (WeightConst_RecWeightPoint1 >= 16
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-16]==0x02
 
-                     && (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-14]==0x30
 
-                         || WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-14]==0x32)
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x0D) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 //  02 22 30 20 30 30 30 30 34 38 30 30 30 30 30 30 0D   48
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 12] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 12] <= 0x39)
 
-                     {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 12] -0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                 }
 
-                 if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-14] == 0x32)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 WeightConst_WeightWS = 0; //设置小数位数
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
- 								
 
-             }else if (WeightConst_RecWeightPoint1 >= 7  
 
-    
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-7]==0x02
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x04){
 
- 								WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
- 								WeightConst_WeightCurTemZF=0;
 
- //1B 4F 6D 30 32 02 2D 31 33 32 30 36 04 1B 4F 61 40 40 41 40 40 45 04 1B 4F 75 30 36 04 1A 04
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + 1] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + 1] <= 0x39)
 
-                     {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i +1] -0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }else if (WeightConst_RecWeightData1[ReadWeight_i + 1] == 0x2D)
 
- 										{
 
- 											WeightConst_WeightCurTemZF=1;                        
 
- 										};
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF>0) WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 WeightConst_WeightWS = 0; //设置小数位数
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原	
 
- 							
 
- 						}
 
- 						else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- static void P_ID511() {
 
- //	02 3A 50 70 30 30 30 30 30 35 30 30 30 30 30 30 0D
 
- //  02 22 30 20 30 30 30 30 34 38 30 30 30 30 30 30 0D
 
-     if (WeightConst_RecWeightPoint1>33) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x02) {
 
-         WeightConst_RecWeightData1[0] = 0x02;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<34) {
 
-             if (WeightConst_RecWeightPoint1 >= 16
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-16]==0x02
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x0D) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 //  02 3A 50 70 30 30 30 30 30 35 30 30 30 30 30 30 0D
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 12] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 12] <= 0x39)
 
-                     {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 12] -0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                 }
 
-                 //if ((WeightConst_RecWeightData1[2] & 0x02)>0)
 
-                 //    WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 if (WeightConst_RecWeightData1[2] ==0x62)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 WeightConst_WeightWS = 0; //设置小数位数
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             } else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- static void P_AD250() {
 
- //	C9 20 20 20 20 33 38 3B 34 D9   38
 
- //  C9 20 20 C4 31 32 38 36 38 D9   -128
 
- //  C9 30 20 20 31 33 32 3C 3F D9   132
 
-     if (WeightConst_RecWeightPoint1>33) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0xC9) {
 
-         WeightConst_RecWeightData1[0] = 0xC9;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<34) {
 
-             if (WeightConst_RecWeightPoint1 >= 9
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1-9]==0xC9
 
-                     && WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0xD9) {
 
-                 WeightConst_WeightCurTem = 0;
 
-                 WeightConst_WeightWS = 0;
 
-                 WeightConst_Weight_ZWS = 0;
 
-                 WeightConst_WeightCurTemZF = 0;
 
-                 //  C9 54 20 20 20 20 30 3C 3D D9
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 6; ReadWeight_i++) {
 
-                     if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 8] >= 0x30
 
-                             && WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 8] <= 0x39)
 
-                     {
 
-                         WeightConst_WeightCurTem = WeightConst_WeightCurTem
 
-                                                    + (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 8] -0x30) * mypow(10, 5 - ReadWeight_i); //计算重量,无小数位的
 
-                         WeightConst_Weight_ZWS++;
 
-                     }
 
-                     else if (WeightConst_RecWeightData1[ReadWeight_i + WeightConst_RecWeightPoint1 - 8] == 0xC4)
 
-                         WeightConst_WeightCurTemZF = 1;
 
-                 }
 
-                 if (WeightConst_WeightCurTemZF)
 
-                     WeightConst_WeightCurTem = WeightConst_WeightCurTem * -1;
 
-                 WeightConst_WeightWS = 0; //设置小数位数
 
-                 setWeightSM();
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             } else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- extern unsigned char eid[10];
 
- unsigned long long curEID = 0;      //当前临时耳标
 
- unsigned long long lastEID = 0;      //上次临时耳标
 
- static void ReadEID() {
 
- 	
 
-  // 02 03 00 16 00 0a 24 3a  
 
-  // 02 03 14 ff 57 83 e7 00 6b 96 1d 5d 00 ff 10 43 e6 1c be 99 1a 15 df 5d 31
 
- 	
 
-     if (WeightConst_RecWeightPoint1>33) WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] = rb_remove(rb_usart1);
 
-     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1]==0x02) {
 
-         WeightConst_RecWeightData1[0] = 0x02;
 
-         WeightConst_RecWeightPoint1 = 0; //指针还原
 
-         WeightConst_RecFlag1 = 0x00;
 
-         WeightConst_Drop = 0;
 
-     }
 
-     if (WeightConst_RecFlag1 != 0xF0 && WeightConst_Drop==0) //上一条完整数据没有处理完
 
-     {
 
-         if (WeightConst_RecWeightPoint1<34) {
 
-             if (WeightConst_RecWeightPoint1 >= 3 
 
-                     && (WeightConst_RecWeightPoint1 >= WeightConst_RecWeightData1[2]+2)) {
 
-                  // 02 03 14 ff 57 83 e7 00 6b 96 1d 5d 00 ff 10 43 e6 1c be 99 1a 15 df 5d 31
 
- 								eid[0]=5;
 
- 											
 
-                 for (int ReadWeight_i = 0; ReadWeight_i < 5; ReadWeight_i++) 
 
-                    eid[ReadWeight_i+1] = WeightConst_RecWeightData1[ReadWeight_i+7];
 
- 											
 
-                 eid[eid[0]+1]= WeightConst_RecWeightData1[3];
 
- 							  eid[eid[0]+2]= WeightConst_RecWeightData1[4];				
 
- 							//	eid[1]=0x00;eid[2]=0x0C;eid[3]=0x12;eid[4]=0x63;eid[5]=0xE0;
 
- 								if (eid[eid[0]+1] ==0xFF){
 
- 									WeightConst_feed[0]=0xCE;
 
- 									WeightConst_feed[1]=0xDE;
 
- 									WeightConst_feed[2]=0xB6;
 
- 									WeightConst_feed[3]=0xFA;
 
- 									WeightConst_feed[4]=0xB1;
 
- 									WeightConst_feed[5]=0xEA;
 
- 									WeightConst_feed[6]=0x20;
 
- 									WeightConst_feed[7]=0x20;
 
- 								}
 
- 								else
 
- 								{
 
- 									curEID = 0;
 
- 									for (int i = 0; i < eid[0]; i++) {
 
- 										curEID = curEID << 8;										
 
- 										curEID = curEID | eid[i+1];										  
 
- 									}
 
- 									if (WeightConst_WeightCur>30 && lastEID != curEID)
 
- 									{	
 
- 										sendEIDWeight(eid, WeightConst_WeightCur);
 
- 									  lastEID = curEID;
 
- 									}
 
- 									rt_memset(WeightConst_feed, 0x20, 40);
 
- 									for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++) {
 
- 										if (SendDisplay_i>0)	curEID=curEID/10;
 
- 										if (abs(curEID)>0)	WeightConst_feed[7-SendDisplay_i] = abs(curEID%10)+'0';
 
- 										else break;
 
- 						      }									
 
- 								}
 
- 								
 
-                 WeightConst_RecFlag1 = 0x00;
 
-                 WeightConst_Drop = 1; //开始抛弃数据
 
-                 WeightConst_RecWeightPoint1 = 0; //指针还原
 
-             } else
 
-                 WeightConst_RecWeightPoint1++;
 
-         }
 
-         else WeightConst_RecWeightPoint1 = 0; //指针还原
 
-     }
 
-     else
 
-     {
 
-         WeightConst_RecWeightPoint1++;
 
-     }
 
- }
 
- void ReadWeight(void)
 
- {
 
- 	  rt_sem_take(display_lock, RT_WAITING_FOREVER);
 
- 		if (WeightConst_TQ==0)
 
- 				P_XDNZ_BC02();
 
- 		else if (WeightConst_TQ==1)
 
- 				//P_300G0();
 
- 				 P_XDNZ_BC02();
 
- 				//P_NEWLabel();
 
- 		else if (WeightConst_TQ==2)
 
- 				//P_300G1();
 
- 				P_AWT_ZM303();
 
- 		else if (WeightConst_TQ==3)
 
- 				XK3190_A27E();
 
- 		else if (WeightConst_TQ==4)
 
- 				P_TMI_II();
 
- 		else if (WeightConst_TQ==5)
 
- 				P_TMI_III();
 
- 		else if (WeightConst_TQ==6)
 
- 				P_EZ4300();
 
- 		else if (WeightConst_TQ==7)
 
- 				//P_TQ();
 
- 				P_AD250();
 
- 		else if (WeightConst_TQ==8)
 
- 				P_PTM();
 
- 		else if (WeightConst_TQ==9)
 
- 				 P_T_2000();
 
- 				//P_HF();
 
- 		else if (WeightConst_TQ==10)
 
- 				P_XL10000();
 
- 		else if (WeightConst_TQ==11)
 
- 				P_XK3190_C8();
 
- 		else if (WeightConst_TQ==12)
 
- 				P_TDI200I();
 
- 		//P_E_2000();
 
- 		else if (WeightConst_TQ==13)
 
- 				P_ID511();
 
- 		else  if (WeightConst_TQ==14) {
 
- 			 if (iscowweight==1) {
 
- 			   ReadEID();
 
- 			 }
 
- 			 else {
 
- 				 while (rb_full_count(rb_usart1) > 0) {
 
- 						rb_remove(rb_usart1);
 
- 					 }	
 
- 			 }	  
 
- 		}
 
- 		rt_sem_release(display_lock);
 
- }
 
- uint16_t tempWeight;
 
- uint16_t tempWeighttime = 0;
 
- void ReadWeightthread(void) {
 
- 	  
 
- 		while(1)
 
- 		{			  
 
- 				if (WeightConst_TQ==14 );// && CanButton== 0x01);
 
- 				{
 
- 									
 
- 						tempWeight = get_weight();	
 
- 					
 
- 					  rt_sem_take(display_lock, RT_WAITING_FOREVER);
 
-            
 
- 					  if (nag)	WeightConst_WeightCurTem = (signed long)(tempWeight*-1);
 
- 					  else WeightConst_WeightCurTem = (signed long)(tempWeight);
 
- 						WeightConst_WeightWS = ad_Point;
 
- 						setWeightSM();	
 
- 						rt_sem_release(display_lock);
 
- 				}
 
- 			  
 
- 				rt_thread_mdelay(125);
 
- 		}
 
- }
 
- union timekeyweight_t getTimeWeight(int i) {
 
-     if ((i==0xF1) && (WeightConst_WeightOK > -32768)) {
 
-         WeightConst_WeightLast = WeightConst_WeightOK;  //保存按键时的重量
 
-         WeightConst_WeightOK = 0;
 
-     }
 
-     else {
 
- 				rt_sem_take(weight_lock, RT_WAITING_FOREVER);
 
-         WeightConst_WeightLast = WeightConst_WeightCur;  //保存按键时的重量
 
- 				rt_sem_release(weight_lock);
 
-     }
 
- 		union timekeyweight_t timekeyweight;
 
- 		rt_sem_take(setTIME_lock, RT_WAITING_FOREVER);
 
- 		timekeyweight.data.datetime.year = TimeConst.data.year;
 
- 		timekeyweight.data.datetime.month = TimeConst.data.month;
 
- 		timekeyweight.data.datetime.date = TimeConst.data.date;
 
- 		timekeyweight.data.datetime.hh = TimeConst.data.hh;
 
- 		timekeyweight.data.datetime.mm = TimeConst.data.mm;
 
- 		timekeyweight.data.datetime.ss = TimeConst.data.ss;
 
- 		rt_sem_release(setTIME_lock);
 
- 		timekeyweight.data.WeightBegin = WeightConst_WeightBegin;
 
- 		timekeyweight.data.WeightLast = WeightConst_WeightLast;
 
- 	  timekeyweight.data.WeightWS = WeightConst_WeightWS;
 
- 		timekeyweight.data.WeightZF =  0;		
 
- 		timekeyweight.data.reserved =  0;
 
- 		timekeyweight.data.WeightRun = 1;
 
- //    if (WeightConst_WeightLast < 0)
 
- //        s[8] = (0<<7) | (WeightConst_WeightWS<<6>>1);
 
- //    else
 
- //        s[8] = (0<<7) | (WeightConst_WeightWS<<6>>1);
 
-       return timekeyweight;
 
- }
 
- static rt_thread_t checkweight_tid = RT_NULL;
 
- static rt_thread_t readweight_tid = RT_NULL;
 
- void ReadWeight_thread(void)
 
- {	
 
- 	  if (WeightConst_TQ==14 )
 
- 		{
 
- 				readweight_tid = rt_thread_create("ReadWeight",
 
- 																ReadWeightthread, RT_NULL,
 
- 																0x800,
 
- 																4, 5);
 
- 		/* 如果获得线程控制块,启动这个线程 */
 
- 				if (readweight_tid != RT_NULL) rt_thread_startup(readweight_tid);
 
- 		}
 
- }
 
- void CheckWeight_thread(void)
 
- {	
 
- 		checkweight_tid = rt_thread_create("CheckWeight",
 
-                             CheckWeightthread, RT_NULL,
 
-                             0x400,
 
-                             4, 5);
 
- 		/* 如果获得线程控制块,启动这个线程 */
 
- 		if (checkweight_tid != RT_NULL) rt_thread_startup(checkweight_tid);  	
 
- }
 
- void ReadEIDthread(void) {
 
-     while (1) {			
 
- 			rt_sem_take(uart1_lock, RT_WAITING_FOREVER);
 
- 		//	02 03 00 16 00 05 64 3E  
 
- 		//	02 03 00 16 00 0a 24 3a
 
- 			usart1_send_data[0] = 0x02;		
 
- 			usart1_send_data[1] = 0x03;
 
- 			usart1_send_data[2] = 0x00;
 
- 			usart1_send_data[3] = 0x16;
 
- 			usart1_send_data[4] = 0x00;
 
- 			usart1_send_data[5] = 0x05;
 
- 			usart1_send_data[6] = 0x64;	
 
- 			usart1_send_data[7] = 0x3e;				
 
- 			HAL_UART_Transmit_DMA(&huart1, usart1_send_data, 8); //remoteSerial
 
- 			rt_thread_mdelay(50);
 
- 			rt_sem_release(uart1_lock);
 
- 		
 
- 			rt_thread_mdelay(1000);
 
-     }
 
- }
 
- static rt_thread_t readEID_tid = RT_NULL;
 
- void ReadEID_thread(void)
 
- {	
 
- 	extern unsigned char  iscowweight;
 
- 	  if (iscowweight==1 )
 
- 		{
 
- 				readEID_tid = rt_thread_create("ReadEID",
 
- 																ReadEIDthread, RT_NULL,
 
- 																0x200,
 
- 																4, 5);
 
- 		/* 如果获得线程控制块,启动这个线程 */
 
- 				if (readEID_tid != RT_NULL) rt_thread_startup(readEID_tid);
 
- 		}
 
- }
 
 
  |