Skip to content

Commit

Permalink
Transition to complete async using bacpypes3. Drop support for web ap…
Browse files Browse the repository at this point in the history
…p. Drop support for bacpypes. As BAC0 wouldn't work with Python 3.12 and over, and will not support 2 different versions. Old modules are in temporary legacy folders to give me time to implement what is missing in async.
  • Loading branch information
ChristianTremblay committed Jan 8, 2024
1 parent 4d8fd90 commit 5bcd3df
Show file tree
Hide file tree
Showing 171 changed files with 5,716 additions and 23,789 deletions.
32 changes: 4 additions & 28 deletions BAC0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

try:
import bacpypes
import bacpypes3
except ImportError:
# Using print here or setup.py will fail
print("=" * 80)
Expand All @@ -15,28 +15,15 @@
try:
from . import core, tasks
from .core.devices.Device import Device as device
from .core.devices.AsyncDevice import ADevice
from .core.devices.Device import DeviceLoad as load
from .core.devices.Trends import TrendLog as TrendLog
from .core.utils.notes import update_log_level as log_level
from .infos import __version__ as version
from .scripts.Base import Base
from .scripts.AsyncBase import AsyncBase
from .tasks.Devices import AddDevice as add_device
from .tasks.Match import Match as match
from .tasks.Poll import SimplePoll as poll

# To be able to use the complete version pandas, flask and bokeh must be installed.
try:
import bokeh
import flask
import flask_bootstrap
import pandas

_COMPLETE = True
except ImportError:
_COMPLETE = False

try:
#
import os
Expand All @@ -48,21 +35,12 @@
except ImportError:
print("You need to pip install python-dotenv to use your .env file")

from .scripts.Lite import Lite as lite
from .scripts.Async import Async as Async
from .scripts.Lite import Lite as lite # to maintain compatibility with old code

if _COMPLETE:
from .scripts.Complete import Complete as gui

connect = gui
else:
connect = lite # type: ignore[assignment, misc]
web = lambda: print(
"All features not available to run BAC0.web(). Some modules are missing (flask, flask-bootstrap, bokeh, pandas). See docs for details. To start BAC0, use BAC0.lite()"
)
# from .scripts.Lite import Lite as app

# Import proprietary classes
from .core.proprietary_objects import jci
# from .core.proprietary_objects.legacy import jci

except ImportError as error:
print("=" * 80)
Expand All @@ -74,5 +52,3 @@
print("\nDiscard this message if you are actually installing BAC0.")
print("=" * 80)
# Probably installing the app...

ASYNC = False
1 change: 0 additions & 1 deletion BAC0/core/app/asyncApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from typing import Coroutine
import asyncio
from asyncio import Future, AbstractEventLoop
from threading import Thread


class BAC0Application(Application):
Expand Down
123 changes: 123 additions & 0 deletions BAC0/core/app/device.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"BACpypes": {
"backup_count": 5,
"color": false,
"cov_lifetime": 60,
"debug": [],
"debug_file": "",
"max_bytes": 1048576,
"route_aware": false
},
"application": [
{
"active-cov-subscriptions": [],
"apdu-segment-timeout": 1000,
"apdu-timeout": 3000,
"application-software-version": "1.0",
"database-revision": 1,
"device-address-binding": [],
"firmware-revision": "N/A",
"local-date": "2023-10-08",
"local-time": "22:15:26.22",
"max-apdu-length-accepted": 1024,
"max-segments-accepted": 16,
"model-name": "N/A",
"number-of-apdu-retries": 3,
"object-identifier": "device,999",
"object-list": [
"device,999",
"network-port,1"
],
"object-name": "BAC0",
"object-type": "device",
"property-list": [
"object-identifier",
"object-name",
"object-type",
"property-list",
"system-status",
"vendor-name",
"vendor-identifier",
"model-name",
"firmware-revision",
"application-software-version",
"protocol-version",
"protocol-revision",
"protocol-services-supported",
"protocol-object-types-supported",
"object-list",
"max-apdu-length-accepted",
"segmentation-supported",
"max-segments-accepted",
"local-time",
"local-date",
"apdu-segment-timeout",
"apdu-timeout",
"number-of-apdu-retries",
"device-address-binding",
"database-revision",
"active-cov-subscriptions",
"status-flags"
],
"protocol-object-types-supported": [],
"protocol-revision": 22,
"protocol-services-supported": [
"acknowledge-alarm",
"confirmed-cov-notification",
"confirmed-event-notification",
"subscribe-cov",
"atomic-write-file",
"add-list-element",
"read-property",
"read-property-multiple",
"write-property",
"write-property-multiple"
],
"protocol-version": 1,
"segmentation-supported": "segmented-both",
"status-flags": [],
"system-status": "operational",
"vendor-identifier": 842,
"vendor-name": "Servisys inc."
},
{
"bacnet-ip-mode": "normal",
"bacnet-ip-udp-port": 47808,
"changes-pending": false,
"ip-address": "192.168.211.208",
"ip-subnet-mask": "255.255.255.0",
"link-speed": 0.0,
"mac-address": "c0a8d3d0bac0",
"network-number": 1,
"network-number-quality": "unknown",
"network-type": "ipv4",
"object-identifier": "network-port,1",
"object-name": "NetworkPort-1",
"object-type": "network-port",
"out-of-service": false,
"property-list": [
"object-identifier",
"object-name",
"object-type",
"property-list",
"status-flags",
"reliability",
"out-of-service",
"network-type",
"protocol-level",
"network-number",
"network-number-quality",
"changes-pending",
"mac-address",
"link-speed",
"bacnet-ip-mode",
"ip-address",
"bacnet-ip-udp-port",
"ip-subnet-mask"
],
"protocol-level": "bacnet-application",
"reliability": "no-fault-detected",
"status-flags": []
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
ReadWritePropertyServices,
)

from ..functions.Discover import NetworkServiceElementWithRequests
from ...functions.Discover import NetworkServiceElementWithRequests

# --- this application's modules ---
from ..utils.notes import note_and_log
from ...utils.notes import note_and_log

# ------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 5bcd3df

Please sign in to comment.