diff --git a/src/Moryx.ControlSystem/Cells/ReadyToWork.cs b/src/Moryx.ControlSystem/Cells/ReadyToWork.cs index 5fe92c0..af53fe8 100644 --- a/src/Moryx.ControlSystem/Cells/ReadyToWork.cs +++ b/src/Moryx.ControlSystem/Cells/ReadyToWork.cs @@ -52,10 +52,8 @@ internal ReadyToWork(Session currentSession) /// /// The activity. public ActivityStart StartActivity(IActivity activity) - { - // Update process before next stage - Process = activity.Process; - return new ActivityStart(this, activity); + { + return new ActivityStart(this, activity) { Process = activity.Process }; } /// @@ -63,9 +61,7 @@ public ActivityStart StartActivity(IActivity activity) /// public SequenceCompleted CompleteSequence(IProcess process, bool processActive, params long[] nextCells) { - // Update process before next stage - Process = process; - return new SequenceCompleted(this, processActive, nextCells); + return new SequenceCompleted(this, processActive, nextCells) { Process = process }; } /// diff --git a/src/Moryx.ControlSystem/Cells/Session.cs b/src/Moryx.ControlSystem/Cells/Session.cs index 2b3e738..19574b7 100644 --- a/src/Moryx.ControlSystem/Cells/Session.cs +++ b/src/Moryx.ControlSystem/Cells/Session.cs @@ -37,7 +37,7 @@ protected Session(Session currentSession) /// /// Context class holding all session information /// - private readonly SessionContext _context; + private SessionContext _context; /// /// Unique id of the current production transaction @@ -134,24 +134,27 @@ private static ReadyToWork CreateSession(ActivityClassification classification, #endregion - private class SessionContext + private struct SessionContext { internal SessionContext(ActivityClassification classification, Guid sessionId, ProcessReference reference) { Classification = classification; SessionId = sessionId; Reference = reference; + + Tag = null; + Process = null; } - public Guid SessionId { get; } + public Guid SessionId; - public IProcess Process { get; set; } + public IProcess Process; - public ProcessReference Reference { get; set; } + public ProcessReference Reference; - public ActivityClassification Classification { get; } + public ActivityClassification Classification; - public object Tag { get; set; } + public object Tag; } } } diff --git a/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs b/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs index 52a5995..29f03f4 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs @@ -46,10 +46,11 @@ public void TestCreateActivityStart() { var readyToWork = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Pull, 4242); - var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process() }); + var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process { Id = 4242 } }); Assert.AreEqual(readyToWork.Reference, activityStart.Reference); Assert.AreEqual(readyToWork.Id, activityStart.Id); + Assert.AreNotEqual(readyToWork.Process, activityStart.Process); // Make sure process is not populated back to RTW } [Test] @@ -82,7 +83,7 @@ public void TestCreateActivityResult() { var readyToWork = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Pull, 4242); - var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process() }); + var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process { Id = 4242 } }); activityStart.Activity.Complete(1); var activityCompleted = activityStart.CreateResult(); @@ -96,7 +97,7 @@ public void TestCompleteSequence() { var readyToWork = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Pull, 4242); - var activityStart = readyToWork.StartActivity(new DummyActivity {Process = new Process()}); + var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process { Id = 4242 } }); activityStart.Activity.Complete(1); var activityCompleted = activityStart.CreateResult(); @@ -123,7 +124,7 @@ public void TestContinueSession(ReadyToWorkType readyToWorkType) { var readyToWork = Session.StartSession(ActivityClassification.Production, readyToWorkType, 4242); - var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process() }); + var activityStart = readyToWork.StartActivity(new DummyActivity { Process = new Process { Id = 4242 } }); activityStart.Activity.Complete(1); var activityCompleted = activityStart.CreateResult();