go-hep.org/x/hep@v0.38.1/fwk/fsm/fsm.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package fsm // import "go-hep.org/x/hep/fwk/fsm" 6 7 import ( 8 "fmt" 9 ) 10 11 type State int 12 13 const ( 14 Undefined State = iota 15 Configuring 16 Configured 17 Starting 18 Started 19 Running 20 Stopping 21 Stopped 22 Offline 23 ) 24 25 func (state State) String() string { 26 switch state { 27 case Undefined: 28 return "UNDEFINED" 29 case Configuring: 30 return "CONFIGURING" 31 case Configured: 32 return "CONFIGURED" 33 case Starting: 34 return "STARTING" 35 case Started: 36 return "STARTED" 37 case Running: 38 return "RUNNING" 39 case Stopping: 40 return "STOPPING" 41 case Stopped: 42 return "STOPPED" 43 case Offline: 44 return "OFFLINE" 45 46 default: 47 panic(fmt.Errorf("invalid fsm.State value %d", int(state))) 48 } 49 }