Skip to content

Commit

Permalink
#232 Improve data yield in fast switching conditions (2)
Browse files Browse the repository at this point in the history
make grace period configurable
  • Loading branch information
dostuffthatmatters committed Dec 11, 2024
1 parent b42229f commit e07364c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"minute": 0,
"second": 0
},
"min_sun_elevation": 0
"min_sun_elevation": 0,
"shutdown_grace_period": 300
},
"tum_enclosure": null,
"helios": null,
Expand Down
5 changes: 4 additions & 1 deletion packages/core/threads/cas_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def main(headless: bool = False) -> None:
time_since_last_good_decision = (
time.time() - last_good_automatic_decision
)
if time_since_last_good_decision < 300:
if (
time_since_last_good_decision
< config.measurement_triggers.shutdown_grace_period
):
should_measure = True
logger.info(
f"Last good automatic decision was {time_since_last_good_decision} seconds ago – not shutting down yet."
Expand Down
12 changes: 12 additions & 0 deletions packages/core/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ class MeasurementTriggersConfig(StricterBaseModel):
start_time: TimeDict
stop_time: TimeDict
min_sun_elevation: float = pydantic.Field(..., ge=0, le=90)
shutdown_grace_period: float = pydantic.Field(
...,
ge=0,
le=3600,
description="How long to wait to stop measurements after the trigger conditions are not met anymore (in seconds)",
)


class PartialMeasurementTriggersConfig(StricterBaseModel):
Expand All @@ -146,6 +152,12 @@ class PartialMeasurementTriggersConfig(StricterBaseModel):
start_time: Optional[PartialTimeDict] = None
stop_time: Optional[PartialTimeDict] = None
min_sun_elevation: Optional[float] = pydantic.Field(None, ge=0, le=90)
shutdown_grace_period: Optional[float] = pydantic.Field(
None,
ge=0,
le=3600,
description="How long to wait to stop measurements after the trigger conditions are not met anymore (in seconds)",
)


class HeliosConfig(StricterBaseModel):
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
start_time={"hour": 7, "minute": 0, "second": 0},
stop_time={"hour": 21, "minute": 0, "second": 0},
min_sun_elevation=0,
shutdown_grace_period=300,
),
tum_enclosure=None,
helios=None,
Expand Down

0 comments on commit e07364c

Please sign in to comment.