- use path for logs
This commit is contained in:
+6
-2
@@ -8,11 +8,14 @@ from components import APid
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import scipy.io
|
import scipy.io
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class TracerTask(ATask):
|
class TracerTask(ATask):
|
||||||
def __init__(self, sensor: ATemperatureSensor, heater: AHeater, temp_ctrl: APid, interval, msg_handler: MsgIo):
|
def __init__(self, sensor: ATemperatureSensor, heater: AHeater, temp_ctrl: APid, interval, msg_handler: MsgIo, path = './logs'):
|
||||||
ATask.__init__(self, interval)
|
ATask.__init__(self, interval)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
|
||||||
self.msg_handler = msg_handler
|
self.msg_handler = msg_handler
|
||||||
msg_handler.set_recv_handler(self.recv)
|
msg_handler.set_recv_handler(self.recv)
|
||||||
@@ -20,6 +23,7 @@ class TracerTask(ATask):
|
|||||||
self.sensor = sensor
|
self.sensor = sensor
|
||||||
self.heater = heater
|
self.heater = heater
|
||||||
self.temp_ctrl = temp_ctrl
|
self.temp_ctrl = temp_ctrl
|
||||||
|
self.path = path
|
||||||
|
|
||||||
async def recv(self, data):
|
async def recv(self, data):
|
||||||
pass
|
pass
|
||||||
@@ -40,7 +44,7 @@ class TracerTask(ATask):
|
|||||||
_tc_dtemp_soll = np.empty(0)
|
_tc_dtemp_soll = np.empty(0)
|
||||||
_tc_dtemp_commanded = np.empty(0)
|
_tc_dtemp_commanded = np.empty(0)
|
||||||
|
|
||||||
filename = "brewpi." + time.strftime("%Y%m%d%H%M%S", time.localtime()) + ".mat"
|
filename = os.path.join(self.directory, '') + "brewpi." + time.strftime("%Y%m%d%H%M%S", time.localtime()) + ".mat"
|
||||||
while True:
|
while True:
|
||||||
_timestamp = np.append(_timestamp, timestamp)
|
_timestamp = np.append(_timestamp, timestamp)
|
||||||
_sensor_temp = np.append(_sensor_temp, self.sensor.temperature())
|
_sensor_temp = np.append(_sensor_temp, self.sensor.temperature())
|
||||||
|
|||||||
Reference in New Issue
Block a user