github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ualberta/enum_ualberta_autopilot_mode.go (about)

     1  //autogenerated:yes
     2  //nolint:revive,misspell,govet,lll,dupl,gocritic
     3  package ualberta
     4  
     5  import (
     6  	"fmt"
     7  	"strconv"
     8  )
     9  
    10  // Available autopilot modes for ualberta uav
    11  type UALBERTA_AUTOPILOT_MODE uint64
    12  
    13  const (
    14  	// Raw input pulse widts sent to output
    15  	MODE_MANUAL_DIRECT UALBERTA_AUTOPILOT_MODE = 1
    16  	// Inputs are normalized using calibration, the converted back to raw pulse widths for output
    17  	MODE_MANUAL_SCALED UALBERTA_AUTOPILOT_MODE = 2
    18  	MODE_AUTO_PID_ATT  UALBERTA_AUTOPILOT_MODE = 3
    19  	MODE_AUTO_PID_VEL  UALBERTA_AUTOPILOT_MODE = 4
    20  	MODE_AUTO_PID_POS  UALBERTA_AUTOPILOT_MODE = 5
    21  )
    22  
    23  var labels_UALBERTA_AUTOPILOT_MODE = map[UALBERTA_AUTOPILOT_MODE]string{
    24  	MODE_MANUAL_DIRECT: "MODE_MANUAL_DIRECT",
    25  	MODE_MANUAL_SCALED: "MODE_MANUAL_SCALED",
    26  	MODE_AUTO_PID_ATT:  "MODE_AUTO_PID_ATT",
    27  	MODE_AUTO_PID_VEL:  "MODE_AUTO_PID_VEL",
    28  	MODE_AUTO_PID_POS:  "MODE_AUTO_PID_POS",
    29  }
    30  
    31  var values_UALBERTA_AUTOPILOT_MODE = map[string]UALBERTA_AUTOPILOT_MODE{
    32  	"MODE_MANUAL_DIRECT": MODE_MANUAL_DIRECT,
    33  	"MODE_MANUAL_SCALED": MODE_MANUAL_SCALED,
    34  	"MODE_AUTO_PID_ATT":  MODE_AUTO_PID_ATT,
    35  	"MODE_AUTO_PID_VEL":  MODE_AUTO_PID_VEL,
    36  	"MODE_AUTO_PID_POS":  MODE_AUTO_PID_POS,
    37  }
    38  
    39  // MarshalText implements the encoding.TextMarshaler interface.
    40  func (e UALBERTA_AUTOPILOT_MODE) MarshalText() ([]byte, error) {
    41  	if name, ok := labels_UALBERTA_AUTOPILOT_MODE[e]; ok {
    42  		return []byte(name), nil
    43  	}
    44  	return []byte(strconv.Itoa(int(e))), nil
    45  }
    46  
    47  // UnmarshalText implements the encoding.TextUnmarshaler interface.
    48  func (e *UALBERTA_AUTOPILOT_MODE) UnmarshalText(text []byte) error {
    49  	if value, ok := values_UALBERTA_AUTOPILOT_MODE[string(text)]; ok {
    50  		*e = value
    51  	} else if value, err := strconv.Atoi(string(text)); err == nil {
    52  		*e = UALBERTA_AUTOPILOT_MODE(value)
    53  	} else {
    54  		return fmt.Errorf("invalid label '%s'", text)
    55  	}
    56  	return nil
    57  }
    58  
    59  // String implements the fmt.Stringer interface.
    60  func (e UALBERTA_AUTOPILOT_MODE) String() string {
    61  	val, _ := e.MarshalText()
    62  	return string(val)
    63  }