# frozen_string_literal: true module DjiMqttConnect module Thing::Product class HmsEventsMessage < EventsMessage attribute :_method, Types::String.enum("hms") attribute :data do attribute :list, Types::Array do # {"0":"Inform","1":"Notice","2":"Alarm"} attribute :level, Types::Integer.enum(0, 1, 2) # {"0":"flight mission","1":"device management","2":"media","3":"hms"} attribute :module, Types::Integer.enum(0, 1, 2, 3) # {"0":"on the ground","1":"in the sky"} attribute? :in_the_sky, Types::Integer.enum(0, 1) attribute :code, Types::String # {"0":"No","1":"Yes"} attribute? :imminent, Types::Integer.enum(0, 1) attribute :args do attribute :component_index, Types::Integer attribute :sensor_index, Types::Integer end def in_the_sky? in_the_sky == 1 end def aircraft_message if in_the_sky? Translations.aircraft_in_the_sky_hms_event_code_message( code: code, sensor_index: args.sensor_index, component_index: args.component_index ) else Translations.aircraft_hms_event_code_message( code: code, sensor_index: args.sensor_index, component_index: args.component_index ) end end def dock_message Translations.dock_hms_event_code_message( code: code, sensor_index: args.sensor_index ) end end end end end end