github.com/bluenviron/gomavlib/v2@v2.2.1-0.20240308101627-2c07e3da629c/pkg/dialects/common/enum_mav_do_reposition_flags.go (about) 1 //autogenerated:yes 2 //nolint:revive,misspell,govet,lll,dupl,gocritic 3 package common 4 5 import ( 6 "fmt" 7 "strconv" 8 "strings" 9 ) 10 11 // Bitmap of options for the MAV_CMD_DO_REPOSITION 12 type MAV_DO_REPOSITION_FLAGS uint64 13 14 const ( 15 // The aircraft should immediately transition into guided. This should not be set for follow me applications 16 MAV_DO_REPOSITION_FLAGS_CHANGE_MODE MAV_DO_REPOSITION_FLAGS = 1 17 ) 18 19 var labels_MAV_DO_REPOSITION_FLAGS = map[MAV_DO_REPOSITION_FLAGS]string{ 20 MAV_DO_REPOSITION_FLAGS_CHANGE_MODE: "MAV_DO_REPOSITION_FLAGS_CHANGE_MODE", 21 } 22 23 var values_MAV_DO_REPOSITION_FLAGS = map[string]MAV_DO_REPOSITION_FLAGS{ 24 "MAV_DO_REPOSITION_FLAGS_CHANGE_MODE": MAV_DO_REPOSITION_FLAGS_CHANGE_MODE, 25 } 26 27 // MarshalText implements the encoding.TextMarshaler interface. 28 func (e MAV_DO_REPOSITION_FLAGS) MarshalText() ([]byte, error) { 29 if e == 0 { 30 return []byte("0"), nil 31 } 32 var names []string 33 for i := 0; i < 1; i++ { 34 mask := MAV_DO_REPOSITION_FLAGS(1 << i) 35 if e&mask == mask { 36 names = append(names, labels_MAV_DO_REPOSITION_FLAGS[mask]) 37 } 38 } 39 return []byte(strings.Join(names, " | ")), nil 40 } 41 42 // UnmarshalText implements the encoding.TextUnmarshaler interface. 43 func (e *MAV_DO_REPOSITION_FLAGS) UnmarshalText(text []byte) error { 44 labels := strings.Split(string(text), " | ") 45 var mask MAV_DO_REPOSITION_FLAGS 46 for _, label := range labels { 47 if value, ok := values_MAV_DO_REPOSITION_FLAGS[label]; ok { 48 mask |= value 49 } else if value, err := strconv.Atoi(label); err == nil { 50 mask |= MAV_DO_REPOSITION_FLAGS(value) 51 } else { 52 return fmt.Errorf("invalid label '%s'", label) 53 } 54 } 55 *e = mask 56 return nil 57 } 58 59 // String implements the fmt.Stringer interface. 60 func (e MAV_DO_REPOSITION_FLAGS) String() string { 61 val, _ := e.MarshalText() 62 return string(val) 63 }