BAC0.core.functions package

Submodules

BAC0.core.functions.DeviceCommunicationControl module

Reinitialize.py - creation of ReinitializeDeviceRequest

class BAC0.core.functions.DeviceCommunicationControl.DeviceCommunicationControl[source]

Bases: object

Mixin to support DeviceCommunicationControl from BAC0 to other devices

clear_notes()

Clear notes object

dcc(address=None, duration=None, password=None, state=None)[source]

Will send DeviceCommunicationControl request

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.functions.DeviceCommunicationControl | DeviceCommunicationControl'
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

BAC0.core.functions.Discover module

Discover.py

Classes needed to make discovering functions on a BACnet network

class BAC0.core.functions.Discover.Discover[source]

Bases: object

Define BACnet WhoIs and IAm functions.

clear_notes()

Clear notes object

iam(destination=None)[source]

Build an IAm response. IAm are sent in response to a WhoIs request that; matches our device ID, whose device range includes us, or is a broadcast. Content is defined by the script (deviceId, vendor, etc…)

Returns:bool

Example:

iam()
init_routing_table(address)[source]

irt <addr>

Send an empty Initialize-Routing-Table message to an address, a router will return an acknowledgement with its routing table configuration.

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.functions.Discover | Discover'
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

what_is_network_number(destination=None)[source]

winn [ <addr> ]

Send a What-Is-Network-Number message. If the address is unspecified the message is locally broadcast.

whohas(object_id=None, object_name=None, instance_range_low_limit=0, instance_range_high_limit=4194303, destination=None, global_broadcast=False)[source]

Object ID : analogInput:1 Object Name : string Instance Range Low Limit : 0 Instance Range High Limit : 4194303 destination (optional) : If empty, local broadcast will be used. global_broadcast : False

whois(*args, global_broadcast=False, destination=None)[source]

Build a WhoIs request

Parameters:args – string built as [ <addr>] [ <lolimit> <hilimit> ] optional
Returns:discoveredDevices as a defaultdict(int)

Example:

whois(global_broadcast=True) # WhoIs broadcast globally.  Every device will respond with an IAm
whois('2:5')                 # WhoIs looking for the device at (Network 2, Address 5)
whois('10 1000')             # WhoIs looking for devices in the ID range (10 - 1000)
whois_router_to_network(network=None, *, destination=None)[source]
class BAC0.core.functions.Discover.NetworkServiceElementWithRequests[source]

Bases: bacpypes.iocb.IOController, bacpypes.netservice.NetworkServiceElement

This class will add the capability to send requests at network level And capability to read responses for NPDU Deals with IOCB so the request can be deferred to task manager

clear_notes()

Clear notes object

confirmation(adapter, npdu)[source]
indication(adapter, npdu)[source]
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.functions.Discover | NetworkServiceElementWithRequests'
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

process_io(iocb)[source]

Figure out how to respond to this request. This must be provided by the derived class.

request(arg)[source]
response(adapter, npdu)[source]

BAC0.core.functions.GetIPAddr module

Utility function to retrieve a functionnal IP and a correct broadcast IP address. Goal : not use 255.255.255.255 as a broadcast IP address as it is not accepted by every devices (>3.8.38.1 bacnet.jar of Tridium Jace for example)

class BAC0.core.functions.GetIPAddr.HostIP(port: Optional[int] = None)[source]

Bases: object

Special class to identify host IP informations

address

IP Address using bacpypes Address format

clear_notes()

Clear notes object

ip_address

IP Address/subnet

ip_address_subnet

IP Address/subnet

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.functions.GetIPAddr | HostIP'
mask

Subnet mask

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

port

IP Port used

BAC0.core.functions.GetIPAddr.validate_ip_address(ip: bacpypes.pdu.Address) → bool[source]

BAC0.core.functions.Reinitialize module

Reinitialize.py - creation of ReinitializeDeviceRequest

class BAC0.core.functions.Reinitialize.Reinitialize[source]

Bases: object

Mixin to support Reinitialize from BAC0 to other devices

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.functions.Reinitialize | Reinitialize'
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

reinitialize(address=None, password=None, state='coldstart')[source]

Will send reinitialize request

BAC0.core.functions.TimeSync module

TimeSync.py - creation of time synch requests

class BAC0.core.functions.TimeSync.TimeHandler(tz: str = 'America/Montreal')[source]

Bases: object

This class will deal with Time / Timezone related features To deal with DateTime Value correctly we need to be aware of timezone.

is_dst() → bool[source]
local_date()[source]
local_time()[source]
now
set_timezone(tz: str) → None[source]
utcOffset() → float[source]

Returns UTC offset in minutes

class BAC0.core.functions.TimeSync.TimeSync[source]

Bases: object

Mixin to support Time Synchronisation from BAC0 to other devices

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.functions.TimeSync | TimeSync'
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

time_sync(destination=None, datetime=None, UTC=False)[source]

Take local time and send it to devices. User can also provide a datetime value (constructed following bacpypes.basetypes.Datetime format).

To create a DateTime

from bacpypes.basetypes import DateTime
from bacpypes.primitivedata import Date, Time

# Create date and time
_date = Date('2019-08-05')
_time = Time('16:45')

# Create Datetime
_datetime = DateTime(date=_date.value, time=_time.value)

# Pass this to the function
bacnet.time_sync(datetime=_datetime)

Module contents