Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26 custom router info #39

Merged
merged 16 commits into from
Mar 30, 2024
Merged

26 custom router info #39

merged 16 commits into from
Mar 30, 2024

Conversation

JoelBender
Copy link
Owner

No description provided.

@JoelBender JoelBender linked an issue Mar 24, 2024 that may be closed by this pull request
@JoelBender
Copy link
Owner Author

@ChristianTremblay This branch changes the routing path and status methods to async functions. There should not be any changes to normal library user applications unless they have provided their own cache implementation. There is a sample application that goes along with this that uses Redis as a secondary cache. Please review this branch.

@ChristianTremblay
Copy link
Collaborator

BAC0.discover() gives me

2024-03-24 15:25:30,434 - INFO    | Found those networks : {1, 2, 303, 304, 10001, 211}
2024-03-24 15:25:30,436 - INFO    | Discovering network 304
2024-03-24 15:25:33,430 - INFO    | Discovering network 1
2024-03-24 15:25:36,440 - INFO    | Discovering network 2
2024-03-24 15:25:39,437 - INFO    | Discovering network 10001
2024-03-24 15:25:42,431 - INFO    | Discovering network 211
2024-03-24 15:25:45,441 - INFO    | Discovering network 303
2024-03-24 15:25:48,429 - INFO    | Discovery done. Found 13 devices on 6 BACnet networks.

bacnet.this_application.app.nsap.router_info_cache.debug_contents()
gives

 path_info = {
        (1, 304) : (<IPv4Address 192.168.211.4>, 0)
        (1, 211) : (<IPv4Address 192.168.211.4>, 0)
        (1, 10001) : (<IPv4Address 192.168.211.30>, 0)
        (1, 303) : (<IPv4Address 192.168.211.30>, 0)
        (1, 2) : (<IPv4Address 192.168.210.253>, 0)
        }
    router_dnets = {
        (1, <IPv4Address 192.168.211.4>) : {304, 211}
        (1, <IPv4Address 192.168.211.30>) : {10001, 303}
        (1, <IPv4Address 192.168.210.253>) : {2}
        }

This made me change the function I had
bacnet.routing_table

that now gives :

{'192.168.211.4': Source Network: 1 | Address: 192.168.211.4 | Destination Networks: {304, 211} | Path: [((1, 304), <RouterState.AVAILABLE: 0>), ((1, 211), <RouterState.AVAILABLE: 0>)],
 '192.168.210.253': Source Network: 1 | Address: 192.168.210.253 | Destination Networks: {2} | Path: [((1, 2), <RouterState.AVAILABLE: 0>)],
 '192.168.211.30': Source Network: 1 | Address: 192.168.211.30 | Destination Networks: {10001, 303} | Path: [((1, 10001), <RouterState.AVAILABLE: 0>), ((1, 303), <RouterState.AVAILABLE: 0>)]}

I created an enum for RouterState... maybe it would be a good thing on your side for clarity as the meaning of status is hidden as constant in the netservice module

@JoelBender
Copy link
Owner Author

There is already a RouterEntryStatus in basetypes that matches the embedded enumeration in BACnetRouterEntry in the standard. Good idea! That change should be pretty simple.

I also don't have a slot for performance-index, so I could make that a 3-element tuple or a dataclass with encode() and decode() methods. Humph.

@JoelBender
Copy link
Owner Author

I'm postponing performance-index again.

@JoelBender JoelBender merged commit 72eedb0 into main Mar 30, 2024
@JoelBender JoelBender deleted the 26-custom-router-info branch March 30, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom router info
2 participants