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

     1  //autogenerated:yes
     2  //nolint:revive,misspell,govet,lll,dupl,gocritic
     3  package common
     4  
     5  import (
     6  	"fmt"
     7  	"strconv"
     8  )
     9  
    10  // Indicates the severity level, generally used for status messages to indicate their relative urgency. Based on RFC-5424 using expanded definitions at: http://www.kiwisyslog.com/kb/info:-syslog-message-levels/.
    11  type MAV_SEVERITY uint64
    12  
    13  const (
    14  	// System is unusable. This is a "panic" condition.
    15  	MAV_SEVERITY_EMERGENCY MAV_SEVERITY = 0
    16  	// Action should be taken immediately. Indicates error in non-critical systems.
    17  	MAV_SEVERITY_ALERT MAV_SEVERITY = 1
    18  	// Action must be taken immediately. Indicates failure in a primary system.
    19  	MAV_SEVERITY_CRITICAL MAV_SEVERITY = 2
    20  	// Indicates an error in secondary/redundant systems.
    21  	MAV_SEVERITY_ERROR MAV_SEVERITY = 3
    22  	// Indicates about a possible future error if this is not resolved within a given timeframe. Example would be a low battery warning.
    23  	MAV_SEVERITY_WARNING MAV_SEVERITY = 4
    24  	// An unusual event has occurred, though not an error condition. This should be investigated for the root cause.
    25  	MAV_SEVERITY_NOTICE MAV_SEVERITY = 5
    26  	// Normal operational messages. Useful for logging. No action is required for these messages.
    27  	MAV_SEVERITY_INFO MAV_SEVERITY = 6
    28  	// Useful non-operational messages that can assist in debugging. These should not occur during normal operation.
    29  	MAV_SEVERITY_DEBUG MAV_SEVERITY = 7
    30  )
    31  
    32  var labels_MAV_SEVERITY = map[MAV_SEVERITY]string{
    33  	MAV_SEVERITY_EMERGENCY: "MAV_SEVERITY_EMERGENCY",
    34  	MAV_SEVERITY_ALERT:     "MAV_SEVERITY_ALERT",
    35  	MAV_SEVERITY_CRITICAL:  "MAV_SEVERITY_CRITICAL",
    36  	MAV_SEVERITY_ERROR:     "MAV_SEVERITY_ERROR",
    37  	MAV_SEVERITY_WARNING:   "MAV_SEVERITY_WARNING",
    38  	MAV_SEVERITY_NOTICE:    "MAV_SEVERITY_NOTICE",
    39  	MAV_SEVERITY_INFO:      "MAV_SEVERITY_INFO",
    40  	MAV_SEVERITY_DEBUG:     "MAV_SEVERITY_DEBUG",
    41  }
    42  
    43  var values_MAV_SEVERITY = map[string]MAV_SEVERITY{
    44  	"MAV_SEVERITY_EMERGENCY": MAV_SEVERITY_EMERGENCY,
    45  	"MAV_SEVERITY_ALERT":     MAV_SEVERITY_ALERT,
    46  	"MAV_SEVERITY_CRITICAL":  MAV_SEVERITY_CRITICAL,
    47  	"MAV_SEVERITY_ERROR":     MAV_SEVERITY_ERROR,
    48  	"MAV_SEVERITY_WARNING":   MAV_SEVERITY_WARNING,
    49  	"MAV_SEVERITY_NOTICE":    MAV_SEVERITY_NOTICE,
    50  	"MAV_SEVERITY_INFO":      MAV_SEVERITY_INFO,
    51  	"MAV_SEVERITY_DEBUG":     MAV_SEVERITY_DEBUG,
    52  }
    53  
    54  // MarshalText implements the encoding.TextMarshaler interface.
    55  func (e MAV_SEVERITY) MarshalText() ([]byte, error) {
    56  	if name, ok := labels_MAV_SEVERITY[e]; ok {
    57  		return []byte(name), nil
    58  	}
    59  	return []byte(strconv.Itoa(int(e))), nil
    60  }
    61  
    62  // UnmarshalText implements the encoding.TextUnmarshaler interface.
    63  func (e *MAV_SEVERITY) UnmarshalText(text []byte) error {
    64  	if value, ok := values_MAV_SEVERITY[string(text)]; ok {
    65  		*e = value
    66  	} else if value, err := strconv.Atoi(string(text)); err == nil {
    67  		*e = MAV_SEVERITY(value)
    68  	} else {
    69  		return fmt.Errorf("invalid label '%s'", text)
    70  	}
    71  	return nil
    72  }
    73  
    74  // String implements the fmt.Stringer interface.
    75  func (e MAV_SEVERITY) String() string {
    76  	val, _ := e.MarshalText()
    77  	return string(val)
    78  }