Skip to content

Commit

Permalink
Old / obsolete / commented code removal
Browse files Browse the repository at this point in the history
Found a bug with chart when sending less than 3 objects to the chart
Added a print of the version when starting the app... this will ease finding version related bugs
  • Loading branch information
ChristianTremblay committed Jun 26, 2017
1 parent 51acd92 commit 6bbf478
Show file tree
Hide file tree
Showing 7 changed files with 630 additions and 341 deletions.
3 changes: 1 addition & 2 deletions BAC0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from . import tasks
from .scripts.BasicScript import BasicScript
from .scripts.ReadWriteScript import ReadWriteScript as connect
#from .core.functions.GetIPAddr import HostIP as ip
from .core.devices.Device import Device as device
from .core.devices.Device import DeviceLoad as load
from .tasks.Poll import SimplePoll as poll
Expand All @@ -14,4 +13,4 @@
from .infos import __version__ as version
except ImportError as error:
print(error)
# Not installed yet
# Not installed yet
5 changes: 3 additions & 2 deletions BAC0/bokeh/BokehRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def loop(self):
class BokehPlot(object):
def __init__(self, device, points_list, *, title = 'My title', show_notes = True, update_data = True):
self.device = device
if len(points_list) < 3:
raise ValueError("Provide at least 3 objects to the chart")
self.points_list = points_list
self.title = title
self.units = {}
Expand Down Expand Up @@ -172,7 +174,6 @@ def build_plot(self):
notes_df = self.read_notes()

TOOLS = "pan,box_zoom,wheel_zoom,resize,save,reset"
#plot_width=800, plot_height=600,
self.p = Figure(x_axis_type="datetime", x_axis_label="Time",
y_axis_label="Numeric Value", title = self.title,
tools = TOOLS, plot_width=700, plot_height=600,
Expand Down Expand Up @@ -216,7 +217,7 @@ def build_plot(self):
if len(self.lst)<=10:
color_mapper = dict(zip(self.lst, d3['Category10'][len(self.lst)]))
else:
# This would be a very bug trend...
# This would be a very loaded trend...
color_mapper = dict(zip(self.lst, Spectral6[:len(self.lst)]))

for each in self.lst:
Expand Down
6 changes: 0 additions & 6 deletions BAC0/core/devices/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
from datetime import datetime

import os.path
#from abc import ABCMeta # abstract base classes

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

import pandas as pd
#from pandas.lib import Timestamp
#from pandas.io import sql
import logging
log = logging.getLogger('BAC0.core.devices')
try:
Expand Down Expand Up @@ -235,7 +232,6 @@ def chart(self, list_of_points, *, title='Live Trending', show_notes=True):
lst = []
for point in list_of_points:
if point in self.points_name:
#print('Add %s to list' % point)
lst.append(point)
else:
self._log.warning('Wrong name, removing %s from list' % point)
Expand Down Expand Up @@ -839,8 +835,6 @@ def initialize_device_from_db(self):
self.points.append(OfflinePoint(self, point))

self.properties = DeviceProperties()
#file_name = "%s_prop.bin" % self.properties.db_name
#device_name = self.properties.name
self.properties.db_name = dbname
self.properties.address = self._props['address']
self.properties.device_id = self._props['device_id']
Expand Down
7 changes: 2 additions & 5 deletions BAC0/scripts/BasicScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def stopApp()
from ..core.app.ScriptApplication import ScriptApplication
from .. import infos
from ..core.io.IOExceptions import NoResponseFromController
#import BAC0.core.functions as fn

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

Expand Down Expand Up @@ -175,20 +174,18 @@ def _startAppThread(self):
self.t = Thread(target=startBacnetIPApp, kwargs={'sigterm': None,'sigusr1': None}, daemon = True)
self.t.start()
self._started = True
self._log.info('BACnet started')
self._log.info('BAC0 started')


@property
def devices(self):
lst = []
#self.whois()
#print(self.discoveredDevices)
for device in self.discoveredDevices:
try:
deviceName, vendorName = self.readMultiple('%s device %s objectName vendorName' % (device[0], device[1]))
lst.append((deviceName, vendorName, device[0], device[1]))
except NoResponseFromController:
#print('No response from %s' % device)
self._log.info('No response from %s' % device)
continue
df = pd.DataFrame(lst, columns=['Name', 'Manufacturer', 'Address',' Device ID']).set_index('Name')
try:
Expand Down
4 changes: 4 additions & 0 deletions BAC0/scripts/ReadWriteScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ReadWriteScript(BasicScript,ReadProperty,WriteProperty)
from ..bokeh.BokehRenderer import BokehSession, BokehDocument
from ..bokeh.BokehServer import BokehServer

from ..infos import __version__ as version

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

# some debugging
Expand All @@ -64,6 +66,7 @@ class ReadWriteScript(BasicScript, WhoisIAm, ReadProperty, WriteProperty, Simula
set to True.
"""
def __init__(self, ip=None, bokeh_server=True):
print("Starting BAC0 version %s" % version)
self._log = logging.getLogger('BAC0.script.%s' \
% self.__class__.__name__)
self._log.debug("Configurating app")
Expand All @@ -74,6 +77,7 @@ def __init__(self, ip=None, bokeh_server=True):
ip_addr = ip

BasicScript.__init__(self, localIPAddr=ip_addr)


self.bokehserver = False
# Force a global whois to find all devices on the network
Expand Down
Loading

0 comments on commit 6bbf478

Please sign in to comment.