Skip to content

Commit

Permalink
Merge pull request #194 from mavlink/fix-enum-translation
Browse files Browse the repository at this point in the history
Fix translate_to_rpc for enums
  • Loading branch information
julianoes authored May 28, 2020
2 parents 7443a05 + c4d828a commit b8b9d17
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 59 deletions.
4 changes: 2 additions & 2 deletions mavsdk/generated/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Result(Enum):
NO_VTOL_TRANSITION_SUPPORT = 10
PARAMETER_ERROR = 11

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == ActionResult.Result.UNKNOWN:
return action_pb2.ActionResult.RESULT_UNKNOWN
if self == ActionResult.Result.SUCCESS:
Expand Down Expand Up @@ -182,7 +182,7 @@ def translate_to_rpc(self, rpcActionResult):



self.result.translate_to_rpc(rpcActionResult.result)
rpcActionResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Result(Enum):
CANCELLED = 9
FAILED_ARMED = 10

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == CalibrationResult.Result.UNKNOWN:
return calibration_pb2.CalibrationResult.RESULT_UNKNOWN
if self == CalibrationResult.Result.SUCCESS:
Expand Down Expand Up @@ -174,7 +174,7 @@ def translate_to_rpc(self, rpcCalibrationResult):



self.result.translate_to_rpc(rpcCalibrationResult.result)
rpcCalibrationResult.result = self.result.translate_to_rpc()



Expand Down
14 changes: 7 additions & 7 deletions mavsdk/generated/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Mode(Enum):
PHOTO = 1
VIDEO = 2

def translate_to_rpc(self, rpcMode):
def translate_to_rpc(self):
if self == Mode.UNKNOWN:
return camera_pb2.MODE_UNKNOWN
if self == Mode.PHOTO:
Expand Down Expand Up @@ -106,7 +106,7 @@ class Result(Enum):
TIMEOUT = 6
WRONG_ARGUMENT = 7

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == CameraResult.Result.UNKNOWN:
return camera_pb2.CameraResult.RESULT_UNKNOWN
if self == CameraResult.Result.SUCCESS:
Expand Down Expand Up @@ -194,7 +194,7 @@ def translate_to_rpc(self, rpcCameraResult):



self.result.translate_to_rpc(rpcCameraResult.result)
rpcCameraResult.result = self.result.translate_to_rpc()



Expand Down Expand Up @@ -846,7 +846,7 @@ class Status(Enum):
NOT_RUNNING = 0
IN_PROGRESS = 1

def translate_to_rpc(self, rpcStatus):
def translate_to_rpc(self):
if self == VideoStreamInfo.Status.NOT_RUNNING:
return camera_pb2.VideoStreamInfo.STATUS_NOT_RUNNING
if self == VideoStreamInfo.Status.IN_PROGRESS:
Expand Down Expand Up @@ -916,7 +916,7 @@ def translate_to_rpc(self, rpcVideoStreamInfo):



self.status.translate_to_rpc(rpcVideoStreamInfo.status)
rpcVideoStreamInfo.status = self.status.translate_to_rpc()



Expand Down Expand Up @@ -978,7 +978,7 @@ class StorageStatus(Enum):
UNFORMATTED = 1
FORMATTED = 2

def translate_to_rpc(self, rpcStorageStatus):
def translate_to_rpc(self):
if self == Status.StorageStatus.NOT_AVAILABLE:
return camera_pb2.Status.STORAGE_STATUS_NOT_AVAILABLE
if self == Status.StorageStatus.UNFORMATTED:
Expand Down Expand Up @@ -1130,7 +1130,7 @@ def translate_to_rpc(self, rpcStatus):



self.storage_status.translate_to_rpc(rpcStatus.storage_status)
rpcStatus.storage_status = self.storage_status.translate_to_rpc()



Expand Down
8 changes: 4 additions & 4 deletions mavsdk/generated/follow_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FollowDirection(Enum):
FRONT_RIGHT = 3
FRONT_LEFT = 4

def translate_to_rpc(self, rpcFollowDirection):
def translate_to_rpc(self):
if self == Config.FollowDirection.NONE:
return follow_me_pb2.Config.FOLLOW_DIRECTION_NONE
if self == Config.FollowDirection.BEHIND:
Expand Down Expand Up @@ -158,7 +158,7 @@ def translate_to_rpc(self, rpcConfig):



self.follow_direction.translate_to_rpc(rpcConfig.follow_direction)
rpcConfig.follow_direction = self.follow_direction.translate_to_rpc()



