You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Java implementation of the state machine standardized in ISA 88. The state machine guarantees that only transitions that only 'valid' transitions can be executed. Have a look at the following figure which depicts the state machine of ISA 88:
4
+
A Java implementation of the state machine standardized in ISA 88. The state machine guarantees that only 'valid' transitions can be executed. Have a look at the following figure which depicts the state machine of ISA 88:
5
5
6
6

7
7
@@ -10,10 +10,11 @@ As you can see in the figure, the state machine defines states and transitions t
10
10
* After production of an order has been completed, the state machine will change its current state to 'Complete'. It can only be reset from this state.
11
11
* When you fire a 'stop'-transition while being in 'Stopped' state, nothing happens
12
12
The state machine makes sure that no invalid transitions can be fired.
13
+
<br>
13
14
14
15
## Documentation
15
-
### Simple state machine without actions
16
-
To use the simplest version of the state machine in your code, you simply obtain an instance from the state machine builder. This state machine will then be in 'Idle' state and you can invoke the transitions shown in the figure above. Note that this simple state machine can just be used to simulate the state machine behavior.
16
+
### A simple state machine without actions
17
+
To use the simplest version of the state machine in your code, you simply obtain an instance from the state machine builder. This state machine will then be in 'Idle' state and you can invoke the transitions shown in the figure above. Note that this state machine cannot execute any actions while being in the active states and that it can just be used to simulate the state machine behavior.
17
18
18
19
```Java
19
20
// necessary imports
@@ -35,14 +36,36 @@ stateMachine.stop();
35
36
// see figure for more transitions
36
37
```
37
38
38
-
You can also create a state machine with a different initial state than 'Idle'. This can be done with the `withInitialState(State s)`-function of the builder. Simply pass in the state you want to have as the initial state to that function.
39
+
You can also create a state machine with a different initial state than 'Idle'. This can be done with the `withInitialState(State s)`-function of the builder. Simply pass in the state you want to have as the initial state to this function. The following example creates a state machine instance that start in the 'Stopped' state:
### Creating a real state machine that executes actions
45
-
The state machine of ISA88 allows for executing actions in all active states. You can create arbitrary actions and pass them to the state machine to let the state machine execute these actions in the correct states. To implement your own actions, simply implement the interface `IStateAction` as shown here:
45
+
As shown above, you can invoke transitions by calling the corresponing methods (start(), stop(), hold(), ...) on the state machine. Alternatively, you can also use this more dynamic version:
46
+
47
+
```java
48
+
invokeTransition(TransitionName transitionName)
49
+
```
50
+
This will invoke a transition with the given TransitionName.
51
+
<br>
52
+
53
+
### A real state machine that executes actions
54
+
The state machine of ISA88 allows for executing actions in all active states. These active states are:
55
+
56
+
* Starting
57
+
* Execute
58
+
* Holding
59
+
* Unholding
60
+
* Suspending
61
+
* Unsuspending
62
+
* Completing
63
+
* Resetting
64
+
* Stopping
65
+
* Aborting
66
+
* Clearing
67
+
68
+
You can create arbitrary actions and pass them to the state machine to let the state machine execute these actions in the correct states. To implement your own actions, simply implement the interface `IStateAction` as shown here:
46
69
47
70
```Java
48
71
importstates.IStateAction;
@@ -100,12 +123,21 @@ Sets action to be the action that is going to be executed when the state machine
100
123
##### withActionInResetting(IStateAction action)
101
124
Sets action to be the action that is going to be executed when the state machine is in 'Resetting' state.
102
125
126
+
<br><br>
127
+
Alternatively, you can also use the more flexible way of adding actions to states:
You can pass in an action and the name of an active state to add this action to a state.
133
+
134
+
103
135
### Getting notified on state changes
104
136
Work in progress, coming soon
105
137
106
138
107
139
## Usage
108
-
With Maven, it's very easy to use this library in your own projects. Releases are published to the Maven Central Repo, snapshot version can be obtained from Sonatype.
140
+
With Maven, it's very easy to use this library in your own projects. Releases are published to the Maven Central Repo, snapshot version can be obtained from Sonatype. Furthermore, you could also grab the .jar from the releases on this github repository. Note that the jar is built as an OSGi-bundle and can therefore be used in an OSGi environment.
109
141
110
142
### Releases
111
143
Releases can be found on the Maven Central repository. Just add this dependency to your pom.xml:
@@ -114,7 +146,7 @@ Releases can be found on the Maven Central repository. Just add this dependency
0 commit comments