cosmos 3.8.3 → 3.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/Manifest.txt +14 -0
  4. data/Rakefile +35 -2
  5. data/autohotkey/config/targets/INST/screens/_footer.txt +4 -0
  6. data/autohotkey/config/targets/INST/screens/hs.txt +1 -4
  7. data/autohotkey/config/tools/table_manager/OldOneDimensionalTable_def.txt +19 -0
  8. data/autohotkey/config/tools/table_manager/OldTwoDimensionalTable_def.txt +248 -0
  9. data/autohotkey/config/tools/table_manager/OneDimensionalTable_def.txt +27 -15
  10. data/autohotkey/config/tools/table_manager/TwoDimensionalTable_def.txt +12 -232
  11. data/autohotkey/procedures/example_test.rb +4 -0
  12. data/autohotkey/tools/TableManagerAHK +4 -9
  13. data/autohotkey/tools/TableManagerAHK2 +18 -0
  14. data/autohotkey/tools/TableManagerAHK3 +18 -0
  15. data/autohotkey/tools/TableManagerAHK4 +24 -0
  16. data/autohotkey/tools/TlmViewerAHK +1 -1
  17. data/autohotkey/tools/autohotkey.rb +2 -1
  18. data/autohotkey/tools/open_gl_builder.ahk +1 -1
  19. data/autohotkey/tools/table_manager.ahk +141 -70
  20. data/cosmos.gemspec +3 -3
  21. data/data/crc.txt +70 -68
  22. data/data/legal.txt +4 -5
  23. data/demo/config/data/crc.txt +10 -9
  24. data/demo/config/targets/INST/screens/_footer.txt +4 -0
  25. data/demo/config/targets/INST/screens/hs.txt +1 -6
  26. data/demo/config/targets/INST/screens/limits.txt +3 -11
  27. data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +1 -0
  28. data/demo/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +33 -22
  29. data/demo/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +30 -22
  30. data/demo/config/tools/table_manager/PPSSelectionTable_def.txt +8 -7
  31. data/demo/config/tools/table_manager/TLMMonitoringTable_def.txt +13 -13
  32. data/demo/lib/example_background_task.rb +6 -12
  33. data/demo/procedures/example_test.rb +5 -0
  34. data/lib/cosmos/conversions/conversion.rb +3 -7
  35. data/lib/cosmos/core_ext/class.rb +3 -1
  36. data/lib/cosmos/core_ext/file.rb +1 -0
  37. data/lib/cosmos/core_ext/io.rb +18 -0
  38. data/lib/cosmos/core_ext/range.rb +1 -5
  39. data/lib/cosmos/core_ext/time.rb +3 -3
  40. data/lib/cosmos/gui/dialogs/about_dialog.rb +60 -36
  41. data/lib/cosmos/gui/dialogs/calendar_dialog.rb +10 -14
  42. data/lib/cosmos/gui/dialogs/cmd_details_dialog.rb +4 -5
  43. data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +31 -17
  44. data/lib/cosmos/gui/dialogs/details_dialog.rb +63 -47
  45. data/lib/cosmos/gui/dialogs/exception_dialog.rb +77 -68
  46. data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +6 -5
  47. data/lib/cosmos/gui/dialogs/legal_dialog.rb +34 -21
  48. data/lib/cosmos/gui/dialogs/packet_log_dialog.rb +19 -43
  49. data/lib/cosmos/gui/dialogs/progress_dialog.rb +79 -42
  50. data/lib/cosmos/gui/dialogs/pry_dialog.rb +9 -5
  51. data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +6 -4
  52. data/lib/cosmos/gui/dialogs/select_dialog.rb +23 -18
  53. data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +34 -10
  54. data/lib/cosmos/gui/dialogs/splash.rb +18 -8
  55. data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +38 -43
  56. data/lib/cosmos/gui/dialogs/tlm_edit_dialog.rb +51 -53
  57. data/lib/cosmos/gui/line_graph/line_graph_scaling.rb +1 -1
  58. data/lib/cosmos/gui/line_graph/lines.rb +1 -1
  59. data/lib/cosmos/gui/qt.rb +9 -2
  60. data/lib/cosmos/gui/qt_tool.rb +50 -8
  61. data/lib/cosmos/gui/widgets/packet_log_frame.rb +53 -27
  62. data/lib/cosmos/interfaces/linc_interface.rb +103 -62
  63. data/lib/cosmos/io/json_drb_object.rb +3 -3
  64. data/lib/cosmos/io/raw_logger.rb +4 -8
  65. data/lib/cosmos/io/tcpip_server.rb +2 -2
  66. data/lib/cosmos/packets/binary_accessor.rb +1 -1
  67. data/lib/cosmos/packets/limits.rb +2 -5
  68. data/lib/cosmos/packets/packet.rb +1 -1
  69. data/lib/cosmos/packets/packet_config.rb +54 -19
  70. data/lib/cosmos/packets/parsers/packet_item_parser.rb +7 -1
  71. data/lib/cosmos/script/scripting.rb +4 -5
  72. data/lib/cosmos/system/system.rb +2 -1
  73. data/lib/cosmos/system/target.rb +4 -0
  74. data/lib/cosmos/tools/cmd_tlm_server/background_task.rb +13 -5
  75. data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +37 -27
  76. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +6 -2
  77. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +7 -5
  78. data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +21 -10
  79. data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +11 -11
  80. data/lib/cosmos/tools/script_runner/script_runner.rb +2 -18
  81. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +6 -6
  82. data/lib/cosmos/tools/table_manager/table.rb +32 -41
  83. data/lib/cosmos/tools/table_manager/table_config.rb +140 -729
  84. data/lib/cosmos/tools/table_manager/table_item.rb +20 -36
  85. data/lib/cosmos/tools/table_manager/table_item_parser.rb +46 -0
  86. data/lib/cosmos/tools/table_manager/table_manager.rb +754 -691
  87. data/lib/cosmos/tools/table_manager/table_manager_core.rb +172 -358
  88. data/lib/cosmos/tools/table_manager/table_parser.rb +75 -0
  89. data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
  90. data/lib/cosmos/tools/test_runner/test_runner.rb +11 -0
  91. data/lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb +2 -2
  92. data/lib/cosmos/tools/tlm_grapher/data_object_adders/singlexy_data_object_adder.rb +2 -2
  93. data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +2 -2
  94. data/lib/cosmos/tools/tlm_grapher/data_objects/data_object.rb +4 -4
  95. data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +13 -13
  96. data/lib/cosmos/tools/tlm_grapher/data_objects/linegraph_data_object.rb +9 -9
  97. data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +9 -9
  98. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +4 -4
  99. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +1 -1
  100. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +8 -18
  101. data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +7 -4
  102. data/lib/cosmos/top_level.rb +12 -0
  103. data/lib/cosmos/version.rb +5 -5
  104. data/run_gui_tests.bat +6 -0
  105. data/spec/core_ext/array_spec.rb +1 -1
  106. data/spec/interfaces/linc_interface_spec.rb +4 -4
  107. data/spec/io/json_drb_spec.rb +2 -2
  108. data/spec/io/json_rpc_spec.rb +1 -1
  109. data/spec/io/raw_logger_spec.rb +5 -1
  110. data/spec/packet_logs/packet_log_writer_spec.rb +1 -1
  111. data/spec/packets/packet_config_spec.rb +144 -0
  112. data/spec/packets/parsers/packet_item_parser_spec.rb +60 -0
  113. data/spec/spec_helper.rb +11 -0
  114. data/spec/system/target_spec.rb +5 -1
  115. data/spec/tools/cmd_tlm_server/background_task_spec.rb +15 -3
  116. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +117 -31
  117. data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +4 -0
  118. data/spec/tools/launcher/launcher_config_spec.rb +1 -1
  119. data/spec/tools/table_manager/table_config_spec.rb +226 -0
  120. data/spec/tools/table_manager/table_item_spec.rb +57 -0
  121. data/spec/tools/table_manager/table_parser_spec.rb +96 -0
  122. data/spec/tools/table_manager/table_spec.rb +90 -0
  123. data/spec/tools/table_manager/tablemanager_core_spec.rb +557 -0
  124. data/spec/top_level/top_level_spec.rb +9 -0
  125. data/spec/utilities/csv_spec.rb +3 -3
  126. metadata +30 -11
