Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Nov 9, 2023
1 parent 34a8c65 commit 0689422
Show file tree
Hide file tree
Showing 180 changed files with 358 additions and 724 deletions.
8 changes: 0 additions & 8 deletions pkg/conversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func (e {{ .Enum.Name }}) MarshalText() ([]byte, error) {
{{- end }}
}
// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *{{ .Enum.Name }}) UnmarshalText(text []byte) error {
{{- if .Enum.Bitmask }}
Expand Down Expand Up @@ -165,15 +164,8 @@ func (e *{{ .Enum.Name }}) UnmarshalText(text []byte) error {
// String implements the fmt.Stringer interface.
func (e {{ .Enum.Name }}) String() string {
{{- if .Enum.Bitmask }}
val, _ := e.MarshalText()
return string(val)
{{- else }}
if name, ok := labels_{{ .Enum.Name }}[e]; ok {
return name
}
return strconv.Itoa(int(e))
{{- end }}
}
{{- end }}
`))
Expand Down
6 changes: 2 additions & 4 deletions pkg/dialects/all/enum_mav_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,6 @@ func (e *MAV_CMD) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e MAV_CMD) String() string {
if name, ok := labels_MAV_CMD[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_accelcal_vehicle_pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func (e *ACCELCAL_VEHICLE_POS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e ACCELCAL_VEHICLE_POS) String() string {
if name, ok := labels_ACCELCAL_VEHICLE_POS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_camera_feedback_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func (e *CAMERA_FEEDBACK_FLAGS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e CAMERA_FEEDBACK_FLAGS) String() string {
if name, ok := labels_CAMERA_FEEDBACK_FLAGS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_camera_status_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func (e *CAMERA_STATUS_TYPES) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e CAMERA_STATUS_TYPES) String() string {
if name, ok := labels_CAMERA_STATUS_TYPES[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_copter_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ func (e *COPTER_MODE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e COPTER_MODE) String() string {
if name, ok := labels_COPTER_MODE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_deepstall_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ func (e *DEEPSTALL_STAGE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e DEEPSTALL_STAGE) String() string {
if name, ok := labels_DEEPSTALL_STAGE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_device_op_bustype.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func (e *DEVICE_OP_BUSTYPE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e DEVICE_OP_BUSTYPE) String() string {
if name, ok := labels_DEVICE_OP_BUSTYPE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gimbal_axis.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *GIMBAL_AXIS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GIMBAL_AXIS) String() string {
if name, ok := labels_GIMBAL_AXIS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *GIMBAL_AXIS_CALIBRATION_REQUIRED) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GIMBAL_AXIS_CALIBRATION_REQUIRED) String() string {
if name, ok := labels_GIMBAL_AXIS_CALIBRATION_REQUIRED[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *GIMBAL_AXIS_CALIBRATION_STATUS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GIMBAL_AXIS_CALIBRATION_STATUS) String() string {
if name, ok := labels_GIMBAL_AXIS_CALIBRATION_STATUS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_burst_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ func (e *GOPRO_BURST_RATE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_BURST_RATE) String() string {
if name, ok := labels_GOPRO_BURST_RATE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_capture_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ func (e *GOPRO_CAPTURE_MODE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_CAPTURE_MODE) String() string {
if name, ok := labels_GOPRO_CAPTURE_MODE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_charging.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ func (e *GOPRO_CHARGING) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_CHARGING) String() string {
if name, ok := labels_GOPRO_CHARGING[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ func (e *GOPRO_COMMAND) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_COMMAND) String() string {
if name, ok := labels_GOPRO_COMMAND[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_field_of_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *GOPRO_FIELD_OF_VIEW) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_FIELD_OF_VIEW) String() string {
if name, ok := labels_GOPRO_FIELD_OF_VIEW[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_frame_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ func (e *GOPRO_FRAME_RATE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_FRAME_RATE) String() string {
if name, ok := labels_GOPRO_FRAME_RATE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_heartbeat_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func (e *GOPRO_HEARTBEAT_STATUS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_HEARTBEAT_STATUS) String() string {
if name, ok := labels_GOPRO_HEARTBEAT_STATUS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func (e *GOPRO_MODEL) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_MODEL) String() string {
if name, ok := labels_GOPRO_MODEL[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_photo_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func (e *GOPRO_PHOTO_RESOLUTION) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_PHOTO_RESOLUTION) String() string {
if name, ok := labels_GOPRO_PHOTO_RESOLUTION[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_protune_colour.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ func (e *GOPRO_PROTUNE_COLOUR) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_PROTUNE_COLOUR) String() string {
if name, ok := labels_GOPRO_PROTUNE_COLOUR[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_protune_exposure.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ func (e *GOPRO_PROTUNE_EXPOSURE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_PROTUNE_EXPOSURE) String() string {
if name, ok := labels_GOPRO_PROTUNE_EXPOSURE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_protune_gain.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func (e *GOPRO_PROTUNE_GAIN) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_PROTUNE_GAIN) String() string {
if name, ok := labels_GOPRO_PROTUNE_GAIN[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_protune_sharpness.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *GOPRO_PROTUNE_SHARPNESS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_PROTUNE_SHARPNESS) String() string {
if name, ok := labels_GOPRO_PROTUNE_SHARPNESS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func (e *GOPRO_PROTUNE_WHITE_BALANCE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_PROTUNE_WHITE_BALANCE) String() string {
if name, ok := labels_GOPRO_PROTUNE_WHITE_BALANCE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_request_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ func (e *GOPRO_REQUEST_STATUS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_REQUEST_STATUS) String() string {
if name, ok := labels_GOPRO_REQUEST_STATUS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_gopro_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ func (e *GOPRO_RESOLUTION) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e GOPRO_RESOLUTION) String() string {
if name, ok := labels_GOPRO_RESOLUTION[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_heading_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func (e *HEADING_TYPE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e HEADING_TYPE) String() string {
if name, ok := labels_HEADING_TYPE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_led_control_pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *LED_CONTROL_PATTERN) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e LED_CONTROL_PATTERN) String() string {
if name, ok := labels_LED_CONTROL_PATTERN[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_limits_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func (e *LIMITS_STATE) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e LIMITS_STATE) String() string {
if name, ok := labels_LIMITS_STATE[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_mav_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,6 @@ func (e *MAV_CMD) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e MAV_CMD) String() string {
if name, ok := labels_MAV_CMD[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (e *MAV_CMD_DO_AUX_FUNCTION_SWITCH_LEVEL) UnmarshalText(text []byte) error

// String implements the fmt.Stringer interface.
func (e MAV_CMD_DO_AUX_FUNCTION_SWITCH_LEVEL) String() string {
if name, ok := labels_MAV_CMD_DO_AUX_FUNCTION_SWITCH_LEVEL[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
6 changes: 2 additions & 4 deletions pkg/dialects/ardupilotmega/enum_mav_mode_gimbal.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func (e *MAV_MODE_GIMBAL) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e MAV_MODE_GIMBAL) String() string {
if name, ok := labels_MAV_MODE_GIMBAL[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func (e *MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS) String() string {
if name, ok := labels_MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func (e *MAV_REMOTE_LOG_DATA_BLOCK_STATUSES) UnmarshalText(text []byte) error {

// String implements the fmt.Stringer interface.
func (e MAV_REMOTE_LOG_DATA_BLOCK_STATUSES) String() string {
if name, ok := labels_MAV_REMOTE_LOG_DATA_BLOCK_STATUSES[e]; ok {
return name
}
return strconv.Itoa(int(e))
val, _ := e.MarshalText()
return string(val)
}
Loading

0 comments on commit 0689422

Please sign in to comment.