串口接收程序.docx
VERSION5.00Object="648A5603-2C6E-101B-82B6-000000000014#l.l#0""MSCOMM32.OCX"Object="5E9E78A0-531B-llCF-91F6-C2863C385E30#1.0#0""MSFLXGRD.OCX"BeginVB.FormFormlCaption=”西安亚川电力科技有限公司火灾报警器调试”CIientHeight=9660CIientLeft=60CIientTop=510CIientWidth=11625LinkTopic="Forml"ScaIeHeight=9660ScaIeWidth=11625StartUpPosition=3,窗口缺省BeginVB.FrameFrame8Caption=”校验上限”Height=975Left=240Tabindex=74Top=8520Width=11175BeginVB-CommandButtonCommand35Caption=”校验C相电流”Height=380Left=9840Tabindex=82Top=360Width=1125EndBeginVB-CommandButtonCommand34Caption="校验漏电流”Height=380Left=240Tabindex=81Top=360Width=1125EndBeginVB-CommandButtonCommand33Caption=”校验1路温度”Height=380Left=1600Tabindex=80Top=360Width=1125BeginVB-CommandButtonCommand32Caption="校验2路温度”Height=380LeftTabindexTopWidthEnd=2950=79=360=1125BeginVB-CommandButtonCommand31Caption="校验3路温度”Height=380LeftTabindexTopWidthEnd=4300=78=360=1125BeginVB-CommandButtonCommand30Caption="校验4路温度”Height=380LeftTabindexTopWidthEnd=5650=77=360=1125BeginVB-CommandButtonCommand29Caption="校验A相电流,HeightLeftTabindexTopWidthEnd=380=7060=76=360=1125BeginVB-CommandButtonCommand28Caption="校验B相电流”HeightLeftTabindexTopWidthEndEnd=380=8480=75=360=1125BeginVB-CommandButtonCommand27Caption="校验C相电流”Height=380Left=IOlOOTabindex=73Top=7680Width=1125EndBeginVB.FrameFrame7Caption=“校验上限”Height=975Left=240Tabindex=65Top=7440Width=11175BeginVB-CommandButtonCommand26Caption=”校验B相电流”Height=380Left=8480Tabindex=72Top=360Width=1125EndBeginVB-CommandButtonCommand25Caption=”校验A相电流”Height=380Left=7060Tabindex=71Top=360Width=1125EndBeginVB-CommandButtonCommand24Caption=”校验4路温度”Height=380Left=5650Tabindex=70Top=360Width=1125EndBeginVB-CommandButtonCommand23Caption=”校验3路温度”Height=380Left=4300Tabindex=69Top=360Width=1125BeginVB-CommandButtonCommand22Caption=”校验2路温度UHeight=380Left=2950Tabindex=68Top=360Width=1125EndBeginVB-CommandButtonCommand21Caption=”校验1路温度”Height=380Left=1600Tabindex=67Top=360Width=1125EndBeginVB-CommandButtonCommand20Caption=”校验漏电流”Height=380Left=240Tabindex=66Top=360Width=1125EndEndBeginVB.FrameFrame6Caption="数据采集"Height=22951.eft=7680Tabindex=55Top=4800Width=3855BeginVB-CommandButtonCommandl7Caption="采集A相电流"Height=3801.eft=120Tabindex=64Top=1560Width=1125EndBeginVB-CommandButtonCommandl8Caption="采集B相电流"Height=3801.eft=1350Tabindex=63Top=1560Width=1125EndBeginVB-CommandButtonCommandl9Caption=”采集C相电流”Height=380Left=2565Tabindex=62Top=1560Width=1125EndBeginVB-CommandButtonCommandl6Caption=”采集4路温度UHeight=380Left=2560Tabindex=61Top=960Width=1125EndBeginVB-CommandButtonCommandlSCaption=”采集3路温度”Height=380Left=1350Tabindex=60Top=960Width=1125EndBeginVB-CommandButtonCommandl4Caption=”采集1路温度”Height=380Left=2560Tabindex=59Top=360Width=1125EndBeginVB-CommandButtonCommandl3Caption=”采集2路温度”Height=380Left=120Tabindex=58Top=960Width=1125BeginVB-CommandButtonCommandl2Caption=”采集开关量Height=380Left=1350Tabindex=57Top=360Width=1125EndBeginVB-CommandButtonCommandllCaption="采集漏电流'Height=380Left=120Tabindex=56Top=360Width=1125EndEndBeginVBJextBoxtxtReceivedTextHeight=810Left=6960MuItiLine=-1'TrueScroIIBars=2'VerticalTabindex=52Top=2160Width=4275EndBeginVB-CommandButtonCommand9Caption=“清除”Height=380Left=6260Tabindex=50Top=6000Width=100OEndBeginVBTextBoxt×tStartHeight=375Left=1230Tabindex=47Top=6000Width=855EndBeginVB.FrameFrame5Caption=“发送”Height=1575Left=240Tabindex=39Top=5760Width=7215BeginVB-OptionButtonOptCommDataCaption=“文本(&X)”Height=180Index=1Left=120Tabindex=86Top=IllOWidth=1035EndBeginVB-OptionButtonOptCommDataCaption三“十六进制'Height=180Index=OLeft=120Tabindex=85Top=840Width=1050EndBeginVB-CheckBoxChkCheckSumCaption=”校验和”Height=330Left=1920Tabindex=84Top=280Width=945EndBeginVB1CommandButtoncmdSendCaption=”发送“Height=380Left=4920Tabindex=54Top=240Width=1000EndBeginVBTextBoxtxtSendHeight=570Left=1320MuItiLine三-1'TrueScroIIBars三2'VerticalTabindex=51TopWidthEnd=840=5595BeginVB.TextBoxtxtEndHeight1.eft=375=3960Tabindex=49TopWidthEnd=240=855BeginVB.LabelLabellCaptionHeightIndexLeft=”前段标志:”=255=4=120Tabindex=41TopWidthEnd=360=1095BeginVB.LabelLabellCaptionHeightIndexLeftTabindex=,结束标志:”=255=1=3000=40TopWidthEndEnd=360=1215BeginVB.FrameFrame4Caption=Height=1.eft=Tabindex=”接收数据”3015684038Top=Width=1204575BeginVB.TextBoxtxtReceivedBinaryHeight1.eftMuItiLine=ScroIIBars=Tabindex=810=120-1'True2'Vertical=53TopWidth=840=4275EndBeginVB.CommandButtoncmdClearCaption=Height=”清除U380Left=3360Tabindex=Top=Width=End442401000BeginVB.CommandButtonCmdCSCaption="CS',Height=3801.eft=2280Tabindex=Top=Width=End432401000BeginVB.CommandButtonCmd485Caption="485"Height=380Left=Tabindex=120042Top=Width=End2401000BeginVBlabeILabellCaption=Height=Index=1.eft=”文本信息:"3756120Tabindex=46Top=Width=End18001095BeginVBlabeILabellCaption="二进制信息:"Height=Index=1.eft=Tabindex=375512045Top=Width=End3501095BeginVB.CommandButtoncmdCloseCaption=Height=1.eft=Tabindex=Top=Width=End”关闭串口”3806240375040100OBeginVB.CommandButtonCmdCommOpenCaption=Height=1.eft=Tabindex=Top=Width=End”打开串口”38050403650401000BeginVB.FrameFrame3Caption=Height=1.eft=Tabindex=Top=Width=”端口设置”8552403148007215BeginVB.ComboBoxCombo2HeightLeftTabindexTopWidthEnd=300=3120=32=300=1455BeginVB.ComboBoxCombolHeightLeftTabindexTextTopWidthEnd=300=950=33="cboCommPort"=300=735BeginVBlabeILabellCaptionHeightIndex1.eftTabindex="端口:,=255=3=360=83Top=360Width=615EndBeginVBlabeILabellCaption="数据格式(F):Height=255Index=21.eft=1920Tabindex=35Top=360Width=1215EndBeginVBlabeILabell7Caption="端口(P):Height=2551.eft=0Tabindex=34Top=840Width=855EndEndBeginVB.FrameFrame2Caption="电流统计计算"Height=13351.eft=5280Tabindex=18Top=3360Width=4860BeginVBJextBoxText8Height=3801.eft=1000Tabindex=22Top=260Width=1000EndBeginVBJextBoxText7Height=3801.eft=3450Tabindex=21Top=240Width=1000EndBeginVBTextBoxText6Height=380Left三3450Tabindex三20Top三720Width三1000EndBeginVBJextBoxText5Height=380Left=1000Tabindex=19Top=735Width三1000EndBeginVB.LabelLabell6Caption三”漏电流Height三375Left=240Tabindex二30Top三360Width三855EndBeginVBlabeILabeIlSCaption三"mA"Height=255Left三2100Tabindex=29Top=360Width二375EndBeginVBlabeILabel14Caption三"A相电流:"Height三375Left=2640Tabindex=28Top=360Width三855EndBeginVB.LabelLabell3Caption三"A"Height=255Left三4550Tabindex三27Top=360Width三255BeginVB.LabelLabell2CaptionHeight="C相电流:"=3751.eft=2640TabindexTopWidthEnd=26=840=855BeginVB.LabelLabelllCaption="A"HeightLeftTabindexTopWidthEnd=255=2100=25=840=375BeginVB.LabelLabeIlOCaption="B相电流:Height=3751.eft=240TabindexTopWidthEnd=24=840=855BeginVB.LabelLabel9CaptionHeightLeftTabindexTopWidthEndEnd="A"=255=4550=23=840=255BeginVBtCommandButtonCommand3Caption=Height=1.eft=Tabindex=Top=Width=End“关闭软件”380103201743201000BeginVB1CommandButtonCommand2Caption=Height=“停止采集”380Left=10320Tabindex=16Top=3840Width=1000EndBeginVB1CommandButtonCommandlCaption="采集线性”Height=380Left=10320Tabindex=15Top=3360Width=1000EndBeginVB.FrameFramelCaption=”温度统计计算,Height=1335Left=200Tabindex=2Top=3360Width=4860BeginVBTextBoxText4Height=3801.eft=100OTabindex=10Top=735Width=1000EndBeginVBJextBoxText3Height=3801.eft=3360Tabindex=9Top=720Width=1000EndBeginVBTextBoxText2Height=3801.eft=3360Tabindex=7Top=240Width=1000EndBeginVBTextBoxTextlHeight=3801.eft=1000Tabindex=4Top=260Width=1000EndBeginVB.LabelLabel8Caption三IlChHeight三255Left三4440Tabindex=14Top=840Width=375EndBeginVB.LabelLabel7Caption=”最小值Height=375Left三240Tabindex=13Top=840Width=855EndBeginVB.LabelLabel6Caption三11C11Height三255Left二2100Tabindex=12Top=840Width三375EndBeginVB.LabelLabel5Caption=”最大值:”Height=375Left三2640Tabindex=11Top=840Width三855EndBeginVB.LabelLabel4Caption=IloQIlHeight=255Left=4440Tabindex=8Top=360Width三375BeginVB.LabelLabel2Caption二”平均值Height=375Left=2640Tabindex=6Top=360Width=855EndBeginVB.LabelLabel3Caption=IlC11Height=255Left=2100Tabindex=5Top=360Width=375EndBeginVB.LabelLabellCaption=”当前值:Height=375Index=0Left三240Tabindex=3Top三360Width-855EndEndBeginVB.TimerTimerlLeft=7320Top=5640EndBeginMSFIexGridLib.MSFIexGridMSFIexGridlHeight=30001.eft=4560Tabindex=1Top=240Width=2085_ExtentX=3678_ExtentY=5292.Version=393216Rows=200EndBeginMSCommLib-MSCommMSComml1.eft=7320Top=6240_ExtentX=1005_ExtentY=1005_Version=393216DTREnabIe=-1'TrueEndBeginVB1PictureBoxPicturelBackCoIor=&HOOFFFFFF&Height=3000Left=200ScaIeHeight=2940ScaIeWidth=4080Tabindex=0Top=240Width=4140EndBeginVB.LabelLabel23Caption=”校验和”Height=255Left=4200Tabindex=48Top=6120Width三1215EndEndAttributeVB_Name="Forml"AttributeVB_GlobalNameSpace=FalseAttributeVB_Creatable=FalseAttributeVB_Predeclaredld=TrueAttributeVB_Exposed=False*'西安亚川电力科技有限公司,火灾报警器调试软件,发布日期:2011/)6/16,描述:FY900火灾监控器专用调试软件,网站:,网站:'e-mail:yachuandianli'e-mail:yachuandianli'OICQ:029-85368687'*木*本*本*,定义窗体级变量,在显示、绘图、报警等过程中使用Dimdatatemp(1000)AsSingle,用于存储温度采样值DimnumAsInteger'用于存储采样值个数DimIAsSingleOptionExplicitPrivateDeclareFunctionGetTickCountLib"kernel32"()AsLongPrivateSubPicture2_Click()EndSubPrivateSubSubWizardl_GotFocus()EndSubPrivateSubCmd485_Click()IfIndex=OThenCboCommSettings="1200,E,8,1”txtSend.Text="68OlOOOO00000068Ol0243C3"chkCheckSum.Value=VbCheckedtxtEnd.Text="16"txtStart.Text=',"OptCommData(O)1VaIue=TrueElseCboCommSettings="300,E,7zl"txtSend.Text="2F3F21DA"chkCheckSum.Value=VbUncheckedtxtEnd.Text=","txtStart.Text=""OptCommData(O),VaIue=TrueEndIfEndSubPrivateSubcmdClear_Click()txtReceivedBinary.Text=',"txtReceivedText.Te×t=""txtSend.SetFocusEndSubPrivateSubcmdClose_Click()CIoseCommEndSubPrivateSubcmdCommOpen_Click()SetMP11CIoseCommOnErrorResumeNextWithMSComml.CommPort=Val(Mid(cboCommPort.Text,4).Settings=cboCommSettings.Text.PortOpen=TrueIfErr=OThenCmdSend.EnabIed=TrueElseMsgBox"错误信息:"&vbCrLf&vbCrLf&Error&Space(7),VblnformationEndIfEndWithSetMPOEndSubPrivateSubcmdSend_Click()Dimarr()AsByteDimIAsLongDimJAsLongDimSAsLongDimCAsLongDimMsg(2)AsStringSetMP11CmdSend-EnabIed=FalseOnErrorResumeNextMsg(O)=txtStart.TextMsg(I)=txtSend.TextMsg(2)=txtEnd.TextForI=OTb2If1=2ThenIfchkCheckSum.Value=VbCheckedThen'数据字节校验和C=C+1ReDimPreservearr(C-1)arr(C-l)=SMod256EndIfEndIfIf(I=1)AndOptCommData(I),VaIueThen,文本方式DoWhileLen(Msg(l)>OC=C+1ReDimPreservearr(C-1)arr(C-1)=Asc(Msg(l)IfI=IThenS=S+arr(C-1)Msg(I)=Mid(Msg(l),2)1.oop日Se'十六进制Msg(I)=Trim(Msg(l)DoWhileLen(Msg(l)>0C=C+1ReDimPreservearr(C-1)arr(C-1)=Val("&H"&Left(MsgfI),2)IfI=IThenS=S+arr(C-1)Msg(I)=Trim(Mid(Msg(l),3)1.oopEndIfNextIIfC>0ThenMSComml.Output=arr()IfErr>OThenMsgBox"错误信息:"&vbCrLf&vbCrLf&Error&Space(7)zVblnformationtxtSend.SetFocuscmdSend.Enabled=TrueSetMPOEndSubPrivateSubCombol_Change()CIoseCommEndSubPrivateSubCombo2_Change()CIoseCommEndSub'开始采集PrivateSubCommandl_Click()Timerl.Enabled=TrueEndSubPrivateSubCommandlO_Click()Dimarr()AsByteDimIAsLongDimJAsLongDimSAsLongDimCAsLongDimMsg(2)AsStringSetMP11cmdSend.Enabled=FalseOnErrorResumeNextMsg(O)=txtStart.TextMsg(I)=txtSend.TextMsg(2)=txtEnd.TextForI=0To2If1=2ThenIfchkCheckSum.Value=VbCheckedThen,数据字节校验和C=C+1ReDimPreservearr(C-1)arr(C-l)=SMod256EndIfEndIfIf(I=1)AndOptCommData(I)VaIueThen,文本方式DoWhileLen(Msg(l)>OC=C+1ReDimPreservearr(C-1)arr(C-1)=Asc(Msg(l)IfI=IThenS=S+arr(C-1)Msg(I)=Mid(Msg(l),2)1.oop日Se'十六进制Msg(I)=TrimfMsg(I)DoWhileLen(Msg(l)>OC=C+1ReDimPreservearr(C-1)arr(C-1)=Val("&H"&Left(MsgfI(z2)IfI=IThenS=S+arr(C-1)Msg(I)=Trim(Mid(Msg(l),3)1.oopEndIfNextIIfC>OThenMSComml.Output=arr()IfErr>OThenMsgBox"错误信息:"&vbCrLf&vbCrLf&Error&Space(7),VblnformationtxtSend.SetFocuscmdSend.Enabled=TrueSetMPOEndSub'停止采集PrivateSubCommand2_Click()Timerl-Enabled=Fa