Skip to content

Commit

Permalink
update dialects with new template
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Nov 7, 2023
1 parent 93ec9c1 commit d98a860
Show file tree
Hide file tree
Showing 228 changed files with 2,263 additions and 1,969 deletions.
22 changes: 11 additions & 11 deletions pkg/dialects/all/enum_mav_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,28 +934,28 @@ var values_MAV_CMD = map[string]MAV_CMD{

// MarshalText implements the encoding.TextMarshaler interface.
func (e MAV_CMD) MarshalText() ([]byte, error) {
name, ok := labels_MAV_CMD[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_MAV_CMD[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *MAV_CMD) UnmarshalText(text []byte) error {
value, ok := values_MAV_CMD[string(text)]
if !ok {
if value, ok := values_MAV_CMD[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = MAV_CMD(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e MAV_CMD) String() string {
name, ok := labels_MAV_CMD[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_MAV_CMD[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_accelcal_vehicle_pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ var values_ACCELCAL_VEHICLE_POS = map[string]ACCELCAL_VEHICLE_POS{

// MarshalText implements the encoding.TextMarshaler interface.
func (e ACCELCAL_VEHICLE_POS) MarshalText() ([]byte, error) {
name, ok := labels_ACCELCAL_VEHICLE_POS[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_ACCELCAL_VEHICLE_POS[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *ACCELCAL_VEHICLE_POS) UnmarshalText(text []byte) error {
value, ok := values_ACCELCAL_VEHICLE_POS[string(text)]
if !ok {
if value, ok := values_ACCELCAL_VEHICLE_POS[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = ACCELCAL_VEHICLE_POS(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e ACCELCAL_VEHICLE_POS) String() string {
name, ok := labels_ACCELCAL_VEHICLE_POS[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_ACCELCAL_VEHICLE_POS[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_camera_feedback_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ var values_CAMERA_FEEDBACK_FLAGS = map[string]CAMERA_FEEDBACK_FLAGS{

// MarshalText implements the encoding.TextMarshaler interface.
func (e CAMERA_FEEDBACK_FLAGS) MarshalText() ([]byte, error) {
name, ok := labels_CAMERA_FEEDBACK_FLAGS[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_CAMERA_FEEDBACK_FLAGS[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *CAMERA_FEEDBACK_FLAGS) UnmarshalText(text []byte) error {
value, ok := values_CAMERA_FEEDBACK_FLAGS[string(text)]
if !ok {
if value, ok := values_CAMERA_FEEDBACK_FLAGS[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = CAMERA_FEEDBACK_FLAGS(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e CAMERA_FEEDBACK_FLAGS) String() string {
name, ok := labels_CAMERA_FEEDBACK_FLAGS[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_CAMERA_FEEDBACK_FLAGS[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_camera_status_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@ var values_CAMERA_STATUS_TYPES = map[string]CAMERA_STATUS_TYPES{

// MarshalText implements the encoding.TextMarshaler interface.
func (e CAMERA_STATUS_TYPES) MarshalText() ([]byte, error) {
name, ok := labels_CAMERA_STATUS_TYPES[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_CAMERA_STATUS_TYPES[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *CAMERA_STATUS_TYPES) UnmarshalText(text []byte) error {
value, ok := values_CAMERA_STATUS_TYPES[string(text)]
if !ok {
if value, ok := values_CAMERA_STATUS_TYPES[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = CAMERA_STATUS_TYPES(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e CAMERA_STATUS_TYPES) String() string {
name, ok := labels_CAMERA_STATUS_TYPES[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_CAMERA_STATUS_TYPES[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_copter_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,28 @@ var values_COPTER_MODE = map[string]COPTER_MODE{

// MarshalText implements the encoding.TextMarshaler interface.
func (e COPTER_MODE) MarshalText() ([]byte, error) {
name, ok := labels_COPTER_MODE[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_COPTER_MODE[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *COPTER_MODE) UnmarshalText(text []byte) error {
value, ok := values_COPTER_MODE[string(text)]
if !ok {
if value, ok := values_COPTER_MODE[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = COPTER_MODE(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e COPTER_MODE) String() string {
name, ok := labels_COPTER_MODE[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_COPTER_MODE[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_deepstall_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ var values_DEEPSTALL_STAGE = map[string]DEEPSTALL_STAGE{

// MarshalText implements the encoding.TextMarshaler interface.
func (e DEEPSTALL_STAGE) MarshalText() ([]byte, error) {
name, ok := labels_DEEPSTALL_STAGE[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_DEEPSTALL_STAGE[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *DEEPSTALL_STAGE) UnmarshalText(text []byte) error {
value, ok := values_DEEPSTALL_STAGE[string(text)]
if !ok {
if value, ok := values_DEEPSTALL_STAGE[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = DEEPSTALL_STAGE(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e DEEPSTALL_STAGE) String() string {
name, ok := labels_DEEPSTALL_STAGE[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_DEEPSTALL_STAGE[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_device_op_bustype.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ var values_DEVICE_OP_BUSTYPE = map[string]DEVICE_OP_BUSTYPE{

// MarshalText implements the encoding.TextMarshaler interface.
func (e DEVICE_OP_BUSTYPE) MarshalText() ([]byte, error) {
name, ok := labels_DEVICE_OP_BUSTYPE[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_DEVICE_OP_BUSTYPE[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *DEVICE_OP_BUSTYPE) UnmarshalText(text []byte) error {
value, ok := values_DEVICE_OP_BUSTYPE[string(text)]
if !ok {
if value, ok := values_DEVICE_OP_BUSTYPE[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = DEVICE_OP_BUSTYPE(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e DEVICE_OP_BUSTYPE) String() string {
name, ok := labels_DEVICE_OP_BUSTYPE[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_DEVICE_OP_BUSTYPE[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
6 changes: 6 additions & 0 deletions pkg/dialects/ardupilotmega/enum_ekf_status_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package ardupilotmega

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

Expand Down Expand Up @@ -65,6 +66,9 @@ var values_EKF_STATUS_FLAGS = map[string]EKF_STATUS_FLAGS{

// MarshalText implements the encoding.TextMarshaler interface.
func (e EKF_STATUS_FLAGS) MarshalText() ([]byte, error) {
if e == 0 {
return []byte("0"), nil
}
var names []string
for i := 0; i < 11; i++ {
mask := EKF_STATUS_FLAGS(1 << i)
Expand All @@ -82,6 +86,8 @@ func (e *EKF_STATUS_FLAGS) UnmarshalText(text []byte) error {
for _, label := range labels {
if value, ok := values_EKF_STATUS_FLAGS[label]; ok {
mask |= value
} else if value, err := strconv.Atoi(label); err == nil {
mask |= EKF_STATUS_FLAGS(value)
} else {
return fmt.Errorf("invalid label '%s'", label)
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_gimbal_axis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ var values_GIMBAL_AXIS = map[string]GIMBAL_AXIS{

// MarshalText implements the encoding.TextMarshaler interface.
func (e GIMBAL_AXIS) MarshalText() ([]byte, error) {
name, ok := labels_GIMBAL_AXIS[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_GIMBAL_AXIS[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *GIMBAL_AXIS) UnmarshalText(text []byte) error {
value, ok := values_GIMBAL_AXIS[string(text)]
if !ok {
if value, ok := values_GIMBAL_AXIS[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = GIMBAL_AXIS(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e GIMBAL_AXIS) String() string {
name, ok := labels_GIMBAL_AXIS[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_GIMBAL_AXIS[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
22 changes: 11 additions & 11 deletions pkg/dialects/ardupilotmega/enum_gimbal_axis_calibration_required.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ var values_GIMBAL_AXIS_CALIBRATION_REQUIRED = map[string]GIMBAL_AXIS_CALIBRATION

// MarshalText implements the encoding.TextMarshaler interface.
func (e GIMBAL_AXIS_CALIBRATION_REQUIRED) MarshalText() ([]byte, error) {
name, ok := labels_GIMBAL_AXIS_CALIBRATION_REQUIRED[e]
if !ok {
return nil, fmt.Errorf("invalid value %d", e)
if name, ok := labels_GIMBAL_AXIS_CALIBRATION_REQUIRED[e]; ok {
return []byte(name), nil
}
return []byte(name), nil
return []byte(strconv.Itoa(int(e))), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *GIMBAL_AXIS_CALIBRATION_REQUIRED) UnmarshalText(text []byte) error {
value, ok := values_GIMBAL_AXIS_CALIBRATION_REQUIRED[string(text)]
if !ok {
if value, ok := values_GIMBAL_AXIS_CALIBRATION_REQUIRED[string(text)]; ok {
*e = value
} else if value, err := strconv.Atoi(string(text)); err == nil {
*e = GIMBAL_AXIS_CALIBRATION_REQUIRED(value)
} else {
return fmt.Errorf("invalid label '%s'", text)
}
*e = value
return nil
}

// String implements the fmt.Stringer interface.
func (e GIMBAL_AXIS_CALIBRATION_REQUIRED) String() string {
name, ok := labels_GIMBAL_AXIS_CALIBRATION_REQUIRED[e]
if !ok {
return strconv.Itoa(int(e))
if name, ok := labels_GIMBAL_AXIS_CALIBRATION_REQUIRED[e]; ok {
return name
}
return name
return strconv.Itoa(int(e))
}
Loading

0 comments on commit d98a860

Please sign in to comment.