Commit 73bbc4c6 authored by Alan Marchiori's avatar Alan Marchiori

removed socket from datalogger class

parent 1ed40155
......@@ -50,7 +50,7 @@ class DataLogger:
self.log = logging.getLogger(__name__)
self.db = sqlite3.connect(db)
self.socket = socket
self.my_node_id = my_node_id
self.metric_id = metric_id
self.pakbus_id = pakbus_id
......@@ -145,7 +145,7 @@ class DataLogger:
return "Metric ID: " + str(self.metric_id) + "; PakBus ID: " + str(self.pakbus_id) + \
"; Table List: " + str(self.list_of_tables)
def getTables(self, count):
def getTables(self, socket, count):
''' Get all tables in the datalogger except for "Public" and "Status"
count: maximum number of retries
'''
......@@ -160,7 +160,7 @@ class DataLogger:
list_of_tables += [Table(self.tabledef[tableno]['Header']['TableName'], self.tabledef, tableno)]
else:
if (count > 0):
self.FileData = pakbus.fileupload(self.socket, self.pakbus_id, self.my_node_id, FileName = '.TDF')[0]
self.FileData = pakbus.fileupload(socket, self.pakbus_id, self.my_node_id, FileName = '.TDF')[0]
return self.getTables(count-1)
else:
# raise exception??
......@@ -184,14 +184,14 @@ class DataLogger:
values[0],
tbl.dic_of_sensorTags[sensor_name].tag)
def collect_all(self):
def collect_all(self, socket):
for tbl in self.list_of_tables:
self.log.debug("Collecting all from {}.{}".format(self.metric_id, tbl.name))
more_flag = True
# collect most recent record
data, more_flag = pakbus.collect_data(self.socket, self.pakbus_id,
data, more_flag = pakbus.collect_data(socket, self.pakbus_id,
self.my_node_id, self.tabledef,
tbl.name,
CollectMode = 0x03)
......@@ -210,10 +210,10 @@ class DataLogger:
#self.data_callback(self, rec)
if more_flag:
self.collect_increment()
self.collect_increment(socket)
def collect_increment(self):
def collect_increment(self, socket):
for tbl in self.list_of_tables:
self.log.debug("Collecting increment from {}.{} NextRecNbr = {}".format(self.metric_id,
......@@ -223,7 +223,7 @@ class DataLogger:
while more_flag:
# collect from where we left off
data, more_flag = pakbus.collect_data(self.socket, self.pakbus_id,
data, more_flag = pakbus.collect_data(socket, self.pakbus_id,
self.my_node_id, self.tabledef,
tbl.name,
CollectMode = 0x04,
......@@ -249,14 +249,14 @@ class DataLogger:
#self.data_callback(tbl.dic_of_sensorTags, rec)
else:
self.log.warn("Collecting data but got no records.")
def collect(self):
def collect(self, socket):
if self.last_collect['ts'] == None:
# initial collection, get all data
self.collect_all()
self.collect_all(socket)
else:
# incremental collect
self.collect_increment()
self.collect_increment(socket)
......
......@@ -182,7 +182,7 @@ def main():
while True:
for metric, dl in dataloggers.iteritems():
dl.collect()
dl.collect(skt)
#logging.warn("all done, exiting")
#exit();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment