Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(impl)!: refactor namespaces to reduce complexity #4

Merged
merged 2 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed doc/sketches.vsd
Binary file not shown.
35 changes: 35 additions & 0 deletions docs/SortDecissionEvent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SortDecisionEvent

## Description
A `SortDecisionEvent` is a predefined `ITriggerEvent` that can be used specifically
to handle route decisions. Whenever a window passes a virtual trigger (trigger point)
that has a `SortDecisionEvent`, it is checked whether the item should trigger an
action of the `ExitHandler` at this trigger point.
Further more before and after the EventHandler, User defined (`IUserDefinedEvent`) events can be executed.

## Public interface:
|||
|-|-|
| SortStrategy : ISortStrategy; | Checks whether an action should be triggered for the item at this trigger point |
|ExitHandler : IExitPointHandler;| Action() of the IExitPointHandler is executed when SortStrategy.Check() returns TRUE|
|EventBefore : IUserDefinedEvent;| Userdefined event which is called before the Action() of the IExitPointHandler is called |
|EventAfter : IUserDefinedEvent; | Userdefined event which is called after the Action() of the IExitPointHandler is called |

## Class diagramm
```mermaid
classDiagram
SortDecisionEvent--|>ITriggerEvent
SortDecisionEvent : SortStrategy ISortStrategy
SortDecisionEvent : ExitHandler IExitPointHandler
SortDecisionEvent : EventBefore IUserDefinedEvent
SortDecisionEvent : EventAfter IUserDefinedEvent
ITriggerEvent : Action()
ITriggerEvent : ActionAfter()
ISortStrategy..SortDecisionEvent
ISortStrategy : Check(ITransportWindow, IVirtualTrigger, IExitPointHandler)
IExitPointHandler..SortDecisionEvent
IUserDefinedEvent..SortDecisionEvent
IUserDefinedEvent : EventStatus Action(IVirtualTrigger, ITransportWindow)
IExitPointHandler : BOOL Ready()
IExitPointHandler : BOOL Activate()
```
File renamed without changes
2 changes: 1 addition & 1 deletion src/EventHandler/EventStatus.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAMESPACE Simatic.Ax.WindowTracking.EventHandler
NAMESPACE Simatic.Ax.WindowTracking

TYPE
EventStatus : (Undefined, Finished, Error, NullReference, NotEnabled) := Undefined;
Expand Down
4 changes: 1 addition & 3 deletions src/EventHandler/ITriggerEvent.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
USING Simatic.Ax.WindowTracking.Trigger;

NAMESPACE Simatic.Ax.WindowTracking.EventHandler
NAMESPACE Simatic.Ax.WindowTracking
INTERFACE ITriggerEvent
METHOD Action : EventStatus
VAR_INPUT
Expand Down
4 changes: 1 addition & 3 deletions src/EventHandler/IUserDefinedEvent.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
USING Simatic.Ax.WindowTracking.Trigger;

NAMESPACE Simatic.Ax.WindowTracking.EventHandler
NAMESPACE Simatic.Ax.WindowTracking
INTERFACE IUserDefinedEvent
METHOD Action : EventStatus
VAR_INPUT
Expand Down
24 changes: 17 additions & 7 deletions src/EventHandler/SortDecisionEvent.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
USING Simatic.Ax.WindowTracking.EventHandler;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.WindowTracking.SortDecision;
USING Simatic.Ax.WindowTracking.ExitPointHandler;

NAMESPACE Simatic.Ax.WindowTracking.EventHandler
CLASS SortDecisionEvent IMPLEMENTS ITriggerEvent
NAMESPACE Simatic.Ax.WindowTracking
/// A sort decision event is a predefined trigger event that can be used specifically
/// to handle route decisions. Whenever a window passes a virtual trigger (trigger point)
/// that has a `sort decision event`, it is checked whether the item should trigger an
/// action at this trigger point.
///
/// Public interface:
/// SortStrategy : ISortStrategy;
/// Checks whether an action should be triggered for the item at this trigger point
///
/// ExitHandler : IExitPointHandler;
/// Action() of the IExitPointHandler is executed when SortStrategy.Check() returns TRUE
///
/// EventBefore : IUserDefinedEvent; Userdefined event which is called before the Action() of the IExitPointHandler is called
/// EventAfter : IUserDefinedEvent; Userdefined event which is called after the Action() of the IExitPointHandler is called
{axcode:docs-v0:@simatic-ax/windowtracking:SortDecissionEvent.md}
CLASS FINAL SortDecisionEvent IMPLEMENTS ITriggerEvent

