Skip to content

Commit 969455f

Browse files
committed
Renamed ControlSystemAttached/Detached and added ProcessEngineContext
1 parent 6926d4e commit 969455f

File tree

14 files changed

+94
-115
lines changed

14 files changed

+94
-115
lines changed

docs/migrations/v8_to_v10.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ To reduce the number of API packages and simplify the overall architecture, **Mo
1414

1515
The simulator module has also been renamed, and its namespace and package id have changed accordingly to reflect its new location within Moryx.ControlSystem.
1616

17+
## ProcessEngineContext and ControlSystemAttached/Detached
18+
19+
The methods `ControlSystemAttached` and `ControlSystemDetached` were renamed to `ProcessEngineAttached` and `ProcessEngineDetached` to match the naming of the framework. ControlSystem is a term for multiple modules and components used within the framework (ProcessEngine, SetupProvider, MaterialManager, ...).
20+
21+
The `ProcessEngineContext` was added to the `ProcessEngineAttached` to provide the `Cell` a possibility to gather information from the process engine. The class is empty in 10.0 because it defines only the API. Features are implemented in the next feature-releases of MORYX 10.x.
1722

1823
## Renamings and Typo-Fixes
1924

@@ -29,6 +34,8 @@ The simulator module has also been renamed, and its namespace and package id hav
2934
- ProcessContext -> ProcessWorkplanContext
3035
- OperationClassification -> OperationStateClassification
3136
- OperationClassification.Loading -> OperationStateClassification.Assigning
37+
- IControlSystemBound.ControlSystemAttached -> ICell.ProcessEngineAttached
38+
- IControlSystemBound.ControlSystemDetached -> ICell.ProcessEngineDetached
3239

3340
## Reduction of interfaces
3441

@@ -38,6 +45,7 @@ Several interfaces have been removed to streamline the codebase and reduce compl
3845
- `IProductInstance`: Replaced with base-class `ProductInstance`
3946
- `IConfig`: Replaced with base-class `ConfigBase`
4047
- `IDatabaseConfig`: Replaced with base-class `DatabaseConfig`
48+
- `IControlSystemBound`: Merged with `ICell`
4149

4250
## Method Signature Changes
4351

src/Moryx.AbstractionLayer/Resources/Resource.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,16 @@ public override string ToString()
148148
return $"{Id}:{Name} ({GetType().Name})";
149149
}
150150

151-
/// <summary>
152-
/// Current capabilities of this resource
153-
/// </summary>
154-
private ICapabilities _capabilities = NullCapabilities.Instance;
155-
156151
/// <inheritdoc />
157152
public ICapabilities Capabilities
158153
{
159-
get
160-
{
161-
return _capabilities;
162-
}
154+
get;
163155
protected set
164156
{
165-
_capabilities = value;
166-
CapabilitiesChanged?.Invoke(this, _capabilities);
157+
field = value;
158+
CapabilitiesChanged?.Invoke(this, field);
167159
}
168-
}
160+
} = NullCapabilities.Instance;
169161

170162
/// <summary>
171163
/// <seealso cref="IResource"/>

src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void Handle(LinkedList<IJobData> newJobs)
7676
}
7777

7878
/// <summary>
79-
/// Creates and inserts setup and/or clean up for the <paramref name="current"/>
79+
/// Creates and inserts setup and/or clean up for the <paramref name="current"/>
8080
/// job. Returns the next job to be handled.
8181
/// </summary>
8282
private LinkedListNode<IJobData> HandleCurrentJob(LinkedList<IJobData> newJobs, LinkedListNode<IJobData> current)
@@ -164,7 +164,7 @@ private ISetupJobData FollowingCleanup(IJobData jobData)
164164
}
165165

