github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_limits_state.go (about) 1 //autogenerated:yes 2 //nolint:revive,misspell,govet,lll,dupl,gocritic 3 package ardupilotmega 4 5 import ( 6 "fmt" 7 "strconv" 8 ) 9 10 type LIMITS_STATE uint64 11 12 const ( 13 // Pre-initialization. 14 LIMITS_INIT LIMITS_STATE = 0 15 // Disabled. 16 LIMITS_DISABLED LIMITS_STATE = 1 17 // Checking limits. 18 LIMITS_ENABLED LIMITS_STATE = 2 19 // A limit has been breached. 20 LIMITS_TRIGGERED LIMITS_STATE = 3 21 // Taking action e.g. Return/RTL. 22 LIMITS_RECOVERING LIMITS_STATE = 4 23 // We're no longer in breach of a limit. 24 LIMITS_RECOVERED LIMITS_STATE = 5 25 ) 26 27 var labels_LIMITS_STATE = map[LIMITS_STATE]string{ 28 LIMITS_INIT: "LIMITS_INIT", 29 LIMITS_DISABLED: "LIMITS_DISABLED", 30 LIMITS_ENABLED: "LIMITS_ENABLED", 31 LIMITS_TRIGGERED: "LIMITS_TRIGGERED", 32 LIMITS_RECOVERING: "LIMITS_RECOVERING", 33 LIMITS_RECOVERED: "LIMITS_RECOVERED", 34 } 35 36 var values_LIMITS_STATE = map[string]LIMITS_STATE{ 37 "LIMITS_INIT": LIMITS_INIT, 38 "LIMITS_DISABLED": LIMITS_DISABLED, 39 "LIMITS_ENABLED": LIMITS_ENABLED, 40 "LIMITS_TRIGGERED": LIMITS_TRIGGERED, 41 "LIMITS_RECOVERING": LIMITS_RECOVERING, 42 "LIMITS_RECOVERED": LIMITS_RECOVERED, 43 } 44 45 // MarshalText implements the encoding.TextMarshaler interface. 46 func (e LIMITS_STATE) MarshalText() ([]byte, error) { 47 if name, ok := labels_LIMITS_STATE[e]; ok { 48 return []byte(name), nil 49 } 50 return []byte(strconv.Itoa(int(e))), nil 51 } 52 53 // UnmarshalText implements the encoding.TextUnmarshaler interface. 54 func (e *LIMITS_STATE) UnmarshalText(text []byte) error { 55 if value, ok := values_LIMITS_STATE[string(text)]; ok { 56 *e = value 57 } else if value, err := strconv.Atoi(string(text)); err == nil { 58 *e = LIMITS_STATE(value) 59 } else { 60 return fmt.Errorf("invalid label '%s'", text) 61 } 62 return nil 63 } 64 65 // String implements the fmt.Stringer interface. 66 func (e LIMITS_STATE) String() string { 67 val, _ := e.MarshalText() 68 return string(val) 69 }