-
Notifications
You must be signed in to change notification settings - Fork 0
Implement sequences #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fweichselbaum
wants to merge
26
commits into
main
Choose a base branch
from
feat/sequences
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f15427b
add crates serde, toml & config
fweichselbaum f391e02
add json schema for sequences
fweichselbaum cb2f2aa
add derive feature for crate serde
fweichselbaum ef303b4
add toml sequences for sequence parsing tests
fweichselbaum ae11b14
add sequence control events
fweichselbaum 4fee8d2
add sequence definitions and parsing
fweichselbaum 1bc7a14
add sequence runner
fweichselbaum 564014a
spawn sequence runner thread
fweichselbaum 8f8d464
remove duplicate sequence loading logic
fweichselbaum 248d90e
fix shutdown behaviour of running sequences
fweichselbaum 79818ee
fix `minItems` for hold and set_param step
fweichselbaum bc25e8a
add check that sequence start time <= 0
fweichselbaum cecbadd
add check that sequence step needs at least 1 action
fweichselbaum 85633dd
add check that conditional hold needs at least 1 condition
fweichselbaum 5dc36f5
fixed test sequences syntax
fweichselbaum bf6226e
fixed tests in sequence definition by checking for error messages
fweichselbaum c81802a
improve sequence validation
fweichselbaum 0c964cc
add crate ntest for test timeouts
fweichselbaum 0f72f85
extract sequence validation function into separate functions
fweichselbaum 628f000
rework sequence building and running + tests
fweichselbaum dc2f9c2
change Event to contain the sequence, not just the sequence name
fweichselbaum bd091aa
change the `interpolate_linear` function to return an Option instead …
fweichselbaum db542a4
fix typo in `Duration` deserialization error message
fweichselbaum 5738b3c
use taplo.toml and adjust test sequences
fweichselbaum 79498a8
add README for sequences
fweichselbaum 5e08a83
improve formatting
fweichselbaum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://spaceteam.at/ferroflow/schemas/sequence.schema.json", | ||
| "title": "FerroFlow Sequence", | ||
| "description": "TOML schema for FerroFlow sequence files.", | ||
| "$defs": { | ||
| "setParam": { | ||
| "type": "object", | ||
| "description": "A parameter value to set at a specific.", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "timestamp", | ||
| "param", | ||
| "value" | ||
| ], | ||
| "properties": { | ||
| "timestamp": { | ||
| "type": "number", | ||
| "description": "Timestamp (seconds) relative to the parent step.", | ||
| "minimum": 0 | ||
| }, | ||
| "param": { | ||
| "type": "string" | ||
| }, | ||
| "value": { | ||
| "type": "number", | ||
| "description": "Logical value of the parameter (see parameter mapping)." | ||
| } | ||
| } | ||
| }, | ||
| "holdCondition": { | ||
| "type": "object", | ||
| "description": "A hold condition that gets evaluated at a specific timestamp.", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "field", | ||
| "is", | ||
| "value" | ||
| ], | ||
| "properties": { | ||
| "field": { | ||
| "type": "string" | ||
| }, | ||
| "is": { | ||
| "enum": [ | ||
| "equal", | ||
| "not_eq", | ||
| "less", | ||
| "less_eq", | ||
| "greater", | ||
| "greater_eq" | ||
| ], | ||
| "description": "Comparison operator for the conditional hold. Will be evaluated like `field <comparison> value`, so the field value is on the left and the provided value is on the right." | ||
| }, | ||
| "value": { | ||
| "type": "number", | ||
| "description": "Logical value of the field (see parameter mapping)." | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "name", | ||
| "globals", | ||
| "steps" | ||
| ], | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "globals": { | ||
| "type": "object", | ||
| "description": "Global settings for the sequence", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "start_time", | ||
| "end_time", | ||
| "interpolations", | ||
| "interpolation_interval" | ||
| ], | ||
| "properties": { | ||
| "start_time": { | ||
| "type": "number", | ||
| "description": "Start time (seconds) of the sequence, <= 0", | ||
| "maximum": 0 | ||
| }, | ||
| "end_time": { | ||
| "type": "number", | ||
| "description": "End time (seconds) of the sequence" | ||
| }, | ||
| "interpolation_interval": { | ||
| "type": "number", | ||
| "description": "The frequency (seconds) at which interpolated values are recalculated and sent", | ||
| "exclusiveMinimum": 0 | ||
| }, | ||
| "interpolations": { | ||
| "type": "object", | ||
| "description": "Mappings, how the param values should be interpolated", | ||
| "patternProperties": { | ||
| "^.+$": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "linear", | ||
| "none" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "steps": { | ||
| "type": "array", | ||
| "items": { | ||
| "anyOf": [ | ||
| { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "name", | ||
| "timestamp", | ||
| "hold" | ||
| ], | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string", | ||
| "description": "Optional." | ||
| }, | ||
| "timestamp": { | ||
| "type": "number", | ||
| "description": "A timestamp (seconds), when to execute the step." | ||
| }, | ||
| "hold": { | ||
| "type": "array", | ||
| "description": "A list of hold conditions. The sequence holds, when all conditions are satisfied. The sequence can then be manually resumed.", | ||
| "minItems": 1, | ||
| "items": { | ||
| "$ref": "#/$defs/holdCondition" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "name", | ||
| "timestamp", | ||
| "hold" | ||
| ], | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string", | ||
| "description": "Optional." | ||
| }, | ||
| "timestamp": { | ||
| "type": "number", | ||
| "description": "A timestamp (seconds), when to execute the step." | ||
| }, | ||
| "hold": { | ||
| "type": "string", | ||
| "description": "A signal, that the sequence unconditionally holds here. The value must be `always`. The sequence can then be manually resumed.", | ||
| "const": "always" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "name", | ||
| "timestamp", | ||
| "set_params" | ||
| ], | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string", | ||
| "description": "Optional." | ||
| }, | ||
| "timestamp": { | ||
| "type": "number", | ||
| "description": "A timestamp (seconds), when to execute the step." | ||
| }, | ||
| "set_params": { | ||
| "type": "array", | ||
| "description": "A list of `SetParam` actions.", | ||
| "minItems": 1, | ||
| "items": { | ||
| "$ref": "#/$defs/setParam" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # FerroFlow Sequences | ||
|
|
||
| Sequences define a timeline of automated parameter changes and (conditional) holds. They are defined as configuration files, preferably using TOML for readability. | ||
|
|
||
| ## Components | ||
|
|
||
| ### Globals | ||
| The `[globals]` section sets the sequence boundaries and interpolation settings: | ||
| - `start_time`: The global timestamp where the sequence begins (seconds). | ||
| - `end_time`: The global timestamp where the sequence ends (seconds). | ||
| - `interpolation_interval`: The frequency (seconds) at which interpolated values are recalculated and sent. | ||
| - `interpolations`: A map of parameter names to their interpolation mode (`linear` or `none`). If a parameter is not specified, the default is `none`. | ||
|
|
||
| ### Steps | ||
| Sequences are composed of `[[steps]]`. Each step occurs at a global `timestamp` (seconds) and must contain either `set_params` or a `hold` instruction. | ||
|
|
||
| #### Step: _Set Parameter_ | ||
| Changes system parameters at specific times. The `timestamp` within each entry in `set_params` is relative to the parent step's timestamp. | ||
| - `set_params`: A list of objects with `timestamp` (relative offset in seconds), `param` name, and `value`. | ||
|
|
||
| #### Step: _Hold_ | ||
| Pauses sequence execution at the step's timestamp. | ||
| - `hold = "always"`: The sequence pauses until manually resumed. | ||
| - `hold = [...]`: The sequence pauses if all conditions in the list are satisfied. The sequence stays paused until manually resumed. | ||
| - `field`: The telemetry field to monitor. | ||
| - `is`: Comparison operator (`equal`, `not_eq`, `less`, `less_eq`, `greater`, `greater_eq`). | ||
| - `value`: The numeric value to compare against. | ||
|
|
||
| ## Validation Rules | ||
|
|
||
| To ensure sequence integrity, the following rules are enforced during loading: | ||
|
|
||
| ### Global Constraints | ||
| - `start_time` must be less than or equal to `0.0`. | ||
| - `start_time` must be less than or equal to `end_time`. | ||
| - The sequence must contain at least one step. | ||
|
|
||
| ### Step Constraints | ||
| - **Ordering**: Steps must be defined in strictly increasing order of their `timestamp`. | ||
| - **Boundaries**: Every step's `timestamp` must fall between the global `start_time` and `end_time`. | ||
| - **Content**: Each step must contain at least one action (`hold` or `set_params`). | ||
|
|
||
| ### Action Constraints | ||
| - **Timing**: Every action must satisfy: | ||
| - `step.timestamp <= action.timestamp < next_step.timestamp` | ||
| - `action.timestamp <= globals.end_time` | ||
| - **Conditional Holds**: Must contain at least one condition. | ||
|
|
||
| ## Schema | ||
| The structure is defined in `schemas/sequence.schema.json`. Most editors/plugins will provide autocompletion and validation based on this schema. The schema should be automatically applied to any `.toml` file in a `sequence` or `sequences` directory or subdirectory. | ||
|
|
||
| ## Sample Sequence | ||
|
|
||
| ### TOML | ||
| ```toml | ||
| name = "Ox leak check" | ||
|
|
||
| [globals] | ||
| start_time = -5.0 | ||
| end_time = 10.0 | ||
| interpolation_interval = 0.01 | ||
| interpolations = { "ox_main_valve" = "linear" } | ||
|
|
||
| [[steps]] | ||
| name = "Initialize" | ||
| timestamp = -5.0 | ||
| set_params = [ | ||
| { timestamp = 0.0, param = "ox_vent", value = 1.0 }, | ||
| { timestamp = 0.0, param = "ox_main_valve", value = 0.0 } | ||
| ] | ||
|
|
||
| [[steps]] | ||
| name = "Pressure Check" | ||
| description = "Conditional hold" | ||
| timestamp = 1.0 | ||
| hold = [ | ||
| { field = "ox_pressure", is = "greater_eq", value = 50.0 } | ||
| ] | ||
|
|
||
| [[steps]] | ||
| name = "Manual Check" | ||
| timestamp = 3.0 | ||
| hold = "always" | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.