|
BACnetX ActiveX Component - Object Access Tutorial
Introduction
To Access Objects in BACnet there are services such as readProperty, readPropertyMultiple,
writeProperty and writePropertyMultiple. This tutorial demonstrates how to use the
readProperty and writeProperty services with the BACnetX activeX component.
Create a global ApplicationLayer object
Public objApplicationLayer As BACNETXLib.ApplicationLayer
Initialize the Application Layer Object
Set objApplicationLayer = New BACNETXLib.ApplicationLayer
objApplicationLayer.Initialize 200
Issue a Read Property Request
Dim Service As New ReadProperty
Service.DeviceID = 100
Service.Request.objectIdentifier.Instance = 1
Service.Request.objectIdentifier.ObjectType = BACnetObjectTypeAnalogValue
Service.Request.propertyIdentifier = Property_presentValue
Service.Execute
If Service.Error.choice = BACnetErrorChoiceEmpty Then
Debug.Print "Value = " & Service.Ack.propertyValue.Real
Else
Debug.Print "Error Class = " & Service.Error.Error.Class & " Error Class = " & Service.Error.Error.Code
End If
Issue a Write Property Request
Dim Service As New BACNETXLib.WriteProperty
Service.async = False
Service.DeviceID = LocalDeviceID
Service.Request.objectIdentifier.Instance = 1
Service.Request.objectIdentifier.ObjectType = BACnetObjectTypeBinaryValue
Service.Request.propertyIdentifier = Property_presentValue
Service.Request.priority = 8 'Priority 8 for Manual Overides
Service.Request.propertyValue.Enumerated = BACnetBinaryPVActive
Service.Execute
If Service.Error.choice <> BACnetErrorChoiceEmpty Then
Debug.Print "Error Class = " & Service.Error.Error.Class & " Error Class = " & Service.Error.Error.Code
End If
Source Code
The Source Code for this application is avaliable as part of the BACnetX ActiveX component
from the downloads area of this web site.
|