BAC0.scripts package

Submodules

BAC0.scripts.Base module

BasicScript - implement the BAC0.core.app.ScriptApplication Its basic function is to start and stop the bacpypes stack. Stopping the stack, frees the IP socket used for BACnet communications. No communications will occur if the stack is stopped.

Bacpypes stack enables Whois and Iam functions, since this minimum is needed to be a BACnet device. Other stack services can be enabled later (via class inheritance). [see: see BAC0.scripts.ReadWriteScript]

Class::
BasicScript(WhoisIAm)
def startApp() def stopApp()
class BAC0.scripts.Base.Base(localIPAddr='127.0.0.1', localObjName='BAC0', deviceId=None, firmwareRevision='3.7.3 (default, Jan 24 2020, 02:22:02) n[GCC 7.4.0]', maxAPDULengthAccepted='1024', maxSegmentsAccepted='1024', segmentationSupported='segmentedBoth', bbmdAddress=None, bbmdTTL=0, modelName=<bacpypes.primitivedata.CharacterString object>, vendorId=842, vendorName=<bacpypes.primitivedata.CharacterString object>)[source]

Bases: object

Build a running BACnet/IP device that accepts WhoIs and IAm requests Initialization requires some minimial information about the local device.

Parameters:
  • localIPAddr='127.0.0.1'
  • localObjName='BAC0'
  • deviceId=None
  • maxAPDULengthAccepted='1024'
  • maxSegmentsAccepted='1024'
  • segmentationSupported='segmentedBoth'
clear_notes()

Clear notes object

disconnect()[source]

Stop the BACnet stack. Free the IP socket.

log(note, *, level=10)

Add a log entry…no note

log_subtitle(subtitle, args=None, width=35)
log_title(title, args=None, width=35)
logname = 'BAC0.scripts.Base | Base'
note(note, *, level=20, log=True)

Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note

notes

Retrieve notes list as a Pandas Series

register_foreign_device(addr=None, ttl=0)[source]
startApp()[source]

Define the local device, including services supported. Once defined, start the BACnet stack in its own thread.

unregister_foreign_device()[source]

BAC0.scripts.Complete module

BAC0.scripts.Lite module

ReadWriteScript - extended version of BasicScript.py

As everything is handled by the BasicScript, select the additional features you want:

# Create a class that implements a basic script with read and write functions
from BAC0.scripts.BasicScript import BasicScript
from BAC0.core.io.Read import ReadProperty
from BAC0.core.io.Write import WriteProperty
class ReadWriteScript(BasicScript,ReadProperty,WriteProperty)

Once the class is created, create the local object and use it:

bacnet = ReadWriteScript(localIPAddr = '192.168.1.10')
bacnet.read('2:5 analogInput 1 presentValue)
class BAC0.scripts.Lite.Lite(ip=None, port=None, mask=None, bbmdAddress=None, bbmdTTL=0, ping=True, **params)[source]

Bases: BAC0.scripts.Base.Base, BAC0.core.functions.Discover.Discover, BAC0.core.io.Read.ReadProperty, BAC0.core.io.Write.WriteProperty, BAC0.core.io.Simulate.Simulation, BAC0.core.functions.TimeSync.TimeSync, BAC0.core.functions.Reinitialize.Reinitialize

Build a BACnet application to accept read and write requests. [Basic Whois/IAm functions are implemented in parent BasicScript class.] Once created, execute a whois() to build a list of available controllers. Initialization requires information on the local device.

Parameters:
  • ip='127.0.0.1' – Address must be in the same subnet as the BACnet network [BBMD and Foreign Device - not supported]
  • bokeh_server – (boolean) If set to false, will prevent Bokeh server from being started. Can help troubleshoot issues with Bokeh. By default, set to True.
add_trend(point_to_trend)[source]

Add point to the list of histories that will be handled by Bokeh

Argument provided must be of type Point or TrendLog ex. bacnet.add_trend(controller[‘point_name’])

clear_notes()

Clear notes object

devices

This property will create a good looking table of all the discovered devices seen on the network.

For that, some requests will be sent over the network to look for name, manufacturer, etc and in big network, this could be a long process.

disconnect()[source]

Stop the BACnet stack. Free the IP socket.

discover(networks='known', limits=(0, 4194303), global_broadcast=False, reset=False)[source]

Discover is meant to be the function used to explore the network when we connect. It will trigger whois request using the different options provided with parameters.

By default, a local broadcast will be used. This is required as in big BACnet network, global broadcast can lead to network flood and loss of data.

If not parameters are given, BAC0 will try to :

  • Find the network on which it is
  • Find routers for other networks (accessible via local broadcast)
  • Detect “known networks”
  • Use the list of known networks and create whois request to find all devices on those networks

This should be sufficient for most cases.

Once discovery is done, user may access the list of “discovered devices” using

bacnet.discoveredDevices
:param networks (list, integer) : A simple integer or a list of integer
representing the network numbers used to issue whois request.
:param limits (tuple) : tuple made of 2 integer, the low limit and the high
limit. Those are the device instances used in the creation of the whois request. Min : 0 ; Max : 4194303
:param global_broadcast (boolean) : If set to true, a global braodcast
will be used for the whois. Use with care.
known_network_numbers

This function will read the table of known network numbers gathered by the NetworkServiceElement. It will also look into the discoveredDevices property and add any network number that would not be in the NSE table.

log(note, *, level=10)

Add a log entry…no note

log_subtitle(subtitle, args=None, width=35)
log_title(title, args=None, width=35)
logname = 'BAC0.scripts.Lite | Lite'
note(note, *, level=20, log=True)

Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note

notes

Retrieve notes list as a Pandas Series

ping_registered_devices()[source]

Registered device on a network (self) are kept in a list (registered_devices). This function will allow pinging thoses device regularly to monitor them. In case of disconnected devices, we will disconnect the device (which will save it). Then we’ll ping again until reconnection, where the device will be bring back online.

To permanently disconnect a device, an explicit device.disconnect(unregister=True [default value]) will be needed. This way, the device won’t be in the registered_devices list and BAC0 won’t try to ping it.

register_device(device)[source]
registered_devices

Devices that have been created using BAC0.device(args)

remove_trend(point_to_remove)[source]

Remove point from the list of histories that will be handled by Bokeh

Argument provided must be of type Point or TrendLog ex. bacnet.remove_trend(controller[‘point_name’])

trends

This will present a list of all registered trends used by Bokeh Server

unregister_device(device)[source]

Remove from the registered list

Module contents