Skip to content

Commit 9ee45ea

Browse files
committed
feat: add belt state machine
1 parent 9b4ddf9 commit 9ee45ea

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

smartFactory/belt.pkl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
7+
beltFsm = new csml.StateMachine {
8+
states {
9+
["loadingState"] = new csml.Initial {
10+
on {
11+
[Events.eObjectValid] {
12+
to = "transportingState"
13+
}
14+
[Events.eJobDone] {
15+
to = "jobDoneState"
16+
}
17+
}
18+
}
19+
["transportingState"] {
20+
entry {
21+
new csml.Invoke {
22+
type = ServiceTypes.stMoveBelt
23+
}
24+
}
25+
26+
exit {
27+
new csml.Invoke {
28+
type = ServiceTypes.stStopBelt
29+
}
30+
}
31+
32+
on {
33+
[Events.eStartUnload] {
34+
to = "unloadingState"
35+
}
36+
[Events.eJobDone] {
37+
to = "jobDoneState"
38+
}
39+
}
40+
}
41+
42+
["jobDoneState"] = new csml.Terminal {}
43+
44+
["unloadingState"] {
45+
entry {
46+
new csml.Emit { event { topic = Events.eArmPickup }; target = "'arm'" }
47+
}
48+
49+
after {
50+
["armPickupTimeout"] {
51+
delay = "1000"
52+
triggers = new csml.Emit { event { topic = Events.eArmPickup }; target = "'arm'" }
53+
}
54+
}
55+
56+
on {
57+
[Events.eJobDone] {
58+
to = "jobDoneState"
59+
}
60+
61+
[Events.ePickedUp] {
62+
to = "loadingState"
63+
}
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)