Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianTremblay committed Sep 15, 2024
2 parents 66310aa + 6158c5c commit 48e50cd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
36 changes: 36 additions & 0 deletions BAC0/core/functions/Alias.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from typing import List, Tuple, Optional, Union

from bacpypes3.app import Application
from bacpypes3.npdu import RejectMessageToNetwork
Expand All @@ -8,6 +9,11 @@

from ...core.utils.notes import note_and_log

ROUTER_TUPLE_TYPE = Union[
Tuple[Union[Address, str], Union[int, List[int]]],
Tuple[Union[Address, str], Union[int, List[int]], Optional[int]],
]


@note_and_log
class Alias:
Expand Down Expand Up @@ -111,6 +117,36 @@ async def init_routing_table(self, address):
_app: Application = _this_application.app
await _app.nse.initialize_routing_table()

async def use_router(
self,
router_infos: Union[
Tuple[Union[Address, str], Union[int, List[int]]],
Tuple[Union[Address, str], Union[int, List[int]], Optional[int]],
] = (None, None, None),
):
address, dnets = router_infos[:2]
try:
snet = router_infos[2]
except IndexError:
snet = None
_this_application: BAC0Application = self.this_application
_app: Application = _this_application.app
if not isinstance(address, Address):
address = Address(address)
if not isinstance(dnets, list):
dnets = [dnets]
response = await self.who_is(address=address)
if response:
self._log.info(f"Router found at {address}")
self._log.info(
f"Adding router reference -> Snet : {snet} Addr : {address} dnets : {dnets}"
)
await _app.nsap.update_router_references(
snet=snet, address=address, dnets=dnets
)
else:
self._log.warning(f"Router not found at {address}")

async def what_is_network_number(self, destination=None, timeout=3):
"""
winn [ <addr> ]
Expand Down
2 changes: 1 addition & 1 deletion BAC0/infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
__email__ = "[email protected]"
__url__ = "https://github.com/ChristianTremblay/BAC0"
__download_url__ = "https://github.com/ChristianTremblay/BAC0/archive/master.zip"
__version__ = "2024.09.08"
__version__ = "2024.09.10"
__license__ = "LGPLv3"
2 changes: 1 addition & 1 deletion BAC0/scripts/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Base:

def __init__(
self,
localIPAddr: str = "127.0.0.1",
localIPAddr: Address = Address("127.0.0.1/24"),
networkNumber: int = None,
localObjName: str = "BAC0",
deviceId: int = None,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "BAC0"
version = "2024.09.13dev"
version = "2024.09.15dev"
description = "BACnet Scripting Framework for testing DDC Controls"
authors = [{name = "Christian Tremblay", email = "[email protected]"}]
readme = "README.md"
Expand Down

0 comments on commit 48e50cd

Please sign in to comment.