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
@@ -16,10 +16,13 @@ require 'cosmos/gui/qt'
|
|
16
16
|
require 'cosmos/gui/dialogs/exception_dialog'
|
17
17
|
|
18
18
|
module Cosmos
|
19
|
-
|
20
19
|
# Displays a list of exceptions in a dialog box. Clicking on any of the
|
21
20
|
# exceptions creates a new ExceptionDialog which shows the details.
|
22
21
|
class ExceptionListDialog < Qt::Dialog
|
22
|
+
# @param message [String] Text to display in the dialog
|
23
|
+
# @param exception_list [Array<Exception>] Array of exceptions to display
|
24
|
+
# @param title [String] Dialog title
|
25
|
+
# @param parent [Qt::Widget] Parent for this dialog
|
23
26
|
def initialize(message, exception_list, title = 'COSMOS Exception List', parent = Qt::CoreApplication.instance.activeWindow)
|
24
27
|
super(parent)
|
25
28
|
self.window_title = title
|
@@ -53,7 +56,5 @@ module Cosmos
|
|
53
56
|
exec()
|
54
57
|
dispose()
|
55
58
|
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end # module Cosmos
|
59
|
-
|
59
|
+
end
|
60
|
+
end
|
@@ -8,21 +8,18 @@
|
|
8
8
|
# as published by the Free Software Foundation; version 3 with
|
9
9
|
# attribution addendums as found in the LICENSE.txt
|
10
10
|
|
11
|
-
# This file contains the implementation of the LegalDialog class. This class
|
12
|
-
# is used to display a legal dialog box
|
13
|
-
|
14
11
|
require 'cosmos'
|
15
12
|
require 'cosmos/gui/qt'
|
16
13
|
require 'open3'
|
17
14
|
|
18
15
|
module Cosmos
|
19
|
-
|
16
|
+
# Creates a dialog displaying the COSMOS copyright information. Also
|
17
|
+
# calculates CRC checks across the entire project to determine if any of the
|
18
|
+
# COSMOS core files have been modified. This ensures the COSMOS system has
|
19
|
+
# not been modified since the last release.
|
20
20
|
class LegalDialog < Qt::Dialog
|
21
|
-
|
22
21
|
def initialize
|
23
22
|
super() # MUST BE FIRST
|
24
|
-
|
25
|
-
# Set Default Icon
|
26
23
|
Cosmos.load_cosmos_icon
|
27
24
|
|
28
25
|
self.window_title = 'Legal Agreement'
|
@@ -37,20 +34,27 @@ module Cosmos
|
|
37
34
|
label.setFrameStyle(Qt::Frame::Box)
|
38
35
|
layout.addWidget(label)
|
39
36
|
|
37
|
+
version = Qt::Label.new("COSMOS Version: " + COSMOS_VERSION)
|
38
|
+
version.setFont(Cosmos.getFont("Arial", 14))
|
39
|
+
version_layout = Qt::HBoxLayout.new
|
40
|
+
version_layout.addWidget(version, 0, Qt::AlignCenter)
|
41
|
+
layout.addLayout(version_layout)
|
42
|
+
|
40
43
|
legal_text = ''
|
41
44
|
legal_text_filename = File.join(::Cosmos::USERPATH, 'config', 'data', 'legal.txt')
|
42
45
|
legal_text_filename = File.join(::Cosmos::PATH, 'data', 'legal.txt') unless File.exist?(legal_text_filename)
|
43
|
-
|
46
|
+
legal_text << File.read(legal_text_filename)
|
47
|
+
legal_text.strip!
|
44
48
|
legal_text.gsub!("\r", '') unless Kernel.is_windows?
|
45
49
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
layout.addWidget(
|
50
|
+
legal_label = Qt::Label.new(legal_text)
|
51
|
+
legal_label.setWordWrap(true)
|
52
|
+
legal_label.setFrameStyle(Qt::Frame::Box)
|
53
|
+
legal_label.setStyleSheet("QLabel { background-color : white; padding: 5px; }");
|
54
|
+
layout.addWidget(legal_label)
|
51
55
|
|
52
56
|
@text_crc = Qt::TextEdit.new
|
53
|
-
@text_crc.
|
57
|
+
@text_crc.setMinimumHeight(100)
|
54
58
|
@text_crc.setReadOnly(true)
|
55
59
|
@text_crc.setFrameStyle(Qt::Frame::Box)
|
56
60
|
layout.addWidget(@text_crc)
|
@@ -81,16 +85,21 @@ module Cosmos
|
|
81
85
|
hlayout.addWidget(update_crc_button, 0, Qt::AlignCenter) if update_crc_button
|
82
86
|
hlayout.addWidget(cancel_button, 0, Qt::AlignRight)
|
83
87
|
layout.addLayout(hlayout)
|
84
|
-
|
88
|
+
|
85
89
|
self.show()
|
86
90
|
self.raise()
|
87
91
|
result = exec()
|
88
92
|
dispose()
|
89
93
|
exit if result != Qt::Dialog::Accepted
|
90
|
-
end
|
94
|
+
end
|
91
95
|
|
96
|
+
# Opens all the files listed in <Cosmos::PATH>/data/crc.txt and calculates their CRCs
|
97
|
+
# against what is listed in the file to detect any modifications. Also
|
98
|
+
# opens all files listed in <Cosmos::USERPATH/config/data/crc.txt to verify
|
99
|
+
# the user defined COSMOS configuration files.
|
100
|
+
# @return [String] Either a success message or warning about all files
|
101
|
+
# which did not match their expected CRCs.
|
92
102
|
def check_all_crcs
|
93
|
-
# Check each file in crc.txt
|
94
103
|
result_text = ''
|
95
104
|
missing_text = ''
|
96
105
|
core_file_count, core_error_count, _, _ = check_crcs(::Cosmos::PATH, File.join(::Cosmos::PATH,'data','crc.txt'), result_text, missing_text, 'CORE')
|
@@ -128,6 +137,12 @@ module Cosmos
|
|
128
137
|
return project_error_count
|
129
138
|
end
|
130
139
|
|
140
|
+
# @param base_path [String] Path to prepend to all the files in crc.txt
|
141
|
+
# @param filename [String] Full path to the crc.txt file
|
142
|
+
# @param result_text [String] String to append results of CRC checks
|
143
|
+
# @param missing_text [String] String to append missing files
|
144
|
+
# @param file_type [String] Whether the COSMOS core or project files. Must
|
145
|
+
# be 'CORE' or 'PROJECT'.
|
131
146
|
def check_crcs(base_path, filename, result_text, missing_text, file_type)
|
132
147
|
file_count = 0
|
133
148
|
error_count = 0
|
@@ -162,8 +177,6 @@ module Cosmos
|
|
162
177
|
end
|
163
178
|
end
|
164
179
|
return file_count, error_count, missing_count, official
|
165
|
-
end
|
166
|
-
|
180
|
+
end
|
167
181
|
end
|
168
|
-
|
169
|
-
end # module Cosmos
|
182
|
+
end
|
@@ -16,8 +16,24 @@ require 'cosmos/gui/qt'
|
|
16
16
|
require 'cosmos/gui/widgets/packet_log_frame'
|
17
17
|
|
18
18
|
module Cosmos
|
19
|
-
|
19
|
+
# Creates a dialog to allow a user to browse for a COSMOS log and select the
|
20
|
+
# time period to process.
|
20
21
|
class PacketLogDialog < Qt::Dialog
|
22
|
+
extend Forwardable
|
23
|
+
def_delegators :@packet_log_frame, :filenames, :time_start, :time_start=,\
|
24
|
+
:time_end, :time_end=, :packet_log_reader
|
25
|
+
|
26
|
+
# @param parent (see PacketLogFrame#initialize)
|
27
|
+
# @param title [String] Dialog title
|
28
|
+
# @param log_directory (see PacketLogFrame#initialize)
|
29
|
+
# @param packet_log_reader (see PacketLogFrame#initialize)
|
30
|
+
# @param initial_filenames (see PacketLogFrame#initialize)
|
31
|
+
# @param initial_output_filename (see PacketLogFrame#initialize)
|
32
|
+
# @param show_output_filename (see PacketLogFrame#initialize)
|
33
|
+
# @param show_time (see PacketLogFrame#initialize)
|
34
|
+
# @param show_log_reader (see PacketLogFrame#initialize)
|
35
|
+
# @param input_filename_filter (see PacketLogFrame#initialize)
|
36
|
+
# @param output_filename_filter (see PacketLogFrame#initialize)
|
21
37
|
def initialize(parent,
|
22
38
|
title,
|
23
39
|
log_directory,
|
@@ -29,13 +45,10 @@ module Cosmos
|
|
29
45
|
show_log_reader = true,
|
30
46
|
input_filename_filter = Cosmos::BIN_FILE_PATTERN,
|
31
47
|
output_filename_filter = Cosmos::BIN_FILE_PATTERN)
|
32
|
-
# Call base class constructor
|
33
48
|
super(parent)
|
34
49
|
setWindowTitle(title)
|
35
50
|
|
36
51
|
@layout = Qt::VBoxLayout.new
|
37
|
-
|
38
|
-
# Create log frame
|
39
52
|
@packet_log_frame = PacketLogFrame.new(self,
|
40
53
|
log_directory,
|
41
54
|
packet_log_reader,
|
@@ -66,41 +79,6 @@ module Cosmos
|
|
66
79
|
|
67
80
|
@layout.addLayout(@button_layout)
|
68
81
|
setLayout(@layout)
|
69
|
-
end # def initialize
|
70
|
-
|
71
|
-
# Returns the chosen filenames
|
72
|
-
def filenames
|
73
|
-
@packet_log_frame.filenames
|
74
|
-
end
|
75
|
-
|
76
|
-
# Return the output filename
|
77
|
-
def output_filename
|
78
|
-
@packet_log_frame.output_filename
|
79
|
-
end
|
80
|
-
|
81
|
-
# Return Start time of packets to process
|
82
|
-
def time_start
|
83
|
-
@packet_log_frame.time_start
|
84
|
-
end
|
85
|
-
|
86
|
-
# Set the start time
|
87
|
-
def time_start=(new_time_start)
|
88
|
-
@packet_log_frame.time_start = new_time_start
|
89
|
-
end
|
90
|
-
|
91
|
-
# Return End time of packets to process
|
92
|
-
def time_end
|
93
|
-
@packet_log_frame.time_end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Set the end time
|
97
|
-
def time_end=(new_time_end)
|
98
|
-
@packet_log_frame.time_end = new_time_end
|
99
|
-
end
|
100
|
-
|
101
|
-
# Return Log reader to use
|
102
|
-
def packet_log_reader
|
103
|
-
@packet_log_frame.packet_log_reader
|
104
82
|
end
|
105
83
|
|
106
84
|
protected
|
@@ -112,7 +90,5 @@ module Cosmos
|
|
112
90
|
@ok_button.setEnabled(true)
|
113
91
|
end
|
114
92
|
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end # module Cosmos
|
93
|
+
end
|
94
|
+
end
|
@@ -15,41 +15,45 @@ require 'cosmos/gui/qt'
|
|
15
15
|
require 'cosmos/gui/dialogs/exception_dialog'
|
16
16
|
|
17
17
|
module Cosmos
|
18
|
-
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# The QT GUI model is to use slots and signals to connect GUI elements together.
|
22
|
-
# This is especially important with multithreaded applications because only the main thread
|
23
|
-
# can update the GUI and other attempts will cause crashes.
|
24
|
-
#
|
25
|
-
# It seems like we should be able to do something like the following:
|
26
|
-
# progress_dialog = ProgressDialog.new(self, 'Progress')
|
27
|
-
# thread = MyRubyThreadWorker.new
|
28
|
-
# connect(thread, SIGNAL('finished(int)'), progress_dialog, SLOT('done(int)'), Qt::QueuedConnection)
|
29
|
-
# thread.start
|
30
|
-
# progress_dialog.exec
|
31
|
-
#
|
32
|
-
# This is creating a thread (but not starting the thread) and then connecting the thread
|
33
|
-
# classes 'finished(int)' signal to the progress_dialog classes 'done(int)' signal.
|
34
|
-
# It then starts the thread and calls exec on the dialog which makes it a modal dialog
|
35
|
-
# that starts its internal QEventLoop going. This allows the GUI to remain updating
|
36
|
-
# (so we can click cancel) while the thread runs. Then when the thread finished it should emit
|
37
|
-
# its 'finished(int)' signal which closes the dialog.
|
38
|
-
#
|
39
|
-
# This all SHOULD work but it tends to randomly crash on Ruby 1.8.6.
|
40
|
-
# HOWEVER, it appears to work well on 1.9.1. We should consider going to this model
|
41
|
-
# in COSMOS 2.0 as it avoids the hacky
|
42
|
-
|
18
|
+
# Dialog which shows a progress bar. Optionally can display two progress
|
19
|
+
# bars: one for overall progress and one for a sub-task. Can also optionally
|
20
|
+
# display informational text.
|
43
21
|
class ProgressDialog < Qt::Dialog
|
22
|
+
# @return [#call] Called when the dialog is canceled. Passed the current
|
23
|
+
# instance of the ProgressDialog
|
44
24
|
attr_accessor :cancel_callback
|
25
|
+
# @return [Thread] Ruby thread associated with this dialog. If specified,
|
26
|
+
# it will automatically be killed if the dialog is canceled.
|
45
27
|
attr_accessor :thread
|
28
|
+
# Accessor to set the complete flag
|
46
29
|
attr_writer :complete
|
47
30
|
|
48
31
|
slots 'append_text(const QString&)'
|
49
32
|
slots 'set_step_progress(int)'
|
50
33
|
slots 'set_overall_progress(int)'
|
51
34
|
|
52
|
-
|
35
|
+
# @param parent [Qt::Widget] Parent of this dialog
|
36
|
+
# @param title [String] Dialog title
|
37
|
+
# @param width [Integer] Dialog width
|
38
|
+
# @param height [Integer] Dialog height
|
39
|
+
# @param show_overall [Boolean] Whether to show the overall progress bar
|
40
|
+
# @param show_step [Boolean] Whether to show the individual step progress
|
41
|
+
# bar
|
42
|
+
# @param show_text [Boolean] Whether to show informational text along with
|
43
|
+
# the progress bar
|
44
|
+
# @param show_done [Boolean] Whether to show a "Done" button which closes
|
45
|
+
# the dialog once the progress is complete
|
46
|
+
# @param show_cancel [Boolean] Whether to show a "Cancel" button which
|
47
|
+
# cancels and closes the dialog
|
48
|
+
def initialize(parent,
|
49
|
+
title,
|
50
|
+
width = 500,
|
51
|
+
height = 300,
|
52
|
+
show_overall = true,
|
53
|
+
show_step = true,
|
54
|
+
show_text = true,
|
55
|
+
show_done = true,
|
56
|
+
show_cancel = true)
|
53
57
|
if show_cancel
|
54
58
|
super(parent)
|
55
59
|
else
|
@@ -129,24 +133,29 @@ module Cosmos
|
|
129
133
|
@step_progress = 0
|
130
134
|
end
|
131
135
|
|
136
|
+
# @return [Boolean] Whether this dialog was canceled
|
132
137
|
def self.canceled?
|
133
138
|
@@canceled
|
134
139
|
end
|
135
140
|
|
141
|
+
# @return [Boolean] Whether this dialog was canceled
|
136
142
|
def canceled?
|
137
143
|
@@canceled
|
138
144
|
end
|
139
145
|
|
146
|
+
# @return [Boolean] Whether this dialog successfully completed
|
140
147
|
def complete?
|
141
|
-
|
148
|
+
@complete
|
142
149
|
end
|
143
150
|
|
151
|
+
# Enable the cancel button if it was specified
|
144
152
|
def enable_cancel_button
|
145
153
|
Qt.execute_in_main_thread(true) do
|
146
154
|
@cancel_button.setEnabled(true) if @cancel_button
|
147
155
|
end
|
148
156
|
end
|
149
157
|
|
158
|
+
# Set complete to true and close the dialog
|
150
159
|
def close_done
|
151
160
|
Qt.execute_in_main_thread(true) do
|
152
161
|
@complete = true
|
@@ -154,6 +163,8 @@ module Cosmos
|
|
154
163
|
end
|
155
164
|
end
|
156
165
|
|
166
|
+
# Call the cancel_callback if given to determine how to proceed. Set
|
167
|
+
# canceled to true and kill any associated threads.
|
157
168
|
def close_cancel
|
158
169
|
Qt.execute_in_main_thread(true) do
|
159
170
|
kill_thread = true
|
@@ -174,25 +185,30 @@ module Cosmos
|
|
174
185
|
end
|
175
186
|
end
|
176
187
|
|
188
|
+
# Empty method to remove warning
|
189
|
+
# @comment TODO: What warning? How does this manifest?
|
177
190
|
def graceful_kill
|
178
|
-
# Do nothing - just to remove warning
|
179
191
|
end
|
180
192
|
|
193
|
+
# @param font [Font] Font to apply on the progress text
|
181
194
|
def set_text_font(font)
|
182
195
|
@progress_text.setFont(font)
|
183
196
|
end
|
184
197
|
|
185
|
-
|
198
|
+
# @param text [String] Text to append to the progress text
|
199
|
+
def append_text(text)
|
186
200
|
unless @complete
|
187
201
|
Qt.execute_in_main_thread(false) do
|
188
202
|
if @progress_text
|
189
|
-
@progress_text.appendPlainText(
|
203
|
+
@progress_text.appendPlainText(text)
|
190
204
|
@progress_text.ensureCursorVisible
|
191
205
|
end
|
192
206
|
end
|
193
207
|
end
|
194
208
|
end
|
195
209
|
|
210
|
+
# Mark the dialog complete by enabling the Done and Cancel button if they
|
211
|
+
# were specified. This method does NOT close the dialog automatically.
|
196
212
|
def complete
|
197
213
|
Qt.execute_in_main_thread(true) do
|
198
214
|
@done_button.setEnabled(true) if @done_button
|
@@ -200,9 +216,12 @@ module Cosmos
|
|
200
216
|
end
|
201
217
|
end
|
202
218
|
|
203
|
-
|
219
|
+
# @comment TODO: Rename to step_progress=
|
220
|
+
# @param value [Float] Fraction from 0 to 1 of the current step that is
|
221
|
+
# complete.
|
222
|
+
def set_step_progress(value)
|
204
223
|
progress_int = (value * 100).to_i
|
205
|
-
if !@complete
|
224
|
+
if !@complete && @step_progress != progress_int
|
206
225
|
@step_progress = progress_int
|
207
226
|
Qt.execute_in_main_thread(false) do
|
208
227
|
@step_bar.setValue(progress_int) if @step_bar
|
@@ -210,9 +229,12 @@ module Cosmos
|
|
210
229
|
end
|
211
230
|
end
|
212
231
|
|
213
|
-
|
232
|
+
# @comment TODO: Rename to overall_progress=
|
233
|
+
# @param value [Float] Fraction from 0 to 1 of the overall progress that is
|
234
|
+
# complete.
|
235
|
+
def set_overall_progress(value)
|
214
236
|
progress_int = (value * 100).to_i
|
215
|
-
if !@complete
|
237
|
+
if !@complete && @overall_progress != progress_int
|
216
238
|
@overall_progress = progress_int
|
217
239
|
Qt.execute_in_main_thread(false) do
|
218
240
|
@overall_bar.setValue(progress_int) if @overall_bar
|
@@ -220,6 +242,9 @@ module Cosmos
|
|
220
242
|
end
|
221
243
|
end
|
222
244
|
|
245
|
+
# @comment TODO: Rename to step_progress
|
246
|
+
# @return [Float] Fraction from 0 to 1 of the step progress that is
|
247
|
+
# complete
|
223
248
|
def get_step_progress
|
224
249
|
result = nil
|
225
250
|
Qt.execute_in_main_thread(true) do
|
@@ -228,6 +253,9 @@ module Cosmos
|
|
228
253
|
return result
|
229
254
|
end
|
230
255
|
|
256
|
+
# @comment TODO: Rename to overall_progress
|
257
|
+
# @return [Float] Fraction from 0 to 1 of the overall progress that is
|
258
|
+
# complete
|
231
259
|
def get_overall_progress
|
232
260
|
result = nil
|
233
261
|
Qt.execute_in_main_thread(true) do
|
@@ -236,7 +264,16 @@ module Cosmos
|
|
236
264
|
return result
|
237
265
|
end
|
238
266
|
|
239
|
-
|
267
|
+
# (see #initialize)
|
268
|
+
def self.execute(parent,
|
269
|
+
title,
|
270
|
+
width = 500,
|
271
|
+
height = 300,
|
272
|
+
show_overall = true,
|
273
|
+
show_step = true,
|
274
|
+
show_text = true,
|
275
|
+
show_done = true,
|
276
|
+
show_cancel = true)
|
240
277
|
# Create a non-modal dialog by default
|
241
278
|
dialog = ProgressDialog.new(parent, title, width, height, show_overall, show_step, show_text, show_done, show_cancel)
|
242
279
|
dialog.setModal(true)
|
@@ -250,8 +287,9 @@ module Cosmos
|
|
250
287
|
yield dialog
|
251
288
|
rescue Exception => error
|
252
289
|
Qt.execute_in_main_thread(true) do
|
253
|
-
# If something bad happened during the yield we'll show the error
|
254
|
-
#
|
290
|
+
# If something bad happened during the yield we'll show the error
|
291
|
+
# but not exit the application. Once the block has completed we
|
292
|
+
# hide and dispose the dialog to allow the main application to run
|
255
293
|
dialog.hide
|
256
294
|
ExceptionDialog.new(parent, error, "Error During Progress", false)
|
257
295
|
end
|
@@ -265,12 +303,11 @@ module Cosmos
|
|
265
303
|
dialog.thread = nil
|
266
304
|
dialog.complete = true
|
267
305
|
|
268
|
-
# Need to make sure all Qt.execute_in_main_thread() have completed before
|
269
|
-
# we will segfault
|
306
|
+
# Need to make sure all Qt.execute_in_main_thread() have completed before
|
307
|
+
# disposing or we will segfault
|
270
308
|
Qt::RubyThreadFix.queue.pop.call until Qt::RubyThreadFix.queue.empty?
|
271
309
|
|
272
310
|
dialog.dispose
|
273
311
|
end
|
274
|
-
end
|
275
|
-
|
276
|
-
end # module Cosmos
|
312
|
+
end
|
313
|
+
end
|