Delete statemachine example

pull/13668/head
Delyan Angelov 2022-03-09 09:18:20 +02:00 committed by GitHub
parent fb6ffb89f2
commit a88f01b2a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 33 deletions

View File

@ -1,33 +0,0 @@
import datatypes.fsm
struct MyReceiver {
mut:
data []string
}
fn main() {
mut receiver := &MyReceiver{}
mut s := fsm.new()
s.add_state('A', on_state_entry, on_state_run, on_state_exit)
s.add_state('B', on_state_entry, on_state_run, on_state_exit)
s.add_transition('A', 'B', condition_transition)
s.run(receiver)
s.run(receiver)
s.run(receiver)
}
fn on_state_entry(mut receiver MyReceiver, from string, to string) {
println('on_state_entry: ' + from + ' -> ' + to)
}
fn on_state_run(mut receiver MyReceiver, from string, to string) {
println('on_state_run: ' + from + ' -> ' + to)
}
fn on_state_exit(mut receiver MyReceiver, from string, to string) {
println('on_state_exit: ' + from + ' -> ' + to)
}
fn condition_transition(receiver &MyReceiver, from string, to string) bool {
return true
}