aboutsummaryrefslogtreecommitdiff
path: root/fsm.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-12-11 22:19:59 +0100
committerDimitri Sokolyuk <demon@dim13.org>2017-12-11 22:19:59 +0100
commit67d5c0d719539357cdb9e3b890e41e53d387878d (patch)
tree76caf99e5862328907193fd2df433dbb26e0823e /fsm.go
parent4ae462c9e0469dc4572a54e8271ae24404a69db7 (diff)
...
Diffstat (limited to 'fsm.go')
-rw-r--r--fsm.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/fsm.go b/fsm.go
index 929fe2c..d9433f1 100644
--- a/fsm.go
+++ b/fsm.go
@@ -9,16 +9,16 @@ import (
type stateFn func() stateFn
type FSM struct {
- events chan *Event
- command chan *Command
+ events chan *Event
+ commands chan *Command
}
func NewFSM(rw io.ReadWriter) *FSM {
events := make(chan *Event)
- command := make(chan *Command)
+ commands := make(chan *Command)
go readEvents(rw, events)
- go writeCommands(rw, command)
- return &FSM{events: events, command: command}
+ go writeCommands(rw, commands)
+ return &FSM{events: events, commands: commands}
}
func readEvents(r io.Reader, ch chan<- *Event) {
@@ -53,7 +53,7 @@ func (f *FSM) Start() {
}
func (f *FSM) initalState() stateFn {
- f.command <- &Command{Direction: 90}
+ f.commands <- &Command{Direction: 90}
return f.readDistance
}
@@ -67,11 +67,11 @@ func (f *FSM) readDistance() stateFn {
}
func (f *FSM) moveAhead() stateFn {
- f.command <- &Command{Speed: &Speed{L: 200, R: 200}}
+ f.commands <- &Command{Speed: &Speed{L: 200, R: 200}}
return f.readDistance
}
func (f *FSM) stop() stateFn {
- f.command <- &Command{Stop: true}
+ f.commands <- &Command{Stop: true}
return f.readDistance
}