Improving CLI tool and improving documentation

This commit is contained in:
Martino Ferrari
2026-01-28 13:32:32 +01:00
parent 31996ae710
commit 01bcd66594
15 changed files with 895 additions and 16 deletions

44
examples/README.md Normal file
View File

@@ -0,0 +1,44 @@
# Examples
This directory contains example projects demonstrating different features and usage patterns of `mdt`.
## Directory Structure
```
examples/
simple/ # A basic, single-file application
complex/ # A multi-file project with custom schema
README.md # This file
```
## Running Examples
Prerequisite: `mdt` must be built (or installed). The Makefiles in the examples assume `mdt` is available at `../../build/mdt`.
### Simple Project
Demonstrates a minimal setup:
- Single `main.marte` file.
- Basic Thread and GAM definition.
**Run:**
```bash
cd simple
make check
make build
```
### Complex Project
Demonstrates advanced features:
- **Multi-file Structure**: `src/app.marte` (Logic) and `src/components.marte` (Data).
- **Namespaces**: Use of `#package` to organize nodes.
- **Custom Schema**: `.marte_schema.cue` defines a custom class (`CustomController`) with specific metadata (`#meta.multithreaded`).
- **Validation**: Enforces strict typing and custom rules.
**Run:**
```bash
cd complex
make check
make build
```

View File

@@ -0,0 +1,12 @@
package schema
#Classes: {
CustomController: {
#meta: {
multithreaded: false
}
Gain: float
InputSignals: {...}
OutputSignals: {...}
}
}

12
examples/complex/Makefile Normal file
View File

@@ -0,0 +1,12 @@
MDT=../../build/mdt
all: check build
check:
$(MDT) check src/*.marte
build:
$(MDT) build -o app_full.marte src/*.marte
fmt:
$(MDT) fmt src/*.marte

View File

@@ -0,0 +1,42 @@
#package complex_ex
+App = {
Class = RealTimeApplication
+States = {
Class = ReferenceContainer
+Run = {
Class = RealTimeState
+ControlThread = {
Class = RealTimeThread
Functions = { Controller }
}
}
}
+Functions = {
Class = ReferenceContainer
+Controller = {
Class = CustomController // Defined in .marte_schema.cue
Gain = 10.5
InputSignals = {
Ref = {
DataSource = App.Data.References
Type = float32
}
}
OutputSignals = {
Actuation = {
DataSource = App.Data.Actuators
Type = float32
}
}
}
}
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = TimingDS
}
}

View File

@@ -0,0 +1,24 @@
#package complex_ex.App.Data
+References = {
Class = GAMDataSource
Signals = {
Ref = {
Type = float32
}
}
}
+Actuators = {
Class = GAMDataSource
Signals = {
Actuation = {
Type = float32
}
}
}
+TimingDS = {
Class = TimingDataSource
}
+DDB1 = {
Class = GAMDataSource
}

12
examples/simple/Makefile Normal file
View File

@@ -0,0 +1,12 @@
MDT=../../build/mdt
all: check build
check:
$(MDT) check main.marte
build:
$(MDT) build -o output.marte main.marte
fmt:
$(MDT) fmt main.marte

View File

@@ -0,0 +1,60 @@
//# Main Application
+App = {
Class = RealTimeApplication
+Data = {
Class = ReferenceContainer
DefaultDataSource = DDB1
+Timer = {
Class = LinuxTimer
Signals = {
Counter = {
Type = uint32
}
//! unused: Time variable is not used
Time = {
Type = uint32
}
}
}
+Logger = {
Class = LoggerDataSource
}
+DDB1 = {
Class = GAMDataSource
}
}
+States = {
Class = ReferenceContainer
+Idle = {
Class = RealTimeState
+Thread1 = {
Class = RealTimeThread
CPUs = 0x1
Functions = { MyGAM }
}
}
}
+Functions = {
Class = ReferenceContainer
+MyGAM = {
Class = IOGAM
InputSignals = {
Counter = {
DataSource = Timer
Type = uint32
Frequency = 100 //Hz
}
}
OutputSignals = {
CounterCopy = {
DataSource = Logger
Type = uint32
}
}
}
}
+Scheduler = {
Class = GAMScheduler
TimingDataSource = Timer
}
}