//autogenerated:yes
//nolint:revive,misspell,govet,lll,dupl,gocritic
package uavionix

import (
	"fmt"
	"strconv"
	"strings"
)

// State flags for ADS-B transponder status report
type UAVIONIX_ADSB_OUT_STATUS_STATE uint64

const (
	UAVIONIX_ADSB_OUT_STATUS_STATE_ON_GROUND               UAVIONIX_ADSB_OUT_STATUS_STATE = 1
	UAVIONIX_ADSB_OUT_STATUS_STATE_INTERROGATED_SINCE_LAST UAVIONIX_ADSB_OUT_STATUS_STATE = 2
	UAVIONIX_ADSB_OUT_STATUS_STATE_XBIT_ENABLED            UAVIONIX_ADSB_OUT_STATUS_STATE = 4
	UAVIONIX_ADSB_OUT_STATUS_STATE_IDENT_ACTIVE            UAVIONIX_ADSB_OUT_STATUS_STATE = 8
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_A_ENABLED          UAVIONIX_ADSB_OUT_STATUS_STATE = 16
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_C_ENABLED          UAVIONIX_ADSB_OUT_STATUS_STATE = 32
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_S_ENABLED          UAVIONIX_ADSB_OUT_STATUS_STATE = 64
	UAVIONIX_ADSB_OUT_STATUS_STATE_1090ES_TX_ENABLED       UAVIONIX_ADSB_OUT_STATUS_STATE = 128
)

var values_UAVIONIX_ADSB_OUT_STATUS_STATE = []UAVIONIX_ADSB_OUT_STATUS_STATE{
	UAVIONIX_ADSB_OUT_STATUS_STATE_ON_GROUND,
	UAVIONIX_ADSB_OUT_STATUS_STATE_INTERROGATED_SINCE_LAST,
	UAVIONIX_ADSB_OUT_STATUS_STATE_XBIT_ENABLED,
	UAVIONIX_ADSB_OUT_STATUS_STATE_IDENT_ACTIVE,
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_A_ENABLED,
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_C_ENABLED,
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_S_ENABLED,
	UAVIONIX_ADSB_OUT_STATUS_STATE_1090ES_TX_ENABLED,
}

var value_to_label_UAVIONIX_ADSB_OUT_STATUS_STATE = map[UAVIONIX_ADSB_OUT_STATUS_STATE]string{
	UAVIONIX_ADSB_OUT_STATUS_STATE_ON_GROUND:               "UAVIONIX_ADSB_OUT_STATUS_STATE_ON_GROUND",
	UAVIONIX_ADSB_OUT_STATUS_STATE_INTERROGATED_SINCE_LAST: "UAVIONIX_ADSB_OUT_STATUS_STATE_INTERROGATED_SINCE_LAST",
	UAVIONIX_ADSB_OUT_STATUS_STATE_XBIT_ENABLED:            "UAVIONIX_ADSB_OUT_STATUS_STATE_XBIT_ENABLED",
	UAVIONIX_ADSB_OUT_STATUS_STATE_IDENT_ACTIVE:            "UAVIONIX_ADSB_OUT_STATUS_STATE_IDENT_ACTIVE",
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_A_ENABLED:          "UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_A_ENABLED",
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_C_ENABLED:          "UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_C_ENABLED",
	UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_S_ENABLED:          "UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_S_ENABLED",
	UAVIONIX_ADSB_OUT_STATUS_STATE_1090ES_TX_ENABLED:       "UAVIONIX_ADSB_OUT_STATUS_STATE_1090ES_TX_ENABLED",
}

var label_to_value_UAVIONIX_ADSB_OUT_STATUS_STATE = map[string]UAVIONIX_ADSB_OUT_STATUS_STATE{
	"UAVIONIX_ADSB_OUT_STATUS_STATE_ON_GROUND":               UAVIONIX_ADSB_OUT_STATUS_STATE_ON_GROUND,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_INTERROGATED_SINCE_LAST": UAVIONIX_ADSB_OUT_STATUS_STATE_INTERROGATED_SINCE_LAST,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_XBIT_ENABLED":            UAVIONIX_ADSB_OUT_STATUS_STATE_XBIT_ENABLED,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_IDENT_ACTIVE":            UAVIONIX_ADSB_OUT_STATUS_STATE_IDENT_ACTIVE,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_A_ENABLED":          UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_A_ENABLED,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_C_ENABLED":          UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_C_ENABLED,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_S_ENABLED":          UAVIONIX_ADSB_OUT_STATUS_STATE_MODE_S_ENABLED,
	"UAVIONIX_ADSB_OUT_STATUS_STATE_1090ES_TX_ENABLED":       UAVIONIX_ADSB_OUT_STATUS_STATE_1090ES_TX_ENABLED,
}

// MarshalText implements the encoding.TextMarshaler interface.
func (e UAVIONIX_ADSB_OUT_STATUS_STATE) MarshalText() ([]byte, error) {
	if e == 0 {
		return []byte("0"), nil
	}
	var names []string
	for _, val := range values_UAVIONIX_ADSB_OUT_STATUS_STATE {
		if e&val == val {
			names = append(names, value_to_label_UAVIONIX_ADSB_OUT_STATUS_STATE[val])
		}
	}
	return []byte(strings.Join(names, " | ")), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *UAVIONIX_ADSB_OUT_STATUS_STATE) UnmarshalText(text []byte) error {
	labels := strings.Split(string(text), " | ")
	var mask UAVIONIX_ADSB_OUT_STATUS_STATE
	for _, label := range labels {
		if value, ok := label_to_value_UAVIONIX_ADSB_OUT_STATUS_STATE[label]; ok {
			mask |= value
		} else if value, err := strconv.Atoi(label); err == nil {
			mask |= UAVIONIX_ADSB_OUT_STATUS_STATE(value)
		} else {
			return fmt.Errorf("invalid label '%s'", label)
		}
	}
	*e = mask
	return nil
}

// String implements the fmt.Stringer interface.
func (e UAVIONIX_ADSB_OUT_STATUS_STATE) String() string {
	val, _ := e.MarshalText()
	return string(val)
}
