In diesem Kapitel setzt du die FillingCell nach dem Produktionsauftrag wieder auf die Standard-Sorte zurück, mit demselben BlendChange-Task, aber einem zweiten Trigger mit AfterProduction. Setup-/Cleanup-Jobs steuert die Process Engine; siehe dazu auch Process Engine.
| Setup | Cleanup | |
|---|---|---|
| Wann | Vor der Produktion | Nach der Produktion |
| Warum | Anlage passt noch nicht zum Auftrag | Anlage wieder in neutralen Zustand |
| Bei uns | Blend auf Produkt-Sorte rüsten | Blend auf Standard (Sencha) zurücksetzen |
Gesamtablauf mit einer FillingCell:
Auftrag Chamomile, Menge 20 starten
1. Setup: BlendChange auf Chamomile (einmal vor dem Job)
2. Production: 20 mal Weighing, Filling, Sealing
3. Cleanup: BlendChange auf Sencha (einmal nach dem kompletten Job)
Cleanup hängt am Production-Job, nicht am einzelnen Beutel. Bei Menge 20 kommt Cleanup erst, wenn alle 20 durch sind, nicht nach dem ersten Stück.
Die Cleanup Instruction erscheint erst, wenn der Production-Job fertig ist.
Beim nächsten Auftrag (z. B. Earl Grey) ist die Zelle wieder auf Sencha. Setup muss erneut rüsten. So siehst du Setup und Cleanup im Wechsel.
Wir verwenden BlendChangeTask / BlendChangeActivity wieder, es ist nämlich kein neuer Activity-Typ nötig. Nur ein zweiter Trigger mit AfterProduction.
Zunächst müssen wir wieder zwei neue Dateien anlegen in src/TeaFactory.ControlSystem/SetupTriggers/.
ResetBlendAfterProductionConfig.cs
Die Config hält den Default-Blend, auf den nach der Produktion zurückgesetzt wird, typischerweise Sencha.
namespace TeaFactory.ControlSystem.SetupTriggers;
/// <summary>
/// Config for <see cref="ResetBlendAfterProductionTrigger"/>.
/// </summary>
public class ResetBlendAfterProductionConfig : SetupTriggerConfig
{
public override string PluginName => nameof(ResetBlendAfterProductionTrigger);
/// <summary>
/// Blend the filling cell is reset to after production (cleanup).
/// </summary>
[DataMember]
[EntrySerialize]
public TeaBlend DefaultBlend { get; set; } = TeaBlend.Sencha;
}ResetBlendAfterProductionTrigger.cs
Wichtig: Gleiche zwei Methoden wie bei Setup, Evaluate und CreateSteps. Nur Execution ist anders.
Evaluate prüft, ob das Produkt überhaupt vom Default abweicht. SetupEvaluation.Remove sagt dem SetupProvider: Die Produktions-Capability entfernen und den Default-Zustand herstellen.
namespace TeaFactory.ControlSystem.SetupTriggers;
/// <summary>
/// After the production job finished: reset the filling cell to the default blend (cleanup)
/// Runs once per production job (e.g. after all 20 bags), not after each single piece
/// </summary>
[ExpectedConfig(typeof(ResetBlendAfterProductionConfig))]
[Plugin(LifeCycle.Transient, typeof(ISetupTrigger), Name = nameof(ResetBlendAfterProductionTrigger))]
public class ResetBlendAfterProductionTrigger : SetupTriggerBase<ResetBlendAfterProductionConfig>
{
public override SetupExecution Execution => SetupExecution.AfterProduction;
public override SetupEvaluation Evaluate(IProductRecipe recipe)
{
if (recipe.Product is not TeaBagType product)
return false;
// Product already uses the default blend, nothing to reset
if (product.Blend == Config.DefaultBlend)
return false;
// Remove the production blend, target state is the default blend on the cell
// SetupProvider can skip cleanup if no cell still provides the production blend
return SetupEvaluation.Remove(
new FillingCapabilities { Blend = product.Blend },
new FillingCapabilities { Blend = Config.DefaultBlend },
SetupClassification.Manual);
}
public override IReadOnlyList<IWorkplanStep> CreateSteps(IProductRecipe recipe)
{
return
[
new BlendChangeTask
{
Parameters = new BlendChangeParameters
{
Blend = Config.DefaultBlend,
Instructions =
[
new VisualInstruction
{
Type = InstructionContentType.Text,
Content = $"Cleanup: reset filling cell to default blend '{Config.DefaultBlend}'"
}
]
}
}
];
}
}Nach Codeänderung App neu starten. Im Command Center SetupProvider, Register
Configuration, SetupTriggers: Typ ResetBlendAfterProductionConfig hinzufügen,
dann Save und Restart.
- FillingCell startet auf Sencha (Ressourcen-UI prüfen)
- Auftrag Chamomile oder Earl Grey anlegen und BEGIN
- Setup: Instruction auf Chamomile, dann SUCCESS
- Production komplett durchlaufen (gesamte Stückzahl)
- Cleanup: Instruction auf Sencha, dann SUCCESS
- FillingCell, Property Blend wieder Sencha
Nächster Auftrag mit anderer Sorte: wieder Setup, weil die Zelle auf Sencha steht.
- Auftrag wirklich durchgelaufen? Cleanup startet erst nach Production.
- Produkt war Sencha? Dann gibt
Evaluatefalsezurück, Cleanup ist unnötig. - Trigger in der Config auf
Disabled: true? - App nach Config-Änderung neu gestartet?
-
ResetBlendAfterProductionConfigund-Triggerunter SetupTriggers angelegt -
Execution = AfterProduction; gleiche Activity wie Setup - Trigger im SetupProvider aktiviert (Save + Restart)
- Auftrag mit anderer Sorte als Sencha: Setup, Production, Cleanup getestet
- FillingCell.Blend nach Cleanup wieder Sencha