国产精品成人网站,日韩视频二区,亚洲成人手机电影,怡红院国产

產(chǎn)品推薦:水表|流量計(jì)|壓力變送器|熱電偶|液位計(jì)|冷熱沖擊試驗(yàn)箱|水質(zhì)分析|光譜儀|試驗(yàn)機(jī)|試驗(yàn)箱


儀表網(wǎng)>技術(shù)中心>使用指南>正文

歡迎聯(lián)系我

有什么可以幫您? 在線咨詢

VB開(kāi)發(fā)BACnetIP主站介紹

來(lái)源:上海迅饒自動(dòng)化科技有限公司   2013年08月06日 13:40  

VB開(kāi)發(fā)BACnetIP主站介紹
Visual Basic開(kāi)發(fā)BACnet IP主站程序方法介紹
這里要說(shuō)的方法就是調(diào)用BACnet IP主站快速開(kāi)發(fā)工具OMBACnetIPMaster.dll。
步驟1、創(chuàng)建通道,而通道管理所有的Bacnet屬性對(duì)象。參數(shù)分別IP地址,端口號(hào)和網(wǎng)絡(luò)超時(shí)時(shí)間,默認(rèn)是100毫秒。
Private Sub OpenChannelButton_Click()
StringToByte txtIPAddress, IPAddress()
ChannelHandle(0) = CreateBacnetChannel(IPAddress(0), CLng(txtPort), 100)
End Sub
通道編輯操作的相關(guān)API函數(shù)聲明如下
‘ 通道管理用于創(chuàng)建、修改、刪除通道。創(chuàng)建通道以后,才能創(chuàng)建Bacnet屬性對(duì)象
‘ 創(chuàng)建一個(gè)通道對(duì)象只要是為了設(shè)置不同設(shè)備的IP地址和端口號(hào)。網(wǎng)絡(luò)超時(shí)等待時(shí)間默認(rèn)是100毫秒
Function CreateBacnetChannel Lib 'OMBacnetIPMaster.dll' Alias '_CreateChannel@12' (ByRef IPAddress As Byte, ByVal nPort As Long, ByVal nTimeOut As Long) As Long
Function ConfigureChannel Lib 'OMBacnetIPMaster.dll' Alias '_ConfigureChannel@16' (ByVal ChannelHandle As Long, ByRef IPAddress As Byte, ByVal nPort As Long, ByVal nTimeOut As Long) As Long
Function RemoveChannel Lib 'OMBacnetIPMaster.dll' Alias '_RemoveChannel@4' (ByVal ChannelHandle As Long) As Long

步驟2、創(chuàng)建Bacnet屬性對(duì)象。
Private Sub CreateBacnetObjButton_Click()
TagHandle(0) = CreateBacnetObj(ChannelHandle(0), 1, 1, 85)
End Sub
BACnet屬性對(duì)象編輯相關(guān)的API函數(shù)申明如下
‘ BACnet對(duì)象管理,創(chuàng)建、修改、刪除
‘參數(shù) ChannelHandle 為通道對(duì)象的句柄
‘參數(shù) nBacnetObjType 為Bacent屬性對(duì)象的類型ID,譬如0表示 Analog Input,1表示Analog Output
‘參數(shù) nInstanceNum 為指明哪一個(gè)對(duì)象,譬如要訪問(wèn)Analog Input 1。則 nInstanceNum為1
‘參數(shù) nProperityID 為要訪問(wèn)屬性的ID,譬如當(dāng)前值的屬性ID是85
‘參數(shù) TagHandle 為Bacnet對(duì)象的句柄
Function CreateBacnetObj Lib 'OMBacnetIPMaster.dll' Alias '_CreateBacnetObject@16' (ByVal ChannelHandle As Long, ByVal nBacnetObjType As Long, ByVal nInstanceNum As Long, ByVal nProperityID As Long) As Long
Function ConfigureObject Lib 'OMBacnetIPMaster.dll' Alias '_ConfigureObject@16' (ByVal ChannelHandle As Long, ByVal nBacnetObjType As Long, ByVal nInstanceNum As Long, ByVal nProperityID As Long) As Long
Function RemoveBacnetObject Lib 'OMBacnetIPMaster.dll' Alias '_RemoveBacnetObject@4' (ByVal TagHandle As Long) As Long

