1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

change samples/DeviceDiscoveryForeign.py to be used in a script instead of from the console.

This commit is contained in:
Damien Picard 2022-07-08 11:12:01 +02:00
parent 014cb85341
commit 32e6778246

View File

@ -12,7 +12,7 @@ from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser from bacpypes.consolelogging import ConfigArgumentParser
from bacpypes.consolecmd import ConsoleCmd from bacpypes.consolecmd import ConsoleCmd
from bacpypes.core import run, enable_sleeping from bacpypes.core import run, enable_sleeping, deferred
from bacpypes.iocb import IOCB from bacpypes.iocb import IOCB
from bacpypes.pdu import Address, GlobalBroadcast from bacpypes.pdu import Address, GlobalBroadcast
@ -187,26 +187,27 @@ def main():
global this_device global this_device
global this_application global this_application
# 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 # make a device object
this_device = LocalDeviceObject(ini=args.ini) this_device = LocalDeviceObject(
objectName="BACSYS"
, objectIdentifier=123
, maxApduLengthAccepted=1024
, segmentationSupported="segmentedBoth"
, vendorIdentifier=264
)
if _debug: _log.debug(" - this_device: %r", this_device) if _debug: _log.debug(" - this_device: %r", this_device)
# make a simple application # make a simple application
this_application = DiscoveryApplication( this_application = DiscoveryApplication(
this_device, args.ini.address, this_device, Address("192.168.85.128:47810"),
Address(args.ini.foreignbbmd), Address("192.168.85.128:47808"),
int(args.ini.foreignttl), 30,
) )
#this_application.who_is()
# make a console # make a console
this_console = DiscoveryConsoleCmd() #this_console = DiscoveryConsoleCmd()
if _debug: _log.debug(" - this_console: %r", this_console) #if _debug: _log.debug(" - this_console: %r", this_console)
# enable sleeping will help with threads # enable sleeping will help with threads
enable_sleeping() enable_sleeping()
@ -215,6 +216,8 @@ def main():
run() run()
deferred(this_application.who_is, low_limit=None, high_limit=None, address=GlobalBroadcast())
_log.debug("fini") _log.debug("fini")
if __name__ == "__main__": if __name__ == "__main__":