def __init__(self, vlan_device: LocalDeviceObject, vlan_address: Address) -> None: if _debug: _VLANApplication._debug("__init__ %r %r", vlan_device, vlan_address) Application.__init__(self, localDevice=vlan_device, aseID=None) # include a application decoder self._asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self._smap = StateMachineAccessPoint(vlan_device) # the segmentation state machines need access to the same device # information cache as the application self._smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self._nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self._nse = NetworkServiceElement() bind(self._nse, self._nsap) # bind the top layers bind(self, self._asap, self._smap, self._nsap) # create a vlan node at the assigned address self._vlan_node = Node(vlan_address) # bind the stack to the node, no network number self._nsap.bind(self._vlan_node)
def __init__(self, vlan_device, vlan_address, aseID=None): if _debug: VLANApplication._debug("__init__ %r %r aseID=%r", vlan_device, vlan_address, aseID) Application.__init__(self, vlan_device, local_address, aseID) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(vlan_device) # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a vlan node at the assigned address self.vlan_node = Node(vlan_address) # bind the stack to the node, no network number self.nsap.bind(self.vlan_node)
def __init__(self, vlan_device, vlan_address, aseID=None): if _debug: VLANApplication._debug("__init__ %r %r aseID=%r", vlan_device, vlan_address, aseID) ApplicationIOController.__init__(self, vlan_device, vlan_address, aseID=aseID) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(vlan_device) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a vlan node at the assigned address self.vlan_node = Node(vlan_address) # bind the stack to the node, no network number self.nsap.bind(self.vlan_node, address=vlan_address) # keep track of requests to line up responses self._request = None if _debug: VLANApplication._debug(" - nsap.local_address: %r", self.nsap.local_address)
def __init__(self, address, vlan): if _debug: BIPSimpleApplicationLayerStateMachine._debug( "__init__ %r %r", address, vlan) # build a name, save the address self.name = "app @ %s" % (address, ) self.address = Address(address) # build a local device object local_device = TestDeviceObject( objectName=self.name, objectIdentifier=('device', 998), vendorIdentifier=999, ) # build an address and save it self.address = Address(address) if _debug: BIPSimpleApplicationLayerStateMachine._debug( " - address: %r", self.address) # continue with initialization ApplicationServiceElement.__init__(self) ClientStateMachine.__init__(self, name=local_device.objectName) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(local_device) # the segmentation state machines need access to some device # information cache, usually shared with the application self.smap.deviceInfoCache = DeviceInfoCache() # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = _NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # BACnet/IP interpreter self.bip = BIPSimple() self.annexj = AnnexJCodec() # fake multiplexer has a VLAN node in it self.mux = FauxMultiplexer(self.address, vlan) # bind the stack together bind(self.bip, self.annexj, self.mux) # bind the stack to the local network self.nsap.bind(self.bip)
def __init__(self, address, vlan): if _debug: BIPBBMDApplication._debug("__init__ %r %r", address, vlan) # build a name, save the address self.name = "app @ %s" % (address,) self.address = Address(address) if _debug: BIPBBMDApplication._debug(" - address: %r", self.address) # build a local device object local_device = TestDeviceObject( objectName=self.name, objectIdentifier=('device', 999), vendorIdentifier=999, ) # continue with initialization Application.__init__(self, local_device, self.address) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(local_device) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # BACnet/IP interpreter self.bip = BIPBBMD(self.address) self.annexj = AnnexJCodec() # build an address, full mask bdt_address = "%s/32:%d" % self.address.addrTuple if _debug: BIPBBMDNode._debug(" - bdt_address: %r", bdt_address) # add itself as the first entry in the BDT self.bip.add_peer(Address(bdt_address)) # fake multiplexer has a VLAN node in it self.mux = FauxMultiplexer(self.address, vlan) # bind the stack together bind(self.bip, self.annexj, self.mux) # bind the stack to the local network self.nsap.bind(self.bip)
def __init__(self, localDevice, localAddress, deviceInfoCache=None, aseID=None): if _debug: DiscoverApplication._debug( "__init__ %r %r deviceInfoCache=%r aseID=%r", localDevice, localAddress, deviceInfoCache, aseID) ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID) # local address might be useful for subclasses if isinstance(localAddress, Address): self.localAddress = localAddress else: self.localAddress = Address(localAddress) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(localDevice) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = DiscoverNetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a generic BIP stack, bound to the Annex J server # on the UDP multiplexer self.bip = BIPSimple() self.annexj = AnnexJCodec() self.mux = UDPMultiplexer(self.localAddress) # bind the bottom layers bind(self.bip, self.annexj, self.mux.annexJ) # bind the BIP stack to the network, no network number self.nsap.bind(self.bip, address=self.localAddress) # keep track of requests to line up responses self._request = None
def __init__(self, address, vlan): if _debug: ApplicationLayerStateMachine._debug("__init__ %r %r", address, vlan) # build a name, save the address self.name = "app @ %s" % (address, ) self.address = Address(address) # build a local device object local_device = TestDeviceObject( objectName=self.name, objectIdentifier=('device', int(address)), vendorIdentifier=999, ) # build an address and save it self.address = Address(address) if _debug: ApplicationLayerStateMachine._debug(" - address: %r", self.address) # continue with initialization ApplicationServiceElement.__init__(self) ClientStateMachine.__init__(self, name=local_device.objectName) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(local_device) # the segmentation state machines need access to some device # information cache, usually shared with the application self.smap.deviceInfoCache = DeviceInfoCache() # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a node, added to the network self.node = Node(self.address, vlan) if _debug: ApplicationLayerStateMachine._debug(" - node: %r", self.node) # bind the stack to the local network self.nsap.bind(self.node)
def __init__(self, objectName, deviceInstance, address, aseID=None): if _debug: VLANApplication._debug("__init__ %r %r %r aseID=%r", objectName, deviceInstance, address, aseID) # make an address vlan_address = Address(address) _log.debug(" - vlan_address: %r", vlan_address) # make a device object vlan_device = LocalDeviceObject( objectName=objectName, objectIdentifier=("device", deviceInstance), maxApduLengthAccepted=1024, segmentationSupported="noSegmentation", vendorIdentifier=15, ) _log.debug(" - vlan_device: %r", vlan_device) # continue with the initialization Application.__init__(self, vlan_device, vlan_address, aseID) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(vlan_device) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a vlan node at the assigned address self.vlan_node = Node(vlan_address) if _debug: VLANApplication._debug(" - vlan_node: %r", self.vlan_node) # bind the stack to the node, no network number self.nsap.bind(self.vlan_node) if _debug: VLANApplication._debug(" - node bound")
def __init__(self, localDevice, vlan): if _debug: ApplicationStateMachine._debug("__init__ %r %r", localDevice, vlan) # build an address and save it self.address = Address(localDevice.objectIdentifier[1]) if _debug: ApplicationStateMachine._debug(" - address: %r", self.address) # continue with initialization Application.__init__(self, localDevice, self.address) StateMachine.__init__(self, name=localDevice.objectName) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(localDevice) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a node, added to the network self.node = Node(self.address, vlan) # bind the network service to the node, no network number self.nsap.bind(self.node) # placeholder for the result block self.confirmed_private_result = None
def __init__(self, vlan_device, vlan_address, aseID=None, register_reader=None): if _debug: VLANApplication._debug("__init__ %r %r aseID=%r", vlan_device, vlan_address, aseID) Application.__init__(self, vlan_device, vlan_address, aseID) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(vlan_device) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a vlan node at the assigned address self.vlan_node = Node(vlan_address) # bind the stack to the node, no network number self.nsap.bind(self.vlan_node) # set register reader class that will look into block of registers for all associated slaves self.register_reader = register_reader
def __init__(self, vlan_device, vlan_address, aseID=None): if _debug: VLANConsoleApplication._debug("__init__ %r %r aseID=%r", vlan_device, vlan_address, aseID) global args # normal initialization ApplicationIOController.__init__(self, vlan_device, aseID=aseID) # optional read property multiple if args.rpm: self.add_capability(ReadWritePropertyMultipleServices) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(vlan_device) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a vlan node at the assigned address self.vlan_node = Node(vlan_address) # bind the stack to the node, no network number, no addresss self.nsap.bind(self.vlan_node)
def __init__(self, localDevice, localAddress, deviceInfoCache=None, aseID=None): if _debug: ReadPointListApplication._debug( "__init__ %r %r deviceInfoCache=%r aseID=%r", localDevice, localAddress, deviceInfoCache, aseID) global args Application.__init__(self, localDevice, deviceInfoCache, aseID=aseID) RecurringTask.__init__(self, args.interval * 1000) # local address might be useful for subclasses if isinstance(localAddress, Address): self.localAddress = localAddress else: self.localAddress = Address(localAddress) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(localDevice) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a generic BIP stack, bound to the Annex J server # on the UDP multiplexer self.bip = BIPSimple() self.annexj = AnnexJCodec() self.mux = UDPMultiplexer(self.localAddress) # bind the bottom layers bind(self.bip, self.annexj, self.mux.annexJ) # bind the BIP stack to the network, no network number self.nsap.bind(self.bip) # install the task self.install_task() # timer self.start_time = None # pending requests self.pending_requests = {}
def __init__( self, localDevice, localAddress, bbmdAddress=None, bbmdTTL=0, deviceInfoCache=None, aseID=None, iam_req=None, ): ApplicationIOController.__init__(self, localDevice, deviceInfoCache, aseID=aseID) self.iam_req = iam_req # local address might be useful for subclasses if isinstance(localAddress, Address): self.localAddress = localAddress else: self.localAddress = Address(localAddress) # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(localDevice) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElementWithRequests() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create a generic BIP stack, bound to the Annex J server # on the UDP multiplexer self.bip = BIPForeign(bbmdAddress, bbmdTTL) self.annexj = AnnexJCodec() self.mux = UDPMultiplexer(self.localAddress, noBroadcast=True) # bind the bottom layers bind(self.bip, self.annexj, self.mux.annexJ) # bind the NSAP to the stack, no network number self.nsap.bind(self.bip) self.i_am_counter = defaultdict(int) self.who_is_counter = defaultdict(int) # keep track of requests to line up responses self._request = None self._last_i_am_received = []
def __init__(self, localDevice, lan, localAddress, deviceInfoCache=None, aseID=None): if _debug: MQTTApplication._debug( "__init__ %r %r %r deviceInfoCache=%r aseID=%r", localDevice, lan, localAddress, deviceInfoCache, aseID) ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID) global args # local address might be useful for subclasses if isinstance(localAddress, str): localAddress = Address(localAddress) if len(localAddress.addrAddr) != bacpypes_mqtt.ADDRESS_LENGTH: raise ValueError("local address must be %d octets" % (bacpypes_mqtt.ADDRESS_LENGTH, )) self.localAddress = localAddress # include a application decoder self.asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation self.smap = StateMachineAccessPoint(localDevice) # the segmentation state machines need access to the same device # information cache as the application self.smap.deviceInfoCache = self.deviceInfoCache # a network service access point will be needed self.nsap = NetworkServiceAccessPoint() # give the NSAP a generic network layer service element self.nse = NetworkServiceElement() bind(self.nse, self.nsap) # bind the top layers bind(self, self.asap, self.smap, self.nsap) # create an MQTT client self.msap = bacpypes_mqtt.MQTTClient(lan, localAddress, args.host, port=args.port, keepalive=args.keepalive) # create a service element for the client self.mse = bacpypes_mqtt.MQTTServiceElement() bind(self.mse, self.msap) # bind the stack to the virtual network, no network number self.nsap.bind(self.msap) # keep track of requests to line up responses self._request = None
segmentationSupported='segmentedBoth', vendorIdentifier=15, ) # make a test address test_address = Address(1) # create a client state machine, trapped server, and bind them together test_application = TestApplication(test_device, test_address) # include a application decoder test_asap = ApplicationServiceAccessPoint() # pass the device object to the state machine access point so it # can know if it should support segmentation test_smap = StateMachineAccessPoint(test_device) # state machine test_server = ServerStateMachine() # bind everything together bind(test_application, test_asap, test_smap, test_server) # ============================================================================== who_is_request = WhoIsRequest( deviceInstanceRangeLowLimit=0, deviceInstanceRangeHighLimit=4194303, ) print("who_is_request") who_is_request.debug_contents()