From bd9030e7311460ca6bbcf7302b3393664b6e2371 Mon Sep 17 00:00:00 2001 From: "Thomas, Jason (Software)" Date: Tue, 14 Jun 2022 12:53:56 -0600 Subject: [PATCH 1/2] Remove old interface code for inject_tlm --- cosmos/lib/cosmos/api/tlm_api.rb | 8 ++++---- .../microservices/interface_microservice.rb | 15 --------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/cosmos/lib/cosmos/api/tlm_api.rb b/cosmos/lib/cosmos/api/tlm_api.rb index ac9e8a135..b0ac68922 100644 --- a/cosmos/lib/cosmos/api/tlm_api.rb +++ b/cosmos/lib/cosmos/api/tlm_api.rb @@ -111,11 +111,11 @@ def set_tlm(*args, type: :CONVERTED, scope: $cosmos_scope, token: $cosmos_token) # Injects a packet into the system as if it was received from an interface # - # @param target_name[String] Target name of the packet - # @param packet_name[String] Packet name of the packet - # @param item_hash[Hash] Hash of item_name and value for each item you want to change from the current value table + # @param target_name [String] Target name of the packet + # @param packet_name [String] Packet name of the packet + # @param item_hash [Hash] Hash of item_name and value for each item you want to change from the current value table # @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS - def inject_tlm(target_name, packet_name, item_hash = nil, log: true, type: :CONVERTED, scope: $cosmos_scope, token: $cosmos_token) + def inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, scope: $cosmos_scope, token: $cosmos_token) authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token) unless CvtModel::VALUE_TYPES.include?(type.intern) raise "Unknown type '#{type}' for #{target_name} #{packet_name}" diff --git a/cosmos/lib/cosmos/microservices/interface_microservice.rb b/cosmos/lib/cosmos/microservices/interface_microservice.rb index f45de99cb..164397bde 100644 --- a/cosmos/lib/cosmos/microservices/interface_microservice.rb +++ b/cosmos/lib/cosmos/microservices/interface_microservice.rb @@ -83,11 +83,6 @@ def run @interface.write_raw(msg_hash['raw']) next 'SUCCESS' end - if msg_hash['inject_tlm'] - Logger.info "#{@interface.name}: Inject telemetry" if msg_hash['log'] - @tlm.inject_tlm(msg_hash) - next 'SUCCESS' - end if msg_hash.key?('log_raw') if msg_hash['log_raw'] == 'true' Logger.info "#{@interface.name}: Enable raw logging" @@ -412,16 +407,6 @@ def handle_packet(packet) TelemetryTopic.write_packet(packet, scope: @scope) end - def inject_tlm(hash) - packet = System.telemetry.packet(hash['target_name'], hash['packet_name']).clone - if hash['item_hash'] - JSON.parse(hash['item_hash']).each do |item, value| - packet.write(item.to_s, value, hash['type'].to_sym) - end - end - handle_packet(packet) - end - def handle_connection_failed(connect_error) @error = connect_error Logger.error "#{@interface.name}: Connection Failed: #{connect_error.formatted(false, false)}" From df7091169a19e3d36c8efb6ab1a5615863f17d1f Mon Sep 17 00:00:00 2001 From: "Thomas, Jason (Software)" Date: Tue, 14 Jun 2022 14:30:24 -0600 Subject: [PATCH 2/2] Restore plugin parsing --- cosmos/bin/cosmos | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cosmos/bin/cosmos b/cosmos/bin/cosmos index 06654daae..af5ae3b45 100755 --- a/cosmos/bin/cosmos +++ b/cosmos/bin/cosmos @@ -280,9 +280,13 @@ def load_plugin(plugin_file_path, scope:, variables_file: nil) end unless found puts "Loading new plugin: #{plugin_file_path}" - variables = nil - variables = JSON.parse(File.read(variables_file)) if variables_file - plugin_hash = Cosmos::PluginModel.install_phase1(plugin_file_path, variables, scope: scope) + if variables_file + # Assume phase1 is already done + variables = JSON.parse(File.read(variables_file)) + plugin_hash = Cosmos::PluginModel.new(name: File.basename(plugin_file_path), variables: variables, scope: scope).as_json + else + plugin_hash = Cosmos::PluginModel.install_phase1(plugin_file_path, scope: scope) + end Cosmos::PluginModel.install_phase2(plugin_hash['name'], plugin_hash['variables'], scope: scope) end rescue => err