From e13320748d5920009c9292e2727d073cd63bb929 Mon Sep 17 00:00:00 2001 From: Enrico Eberhard <32450951+eeberhard@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:27:52 +0200 Subject: [PATCH] feat(schema): revise transitions and states (#177) * feat(schema): rename 'loaded' state to 'inactive' for controllers * feat(schema): add additional lifecycle transitions to components * docs: changelog * refactor: move on_shutdown transition further down in the order * feat: update static generated schemas --- docs/static/schemas/draft/2-0-0/application.d.ts | 9 ++++++--- .../schemas/draft/2-0-0/application.schema.json | 16 +++++++++++++--- schemas/applications/CHANGELOG.md | 2 ++ .../schema/common/condition_object.schema.json | 5 +++-- .../applications/schema/components.schema.json | 11 ++++++++++- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/static/schemas/draft/2-0-0/application.d.ts b/docs/static/schemas/draft/2-0-0/application.d.ts index e827da86..bd869d6a 100644 --- a/docs/static/schemas/draft/2-0-0/application.d.ts +++ b/docs/static/schemas/draft/2-0-0/application.d.ts @@ -227,7 +227,7 @@ export type ComponentState = /** * The runtime state of the controller */ -export type ControllerState = "unloaded" | "loaded" | "active"; +export type ControllerState = "unloaded" | "inactive" | "active"; /** * The runtime state of the hardware interface */ @@ -235,7 +235,7 @@ export type HardwareState = "unloaded" | "loaded"; /** * The runtime state of the sequence */ -export type SequenceState = "inactive" | "active"; +export type SequenceState = "inactive" | "active" | "aborted"; /** * True only when every listed item is true */ @@ -719,8 +719,11 @@ export interface ComponentStateTransitions { on_activate?: Events; on_deactivate?: Events; on_cleanup?: Events; - on_shutdown?: Events; + on_configure_failure?: Events; + on_activate_failure?: Events; on_error?: Events; + on_error_recovery?: Events; + on_shutdown?: Events; on_unload?: Events; } diff --git a/docs/static/schemas/draft/2-0-0/application.schema.json b/docs/static/schemas/draft/2-0-0/application.schema.json index 9677209d..d79f39ae 100644 --- a/docs/static/schemas/draft/2-0-0/application.schema.json +++ b/docs/static/schemas/draft/2-0-0/application.schema.json @@ -462,12 +462,21 @@ "on_cleanup": { "$ref": "#/$defs/events" }, - "on_shutdown": { + "on_configure_failure": { + "$ref": "#/$defs/events" + }, + "on_activate_failure": { "$ref": "#/$defs/events" }, "on_error": { "$ref": "#/$defs/events" }, + "on_error_recovery": { + "$ref": "#/$defs/events" + }, + "on_shutdown": { + "$ref": "#/$defs/events" + }, "on_unload": { "$ref": "#/$defs/events" } @@ -685,7 +694,7 @@ "type": "string", "enum": [ "unloaded", - "loaded", + "inactive", "active" ] } @@ -735,7 +744,8 @@ "type": "string", "enum": [ "inactive", - "active" + "active", + "aborted" ] } }, diff --git a/schemas/applications/CHANGELOG.md b/schemas/applications/CHANGELOG.md index 8c7ee06b..420e688b 100644 --- a/schemas/applications/CHANGELOG.md +++ b/schemas/applications/CHANGELOG.md @@ -24,6 +24,8 @@ Release Versions: - A running application can be stopped with the `application: stop` event from any event source - Components, controllers and hardware support dedicated transition events such as `on_load`, `on_activate` and `on_error` which behave as event triggers similar to predicates +- Lifecycle components have access to additional error handling with the `on_configure_failure`, `on_activate_failure`, + `on_error` and `on_error_recovery` transition events - Condition sources for sequence steps and conditions now include component, controller, hardware or sequence states in addition to the previous component or controller predicate sources - Hardware control rate can be supplemented with a `rate_tolerance` to determine the allowable deviation from the diff --git a/schemas/applications/schema/common/condition_object.schema.json b/schemas/applications/schema/common/condition_object.schema.json index 71d2a32a..1fc74b76 100644 --- a/schemas/applications/schema/common/condition_object.schema.json +++ b/schemas/applications/schema/common/condition_object.schema.json @@ -115,7 +115,7 @@ "type": "string", "enum": [ "unloaded", - "loaded", + "inactive", "active" ] } @@ -165,7 +165,8 @@ "type": "string", "enum": [ "inactive", - "active" + "active", + "aborted" ] } }, diff --git a/schemas/applications/schema/components.schema.json b/schemas/applications/schema/components.schema.json index b54f51f5..69b0040b 100644 --- a/schemas/applications/schema/components.schema.json +++ b/schemas/applications/schema/components.schema.json @@ -106,12 +106,21 @@ "on_cleanup": { "$ref": "events.schema.json" }, - "on_shutdown": { + "on_configure_failure": { + "$ref": "events.schema.json" + }, + "on_activate_failure": { "$ref": "events.schema.json" }, "on_error": { "$ref": "events.schema.json" }, + "on_error_recovery": { + "$ref": "events.schema.json" + }, + "on_shutdown": { + "$ref": "events.schema.json" + }, "on_unload": { "$ref": "events.schema.json" }