abstract_classes
Classes
Base class for Camera interface. |
|
Base class for event logging interfaces. |
|
Base class for Motor interface. |
|
Base class for Bpod interface. |
|
Base class for Scale interface. |
|
Base class for Sound Device interface. |
|
Base class for Telegram Bot interface. |
|
Base class for Temperature Sensor interface. |
- class PyBpodBase[source]
Bases:
objectBase class for Bpod interface.
- error
Error message.
- Type:
str
- session
Bpod session object.
- Type:
Session | Any
- connected
Connection status.
- Type:
bool
- error: str = 'Error connecting to the bpod '
- session: Session | Any = None
- connected: bool = False
- connect(functions: list[Callable]) None[source]
Connects to the Bpod device.
- Parameters:
functions (list[Callable]) – List of callback functions for softcodes.
- add_state(state_name: Any, state_timer: float = 0, state_change_conditions: Any = {}, output_actions: Any = ()) None[source]
Adds a state to the state machine.
- Parameters:
state_name (Any) – Name of the state.
state_timer (float) – Duration of the state in seconds.
state_change_conditions (Any) – Conditions to transition to other states.
output_actions (Any) – Actions to perform in this state.
- set_global_timer(timer_id: Any, timer_duration: Any, on_set_delay: int = 0, channel: Any | None = None, on_message: int = 1, off_message: int = 0, loop_mode: int = 0, loop_intervals: int = 0, send_events: int = 1, oneset_triggers: Any | None = None) None[source]
Configures a global timer.
- Parameters:
timer_id (Any) – ID of the timer.
timer_duration (Any) – Duration of the timer.
on_set_delay (int) – Delay before the timer starts.
channel (Any | None) – Output channel to link.
on_message (int) – Message when timer starts.
off_message (int) – Message when timer ends.
loop_mode (int) – Loop mode.
loop_intervals (int) – Interval between loops.
send_events (int) – Whether to send events.
oneset_triggers (Any | None) – Triggers to set.
- set_condition(condition_number: Any, condition_channel: Any, channel_value: Any) None[source]
Sets a condition for the state machine.
- Parameters:
condition_number (Any) – The condition ID.
condition_channel (Any) – The channel to check.
channel_value (Any) – The value to match.
- set_global_counter(counter_number: Any, target_event: Any, threshold: Any) None[source]
Configures a global counter.
- Parameters:
counter_number (Any) – The counter ID.
target_event (Any) – The event to count.
threshold (Any) – The count threshold.
- create_state_machine() None[source]
Creates and initializes a new state machine.
- send_and_run_state_machine() None[source]
Sends the current state machine to the Bpod and starts it.
- close() None[source]
Closes the connection to the Bpod.
- stop() None[source]
Stops the current trial or operation.
- manual_override_input(message: str) None[source]
Simulates an input event manually.
- Parameters:
message (str) – The input message/event string.
- manual_override_output(message: str | tuple) None[source]
Manually triggers an output.
- Parameters:
message (str | tuple) – The output command.
- register_value(name: str, value: Any) None[source]
Registers a value to be tracked or logged.
- Parameters:
name (str) – Name of the value.
value (Any) – The value itself.
- receive_softcode(idx: int) None[source]
Handles received softcodes.
- Parameters:
idx (int) – The softcode index.
- led(i: int, close: bool) None[source]
Controls an LED.
- Parameters:
i (int) – The LED index.
close (bool) – Whether to turn it off (or close the circuit).
- water(i: int, close: bool) None[source]
Controls a water valve.
- Parameters:
i (int) – The valve index.
close (bool) – Whether to close the valve.
- poke(i: int, close: bool) None[source]
Simulates a poke event.
- Parameters:
i (int) – The poke index.
close (bool) – State of the poke.
- class TelegramBotBase[source]
Bases:
objectBase class for Telegram Bot interface.
- error
Error message.
- Type:
str
- error: str = 'Error connecting to the telegram_bot '
- alarm(message: str) None[source]
Sends an alarm message.
- Parameters:
message (str) – The alarm message.
- class ScaleBase[source]
Bases:
objectBase class for Scale interface.
- error
Error message.
- Type:
str
- error: str = 'Error connecting to the scale '
- tare() None[source]
Tares the scale.
- calibrate(weight: float) None[source]
Calibrates the scale using a known weight.
- Parameters:
weight (float) – The known weight.
- get_weight() float[source]
Gets the current weight.
- Returns:
The weight reading (default 0.0).
- Return type:
float
- class TempSensorBase[source]
Bases:
objectBase class for Temperature Sensor interface.
- error
Error message.
- Type:
str
- error: str = 'Error connecting to the temp_sensor '
- start() None[source]
Starts the sensor.
- get_temperature() tuple[float, float, str][source]
Gets temperature and humidity.
- Returns:
Temperature, humidity, and formatted string.
- Return type:
tuple[float, float, str]
- class MotorBase[source]
Bases:
objectBase class for Motor interface.
- error
Error message.
- Type:
str
- open_angle
Angle for open position.
- Type:
int
- close_angle
Angle for close position.
- Type:
int
- error: str = 'Error connecting to the motor '
- open_angle: int = 0
- close_angle: int = 0
- open() None[source]
Opens the motor/device.
- close() None[source]
Closes the motor/device.
- class SoundDeviceBase[source]
Bases:
objectBase class for Sound Device interface.
- samplerate
Audio sample rate.
- Type:
int
- error
Error message.
- Type:
str
- samplerate: int = 44100
- error: str = 'Error connecting to the sound_device '
- load(load: Any, right: Any) None[source]
Loads sound data.
- Parameters:
load (Any) – Left channel data or similar.
right (Any) – Right channel data.
- play() None[source]
Plays the loaded sound.
- stop() None[source]
Stops sound playback.
- load_wav(file: str) None[source]
Loads a WAV file.
- Parameters:
file (str) – Path or name of the WAV file.
- class EventBase[source]
Bases:
objectBase class for event logging interfaces.
- log(date: str, type: str, subject: str, description: str) None[source]
Logs a generic event.
- Parameters:
date (str) – Date/time string.
type (str) – Event type.
subject (str) – Subject name.
description (str) – Description.
- log_temp(date: str, temperature: float, humidity: float) None[source]
Logs temperature and humidity data.
- Parameters:
date (str) – Date/time string.
temperature (float) – Temperature value.
humidity (float) – Humidity value.
- class CameraBase[source]
Bases:
objectBase class for Camera interface.
- area1
Coordinates for area 1.
- Type:
list[int]
- area2
Coordinates for area 2.
- Type:
list[int]
- area3
Coordinates for area 3.
- Type:
list[int]
- area4
Coordinates for area 4.
- Type:
list[int]
- areas
List of all area coordinates.
- Type:
list[list[int]]
- area1_is_triggered
Trigger status for area 1.
- Type:
bool
- area2_is_triggered
Trigger status for area 2.
- Type:
bool
- area3_is_triggered
Trigger status for area 3.
- Type:
bool
- area4_is_triggered
Trigger status for area 4.
- Type:
bool
- change
Flag for property changes.
- Type:
bool
- annotation
Current annotation text.
- Type:
str
- path_picture
Path to save pictures.
- Type:
str
- error
Error message.
- Type:
str
- trial
Current trial number.
- Type:
int
- is_recording
Recording status.
- Type:
bool
- show_time_info
Time info display flag.
- Type:
bool
- x_position
X coordinate of tracked object.
- Type:
int
- y_position
Y coordinate of tracked object.
- Type:
int
- chrono
Timer utility.
- Type:
time_utils.Chrono
- area1: list[int] = []
- area2: list[int] = []
- area3: list[int] = []
- area4: list[int] = []
- areas: list[list[int]] = []
- area1_is_triggered: bool = False
- area2_is_triggered: bool = False
- area3_is_triggered: bool = False
- area4_is_triggered: bool = False
- change: bool = False
- annotation: str = ''
- path_picture: str = ''
- error: str = 'Error connecting to the camera '
- trial: int = -1
- is_recording: bool = False
- show_time_info: bool = False
- x_position: int = -1
- y_position: int = -1
- chrono = <village.scripts.time_utils.TimeUtils.Chrono object>
- start_camera() None[source]
Starts the camera.
- stop_camera() None[source]
Stops the camera.
- start_preview_window() <MagicMock name='mock.QWidget' id='140286155962896'>[source]
Starts the preview window.
- Returns:
A QWidget for the preview.
- Return type:
QWidget
- stop_preview_window() None[source]
Stops the preview window.
- start_recording(path_video: str = '', path_csv: str = '') None[source]
Starts recording.
- Parameters:
path_video (str) – Path for video file.
path_csv (str) – Path for CSV data.
- stop_recording() None[source]
Stops recording.
- print_info_about_config() None[source]
Prints camera configuration info.
- pre_process(request) None[source]
Preprocessing callback for frames.
- Parameters:
request – The request object.
- write_text(text: str) None[source]
Writes text annotation to the frame.
- Parameters:
text (str) – The text to write.
- areas_corridor_ok() bool[source]
Checks corridor areas status.
- Returns:
True if OK.
- Return type:
bool
- area_1_empty() bool[source]
Checks if area 1 is empty.
- Returns:
True if empty.
- Return type:
bool
- area_2_empty() bool[source]
Checks if area 2 is empty.
- Returns:
True if empty.
- Return type:
bool
- area_3_empty() bool[source]
Checks if area 3 is empty.
- Returns:
True if empty.
- Return type:
bool
- area_4_empty() bool[source]
Checks if area 4 is empty.
- Returns:
True if empty.
- Return type:
bool
- take_picture() None[source]
Takes a picture.