166166
/// <summary>
167-
/// Abort the <paramref name="current"/> and all following jobs that would cause the
167+
/// Abort the <paramref name="current"/> and all following jobs that would cause the
168168
/// same exception during cleanup creation as they share the same recipe
169169
/// </summary>
170170
/// <param name="current">The job that caused the exception initially</param>
@@ -220,7 +220,7 @@ private bool RequiresCleanUpCreation(LinkedList<IJobData> newJobs, IJobData curr
220220
}
221221

222222
/// <summary>
223-
/// Abort the <paramref name="current"/> and all previous jobs that would cause the
223+
/// Abort the <paramref name="current"/> and all previous jobs that would cause the
224224
/// same exception during cleanup creation as they share the same recipe
225225
/// </summary>
226226
/// <param name="current">The job that caused the exception initially</param>
@@ -324,12 +324,12 @@ public IReadOnlyList<ICell> Cells(ICapabilities capabilities)
324324

325325
private class CellReference : Cell, ICell
326326
{
327-
public override IEnumerable<Session> ControlSystemAttached()
327+
protected override IEnumerable<Session> ProcessEngineAttached()
328328
{
329329
yield break;
330330
}
331331

332-
public override IEnumerable<Session> ControlSystemDetached()
332+
protected override IEnumerable<Session> ProcessEngineDetached()
333333
{
334334
yield break;
335335
}

src/Moryx.ControlSystem.ProcessEngine/Processes/CellReference.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public CellReference(long id)
2626
Id = id;
2727
}
2828

29-
public IEnumerable<Session> ControlSystemAttached()
29+
public IEnumerable<Session> ProcessEngineAttached(ProcessEngineContext context)
3030
{
3131
throw new NotImplementedException();
3232
}
3333

34-
public IEnumerable<Session> ControlSystemDetached()
34+
public IEnumerable<Session> ProcessEngineDetached()
3535
{
3636
throw new NotImplementedException();
3737
}

src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityDispatcher.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void Start()
9191
var cell = _cells[index];
9292
try
9393
{
94-
sessions[index] = cell.ControlSystemAttached()
94+
sessions[index] = cell.ProcessEngineAttached(new ProcessEngineContext())
9595
.Select(session => new ResourceAndSession(cell, session))
9696
.ToArray();
9797
}
@@ -116,7 +116,7 @@ public void Stop()
116116
{
117117
try
118118
{
119-
foreach (var session in cell.ControlSystemDetached().OfType<ActivityCompleted>())
119+
foreach (var session in cell.ProcessEngineDetached().OfType<ActivityCompleted>())
120120
HandleActivityCompleted(cell, session);
121121
}
122122
catch (Exception e)
@@ -206,7 +206,7 @@ private void OnResourcesAdded(object sender, IResource e)
206206
cell.ActivityCompleted += OnCellActivityCompleted;
207207

208208
// Attach the new cell
209-
var sessions = cell.ControlSystemAttached()
209+
var sessions = cell.ProcessEngineAttached(new ProcessEngineContext())
210210
.Select(s => new ResourceAndSession(cell, s));
211211
HandleAttachedCells(sessions);
212212
}

src/Moryx.ControlSystem/Cells/Cell.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.ComponentModel;
55
using Moryx.AbstractionLayer.Activities;
6-
using Moryx.AbstractionLayer.Capabilities;
76
using Moryx.AbstractionLayer.Resources;
87