VAR PUBLIC
SortStrategy : ISortStrategy;
Expand Down
6 changes: 2 additions & 4 deletions src/EventHandler/TerminateWindowEvent.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
USING Simatic.Ax.WindowTracking.Trigger;

NAMESPACE Simatic.Ax.WindowTracking.EventHandler
CLASS TerminateWindowEvent IMPLEMENTS ITriggerEvent
NAMESPACE Simatic.Ax.WindowTracking
CLASS FINAL TerminateWindowEvent IMPLEMENTS ITriggerEvent
VAR PUBLIC
WindowList : ITransportWindowsTerminate;
EventBefore : IUserDefinedEvent;
Expand Down
6 changes: 3 additions & 3 deletions src/Items/IItem.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USING Simatic.Ax.WindowTracking.EventHandler;
USING Simatic.Ax.WindowTracking.Trigger;
NAMESPACE Simatic.Ax.WindowTracking.Items
USING Simatic.Ax.WindowTracking;

NAMESPACE Simatic.Ax.WindowTracking
INTERFACE IItem
METHOD GetDestination : IVirtualTrigger
VAR_INPUT
Expand Down
4 changes: 1 addition & 3 deletions src/Items/Item1Destination.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
USING Simatic.Ax.WindowTracking.Trigger;

NAMESPACE Simatic.Ax.WindowTracking.Items
NAMESPACE Simatic.Ax.WindowTracking
CLASS ItemOneDestination IMPLEMENTS IItem

VAR PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion src/Others/IExitPointHandler.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAMESPACE Simatic.Ax.WindowTracking.ExitPointHandler
NAMESPACE Simatic.Ax.WindowTracking
INTERFACE IExitPointHandler
METHOD IsReady : BOOL
END_METHOD
Expand Down
5 changes: 2 additions & 3 deletions src/Others/ISortStrategy.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.WindowTracking.ExitPointHandler;
USING Simatic.Ax.WindowTracking;

NAMESPACE Simatic.Ax.WindowTracking.SortDecision
NAMESPACE Simatic.Ax.WindowTracking
INTERFACE ISortStrategy
METHOD Check : BOOL
VAR_INPUT
Expand Down
6 changes: 1 addition & 5 deletions src/Others/SortDecisionOneDestination.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
USING Simatic.Ax.WindowTracking.Items;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.WindowTracking.ExitPointHandler;

NAMESPACE Simatic.Ax.WindowTracking.SortDecision
NAMESPACE Simatic.Ax.WindowTracking
CLASS SortDecisionOneDestination IMPLEMENTS ISortStrategy
VAR PUBLIC

Expand Down
2 changes: 1 addition & 1 deletion src/Trigger/ITriggerList.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAMESPACE Simatic.Ax.WindowTracking.Trigger
NAMESPACE Simatic.Ax.WindowTracking
INTERFACE ITriggerList

METHOD Add : BOOL
Expand Down
4 changes: 2 additions & 2 deletions src/Trigger/IVirtualTrigger.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USING Simatic.Ax.WindowTracking.EventHandler;
USING Simatic.Ax.WindowTracking;

NAMESPACE Simatic.Ax.WindowTracking.Trigger
NAMESPACE Simatic.Ax.WindowTracking
INTERFACE IVirtualTrigger

METHOD ActivateEvent : EventStatus
Expand Down
6 changes: 3 additions & 3 deletions src/Trigger/VirtualTrigger.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
USING Simatic.Ax.WindowTracking.EventHandler;
USING Simatic.Ax.WindowTracking;

NAMESPACE Simatic.Ax.WindowTracking.Trigger
CLASS VirtualTrigger IMPLEMENTS IVirtualTrigger
NAMESPACE Simatic.Ax.WindowTracking
CLASS FINAL VirtualTrigger IMPLEMENTS IVirtualTrigger

