diff --git a/src/Moryx.ControlSystem/Activities/ActivityClassification.cs b/src/Moryx.ControlSystem/Activities/ActivityClassification.cs
index 7548c64..17f721d 100644
--- a/src/Moryx.ControlSystem/Activities/ActivityClassification.cs
+++ b/src/Moryx.ControlSystem/Activities/ActivityClassification.cs
@@ -15,6 +15,11 @@ namespace Moryx.ControlSystem.Activities
[Flags]
public enum ActivityClassification
{
+ ///
+ /// Use in case the activity classification is unkown
+ ///
+ Unknown = 0x00,
+
///
/// Default classification is production
///
@@ -33,6 +38,6 @@ public enum ActivityClassification
///
/// Activity performs a preparation, for example for a activity
///
- Preparation = 0x08
+ Preparation = 0x08,
}
}
diff --git a/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs b/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs
index 5d315fe..4ad1466 100644
--- a/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs
+++ b/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs
@@ -10,9 +10,6 @@ namespace Moryx.ControlSystem.Cells
///
public class ActivityCompleted : Session, ICompletableSession
{
- ///
- /// Initialize a new resource request for a certain resource
- ///
internal ActivityCompleted(IActivity completed, Session currentSession)
: base(currentSession)
{
diff --git a/src/Moryx.ControlSystem/Cells/Session.cs b/src/Moryx.ControlSystem/Cells/Session.cs
index 5f0474e..e379d73 100644
--- a/src/Moryx.ControlSystem/Cells/Session.cs
+++ b/src/Moryx.ControlSystem/Cells/Session.cs
@@ -125,6 +125,19 @@ public static ReadyToWork StartSession(ActivityClassification classification, Re
return CreateSession(classification, type, ProcessReference.InstanceIdentity(identity), constraints);
}
+
+ ///
+ /// Creates a new for the activity
+ /// with a new session context and marks the activity as failed.
+ ///
+ ///
+ public static UnknownActivityAborted WrapUnknownActivity(IActivity unknown)
+ {
+ var wrapper = StartSession(ActivityClassification.Unknown, ReadyToWorkType.Unset, unknown.Process.Id)
+ .CompleteSequence(null, false, new long[] { });
+ return new UnknownActivityAborted(unknown, wrapper);
+ }
+
private static ReadyToWork CreateSession(ActivityClassification classification, ReadyToWorkType type, ProcessReference reference, IConstraint[] constraints)
{
if (constraints == null)
diff --git a/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs b/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs
new file mode 100644
index 0000000..33a79ef
--- /dev/null
+++ b/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs
@@ -0,0 +1,26 @@
+// Copyright (c) 2024, Phoenix Contact GmbH & Co. KG
+// Licensed under the Apache License, Version 2.0
+
+using Moryx.AbstractionLayer;
+
+namespace Moryx.ControlSystem.Cells
+{
+ ///
+ /// Message send by the resource managment when it aborted an activity for an
+ /// unkown session.
+ ///
+ public class UnknownActivityAborted : ActivityCompleted
+ {
+ internal UnknownActivityAborted(IActivity aborted, Session wrapper)
+ : base(aborted, wrapper)
+ {
+ aborted.Fail();
+ AbortedActivity = aborted;
+ }
+
+ ///
+ /// Activity that was aborted
+ ///
+ public IActivity AbortedActivity { get; }
+ }
+}
diff --git a/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs b/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs
index 29f03f4..751b282 100644
--- a/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs
+++ b/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs
@@ -139,5 +139,20 @@ public void TestContinueSession(ReadyToWorkType readyToWorkType)
Assert.AreEqual(ReadyToWorkType.Pull, readyToWork2.ReadyToWorkType);
}
+ [Test]
+ public void TestUnknownActivityAborted()
+ {
+ // Arrange
+ var process = new Process { Id = 4242 };
+ var activity = new DummyActivity { Process = process };
+
+ // Act
+ var session = Session.WrapUnknownActivity(activity);
+
+ // Assert
+ Assert.That(session.AcceptedClassification, Is.EqualTo(ActivityClassification.Unknown));
+ Assert.That(session.AbortedActivity, Is.EqualTo(activity));
+ Assert.That(session.Reference.Matches(process));
+ }
}
}