Skip to content

Commit

Permalink
put a sleep in to avoid a rc
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed May 21, 2024
1 parent 7c11bb5 commit e96c7e3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- fix `pio workers update-active` using the wrong HTTP verb.
- When the local access point would start on a fresh boot, the SSID would start as `pioreactor`, and then change to `pioreactor-<leader-name>` after the next reboot. Now, this will now always be `pioreactor-<leader-name>`.
- Fix using ethernet cable to connect Pioreactor to a router: a new simple ethernet nmconnection has been added, and has higher connection priority than the PioreactorLocalLink nmconnection.
- Fix race conditions between stirring and growth-rate.

### 24.5.13

Expand Down
6 changes: 3 additions & 3 deletions pioreactor/actions/self_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_all_positive_correlations_between_pds_and_leds(
adc_reader = ADCReader(
channels=ALL_PD_CHANNELS, dynamic_gain=False, fake_data=is_testing_env(), penalizer=0.0
)
adc_reader.setup_adc()
adc_reader.tune_adc()

ir_led_channel = cast(LedChannel, config["leds_reverse"][IR_keyword])

Expand Down Expand Up @@ -240,7 +240,7 @@ def test_ambient_light_interference(client: Client, logger: CustomLogger, unit:
fake_data=is_testing_env(),
)

adc_reader.setup_adc()
adc_reader.tune_adc()
led_intensity(
{channel: 0 for channel in ALL_LED_CHANNELS},
unit=unit,
Expand Down Expand Up @@ -273,7 +273,7 @@ def test_REF_is_lower_than_0_dot_256_volts(
adc_reader = ADCReader(
channels=[reference_channel], dynamic_gain=False, fake_data=is_testing_env(), penalizer=0.0
)
adc_reader.setup_adc()
adc_reader.tune_adc()

with change_leds_intensities_temporarily(
{ir_channel: ir_intensity},
Expand Down
3 changes: 3 additions & 0 deletions pioreactor/background_jobs/growth_rate_calculating.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from datetime import datetime
from json import dumps
from json import loads
from time import sleep
from typing import Generator

import click
Expand Down Expand Up @@ -243,6 +244,8 @@ def create_obs_noise_covariance(self, obs_std): # type: ignore
def _compute_and_cache_od_statistics(
self,
) -> tuple[dict[pt.PdChannel, float], dict[pt.PdChannel, float]]:
# why sleep? Users sometimes spam jobs, and if stirring and gr start closely there can be a race to secure HALL_SENSOR. This gives stirring priority.
sleep(5)
means, variances = od_statistics(
self._yield_od_readings_from_mqtt(),
action_name="od_normalization",
Expand Down
8 changes: 4 additions & 4 deletions pioreactor/background_jobs/od_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ADCReader(LoggerMixin):
from pioreactor.background_jobs.od_reading import ADCReader
adc = ADCReader(["1", "2"], fake_data=False)
adc.setup_adc()
adc.tune_adc()
while True:
print(adc.take_reading())
Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(
else:
self.most_appropriate_AC_hz = None

def setup_adc(self) -> PdChannelToVoltage:
def tune_adc(self) -> PdChannelToVoltage:
"""
This configures the ADC for reading, performs an initial read, and sets variables based on that reading.
Expand Down Expand Up @@ -425,7 +425,7 @@ def take_reading(self) -> PdChannelToVoltage:
"""
if not self._setup_complete:
raise ValueError("Must call setup_adc() first.")
raise ValueError("Must call tune_adc() first.")

max_signal = -1.0
oversampling_count = self.oversampling_count
Expand Down Expand Up @@ -906,7 +906,7 @@ def __init__(
self.start_ir_led()
sleep(0.10)

on_reading = self.adc_reader.setup_adc() # determine best gain, max-signal, etc.
on_reading = self.adc_reader.tune_adc() # determine best gain, max-signal, etc.

# IR led is off so we can set blanks
self.stop_ir_led()
Expand Down

0 comments on commit e96c7e3

Please sign in to comment.