From 43a45881ad4dffea2911d82c6cd151d0f81f36db Mon Sep 17 00:00:00 2001
From: "luca.conterio" <luca.conterio@skywarder.eu>
Date: Thu, 21 Oct 2021 11:57:38 +0200
Subject: [PATCH] [FSM] Added mermaid readme

---
 src/boards/DeathStack/AirBrakes/readme.md     |  3 +-
 .../ApogeeDetectionAlgorithm/readme.md        | 11 +++++
 src/boards/DeathStack/Deployment/readme.md    |  9 +----
 .../DeathStack/FlightModeManager/readme.md    | 40 +++++++++++++++++++
 .../DeathStack/FlightStatsRecorder/readme.md  | 10 +++++
 .../NavigationAttitudeSystem/readme.md        |  5 ++-
 6 files changed, 67 insertions(+), 11 deletions(-)
 create mode 100644 src/boards/DeathStack/ApogeeDetectionAlgorithm/readme.md
 create mode 100644 src/boards/DeathStack/FlightModeManager/readme.md
 create mode 100644 src/boards/DeathStack/FlightStatsRecorder/readme.md

diff --git a/src/boards/DeathStack/AirBrakes/readme.md b/src/boards/DeathStack/AirBrakes/readme.md
index ef63c80a..32dfce51 100644
--- a/src/boards/DeathStack/AirBrakes/readme.md
+++ b/src/boards/DeathStack/AirBrakes/readme.md
@@ -1,7 +1,6 @@
 ```mermaid
 stateDiagram-v2
-    [*] --> initialization
-    initialization --> idle
+    [*] --> idle
     idle --> shadow_mode : EV_LIFTOFF
     idle --> test_airbrakes : EV_TEST_ABK
     shadow_mode --> enabled : EV_SHADOW_MODE_TIMEOUT
diff --git a/src/boards/DeathStack/ApogeeDetectionAlgorithm/readme.md b/src/boards/DeathStack/ApogeeDetectionAlgorithm/readme.md
new file mode 100644
index 00000000..235ffbbf
--- /dev/null
+++ b/src/boards/DeathStack/ApogeeDetectionAlgorithm/readme.md
@@ -0,0 +1,11 @@
+```mermaid
+stateDiagram-v2
+    [*] --> idle
+    idle --> calibrating : EV_CALIBRATE_ADA
+    calibrating --> ready : EV_ADA_READY
+    ready --> shadow_mode : EV_LIFTOFF
+    shadow_mode --> active_mode : EV_SHADOW_MODE_TIMEOUT
+    active_mode --> pressure_stabilization : EV_ADA_APOGEE_DETECTED
+    pressure_stabilization --> drogue_descent : EV_TIMEOUT_PRESS_STABILIZATION
+    drogue_descent -->  : EV_ADA_DPL_ALT_DETECTED
+```
\ No newline at end of file
diff --git a/src/boards/DeathStack/Deployment/readme.md b/src/boards/DeathStack/Deployment/readme.md
index 22794a43..7dacbd62 100644
--- a/src/boards/DeathStack/Deployment/readme.md
+++ b/src/boards/DeathStack/Deployment/readme.md
@@ -3,12 +3,7 @@ stateDiagram-v2
     [*] --> idle
     idle --> nosecone_ejection : EV_NC_OPEN
     idle --> cutting_primary : EV_CUT_DROGUE
-    idle --> test_cutting_primary : EV_TEST_CUT_PRIMARY
-    idle --> test_cutting_backup : EV_TEST_CUT_BACKUP
     nosecone_ejection --> idle : EV_NC_DETACHED
     nosecone_ejection --> idle : EV_NC_OPEN_TIMEOUT
-    cutting_primary --> cutting_backup : EV_CUTTING_TIMEOUT
-    cutting_backup --> idle : EV_CUTTING_TIMEOUT
-    test_cutting_primary --> idle : EV_CUTTING_TIMEOUT
-    test_cutting_backup --> idle : EV_CUTTING_TIMEOUT
-```
+    cutting --> idle : EV_CUTTING_TIMEOUT
+```
\ No newline at end of file
diff --git a/src/boards/DeathStack/FlightModeManager/readme.md b/src/boards/DeathStack/FlightModeManager/readme.md
new file mode 100644
index 00000000..e1282719
--- /dev/null
+++ b/src/boards/DeathStack/FlightModeManager/readme.md
@@ -0,0 +1,40 @@
+```mermaid
+stateDiagram-v2
+    [*] --> OnGround
+    on_ground --> flying : EV_TC_LAUNCH
+    on_ground --> init_done : EV_INIT_OK
+    on_ground --> init_error : EV_INIT_ERROR
+    on_ground --> init_done : EV_TC_FORCE_INIT
+    on_ground --> test_mode : EV_TC_TEST_MODE
+    on_ground --> sensors_calibration : EV_TC_CALIBRATE_SENSORS
+    on_ground --> test_mode : EV_TC_NC_OPEN
+    on_ground --> test_mode : EV_TC_DPL_WIGGLE_SERVO
+    on_ground --> test_mode : EV_TC_DPL_RESET_SERVO
+    on_ground --> test_mode : EV_TC_CUT_DROGUE
+    on_ground --> test_mode : EV_TC_ABK_WIGGLE_SERVO
+    on_ground --> test_mode : EV_TC_ABK_RESET_SERVO
+    on_ground --> test_mode : EV_TC_TEST_ABK
+    on_ground --> test_mode : EV_TC_CLOSE_LOG
+    on_ground --> test_mode : EV_TC_START_LOG
+    on_ground --> sensors_calibration : EV_TC_CALIBRATE_SENSORS
+    on_ground --> algos_calibration : EV_SENSORS_READY
+    on_ground --> algos_calibration : EV_TC_CALIBRATE_ALGOS
+    on_ground --> algos_calibration : EV_ADA_READY
+    on_ground --> algos_calibration : EV_NAS_READY
+    on_ground --> disarmed : EV_CALIBRATION_OK
+    on_ground --> sensors_calibration : EV_TC_CALIBRATE_SENSORS
+    on_ground --> algos_calibration : EV_TC_CALIBRATE_ALGOS
+    on_ground --> armed : EV_TC_ARM
+    armed --> disarmed : EV_TC_DISARM
+    armed --> ascending : EV_UMBILICAL_DETACHED
+    armed --> ascending : EV_TC_LAUNCH
+    flying --> landed : EV_TC_END_MISSION
+    flying --> landed : EV_TIMEOUT_END_MISSION
+    flying --> ascending : EV_ADA_DISABLE_ABK
+    flying --> descending : EV_ADA_APOGEE_DETECTED
+    flying --> descending : EV_TC_NC_OPEN
+    flying --> terminal_descent : EV_ADA_DPL_ALT_DETECTED
+    flying --> terminal_descent : EV_TC_CUT_DROGUE
+    flying --> drogue_descent : EV_NC_DETACHED
+    flying --> terminal_descent : EV_TC_CUT_DROGUE
+```
\ No newline at end of file
diff --git a/src/boards/DeathStack/FlightStatsRecorder/readme.md b/src/boards/DeathStack/FlightStatsRecorder/readme.md
new file mode 100644
index 00000000..4d76543d
--- /dev/null
+++ b/src/boards/DeathStack/FlightStatsRecorder/readme.md
@@ -0,0 +1,10 @@
+```mermaid
+stateDiagram-v2
+    [*] --> idle
+    idle --> main_dlp : EV_DPL_ALTITUDE
+    idle --> liftoff : EV_LIFTOFF
+    main_dlp --> idle : EV_STATS_TIMEOUT
+    liftoff --> ascent : EV_STATS_TIMEOUT
+    ascent --> drogue_dpl : EV_APOGEE
+    drogue_dpl --> idle : EV_STATS_TIMEOUT
+```
\ No newline at end of file
diff --git a/src/boards/DeathStack/NavigationAttitudeSystem/readme.md b/src/boards/DeathStack/NavigationAttitudeSystem/readme.md
index 7aa33f5f..6159be55 100644
--- a/src/boards/DeathStack/NavigationAttitudeSystem/readme.md
+++ b/src/boards/DeathStack/NavigationAttitudeSystem/readme.md
@@ -1,8 +1,9 @@
 ```mermaid
 stateDiagram-v2
     [*] --> idle
-    idle --> triad : EV_CALIBRATE_NAS
-    triad --> ready : EV_NAS_READY
+    idle --> triad : EV_CALIBRATE
+    calibrating --> triad : EV_CALIBRATE_NAS
+    calibrating --> ready : EV_NAS_READY
     ready --> active : EV_LIFTOFF
     ready --> triad : EV_CALIBRATE_NAS
     active --> end : EV_LANDED
-- 
GitLab