// ============================================================================= // DEE Action: ASA_Scenario5_CheckStationHasNoPendingTests // Scenario: 5 — Custom DEE Action at Every Stage // Stage: Detector // // Purpose: // Determine whether the target baking station is ready for recalibration by // checking that it has no active or queued quality tests in the QMS. // This is the per-oven readiness signal. If the QMS reports pending tests, // the task is skipped with SkippedNotReady and retried on the next pass. // // Simulation: // The pending-tests state for each station is controlled by a per-resource // MES Configuration Entry, toggled independently from the MES UI: // // Path : /Cmf/Tutorials/AutomationScheduleAction/Scenario5/NoPendingTests/{resourceName} // Type : Boolean // Value: true → no pending tests → detector returns ready // false → tests pending → SkippedNotReady // // Example entries for the tutorial resources: // /Cmf/Tutorials/AutomationScheduleAction/Scenario5/NoPendingTests/ASA Baker-01 // /Cmf/Tutorials/AutomationScheduleAction/Scenario5/NoPendingTests/ASA Baker-02 // // Set Baker-02 to false while Baker-01 is true to demonstrate that the // detector blocks one oven independently of the other. // // DEE Contract: // Input - Task : AutomationScheduledActionTask (includes target entity via EntityName) // Output - Result : Boolean (true = no pending tests, false = tests pending) // // Fail-closed: any exception or missing config is treated as false. // ============================================================================= using Cmf.Foundation.BusinessOrchestration.Abstractions; using Cmf.Foundation.BusinessOrchestration.ConfigurationManagement.InputObjects; using Cmf.Foundation.Common.Abstractions; using Cmf.Foundation.Configuration.Abstractions; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; namespace Cmf.Custom.Tutorials.AutomationScheduleAction.Actions { public class ASA_Scenario5_CheckStationHasNoPendingTests : DeeDevBase { public override bool DeeTestCondition(Dictionary Input) { //---Start DEE Condition Code--- return true; //---End DEE Condition Code--- } public override Dictionary DeeActionCode(Dictionary Input) { //---Start DEE Code--- UseReference("", "Cmf.Foundation.BusinessOrchestration.Abstractions"); UseReference("", "Cmf.Foundation.BusinessOrchestration.ConfigurationManagement"); UseReference("", "Cmf.Foundation.BusinessOrchestration.ConfigurationManagement.InputObjects"); IServiceProvider _svcProvider = Input["ServiceProvider"] as IServiceProvider; IEntityFactory _entFactory = _svcProvider.GetService(); //INPUT: Automation Scheduled Action Task var task = Input["Task"] as IAutomationScheduledActionTask; string resourceName = task?.EntityName ?? string.Empty; // In production this is where the QMS query would go // For simulation, we just read the config value to determine if there are pending tests const string configParentPath = "/Cmf/Tutorials/AutomationScheduleAction/Scenario5/NoPendingTests"; string configPath = $"{configParentPath}/{resourceName}"; IConfig testsConfig = _entFactory.Create(); if (!testsConfig.TryLoad(configPath)) { testsConfig.Name = resourceName; testsConfig.ValueType = "System.Boolean"; testsConfig.Value = false; testsConfig.Create(configParentPath); } bool noPendingTests = testsConfig.GetConfigValue(); //OUTPUT: Boolean - true if task can proceed, otherwise false Input["Result"] = noPendingTests; //---End DEE Code--- return Input; } } }