1+ import logging
12import random
23import sys
34
@@ -27,8 +28,33 @@ class VirtualDevice:
2728 def __init__ (self , host : str = "0.0.0.0" ):
2829 parser = ConfigArgumentParser (description = __doc__ )
2930 args = parser .parse_args ()
31+ logging .basicConfig (level = logging .INFO )
32+
33+ _log .info ("Starting Virtual BACnet device" )
34+ _log .debug ("Parsed arguments: %s" , args )
35+ if not getattr (args , "ini" , None ):
36+ raise ValueError ("BACpypes configuration file (--ini) is required" )
37+ _log .info ("Using configuration ini: %s" , args .ini )
38+
3039 self .device = LocalDeviceObject (ini = args .ini )
40+ _log .info (
41+ "Created LocalDeviceObject name=%s identifier=%s" ,
42+ self .device .objectName ,
43+ getattr (self .device , "objectIdentifier" , None ),
44+ )
3145 self .application = VirtualBACnetApp (self .device , host )
46+ # ensure protocol services advertised match application capabilities
47+ # try:
48+ # self.device.protocolServicesSupported = (
49+ # self.application.get_services_supported()
50+ # )
51+ # except AttributeError:
52+ # _log.warning("Unable to set protocolServicesSupported on LocalDeviceObject")
53+ # else:
54+ # _log.debug(
55+ # "protocolServicesSupported: %s",
56+ # self.device.protocolServicesSupported,
57+ # )
3258
3359 # setup points
3460 self .points = {
@@ -54,9 +80,16 @@ def __init__(self, host: str = "0.0.0.0"):
5480 ),
5581 }
5682
57- for p in self .points .values ():
58- self .application .add_object (p )
83+ for name , point in self .points .items ():
84+ self .application .add_object (point )
85+ _log .info (
86+ "Registered BACnet object %s identifier=%s value=%s" ,
87+ name ,
88+ point .objectIdentifier ,
89+ getattr (point , "presentValue" , None ),
90+ )
5991
92+ _log .info ("Virtual device listening on host %s" , host )
6093 run ()
6194
6295
0 commit comments