步驟3、BACnet屬性對(duì)象的讀寫(xiě)
Private Sub WriteBacnetObjectButtton_Click()
error = WriteBacnetObj(TagHandle(0), CSng(Tag2.Text), 0)
End Sub
Private Sub ReadBacnetObjButton_Click()
Dim a As Variant
error = ReadBacnetObj(TagHandle(0), a)
Tag1.Text = a
End Sub
‘ BACnet對(duì)象屬性值讀寫(xiě)
‘參數(shù) nTagNum 為Bacnet對(duì)象的Tag Number。也就是要寫(xiě)的對(duì)象屬性的數(shù)據(jù)類型。當(dāng)操作過(guò)ReadBacnet以后,這個(gè)參數(shù)可以為空。
‘當(dāng)只寫(xiě)操作的時(shí)候,則需要用戶自己指明是什么數(shù)據(jù)類型。譬如Analog Output為4.也就是單精度浮點(diǎn)型。
Function ReadBacnetObj Lib 'OMBacnetIPMaster.dll' Alias '_ReadBacnetObject@8' (ByVal TagHandle As Long, ByRef Value As Variant) As Long
Function WriteBacnetObj Lib 'OMBacnetIPMaster.dll' Alias '_WriteBacnetObject@12' (ByVal TagHandle As Long, ByRef Value As Variant, ByVal nTagNum As Long) As Long
步驟4、關(guān)閉程序時(shí),釋放對(duì)象資源。

Private Sub RemoveBacnetObjButton_Click()
error = RemoveBacnetObject(ByVal TagHandle(0))
End Sub

Private Sub RemoveChannelButton_Click()
error = RemoveChannel(ByVal ChannelHandle(0))
End Sub
zui后討論一下輔助函數(shù)的作用
‘以下是輔助函數(shù),可以選擇性使用
‘設(shè)置寫(xiě)操作的優(yōu)先等級(jí)
Function SetBacnetPriority Lib 'OMBacnetIPMaster.dll' Alias '_SetBacnetPriority@8' (ByVal TagHandle As Long, ByVal nPriority As Long) As Long
‘返回Bacnet對(duì)象屬性的數(shù)據(jù)類型,一般用于寫(xiě)操作
Function GetBacnetObjType Lib 'OMBacnetIPMaster.dll' Alias '_GetBacnetObjType@4' (ByVal TagHandle As Long) As Long
‘通信故障狀況回調(diào)函數(shù)
Function EnableErrorMsgNofity Lib 'OMBacnetIPMaster.dll' Alias '_EnableErrorMsgNofity@4' (ByVal Callback As Long) As Long
Function EnableAbortMsgNofity Lib 'OMBacnetIPMaster.dll' Alias '_EnableAbortMsgNofity@4' (ByVal Callback As Long) As Long
Function EnableRejectMsgNofity Lib 'OMBacnetIPMaster.dll' Alias '_EnableRejectMsgNofity@4' (ByVal Callback As Long) As Long

免責(zé)聲明

  • 凡本網(wǎng)注明“來(lái)源:儀表網(wǎng)”的所有作品,均為浙江興旺寶明通網(wǎng)絡(luò)有限公司-儀表網(wǎng)合法擁有版權(quán)或有權(quán)使用的作品,未經(jīng)本網(wǎng)授權(quán)不得轉(zhuǎn)載、摘編或利用其它方式使用上述作品。已經(jīng)本網(wǎng)授權(quán)使用作品的,應(yīng)在授權(quán)范圍內(nèi)使用,并注明“來(lái)源:儀表網(wǎng)”。違反上述聲明者,本網(wǎng)將追究其相關(guān)法律責(zé)任。
  • 本網(wǎng)轉(zhuǎn)載并注明自其它來(lái)源(非儀表網(wǎng))的作品,目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點(diǎn)或和對(duì)其真實(shí)性負(fù)責(zé),不承擔(dān)此類作品侵權(quán)行為的直接責(zé)任及連帶責(zé)任。其他媒體、網(wǎng)站或個(gè)人從本網(wǎng)轉(zhuǎn)載時(shí),必須保留本網(wǎng)注明的作品第一來(lái)源,并自負(fù)版權(quán)等法律責(zé)任。
  • 如涉及作品內(nèi)容、版權(quán)等問(wèn)題,請(qǐng)?jiān)谧髌钒l(fā)表之日起一周內(nèi)與本網(wǎng)聯(lián)系,否則視為放棄相關(guān)權(quán)利。
聯(lián)系我們

客服熱線: 15267989561

加盟熱線: 15267989561

媒體合作: 0571-87759945

投訴熱線: 0571-87759942

關(guān)注我們
  • 下載儀表站APP

  • Ybzhan手機(jī)版

  • Ybzhan公眾號(hào)

  • Ybzhan小程序

企業(yè)未開(kāi)通此功能
詳詢客服 : 0571-87759942