diff options
author | Christian Pointner <equinox@spreadspace.org> | 2019-02-12 00:30:33 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2019-02-12 00:30:33 +0100 |
commit | 4f74d9a56785fe754e9100b745109e1dca494e59 (patch) | |
tree | ae52d4dfa1daae2542be6036cb46a466ca37eb31 /cmd | |
parent | subscribing to controller events works now (diff) |
more state
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dolmetschctld/statemachine.go | 17 | ||||
-rw-r--r-- | cmd/dolmetschctld/telnet.go | 5 |
2 files changed, 16 insertions, 6 deletions
diff --git a/cmd/dolmetschctld/statemachine.go b/cmd/dolmetschctld/statemachine.go index b8946d6..b1e74c7 100644 --- a/cmd/dolmetschctld/statemachine.go +++ b/cmd/dolmetschctld/statemachine.go @@ -94,8 +94,14 @@ type getOriginal2InterpreterRatioReq struct { resCh chan float32 } +type getStateRes struct { + state State + ratio float32 + language Language +} + type getStateReq struct { - resCh chan State + resCh chan getStateRes } type StateMachine struct { @@ -250,7 +256,7 @@ func (sm *StateMachine) run() { case req := <-sm.getOriginal2InterpreterRatioCh: req.resCh <- sm.original2InterpreterRatio case req := <-sm.getStateCh: - req.resCh <- sm.state + req.resCh <- getStateRes{sm.state, sm.original2InterpreterRatio, sm.language} case ev := <-sm.mixerEventCh: sm.handleMixerEvent(ev) sm.reconcile(false) @@ -339,10 +345,11 @@ func (sm *StateMachine) GetOriginal2InterpreterRatio() float32 { return <-resCh } -func (sm *StateMachine) GetState() State { - resCh := make(chan State) +func (sm *StateMachine) GetState() (State, float32, Language) { + resCh := make(chan getStateRes) sm.getStateCh <- getStateReq{resCh} - return <-resCh + res := <-resCh + return res.state, res.ratio, res.language } func (sm *StateMachine) Shutdown() { diff --git a/cmd/dolmetschctld/telnet.go b/cmd/dolmetschctld/telnet.go index a7ede85..8ea6a61 100644 --- a/cmd/dolmetschctld/telnet.go +++ b/cmd/dolmetschctld/telnet.go @@ -79,7 +79,10 @@ func telnetCmdState(c *telgo.Client, args []string, sm *StateMachine) bool { c.Sayln("usage: state") return false } - c.Sayln("current state: %s", sm.GetState()) + state, ratio, lang := sm.GetState() + c.Sayln("current state: %s", state) + c.Sayln("current ratio: %s", ratio) + c.Sayln("current language: %s", lang) return false } |