Expand Down Expand Up @@ -370,7 +370,7 @@ class Result(Enum):
NOT_ACTIVE = 7
SET_CONFIG_FAILED = 8

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == FollowMeResult.Result.UNKNOWN:
return follow_me_pb2.FollowMeResult.RESULT_UNKNOWN
if self == FollowMeResult.Result.SUCCESS:
Expand Down Expand Up @@ -462,7 +462,7 @@ def translate_to_rpc(self, rpcFollowMeResult):



self.result.translate_to_rpc(rpcFollowMeResult.result)
rpcFollowMeResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Result(Enum):
UNSUPPORTED = 10
PROTOCOL_ERROR = 11

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == FtpResult.Result.UNKNOWN:
return ftp_pb2.FtpResult.RESULT_UNKNOWN
if self == FtpResult.Result.SUCCESS:
Expand Down Expand Up @@ -256,7 +256,7 @@ def translate_to_rpc(self, rpcFtpResult):



self.result.translate_to_rpc(rpcFtpResult.result)
rpcFtpResult.result = self.result.translate_to_rpc()



Expand Down
8 changes: 4 additions & 4 deletions mavsdk/generated/geofence.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Type(Enum):
INCLUSION = 0
EXCLUSION = 1

def translate_to_rpc(self, rpcType):
def translate_to_rpc(self):
if self == Polygon.Type.INCLUSION:
return geofence_pb2.Polygon.TYPE_INCLUSION
if self == Polygon.Type.EXCLUSION:
Expand Down Expand Up @@ -187,7 +187,7 @@ def translate_to_rpc(self, rpcPolygon):



self.type.translate_to_rpc(rpcPolygon.type)
rpcPolygon.type = self.type.translate_to_rpc()



Expand Down Expand Up @@ -247,7 +247,7 @@ class Result(Enum):
TIMEOUT = 5
INVALID_ARGUMENT = 6

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == GeofenceResult.Result.UNKNOWN:
return geofence_pb2.GeofenceResult.RESULT_UNKNOWN
if self == GeofenceResult.Result.SUCCESS:
Expand Down Expand Up @@ -331,7 +331,7 @@ def translate_to_rpc(self, rpcGeofenceResult):



self.result.translate_to_rpc(rpcGeofenceResult.result)
rpcGeofenceResult.result = self.result.translate_to_rpc()



Expand Down
6 changes: 3 additions & 3 deletions mavsdk/generated/gimbal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GimbalMode(Enum):
YAW_FOLLOW = 0
YAW_LOCK = 1

def translate_to_rpc(self, rpcGimbalMode):
def translate_to_rpc(self):
if self == GimbalMode.YAW_FOLLOW:
return gimbal_pb2.GIMBAL_MODE_YAW_FOLLOW
if self == GimbalMode.YAW_LOCK:
Expand Down Expand Up @@ -82,7 +82,7 @@ class Result(Enum):
ERROR = 2
TIMEOUT = 3

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == GimbalResult.Result.UNKNOWN:
return gimbal_pb2.GimbalResult.RESULT_UNKNOWN
if self == GimbalResult.Result.SUCCESS:
Expand Down Expand Up @@ -154,7 +154,7 @@ def translate_to_rpc(self, rpcGimbalResult):



self.result.translate_to_rpc(rpcGimbalResult.result)
rpcGimbalResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class Result(Enum):
SUCCESS = 1
INFORMATION_NOT_RECEIVED_YET = 2

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == InfoResult.Result.UNKNOWN:
return info_pb2.InfoResult.RESULT_UNKNOWN
if self == InfoResult.Result.SUCCESS:
Expand Down Expand Up @@ -566,7 +566,7 @@ def translate_to_rpc(self, rpcInfoResult):



self.result.translate_to_rpc(rpcInfoResult.result)
rpcInfoResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/log_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Result(Enum):
INVALID_ARGUMENT = 5
FILE_OPEN_FAILED = 6

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == LogFilesResult.Result.UNKNOWN:
return log_files_pb2.LogFilesResult.RESULT_UNKNOWN
if self == LogFilesResult.Result.SUCCESS:
Expand Down Expand Up @@ -290,7 +290,7 @@ def translate_to_rpc(self, rpcLogFilesResult):



self.result.translate_to_rpc(rpcLogFilesResult.result)
rpcLogFilesResult.result = self.result.translate_to_rpc()



Expand Down
8 changes: 4 additions & 4 deletions mavsdk/generated/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CameraAction(Enum):
START_VIDEO = 4
STOP_VIDEO = 5

