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

     1  //autogenerated:yes
     2  //nolint:revive,misspell,govet,lll,dupl,gocritic
     3  package ardupilotmega
     4  
     5  import (
     6  	"fmt"
     7  	"strconv"
     8  )
     9  
    10  type SCRIPTING_CMD uint64
    11  
    12  const (
    13  	// Start a REPL session.
    14  	SCRIPTING_CMD_REPL_START SCRIPTING_CMD = 0
    15  	// End a REPL session.
    16  	SCRIPTING_CMD_REPL_STOP SCRIPTING_CMD = 1
    17  	// Stop execution of scripts.
    18  	SCRIPTING_CMD_STOP SCRIPTING_CMD = 2
    19  	// Stop execution of scripts and restart.
    20  	SCRIPTING_CMD_STOP_AND_RESTART SCRIPTING_CMD = 3
    21  )
    22  
    23  var labels_SCRIPTING_CMD = map[SCRIPTING_CMD]string{
    24  	SCRIPTING_CMD_REPL_START:       "SCRIPTING_CMD_REPL_START",
    25  	SCRIPTING_CMD_REPL_STOP:        "SCRIPTING_CMD_REPL_STOP",
    26  	SCRIPTING_CMD_STOP:             "SCRIPTING_CMD_STOP",
    27  	SCRIPTING_CMD_STOP_AND_RESTART: "SCRIPTING_CMD_STOP_AND_RESTART",
    28  }
    29  
    30  var values_SCRIPTING_CMD = map[string]SCRIPTING_CMD{
    31  	"SCRIPTING_CMD_REPL_START":       SCRIPTING_CMD_REPL_START,
    32  	"SCRIPTING_CMD_REPL_STOP":        SCRIPTING_CMD_REPL_STOP,
    33  	"SCRIPTING_CMD_STOP":             SCRIPTING_CMD_STOP,
    34  	"SCRIPTING_CMD_STOP_AND_RESTART": SCRIPTING_CMD_STOP_AND_RESTART,
    35  }
    36  
    37  // MarshalText implements the encoding.TextMarshaler interface.
    38  func (e SCRIPTING_CMD) MarshalText() ([]byte, error) {
    39  	if name, ok := labels_SCRIPTING_CMD[e]; ok {
    40  		return []byte(name), nil
    41  	}
    42  	return []byte(strconv.Itoa(int(e))), nil
    43  }
    44  
    45  // UnmarshalText implements the encoding.TextUnmarshaler interface.
    46  func (e *SCRIPTING_CMD) UnmarshalText(text []byte) error {
    47  	if value, ok := values_SCRIPTING_CMD[string(text)]; ok {
    48  		*e = value
    49  	} else if value, err := strconv.Atoi(string(text)); err == nil {
    50  		*e = SCRIPTING_CMD(value)
    51  	} else {
    52  		return fmt.Errorf("invalid label '%s'", text)
    53  	}
    54  	return nil
    55  }
    56  
    57  // String implements the fmt.Stringer interface.
    58  func (e SCRIPTING_CMD) String() string {
    59  	val, _ := e.MarshalText()
    60  	return string(val)
    61  }