@@ -269,6 +269,10 @@ module Cosmos
269
269
  end
270
270
 
271
271
  describe "self.subscribe_packet_data" do
272
+ it "rejects bad queue sizes" do
273
+ expect{ CmdTlmServer.subscribe_packet_data([["COSMOS","VERSION"]], true) }.to raise_error(ArgumentError)
274
+ end
275
+
272
276
  it "subscribes to packets" do
273
277
  version = System.telemetry.packet("COSMOS","VERSION")
274
278
  allow_any_instance_of(Interface).to receive(:read) do
@@ -19,7 +19,7 @@ module Cosmos
19
19
  describe LauncherConfig do
20
20
  describe "initialize" do
21
21
  it "checks for a given filename" do
22
- expect { LauncherConfig.new('blah_file.txt') }.to raise_error
22
+ expect { LauncherConfig.new('blah_file.txt') }.to raise_error(/file does not exist/)
23
23
  end
24
24
 
25
25
  it "raises on unknown parameters" do
@@ -0,0 +1,226 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'spec_helper'
12
+ require 'cosmos'
13
+ require 'cosmos/tools/table_manager/table_config'
14
+ require 'tempfile'
15
+
16
+ module Cosmos
17
+
18
+ describe TableConfig do
19
+ let(:tc) { TableConfig.new }
20
+
21
+ describe "tables" do
22
+ it "returns the tables hash" do
23
+ tf = Tempfile.new('unittest')
24
+ tf.puts("TABLE table1 BIG_ENDIAN ONE_DIMENSIONAL")
25
+ tf.puts("TABLE table2 BIG_ENDIAN TWO_DIMENSIONAL 2")
26
+ tf.puts("TABLE table3 BIG_ENDIAN ONE_DIMENSIONAL")
27
+ tf.close
28
+ tc.process_file(tf.path)
29
+ expect(tc.tables.keys).to eql %w(TABLE1 TABLE2 TABLE3)
30
+ expect(tc.tables.values[0]).to be_a Table
31
+ tf.unlink
32
+ end
33
+ end
34
+
35
+ describe "table_names" do
36
+ it "returns the table names" do
37
+ tf = Tempfile.new('unittest')
38
+ tf.puts("TABLE table1 BIG_ENDIAN ONE_DIMENSIONAL")
39
+ tf.puts("TABLE table2 BIG_ENDIAN TWO_DIMENSIONAL 2")
40
+ tf.puts("TABLE table3 BIG_ENDIAN ONE_DIMENSIONAL")
41
+ tf.close
42
+ tc.process_file(tf.path)
43
+ expect(tc.table_names).to eql %w(TABLE1 TABLE2 TABLE3)
44
+ tf.unlink
45
+ end
46
+ end
47
+
48
+ describe "table" do
49
+ it "returns a table" do
50
+ tf = Tempfile.new('unittest')
51
+ tf.puts("TABLE table1 BIG_ENDIAN ONE_DIMENSIONAL")
52
+ tf.puts("TABLE table2 BIG_ENDIAN TWO_DIMENSIONAL 2")
53
+ tf.puts("TABLE table3 BIG_ENDIAN ONE_DIMENSIONAL")
54
+ tf.close
55
+ tc.process_file(tf.path)
56
+ expect(tc.table("TABLE1").table_name).to eql "TABLE1"
57
+ expect(tc.table("TABLE1").type).to eql :ONE_DIMENSIONAL
58
+ expect(tc.table("TABLE2").table_name).to eql "TABLE2"
59
+ expect(tc.table("TABLE2").type).to eql :TWO_DIMENSIONAL
60
+ expect(tc.table("TABLE3").table_name).to eql "TABLE3"
61
+ expect(tc.table("TABLE3").type).to eql :ONE_DIMENSIONAL
62
+ tf.unlink
63
+ end
64
+ end
65
+
66
+ describe "process_file" do
67
+ it "complains about unknown keywords" do
68
+ tf = Tempfile.new('unittest')
69
+ tf.puts("BLAH")
70
+ tf.close
71
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Unknown keyword 'BLAH'/)
72
+ tf.unlink
73
+ end
74
+
75
+ it "handles errors in processing elements" do
76
+ tf = Tempfile.new('unittest')
77
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
78
+ tf.puts ' APPEND_PARAMETER item1'
79
+ tf.close
80
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters/)
81
+ tf.unlink
82
+ end
83
+
84
+ context "with TABLEFILE" do
85
+ it "complains if not enough parameters" do
86
+ tf = Tempfile.new('unittest')
87
+ tf.puts 'TABLEFILE'
88
+ tf.close
89
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters/)
90
+ tf.unlink
91
+ end
92
+
93
+ it "complains if too many parameters" do
94
+ tf = Tempfile.new('unittest')
95
+ tf.puts 'TABLEFILE table_file table_file'
96
+ tf.close
97
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters/)
98
+ tf.unlink
99
+ end
100
+
101
+ it "complains if the table file does not exist" do
102
+ tf = Tempfile.new('unittest')
103
+ tf.puts 'TABLEFILE table_file'
104
+ tf.close
105
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /not found/)
106
+ tf.unlink
107
+ end
108
+
109
+ it "parses the table definition file" do
110
+ tf = Tempfile.new('test_table')
111
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
112
+ tf.puts ' APPEND_PARAMETER item1 16 UINT 0 0 0 "Item"'
113
+ tf.close
114
+ tf1 = Tempfile.new('unittest')
115
+ tf1.puts "TABLEFILE #{File.basename(tf.path)}"
116
+ tf1.close
117
+ tc.process_file(tf1.path)
118
+ tbl = tc.table("TABLE")
119
+ expect(tbl.get_item("ITEM1").description).to eql "Item"
120
+ tf1.unlink
121
+ tf.unlink
122
+ end
123
+ end
124
+
125
+ context "with SELECT_TABLE" do
126
+ it "complains if the table is not found" do
127
+ tf = Tempfile.new('unittest')
128
+ tf.puts 'SELECT_TABLE table'
129
+ tf.puts 'SELECT_ITEM ITEM1'
130
+ tf.puts ' DESCRIPTION "New description"'
131
+ tf.close
132
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Table TABLE not found/)
133
+ tf.unlink
134
+ end
135
+
136
+ it "selects a table for modification" do
137
+ tf = Tempfile.new('unittest')
138
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
139
+ tf.puts ' APPEND_PARAMETER item1 16 UINT 0 0 0 "Item"'
140
+ tf.close
141
+ tc.process_file(tf.path)
142
+ tbl = tc.table("TABLE")
143
+ expect(tbl.get_item("ITEM1").description).to eql "Item"
144
+ tf.unlink
145
+
146
+ tf = Tempfile.new('unittest')
147
+ tf.puts 'SELECT_TABLE table'
148
+ tf.puts 'SELECT_PARAMETER ITEM1'
149
+ tf.puts ' DESCRIPTION "New description"'
150
+ tf.close
151
+ tc.process_file(tf.path)
152
+ tbl = tc.table("TABLE")
153
+ expect(tbl.get_item("ITEM1").description).to eql "New description"
154
+ tf.unlink
155
+ end
156
+ end
157
+
158
+ context "with SELECT_PARAMETER" do
159
+ it "complains if the parameter is not found" do
160
+ tf = Tempfile.new('unittest')
161
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
162
+ tf.puts ' APPEND_PARAMETER PARAM 16 UINT 0 0 0 "Param"'
163
+ tf.close
164
+ tc.process_file(tf.path)
165
+ tbl = tc.table("TABLE")
166
+ expect(tbl.get_item("PARAM").description).to eql "Param"
167
+ expect(tbl.get_item("PARAM").editable).to eql true
168
+ tf.unlink
169
+
170
+ tf = Tempfile.new('unittest')
171
+ tf.puts 'SELECT_TABLE table'
172
+ tf.puts ' SELECT_PARAMETER PARAMX'
173
+ tf.puts ' DESCRIPTION "New description"'
174
+ tf.close
175
+ expect { tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /PARAMX not found in table TABLE/)
176
+ tf.unlink
177
+ end
178
+ end
179
+
180
+ context "with TWO_DIMESIONAL tables" do
181
+ it "duplicates parameters to create rows" do
182
+ tf = Tempfile.new('unittest')
183
+ tf.puts 'TABLE table LITTLE_ENDIAN TWO_DIMENSIONAL 2 "Table"'
184
+ tf.puts ' APPEND_PARAMETER item1 16 UINT 0 0 0 "Item"'
185
+ tf.puts ' APPEND_PARAMETER item2 16 UINT 0 0 0 "Item"'
186
+ tf.close
187
+ tc.process_file(tf.path)
188
+ tbl = tc.table("TABLE")
189
+ names = []
190
+ tbl.sorted_items.each {|item| names << item.name }
191
+ expect(names).to eql %w(ITEM10 ITEM20 ITEM11 ITEM21)
192
+ tf.unlink
193
+ end
194
+ end
195
+
196
+ context "with UNEDITABLE" do
197
+ it "sets editable to false" do
198
+ tf = Tempfile.new('unittest')
199
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
200
+ tf.puts ' PARAMETER item1 0 16 UINT 0 0 0 "Item"'
201
+ tf.puts ' UNEDITABLE'
202
+ tf.close
203
+ tc.process_file(tf.path)
204
+ tbl = tc.table("TABLE")
205
+ expect(tbl.get_item("ITEM1").editable).to eql false
206
+ tf.unlink
207
+ end
208
+ end
209
+
210
+ context "with HIDDEN" do
211
+ it "sets hidden to true" do
212
+ tf = Tempfile.new('unittest')
213
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
214
+ tf.puts ' PARAMETER item1 0 16 UINT 0 0 0 "Item"'
215
+ tf.puts ' HIDDEN'
216
+ tf.close
217
+ tc.process_file(tf.path)
218
+ tbl = tc.table("TABLE")
219
+ expect(tbl.get_item("ITEM1").hidden).to eql true
220
+ tf.unlink
221
+ end
222
+ end
223
+
224
+ end # describe "process_file"
225
+ end
226
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'spec_helper'
12
+ require 'cosmos'
13
+ require 'cosmos/tools/table_manager/table_item'
14
+
15
+ module Cosmos
16
+
17
+ describe TableItem do
18
+ before(:each) do
19
+ @ti = TableItem.new("test", 0, 32, :UINT, :BIG_ENDIAN, nil)
20
+ end
21
+
22
+ describe "editable=" do
23
+ it "sets the editable flag" do
24
+ @ti.editable = true
25
+ expect(@ti.editable).to eql true
26
+ @ti.editable = false
27
+ expect(@ti.editable).to eql false
28
+ end
29
+
30
+ it "complains about non boolean values" do
31
+ expect { @ti.editable = 5 }.to raise_error(ArgumentError, "#{@ti.name}: editable must be a boolean but is a Fixnum")
32
+ end
33
+ end
34
+
35
+ describe "clone" do
36
+ it "duplicates the entire TableItem" do
37
+ pi2 = @ti.clone
38
+ expect(@ti == pi2).to be true
39
+ end
40
+ end
41
+
42
+ describe "to_hash" do
43
+ it "converts to a Hash" do
44
+ hash = @ti.to_hash
45
+ # Check the values from StructureItem
46
+ expect(hash.keys).to include('editable')
47
+ expect(hash["editable"]).to eql true
48
+
49
+ @ti.editable = false
50
+
51
+ hash = @ti.to_hash
52
+ expect(hash["editable"]).to eql false
53
+ end
54
+ end
55
+ end
56
+ end
57
+
@@ -0,0 +1,96 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'spec_helper'
12
+ require 'cosmos'
13
+ require 'cosmos/tools/table_manager/table_config'
14
+ require 'cosmos/tools/table_manager/table_parser'
15
+ require 'tempfile'
16
+
17
+ module Cosmos
18
+
19
+ describe TableParser do
20
+
21
+ describe "process_file" do
22
+ before(:each) do
23
+ @tc = TableConfig.new
24
+ end
25
+
26
+ it "complains if there are not enough parameters" do
27
+ tf = Tempfile.new('unittest')
28
+ tf.puts("TABLE table")
29
+ tf.close
30
+ expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for TABLE/)
31
+ tf.unlink
32
+
33
+ tf = Tempfile.new('unittest')
34
+ tf.puts("TABLE table BIG_ENDIAN TWO_DIMENSIONAL")
35
+ tf.close
36
+ expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Not enough parameters for TABLE/)
37
+ tf.unlink
38
+ end
39
+
40
+ it "complains if there are too many parameters" do
41
+ tf = Tempfile.new('unittest')
42
+ tf.puts "TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL 'Table' extra"
43
+ tf.close
44
+ expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for TABLE/)
45
+ tf.unlink
46
+
47
+ tf = Tempfile.new('unittest')
48
+ tf.puts "TABLE table LITTLE_ENDIAN TWO_DIMENSIONAL 2 'Table' extra"
49
+ tf.close
50
+ expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Too many parameters for TABLE/)
51
+ tf.unlink
52
+ end
53
+
54
+ it "complains about invalid type" do
55
+ tf = Tempfile.new('unittest')
56
+ tf.puts 'TABLE table LITTLE_ENDIAN FOUR_DIMENSIONAL "Table"'
57
+ tf.close
58
+ expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Invalid display type FOUR_DIMENSIONAL/)
59
+ tf.unlink
60
+ end
61
+
62
+ it "complains about invalid endianness" do
63
+ tf = Tempfile.new('unittest')
64
+ tf.puts 'TABLE table MIDDLE_ENDIAN ONE_DIMENSIONAL "Table"'
65
+ tf.close
66
+ expect { @tc.process_file(tf.path) }.to raise_error(ConfigParser::Error, /Invalid endianness MIDDLE_ENDIAN/)
67
+ tf.unlink
68
+ end
69
+
70
+ it "processes table, endianness, type, description" do
71
+ tf = Tempfile.new('unittest')
72
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Table"'
73
+ tf.close
74
+ @tc.process_file(tf.path)
75
+ tbl = @tc.table("TABLE")
76
+ expect(tbl.table_name).to eql "TABLE"
77
+ expect(tbl.default_endianness).to eql :LITTLE_ENDIAN
78
+ expect(tbl.type).to eql :ONE_DIMENSIONAL
79
+ expect(tbl.description).to eql "Table"
80
+ tf.unlink
81
+ end
82
+
83
+ it "complains if a table is redefined" do
84
+ tf = Tempfile.new('unittest')
85
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Packet 1"'
86
+ tf.puts 'TABLE table LITTLE_ENDIAN ONE_DIMENSIONAL "Packet 2"'
87
+ tf.close
88
+ @tc.process_file(tf.path)
89
+ expect(@tc.warnings).to include("Table TABLE redefined.")
90
+ tf.unlink
91
+ end
92
+
93
+ end # describe "process_file"
94
+ end
95
+ end
96
+
@@ -0,0 +1,90 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2014 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+
11
+ require 'spec_helper'
12
+ require 'cosmos'
13
+ require 'cosmos/tools/table_manager/table'
14
+
15
+ module Cosmos
16
+
17
+ describe Table do
18
+
19
+ describe "table_name" do
20
+ it "returns the table name upcased" do
21
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", "filename")
22
+ expect(t.table_name).to eql "TABLE"
23
+ end
24
+ end
25
+
26
+ describe "type" do
27
+ it "must be :ONE_DIMENSIONAL or :TWO_DIMENSIONAL" do
28
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", "filename")
29
+ expect(t.type).to eql :ONE_DIMENSIONAL
30
+ t = Table.new("table", :BIG_ENDIAN, :TWO_DIMENSIONAL, "description", "filename")
31
+ expect(t.type).to eql :TWO_DIMENSIONAL
32
+ expect { Table.new("table", :BIG_ENDIAN, :BIG, "description", "filename") }.to raise_error(ArgumentError, /Invalid type 'BIG' for table 'table'/)
33
+ end
34
+ end
35
+
36
+ describe "filename" do
37
+ it "stores the filename" do
38
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", File.join(Dir.pwd, "filename"))
39
+ expect(t.filename).to eql File.join(Dir.pwd, "filename")
40
+ end
41
+ end
42
+
43
+ describe "num_rows=" do
44
+ it "raises an error for ONE_DIMENTIONAL" do
45
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", "filename")
46
+ expect { t.num_rows = 2 }.to raise_error(/Rows are fixed/)
47
+ end
48
+
49
+ it "sets num_rows for TWO_DIMENTIONAL" do
50
+ t = Table.new("table", :BIG_ENDIAN, :TWO_DIMENSIONAL, "description", "filename")
51
+ t.num_rows = 2
52
+ expect(t.num_rows).to eql 2
53
+ end
54
+ end
55
+
56
+ describe "num_rows" do
57
+ it "initializes to 0" do
58
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", "filename")
59
+ expect(t.num_rows).to eql 0
60
+ end
61
+
62
+ it "equals the number of visible items in ONE_DIMENSIONAL" do
63
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", "filename")
64
+ ti1 = TableItem.new("test1", 0, 32, :UINT, :BIG_ENDIAN, nil)
65
+ ti2 = TableItem.new("test2", 0, 32, :UINT, :BIG_ENDIAN, nil)
66
+ ti2.hidden = true
67
+ ti3 = TableItem.new("test3", 0, 32, :UINT, :BIG_ENDIAN, nil)
68
+ t.append(ti1)
69
+ expect(t.num_rows).to eql 1
70
+ t.append(ti2)
71
+ expect(t.num_rows).to eql 1
72
+ t.append(ti3)
73
+ expect(t.num_rows).to eql 2
74
+ end
75
+ end
76
+
77
+ describe "num_columns" do
78
+ it "initializes to 1 for ONE_DIMENSIONAL" do
79
+ t = Table.new("table", :BIG_ENDIAN, :ONE_DIMENSIONAL, "description", "filename")
80
+ expect(t.num_columns).to eql 1
81
+ end
82
+ it "initializes to 0 for TWO_DIMENSIONAL" do
83
+ t = Table.new("table", :BIG_ENDIAN, :TWO_DIMENSIONAL, "description", "filename")
84
+ expect(t.num_columns).to eql 0
85
+ end
86
+ end
87
+
88
+ end # describe Table
89
+ end
90
+