BAC0.core.io package
Submodules
BAC0.core.io.IOExceptions module
IOExceptions.py - BAC0 application level exceptions
- exception BAC0.core.io.IOExceptions.ApplicationNotStarted[source]
Bases:
ExceptionApplication not started, no communication available.
- exception BAC0.core.io.IOExceptions.BokehServerCantStart[source]
Bases:
ExceptionRaised if Bokeh Server can’t be started automatically
- exception BAC0.core.io.IOExceptions.BufferOverflow[source]
Bases:
ExceptionBuffer capacity of device exceeded.
- exception BAC0.core.io.IOExceptions.NetworkInterfaceException[source]
Bases:
ExceptionThis exception covers different network related exc eption (like finding IP or subnet mask…)
- exception BAC0.core.io.IOExceptions.NoResponseFromController[source]
Bases:
ExceptionThis exception is used when trying to read or write and there is not answer.
- exception BAC0.core.io.IOExceptions.OutOfServiceNotSet[source]
Bases:
ExceptionThis 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:
ExceptionThis 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:
ValueErrorThis exception is used when trying to read a property.
- exception BAC0.core.io.IOExceptions.ReadPropertyMultipleException[source]
Bases:
ValueErrorThis exception is used when trying to read multiple properties.
- exception BAC0.core.io.IOExceptions.ReadRangeException[source]
Bases:
ValueErrorThis exception is used when trying to read a property.
- exception BAC0.core.io.IOExceptions.RemovedPointException[source]
Bases:
ExceptionWhen defining a device from DB it may not be identical to the actual device.
- exception BAC0.core.io.IOExceptions.UnrecognizedService[source]
Bases:
ExceptionThis exception is used when trying to read or write and there is not answer.
- exception BAC0.core.io.IOExceptions.WriteAccessDenied[source]
Bases:
ExceptionThis exception is used when trying to write and controller refuse it.
- exception BAC0.core.io.IOExceptions.WritePropertyCastError[source]
Bases:
ExceptionThis exception is used when trying to write to a property and a cast error occurs.
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:
objectDefines 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.
- async build_rpm_request(args: List[str], vendor_id: int = 0) ReadPropertyMultipleRequest[source]
Build request from args
- async build_rpm_request_from_dict(request_dict, vendor_id=0)[source]
Read property multiple allow to read a lot of properties with only one request The existing RPM function is made using a string that must be created using bacpypes console style and is hard to automate.
This new version will be an attempt to improve that:
_rpm = {'address': '11:2', 'objects': {'analogInput:1': ['presentValue', 'description', 'unit', 'objectList@idx:0'], 'analogInput:2': ['presentValue', 'description', 'unit', 'objectList@idx:0'], }, vendor_id: 842 }
- clear_notes()
Clear notes object
- log(note, *, level: str | int = 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
- property notes
Retrieve notes list as a Pandas Series
- async read(args: str, arr_index: int | None = None, vendor_id: int = 0, bacoid=None, timeout: int = 10, show_property_name: bool = False) Any[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).
- async readMultiple(args: str, request_dict=None, vendor_id: int = 0, timeout: int = 10, show_property_name: bool = False, from_regex=False) Dict | List[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).
- async readRange(args, range_params=None, arr_index=None, vendor_id=0, bacoid=None, timeout=10)[source]
Build a ReadRangeRequest request, wait for the answer and return the value
- Parameters:
args –
String with <addr> <type> <inst> <prop> [ <indx> ] :param range_params: parameters defining how to query the range, a list of five elements :returns: data read from device (list of LogRecords)
Range parameters (five elements):
- range_type (str): one of [‘p’, ‘s’, ‘t’]
’p’ (RangeByPosition) uses (first, count)
’s’ (RangeBySequenceNumber) uses (first, count)
’t’ (RangeByTime) filters by the given time and uses (date, time, count)
first (int): first element when querying by Position or Sequence Number
date (str): “YYYY-mm-DD” passed to bacpypes3.primitivedata.Date constructor
time (str): “HH:MM:SS” passed to bacpypes3.primitivedata.Time constructor
count (int): number of elements to return; negative numbers reverse the search direction
Example:
import BAC0 from bacpypes.basetypes import Date, Time myIPAddr = '192.168.1.10/24' bacnet = BAC0.connect(ip=myIPAddr) log_records = bacnet.readRange('2:5 trendLog 1 logBuffer', range_params=('t', None, '2023-05-12', '12:00:00', 2)) for log_record in log_records: print(Date(log_record.timestamp.date), Time(log_record.timestamp.time), log_record.logDatum.realValue) # Date(2023-5-12 fri) Time(12:10:00.00) 130.331 # Date(2023-5-12 fri) Time(12:20:00.00) 134.123 log_records = bacnet.readRange('2:5 trendLog 1 logBuffer', range_params=('t', None, '2023-05-12', '12:00:00', -2)) for log_record in log_records: print(Date(log_record.timestamp.date), Time(log_record.timestamp.time), log_record.logDatum.realValue) # Date(2023-5-12 fri) Time(11:40:00.00) 123.4 # Date(2023-5-12 fri) Time(11:50:00.00) 125.1213
- this_application: BAC0Application
BAC0.core.io.Simulate module
Simulate.py - simulate the value of controller I/O values
- class BAC0.core.io.Simulate.Simulation[source]
Bases:
objectGlobal informations regarding simulation
- async force_reliability(args)[source]
Set reliability property to NO_FAULT_DETECTED. Or else, in some cases, internal condition or previous reliability will prevent the value from being used internally.
- Parameters:
args – String with <addr> <type> <inst> <prop> <value> [ <indx> ] [ <priority> ]
- async 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> ]
- async 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>
- async sim(args, vendor_id: int = 0)[source]
Simulate I/O points by setting the Out_Of_Service property, then doing a WriteProperty to the point’s Present_Value. In the case of JCI controllers, we will also send a reliability “reliable” value to overcome the priority given to “communication error” over out of service.
- 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:
objectDefines BACnet Write functions: WriteProperty [WritePropertyMultiple not supported]
- clear_notes()
Clear notes object
- log(note, *, level: str | int = 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
- property notes
Retrieve notes list as a Pandas Series