Public Access
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
# -*- coding: iso-8859-1 -*-
|
|
|
|
from .Resultable import Resultable
|
|
from .Drawable import Drawable
|
|
|
|
#############################################################################
|
|
# #
|
|
# Name: Class Temp_Result #
|
|
# #
|
|
# Purpose: Specialised class of Resultable and Drawable #
|
|
# Contains recorded temperature data #
|
|
# #
|
|
#############################################################################
|
|
|
|
class TemperatureResult(Resultable, Drawable):
|
|
"""
|
|
Specialised class of Resultable and Drawable
|
|
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, 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.x = [] if x is None else x
|
|
self.y = [] if y is None else y
|
|
self.setpoint = [] if setpoint is None else setpoint
|
|
|
|
# Set metadata if provided
|
|
if desc is not None:
|
|
self.description = desc
|
|
if job_id is not None:
|
|
self.job_id = job_id
|
|
if job_date is not None:
|
|
self.job_date = job_date
|
|
|
|
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})"
|