diff --git a/BAC0/core/devices/local/factory.py b/BAC0/core/devices/local/factory.py index fa6be587..31dc330f 100644 --- a/BAC0/core/devices/local/factory.py +++ b/BAC0/core/devices/local/factory.py @@ -328,7 +328,7 @@ def analog(**kwargs): "properties": { "units": "percent", # "eventState": EventState(), - # "covIncrement": 0.15, + "covIncrement": 0.15, }, "presentValue": 0, } diff --git a/tests/manual_test_cov.py b/tests/manual_test_cov.py new file mode 100644 index 00000000..fd0032b0 --- /dev/null +++ b/tests/manual_test_cov.py @@ -0,0 +1,40 @@ +import asyncio +import random + +from bacpypes3.primitivedata import Real + +import BAC0 +from BAC0.core.devices.local.factory import analog_value +from BAC0.scripts.script_runner import run + +bacnet = None + + +async def main(): + async with BAC0.start() as bacnet: + device = BAC0.start(port=47809, deviceId=123) + + new_obj = analog_value(presentValue=0) + new_obj.add_objects_to_application(device) + + # From Server + dev_av = device.this_application.app.get_object_name("AV") + print(dev_av.covIncrement) + + # From client + ip = device.localIPAddr.addrTuple[0] + boid = device.Boid + bacnet._log.info("Defining device with poll 0 so the AV won't get updated") + dev = await BAC0.device(f"{ip}:47809", boid, bacnet, poll=0) + av = dev["AV"] + bacnet._log.info("Subscribing to AV") + await dev["AV"].subscribe_cov(lifetime=90) + + while True: + dev_av.presentValue = Real(random.randint(1, 100)) + bacnet._log.info(f"Setting AV to {dev_av.presentValue}") + await asyncio.sleep(5) + + +if __name__ == "__main__": + run(main, bacnet) diff --git a/tests/manualtest_cov.py b/tests/manualtest_cov.py deleted file mode 100644 index c5dc00c2..00000000 --- a/tests/manualtest_cov.py +++ /dev/null @@ -1,27 +0,0 @@ -import time - - -import BAC0 -from BAC0.core.devices.local.models import analog_value - -device = BAC0.lite("192.168.211.55/24", deviceId=123) -client = BAC0.lite("192.168.212.12/24") - -new_obj = analog_value() -new_obj.add_objects_to_application(device) - -# From Server -dev_av = device.this_application.get_object_name("AV") -print(dev_av.covIncrement) - -# From client -dev = dev = BAC0.device("192.168.211.55", 123, client, poll=0) -av = dev["AV"] -dev["AV"].subscribe_cov(lifetime=0) - -print() -while True: - print(dev["AV"]) - time.sleep(1) - dev["AV"] += 1 - time.sleep(1)