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

Develop #303

Merged
merged 77 commits into from Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
2abcd80
Update sql.py
kushan-26 Mar 5, 2021
04ee67b
Check that the returned value is not None
snuids May 14, 2021
1b9af78
Improvement from issue #261
ChristianTremblay May 28, 2021
2f83aba
Doc : How to specify deviceId
ChristianTremblay May 29, 2021
1a20a2e
Black barfing over whitespaces
ChristianTremblay May 29, 2021
13055d0
Adding calendar as per issuer #258. Made calendar and Schedule be ver…
ChristianTremblay May 29, 2021
8ffe39a
Bumping dev version
ChristianTremblay May 29, 2021
cb05a7a
Check permision on write to file even if .BAC0 directory exists
HubertAPO Jul 7, 2021
2e87153
Merge pull request #264 from kushan-26/patch-1
ChristianTremblay Jul 23, 2021
ec3bbae
remove instance override for analog points
Jul 27, 2021
bc056e6
Merge branch 'develop' into master
ChristianTremblay Jul 28, 2021
c363d02
Merge pull request #288 from igloodan/master
ChristianTremblay Jul 28, 2021
6d80de7
Update infos.py
ChristianTremblay Jul 28, 2021
cc35bfe
Merge branch 'develop' into master
ChristianTremblay Jul 28, 2021
fef37bf
Merge pull request #282 from EddieTheHead/master
ChristianTremblay Jul 28, 2021
9e5ab88
Update infos.py
ChristianTremblay Jul 28, 2021
12414cf
Merge pull request #276 from snuids/master
ChristianTremblay Jul 28, 2021
d3b3f50
Adding support for dotenv. Actually used for InfluxDB
ChristianTremblay Jul 28, 2021
f7cb9db
Folder SQL renamed to db, will make more sense
ChristianTremblay Jul 28, 2021
33ac6f1
Making timestamps timezone aware
ChristianTremblay Jul 28, 2021
09e1cf8
InfluxDB class creation
ChristianTremblay Jul 28, 2021
ad1168f
Unused import
ChristianTremblay Jul 28, 2021
cad2662
Documentation started
ChristianTremblay Jul 28, 2021
58716e4
Bumping version
ChristianTremblay Jul 28, 2021
8b30102
Merging InfluxDB with develop
ChristianTremblay Jul 28, 2021
b392901
File saving issue for infos.py
ChristianTremblay Jul 28, 2021
7c0a00f
Update test.yml
ChristianTremblay Jul 28, 2021
793f2cc
Prevents app from failing if influxdb_client is not installed
ChristianTremblay Jul 28, 2021
dba7583
Black
ChristianTremblay Jul 28, 2021
8771500
Issue with PR#264. Need some investigation, For now I removed line 106
ChristianTremblay Jul 28, 2021
4414efd
Merge branch 'develop' of github.com:ChristianTremblay/BAC0 into develop
ChristianTremblay Jul 28, 2021
be4b37a
Changed my mind on Record ID. Really need them to be unique and the o…
ChristianTremblay Jul 28, 2021
c99f3f6
Trying to find a solution to issue#291. I want to keep the string val…
ChristianTremblay Jul 28, 2021
ee373c5
Fixing bugs with InfluxDB implementation where data is not written at…
ChristianTremblay Jul 30, 2021
bfac9f1
Modifications required to connect to InfluxDB 1.8 without token. Now …
ChristianTremblay Jul 30, 2021
dc646e4
Not allowing saving to SQL if Pandas is not installed. Eventually, I …
ChristianTremblay Jul 30, 2021
37f24e6
Trying to give a little resilience to BAC0 when devices get disconnected
ChristianTremblay Aug 25, 2021
2223094
Working on resilience...
ChristianTremblay Sep 5, 2021
8d7fe7d
Resume polling on reconnection
ChristianTremblay Sep 6, 2021
43af818
Loading env in curretn working directory...will it work ?
ChristianTremblay Sep 6, 2021
8ff1350
Loading env in curretn working directory...will it work ?
ChristianTremblay Sep 6, 2021
75e5d86
Merge branch 'develop' of github.com:ChristianTremblay/BAC0 into develop
ChristianTremblay Sep 6, 2021
d16e853
Loading env in curretn working directory...will it work ?
ChristianTremblay Sep 6, 2021
3640637
Loading env in current working directory...gave specific directory to…
ChristianTremblay Sep 6, 2021
791a1b7
Missing variables in device.properties
ChristianTremblay Sep 6, 2021
abaf2e8
New ping function...
ChristianTremblay Sep 7, 2021
9de2203
Skip polling if ping failed
ChristianTremblay Sep 7, 2021
a09cc9c
Propoerty changed for ping_failures as it counts failures
ChristianTremblay Sep 7, 2021
e920fe5
fix iterator error when discovering slow networks
gnmerritt Sep 8, 2021
cf09565
Merge pull request #295 from gnmerritt/slow-networks-crash
ChristianTremblay Sep 9, 2021
e5c0321
Typo in log.error
ChristianTremblay Sep 10, 2021
d0bc61b
Clearer error message on value error in polling
ChristianTremblay Sep 10, 2021
6fb95a4
Removing deprecated files
ChristianTremblay Sep 14, 2021
2ded614
Jupyter folder and example are so out of date...they must go
ChristianTremblay Sep 14, 2021
bee2236
A new samples folder that will store some code examples
ChristianTremblay Sep 14, 2021
9a5876c
Update Device.py
kushan-26 Oct 12, 2021
e68543a
Merge pull request #298 from kushan-26/master
ChristianTremblay Oct 14, 2021
3b9780b
Possibility to add more tags to points... allows InfluxDB records wit…
ChristianTremblay Oct 18, 2021
d9d1ea9
Black
ChristianTremblay Oct 18, 2021
34d873a
Black
ChristianTremblay Oct 18, 2021
e0637d3
Show property name is a better name for bacnet properties functions
ChristianTremblay Oct 18, 2021
693466f
JCI provided a document with all vendor properties detailed...so I iu…
ChristianTremblay Oct 18, 2021
11e0eb3
Support for our own proprietary objects and properties
ChristianTremblay Oct 18, 2021
d16ee55
This was a request for a user... make sense to put in the samples
ChristianTremblay Oct 18, 2021
73eb559
Bumping dev version
ChristianTremblay Oct 18, 2021
85262d3
Merge branch 'develop' of github.com:ChristianTremblay/BAC0 into develop
ChristianTremblay Oct 18, 2021
c8a78bc
- BBMD mode was lacking broadcast in
ChristianTremblay Oct 18, 2021
3c7a872
Working on DateTimeValue support
ChristianTremblay Oct 22, 2021
e159782
Adding support to create XML files requires for Johnson Controls TAD …
ChristianTremblay Oct 22, 2021
ee15925
Work to improve BBMD. Modified default tags parameters to a empty lis…
ChristianTremblay Oct 23, 2021
954de94
Merge branch 'develop' of https://github.com/ChristianTremblay/BAC0 i…
ChristianTremblay Oct 23, 2021
c8d57c3
Vendor id was not handled correctly in points
ChristianTremblay Oct 28, 2021
e6cbfc7
Merge branch 'develop' of github.com:ChristianTremblay/BAC0 into develop
ChristianTremblay Oct 28, 2021
783bfc2
Added support to add local objects to Foerign and BBMD BAC0 app
ChristianTremblay Oct 31, 2021
94eaec8
Trying to improving recurring tasks
ChristianTremblay Nov 1, 2021
756af76
Not all objects are well supporteed by default to save to SQL...limit…
ChristianTremblay Dec 3, 2021
ff3a980
Update infos.py
ChristianTremblay Dec 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env~
@@ -0,0 +1,10 @@
# InfluxDB Params Example .env file
INFLUXDB_V2_URL=http://192.168.1.10:8086
INFLUXDB_V2_ORG=my-org
INFLUXDB_V2_TOKEN=123456789abcdefg
# INFLUXDB_V2_TIMEOUT=
# INFLUXDB_V2_VERIFY_SSL=
# INFLUXDB_V2_SSL_CA_CERT=
# INFLUXDB_V2_CONNECTION_POOL_MAXSIZE=
# INFLUXDB_V2_AUTH_BASIC=
# INFLUXDB_V2_PROFILERS=
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -35,6 +35,7 @@ jobs:
pip install flask_bootstrap
pip install colorama
pip install netifaces
pip install python-dotenv
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Lint with flake8
Expand Down Expand Up @@ -68,4 +69,4 @@ jobs:
# env:
# GITHUB_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
# COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
# COVERALLS_PARALLEL: true
# COVERALLS_PARALLEL: true
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -41,3 +41,6 @@ obj300.bin
wily-report.html
make_doc.bat
tests/manual_test_bokeh.py
.env
samples/pascal_stlouis.py
samples/johnhensen.py
11 changes: 11 additions & 0 deletions BAC0/__init__.py
Expand Up @@ -36,6 +36,17 @@
except ImportError:
_COMPLETE = False

