# frozen_string_literal: true module DjiMqttConnect module Thing::Product # Report wayline task progress # https://developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/thing-model/gateway/dock/wayline.html#report-wayline-task-progress # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/dock2/wayline.html#report-mission-progress class FlighttaskProgressEventsMessage < EventsMessage attribute :_method, Types::String.enum("flighttask_progress") attribute :data do include Mixins::ResultMessage attribute :result, Types::ResultCode attribute :output do attribute :ext do attribute :current_waypoint_index, Types::Integer # {"0":"Disconnected","1":"This waypoint is not supported","2":"Wayline preparation state. It can upload files and execute existing files","3":"Wayline file uploading","4":"Trigger start command. The aircraft triggers logic such as reading the wayline. The mission has not started yet and it's in a preparation state","5":"Entering the wayline, heading to the first waypoint","6":"Wayline execution","7":"Wayline interrupted. Triggered conditions are 1 for User actively pauses and 2 for Flight control abnormality","8":"Wayline recovery","9":"Wayline completed"} attribute? :wayline_mission_state, Types::Integer.enum(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) def humanized_wayline_mission_state I18n.t(wayline_mission_state, scope: "dji_mqtt_connect.thing_product_flighttask_progress_events_message.humanized_wayline_mission_state", default: wayline_mission_state) end # Number of media files generated during the current flight mission attribute? :media_count, Types::Integer attribute :track_id, Types::String | Types::Nil attribute :flight_id, Types::FlightID attribute? :wayline_id, Types::Integer attribute? :break_point do attribute :index, Types::Integer # {"0":"On the wayline segment","1":"On the waypoint"} attribute :state, Types::Integer.enum(0, 1) # {"min":"0","max":"1.0"} attribute :progress, Types::JSON::Decimal.constrained(gteq: 0, lteq: 1.0) attribute :wayline_id, Types::Integer # {"0":"No abnormalities","1":"Mission ID does not exist. The wayline mission has not been executed.","2":"Uncommon error, please contact technical support","4":"Error loading wayline file when requesting to start/resume the wayline mission, please try uploading the file again or contact technical support","5":"Failed to query breakpoint file when requesting breakpoint information. Failed to parse breakpoint type when requesting to resume the wayline mission","6":"Incorrect cmd parameter when requesting to start/end the wayline mission, incorrect protocol command in the request. Failed to parse breakpoint type when requesting to resume the wayline mission","7":"Timeout parsing the WPMZ file when requesting to start/resume the wayline mission, please retry","257":"Wayline has already started, cannot start again","258":"Unable to interrupt the wayline in this state, only allowed to pause the wayline in the executing state","259":"Wayline has not started, cannot end the wayline","261":"Flight mission conflict, unable to obtain control of the aircraft, not allowed to start the wayline during landing and return","262":"Unable to resume wayline in this state, only allowed when the wayline is paused","513":"Aircraft exceeded the maximum altitude limit","514":"Aircraft exceeded the maximum distance limit","516":"Aircraft triggered altitude limit","517":"Aircraft triggered obstacle sensing","518":"Poor RTK signal","519":"Approaching the boundary of Restricted Zone","521":"Exceeded the dock's GEO zone altitude limit","522":"Failed to request takeoff for the wayline","523":"Takeoff mission execution failed","524":"Failed to request wayline mission","526":"Failed to request wayline RTK fixing mission","527":"Wayline RTK fixing mission failed to run","769":"Weak GPS signal","770":"The remote controller gear is not in N position.","771":"Home point not refreshed","772":"Unable to start the mission due to low current battery level","773":"Wayline interrupted due to low battery causing return to home","775":"Disconnection between the remote controller and the aircraft","778":"Aircraft is on the ground with propellers spinning, not allowed to start the wayline","779":"During the real-time terrain follow, the camera state is abnormal(such as too bright, too dark and inconsistent brightness on both sides)","780":"Real-time terrain-following altitude set by the user is invalid (greater than 200m or less than 30m)","781":"Global map calculation error during real-time terrain follow","784":"Wayline interrupted due to strong winds causing return to home","1281":"User exit","1282":"User interruption","1283":"User triggered return to home","1539":"Incorrect start information (waypoint index or progress)","1540":"Using an unsupported coordinate system","1541":"Using an unsupported altitude mode","1542":"Using an unsupported transitional wayline mode","1543":"Using an unsupported yaw mode","1544":"Using an unsupported yaw direction reversal mode","1545":"Using an unsupported waypoint type","1546":"Coordinated turning type cannot be used for the start and end points","1547":"Wayline global speed exceeds a reasonable range","1548":"Waypoint number abnormal","1549":"Abnormal latitude and longitude data","1550":"Abnormal turning intercept","1551":"Maximum speed of wayline segment exceeds a reasonable range","1552":"Wayline segment target speed exceeds a reasonable range","1553":"Waypoint yaw angle exceeds a reasonable range","1555":"Input mission_id of resuming from breakpoint is wrong","1556":"Progress information of resuming from breakpoint input error","1557":"Mission state of resuming from breakpoint is abnormal","1558":"Waypoint index information of resuming from breakpoint input error","1559":"Incorrect latitude and longitude information for resuming from breakpoint","1560":"Yaw input error for waypoints during resuming from breakpoint","1561":"Incorrect flag setting for resuming from breakpoint","1563":"Wayline generation failed","1564":"Wayline execution failed","1565":"Emergency stop due to wayline obstacle sensing","1588":"Unrecognized action type","1595":"Action ID must be unique.","1598":"Action ID value cannot be 65535","1602":"Number of action groups exceeds a reasonable range","1603":"Error in action group effective range","1606":"Action index exceeds a reasonable range during resuming from breakpoint","1608":"Trigger running result of breakpoint information is abnormal","1609":"Action group ID information can not be duplicated during resume from breakpoint","1610":"Action group positions cannot be repeated during resuming from breakpoint","1611":"Action group positions exceed a reasonable range during resuming from breakpoint","1612":"Action ID is not in the breakpoint information during resuming","1613":"The action state can not be set to interrupt during the resuming flight from breakpoint","1614":"Resume failure due to incorrect breakpoint information","1634":"Unrecognized action type","1649":"Unrecognized trigger type","65534":"Unknown issue","65535":"Unknown issue"} attribute :break_reason, Types::Integer def humanized_break_reason I18n.t(break_reason, scope: "dji_mqtt_connect.flighttask_progress.break_reason", default: break_reason.to_s) end attribute :latitude, Types::Latitude attribute :longitude, Types::Longitude # {"unit":"m","unitName":"meter"} attribute :height, Types::JSON::Decimal attribute :attitude_head, Types::Integer | Types::JSON::Decimal end end # {"partially_done":"partially done","sent":"sent","in_progress":"in progress","ok":"success","paused":"paused","rejected":"rejected","failed":"failed","canceled":"canceled or stopped","timeout":"timeout"} attribute :status, Types::String.enum( "partially_done", "sent", "in_progress", "ok", "paused", "rejected", "failed", "canceled", "timeout" ) def humanized_status I18n.t(status, scope: "dji_mqtt_connect.flighttask_status", default: status.titleize) end attribute :progress do # {"0":"Initial state","1":"Pre-flight check, whether the aircraft is executing a wayline","2":"Pre-flight check, whether the dock has exited working mode","3":"Pre-flight check, wayline execution in progress","4":"Pre-return-to-home check, in the process of returning to home","5":"Wayline execution enters the preparation state, waiting for the mission to be issued","6":"Dock enters working state","7":"Enter the startup check and cover preparation work","8":"Remote image transmission frequency Pairing","9":"Waiting for the flight system to be ready, push connection established","10":"Waiting for RTK source to listen for reported values","11":"Check if the RTK source is from the dock, if not, reset it","12":"Waiting for flight control notification","13":"The dock has no control and seizes the control of the aircraft","14":"Consistency check of custom flight area","15":"Consistency check of offline maps","16":"Get the latest KMZ URL","17":"Download KMZ","18":"KMZ uploading","19":"Coloring configuration","20":"Aircraft takeoff parameter setting, alternate landing point setting, takeoff altitude setting, coloring setting","21":"Aircraft flyto takeoff parameter setting","22":"Takeoff dock checks the landing dock preparation status","23":"Home point setting","24":"Trigger wayline execution","25":"Wayline executing","26":"Enter pre-return-to-home check","27":"Aircraft landing at the dock","28":"Close the cover after landing","29":"Dock exits working mode","30":"Dock abnormal recovery","31":"Dock uploads flight system logs","32":"Check camera recording state","33":"Get the number of media files","34":"Abnormal recovery after dock takeoff cover","35":"Notify mission result","36":"Log list retrieval - Aircraft list","37":"Log list retrieval - Retrieve the list of docks","38":"Log list retrieval - Upload log list result","39":"Log retrieval - Retrieve aircraft logs","40":"Log retrieval - Retrieve dock logs","41":"Log retrieval - Compress aircraft logs","42":"Log retrieval - Compress dock logs","43":"Log retrieval - Upload aircraft logs","44":"Log retrieval - Upload dock logs","45":"Log retrieval - Notify the result","46":"Custom flight area file update preparation","47":"Custom flight area updating","48":"Offline map update preparation","49":"Offline map updating","65533":"Wait for service response after completion","65534":"No specific state","65535":"UNKNOWN"} attribute :current_step, Types::Integer def humanized_current_step I18n.t(current_step, scope: "dji_mqtt_connect.flighttask_progress.current_step", default: current_step.to_s) end # {"min":"0","max":"100","step":"1"} attribute :percent, Types::Integer.constrained(gteq: 0, lteq: 100) end end end def humanized_summary return super unless data.output.ext.break_point Translations.thing_product_events_summary( "#{_method}_with_break_point", **humanized_summary_interpolation ) end def humanized_summary_interpolation super.merge( status: data.output.humanized_status, percent: data.output.progress.percent, current_step: data.output.progress.humanized_current_step, wayline_mission_state: data.output.ext.humanized_wayline_mission_state || "-", flight_id: data.output.ext.flight_id, break_reason: data.output.ext.break_point&.humanized_break_reason || "-" ) end # All the flight IDs in the message def flight_ids [data.output.ext.flight_id] end end end end