From 67d5c0d719539357cdb9e3b890e41e53d387878d Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 11 Dec 2017 22:19:59 +0100 Subject: ... --- fsm.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'fsm.go') 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 } -- cgit v1.2.3