Class: Cosmos::SimulatedTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/utilities/simulated_target.rb

Overview

Base class for all virtual COSMOS targets which must be implemented by a subclass. Provides a framework and helper methods to implement a virtual target which can cycle telemetry values and emit telemetry packets.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_name) ⇒ SimulatedTarget

Returns a new instance of SimulatedTarget.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cosmos/utilities/simulated_target.rb', line 36

def initialize(target_name)
  @tlm_packets = {}

  # Generate copy of telemetry packets for this target
  System.telemetry.packets(target_name).each do |name, packet|
    @tlm_packets[name] = packet.clone
    @tlm_packets[name].enable_method_missing
  end

  # Set id values
  @tlm_packets.each do |name, packet|
    ids = packet.id_items
    ids.each do |id|
      packet.public_send((id.name + '=').to_sym, id.id_value)
    end
  end

  @current_cycle_delta = {}
end

Instance Attribute Details

#tlm_packetsObject

Returns the value of attribute tlm_packets.



34
35
36
# File 'lib/cosmos/utilities/simulated_target.rb', line 34

def tlm_packets
  @tlm_packets
end

Instance Method Details

#read(count_100hz, time) ⇒ Object



64
65
66
# File 'lib/cosmos/utilities/simulated_target.rb', line 64

def read(count_100hz, time)
  raise "Error: read must be implemented by subclass"
end

#set_ratesObject



56
57
58
# File 'lib/cosmos/utilities/simulated_target.rb', line 56

def set_rates
  raise "Error: set_rates must be implemented by subclass"
end

#write(packet) ⇒ Object



60
61
62
# File 'lib/cosmos/utilities/simulated_target.rb', line 60

def write(packet)
  raise "Error: write must be implemented by subclass"
end