Skip to content

Commit

Permalink
tool sensors changes
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Mar 15, 2024
1 parent 5c1c040 commit 194dcc2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class AddLinearMoveRequest(BaseMessage): # noqa: D101


@dataclass
class AddSensorLinearMoveRequest(BaseMessage): # noqa: D101
class AddSensorLinearMoveRequest(BaseMessage):
"""Sensor Linear Move Request."""

payload: payloads.AddSensorLinearMoveBasePayload
Expand Down
23 changes: 7 additions & 16 deletions hardware/opentrons_hardware/hardware_control/tool_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@
SensorDataType,
sensor_fixed_point_conversion,
)
from opentrons_hardware.firmware_bindings.messages.payloads import (
BindSensorOutputRequestPayload,
SendAccumulatedPressureDataPayload,
)
from opentrons_hardware.firmware_bindings.messages.message_definitions import (
BindSensorOutputRequest,
SendAccumulatedPressureDataRequest,
)
from opentrons_hardware.firmware_bindings.messages.fields import (
SensorOutputBindingField,
SensorTypeField,
SensorIdField,
)
from opentrons_hardware.sensors.sensor_types import SensorInformation, PressureSensor
from opentrons_hardware.sensors.scheduler import SensorScheduler
from opentrons_hardware.sensors.utils import SensorThresholdInformation
Expand Down Expand Up @@ -115,7 +102,10 @@ async def run_pass_output_to_csv(
threshold_pascals: float,
head_node: NodeId,
move_group: MoveGroupRunner,
data_file: Optional[str] = None,
) -> Dict[NodeId, MotorPositionStatus]:
"""Runs the sensor pass move group and creates a csv file with the results."""
log_file: str = "/var/pressure_sensor_data.csv" if not data_file else data_file
file_heading = [
"time(s)",
"Pressure(pascals)",
Expand All @@ -126,7 +116,7 @@ async def run_pass_output_to_csv(
sensor_metadata = [0, 0, mount_speed, plunger_speed, threshold_pascals]
sensor_capturer = LogListener(
mount=head_node,
data_file="/var/pressure_sensor_data.csv",
data_file=log_file,
file_heading=file_heading,
sensor_metadata=sensor_metadata,
)
Expand All @@ -143,6 +133,8 @@ async def run_pass_output_to_csv(


class OutputOptions(Enum):
"""Specifies where we should report sensor data to during a sensor pass."""

write_to_csv = auto()
can_bus_only = auto()
none = auto()
Expand All @@ -161,10 +153,8 @@ async def liquid_probe(
auto_zero_sensor: bool = True,
num_baseline_reads: int = 10,
sensor_id: SensorId = SensorId.S0,
canbus_output: bool = True,
) -> Dict[NodeId, MotorPositionStatus]:
"""Move the mount and pipette simultaneously while reading from the pressure sensor."""
log_file: str = "/var/pressure_sensor_data.csv" if not data_file else data_file
sensor_driver = SensorDriver()
threshold_fixed_point = threshold_pascals * sensor_fixed_point_conversion
pressure_sensor = PressureSensor.build(
Expand Down Expand Up @@ -200,6 +190,7 @@ async def liquid_probe(
threshold_pascals,
head_node,
sensor_runner,
data_file,
)

elif output_format == OutputOptions.can_bus_only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
check_overpressure,
InstrumentProbeTarget,
PipetteProbeTarget,
OutputOptions,
)
from opentrons_hardware.firmware_bindings.constants import (
NodeId,
Expand Down Expand Up @@ -180,7 +181,7 @@ def move_responder(
mount_speed=10,
plunger_speed=8,
threshold_pascals=threshold_pascals,
log_pressure=False,
output_format=OutputOptions.none,
auto_zero_sensor=True,
num_baseline_reads=8,
sensor_id=SensorId.S0,
Expand Down Expand Up @@ -209,7 +210,7 @@ def move_responder(
mount_speed=10,
plunger_speed=8,
threshold_pascals=threshold_pascals,
log_pressure=True,
output_format=OutputOptions.none,
auto_zero_sensor=True,
num_baseline_reads=8,
sensor_id=SensorId.S0,
Expand Down

0 comments on commit 194dcc2

Please sign in to comment.