Method: Cosmos::Api#get_all_target_info

Defined in:
lib/cosmos/api/target_api.rb

#get_all_target_info(scope: $cosmos_scope, token: $cosmos_token) ⇒ Array<Array<String, Numeric, Numeric>] Array of Arrays \[name, interface, cmd_cnt, tlm_cnt]

Get information about all targets

Returns:

  • (Array<Array<String, Numeric, Numeric>] Array of Arrays \[name, interface, cmd_cnt, tlm_cnt])

    Array<Array<String, Numeric, Numeric>] Array of Arrays [name, interface, cmd_cnt, tlm_cnt]



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cosmos/api/target_api.rb', line 52

def get_all_target_info(scope: $cosmos_scope, token: $cosmos_token)
  authorize(permission: 'system', scope: scope, token: token)
  info = []
  get_target_list(scope: scope, token: token).each do |target_name|
    cmd_cnt = 0
    packets = TargetModel.packets(target_name, type: :CMD, scope: scope)
    packets.each do |packet|
      cmd_cnt += Topic.get_cnt("#{scope}__COMMAND__{#{target_name}}__#{packet['packet_name']}")
    end
    tlm_cnt = 0
    packets = TargetModel.packets(target_name, type: :TLM, scope: scope)
    packets.each do |packet|
      tlm_cnt += Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet['packet_name']}")
    end
    interface_name = ''
    InterfaceModel.all(scope: scope).each do |name, interface|
      if interface['target_names'].include? target_name
        interface_name = interface['name']
        break
      end
    end
    info << [target_name, interface_name, cmd_cnt, tlm_cnt]
  end
  info
end