BAC0.core.io package

Submodules

BAC0.core.io.IOExceptions module

IOExceptions.py - BAC0 application level exceptions

exception BAC0.core.io.IOExceptions.APDUError[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.ApplicationNotStarted[source]

Bases: Exception

Application not started, no communication available.

exception BAC0.core.io.IOExceptions.BadDeviceDefinition[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.BokehServerCantStart[source]

Bases: Exception

Raised if Bokeh Server can’t be started automatically

exception BAC0.core.io.IOExceptions.InitializationError[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.NetworkInterfaceException[source]

Bases: Exception

This exception covers different network related exc eption (like finding IP or subnet mask…)

exception BAC0.core.io.IOExceptions.NoResponseFromController[source]

Bases: Exception

This exception is used when trying to read or write and there is not answer.

exception BAC0.core.io.IOExceptions.OutOfServiceNotSet[source]

Bases: Exception

This exception is used when trying to simulate a point and the out of service property is false.

exception BAC0.core.io.IOExceptions.OutOfServiceSet[source]

Bases: Exception

This exception is used when trying to set the out of service property to false to release the simulation…and it doesn’t work.

exception BAC0.core.io.IOExceptions.ReadPropertyException[source]

Bases: ValueError

This exception is used when trying to read a property.

exception BAC0.core.io.IOExceptions.ReadPropertyMultipleException[source]

Bases: ValueError

This exception is used when trying to read multiple properties.

exception BAC0.core.io.IOExceptions.ReadRangeException[source]

Bases: ValueError

This exception is used when trying to read a property.

exception BAC0.core.io.IOExceptions.RemovedPointException[source]

Bases: Exception

When defining a device from DB it may not be identical to the actual device.

exception BAC0.core.io.IOExceptions.SegmentationNotSupported[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.Timeout[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.UnknownObjectError[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.UnknownPropertyError[source]

Bases: Exception

exception BAC0.core.io.IOExceptions.UnrecognizedService[source]

Bases: Exception

This exception is used when trying to read or write and there is not answer.

exception BAC0.core.io.IOExceptions.WriteAccessDenied[source]

Bases: Exception

This exception is used when trying to write and controller refuse it.

exception BAC0.core.io.IOExceptions.WritePropertyCastError[source]

Bases: Exception

This exception is used when trying to write to a property and a cast error occurs.

exception BAC0.core.io.IOExceptions.WritePropertyException[source]

Bases: Exception

This exception is used when trying to write a property.

BAC0.core.io.Read module

Read.py - creation of ReadProperty and ReadPropertyMultiple requests

Used while defining an app: Example:

class BasicScript(WhoisIAm, ReadProperty)

Class:

ReadProperty()
    def read()
    def readMultiple()
class BAC0.core.io.Read.ReadProperty[source]

Bases: object

Defines BACnet Read functions: readProperty and readPropertyMultiple. Data exchange is made via a Queue object A timeout of 10 seconds allows detection of invalid device or communciation errors.

build_rp_request(args, arr_index=None, vendor_id=0, bacoid=None)[source]
build_rpm_request(args, vendor_id=0)[source]

Build request from args

build_rrange_request(args, arr_index=None, vendor_id=0, bacoid=None)[source]
clear_notes()

Clear notes object

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.core.io.Read | ReadProperty'
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

read(args, arr_index=None, vendor_id=0, bacoid=None, timeout=10, prop_id_required=False)[source]

Build a ReadProperty request, wait for the answer and return the value

Parameters:args – String with <addr> <type> <inst> <prop> [ <indx> ]
Returns:data read from device (str representing data like 10 or True)

Example:

import BAC0
myIPAddr = '192.168.1.10/24'
bacnet = BAC0.connect(ip = myIPAddr)
bacnet.read('2:5 analogInput 1 presentValue')

Requests the controller at (Network 2, address 5) for the presentValue of its analog input 1 (AI:1).

readMultiple(args, vendor_id=0, timeout=10, prop_id_required=False)[source]

Build a ReadPropertyMultiple request, wait for the answer and return the values

Parameters:args – String with <addr> ( <type> <inst> ( <prop> [ <indx> ] )… )…
Returns:data read from device (str representing data like 10 or True)

Example:

import BAC0
myIPAddr = '192.168.1.10/24'
bacnet = BAC0.connect(ip = myIPAddr)
bacnet.readMultiple('2:5 analogInput 1 presentValue units')

Requests the controller at (Network 2, address 5) for the (presentValue and units) of its analog input 1 (AI:1).

readRange(args, arr_index=None, vendor_id=0, bacoid=None, timeout=10)[source]

Build a ReadProperty request, wait for the answer and return the value

Parameters:args – String with <addr> <type> <inst> <prop> [ <indx> ]
Returns:data read from device (str representing data like 10 or True)

Example:

import BAC0
myIPAddr = '192.168.1.10/24'
bacnet = BAC0.connect(ip = myIPAddr)
bacnet.read('2:5 analogInput 1 presentValue')

Requests the controller at (Network 2, address 5) for the presentValue of its analog input 1 (AI:1).

BAC0.core.io.Read.cast_datatype_from_tag(propertyValue, obj_id, prop_id)[source]
BAC0.core.io.Read.find_reason(apdu)[source]

BAC0.core.io.Simulate module

Simulate.py - simulate the value of controller I/O values

class BAC0.core.io.Simulate.Simulation[source]

Bases: object

Global informations regarding simulation

out_of_service(args)[source]

Set the Out_Of_Service property so the Present_Value of an I/O may be written.

Parameters:args – String with <addr> <type> <inst> <prop> <value> [ <indx> ] [ <priority> ]
release(args)[source]

Set the Out_Of_Service property to False - to release the I/O point back to the controller’s control.

Parameters:args – String with <addr> <type> <inst>
sim(args)[source]

Simulate I/O points by setting the Out_Of_Service property, then doing a WriteProperty to the point’s Present_Value.

Parameters:args – String with <addr> <type> <inst> <prop> <value> [ <indx> ] [ <priority> ]

BAC0.core.io.Write module

Write.py - creation of WriteProperty requests

Used while defining an app Example:

class BasicScript(WhoisIAm, WriteProperty)

Class:

WriteProperty()
    def write()
class BAC0.core.io.Write.WriteProperty[source]

Bases: object

Defines BACnet Write functions: WriteProperty [WritePropertyMultiple not supported]

build_wp_request(args, vendor_id=0)[source]
build_wpm_request(args, vendor_id=0, addr=None)[source]
clear_notes()

Clear notes object

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.core.io.Write | WriteProperty'
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

write(args, vendor_id=0, timeout=10)[source]

Build a WriteProperty request, wait for an answer, and return status [True if ok, False if not].

Parameters:args – String with <addr> <type> <inst> <prop> <value> [ <indx> ] - [ <priority> ]
Returns:return status [True if ok, False if not]

Example:

import BAC0
bacnet = BAC0.lite()
bacnet.write('2:5 analogValue 1 presentValue 100 - 8')

Direct the controller at (Network 2, address 5) to write 100 to the presentValues of its analogValue 1 (AV:1) at priority 8

writeMultiple(addr=None, args=None, vendor_id=0, timeout=10)[source]

Build a WritePropertyMultiple request, wait for an answer, and return status [True if ok, False if not].

Parameters:
  • addr – destination of request (ex. ‘2:3’ or ‘192.168.1.2’)
  • args – list of String with <type> <inst> <prop> <value> [ <indx> ] - [ <priority> ]
  • vendor_id – Mandatory for registered proprietary object and properties
  • timeout – used by IOCB to discard request if timeout reached
Returns:

return status [True if ok, False if not]

Example:

import BAC0
bacnet = BAC0.lite()
r = ['analogValue 1 presentValue 100','analogValue 2 presentValue 100','analogValue 3 presentValue 100 - 8','@obj_142 1 @prop_1042 True']
bacnet.writeMultiple(addr='2:5',args=r,vendor_id=842)
# or 
# bacnet.writeMultiple('2:5',r)

Module contents