Class: Cosmos::TlmViewerConfig::ScreenInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group, target_name, name, filename, x_pos, y_pos) ⇒ ScreenInfo

Returns a new instance of ScreenInfo.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 32

def initialize(group, target_name, name, filename, x_pos, y_pos)
  @group = group
  @target_name = target_name.upcase
  @original_target_name = nil
  @name = name.upcase
  @name = "#{@target_name} #{@name}" if group
  @filename = filename
  @x_pos = x_pos
  @y_pos = y_pos
  @substitute = nil
  @force_substitute = false
  @screen = nil
  @show_on_startup = false
  @items = []
  @invalid_items = []
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



22
23
24
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 22

def filename
  @filename
end

#force_substituteObject

Returns the value of attribute force_substitute.



26
27
28
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 26

def force_substitute
  @force_substitute
end

#groupObject

Returns the value of attribute group.



18
19
20
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 18

def group
  @group
end

#invalid_itemsObject

Returns the value of attribute invalid_items.



30
31
32
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 30

def invalid_items
  @invalid_items
end

#itemsObject

Returns the value of attribute items.



29
30
31
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 29

def items
  @items
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 21

def name
  @name
end

#original_target_nameObject

Returns the value of attribute original_target_name.



20
21
22
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 20

def original_target_name
  @original_target_name
end

#screenObject

Returns the value of attribute screen.



27
28
29
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 27

def screen
  @screen
end

#show_on_startupObject

Returns the value of attribute show_on_startup.



28
29
30
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 28

def show_on_startup
  @show_on_startup
end

#substituteObject

Returns the value of attribute substitute.



25
26
27
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 25

def substitute
  @substitute
end

#target_nameObject

Returns the value of attribute target_name.



19
20
21
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 19

def target_name
  @target_name
end

#x_posObject

Returns the value of attribute x_pos.



23
24
25
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 23

def x_pos
  @x_pos
end

#y_posObject

Returns the value of attribute y_pos.



24
25
26
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 24

def y_pos
  @y_pos
end

Instance Method Details

#full_nameObject



49
50
51
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 49

def full_name
  @group ? @name : "#{@target_name} #{@name}"
end

#read_itemsObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb', line 53

def read_items
  @items = []
  @invalid_items = []
  begin
    parser = ConfigParser.new
    parser.parse_file(@filename) do |keyword, parameters|
      if keyword
        case keyword
        when 'SCREEN', 'END', 'SETTING', 'SUBSETTING', 'GLOBAL_SETTING', 'GLOBAL_SUBSETTING'
          # Do nothing
        else
          if keyword == 'NAMED_WIDGET'
            keyword = parameters[1].to_s.upcase
            parameters = parameters[2..-1]
          end

          klass = Cosmos.require_class(keyword.downcase + '_widget')
          if klass.takes_value?
            begin
              if @substitute and (@original_target_name == parameters[0].to_s.upcase or @force_substitute)
                System.telemetry.packet_and_item(@substitute, parameters[1], parameters[2])
                @items << "#{@substitute} #{parameters[1]} #{parameters[2]}".upcase
              else
                System.telemetry.packet_and_item(*parameters[0..2])
                @items << "#{parameters[0]} #{parameters[1]} #{parameters[2]}".upcase
              end
            rescue
              @invalid_items << "#{parameters[0]} #{parameters[1]} #{parameters[2]}".upcase
              next
            end
          end
        end # case keyword
      end # if keyword
    end # parser.parse_file
  rescue Exception
    # Oh well - Bad Screen
  end
end