added POC for temperature logging

This commit is contained in:
2026-07-11 22:11:03 +02:00
parent d48f96e498
commit 5338304ee8
6 changed files with 768 additions and 7 deletions
+48 -5
View File
@@ -15,17 +15,60 @@ from .Drawable import Drawable
class TemperatureResult(Resultable, Drawable):
"""
Specialised class of Resultable and Drawable
Contains recorded temperature data
Contains recorded temperature data.
Attributes:
x: List of timestamps in seconds.
y: List of temperature readings in Celsius.
setpoint: Optional list of setpoint temperatures in Celsius.
xlabel: Label for x-axis (default: "Time (s)").
ylabel: Label for y-axis (default: "Temperature (C)").
"""
def __init__(self, x = None, y = None, desc = None, job_id = None, job_date = None):
def __init__(self, x = None, y = None, setpoint = None, desc = None, job_id = None, job_date = None):
Resultable.__init__(self)
Drawable.__init__(self)
# Set default labels
self.xlabel = "Time (s)"
self.ylabel = "Temperature (C)"
# Initialize data lists
self.setpoint = [] if setpoint is None else setpoint
if (x is None) and (y is None) and (desc is None) and (job_id is None) and (job_date is None):
pass
# Empty initialization - will be filled later
self.x = []
self.y = []
elif (x is not None) and (y is not None) and (desc is not None) and (job_id is not None) and (job_date is not None):
pass
# Full initialization
self.x = x
self.y = y
self.description = desc
self.job_id = job_id
self.job_date = job_date
else:
raise ValueError("Wrong usage of __init__!")
def get_number_of_channels(self):
"""Returns 1 for temperature data."""
return 1
def get_xdata(self):
"""Returns the x data (timestamps)."""
return self.x
def get_ydata(self, channel=0):
"""Returns the y data (temperature readings)."""
if channel == 0:
return self.y
return []
def __len__(self):
"""Returns the number of data points."""
return len(self.y) if self.y else 0
def __repr__(self):
"""String representation of the temperature result."""
return f"TemperatureResult(points={len(self)}, job_id={self.job_id})"