98
namespace Moryx.ControlSystem.Cells
@@ -14,11 +13,30 @@ namespace Moryx.ControlSystem.Cells
1413
[Description("Base type for all cells within a production system")]
1514
public abstract class Cell : Resource, ICell
1615
{
16+
/// <summary>
17+
/// Context class used by the process engine to inform cell about updates
18+
/// </summary>
19+
public ProcessEngineContext ProcessEngineContext { get; private set; }
20+
1721
/// <inheritdoc />
18-
public abstract IEnumerable<Session> ControlSystemAttached();
22+
IEnumerable<Session> ICell.ProcessEngineAttached(ProcessEngineContext context)
23+
{
24+
ProcessEngineContext = context;
25+
return ProcessEngineAttached();
26+
}
27+
28+
/// <see cref="ICell.ProcessEngineAttached"/>
29+
protected abstract IEnumerable<Session> ProcessEngineAttached();
1930

2031
/// <inheritdoc />
21-
public abstract IEnumerable<Session> ControlSystemDetached();
32+
IEnumerable<Session> ICell.ProcessEngineDetached()
33+
{
34+
ProcessEngineContext = null;
35+
return ProcessEngineDetached();
36+
}
37+
38+
/// <see cref="ICell.ProcessEngineDetached"/>
39+
protected abstract IEnumerable<Session> ProcessEngineDetached();
2240

2341
/// <inheritdoc />
2442
public abstract void StartActivity(ActivityStart activityStart);
@@ -28,20 +46,7 @@ public virtual void ProcessAborting(IActivity affectedActivity) { }
2846

2947
/// <inheritdoc />
3048
public abstract void SequenceCompleted(SequenceCompleted completed);
31-
private ICapabilities _capabilities = NullCapabilities.Instance;
3249

33-
public ICapabilities Capabilities
34-
{
35-
get
36-
{
37-
return _capabilities;
38-
}
39-
protected set
40-
{
41-
_capabilities = value;
42-
this.CapabilitiesChanged?.Invoke(this, _capabilities);
43-
}
44-
}
4550
/// <summary>
4651
/// Publish a <see cref="ReadyToWork"/> from the resource
4752
/// </summary>
@@ -75,6 +80,5 @@ public void PublishActivityCompleted(ActivityCompleted activityResult)
7580

7681
/// <inheritdoc />
7782
public event EventHandler<ActivityCompleted> ActivityCompleted;
78-
public event EventHandler<ICapabilities> CapabilitiesChanged;
7983
}
8084
}

src/Moryx.ControlSystem/Cells/ICell.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,20 @@ namespace Moryx.ControlSystem.Cells
99
/// <summary>
1010
/// Interface for all cells
1111
/// </summary>
12-
public interface ICell : IResource, IControlSystemBound
12+
public interface ICell : IResource
1313
{
14+
/// <summary>
15+
/// Called if the process engine was attached to production cells.
16+
/// Can return currently active sessions within the cell
17+
/// </summary>
18+
IEnumerable<Session> ProcessEngineAttached(ProcessEngineContext context);
19+
20+
/// <summary>
21+
/// Called if the process engine was detached from production cells.
22+
/// Can return currently active sessions within the cell
23+
/// </summary>
24+
IEnumerable<Session> ProcessEngineDetached();
25+
1426
/// <summary>
1527
/// Start an activity in the cell
1628
/// </summary>
@@ -23,7 +35,7 @@ public interface ICell : IResource, IControlSystemBound
2335
void ProcessAborting(IActivity affectedActivity);
2436

2537
/// <summary>
26-
/// Callback from the control system, that the sequence was completed
38+
/// Callback from the process engine, that the sequence was completed
2739
/// </summary>
2840
void SequenceCompleted(SequenceCompleted completed);
2941

src/Moryx.ControlSystem/Cells/IControlSystemBound.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG
2+
// Licensed under the Apache License, Version 2.0
3+
4+
namespace Moryx.ControlSystem.Cells;
5+
6+
/// <summary>
7+
/// Context class used by the process engine to inform cell about updates
8+
/// </summary>
9+
public class ProcessEngineContext
10+
{
11+
12+
}

src/Moryx.Resources.Benchmarking/AssemblyCell.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ protected override void OnDispose()
3131
base.OnDispose();
3232
}
3333

34-
public override IEnumerable<Session> ControlSystemAttached()
34+
protected override IEnumerable<Session> ProcessEngineAttached()
3535
{
3636
yield break;
3737
}
3838

39-
public override IEnumerable<Session> ControlSystemDetached()
39+
protected override IEnumerable<Session> ProcessEngineDetached()
4040
{
4141
yield break;
4242
}

0 commit comments

Comments
 (0)