def main(): global this_device, this_application, this_console # 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=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) if _debug: _log.debug(" - this_device: %r", this_device) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value # make a simple application this_application = WhoIsIAmApplication( this_device, args.ini.address, Address(args.ini.foreignbbmd), int(args.ini.foreignttl), ) if _debug: _log.debug(" - this_application: %r", this_application) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make a console this_console = WhoIsIAmConsoleCmd() if _debug: _log.debug(" - this_console: %r", this_console) _log.debug("running") run() _log.debug("finally")
def createApplication(device): global applicationCount, applications try: #Defining Device threadName = 'app_' + str(applicationCount) localDevice = LocalDeviceObject( objectName=device.getObjectName(), objectIdentifier=int(device.getObjectIdentifier()), maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()), segmentationSupported=device.getSegmentationSupported(), vendorIdentifier=int(device.getVendorIdentifier()), ) pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 localDevice.protocolServicesSupported = pss.value application = Application(localDevice, device.getDeviceAddress()) applications.append(application) applicationThread = BACpypeThread(threadName) applicationThread.start() applicationCount += 1 except Exception, e: print "Error: doStart()" ErrorHandler(e,device)
def setup_device(self, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): _log.info('seg_supported ' + str(seg_supported)) _log.info('max_apdu_len ' + str(max_apdu_len)) _log.info('obj_id ' + str(obj_id)) _log.info('obj_name ' + str(obj_name)) _log.info('ven_id ' + str(ven_id)) this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING. pss = ServicesSupported() # set the property value to be just the bits this_device.protocolServicesSupported = pss.value self.this_application = BACnet_application(this_device, address) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True server_thread.start()
def createApplication(device): global applicationCount, applications try: #Defining Device threadName = 'app_' + str(applicationCount) localDevice = LocalDeviceObject( objectName=device.getObjectName(), objectIdentifier=int(device.getObjectIdentifier()), maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()), segmentationSupported=device.getSegmentationSupported(), vendorIdentifier=int(device.getVendorIdentifier()), ) pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 localDevice.protocolServicesSupported = pss.value application = Application(localDevice, device.getDeviceAddress()) applications.append(application) applicationThread = BACpypeThread(threadName) applicationThread.start() applicationCount += 1 except Exception, e: print "Error: doStart()" ErrorHandler(e, device)
def doStart(device): global this_application, this_device, applicationThread, has_started has_started = False try: #Defining Device this_device = LocalDeviceObject( objectName=device.getObjectName(), objectIdentifier=int(device.getObjectIdentifier()), maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()), segmentationSupported=device.getSegmentationSupported(), vendorIdentifier=int(device.getVendorIdentifier()), ) pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 this_device.protocolServicesSupported = pss.value this_application = Application(this_device, device.getDeviceAddress()) #Start BACpypes Thread applicationThread = BACpypeThread('BACPYPE-APP') applicationThread.start() has_started = True return has_started except Exception, e: ErrorHandler(e,device)
def doStart(device): global this_application, this_device, applicationThread, has_started has_started = False try: # Defining Device this_device = LocalDeviceObject( objectName=device.getObjectName(), objectIdentifier=int(device.getObjectIdentifier()), maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()), segmentationSupported=device.getSegmentationSupported(), vendorIdentifier=int(device.getVendorIdentifier()), ) pss = ServicesSupported() pss["whoIs"] = 1 pss["iAm"] = 1 pss["readProperty"] = 1 pss["writeProperty"] = 1 this_device.protocolServicesSupported = pss.value this_application = Application(this_device, device.getDeviceAddress()) # Start BACpypes Thread applicationThread = BACpypeThread("BACPYPE-APP") applicationThread.start() has_started = True return has_started except Exception, e: ErrorHandler(e, device)
def get_server_application(self): if _debug: DeviceAbstraction._debug(" - creating application") # make a device object this_device = LocalDeviceObject(objectName="Betelgeuse", objectIdentifier=args.device_id, maxApduLengthAccepted=1024, segmentationSupported="segmentedBoth", vendorIdentifier=15) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['readPropertyMultiple'] = 1 pss['writeProperty'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value # make a sample application this_application = ReadPropertyMultipleApplication( this_device, args.interface) registers = self.registers[('byte', True)] #Currently we don't actually enforce read only properties. for register in registers: if _debug: DeviceAbstraction._debug( " - creating object of type: %s, %i", register.object_type, register.instance_number) klass = get_object_class(register.object_type) ravo = klass(objectIdentifier=(register.object_type, register.instance_number), objectName=register.point_name) ravo.WriteProperty("presentValue", 0, direct=True) this_application.add_object(ravo) registers = self.registers[('byte', False)] for register in registers: if _debug: DeviceAbstraction._debug( " - creating object of type: %s, %i", register.object_type, register.instance_number) klass = get_object_class(register.object_type) ravo = klass(objectIdentifier=(register.object_type, register.instance_number), objectName=register.point_name) ravo.WriteProperty("presentValue", 0, direct=True) this_application.add_object(ravo) return this_application
def setup_device(self, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): global this_application #We use a singleton device if this_application is not None: return print 'seg_supported', seg_supported print 'max_apdu_len', max_apdu_len print 'obj_id', obj_id print 'obj_name', obj_name print 'ven_id', ven_id #Check to see if they gave a valid apdu length. if encode_max_apdu_response(max_apdu_len) is None: raise ValueError( 'Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476' ) this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING. pss = ServicesSupported() # set the property value to be just the bits this_device.protocolServicesSupported = pss.value this_application = BACnet_application(this_device, address) #We must use traditional python threads, otherwise the driver will # hang during startup while trying to scrape actuator values. # I think this is because the reactor hasn't started before we start trying # to use the other threads. #reactor.callInThread(bacpypes.core.run) #reactor.addSystemEventTrigger("before", "shutdown", bacpypes.core.stop) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True server_thread.start()
def get_server_application(self): if _debug: DeviceAbstraction._debug(" - creating application") # make a device object this_device = LocalDeviceObject( objectName="Betelgeuse", objectIdentifier=599, maxApduLengthAccepted=1024, segmentationSupported="segmentedBoth", vendorIdentifier=15 ) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['readPropertyMultiple'] = 1 pss['writeProperty'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value # make a sample application this_application = ReadPropertyMultipleApplication(this_device, args.interface) registers= self.registers[('byte',True)] #Currently we don't actually enforce read only properties. for register in registers: if _debug: DeviceAbstraction._debug(" - creating object of type: %s, %i", register.object_type, register.instance_number) klass = get_object_class(register.object_type) ravo = klass(objectIdentifier=(register.object_type, register.instance_number), objectName=register.point_name) ravo.WriteProperty("presentValue", 0, direct=True) this_application.add_object(ravo) registers= self.registers[('byte',False)] for register in registers: if _debug: DeviceAbstraction._debug(" - creating object of type: %s, %i", register.object_type, register.instance_number) klass = get_object_class(register.object_type) ravo = klass(objectIdentifier=(register.object_type, register.instance_number), objectName=register.point_name) ravo.WriteProperty("presentValue", 0, direct=True) this_application.add_object(ravo) return this_application
def main(): if _debug: main._debug("initialization") try: # parse the command line arguments args = ConfigArgumentParser(description=__doc__).parse_args() if _debug: main._debug("initialization") if _debug: main._debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject( objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=vendor_id, ) # make a sample application this_application = BIPSimpleApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make some objects ravo1 = VendorAVObject( objectIdentifier=(513, 1), objectName='Random1' ) if _debug: main._debug(" - ravo1: %r", ravo1) ravo2 = VendorAVObject( objectIdentifier=(513, 2), objectName='Random2' ) if _debug: main._debug(" - ravo2: %r", ravo2) # add it to the device this_application.add_object(ravo1) this_application.add_object(ravo2) if _debug: main._debug(" - object list: %r", this_device.objectList) if _debug: main._debug("running") run() except Exception as error: main._exception("an error has occurred: %s", error) finally: if _debug: main._debug("finally")
def setup_device(self, async_call, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): _log.info('seg_supported ' + str(seg_supported)) _log.info('max_apdu_len ' + str(max_apdu_len)) _log.info('obj_id ' + str(obj_id)) _log.info('obj_name ' + str(obj_name)) _log.info('ven_id ' + str(ven_id)) #Check to see if they gave a valid apdu length. if encode_max_apdu_response(max_apdu_len) is None: raise ValueError( 'Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476' .format(max_apdu_len)) this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names. pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value def i_am_callback(address, device_id, max_apdu_len, seg_supported, vendor_id): async_call.send(None, self.i_am, address, device_id, max_apdu_len, seg_supported, vendor_id) #i_am_callback('foo', 'bar', 'baz', 'foobar', 'foobaz') self.this_application = BACnet_application(i_am_callback, this_device, address) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True server_thread.start()
def main(): if _debug: main._debug("initialization") try: # parse the command line arguments args = ConfigArgumentParser(description=__doc__).parse_args() if _debug: main._debug("initialization") if _debug: main._debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject( objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=vendor_id, ) # make a sample application this_application = BIPSimpleApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make some objects ravo1 = VendorAVObject(objectIdentifier=(513, 1), objectName='Random1') if _debug: main._debug(" - ravo1: %r", ravo1) ravo2 = VendorAVObject(objectIdentifier=(513, 2), objectName='Random2') if _debug: main._debug(" - ravo2: %r", ravo2) # add it to the device this_application.add_object(ravo1) this_application.add_object(ravo2) if _debug: main._debug(" - object list: %r", this_device.objectList) if _debug: main._debug("running") run() except Exception as error: main._exception("an error has occurred: %s", error) finally: if _debug: main._debug("finally")
def setup_device(self, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): global this_application #We use a singleton device if this_application is not None: return print 'seg_supported', seg_supported print 'max_apdu_len', max_apdu_len print 'obj_id', obj_id print 'obj_name', obj_name print 'ven_id', ven_id #Check to see if they gave a valid apdu length. if encode_max_apdu_response(max_apdu_len) is None: raise ValueError('Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476') this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING. pss = ServicesSupported() # set the property value to be just the bits this_device.protocolServicesSupported = pss.value this_application = BACnet_application(this_device, address) #We must use traditional python threads, otherwise the driver will # hang during startup while trying to scrape actuator values. # I think this is because the reactor hasn't started before we start trying # to use the other threads. #reactor.callInThread(bacpypes.core.run) #reactor.addSystemEventTrigger("before", "shutdown", bacpypes.core.stop) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True server_thread.start()
def setup_device(self, async_call, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): _log.info('seg_supported '+str(seg_supported)) _log.info('max_apdu_len '+str(max_apdu_len)) _log.info('obj_id '+str(obj_id)) _log.info('obj_name '+str(obj_name)) _log.info('ven_id '+str(ven_id)) #Check to see if they gave a valid apdu length. if encode_max_apdu_response(max_apdu_len) is None: raise ValueError('Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476'.format(max_apdu_len)) this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names. pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value def i_am_callback(address, device_id, max_apdu_len, seg_supported, vendor_id): async_call.send(None, self.i_am, address, device_id, max_apdu_len, seg_supported, vendor_id) #i_am_callback('foo', 'bar', 'baz', 'foobar', 'foobaz') self.this_application = BACnet_application(i_am_callback, this_device, address) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True server_thread.start()
def main(): if _debug: main._debug("initialization") global this_application try: # parse the command line arguments args = ConfigArgumentParser(description=__doc__).parse_args() if _debug: main._debug("initialization") if _debug: main._debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject( objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) # make a simple application this_application = ReadPropertyApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make a console this_console = ReadWritePropertyConsoleCmd() main._debug("running") run() except Exception as error: main._exception("an error has occurred: %s", error) finally: main._debug("finally")
def setup_device(self, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): _log.info('seg_supported ' + str(seg_supported)) _log.info('max_apdu_len ' + str(max_apdu_len)) _log.info('obj_id ' + str(obj_id)) _log.info('obj_name ' + str(obj_name)) _log.info('ven_id ' + str(ven_id)) # Check to see if they gave a valid apdu length. if encode_max_apdu_response(max_apdu_len) is None: raise ValueError( 'Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476' .format(max_apdu_len)) this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING. pss = ServicesSupported() # set the property value to be just the bits this_device.protocolServicesSupported = pss.value self.this_application = BACnet_application(this_device, address) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True request = WhoIsRequest() request.pduDestination = GlobalBroadcast() server_thread.start()
def doStart(device): global this_application, this_device, applicationThread, request_addr, has_started has_started = True applicationThread = None try: #Defining Device this_device = LocalDeviceObject( #objectName="Name", objectName=device.getObjectName(), #objectIdentifier=2450, objectIdentifier=int(device.getObjectIdentifier()), maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()), #maxApduLenghtAccepted = int(device.getMaxApduLengthAccepted()), segmentationSupported=device.getSegmentationSupported(), #device.getSegmentationSupported(), vendorIdentifier=int(device.getVendorIdentifier()), #int(device.getVendorIdentifier()), ) #request_addr = "192.168.92.68" request_addr = device.getRequestAddress() print 'req Add: ' + request_addr pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 this_device.protocolServicesSupported = pss.value this_application = Application(this_device, device.getDeviceAddress()) print "this Addr:" + str(device.getDeviceAddress()) #Start BACpypes Thread applicationThread = BACpypeThread('BACPYPE-APP') applicationThread.start() except Exception, e: has_started = False print 'An error has occured: ' + str(e) + "\n"
def main(): if _debug: main._debug("initialization") global this_application try: # parse the command line arguments args = ConfigArgumentParser(description=__doc__).parse_args() if _debug: main._debug("initialization") if _debug: main._debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject( objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value # make a simple application this_application = ReadPropertyApplication(this_device, args.ini.address) this_console = ReadWritePropertyConsoleCmd() main._debug("running") run() except Exception, e: main._exception("an error has occurred: %s", e)
def doStart(device): global this_application, this_device, applicationThread, request_addr, has_started has_started = True try: #args = ConfigArgumentParser(description=__doc__).parse_args() #Defining Device this_device = LocalDeviceObject( objectName=device.getObjectName(), objectIdentifier=int(device.getObjectIdentifier()), maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()), segmentationSupported=device.getSegmentationSupported(), vendorIdentifier=int(device.getVendorIdentifier()), ) print request_addr = device.getRequestAddress() pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 this_device.protocolServicesSupported = pss.value this_application = Application(this_device, device.getDeviceAddress()) print "this Addr:" + str(device.getDeviceAddress()) #Start BACpypes Thread applicationThread = BACpypeThread('BACPYPE-APP') applicationThread.start() except Exception: has_started = False finally: #print "Finally\n" return has_started
def setup_device(self, address, max_apdu_len=1024, seg_supported='segmentedBoth', obj_id=599, obj_name='sMap BACnet driver', ven_id=15): print 'seg_supported', seg_supported print 'max_apdu_len', max_apdu_len print 'obj_id', obj_id print 'obj_name', obj_name print 'ven_id', ven_id #Check to see if they gave a valid apdu length. if encode_max_apdu_response(max_apdu_len) is None: raise ValueError('Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476') this_device = LocalDeviceObject( objectName=obj_name, objectIdentifier=obj_id, maxApduLengthAccepted=max_apdu_len, segmentationSupported=seg_supported, vendorIdentifier=ven_id, ) # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING. pss = ServicesSupported() # set the property value to be just the bits this_device.protocolServicesSupported = pss.value self.this_application = BACnet_application(this_device, address) server_thread = threading.Thread(target=bacpypes.core.run) # exit the BACnet App thread when the main thread terminates server_thread.daemon = True server_thread.start()
def __init__(self, config): if _debug: BACnetAggregator._debug("__init__ %r", config) # get local address from the config file laddr = config.get('BACpypes', 'address') # make a local device object local_device = \ LocalDeviceObject( objectName=config.get('BACpypes','objectName') , objectIdentifier=config.getint('BACpypes','objectIdentifier') , maxApduLengthAccepted=config.getint('BACpypes','maxApduLengthAccepted') , segmentationSupported=config.get('BACpypes','segmentationSupported') , vendorIdentifier=config.getint('BACpypes','vendorIdentifier') ) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 # set the property value to be just the bits local_device.protocolServicesSupported = pss.value # make a simple application BIPSimpleApplication.__init__(self, local_device, laddr) # create logger self.logger = BACnetDataLogger(self, config) self.loadKey() # keep track of requests to line up responses self._request = None # connect to local repo self.publisher = RepoSocketPublisher(12345) self.interval = 5 # in seconds
def setup_device(self, address, port): this_device = LocalDeviceObject( objectName="sMap BACnet driver", objectIdentifier=599, maxApduLengthAccepted=1024, segmentationSupported="segmentedBoth", vendorIdentifier=15, ) # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING. pss = ServicesSupported() # set the property value to be just the bits this_device.protocolServicesSupported = pss.value self.this_application = BACnet_application(this_device, address + ':' + str(port)) server_thread = threading.Thread(target=self.this_application.run_me) # exit the server thread when the main thread terminates server_thread.daemon = True server_thread.start()
objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) # make a sample application this_application = WhoHasIHaveApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value _log.debug("running") # run until stopped, ^C works run() print("----- Who Has -----") for (src, objname), count in sorted(who_has_counter.items()): print("%-20s %-30s %4d" % (src, objname, count)) print("") print("----- I Have -----") for (src, devid, objid, objname), count in sorted(i_have_counter.items()): print("%-20s %-20s %-20s %-20s %4d" % (src, devid, objid, objname, count))
objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 pss['readProperty'] = 1 pss['writeProperty'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value # make a simple application this_application = WhoIsIAmApplication(this_device, args.ini.address) # get the services supported services_supported = this_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know this_device.protocolServicesSupported = services_supported.value # make a console this_console = WhoIsIAmConsoleCmd() _log.debug("running")
# make a device object this_device = LocalDeviceObject( objectName=args.ini.objectname, objectIdentifier=int(args.ini.objectidentifier), maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted), segmentationSupported=args.ini.segmentationsupported, vendorIdentifier=int(args.ini.vendoridentifier), ) # build a bit string that knows about the bit names pss = ServicesSupported() pss['whoIs'] = 1 pss['iAm'] = 1 # set the property value to be just the bits this_device.protocolServicesSupported = pss.value # make a simple application this_application = WhoIsIAmApplication(this_device, args.ini.address) _log.debug("running") request = WhoIsRequest() if args.address is not None: request.pduDestination = Address(args.address) else: request.pduDestination = GlobalBroadcast() if args.range is not None: request.deviceInstanceRangeLowLimit = int(args.range[0]) request.deviceInstanceRangeHighLimit = int(args.range[1])
) # 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) print("objects: " + str(test_application.objectIdentifier)) # get the services supported services_supported = test_application.get_services_supported() if _debug: _log.debug(" - services_supported: %r", services_supported) # let the device object know test_device.protocolServicesSupported = services_supported.value # 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 = MatchingStateMachine() # bind everything together bind(test_application, test_asap, test_smap, test_server) # ==============================================================================