Skip to content
Open
Show file tree
Hide file tree
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 Apr 17, 2026
f391e02
add json schema for sequences
fweichselbaum Apr 17, 2026
cb2f2aa
add derive feature for crate serde
fweichselbaum Apr 17, 2026
ef303b4
add toml sequences for sequence parsing tests
fweichselbaum Apr 18, 2026
ae11b14
add sequence control events
fweichselbaum Apr 18, 2026
4fee8d2
add sequence definitions and parsing
fweichselbaum Apr 18, 2026
1bc7a14
add sequence runner
fweichselbaum Apr 18, 2026
564014a
spawn sequence runner thread
fweichselbaum Apr 18, 2026
8f8d464
remove duplicate sequence loading logic
fweichselbaum Apr 19, 2026
248d90e
fix shutdown behaviour of running sequences
fweichselbaum Apr 20, 2026
79818ee
fix `minItems` for hold and set_param step
fweichselbaum Apr 22, 2026
bc25e8a
add check that sequence start time <= 0
fweichselbaum Apr 22, 2026
cecbadd
add check that sequence step needs at least 1 action
fweichselbaum Apr 22, 2026
85633dd
add check that conditional hold needs at least 1 condition
fweichselbaum Apr 22, 2026
5dc36f5
fixed test sequences syntax
fweichselbaum Apr 22, 2026
bf6226e
fixed tests in sequence definition by checking for error messages
fweichselbaum Apr 22, 2026
c81802a
improve sequence validation
fweichselbaum Apr 23, 2026
0c964cc
add crate ntest for test timeouts
fweichselbaum Apr 30, 2026
0f72f85
extract sequence validation function into separate functions
fweichselbaum Apr 30, 2026
628f000
rework sequence building and running + tests
fweichselbaum Apr 30, 2026
dc2f9c2
change Event to contain the sequence, not just the sequence name
fweichselbaum May 4, 2026
bd091aa
change the `interpolate_linear` function to return an Option instead …
fweichselbaum May 4, 2026
db542a4
fix typo in `Duration` deserialization error message
fweichselbaum May 4, 2026
5738b3c
use taplo.toml and adjust test sequences
fweichselbaum May 25, 2026
79498a8
add README for sequences
fweichselbaum May 25, 2026
5e08a83
improve formatting
fweichselbaum May 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
443 changes: 433 additions & 10 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ chrono = "0.4"
serde_json = "1.0"
anyhow = "1.0.102"
dashmap = "6.1.0"
toml = "1.1.2"
serde = { version = "1.0.228", features = ["derive"] }
config = "0.15.22"

[dev-dependencies]
diesel_migrations = "2.3"
ntest = "0.9.5"
testcontainers = { version = "0.27", features = ["blocking"] }
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Ferroflow is the new control software for all Liquid Rocketry projects at the TU
It interfaces with our custom Engine Control Units ECUs, through our custom [LiquidCAN protocol](https://github.com/SpaceTeam/LiquidCAN/).
On the other end, it provides a high-level API for our [ECUI](https://github.com/SpaceTeam/web_ecui_houbolt), which is the user interface for our ECUs.

## Sequences
Ferroflow supports automated sequences for parameter changes and holds.
See the [Sequences README](sequences/README.md) for more information.

# Setup
TODO

Expand Down
208 changes: 208 additions & 0 deletions schemas/sequence.schema.json
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"
}
}
}
Comment thread
fweichselbaum marked this conversation as resolved.
},
{
"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"
}
}
}
}
]
}
}
}
}
84 changes: 84 additions & 0 deletions sequences/README.md
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"
```
8 changes: 8 additions & 0 deletions src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::sync::{RwLock, mpsc::Sender};

use crate::sequence::Sequence;
use liquidcan::{CanMessage, CanMessageId};
use socketcan::CanAnyFrame;

Expand All @@ -22,6 +23,13 @@ pub enum Event {
from_interface: String,
frame: CanAnyFrame,
},
StartSequence {
seq: Sequence,
abort_seq: Sequence,
},
PauseSequence,
ResumeSequence,
AbortSequence,
}

struct EventListener {
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(clippy::single_match)]
use anyhow::Result;
use ferro_flow::{can, config, db, events, nodes};
use ferro_flow::{can, config, db, events, nodes, sequence};

fn main() -> Result<()> {
let _config = config::load_config()?;
Expand All @@ -22,6 +22,7 @@ fn main() -> Result<()> {
&event_dispatcher,
scope,
);
sequence::spawn_sequence_runner_thread(&event_dispatcher, scope);

Ok(())
});
Expand Down
Loading