From 4f74d9a56785fe754e9100b745109e1dca494e59 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 12 Feb 2019 00:30:33 +0100 Subject: more state --- cmd/dolmetschctld/statemachine.go | 17 ++++++++++++----- cmd/dolmetschctld/telnet.go | 5 ++++- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'cmd/dolmetschctld') 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 } -- cgit v1.2.3