STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
burn_time_sync.py
Go to the documentation of this file.
1
"""Keep burn-time fields aligned across config sections."""
2
3
from
__future__
import
annotations
4
5
from
typing
import
TYPE_CHECKING, Optional
6
7
if
TYPE_CHECKING:
8
from
engine.pipeline.config_schemas
import
PintleEngineConfig
9
10
11
def
canonical_burn_time_s
(config:
"PintleEngineConfig"
) -> Optional[float]:
12
"""Return the authoritative burn time [s] from config.
13
14
Priority: design_requirements.target_burn_time, then pressure_curves.target_burn_time_s,
15
then thrust.burn_time.
16
"""
17
dr = getattr(config,
"design_requirements"
,
None
)
18
if
dr
is
not
None
and
getattr(dr,
"target_burn_time"
,
None
)
is
not
None
:
19
return
float(dr.target_burn_time)
20
21
pc = getattr(config,
"pressure_curves"
,
None
)
22
if
pc
is
not
None
and
getattr(pc,
"target_burn_time_s"
,
None
)
is
not
None
:
23
return
float(pc.target_burn_time_s)
24
25
thrust = getattr(config,
"thrust"
,
None
)
26
if
thrust
is
not
None
and
getattr(thrust,
"burn_time"
,
None
)
is
not
None
:
27
return
float(thrust.burn_time)
28
29
return
None
30
31
32
def
sync_burn_time_fields
(config:
"PintleEngineConfig"
) ->
None
:
33
"""In-place: set all present burn-time slots to the canonical value."""
34
bt =
canonical_burn_time_s
(config)
35
if
bt
is
None
:
36
return
37
38
dr = getattr(config,
"design_requirements"
,
None
)
39
if
dr
is
not
None
:
40
dr.target_burn_time = bt
41
42
thrust = getattr(config,
"thrust"
,
None
)
43
if
thrust
is
not
None
:
44
thrust.burn_time = bt
45
46
pc = getattr(config,
"pressure_curves"
,
None
)
47
if
pc
is
not
None
:
48
pc.target_burn_time_s = bt
engine.pipeline.burn_time_sync.canonical_burn_time_s
Optional[float] canonical_burn_time_s("PintleEngineConfig" config)
Definition
burn_time_sync.py:11
engine.pipeline.burn_time_sync.sync_burn_time_fields
None sync_burn_time_fields("PintleEngineConfig" config)
Definition
burn_time_sync.py:32
engine.pipeline.config_schemas
Definition
config_schemas.py:1
EngineDesign
engine
pipeline
burn_time_sync.py
Generated by
1.15.0