def translate_to_rpc(self, rpcCameraAction):
def translate_to_rpc(self):
if self == MissionItem.CameraAction.NONE:
return mission_pb2.MissionItem.CAMERA_ACTION_NONE
if self == MissionItem.CameraAction.TAKE_PHOTO:
Expand Down Expand Up @@ -261,7 +261,7 @@ def translate_to_rpc(self, rpcMissionItem):



self.camera_action.translate_to_rpc(rpcMissionItem.camera_action)
rpcMissionItem.camera_action = self.camera_action.translate_to_rpc()



Expand Down Expand Up @@ -494,7 +494,7 @@ class Result(Enum):
UNSUPPORTED_MISSION_CMD = 11
TRANSFER_CANCELLED = 12

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == MissionResult.Result.UNKNOWN:
return mission_pb2.MissionResult.RESULT_UNKNOWN
if self == MissionResult.Result.SUCCESS:
Expand Down Expand Up @@ -602,7 +602,7 @@ def translate_to_rpc(self, rpcMissionResult):



self.result.translate_to_rpc(rpcMissionResult.result)
rpcMissionResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/mission_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class Result(Enum):
NO_MISSION_AVAILABLE = 8
TRANSFER_CANCELLED = 9

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == MissionRawResult.Result.UNKNOWN:
return mission_raw_pb2.MissionRawResult.RESULT_UNKNOWN
if self == MissionRawResult.Result.SUCCESS:
Expand Down Expand Up @@ -490,7 +490,7 @@ def translate_to_rpc(self, rpcMissionRawResult):



self.result.translate_to_rpc(rpcMissionRawResult.result)
rpcMissionRawResult.result = self.result.translate_to_rpc()



Expand Down
8 changes: 4 additions & 4 deletions mavsdk/generated/mocap.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ class MavFrame(Enum):
MOCAP_NED = 0
LOCAL_FRD = 1

def translate_to_rpc(self, rpcMavFrame):
def translate_to_rpc(self):
if self == Odometry.MavFrame.MOCAP_NED:
return mocap_pb2.Odometry.MAV_FRAME_MOCAP_NED
if self == Odometry.MavFrame.LOCAL_FRD:
Expand Down Expand Up @@ -915,7 +915,7 @@ def translate_to_rpc(self, rpcOdometry):



self.frame_id.translate_to_rpc(rpcOdometry.frame_id)
rpcOdometry.frame_id = self.frame_id.translate_to_rpc()



Expand Down Expand Up @@ -1003,7 +1003,7 @@ class Result(Enum):
CONNECTION_ERROR = 3
INVALID_REQUEST_DATA = 4

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == MocapResult.Result.UNKNOWN:
return mocap_pb2.MocapResult.RESULT_UNKNOWN
if self == MocapResult.Result.SUCCESS:
Expand Down Expand Up @@ -1079,7 +1079,7 @@ def translate_to_rpc(self, rpcMocapResult):



self.result.translate_to_rpc(rpcMocapResult.result)
rpcMocapResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/offboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ class Result(Enum):
TIMEOUT = 6
NO_SETPOINT_SET = 7

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == OffboardResult.Result.UNKNOWN:
return offboard_pb2.OffboardResult.RESULT_UNKNOWN
if self == OffboardResult.Result.SUCCESS:
Expand Down Expand Up @@ -817,7 +817,7 @@ def translate_to_rpc(self, rpcOffboardResult):



self.result.translate_to_rpc(rpcOffboardResult.result)
rpcOffboardResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Result(Enum):
WRONG_TYPE = 4
PARAM_NAME_TOO_LONG = 5

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == ParamResult.Result.UNKNOWN:
return param_pb2.ParamResult.RESULT_UNKNOWN
if self == ParamResult.Result.SUCCESS:
Expand Down Expand Up @@ -134,7 +134,7 @@ def translate_to_rpc(self, rpcParamResult):



self.result.translate_to_rpc(rpcParamResult.result)
rpcParamResult.result = self.result.translate_to_rpc()



Expand Down
4 changes: 2 additions & 2 deletions mavsdk/generated/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Result(Enum):
NO_RESPONSE = 4
BUSY = 5

def translate_to_rpc(self, rpcResult):
def translate_to_rpc(self):
if self == ShellResult.Result.UNKNOWN:
return shell_pb2.ShellResult.RESULT_UNKNOWN
if self == ShellResult.Result.SUCCESS:
Expand Down Expand Up @@ -134,7 +134,7 @@ def translate_to_rpc(self, rpcShellResult):



self.result.translate_to_rpc(rpcShellResult.result)
rpcShellResult.result = self.result.translate_to_rpc()



Expand Down
Loading

0 comments on commit b8b9d17

Please sign in to comment.