Expose STARBackend.channel_measure_temperature()#908
Expose STARBackend.channel_measure_temperature()#908BioCam wants to merge 1 commit intoPyLabRobot:mainfrom
STARBackend.channel_measure_temperature()#908Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds public measurement helpers to the Hamilton STAR liquid handling backend so callers can query pipetting-channel temperature readings directly from firmware.
Changes:
- Added
STARBackend.channel_measure_temperature(channel_idx)to query a single channel’s temperature via theRMfirmware command. - Added
STARBackend.channels_measure_temperatures()to query all channels and return a list of temperatures.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
|
|
||
| resp = await self.send_command( | ||
| module=STARBackend.channel_id(channel_idx), |
There was a problem hiding this comment.
Use self.channel_id(channel_idx) instead of STARBackend.channel_id(channel_idx) here to avoid hard-coding the base class and to stay consistent with nearby channel-specific helpers (e.g. channel_request_y_minimum_spacing). This also keeps the method override-friendly if a subclass ever customizes channel addressing.
| module=STARBackend.channel_id(channel_idx), | |
| module=self.channel_id(channel_idx), |
| async def channel_measure_temperature(self, channel_idx: int) -> float: | ||
| """Measure the temperature of a single channel. | ||
|
|
||
| Args: | ||
| channel_idx: The channel index to query (0-indexed). | ||
|
|
||
| Returns: | ||
| The temperature reading as a float. | ||
| """ | ||
|
|
||
| if not (0 <= channel_idx < self.num_channels): | ||
| raise ValueError( | ||
| f"channel_idx must be between 0 and {self.num_channels - 1}, got {channel_idx}." | ||
| ) | ||
|
|
||
| resp = await self.send_command( | ||
| module=STARBackend.channel_id(channel_idx), | ||
| command="RM", | ||
| fmt="rm####", | ||
| ) | ||
| return round(resp["rm"] / 100.0, 2) | ||
|
|
||
| async def channels_measure_temperatures(self) -> List[float]: | ||
| """Measure the temperature of all channels. | ||
|
|
||
| Returns: | ||
| A list of temperature readings as floats, one per channel, ordered by channel index. | ||
| """ | ||
|
|
||
| temperatures: List[float] = [] | ||
| for idx in range(self.num_channels): | ||
| temperature = await self.channel_measure_temperature(channel_idx=idx) | ||
| temperatures.append(temperature) | ||
| return temperatures |
There was a problem hiding this comment.
New public measurement helpers (channel_measure_temperature / channels_measure_temperatures) don’t appear to be covered by tests. Since this backend has an extensive STAR_tests.py, please add unit tests that validate the generated command (module/command/fmt) and that the returned value correctly converts the firmware integer (e.g. rm0234 -> 2.34).
|
all report exactly 20.0C, so I don't think this works |
ahh sad, our AC is set to 20C which is why I thought it was returning the correct values If it doesn't return the correct values then the firmware command is not working and I will close the PR - I will test with different AC conditions and ask some more people to test in their labs before doing so |
|
our labs can't be both exactly 20.0C on all channels 😅 |
|
yes, that is what I am saying |
No description provided.