【正文】
,1)。//16進制字符串轉(zhuǎn)換成字符串function HexStrToStr(const S:string):string。begint:=1。039。A39。a39。 if (t+1Length(S))or(not (S[t+1] in [39。,39。,39。])) then ts:=39。+S[t]+S[t+1]。end。 begin {source在S中出現(xiàn)的位置} site:=pos(source,s)。 {返回新串} replacing:=s。const GENP=$A001。procedure CalOneByte(AByte:Byte)。 //取出最低位 crc:=crc shr 1。 end。 Result:=crc。 i,j,Count:Integer。begin szData:=Trimplace(vStr1)。 for j:=0 to Count1 do begin if (i mod 2)=0 then //每2個字符放入一個字節(jié)中 i:=i+1。+copy(szData,i,2))。 Res:=CalCRC16(Data,Low(Data),Count1)。+LeftStr(ResStr,2)。 if 0 then begin try :=0。 //設(shè)置串口的當(dāng)前波特率 。++39。++39。串口狀態(tài):39。 //showmessage(inttostr())。 //設(shè)置串口的當(dāng)前波特率 :=。 if =39。None(無)39。 then :=Odd。 if =39。639。 then :=_7。 //設(shè)置數(shù)據(jù)位 if =39。39。 then :=_2。狀態(tài):39。狀態(tài):39。 //:=inttoStr()。begin 。串口已停止捕獲39。end。begin viewstring:=39。 for i:=1 to high(sbuf) do begin if not (sbuf[i],1) then begin mflg:=false。 viewstring:=viewstring+inttohex(sbuf[i],2)+39。,mterror,[mbyes],0)。+viewstring。)。 i,j,k:integer。 then begin str11:=Trimplace(SqrStr)。 //重新設(shè)定發(fā)送數(shù)組范圍 //showmessage(inttostr(high(sbuf)))。39。$39。 sbuf[1]:=byte($01)。 sbuf[5]:=byte($00)。 end。 Buffer: Pointer。 i:integer。begin str1:=Buffer。139。339。 for i:=10 to 15 do s[i]:=chr(55+i)。 string1:=string1+s[n div 16]+s[n mod 16]+ 39。 + s[n div 16]+s[n mod 16] )。狀態(tài):已停止過濾39。)。,39。81 33 00 00 09 80 33 00 00 08 39。 } end。接收39。39。 for i:=1 to 16 do begin if Tmr_Qry_Str[i]=39。39。 end。end。end。end。//查詢狀態(tài)函數(shù)function Return_Sta_Sting(SqrStr:string):String。 //計算CRC16校驗碼 End_Sqr_Str:=SqrStr +39。 //發(fā)送查詢指令 Result:=End_Sqr_Str end end。 //循環(huán)用整數(shù)變量Tmr_Qry_Str1:string。 //查詢字符串 Ad_id:=StrToInt(39。 //為狀態(tài)查詢字符串?dāng)?shù)組賦值 Return_Sta_Sting(Tmr_Qry_Str1)。 if (Tmr_Rtn_Str139。) and (round(length(Tmr_Rtn_Str1)/2)=15) then begin :=Tmr_Rtn_Str1。 //當(dāng)前溫度 :=。$39。 :=IntToStr(trunc(StrToInt(39。 if StrToInt(39。 :=39。 :=39。$39。 end else begin :=true。 end。//=================================開關(guān)按鈕=====================================procedure (Sender: TObject)。01 06 00 04 00 0039。 //查詢字符串地址碼 for i:=1 to 16 do begin if i=Ad_id then begin if =39。 //關(guān)閉 Btn_Qry_Str[i]:=Btn_Qry_Str1。 :=39。 //功能碼 :=39。 //數(shù)據(jù)(關(guān)閉) :=Btn_Qry_Str1。 :=Return_Sta_Sting(Btn_Qry_Str1)。0139。000439。 end。//=================================模式按鈕=====================================procedure (Sender: TObject)。 then begin Btn_Qry_Str1:=39。0139。000239。0039。 :=39。 //功能碼 :=39。 //數(shù)據(jù)(睡眠) :=39。//=================================調(diào)溫按鈕=====================================procedure (Sender: TObject)。0639。 :=intToHex((strtoint())*10,4)。end。 //地址碼 :=39。 //寄存器地址 if strtoint()10 then begin :=inttostr(strtoint()1)。 end。end。procedure (Sender: TObj