github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/ualberta/enum_ualberta_pilot_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  // Mode currently commanded by pilot
    11  type UALBERTA_PILOT_MODE uint64
    12  
    13  const (
    14  	PILOT_MANUAL UALBERTA_PILOT_MODE = 1
    15  	PILOT_AUTO   UALBERTA_PILOT_MODE = 2
    16  	// Rotomotion mode
    17  	PILOT_ROTO UALBERTA_PILOT_MODE = 3
    18  )
    19  
    20  var labels_UALBERTA_PILOT_MODE = map[UALBERTA_PILOT_MODE]string{
    21  	PILOT_MANUAL: "PILOT_MANUAL",
    22  	PILOT_AUTO:   "PILOT_AUTO",
    23  	PILOT_ROTO:   "PILOT_ROTO",
    24  }
    25  
    26  var values_UALBERTA_PILOT_MODE = map[string]UALBERTA_PILOT_MODE{
    27  	"PILOT_MANUAL": PILOT_MANUAL,
    28  	"PILOT_AUTO":   PILOT_AUTO,
    29  	"PILOT_ROTO":   PILOT_ROTO,
    30  }
    31  
    32  // MarshalText implements the encoding.TextMarshaler interface.
    33  func (e UALBERTA_PILOT_MODE) MarshalText() ([]byte, error) {
    34  	if name, ok := labels_UALBERTA_PILOT_MODE[e]; ok {
    35  		return []byte(name), nil
    36  	}
    37  	return []byte(strconv.Itoa(int(e))), nil
    38  }
    39  
    40  // UnmarshalText implements the encoding.TextUnmarshaler interface.
    41  func (e *UALBERTA_PILOT_MODE) UnmarshalText(text []byte) error {
    42  	if value, ok := values_UALBERTA_PILOT_MODE[string(text)]; ok {
    43  		*e = value
    44  	} else if value, err := strconv.Atoi(string(text)); err == nil {
    45  		*e = UALBERTA_PILOT_MODE(value)
    46  	} else {
    47  		return fmt.Errorf("invalid label '%s'", text)
    48  	}
    49  	return nil
    50  }
    51  
    52  // String implements the fmt.Stringer interface.
    53  func (e UALBERTA_PILOT_MODE) String() string {
    54  	val, _ := e.MarshalText()
    55  	return string(val)
    56  }