try:
#
import os

if os.path.isfile("{}/.env".format(os.getcwd())):
from dotenv import load_dotenv

load_dotenv(os.path.join(os.getcwd(), ".env"))
except ImportError:
print("You need to pip install python-dotenv to use your .env file")

from .scripts.Lite import Lite as lite

if _COMPLETE:
Expand Down
4 changes: 2 additions & 2 deletions BAC0/core/app/ScriptApplication.py
Expand Up @@ -52,7 +52,7 @@

class common_mixin:
"""
They take message coming from the network that are not generated from
They take message coming from the network that are not generated from
a request we made.
"""

Expand Down Expand Up @@ -415,7 +415,7 @@ def __init__(
# on the UDP multiplexer
self.bip = BIPBBMD(self.localAddress)
self.annexj = AnnexJCodec()
self.mux = UDPMultiplexer(self.localAddress, noBroadcast=True)
self.mux = UDPMultiplexer(self.localAddress, noBroadcast=False)

# bind the bottom layers
# bind(self.bip, self.annexj, self.mux.annexJ)
Expand Down
50 changes: 37 additions & 13 deletions BAC0/core/devices/Device.py
Expand Up @@ -15,9 +15,6 @@

import os.path

# --- 3rd party modules ---
import sqlite3

try:
import pandas as pd

Expand Down Expand Up @@ -49,7 +46,7 @@
)

