BAC0 is a script module based on bacpypes (https://github.com/JoelBender/bacpypes.git) to automate task using Bacnet/IP protocole. It's mainly targetted as a tool to test sequences on DDC controlelrs using bacnet.
Using the simplciity of python, the power of pandas, it's easy to test and keep a trace of the history of each points.
First you must install the 2 modules pip install bacpypes
Note : All tests have been done in Windows 7 using Anaconda3 (http://continuum.io/downloads)
In [1]:
import BAC0
import pandas as pd
%matplotlib inline
# Define network and connect to it
bacnet = BAC0.connect()
In [2]:
BAC0.version
Out[2]:
In [2]:
# Define the controller using : controller = BAC0.device(address, device_id, network)
fx = BAC0.device('2:5',5,bacnet)
In [4]:
# Access points list
fx.points
Out[4]:
In [6]:
# Create a table with multiple points
lst = ['nvoAI1', 'nvoAI2', 'nvoDI1']
fx.df(lst).fillna(method='ffill')
Out[6]:
In [7]:
# Create a trend with multiple points using the DataFrame
lst = ['nvoAI1', 'nvoAI2']
fx.df(lst).resample('1min').plot(title='My title')
Out[7]:
In [8]:
fx.chart(lst, title='My title')
Out[8]:
In [9]:
fx.notes = 'New note to remember'
fx.notes
Out[9]:
In [10]:
fx
Out[10]:
In [ ]:
bacnet.whois() # Note that this function is called automatically in ReadWriteScript
# The result takes a few milliseconds to be processed... it can be used in the same cell.
Accessing the list of object of a device can be done using the objectList property
In [ ]:
# Let's print the first 10 objects...
bacnet.read('2:5 device 5 objectList')[:10]
In [ ]:
bacnet.readMultiple('2:5 analogInput 1 objectName description presentValue units')
In [ ]:
import time
obj = '2:5 analogValue 41 presentValue'
old_value = bacnet.read(obj)
print('Old Value is : %s' % old_value)
new_value = 120
bacnet.write('%s %s' % (obj,new_value))
print('New value is %s' % bacnet.read(obj))
In [ ]:
bacnet.disconnect()