Skip to content

Commit

Permalink
Migrated and improved manual_test_cov which leads to including a defa…
Browse files Browse the repository at this point in the history
…ult value of 0.15 in covIncrment for analog values in the factory... we don't want None there as it leads to errors when someone register
  • Loading branch information
ChristianTremblay committed Sep 16, 2024
1 parent bf1cbde commit 71d504f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion BAC0/core/devices/local/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def analog(**kwargs):
"properties": {
"units": "percent",
# "eventState": EventState(),
# "covIncrement": 0.15,
"covIncrement": 0.15,
},
"presentValue": 0,
}
Expand Down
40 changes: 40 additions & 0 deletions tests/manual_test_cov.py
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 0 additions & 27 deletions tests/manualtest_cov.py

This file was deleted.

0 comments on commit 71d504f

Please sign in to comment.