github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ardupilotmega/enum_gimbal_axis.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 GIMBAL_AXIS uint64 11 12 const ( 13 // Gimbal yaw axis. 14 GIMBAL_AXIS_YAW GIMBAL_AXIS = 0 15 // Gimbal pitch axis. 16 GIMBAL_AXIS_PITCH GIMBAL_AXIS = 1 17 // Gimbal roll axis. 18 GIMBAL_AXIS_ROLL GIMBAL_AXIS = 2 19 ) 20 21 var labels_GIMBAL_AXIS = map[GIMBAL_AXIS]string{ 22 GIMBAL_AXIS_YAW: "GIMBAL_AXIS_YAW", 23 GIMBAL_AXIS_PITCH: "GIMBAL_AXIS_PITCH", 24 GIMBAL_AXIS_ROLL: "GIMBAL_AXIS_ROLL", 25 } 26 27 var values_GIMBAL_AXIS = map[string]GIMBAL_AXIS{ 28 "GIMBAL_AXIS_YAW": GIMBAL_AXIS_YAW, 29 "GIMBAL_AXIS_PITCH": GIMBAL_AXIS_PITCH, 30 "GIMBAL_AXIS_ROLL": GIMBAL_AXIS_ROLL, 31 } 32 33 // MarshalText implements the encoding.TextMarshaler interface. 34 func (e GIMBAL_AXIS) MarshalText() ([]byte, error) { 35 if name, ok := labels_GIMBAL_AXIS[e]; ok { 36 return []byte(name), nil 37 } 38 return []byte(strconv.Itoa(int(e))), nil 39 } 40 41 // UnmarshalText implements the encoding.TextUnmarshaler interface. 42 func (e *GIMBAL_AXIS) UnmarshalText(text []byte) error { 43 if value, ok := values_GIMBAL_AXIS[string(text)]; ok { 44 *e = value 45 } else if value, err := strconv.Atoi(string(text)); err == nil { 46 *e = GIMBAL_AXIS(value) 47 } else { 48 return fmt.Errorf("invalid label '%s'", text) 49 } 50 return nil 51 } 52 53 // String implements the fmt.Stringer interface. 54 func (e GIMBAL_AXIS) String() string { 55 val, _ := e.MarshalText() 56 return string(val) 57 }