Question regarding speeding up data collection #456
Replies: 5 comments 1 reply
-
what version of Python are you using? Python 3.12 and above is all asyncio based including BAC0 but older versions its all sync type code. |
Beta Was this translation helpful? Give feedback.
-
if you are using older Python (3.11 and below) where BAC0/bacpypes is synchronous, using asyncio for managing concurrency may not provide the intended benefits. Asynchronous programming is most effective when the underlying operations (like network I/O) can yield control back to the event loop, allowing other tasks to run concurrently. If the BACnet operations are synchronous and blocking, using asyncio will not be effective in improving concurrency or performance. Could consider using threading or multiprocessing to achieve concurrency using threading for concurrent queries. Haven't tested this code below but it maybe worth playing around with....I have also have ran into issues where the global BACnet discovery process doesnt exactly grab every BACnet device on the network especially if its older twisted pair communication BACnet MSTP networks where I ended up just hard coding BACnet device address and discovering from a different script. Also BACnet is UDP protocol based and my high level of understanding it (I am not a protocol wizard)... it is not like TCP based where there is a handshake and multiple checks between client/server devices that data has transferred properly but I think there is Acknowledged BACnet message services. I think people generally using the words "polling" or "discovered" or "offline/online", the words "connected" and "disconnected" is confusing to me even though BAC0 uses it but UDP by nature is a connectionless protocol.
|
Beta Was this translation helpful? Give feedback.
-
Thank you @bbartling! Appreciate it!
|
Beta Was this translation helpful? Give feedback.
-
@ChristianTremblay. @bbartling Apologies, just wanted to ask if I could create as many controllers or is there a limit. So in my code below, I am creating a controller for every device, therefore was just wondering if say there are 300 devices, will it be okay? this code works perfectly but I am just worried in case there are more devices.
|
Beta Was this translation helpful? Give feedback.
-
To work with Python 3.12, you need to use the asynchronous version of BAC0 (see async branch) here is a small example of what you could use to generate the devices discovered
then once done
|
Beta Was this translation helpful? Give feedback.
-
Dear @ChristianTremblay,
Thank you for all your work on BAC0. I was working on collecting BACnet data from devices but speeding things up using asyncio or threading. However, the issue is that the controller disconnects and reconnects every iteration (I understand it kills the process due to sleep). When I define the controller outside such as in the code below, the points are not updated and there is a noResponse warning from the controller.
My ultimate aim is to collect data that is changing from multiple BACnet devices in a faster way so that I can collect all data regularly (say every minute). This is also assuming I want to collect all the properties of the BACnet devices. I was just wondering if there was any possible method to refresh or update the points every iteration. If not, is there any other way?
I also understand that the BACnet data is meant to be polled to collect data. I was wondering if polling and retrieving the history was a better way than this? Would it be able to collect many points (In thousands) quickly (within a minute)? And ultimately, can that be integrated into using asyncio? I really appreciate it thank you!
Edit: I have also tried adding
point.update_bacnet_properties
to try and retrieve the new data but while the new data updates, every iteration there are some warnings for no response from controller and takes much longer.Edit: Tried it on an actual device with scheduler! Seems to work. Thank you so much!
Beta Was this translation helpful? Give feedback.
All reactions