# from ...bokeh.BokehRenderer import BokehPlot
from ...sql.sql import SQLMixin
from ...db.sql import SQLMixin
from ...tasks.DoOnce import DoOnce
from .mixins.read_mixin import ReadPropertyMultiple, ReadProperty
from .Virtuals import VirtualPoint
Expand Down Expand Up @@ -77,7 +74,13 @@ def __init__(self):
self.db_name = None
self.segmentation_supported = True
self.history_size = None
self.save_resampling = "1s"
self.clear_history_on_save = None
self.bacnet_properties = {}
self.auto_save = None
self.fast_polling = False
self.vendor_id = 0
self.ping_failures = 0

def __repr__(self):
return "{}".format(self.asdict)
Expand Down Expand Up @@ -156,7 +159,7 @@ def __init__(
self.properties.auto_save = auto_save
self.properties.save_resampling = save_resampling
self.properties.clear_history_on_save = clear_history_on_save
self.properties.default_history_size = history_size
self.properties.history_size = history_size
self._reconnect_on_failure = reconnect_on_failure

self.segmentation_supported = segmentation_supported
Expand Down Expand Up @@ -531,12 +534,14 @@ def _buildPointList(self):
)
)
try:
self.properties.objects_list, self.points, self._list_of_trendlogs = self._discoverPoints(
self.custom_object_list
)
(
self.properties.objects_list,
self.points,
self._list_of_trendlogs,
) = self._discoverPoints(self.custom_object_list)
if self.properties.pollDelay > 0:
self.poll(delay=self.properties.pollDelay)
self.update_history_size(size=self.properties.default_history_size)
self.update_history_size(size=self.properties.history_size)
# self.clear_histories()
except NoResponseFromController as error:
self._log.error("Cannot retrieve object list, disconnecting...")
Expand Down Expand Up @@ -726,7 +731,9 @@ def read_property(self, prop):
request = "{} {} {} {}".format(
self.properties.address, _obj, _instance, _prop
)
val = self.properties.network.read(request, vendor_id=0)
val = self.properties.network.read(
request, vendor_id=self.properties.vendor_id
)
except KeyError as error:
raise Exception("Unknown property : {}".format(error))
return val
Expand Down Expand Up @@ -757,15 +764,15 @@ def write_property(self, prop, value, priority=None):
def update_bacnet_properties(self):
"""
Retrieve bacnet properties for this device
To retrieve something general, forcing vendor id 0

"""
try:
res = self.properties.network.readMultiple(
"{} device {} all".format(
self.properties.address, str(self.properties.device_id)
),
vendor_id=0,
prop_id_required=True,
vendor_id=self.properties.vendor_id,
show_property_name=True,
)
for each in res:
if not each:
Expand Down Expand Up @@ -795,6 +802,19 @@ def update_description(self, value):
)
self.properties.description = self.read_property("description")

def ping(self):
try:
if self.read_property("objectName") == self.properties.name:
self.properties.ping_failures = 0
return True
else:
self.properties.ping_failures += 1
return False
except NoResponseFromController as e:
self._log.error("Error in ping : {}".format(e))
self.properties.ping_failures += 1
return False

def __repr__(self):
return "{} / Connected".format(self.properties.name)

Expand Down Expand Up @@ -1061,6 +1081,10 @@ def initialize_device_from_db(self):
self.properties.serving_chart = {}
self.properties.charts = []
self.properties.multistates = self._props["multistates"]
self.properties.auto_save = self._props["auto_save"]
self.properties.save_resampling = self._props["save_resampling"]
self.properties.clear_history_on_save = self._props["clear_history_on_save"]
self.properties.default_history_size = self._props["history_size"]
self._log.info("Device restored from db")
self._log.info(
'You can reconnect to network using : "device.connect(network=bacnet)"'
Expand Down