# frozen_string_literal: true module DjiMqttConnect module Thing::Product class DockOsdMessage < OsdMessage schema schema.strict STABLE_DATA_ATTRIBUTES = %i[ drc_state drone_in_dock job_number ] # {"0":"Idle mode (No cooling, heating, and dehumidification)","1":"Cooling mode","2":"Heating mode","3":"Dehumidification mode","4":"Cooling exit mode","5":"Heating exit mode","6":"Dehumidification exit mode","7":"Cooling preparation mode","8":"Heating preparation mode","9":"Dehumidification preparation mode"} AirConditionerState = Types::Integer.enum(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) attribute :data do include Mixins::LatitudeConditional include Mixins::LongitudeConditional include Mixins::TemperatureConditional attribute? :acc_time, Types::Integer attribute? :activation_time, Types::Integer attribute? :backup_battery do include Mixins::TemperatureConditional attribute :switch, Types::Integer.enum(0, 1) attribute :voltage, Types::Integer attribute :temperature, Types::Temperature end # {"0":"Disconnected","1":"Connecting","2":"Connected"} attribute? :drc_state, Types::Integer.enum(0, 1, 2) attribute? :drone_battery_maintenance_info do attribute :batteries, Types::Array do include Mixins::TemperatureConditional attribute :index, Types::Integer attribute :capacity_percent, Types::Integer attribute :voltage, Types::Integer attribute :temperature, Types::Temperature end # {"0":"Battery is not in heating or insulation","1":"Battery is in heating","2":"Battery is in insulation"} attribute? :heat_state, Types::Integer.enum(0, 1, 2) # {"0":"No need to maintenance","1":"Need maintenance","2":"Under maintenance"} attribute? :maintenance_state, Types::Integer attribute? :maintenance_time_left, Types::Integer end attribute? :drone_charge_state do # {"0":"not charging","1":"charging"} attribute :state, Types::Integer.enum(0, 1) # {"min":"0","max":"100"} attribute :capacity_percent, Types::Integer.constrained(gteq: 0, lteq: 100) end attribute? :drone_in_dock, Types::Integer.enum(0, 1) attribute? :electric_supply_voltage, Types::Integer attribute? :flighttask_prepare_capacity, Types::Integer attribute? :flighttask_step_code, Types::Integer attribute? :job_number, Types::Integer attribute? :latitude, Types::Latitude attribute? :longitude, Types::Longitude attribute? :maintain_status do attribute :maintain_status_array, Types::Array do # {"0":"No maintenance","1":"Under maintenance"} attribute :state, Types::Integer # {"0":"No maintenance","1":"Drone basic maintenance","2":"Drone routine maintenance","3":"Drone deep maintenance","17":"Dock maintenance"} attribute :last_maintain_type, Types::Integer attribute :last_maintain_time, Types::Integer attribute :last_maintain_work_sorties, Types::Integer end end attribute? :media_file_detail do attribute :remain_upload, Types::Integer end attribute? :network_state do attribute :type, Types::Integer attribute :quality, Types::Integer attribute :rate, Types::JSON::Decimal end attribute? :sdr do attribute :down_quality, Types::Integer attribute :frequency_band, Types::JSON::Decimal attribute :up_quality, Types::Integer end attribute? :wireless_link do attribute :_4g_freq_band, Types::JSON::Decimal attribute :_4g_gnd_quality, Types::Integer attribute :_4g_link_state, Types::Integer attribute :_4g_quality, Types::Integer attribute :_4g_uav_quality, Types::Integer attribute :dongle_number, Types::Integer attribute :link_workmode, Types::Integer attribute :sdr_freq_band, Types::JSON::Decimal attribute :sdr_link_state, Types::Integer attribute :sdr_quality, Types::Integer end attribute? :working_current, Types::Integer attribute? :working_voltage, Types::Integer # Weather attribute? :height, Types::JSON::Decimal attribute? :humidity, Types::Integer attribute? :rainfall, Types::JSON::Decimal attribute? :temperature, Types::Temperature attribute? :wind_speed, Types::JSON::Decimal attribute? :environment_temperature, Types::Temperature attribute? :alternate_land_point do attribute :latitude, Types::Latitude attribute :longitude, Types::Longitude attribute :height, Types::JSON::Decimal attribute :safe_land_height, Types::JSON::Decimal attribute :is_configured, Types::Integer.enum(0, 1) end attribute? :first_power_on, Types::Integer attribute? :position_state do # {"0":"Not calibrated","1":"Calibrated"} attribute :is_calibration, Types::Integer.enum(0, 1) # {"0":"Not start","1":"fixing","2":"fix successfully","3":"fix failed"} attribute :is_fixed, Types::Integer.enum(0, 1, 2, 3) attribute :quality, Types::Integer.constrained(gteq: 0, lteq: 5) attribute :gps_number, Types::Integer attribute :rtk_number, Types::Integer end attribute? :storage do attribute :total, Types::Integer attribute :used, Types::Integer end # {"0":"Idle","1":"On-site debugging","2":"Remote debugging","3":"Firmware upgrading","4":"Working"} attribute? :mode_code, Types::Integer.enum(0, 1, 2, 3, 4) attribute? :air_conditioner do attribute :air_conditioner_state, AirConditionerState | Types::Integer attribute :switch_time, Types::Integer def air_conditioner_state? AirConditionerState.valid?(air_conditioner_state) end end # {"0":"Closed","1":"Opened"} attribute? :alarm_state, Types::Integer.enum(0, 1) # {"1":"Planned storage strategy of battery","2":"Emergency storage strategy of battery"} attribute? :battery_store_mode, Types::Integer.enum(1, 2) # {"0":"Closed","1":"Opened","2":"Half-open","3":"Cover state is abnormal"} attribute? :cover_state, Types::Integer.enum(0, 1, 2, 3) # {"0":"Closed","1":"Opened"} attribute? :emergency_stop_state, Types::Integer.enum(0, 1) # {"0":"Closed","1":"Opened","2":"Half-open","3":"Putter state is abnormal"} attribute? :putter_state, Types::Integer.enum(0, 1, 2, 3) # {"0":"Closed","1":"Opened"} attribute? :supplement_light_state, Types::Integer.enum(0, 1) attribute? :sub_device do attribute? :device_sn, Types::String attribute? :device_model_key, Types::String # {"0":"Offline","1":"Online"} attribute :device_online_status, Types::Integer.enum(0, 1) # {"0":"Not paired","1":"Paired"} attribute :device_paired, Types::Integer.enum(0, 1) end def drone_in_dock? drone_in_dock == 1 end def environment_temperature? environment_temperature && !Types::InvalidTemperature.valid?(environment_temperature) end end end end end