cosmos 3.8.3 → 3.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Manifest.txt +14 -0
- data/Rakefile +35 -2
- data/autohotkey/config/targets/INST/screens/_footer.txt +4 -0
- data/autohotkey/config/targets/INST/screens/hs.txt +1 -4
- data/autohotkey/config/tools/table_manager/OldOneDimensionalTable_def.txt +19 -0
- data/autohotkey/config/tools/table_manager/OldTwoDimensionalTable_def.txt +248 -0
- data/autohotkey/config/tools/table_manager/OneDimensionalTable_def.txt +27 -15
- data/autohotkey/config/tools/table_manager/TwoDimensionalTable_def.txt +12 -232
- data/autohotkey/procedures/example_test.rb +4 -0
- data/autohotkey/tools/TableManagerAHK +4 -9
- data/autohotkey/tools/TableManagerAHK2 +18 -0
- data/autohotkey/tools/TableManagerAHK3 +18 -0
- data/autohotkey/tools/TableManagerAHK4 +24 -0
- data/autohotkey/tools/TlmViewerAHK +1 -1
- data/autohotkey/tools/autohotkey.rb +2 -1
- data/autohotkey/tools/open_gl_builder.ahk +1 -1
- data/autohotkey/tools/table_manager.ahk +141 -70
- data/cosmos.gemspec +3 -3
- data/data/crc.txt +70 -68
- data/data/legal.txt +4 -5
- data/demo/config/data/crc.txt +10 -9
- data/demo/config/targets/INST/screens/_footer.txt +4 -0
- data/demo/config/targets/INST/screens/hs.txt +1 -6
- data/demo/config/targets/INST/screens/limits.txt +3 -11
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +1 -0
- data/demo/config/tools/table_manager/MCConfigurationTable_fsw1_def.txt +33 -22
- data/demo/config/tools/table_manager/MCConfigurationTable_fsw2_def.txt +30 -22
- data/demo/config/tools/table_manager/PPSSelectionTable_def.txt +8 -7
- data/demo/config/tools/table_manager/TLMMonitoringTable_def.txt +13 -13
- data/demo/lib/example_background_task.rb +6 -12
- data/demo/procedures/example_test.rb +5 -0
- data/lib/cosmos/conversions/conversion.rb +3 -7
- data/lib/cosmos/core_ext/class.rb +3 -1
- data/lib/cosmos/core_ext/file.rb +1 -0
- data/lib/cosmos/core_ext/io.rb +18 -0
- data/lib/cosmos/core_ext/range.rb +1 -5
- data/lib/cosmos/core_ext/time.rb +3 -3
- data/lib/cosmos/gui/dialogs/about_dialog.rb +60 -36
- data/lib/cosmos/gui/dialogs/calendar_dialog.rb +10 -14
- data/lib/cosmos/gui/dialogs/cmd_details_dialog.rb +4 -5
- data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +31 -17
- data/lib/cosmos/gui/dialogs/details_dialog.rb +63 -47
- data/lib/cosmos/gui/dialogs/exception_dialog.rb +77 -68
- data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +6 -5
- data/lib/cosmos/gui/dialogs/legal_dialog.rb +34 -21
- data/lib/cosmos/gui/dialogs/packet_log_dialog.rb +19 -43
- data/lib/cosmos/gui/dialogs/progress_dialog.rb +79 -42
- data/lib/cosmos/gui/dialogs/pry_dialog.rb +9 -5
- data/lib/cosmos/gui/dialogs/scroll_text_dialog.rb +6 -4
- data/lib/cosmos/gui/dialogs/select_dialog.rb +23 -18
- data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +34 -10
- data/lib/cosmos/gui/dialogs/splash.rb +18 -8
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +38 -43
- data/lib/cosmos/gui/dialogs/tlm_edit_dialog.rb +51 -53
- data/lib/cosmos/gui/line_graph/line_graph_scaling.rb +1 -1
- data/lib/cosmos/gui/line_graph/lines.rb +1 -1
- data/lib/cosmos/gui/qt.rb +9 -2
- data/lib/cosmos/gui/qt_tool.rb +50 -8
- data/lib/cosmos/gui/widgets/packet_log_frame.rb +53 -27
- data/lib/cosmos/interfaces/linc_interface.rb +103 -62
- data/lib/cosmos/io/json_drb_object.rb +3 -3
- data/lib/cosmos/io/raw_logger.rb +4 -8
- data/lib/cosmos/io/tcpip_server.rb +2 -2
- data/lib/cosmos/packets/binary_accessor.rb +1 -1
- data/lib/cosmos/packets/limits.rb +2 -5
- data/lib/cosmos/packets/packet.rb +1 -1
- data/lib/cosmos/packets/packet_config.rb +54 -19
- data/lib/cosmos/packets/parsers/packet_item_parser.rb +7 -1
- data/lib/cosmos/script/scripting.rb +4 -5
- data/lib/cosmos/system/system.rb +2 -1
- data/lib/cosmos/system/target.rb +4 -0
- data/lib/cosmos/tools/cmd_tlm_server/background_task.rb +13 -5
- data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +37 -27
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +6 -2
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +7 -5
- data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +21 -10
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +11 -11
- data/lib/cosmos/tools/script_runner/script_runner.rb +2 -18
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +6 -6
- data/lib/cosmos/tools/table_manager/table.rb +32 -41
- data/lib/cosmos/tools/table_manager/table_config.rb +140 -729
- data/lib/cosmos/tools/table_manager/table_item.rb +20 -36
- data/lib/cosmos/tools/table_manager/table_item_parser.rb +46 -0
- data/lib/cosmos/tools/table_manager/table_manager.rb +754 -691
- data/lib/cosmos/tools/table_manager/table_manager_core.rb +172 -358
- data/lib/cosmos/tools/table_manager/table_parser.rb +75 -0
- data/lib/cosmos/tools/test_runner/results_writer.rb +1 -1
- data/lib/cosmos/tools/test_runner/test_runner.rb +11 -0
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/housekeeping_data_object_adder.rb +2 -2
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/singlexy_data_object_adder.rb +2 -2
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +2 -2
- data/lib/cosmos/tools/tlm_grapher/data_objects/data_object.rb +4 -4
- data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +13 -13
- data/lib/cosmos/tools/tlm_grapher/data_objects/linegraph_data_object.rb +9 -9
- data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +9 -9
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_config.rb +4 -4
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +8 -18
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer_config.rb +7 -4
- data/lib/cosmos/top_level.rb +12 -0
- data/lib/cosmos/version.rb +5 -5
- data/run_gui_tests.bat +6 -0
- data/spec/core_ext/array_spec.rb +1 -1
- data/spec/interfaces/linc_interface_spec.rb +4 -4
- data/spec/io/json_drb_spec.rb +2 -2
- data/spec/io/json_rpc_spec.rb +1 -1
- data/spec/io/raw_logger_spec.rb +5 -1
- data/spec/packet_logs/packet_log_writer_spec.rb +1 -1
- data/spec/packets/packet_config_spec.rb +144 -0
- data/spec/packets/parsers/packet_item_parser_spec.rb +60 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/system/target_spec.rb +5 -1
- data/spec/tools/cmd_tlm_server/background_task_spec.rb +15 -3
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +117 -31
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_spec.rb +4 -0
- data/spec/tools/launcher/launcher_config_spec.rb +1 -1
- data/spec/tools/table_manager/table_config_spec.rb +226 -0
- data/spec/tools/table_manager/table_item_spec.rb +57 -0
- data/spec/tools/table_manager/table_parser_spec.rb +96 -0
- data/spec/tools/table_manager/table_spec.rb +90 -0
- data/spec/tools/table_manager/tablemanager_core_spec.rb +557 -0
- data/spec/top_level/top_level_spec.rb +9 -0
- data/spec/utilities/csv_spec.rb +3 -3
- metadata +30 -11
data/lib/cosmos/io/raw_logger.rb
CHANGED
@@ -27,7 +27,7 @@ module Cosmos
|
|
27
27
|
# @return [Boolean] Is logging enabled?
|
28
28
|
attr_reader :logging_enabled
|
29
29
|
|
30
|
-
# @
|
30
|
+
# @return [String] Original name passed to raw logger
|
31
31
|
attr_reader :orig_name
|
32
32
|
|
33
33
|
# The allowable log types
|
@@ -41,12 +41,8 @@ module Cosmos
|
|
41
41
|
# name of the corresponding interface
|
42
42
|
# @param log_type [Symbol] The type of log to create. Must be :READ
|
43
43
|
# or :WRITE.
|
44
|
-
# @param
|
45
|
-
#
|
46
|
-
# independently.
|
47
|
-
# @param cycle_size [Integer] The size in bytes before creating a new log
|
48
|
-
# file. This can be combined with cycle_time but is better used
|
49
|
-
# independently.
|
44
|
+
# @param logging_enabled [Boolean] Whether to enable raw logging
|
45
|
+
# @param cycle_size [Integer] The size in bytes before creating a new log file.
|
50
46
|
# @param log_directory [String] The directory to store the log files.
|
51
47
|
# Passing nil will use the system default 'LOGS' directory.
|
52
48
|
def initialize(
|
@@ -75,7 +71,7 @@ module Cosmos
|
|
75
71
|
end
|
76
72
|
|
77
73
|
# Set the raw logger name
|
78
|
-
# @param
|
74
|
+
# @param log_name [String] new name
|
79
75
|
def name=(log_name)
|
80
76
|
@orig_name = log_name
|
81
77
|
@log_name = (log_name.to_s.downcase + '_raw_' + @log_type.to_s.downcase + '_' + self.object_id.to_s).freeze
|
@@ -500,7 +500,7 @@ module Cosmos
|
|
500
500
|
indexes_to_delete.each do |index_to_delete|
|
501
501
|
@write_stream_protocols.delete_at(index_to_delete)
|
502
502
|
end
|
503
|
-
end #
|
503
|
+
end # connection_mutex.synchronize
|
504
504
|
|
505
505
|
# Sleep until we receive a packet or for 100ms
|
506
506
|
@write_mutex.synchronize do
|
@@ -544,7 +544,7 @@ module Cosmos
|
|
544
544
|
indexes_to_delete.each do |index_to_delete|
|
545
545
|
@write_stream_protocols.delete_at(index_to_delete)
|
546
546
|
end
|
547
|
-
end #
|
547
|
+
end # connection_mutex.synchronize
|
548
548
|
end
|
549
549
|
end
|
550
550
|
|
@@ -542,7 +542,7 @@ module Cosmos
|
|
542
542
|
# Adjusts the packed array to be the given number of bytes
|
543
543
|
#
|
544
544
|
# @param num_bytes [Integer] The desired number of bytes
|
545
|
-
# @param
|
545
|
+
# @param packed [Array] The packed data buffer
|
546
546
|
def self.adjust_packed_size(num_bytes, packed)
|
547
547
|
difference = num_bytes - packed.length
|
548
548
|
if difference > 0
|
@@ -56,7 +56,7 @@ module Cosmos
|
|
56
56
|
return items
|
57
57
|
end
|
58
58
|
|
59
|
-
# @ignored_items [Array
|
59
|
+
# @param ignored_items [Array<Array<String, String, String>>] Items to ignore from the consideration
|
60
60
|
# @return [Symbol] The overall limits state for the system
|
61
61
|
def overall_limits_state(ignored_items = nil)
|
62
62
|
overall = :GREEN
|
@@ -260,8 +260,5 @@ module Cosmos
|
|
260
260
|
end
|
261
261
|
return false
|
262
262
|
end
|
263
|
-
|
264
|
-
end # class Limits
|
265
|
-
|
263
|
+
end
|
266
264
|
end
|
267
|
-
|
@@ -556,7 +556,7 @@ module Cosmos
|
|
556
556
|
# Restore all items in the packet to their default value
|
557
557
|
#
|
558
558
|
# @param buffer [String] Raw buffer of binary data
|
559
|
-
# @param
|
559
|
+
# @param skip_item_names [Array] Array of item names to skip
|
560
560
|
def restore_defaults(buffer = @buffer, skip_item_names = nil)
|
561
561
|
upcase_skip_item_names = skip_item_names.map(&:upcase) if skip_item_names
|
562
562
|
@sorted_items.each do |item|
|
@@ -91,7 +91,7 @@ module Cosmos
|
|
91
91
|
# knowledge of the commands, telemetry, and limits groups.
|
92
92
|
#
|
93
93
|
# @param filename [String] The name of the configuration file
|
94
|
-
# @param
|
94
|
+
# @param process_target_name [String] The target name
|
95
95
|
def process_file(filename, process_target_name)
|
96
96
|
# Handle .xtce files
|
97
97
|
if File.extname(filename).to_s.downcase == ".xtce"
|
@@ -220,8 +220,12 @@ module Cosmos
|
|
220
220
|
finish_packet()
|
221
221
|
|
222
222
|
# Remove abstract
|
223
|
-
@commands[@current_target_name]
|
224
|
-
|
223
|
+
if @commands[@current_target_name]
|
224
|
+
@commands[@current_target_name].delete_if {|packet_name, packet| packet.abstract}
|
225
|
+
end
|
226
|
+
if @telemetry[@current_target_name]
|
227
|
+
@telemetry[@current_target_name].delete_if {|packet_name, packet| packet.abstract}
|
228
|
+
end
|
225
229
|
|
226
230
|
# Reverse order of packets for the target so ids work correctly
|
227
231
|
reverse_packet_order(@current_target_name, @commands)
|
@@ -554,17 +558,19 @@ module Cosmos
|
|
554
558
|
end
|
555
559
|
|
556
560
|
def reverse_packet_order(target_name, cmd_or_tlm_hash)
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
cmd_or_tlm_hash[target_name].
|
565
|
-
|
566
|
-
|
567
|
-
|
561
|
+
if cmd_or_tlm_hash[target_name]
|
562
|
+
packets = []
|
563
|
+
names_to_remove = []
|
564
|
+
cmd_or_tlm_hash[target_name].each do |packet_name, packet|
|
565
|
+
packets << packet
|
566
|
+
names_to_remove << packet_name
|
567
|
+
end
|
568
|
+
cmd_or_tlm_hash[target_name].length.times do |i|
|
569
|
+
cmd_or_tlm_hash[target_name].delete(names_to_remove[i])
|
570
|
+
end
|
571
|
+
packets.reverse.each do |packet|
|
572
|
+
cmd_or_tlm_hash[target_name][packet.packet_name] = packet
|
573
|
+
end
|
568
574
|
end
|
569
575
|
end
|
570
576
|
|
@@ -636,16 +642,45 @@ module Cosmos
|
|
636
642
|
end
|
637
643
|
|
638
644
|
when 'ByteOrderList'
|
645
|
+
byte_list = []
|
639
646
|
xtce_recurse_element(element, depth + 1) do |element, depth|
|
640
647
|
if element.name == 'Byte'
|
641
|
-
if element['byteSignificance']
|
642
|
-
|
648
|
+
if element['byteSignificance']
|
649
|
+
byte_list << element['byteSignificance'].to_i
|
643
650
|
end
|
644
|
-
false
|
645
|
-
else
|
646
|
-
true
|
647
651
|
end
|
652
|
+
true
|
648
653
|
end
|
654
|
+
if byte_list[0] == 0
|
655
|
+
# Little endian will always start with 0 - Its ok if a single byte item is marked little endian
|
656
|
+
@current_type.endianness = :LITTLE_ENDIAN
|
657
|
+
end
|
658
|
+
|
659
|
+
# Verify ordering of byte list is supported
|
660
|
+
if byte_list[0] >= byte_list[-1]
|
661
|
+
ordered_byte_list = byte_list.reverse
|
662
|
+
else
|
663
|
+
ordered_byte_list = byte_list.clone
|
664
|
+
end
|
665
|
+
if ordered_byte_list[0] != 0
|
666
|
+
msg = "Invalid ByteOrderList detected: #{byte_list.join(", ")}"
|
667
|
+
Logger.instance.warn msg
|
668
|
+
@warnings << msg
|
669
|
+
else
|
670
|
+
previous_byte = nil
|
671
|
+
ordered_byte_list.each do |byte|
|
672
|
+
if previous_byte
|
673
|
+
if byte - previous_byte != 1
|
674
|
+
msg = "Invalid ByteOrderList detected: #{byte_list.join(", ")}"
|
675
|
+
Logger.instance.warn msg
|
676
|
+
@warnings << msg
|
677
|
+
break
|
678
|
+
end
|
679
|
+
end
|
680
|
+
previous_byte = byte
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
649
684
|
return false # Already recursed
|
650
685
|
|
651
686
|
when "SizeInBits"
|
@@ -195,8 +195,14 @@ module Cosmos
|
|
195
195
|
if keyword.include?("ARRAY")
|
196
196
|
usage << "INT/UINT/FLOAT/STRING/BLOCK> "
|
197
197
|
else
|
198
|
+
begin
|
199
|
+
data_type = get_data_type()
|
200
|
+
rescue
|
201
|
+
# If the data type could not be determined set something
|
202
|
+
data_type == :INT
|
203
|
+
end
|
198
204
|
# STRING and BLOCK types do not have min or max values
|
199
|
-
if
|
205
|
+
if data_type == :STRING || data_type == :BLOCK
|
200
206
|
usage << "STRING/BLOCK> "
|
201
207
|
else
|
202
208
|
usage << "INT/UINT/FLOAT> <MIN VALUE> <MAX VALUE> "
|
@@ -23,11 +23,10 @@ module Cosmos
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def status_bar(message)
|
26
|
-
if defined? ScriptRunner
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
26
|
+
script_runner = ObjectSpace.find(ScriptRunner) if defined? ScriptRunner
|
27
|
+
script_runner.script_set_status(message) if script_runner
|
28
|
+
test_runner = ObjectSpace.find(TestRunner) if defined? TestRunner
|
29
|
+
test_runner.script_set_status(message) if test_runner
|
31
30
|
end
|
32
31
|
|
33
32
|
def ask_string(question, blank_or_default = false, password = false)
|
data/lib/cosmos/system/system.rb
CHANGED
@@ -176,7 +176,7 @@ module Cosmos
|
|
176
176
|
|
177
177
|
# Change the system limits set
|
178
178
|
#
|
179
|
-
# @param [Symbol] The name of the limits set. :DEFAULT is always an option
|
179
|
+
# @param limits_set [Symbol] The name of the limits set. :DEFAULT is always an option
|
180
180
|
# but limits sets are user defined
|
181
181
|
def limits_set=(limits_set)
|
182
182
|
load_packets() unless @config
|
@@ -197,6 +197,7 @@ module Cosmos
|
|
197
197
|
self.instance.limits_set = limits_set
|
198
198
|
end
|
199
199
|
|
200
|
+
# @param filename [String] System configuration file to parse
|
200
201
|
# @return [System] The System singleton
|
201
202
|
def self.instance(filename = nil)
|
202
203
|
return @@instance if @@instance
|
data/lib/cosmos/system/target.rb
CHANGED
@@ -192,6 +192,10 @@ module Cosmos
|
|
192
192
|
Dir[File.join(dir, 'cmd_tlm', '**', '*.txt')].each do |filename|
|
193
193
|
cmd_tlm_files << filename
|
194
194
|
end
|
195
|
+
# Grab All *.xtce files in the cmd_tlm folder and subfolders
|
196
|
+
Dir[File.join(dir, 'cmd_tlm', '**', '*.xtce')].each do |filename|
|
197
|
+
cmd_tlm_files << filename
|
198
|
+
end
|
195
199
|
end
|
196
200
|
cmd_tlm_files.sort!
|
197
201
|
end
|
@@ -16,15 +16,25 @@ module Cosmos
|
|
16
16
|
class BackgroundTask
|
17
17
|
include Api
|
18
18
|
|
19
|
+
# @return [Integer] The number of background tasks created
|
20
|
+
@@count = 0
|
21
|
+
|
22
|
+
# @return [String] Name of the background task
|
19
23
|
attr_accessor :name
|
24
|
+
# @return [Thread] Ruby thread running the task
|
20
25
|
attr_accessor :thread
|
26
|
+
# @return [String] Status message to display in the CTS
|
21
27
|
attr_accessor :status
|
28
|
+
# @return [Boolean] Whether the task is initially stopped when the CTS starts
|
29
|
+
attr_accessor :stopped
|
22
30
|
|
23
31
|
# Constructor
|
24
32
|
def initialize
|
25
|
-
|
33
|
+
@@count += 1
|
34
|
+
@name = "Background Task #{@@count}"
|
26
35
|
@thread = nil
|
27
|
-
@status =
|
36
|
+
@status = ''
|
37
|
+
@stopped = false
|
28
38
|
end
|
29
39
|
|
30
40
|
# Subclasses should override the call method which is called once by
|
@@ -40,7 +50,5 @@ module Cosmos
|
|
40
50
|
def stop
|
41
51
|
# Nothing to do by default
|
42
52
|
end
|
43
|
-
|
44
|
-
end # class BackgroundTask
|
45
|
-
|
53
|
+
end
|
46
54
|
end
|
@@ -11,7 +11,6 @@
|
|
11
11
|
require 'cosmos/tools/cmd_tlm_server/cmd_tlm_server_config'
|
12
12
|
|
13
13
|
module Cosmos
|
14
|
-
|
15
14
|
# Manages starting and stopping all the background tasks which
|
16
15
|
# were discovered when parsing the configuration file.
|
17
16
|
class BackgroundTasks
|
@@ -22,37 +21,50 @@ module Cosmos
|
|
22
21
|
@threads = []
|
23
22
|
end
|
24
23
|
|
25
|
-
# Start background tasks by creating a new Ruby thread for each and then
|
26
|
-
# calling their 'call' method once.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
begin
|
32
|
-
background_task.call
|
33
|
-
rescue Exception => err
|
34
|
-
Logger.error "Background Task thread unexpectedly died"
|
35
|
-
Cosmos.handle_fatal_exception(err)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
@threads << new_thread
|
24
|
+
# Start all background tasks by creating a new Ruby thread for each and then
|
25
|
+
# calling their 'call' method once. Tasks which have stopped set to true
|
26
|
+
# are not started and must be started by calling #start.
|
27
|
+
def start_all
|
28
|
+
(0...all.length).each do |index|
|
29
|
+
start(index) unless @config.background_tasks[index].stopped
|
39
30
|
end
|
40
31
|
end
|
41
32
|
|
42
|
-
#
|
43
|
-
#
|
44
|
-
|
45
|
-
|
33
|
+
# Start an individual background task by creating a new Ruby thread and then
|
34
|
+
# calling the 'call' method once.
|
35
|
+
# @param index [Integer] Which background task to start
|
36
|
+
def start(index)
|
37
|
+
@threads[index] = Thread.new do
|
38
|
+
@config.background_tasks[index].thread = Thread.current
|
46
39
|
begin
|
47
|
-
|
48
|
-
rescue
|
49
|
-
|
40
|
+
@config.background_tasks[index].call
|
41
|
+
rescue Exception => err
|
42
|
+
Logger.error "Background Task '#{@config.background_tasks[index].name}' unexpectedly died"
|
43
|
+
Cosmos.handle_fatal_exception(err)
|
50
44
|
end
|
51
45
|
end
|
52
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
# Stop all background tasks by calling their stop method and then killing
|
49
|
+
# their Ruby thread.
|
50
|
+
def stop_all
|
51
|
+
(0...all.length).each { |index| stop(index) }
|
53
52
|
@threads = []
|
54
53
|
end
|
55
54
|
|
55
|
+
# Stop background task by calling their stop method and then killing their
|
56
|
+
# Ruby thread.
|
57
|
+
# @param index [Integer] Which background task to stop
|
58
|
+
def stop(index)
|
59
|
+
begin
|
60
|
+
@config.background_tasks[index].stop
|
61
|
+
rescue
|
62
|
+
# Ignore any errors because we're about to kill the thread anyway
|
63
|
+
end
|
64
|
+
Cosmos.kill_thread(self, @threads[index])
|
65
|
+
@threads[index] = nil
|
66
|
+
end
|
67
|
+
|
56
68
|
# Return the array of background tasks
|
57
69
|
def all
|
58
70
|
@config.background_tasks
|
@@ -61,7 +73,5 @@ module Cosmos
|
|
61
73
|
def graceful_kill
|
62
74
|
# This method is just here to remove warnings - background_task.stop should kill the thread
|
63
75
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end # module Cosmos
|
76
|
+
end
|
77
|
+
end
|
@@ -190,7 +190,7 @@ module Cosmos
|
|
190
190
|
System.telemetry.limits_change_callback = method(:limits_change_callback)
|
191
191
|
@interfaces.start
|
192
192
|
@routers.start
|
193
|
-
@background_tasks.
|
193
|
+
@background_tasks.start_all
|
194
194
|
|
195
195
|
# Start staleness monitor thread
|
196
196
|
@sleeper = Sleeper.new
|
@@ -221,7 +221,7 @@ module Cosmos
|
|
221
221
|
# Shutdown staleness monitor thread
|
222
222
|
Cosmos.kill_thread(self, @staleness_monitor_thread)
|
223
223
|
|
224
|
-
@background_tasks.
|
224
|
+
@background_tasks.stop_all
|
225
225
|
@routers.stop
|
226
226
|
@interfaces.stop
|
227
227
|
@packet_logging.shutdown
|
@@ -431,6 +431,10 @@ module Cosmos
|
|
431
431
|
raise ArgumentError, "packets must be nested array: [['TGT','PKT'],...]"
|
432
432
|
end
|
433
433
|
|
434
|
+
unless queue_size.is_a? Integer and queue_size > 0
|
435
|
+
raise ArgumentError, "Invalid queue size for subscribe_packet_data: #{queue_size}"
|
436
|
+
end
|
437
|
+
|
434
438
|
id = nil
|
435
439
|
upcase_packets = []
|
436
440
|
|
@@ -15,7 +15,6 @@ require 'cosmos/packet_logs'
|
|
15
15
|
require 'cosmos/io/raw_logger_pair'
|
16
16
|
|
17
17
|
module Cosmos
|
18
|
-
|
19
18
|
# Reads an ascii file that defines the configuration settings used to
|
20
19
|
# configure the Command/Telemetry Server.
|
21
20
|
class CmdTlmServerConfig
|
@@ -245,6 +244,11 @@ module Cosmos
|
|
245
244
|
@background_tasks << background_task.new
|
246
245
|
end
|
247
246
|
|
247
|
+
when 'STOPPED'
|
248
|
+
parser.verify_num_parameters(0, 0, "#{keyword}")
|
249
|
+
raise parser.error("No BACKGROUND_TASK defined") if @background_tasks.empty?
|
250
|
+
@background_tasks[-1].stopped = true
|
251
|
+
|
248
252
|
# TODO: Deprecate COLLECT_META_DATA
|
249
253
|
when 'COLLECT_METADATA', 'COLLECT_META_DATA'
|
250
254
|
parser.verify_num_parameters(2, 2, "#{keyword} <Metadata Target Name> <Metadata Packet Name>")
|
@@ -259,7 +263,5 @@ module Cosmos
|
|
259
263
|
end # loop
|
260
264
|
end
|
261
265
|
end
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
end # module Cosmos
|
266
|
+
end
|
267
|
+
end
|