VAR PUBLIC
Position : DINT;
Expand Down
4 changes: 2 additions & 2 deletions src/Trigger/VirtualTriggerList.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAMESPACE Simatic.Ax.WindowTracking.Trigger
CLASS VirtualTriggerList IMPLEMENTS ITriggerList
NAMESPACE Simatic.Ax.WindowTracking
CLASS FINAL VirtualTriggerList IMPLEMENTS ITriggerList
VAR PUBLIC
PositiveTolerance : DINT := 5;
NegativeTolerance : DINT := 5;
Expand Down
1 change: 0 additions & 1 deletion src/Window/ITransportWindow.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
USING Simatic.Ax.WindowTracking.Items;
USING Simatic.Ax.SimpleControlModules;

NAMESPACE Simatic.Ax.WindowTracking
Expand Down
3 changes: 0 additions & 3 deletions src/Window/ITransportWindowsTerminate.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.SimpleControlModules;

NAMESPACE Simatic.Ax.WindowTracking
INTERFACE ITransportWindowsTerminate

Expand Down
4 changes: 2 additions & 2 deletions src/Window/TransportWindow.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
USING Simatic.Ax.SimpleControlModules;
USING Simatic.Ax.WindowTracking.Items;

NAMESPACE Simatic.Ax.WindowTracking

CLASS TransportWindow IMPLEMENTS ITransportWindow
CLASS FINAL TransportWindow IMPLEMENTS ITransportWindow
VAR PUBLIC
Item : IItem;
END_VAR
Expand Down
4 changes: 1 addition & 3 deletions src/Window/TransportWindowList.st
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.SimpleControlModules;
USING Simatic.Ax.WindowTracking.Items;

NAMESPACE Simatic.Ax.WindowTracking
CLASS TransportWindowList IMPLEMENTS ITransportWindowsTerminate
CLASS FINAL TransportWindowList IMPLEMENTS ITransportWindowsTerminate
VAR PUBLIC
Encoder : IEncoder;
TriggerPointList : ITriggerList;
Expand Down
4 changes: 1 addition & 3 deletions test/ItemTest.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
USING AxUnit.Assert;
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.Trigger;

NAMESPACE Simatic.Ax.WindowTracking.Items
NAMESPACE Simatic.Ax.WindowTracking
{TestFixture}
CLASS ItemTest
VAR PROTECTED
Expand Down
6 changes: 1 addition & 5 deletions test/SortDecisionOneDestinationTest.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.EventHandler;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.WindowTracking.Items;
USING Simatic.Ax.WindowTracking.ExitPointHandler;

NAMESPACE Simatic.Ax.WindowTracking.SortDecision
NAMESPACE Simatic.Ax.WindowTracking
{TestFixture}
CLASS SortDecisionOneDestinationTest
VAR PROTECTED
Expand Down
4 changes: 1 addition & 3 deletions test/TerminateWindowTest.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.EventHandler;
USING Simatic.Ax.WindowTracking.Trigger;

NAMESPACE Simatic.Ax.WindowTracking.EventHandler
NAMESPACE Simatic.Ax.WindowTracking
{TestFixture}
CLASS TerminateWindowTest
VAR PROTECTED
Expand Down
1 change: 0 additions & 1 deletion test/TransportWindowTest.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.SimpleControlModules;


Expand Down
1 change: 0 additions & 1 deletion test/TransportWindowsListTest.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.SimpleControlModules;


Expand Down
4 changes: 2 additions & 2 deletions test/VirtualTriggerListTest.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
USING Simatic.Ax.WindowTracking.Trigger;
USING AxUnit.Assert;
NAMESPACE Simatic.Ax.WindowTracking.Trigger

NAMESPACE Simatic.Ax.WindowTracking
{TestFixture}
CLASS TestVirtualTriggerList
VAR PROTECTED
Expand Down
4 changes: 1 addition & 3 deletions test/VirtualTriggerTest.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.WindowTracking.EventHandler;
NAMESPACE Simatic.Ax.WindowTracking.Trigger
NAMESPACE Simatic.Ax.WindowTracking
{TestFixture}
CLASS TestVirtualTrigger
VAR PROTECTED
Expand Down
4 changes: 1 addition & 3 deletions test/WindowingIntegrativeTest.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
USING AxUnit.Assert;
USING Simatic.Ax.WindowTracking.Trigger;
USING Simatic.Ax.WindowTracking.EventHandler;
NAMESPACE Simatic.Ax.WindowTracking.Trigger
NAMESPACE Simatic.Ax.WindowTracking
{TestFixture}
CLASS WindowingIntegraiveTest
VAR PROTECTED
Expand Down