def __init__(self, ini_file, overriding_port: int = None): self.args = ConfigArgumentParser().parse_args(["--ini", ini_file]) #addr = Address(self.args.ini.address) #if overriding_port: # addr.addrPort = overriding_port #print('Address: {0}'.format(addr.addrPort)) if overriding_port: ip, port = self.args.ini['address'].split(':') self.args.ini['address'] = ip + ':' + str(overriding_port) self.this_device = LocalDeviceObject(ini=self.args.ini) BIPSimpleApplication.__init__(self, self.this_device, self.args.ini['address']) self.taskman = TaskManager() self.datatype_map = { 'b': Boolean, 'u': lambda x: Unsigned(int(x)), 'i': lambda x: Integer(int(x)), 'r': lambda x: Real(float(x)), 'd': lambda x: Double(float(x)), 'o': OctetString, 'c': CharacterString, 'bs': BitString, 'date': Date, 'time': Time, 'id': ObjectIdentifier, } thread_handle = threading.Thread(target=self.run_thread) thread_handle.daemon = True thread_handle.start()
def __init__(self, *args): """ Creation of the application. Adding properties to basic B/IP App. :param *args: local object device, local IP address See BAC0.scripts.BasicScript for more details. """ logging.getLogger("comtypes").setLevel(logging.INFO) log_debug("__init__ %r", args) self.localAddress = None BIPSimpleApplication.__init__(self, *args) # _lock will be used by read/write operation to wait for answer before # making another request self._lock = Lock() self._request = None self.value = None self.error = None self.values = [] self.i_am_counter = defaultdict(int) self.who_is_counter = defaultdict(int) self.ResponseQueue = Queue() if isinstance(self.localAddress, Address): self.local_unicast_tuple = self.localAddress.addrTuple self.local_broadcast_tuple = self.localAddress.addrBroadcastTuple else: self.local_unicast_tuple = ('', 47808) self.local_broadcast_tuple = ('255.255.255.255', 47808)
def __init__(self, *args): if _debug: WhoIsIAmApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) # keep track of requests to line up responses self._request = None
def __init__(self, point_list, *args): if _debug: ReadPointListApplication._debug("__init__ %r, %r", point_list, args) BIPSimpleApplication.__init__(self, *args) # turn the point list into a queue self.point_queue = deque(point_list)
def __init__( self, bacpypes_inifile, brickbacnet_config, sqlite_db, ): self.logger = logging.getLogger('bacnet_discovery') self.logger.setLevel(logging.WARNING) config = configparser.ConfigParser() config.read(bacpypes_inifile) config = config["BACpypes"] self.address_mask = config["address"] # TODO: What does this do? self.this_device = LocalDeviceObject( objectName=config["objectName"], objectIdentifier=int(config["objectIdentifier"]), maxApduLengthAccepted=int(config["maxApduLengthAccepted"]), segmentationSupported=config["segmentationSupported"], vendorIdentifier=int(config["vendorIdentifier"]), vendorName="brick-community", ) self.sqlite_db = sqlite_db BIPSimpleApplication.__init__(self, self.this_device, config["address"]) self.taskman = TaskManager() self.object_custom_fields = brickbacnet_config['object_custom_fields']
def __init__(self, *args): BIPSimpleApplication.__init__(Mock()) self.elementService = Mock() #self.ResponseQueue = Mock() #self.ResponseQueue.get.return_value = ([21, 'degreesCelcius'], Event()) iocb = IOCB() apdu = ReadPropertyMultipleACK(listOfReadAccessResults=[ ReadAccessResult( objectIdentifier=('analogValue', 1), listOfResults=[ ReadAccessResultElement( propertyIdentifier='presentValue', readResult=ReadAccessResultElementChoice( propertyValue=Any(Real(21.0)), )), ReadAccessResultElement( propertyIdentifier='units', readResult=ReadAccessResultElementChoice( propertyValue=Any(Enumerated(62)), )), ], ) ]) iocb.complete(apdu) self.request = Mock() self.request.return_value = iocb
def __init__(self, *args): BIPSimpleApplication.__init__(Mock()) self.elementService = Mock() self.ResponseQueue = Mock() self.ResponseQueue.get.return_value = (None, Event()) self.request = Mock() self.value = None
def __init__(self, *args): if _debug: ReadRangeApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) # keep track of requests to line up responses self._request = None
def __init__(self, *args): BIPSimpleApplication.__init__(Mock()) self.elementService = Mock() self.ResponseQueue = Mock() self.ResponseQueue.get.return_value = ([21, 'degreesCelcius'], Event()) self.request = Mock() self.value = None
def __init__(self, hmi, *args): self._debug = True self._hmi = hmi if self._debug: print("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) if self._debug: print("super called") # keep track of requests to line up responses self._request = None
def __init__(self,*args,**kwarg): self.userdata=None device=LocalDeviceObject(vendorIdentifier=47808,objectIdentifier=47808) print('BacnetAppInit',*args,**kwarg) BIPSimpleApplication.__init__(self,device,*args,**kwarg) #time.sleep(0.8)#等待bac run self.whoisback=None self.who_is({})
def __init__(self, *args): BIPSimpleApplication.__init__(self, *args) # assigning invoke identifiers self.nextInvokeID = 1 # keep track of requests to line up responses self.iocb = {}
def __init__(self, *args): if _debug: WebServerApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) # assigning invoke identifiers self.nextInvokeID = 1 # keep track of requests to line up responses self.iocb = {}
def __init__(self, point_list, *args): if _debug: ReadPointListApplication._debug("__init__ %r, %r", point_list, args) BIPSimpleApplication.__init__(self, *args) # turn the point list into a queue self.point_queue = deque(point_list) # make a list of the response values self.response_values = []
def __init__(self, interval, *args): if _debug: PrairieDog._debug("__init__ %r %r", interval, args) BIPSimpleApplication.__init__(self, *args) RecurringTask.__init__(self, interval * 1000) # no longer busy self.is_busy = False # install the task self.install_task()
def __init__( self, reader_address, reader_object_identifier, put_result_in_source_queue_fn: Callable[[str, str, Dict], None], disk_cache_filename=None, retry_count=10, ): self._thread = Thread(target=bacnet_run) # MetricQ Bacnet Run Thread self._thread.name = "MQBRT#{}".format(reader_address) bacnet_enable_sleeping() self._put_result_in_source_queue = put_result_in_source_queue_fn # cache for object properties # key is (device address, object type, object instance) # value is dict of property name and value self._disk_cache_filename = disk_cache_filename self._object_info_cache_lock = RLock() with self._object_info_cache_lock: self._object_info_cache: Dict[Tuple[str, str, int], Dict[str, Any]] = {} if disk_cache_filename: try: with open(disk_cache_filename) as disk_cache_file: self._object_info_cache = { _cachekey_str_to_tuple(key): value for key, value in json.load( disk_cache_file).items() } except (OSError, json.decoder.JSONDecodeError): logger.warning( "Can't read disk cache file. Starting with empty cache!", exc_info=True, ) self._retry_count = retry_count local_device_object = LocalDeviceObject( objectName="MetricQReader", objectIdentifier=reader_object_identifier, vendorIdentifier=15, maxApduLengthAccepted=1476, # 1024 segmentationSupported="segmentedBoth", ) BIPSimpleApplication.__init__( self, local_device_object, reader_address, deviceInfoCache=BetterDeviceInfoCache(), )
def __init__(self, point_list, *args): if _debug: ReadPointListApplication._debug("__init__ %r, %r", point_list, args) BIPSimpleApplication.__init__(self, *args) # keep track of requests to line up responses self._request = None # make a list of the response values self.response_values = [] # turn the point list into a queue self.point_queue = deque(point_list)
def __init__(self, *args): BIPSimpleApplication.__init__(self, *args) RecurringTask.__init__(self, 250) self.request_queue = Queue() # assigning invoke identifiers self.nextInvokeID = 1 # keep track of requests to line up responses self.iocb = {} self.install_task()
def __init__(self, device, hostname, args): BIPSimpleApplication.__init__(self, device, hostname) self.who_is_request = None self.credentials = args self.interval = args["whoisInterval"] self.low_limit = args["lowerDeviceIdLimit"] self.high_limit = args["upperDeviceIdLimit"] self.mqtt = None self.cb_device_client = None self.bacnet_devices = None self.bacnet_sensors = None self._init_cb()
def __init__(self, *args): BIPSimpleApplication.__init__(Mock()) self.elementService = Mock() #self.value = None iocb = IOCB() # Forging apdu response fake_apdu = ReadPropertyACK( objectIdentifier=('analogInput', 0), propertyIdentifier='presentValue', propertyValue=Any(Real(32)), ) iocb.complete(fake_apdu) self.request = Mock() self.request.return_value = iocb
def __init__(self, *args): # # スーパーコンストラクタ呼び出し # BIPSimpleApplication.__init__(self, *args) # # BACnet デバイスキャッシュ用 # self.device_map = {} # # IAmRequest を 受けたデバイスIDを管理するキュー # self.responseQueue = Queue()
def __init__(self, interval, *args): if _debug: PrairieDog._debug("__init__ %r, %r", interval, args) BIPSimpleApplication.__init__(self, *args) RecurringTask.__init__(self, interval * 1000) # keep track of requests to line up responses self._request = None # start out idle self.is_busy = False self.point_queue = deque() self.response_values = [] # install it self.install_task()
def __init__(self, interval, *args): BIPSimpleApplication.__init__(self, *args) RecurringTask.__init__(self, interval * 1000) # Configure IoT telemetry self.iot_broker = 'mqtt.googleapis.com' self.iot_broker_port = 8883 # Task Runner Status self.is_busy = False # Install task to queue self.install_task() # Bacnet point list self.bacnet_points = {}
def __init__(self, *args): ips = getIPs() device_address = ips[0] + "/24" # make a device object this_device = LocalDeviceObject( objectName="BEMOSS-PLUS", objectIdentifier=int(599), maxApduLengthAccepted=int(1024), segmentationSupported="segmentedBoth", vendorIdentifier=int(15), ) # make a simple application SynchronousApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) self.expect_confirmation = True
def __init__(self, *args): """Creation of the application. Adding properties to basic B/IP App. :param *args: local object device, local IP address See BAC0.scripts.BasicScript for more details. """ if _debug: ScriptApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) # keep track of requests to line up responses self._request = None self.value = None self.error = None self.values = [] self.i_am_counter = defaultdict(int) self.ResponseQueue = Queue()
def __init__(self, *args): if _debug: WhoIsIAmApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) # turn the point list into a queue self.point_queue = deque(point_list) # make a list of the response values self.response_values = [] # keep track of requests to line up responses self._request = None # list of the response values from "bacnet settings" (NET, BCP) self.response_bacset = [] # variable for Proxy IP self.proxyIP = "0.0.0.0"
def __init__(self, i_am_callback, forward_cov_callback, request_check_interval, *args): BIPSimpleApplication.__init__(self, *args) RecurringTask.__init__(self, request_check_interval) self.i_am_callback = i_am_callback self.forward_cov_callback = forward_cov_callback self.request_queue = Queue() # assigning invoke identifiers self.nextInvokeID = 1 # keep track of requests to line up responses self.iocb = {} # Tracking mechanism for matching COVNotifications to a COV subscriptionContext object self.sub_cov_contexts = {} self.cov_sub_process_ID = 1 self.install_task()
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 __init__(self, i_am_callback, send_cov_subscription_callback, forward_cov_callback, request_check_interval, *args): BIPSimpleApplication.__init__(self, *args) RecurringTask.__init__(self, request_check_interval) self.i_am_callback = i_am_callback self.send_cov_subscription_callback = send_cov_subscription_callback self.forward_cov_callback = forward_cov_callback self.request_queue = Queue() # assigning invoke identifiers self.nextInvokeID = 1 # keep track of requests to line up responses self.iocb = {} # Tracking mechanism for matching COVNotifications to a COV # subscriptionContext object self.sub_cov_contexts = {} self.cov_sub_process_ID = 1 self.install_task()
def __init__(self, *args): SynchronousApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) self.expect_confirmation = True
def __init__(self, *args): if _debug: ReadRangeApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args)
def __init__(self, *args): if _debug: SubscribeCOVApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args)
def __init__(self, device, ipAddress): # if _debug: ReadPropertyApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, device, ipAddress) # keep track of requests to line up responses self._request = None
def __init__(self, *args): if _debug: ReadPropertyApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args) # current property being read self.property_identifier = None
def __init__(self, local_address, routers): local_device_object = \ LocalDeviceObject(objectName='IIITD BACnet Controller', objectIdentifier=0) BIPSimpleApplication.__init__(self, local_device_object, local_address)
def __init__(self, device, address): print "Initializing BACpypes Service..." BIPSimpleApplication.__init__(self, device, address)
def __init__(self,*args,**kwarg): self.userdata=None BIPSimpleApplication.__init__(self,*args,**kwarg)
def __init__(self, *args, **kwargs): if _debug: ReadPropertyMultipleApplication._debug("__init__ %r %r", args, kwargs) BIPSimpleApplication.__init__(self, *args, **kwargs)
def __init__(self, device, address): if _debug: WhoHasIHaveApplication._debug("__init__ %r %r", device, address) BIPSimpleApplication.__init__(self, device, address)
def __init__(self, device, address): if _debug: SampleApplication._debug("__init__ %r %r", device, address) BIPSimpleApplication.__init__(self, device, address)
def __init__(self, *args): SynchronousApplication._debug("__init__ %r", args) BIPSimpleApplication.__init__(self, *args)
def __init__(self, device, address): print 'Initializing BACpypes Service...\n' BIPSimpleApplication.__init__(self, device, address) self.__response_value = None