poulet_py.hardware.stimulator package#
- class Arduino(ports=None)[source]#
Bases:
object- __init__(ports=None)[source]#
Initialize the Arduino class with the given ports.
- Args:
ports (list): List of serial port addresses.
- read_data(data_parser=<class 'float'>)[source]#
Read data from the Arduino and parse it.
- Args:
- data_parser (callable): Function to parse the data read from the Arduino.
Defaults to float.
- Sets:
self.parsed_data: Parsed data from Arduino.
- set_error_log_path(folder_path, error_file_name)[source]#
Set the error log path for the Arduino.
- Args:
folder_path (str): Path to the folder where the error log will be stored. error_file_name (str): Name of the error log file.
- set_output_file(path, extra_name, data_columns=['data'], base_file_name='arduino')[source]#
Set the output file for the Arduino.
- Args:
path (str): Path to the folder where the output file will be saved. extra_name (str): An additional name to be added to the base file name. base_file_name (str): Base name of the output file. Defaults to ‘arduino’.
- class JulaboChiller(port=None, baudrate=9600, timeout=1)[source]#
Bases:
objectClass to interact with a Julabo water chiller via serial port.
- __init__(port=None, baudrate=9600, timeout=1)[source]#
Initialize the JulaboChiller with the given serial port configuration.
- Args:
port (str): The serial port (e.g., ‘COM12’). baudrate (int, optional): The baud rate for the serial communication. Default is 9600. timeout (int or float, optional): The read timeout value. Default is 1 second.
- get_target_temperature()[source]#
Get the target temperature set point.
- Returns:
str: The target temperature.
- get_temperature()[source]#
Get the current temperature from the chiller.
- Returns:
str: The current temperature reported by the chiller.
- read()[source]#
Read data from the chiller.
- Returns:
str: The response from the chiller, or None if no data is available.
- save_temperature(timestamp, temperature)[source]#
Save the temperature to a CSV file.
- Args:
timestamp: The timestamp to be saved. temperature: The temperature to be saved.
- set_error_log_path(path, file_name)[source]#
Sets the path for the error log file.
- Args:
path (str): The directory where the error log file will be saved.
- set_output_file(path, extra_name, base_file_name='julabo_chiller')[source]#
Sets the output file for recording the video.
- Args:
path (str): The directory where the output file will be saved.
- set_temperature(temperature)[source]#
Set the temperature of the chiller.
- Args:
temperature (float): The temperature to set (in Celsius).
- class TCS(port, *, maximum_temperature=40.0, beep=False, trigger_out_channel=255, read_timeout=2.0, response_timeout=2.0, stimulus_trigger=None)[source]#
Bases:
objectInterface for communicating with a TCS thermal stimulator.
- Parameters:
port (str) – Serial port to which the device is connected.
maximum_temperature (float, optional) – Maximum allowed temperature in °C (default: 40).
beep (bool, optional) – Whether to enable audible beeps (default: False).
trigger_out_channel (int, optional) – Output channel for trigger signals (default: 255).
read_timeout (float, optional) – Timeout for read operations in seconds (default: 2).
response_timeout (float, optional) – Timeout for device responses in seconds (default: 2).
stimulus_trigger (BaseTrigger, optional) – A Trigger found in poulet_py/hardware/triggers to trigger the next stimulus.
Examples
>>> with TCS(port="/dev/ttyUSB0") as tcs: >>> tcs.init() >>> stimulus = TCSStimulus(surface=1, target=35.0) >>> tcs.stimulus = stimulus >>> tcs.trigger() >>> readings = tcs.get_readings() >>> print(readings)
- __init__(port, *, maximum_temperature=40.0, beep=False, trigger_out_channel=255, read_timeout=2.0, response_timeout=2.0, stimulus_trigger=None)[source]#
- execute_command(command, *args, expected_pattern=None)[source]#
Execute a command and optionally wait for a response.
- Parameters:
command (TCSCommand) – The command to execute
*args – Arguments to format into the command
expected_pattern (Pattern | None) – Regex pattern to match against the response
- Returns:
If expected_pattern provided, returns (timestamp, match) tuple
- Return type:
tuple[int, Match[str]]] | None
Examples
>>> tcs.execute_command(TCSCommand.READ_INFO, expected_pattern=compile(r"Firmware:(.*)"))
- get_readings()[source]#
Get current temperature readings from all sensors.
- Returns:
Dictionary containing temperatures for neutral and all surfaces, plus a timestamp key.
- Return type:
Dict[str, float]
- Raises:
RuntimeError – If reading temperatures fails
- info()[source]#
Get device information including firmware version and probe details.
- Returns:
Device information string
- Return type:
str
- Raises:
RuntimeError – If the info command fails or times out
- init()[source]#
Initialize the TCS connection and verify communication.
- Raises:
RuntimeError – If initialization fails
- property stimulus: TCSStimulus#
- class TCSCommand(*values)[source]#
Bases:
bytes,EnumEnumeration of all available TCS commands with their byte representations.
Each command includes formatting capability for parameterized commands.
Examples
>>> TCSCommand.READ_TEMPERATURES <TCSCommand.READ_TEMPERATURES: b'E'> >>> TCSCommand.BASELINE_TEMPERATURE.format(300) b'N300'
- format(*args)[source]#
Format the command with the given arguments.
- Parameters:
*args (int, float) – Arguments to format into the command string
- Returns:
Formatted command string
- Return type:
bytes
- Raises:
ValueError – If arguments don’t match the command’s format requirements
Examples
>>> TCSCommand.TARGET_TEMPERATURE.format(1, 350) b'C1350'
- READ_INFO = b'H'#
- READ_TEMPERATURES = b'E'#
- READ_STIMULATION_VALUES = b'P'#
- READ_BUTTON_STATUS = b'K'#
- READ_BATTERY = b'B'#
- READ_ERRORS = b'Q'#
- DISPLAY_TEMPERATURES_BETWEEN_STIMULATION = b'Oa'#
- DISPLAY_TEMPERATURES_DURING_STIMULATION = b'Ob'#
- RESET = b'Oc'#
- SET_MAX_TEMPERATURE = b'Om%03d'#
- AUTOMATIC_CALIBRATION = b'G'#
- DEACTIVATE_DISPLAY = b'F'#
- TRIGGER_STIMULATION = b'L'#
- HALT_STIMULATION = b'A'#
- BASELINE_TEMPERATURE = b'N%03d'#
- SURFACE_SELECTION = b'S%05d'#
- TARGET_TEMPERATURE = b'C%d%03d'#
- STIMULATION_RATE = b'V%d%04d'#
- RETURN_SPEED = b'R%d%04d'#
- STIMULATION_DURATION = b'D%d%05d'#
- TRIGGER_CHANNEL_DURATION = b'T%03d%03d'#
- BUZZER = b'Z%03d%03d'#
- class TCSStimulus(**data)[source]#
Bases:
BaseModelConfiguration for thermal stimulation parameters.
- surface#
Target surface (0-5, where 0 means all surfaces).
- Type:
int
- baseline#
Baseline temperature in °C (20-45).
- Type:
float
- target#
Target temperature in °C (0-60).
- Type:
float
- rise_rate#
Temperature rise rate in °C/s (0.1-999.9).
- Type:
float
- return_speed#
Temperature return speed in °C/s (0.1-999.9).
- Type:
float
- duration#
Stimulation duration in ms (10-99999).
- Type:
int
Examples
>>> stimulus = TCSStimulus(surface=1) >>> stimulus.commands() [b'S10000', b'N300', b'C1000', b'V10010', b'D100100', b'R10010']
- commands()[source]#
Generate the sequence of commands needed to configure this stimulus.
- Returns:
Sequence of formatted command strings
- Return type:
list
Examples
>>> stimulus = TCSStimulus(surface=1) >>> stimulus.commands() [b'S10000', b'N300', b'C1000', b'V10010', b'D100100', b'R10010']
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
surface:
int#
-
baseline:
float#
-
target:
float#
-
rise_rate:
float#
-
return_speed:
float#
-
duration:
int#
Submodules#
- poulet_py.hardware.stimulator.arduino module
- poulet_py.hardware.stimulator.julabo module
JulaboChillerJulaboChiller.__init__()JulaboChiller.set_timer()JulaboChiller.set_error_log_path()JulaboChiller.set_output_file()JulaboChiller.save_temperature()JulaboChiller.read()JulaboChiller.write()JulaboChiller.close_port()JulaboChiller.set_temperature()JulaboChiller.get_temperature()JulaboChiller.start()JulaboChiller.stop()JulaboChiller.check_version()JulaboChiller.check_status()JulaboChiller.check_started()JulaboChiller.get_target_temperature()
- poulet_py.hardware.stimulator.qst module
TCSCommandTCSCommand.READ_INFOTCSCommand.READ_TEMPERATURESTCSCommand.READ_STIMULATION_VALUESTCSCommand.READ_BUTTON_STATUSTCSCommand.READ_BATTERYTCSCommand.READ_ERRORSTCSCommand.DISPLAY_TEMPERATURES_BETWEEN_STIMULATIONTCSCommand.DISPLAY_TEMPERATURES_DURING_STIMULATIONTCSCommand.RESETTCSCommand.SET_MAX_TEMPERATURETCSCommand.AUTOMATIC_CALIBRATIONTCSCommand.DEACTIVATE_DISPLAYTCSCommand.TRIGGER_STIMULATIONTCSCommand.HALT_STIMULATIONTCSCommand.BASELINE_TEMPERATURETCSCommand.SURFACE_SELECTIONTCSCommand.TARGET_TEMPERATURETCSCommand.STIMULATION_RATETCSCommand.RETURN_SPEEDTCSCommand.STIMULATION_DURATIONTCSCommand.TRIGGER_CHANNEL_DURATIONTCSCommand.BUZZERTCSCommand.format()
TCSStimulusTCSStimulus.surfaceTCSStimulus.baselineTCSStimulus.targetTCSStimulus.rise_rateTCSStimulus.return_speedTCSStimulus.durationTCSStimulus.commands()TCSStimulus.surfaceTCSStimulus.baselineTCSStimulus.targetTCSStimulus.rise_rateTCSStimulus.return_speedTCSStimulus.durationTCSStimulus.commands()TCSStimulus.model_config
TCS