#how to connect a smart home, #smart home cameras, #smart home system, #download a smart home, #smart home, #buy a smart home, #smart home with Alice
Chris Gurtler SCADA Engine
BACnet web services: know and be able to
Most likely, you have already heard about the new addition to the BACnet web services standard, but I suspect that most still have no idea what web services are and what they are intended for.
If anyone is interested in learning more about their use in BACnet, this article is for you.
Web services make it easy to integrate real-time data into almost any application.
So, let's imagine that there is a BACnet system and the customer wants to receive certain information at the output of the system in real time. For example, the air temperature in the main hall of the building, displayed on the local network site.
There are many solutions to this problem that can be offered by manufacturers of various equipment, and the customer will be presented with a hefty bill for its implementation.
And some of these solutions will certainly be good, but still it would be nice to have a common, standard approach to solving such a problem.
And such a solution already exists.
And it is very simple thanks to BACnet web services.
Let's start with a .Net application, and in subsequent articles we'll tell you how to do this using a web browser, HTML and Java-script.
Installing web services
The first thing you need to do is install web services. If, of course, you don't have them yet. Download a demo version of the web service from SCADA Engine
http://scadaengine/downloads.html
Follow the instructions to install it, and you will see the web service displayed as shown in Figure 1. If you already have a web service installed on your computer, these instructions are suitable for any BACnet web service from any developer.
Figure 1
Specifying web service paths
BACnet web service uses paths to reference values. Path names are a bit like file names on a computer. Different computers have different files and different file names. The same is true for BACnet web service — path names are system-specific.
In the web service from SCADA Engine, the path is built from the BACnet address:
/[Network]/[Device]/[ObjectType]/[Instance]
Thus, the path to AV 0 (see Fig. 1) will be /2/11/2/0 and its value will be equal to 72. To make the name more convenient for traversing the path, you can create a “reference” path. But let's leave this option for the next publication.
Reading data
To read the values, there is a service called getValue that takes a path as input and returns the value for that path. If you want to know the value of the variable AV 0, it would look like this: getValue(«», «/2/11/2/0»)
Creating a Visual Basic Application
Now you have a general idea of the BACnet web service and you have already installed the web service on your computer. Now let's start creating our own application. Let's assume that the analog value Analog Value 1 is the air temperature in the main hall of the building, i.e. exactly the information that your client asks to display on his website. We see that the parameter value is 72 and its path is /2/11/2/0.
Fig. 2
Open Visual Studio 2005, create a new project (new Windows Application Project), which we will call bacnet. Then click «OK».
Adding a web link (reference)
Now we need to add a web reference in the BACnet application. This is very similar to adding a reference in COM/ActiveX objects. But after we add it, we will get access to the XML web service in the BACnet web service.
Open Solution Explorer, right-click on References and then Add Web Reference. You can also select the Project menu and click Add Web Reference.
In the Add Web Reference window, in the address bar, type:
C:Program FilesSCADA EngineBACnetWS Web Servicebacnet.wsdl.
Please note that this link is case-separated, so you must enter the address exactly as shown here.
Fig. 3
Once you have entered the URL and pressed Enter, the BACnet web service will be loaded and your screen will look like Fig. 3, and the Add Reference button will be activated.
Click it to add a web reference to the project.
In the Solution Explorer window, click Web Reference to see the reference to the BACnetWS (web service) that you added.
Fig. 4
Add a Textbox to the form and name it TextBox1.
Insert the following code into the Code View section of the form.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As BACnetWS.bacnet = New BACnetWS.bacnet()
TextBox1.Text = a.getValue(«», «/2/11/2/0»)
End Sub
End Class
Running the Application
The preparatory work with the codes of our application is complete.
Now let's run the application and check if the value returned is the same as it was in the BACnet system. You should see a form with a text box (Fig. 5).
Fig. 5
We assumed that Analog Value 1 represents the temperature in the main hall of the building, and this is what the customer wants to see displayed on their website.
In the form window, we can see that this value is 72.
I hope you now understand how easy it is to implement BACnet web services into your applications.
In the next article, I plan to show how real-time data can be displayed on a website.