From abc29eaa312562a7c4a090035e89cda8986ae2da Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 20 Aug 2023 02:39:57 +0200 Subject: [PATCH] Activity-Lang: complete implementation for Gate (conditional) Decision how to handle a failed Gate-check - spin forward (re-scheduler) by some time amount - this spin-offset parameter is retrieved from the Execution Context - thus it will be some kind of engine parameter With these determinations and the framework for the Execution Context it is now possible to code up the logic for Gate check, which in turn can then be verified by the watchGate diagnostics --- src/vault/gear/activity.hpp | 10 +++- tests/vault/gear/activity-detector-test.cpp | 18 +++++- tests/vault/gear/activity-detector.hpp | 19 ++++--- wiki/thinkPad.ichthyo.mm | 61 ++++++++++++++------- 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/src/vault/gear/activity.hpp b/src/vault/gear/activity.hpp index 9a53e7060..c4273f4f9 100644 --- a/src/vault/gear/activity.hpp +++ b/src/vault/gear/activity.hpp @@ -169,6 +169,7 @@ namespace gear { ASSERT_MEMBER_FUNCTOR (EXE::work, void(Time, size_t)); ASSERT_MEMBER_FUNCTOR (EXE::done, void(Time, size_t)); ASSERT_MEMBER_FUNCTOR (EXE::tick, Proc(Time)); + ASSERT_MEMBER_FUNCTOR (EXE::spin, Time(Time)); #undef ASSERT_MEMBER_FUNCTOR @@ -441,8 +442,13 @@ namespace gear { activity::Proc checkGate (Time now, EXE& executionCtx) { - UNIMPLEMENTED ("evaluate GATE condition and branch accordingly"); - return executionCtx.post (now, *next, executionCtx); + REQUIRE (GATE == verb_); + if (now > data_.condition.dead) // beyond deadline + return activity::SKIP; + if (0 < data_.condition.rest) // prerequisite count not(yet) fulfilled -> spin (=re-invoke later) + return executionCtx.post (executionCtx.spin(now), *this, executionCtx); + else + return activity::PASS; } template diff --git a/tests/vault/gear/activity-detector-test.cpp b/tests/vault/gear/activity-detector-test.cpp index 0d64687cd..dd6d8b990 100644 --- a/tests/vault/gear/activity-detector-test.cpp +++ b/tests/vault/gear/activity-detector-test.cpp @@ -336,8 +336,15 @@ namespace test { - /** @test TODO diagnostic setup to watch Activity::GATE activation - * @todo WIP 7/23 🔁 define ⟶ implement + /** @test diagnostic setup to watch Activity::GATE activation + * - when applied, Tap will be inserted before and after the + * instrumented GATE-Activity + * - it can thus be traced when the Gate is activated, + * but also when the Gate condition is met and the `next` + * Activity after the Gate is activated + * - for this unit-test, a Gate and a follow-up Activity + * is invoked directly, to verify the generated log entries + * @todo WIP 7/23 ✔ define ✔ implement */ void watch_gate() @@ -353,8 +360,13 @@ namespace test { Time tt{5,5}; wiring->activate(tt, detector.executionCtx); + ++detector; + wiring->next->activate(tt, detector.executionCtx); - cout<::Type done; _DiagnosticFun::Type tick; + static Time spin (Time now) { return now + SPIN_DELAY; } + FakeExecutionCtx (ActivityDetector& adi) : post{adi.buildDiagnosticFun(CTX_POST).returning(activity::PASS)} , work{adi.buildDiagnosticFun(CTX_WORK)} diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 0b3d24fbf..1836e0d16 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -77840,7 +77840,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -78447,6 +78447,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + @@ -78649,23 +78652,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - - + + - + - - - - + + + + - - + + - - + + @@ -81666,10 +81669,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - + @@ -81763,6 +81766,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + +
@@ -82059,6 +82065,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + @@ -82284,14 +82294,17 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + - - + + + + + @@ -82303,8 +82316,16 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + + + +

+ passende ID hierfür vergeben: afterGATE +

+ +
+