# frozen_string_literal: true module DjiMqttConnect module Thing::Product # Issue wayline task # https://developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/thing-model/gateway/dock/wayline.html#issue-wayline-task class FlighttaskPrepareServicesMessage < ServicesMessage def self.build(data:, bid: generate_bid, tid: generate_tid, timestamp: current_timestamp) new( bid: bid, tid: tid, timestamp: timestamp, _method: "flighttask_prepare", data: data ) end attribute :_method, Types::String.enum("flighttask_prepare") attribute :data do # Millisecond timestamp of task execution time. # Optional field. When the task_type is 0 or 1, it is required. When the task_type is 2, it is not required. attribute? :execute_time, Types::Timestamp attribute :flight_id, Types::String # The execution time of immediate task and timed task are defined by execute_time. # The conditional task supports the task readiness condition defined by ready_conditions. # The task can be executed if conditions are satisfied within a specified period. # Immediate task has the highest priority. # Timed task and conditional task have the same priority. # {"0":"Immediate task","1":"Timed task","2":"Conditional task"} attribute :task_type, Types::Integer.enum(0, 1, 2) # {"0":"Normal waypoint wayline"} attribute :wayline_type, Types::Integer.enum(0) attribute :file do # File MD5 signature attribute :fingerprint, Types::String # File URL attribute :url, Types::String end # Optional field. For conditional task (which means the task_type is 2), this field is required. For other types of tasks, this field is ignored. # After the conditional task is issued, device will check whether the ready_conditions are satisfied or not at a fixed frequency. # If conditions are satisfied, flighttask_ready event will be sent. # When the device side receives the flighttask_execute command, conditions of the ready_conditions of task will be checked whether they are all satisfied. attribute? :ready_conditions do attribute? :battery_capacity, Types::Integer attribute? :begin_time, Types::Timestamp attribute? :end_time, Types::Timestamp end # Optional field. Pre-check conditions added for task execution on the device side. If any condition is not satisfied, execution will fail. attribute? :executable_conditions do attribute :storage_capacity, Types::Integer end # Optional field for resuming interrupted wayline task. If specified, the wayline task will start executing from the breakpoint position indicated by the field. attribute? :break_point do attribute :index, Types::Integer # {"0":"On the wayline segment","1":"On the waypoint"} attribute :state, Types::Integer.enum(0, 1) attribute :progress, Types::Float.constrained(gteq: 0, lteq: 1.0) attribute :wayline_id, Types::Integer end # {"unit":"meter","min":20,"max":1500} attribute :rth_altitude, Types::Integer.constrained(gteq: 20, lteq: 1500) # {"0":"Intelligent altitude","1":"Preset altitude"} attribute? :rth_mode, Types::Integer.enum(0, 1) # {"0":"Return to Home (RTH)","1":"Hovering","2":"Landing"} attribute :out_of_control_action, Types::Integer.enum(0, 1, 2) # {"0":"Continue executing the wayline task","1":"Exit the wayline task and execute the remote controller out of control action"} attribute :exit_wayline_when_rc_lost, Types::Integer.enum(0, 1) end end end end