Created
August 22, 2021 06:09
-
-
Save JoelBender/dad7e16c6afc8b5485ca97eb052086d7 to your computer and use it in GitHub Desktop.
GroupObject Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
This sample application shows how to create a GroupObject. | |
""" | |
import os | |
import random | |
from bacpypes.debugging import bacpypes_debugging, ModuleLogger | |
from bacpypes.consolelogging import ConfigArgumentParser | |
from bacpypes.core import run | |
from bacpypes.primitivedata import Real | |
from bacpypes.apdu import ReadAccessSpecification, PropertyReference | |
from bacpypes.object import AnalogValueObject, GroupObject | |
from bacpypes.errors import ExecutionError | |
from bacpypes.app import BIPSimpleApplication | |
from bacpypes.local.device import LocalDeviceObject | |
# some debugging | |
_debug = 0 | |
_log = ModuleLogger(globals()) | |
# | |
# __main__ | |
# | |
def main(): | |
# parse the command line arguments | |
args = ConfigArgumentParser(description=__doc__).parse_args() | |
if _debug: | |
_log.debug("initialization") | |
if _debug: | |
_log.debug(" - args: %r", args) | |
# make a device object | |
this_device = LocalDeviceObject( | |
objectName=args.ini.objectname, | |
objectIdentifier=("device", int(args.ini.objectidentifier)), | |
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), | |
segmentationSupported=args.ini.segmentationsupported, | |
vendorIdentifier=int(args.ini.vendoridentifier), | |
) | |
# make a sample application | |
this_application = BIPSimpleApplication(this_device, args.ini.address) | |
# make an analog value object | |
analog_value_1 = AnalogValueObject( | |
objectIdentifier=("analogValue", 1), | |
objectName="AVO1", | |
) | |
_log.debug(" - analog_value_1: %r", analog_value_1) | |
this_application.add_object(analog_value_1) | |
# make a group object that references the analog value object | |
group_1 = GroupObject( | |
objectIdentifier=("group", 1), | |
objectName="GO1", | |
description="Group Object Description", | |
listOfGroupMembers=[ | |
ReadAccessSpecification( | |
objectIdentifier=("analogValue", 1), | |
listOfPropertyReferences=[ | |
PropertyReference(propertyIdentifier="presentValue") | |
], | |
) | |
], | |
) | |
_log.debug(" - group_1: %r", group_1) | |
this_application.add_object(group_1) | |
# make sure they are all there | |
_log.debug(" - object list: %r", this_device.objectList) | |
_log.debug("running") | |
run() | |
_log.debug("fini") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment