Skip to content

Commit b80c86d

Browse files
committed
feat: add messageProcessor state machine
1 parent 8331b65 commit b80c86d

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

smartFactory/messageProcessor.pkl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import
2+
"https://raw.githubusercontent.com/CollaborativeStateMachines/Cirrina/refs/heads/develop/src/main/resources/pkl/csm/csml.pkl"
3+
4+
import "events.pkl" as Events
5+
import "serviceTypes.pkl" as ServiceTypes
6+
import "variables.pkl" as Vars
7+
8+
messageProcessorFSM = new csml.StateMachine {
9+
states {
10+
["idleState"] = new csml.Initial {
11+
on {
12+
[Events.eProcessMessage] {
13+
to = "processState"
14+
}
15+
16+
[Events.eJobDone] {
17+
to = "jobDoneState"
18+
}
19+
}
20+
}
21+
22+
["jobDoneState"] = new csml.Terminal {}
23+
}
24+
}
25+
26+
emailProcessorFSM = (messageProcessorFSM) {
27+
states {
28+
["processState"] {
29+
entry {
30+
new csml.Invoke {
31+
type = ServiceTypes.stProcessEmail
32+
input {
33+
["msg"] = "$msg"
34+
}
35+
}
36+
}
37+
38+
always {
39+
new csml.Transition {
40+
to = "idleState"
41+
}
42+
}
43+
}
44+
}
45+
}
46+
47+
smsProcessorFSM = (messageProcessorFSM) {
48+
states {
49+
["processState"] {
50+
entry {
51+
new csml.Invoke {
52+
type = ServiceTypes.stProcessSms
53+
input {
54+
["msg"] = "$msg"
55+
}
56+
}
57+
}
58+
59+
always {
60+
new csml.Transition {
61+
to = "idleState"
62+
}
63+
}
64+
}
65+
}
66+
}
67+
68+
logProcessorFSM = (messageProcessorFSM) {
69+
states {
70+
["processState"] {
71+
entry {
72+
new csml.Eval {
73+
expression = "\(Vars.vLogs).add($msg)"
74+
}
75+
}
76+
77+
always {
78+
new csml.Transition {
79+
to = "idleState"
80+
}
81+
}
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)