cosmos 4.4.0-java → 4.5.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +2 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +6 -6
  5. data/Dockerfile +70 -0
  6. data/Manifest.txt +37 -2
  7. data/README.md +9 -0
  8. data/Rakefile +55 -5
  9. data/appveyor.yml +18 -8
  10. data/autohotkey/config/tools/cmd_sequence/cmd_sequence.txt +2 -0
  11. data/autohotkey/lib/cmd_sequence_exporter.rb +52 -0
  12. data/autohotkey/procedures/collect.rb +2 -2
  13. data/autohotkey/procedures/collect_util.rb +1 -1
  14. data/autohotkey/procedures/script_test.rb +1 -1
  15. data/autohotkey/tools/CmdSenderAHK2 +18 -0
  16. data/autohotkey/tools/cmd_extractor.ahk +11 -9
  17. data/autohotkey/tools/cmd_sender.ahk +35 -7
  18. data/autohotkey/tools/cmd_sender2.ahk +4 -0
  19. data/autohotkey/tools/cmd_sequence.ahk +22 -9
  20. data/autohotkey/tools/config_editor.ahk +4 -4
  21. data/autohotkey/tools/data_viewer.ahk +1 -1
  22. data/autohotkey/tools/limits_monitor.ahk +1 -1
  23. data/autohotkey/tools/packet_viewer.ahk +1 -1
  24. data/autohotkey/tools/script_runner.ahk +1 -1
  25. data/autohotkey/tools/test_runner2.ahk +1 -1
  26. data/autohotkey/tools/tlm_grapher.ahk +1 -1
  27. data/autohotkey/tools/tlm_grapher3.ahk +1 -1
  28. data/autohotkey/tools/tlm_viewer.ahk +1 -1
  29. data/autohotkey/tools/tlm_viewer2.ahk +1 -1
  30. data/autohotkey/tools/tlm_viewer5.ahk +1 -1
  31. data/bin/cstol_converter +1 -1
  32. data/bin/rubysloc +73 -28
  33. data/bin/xtce_converter +1 -1
  34. data/cosmos.gemspec +2 -2
  35. data/data/config/command_modifiers.yaml +16 -1
  36. data/data/config/interface_modifiers.yaml +3 -2
  37. data/data/config/param_item_modifiers.yaml +5 -0
  38. data/data/config/system.yaml +110 -23
  39. data/data/config/telemetry_modifiers.yaml +16 -1
  40. data/data/crc.txt +416 -411
  41. data/demo/Rakefile +4 -4
  42. data/demo/config/dart/Gemfile +1 -6
  43. data/demo/config/data/crc.txt +233 -232
  44. data/demo/config/system/system.txt +17 -6
  45. data/demo/config/system/system2.txt +17 -6
  46. data/demo/config/system/system_alt_ports.txt +17 -6
  47. data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +4 -4
  48. data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +4 -0
  49. data/demo/config/targets/INST/cmd_tlm/inst_tlm_override.txt +12 -0
  50. data/demo/config/targets/INST/lib/sim_inst.rb +2 -2
  51. data/demo/config/targets/INST/target.txt +1 -0
  52. data/demo/config/tools/handbook_creator/default_toc.xsl +59 -59
  53. data/demo/procedures/cosmos_api_test.rb +8 -8
  54. data/ext/cosmos/ext/buffered_file/buffered_file.c +2 -2
  55. data/ext/cosmos/ext/config_parser/config_parser.c +1 -2
  56. data/ext/cosmos/ext/line_graph/line_graph.c +53 -94
  57. data/ext/cosmos/ext/platform/platform.c +56 -21
  58. data/ext/cosmos/ext/polynomial_conversion/polynomial_conversion.c +4 -8
  59. data/ext/cosmos/ext/structure/structure.c +12 -0
  60. data/extensions/vscode/.gitignore +4 -0
  61. data/extensions/vscode/.vscode/launch.json +32 -0
  62. data/extensions/vscode/.vscode/settings.json +13 -0
  63. data/extensions/vscode/.vscode/tasks.json +79 -0
  64. data/extensions/vscode/License.txt +879 -0
  65. data/extensions/vscode/README.md +9 -0
  66. data/extensions/vscode/client/License.txt +879 -0
  67. data/extensions/vscode/client/README.md +39 -0
  68. data/extensions/vscode/client/cosmos.configuration.json +23 -0
  69. data/extensions/vscode/client/images/icon.png +0 -0
  70. data/extensions/vscode/client/package-lock.json +414 -0
  71. data/extensions/vscode/client/package.json +105 -0
  72. data/extensions/vscode/client/src/extension.ts +132 -0
  73. data/extensions/vscode/client/src/screen_preview.rb +25 -0
  74. data/extensions/vscode/client/syntaxes/cosmos.tmLanguage.json +219 -0
  75. data/extensions/vscode/client/tsconfig.json +17 -0
  76. data/extensions/vscode/package-lock.json +26 -0
  77. data/extensions/vscode/package.json +35 -0
  78. data/extensions/vscode/server/License.txt +879 -0
  79. data/extensions/vscode/server/package-lock.json +236 -0
  80. data/extensions/vscode/server/package.json +29 -0
  81. data/extensions/vscode/server/src/server.ts +59 -0
  82. data/extensions/vscode/server/tsconfig.json +16 -0
  83. data/install/Rakefile +4 -4
  84. data/install/config/dart/Gemfile +2 -7
  85. data/install/config/data/crc.txt +137 -137
  86. data/install/config/system/system.txt +17 -6
  87. data/install/config/tools/handbook_creator/default_toc.xsl +59 -59
  88. data/lib/cosmos/config/config_parser.rb +2 -10
  89. data/lib/cosmos/core_ext/class.rb +10 -0
  90. data/lib/cosmos/core_ext/time.rb +5 -3
  91. data/lib/cosmos/dart/config/boot.rb +1 -1
  92. data/lib/cosmos/dart/config/database.yml +2 -0
  93. data/lib/cosmos/dart/examples/dart_decom_client.rb +1 -1
  94. data/lib/cosmos/dart/lib/dart_common.rb +12 -5
  95. data/lib/cosmos/dart/lib/dart_constants.rb +15 -0
  96. data/lib/cosmos/dart/lib/dart_decom_query.rb +5 -6
  97. data/lib/cosmos/dart/lib/dart_decommutator.rb +64 -54
  98. data/lib/cosmos/dart/lib/dart_master_query.rb +71 -0
  99. data/lib/cosmos/dart/lib/dart_reducer_worker_thread.rb +165 -134
  100. data/lib/cosmos/dart/processes/dart.rb +4 -2
  101. data/lib/cosmos/dart/processes/dart_decom_server.rb +3 -3
  102. data/lib/cosmos/dart/processes/dart_ingester.rb +38 -1
  103. data/lib/cosmos/dart/processes/dart_master.rb +44 -0
  104. data/lib/cosmos/dart/processes/dart_util.rb +115 -0
  105. data/lib/cosmos/dart/spec/dart/dart_database_cleaner_spec.rb +2 -2
  106. data/lib/cosmos/gui/qt.rb +10 -10
  107. data/lib/cosmos/gui/qt_tool.rb +17 -12
  108. data/lib/cosmos/gui/text/completion_text_edit.rb +2 -0
  109. data/lib/cosmos/gui/widgets/dart_meta_frame.rb +22 -3
  110. data/lib/cosmos/interfaces/dart_status_interface.rb +1 -1
  111. data/lib/cosmos/interfaces/linc_interface.rb +3 -3
  112. data/lib/cosmos/interfaces/protocols/burst_protocol.rb +1 -1
  113. data/lib/cosmos/interfaces/protocols/crc_protocol.rb +1 -1
  114. data/lib/cosmos/interfaces/protocols/length_protocol.rb +5 -0
  115. data/lib/cosmos/interfaces/protocols/template_protocol.rb +3 -3
  116. data/lib/cosmos/interfaces/serial_interface.rb +7 -1
  117. data/lib/cosmos/interfaces/stream_interface.rb +1 -1
  118. data/lib/cosmos/interfaces/tcpip_server_interface.rb +16 -16
  119. data/lib/cosmos/io/io_multiplexer.rb +6 -2
  120. data/lib/cosmos/io/json_drb.rb +5 -5
  121. data/lib/cosmos/io/json_drb_object.rb +7 -2
  122. data/lib/cosmos/io/json_drb_rack.rb +25 -5
  123. data/lib/cosmos/io/json_rpc.rb +1 -1
  124. data/lib/cosmos/io/posix_serial_driver.rb +60 -22
  125. data/lib/cosmos/io/serial_driver.rb +11 -8
  126. data/lib/cosmos/io/win32_serial_driver.rb +31 -3
  127. data/lib/cosmos/packet_logs/packet_log_reader.rb +2 -2
  128. data/lib/cosmos/packets/packet.rb +9 -9
  129. data/lib/cosmos/packets/packet_config.rb +27 -9
  130. data/lib/cosmos/packets/parsers/xtce_converter.rb +10 -10
  131. data/lib/cosmos/packets/parsers/xtce_parser.rb +3 -0
  132. data/lib/cosmos/packets/structure.rb +35 -5
  133. data/lib/cosmos/packets/structure_item.rb +5 -1
  134. data/lib/cosmos/packets/telemetry.rb +7 -1
  135. data/lib/cosmos/script/api_shared.rb +18 -1
  136. data/lib/cosmos/script/extract.rb +1 -1
  137. data/lib/cosmos/script/script.rb +4 -11
  138. data/lib/cosmos/streams/serial_stream.rb +11 -6
  139. data/lib/cosmos/system/system.rb +155 -57
  140. data/lib/cosmos/tools/cmd_sender/cmd_param_table_item_delegate.rb +15 -0
  141. data/lib/cosmos/tools/cmd_sender/cmd_params.rb +382 -0
  142. data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +29 -318
  143. data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +14 -17
  144. data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +38 -331
  145. data/lib/cosmos/tools/cmd_sequence/sequence_list.rb +16 -11
  146. data/lib/cosmos/tools/cmd_tlm_server/api.rb +10 -8
  147. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +2 -2
  148. data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +1 -0
  149. data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +1 -1
  150. data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +29 -26
  151. data/lib/cosmos/tools/cmd_tlm_server/limits_groups_background_task.rb +1 -1
  152. data/lib/cosmos/tools/cmd_tlm_server/router_thread.rb +5 -0
  153. data/lib/cosmos/tools/config_editor/config_editor.rb +34 -3
  154. data/lib/cosmos/tools/config_editor/config_editor_frame.rb +8 -9
  155. data/lib/cosmos/tools/config_editor/system_config_dialog.rb +158 -0
  156. data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +1 -1
  157. data/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +1 -1
  158. data/lib/cosmos/tools/script_runner/script_runner_frame.rb +7 -4
  159. data/lib/cosmos/tools/test_runner/test.rb +6 -3
  160. data/lib/cosmos/tools/test_runner/test_runner.rb +6 -6
  161. data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +3 -3
  162. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +1 -4
  163. data/lib/cosmos/tools/tlm_extractor/tlm_extractor_processor.rb +20 -16
  164. data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_dart_thread.rb +21 -17
  165. data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +18 -11
  166. data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +17 -6
  167. data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +2 -0
  168. data/lib/cosmos/top_level.rb +1 -1
  169. data/lib/cosmos/utilities/ruby_lex_utils.rb +34 -30
  170. data/lib/cosmos/utilities/simulated_target.rb +1 -1
  171. data/lib/cosmos/version.rb +5 -5
  172. data/lib/cosmos/win32/excel.rb +23 -17
  173. data/run_gui_tests.bat +1 -0
  174. data/spec/core_ext/class_spec.rb +54 -0
  175. data/spec/core_ext/socket_spec.rb +1 -1
  176. data/spec/core_ext/time_spec.rb +4 -0
  177. data/spec/install/yaml_docs_spec.rb +26 -6
  178. data/spec/interfaces/linc_interface_spec.rb +1 -1
  179. data/spec/interfaces/protocols/length_protocol_spec.rb +39 -0
  180. data/spec/interfaces/serial_interface_spec.rb +1 -5
  181. data/spec/io/json_drb_rack_spec.rb +166 -0
  182. data/spec/io/json_drb_spec.rb +14 -0
  183. data/spec/io/json_rpc_spec.rb +4 -5
  184. data/spec/io/posix_serial_driver_spec.rb +81 -0
  185. data/spec/io/win32_serial_driver_spec.rb +33 -3
  186. data/spec/packet_logs/packet_log_reader_spec.rb +36 -37
  187. data/spec/packets/structure_spec.rb +52 -2
  188. data/spec/packets/telemetry_spec.rb +29 -1
  189. data/spec/script/extract_spec.rb +4 -1
  190. data/spec/system/system_spec.rb +111 -3
  191. data/spec/tools/cmd_tlm_server/api_spec.rb +12 -12
  192. data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +2 -2
  193. data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +4 -3
  194. data/spec/tools/cmd_tlm_server/router_thread_spec.rb +2 -3
  195. data/spec/utilities/logger_spec.rb +3 -3
  196. data/spec/utilities/message_log_spec.rb +6 -3
  197. data/tasks/gemfile_stats.rake +22 -13
  198. data/test/performance/Rakefile +4 -4
  199. data/test/performance/config/data/crc.txt +67 -48
  200. metadata +44 -9
  201. data/demo/outputs/dart/logs/README.txt +0 -1
  202. data/lib/cosmos/dart/Gemfile +0 -69
@@ -14,6 +14,7 @@ Cosmos.catch_fatal_exception do
14
14
  require 'cosmos/gui/dialogs/progress_dialog'
15
15
  require 'cosmos/gui/dialogs/scroll_text_dialog'
16
16
  require 'cosmos/tools/config_editor/config_editor_frame'
17
+ require 'cosmos/tools/config_editor/system_config_dialog'
17
18
  end
18
19
 
19
20
  module Cosmos
@@ -72,6 +73,12 @@ module Cosmos
72
73
  ["tlm_viewer", "/config/tools/tlm_viewer/tlm_viewer.txt"],
73
74
  }
74
75
 
76
+ # Class instance variable to store all the parsed metadata
77
+ @meta = {}
78
+ class << self
79
+ attr_reader :meta
80
+ end
81
+
75
82
  def initialize(options)
76
83
  # All code before super is executed twice in RubyQt Based classes
77
84
  super(options) # MUST BE FIRST
@@ -86,8 +93,27 @@ module Cosmos
86
93
  initialize_central_widget()
87
94
  complete_initialize()
88
95
 
96
+ # Process all the configuration yaml files up front
97
+ # If they passed in a filename we need to wait for all meta files to be processed
98
+ wait = options.filename ? true : false
99
+ Splash.execute(self, wait) do |splash|
100
+ count = 1.0
101
+ CONFIGURATION_FILES.each do |key, vals|
102
+ type = vals[0]
103
+ next unless type
104
+ splash.message = "Processing #{type}.yaml"
105
+ splash.progress = count / CONFIGURATION_FILES.length
106
+ begin
107
+ ConfigEditor.meta[key] = @file_meta = MetaConfigParser.load("#{type}.yaml")
108
+ rescue => error
109
+ Kernel.raise $! if error.is_a? Psych::SyntaxError
110
+ end
111
+ count += 1.0
112
+ end
113
+ end
114
+
89
115
  if options.filename
90
- file_open(options.filename)
116
+ file_open(File.expand_path(options.filename))
91
117
  else
92
118
  create_tab()
93
119
  end
@@ -227,9 +253,13 @@ module Cosmos
227
253
  update_cursor()
228
254
  end
229
255
 
230
- @create_target = Qt::Action.new('&Create Target', self)
256
+ @create_target = Qt::Action.new('Create &Target', self)
231
257
  @create_target.statusTip = 'Create a new COSMOS target'
232
258
  @create_target.connect(SIGNAL('triggered()')) { create_target() }
259
+
260
+ @create_system_config = Qt::Action.new('Create New &System Config', self)
261
+ @create_system_config.statusTip = 'Create a new system configuration'
262
+ @create_system_config.connect(SIGNAL('triggered()')) { SystemConfigDialog.new(self) }
233
263
  end
234
264
 
235
265
  def initialize_menus
@@ -294,6 +324,7 @@ module Cosmos
294
324
 
295
325
  # Actions Menu
296
326
  actions_menu = menuBar.addMenu('&Actions')
327
+ actions_menu.addAction(@create_system_config)
297
328
  actions_menu.addAction(@create_target)
298
329
 
299
330
  # Help Menu
@@ -622,7 +653,7 @@ module Cosmos
622
653
  end
623
654
  File.open(File.join(target_folder, 'procedures', "#{target.downcase}_noop.rb"), 'w') do |file|
624
655
  file.puts "require 'cosmos'"
625
- file.puts "require '#{File.basename(lib_filename)}'"
656
+ file.puts "load_utility '#{File.basename(lib_filename)}'"
626
657
  file.puts "\n"
627
658
  file.puts "#{target.downcase} = #{lib_filename.filename_to_class_name}.new"
628
659
  file.puts "#{target.downcase}.noop"
@@ -28,6 +28,10 @@ module Cosmos
28
28
  def focusInEvent(event)
29
29
  emit focus_in
30
30
  end
31
+
32
+ def wheelEvent(event)
33
+ event.ignore()
34
+ end
31
35
  end
32
36
 
33
37
  class ConfigEditorFrame < Qt::Widget
@@ -290,17 +294,10 @@ module Cosmos
290
294
  end
291
295
  emit file_type_changed # Tell ConfigEditor about the file type
292
296
  load_meta_data()
293
- display_keyword_help()
294
297
  end
295
298
 
296
299
  def load_meta_data
297
- begin
298
- type = ConfigEditor::CONFIGURATION_FILES[@file_type][0]
299
- @file_meta = MetaConfigParser.load("#{type}.yaml")
300
- rescue => error
301
- Kernel.raise $! if error.is_a? Psych::SyntaxError
302
- @file_meta = nil
303
- end
300
+ @file_meta = ConfigEditor.meta[@file_type]
304
301
  display_keyword_help()
305
302
  end
306
303
 
@@ -565,7 +562,8 @@ module Cosmos
565
562
  if attribute_value.is_a? Hash
566
563
  # If the value is a Hash then we have parameter specific
567
564
  # parameters embedded in this parameter we have to parse
568
- value_widget = Qt::ComboBox.new()
565
+ value_widget = FocusComboBox.new()
566
+ value_widget.setFocusPolicy(Qt::StrongFocus)
569
567
  value_widget.addItem(current_value) unless attribute_value.keys.include?(current_value)
570
568
  value_widget.addItems(attribute_value.keys)
571
569
  value_widget.setCurrentText(current_value)
@@ -581,6 +579,7 @@ module Cosmos
581
579
  end
582
580
  elsif attribute_value.is_a? Array # Just a bunch of strings
583
581
  value_widget = FocusComboBox.new()
582
+ value_widget.setFocusPolicy(Qt::StrongFocus)
584
583
  value_widget.addItems(attribute_value)
585
584
  if required && current_value.nil?
586
585
  value_widget.setStyleSheet("border: 1px solid red")
@@ -0,0 +1,158 @@
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 'cosmos'
12
+ require 'cosmos/gui/qt'
13
+
14
+ module Cosmos
15
+ # Creates a dialog asking to create a new system configuration.
16
+ class SystemConfigDialog < Qt::Dialog
17
+ def initialize(parent)
18
+ super(parent) # MUST BE FIRST
19
+ @parent = parent
20
+ Cosmos.load_cosmos_icon
21
+
22
+ self.window_title = 'Create System Configuration'
23
+ layout = Qt::VBoxLayout.new
24
+ self.layout = layout
25
+
26
+ description = Qt::Label.new("Creating a new COSMOS system configuration allows you to reuse "\
27
+ "an existing COSMOS configuration but include different targets and/or change configuration details.")
28
+ description.setWordWrap(true)
29
+ layout.addWidget(description)
30
+
31
+ select = Qt::Label.new("Select an existing system.txt file to base the new configuration on:")
32
+ select.setWordWrap(true)
33
+ layout.addWidget(select)
34
+ @system_combo = Qt::ComboBox.new
35
+ Dir[File.join(::Cosmos::USERPATH, 'config', 'system', '*.txt')].each do |system|
36
+ @system_combo.addItem(File.basename(system))
37
+ end
38
+ layout.addWidget(@system_combo)
39
+ layout.addSpacing(10)
40
+
41
+ name_label = Qt::Label.new("Enter a name for the new system configuration that is descriptive "\
42
+ " but relatively short. For example, 'EMI', 'SW Test', etc:")
43
+ name_label.setWordWrap(true)
44
+ layout.addWidget(name_label)
45
+ @system_name = Qt::LineEdit.new
46
+ layout.addWidget(@system_name)
47
+ layout.addSpacing(10)
48
+
49
+ info = Qt::Label.new("This action will create a new COSMOS system.txt, "\
50
+ "cmd_tlm_server.txt, launcher.txt, and Windows Batch file appended with the specified name. "\
51
+ "For example, system_emi.txt, system_sw_test.txt, launcher_emi.txt, launcher_sw_test.txt, etc.")
52
+ info.setWordWrap(true)
53
+ layout.addWidget(info)
54
+
55
+ ok_button = Qt::PushButton.new('Ok')
56
+ connect(ok_button, SIGNAL('clicked()'), self, SLOT('accept()'))
57
+ cancel_button = Qt::PushButton.new('Cancel')
58
+ connect(cancel_button, SIGNAL('clicked()'), self, SLOT('reject()'))
59
+
60
+ hlayout = Qt::HBoxLayout.new
61
+ hlayout.addWidget(ok_button, 0, Qt::AlignLeft)
62
+ hlayout.addWidget(cancel_button, 0, Qt::AlignRight)
63
+ layout.addLayout(hlayout)
64
+
65
+ resize(500, 300)
66
+
67
+ self.show()
68
+ self.raise()
69
+ if self.exec() == Qt::Dialog::Accepted
70
+ build_system_config()
71
+ end
72
+ self.dispose()
73
+ end
74
+
75
+ def build_system_config
76
+ new_suffix = @system_name.text.downcase.gsub(' ','_')
77
+ existing_system = @system_combo.text
78
+ # Look for system_xxx.txt where we find the 'xxx' as the existing suffix
79
+ if existing = existing_system.scan(/.*?_(.*)\.txt/)[0]
80
+ existing_suffix = existing[0]
81
+ else
82
+ existing_suffix = nil
83
+ end
84
+
85
+ # First determine all the new files and make sure they don't already exist
86
+ new_system = File.join(Cosmos::USERPATH, 'config', 'system', "system_#{new_suffix}.txt")
87
+ return if file_exist?(new_system)
88
+ cmd_tlm_server_path = File.join('config', 'tools', 'cmd_tlm_server')
89
+ new_cmd_tlm_server = File.join(Cosmos::USERPATH, cmd_tlm_server_path, "cmd_tlm_server_#{new_suffix}.txt")
90
+ return if file_exist?(new_cmd_tlm_server)
91
+ launcher_path = File.join('config', 'tools', 'launcher')
92
+ new_launcher = File.join(Cosmos::USERPATH, launcher_path, "launcher_#{new_suffix}.txt")
93
+ return if file_exist?(new_launcher)
94
+ new_batch = File.join(Cosmos::USERPATH, "Launcher#{@system_name.text.gsub(' ','')}.bat")
95
+ return if file_exist?(new_batch)
96
+
97
+ # Create the new system.txt. We know the existing exists so simply copy it.
98
+ File.open(new_system, 'w') do |file|
99
+ file.puts File.read(File.join(::Cosmos::USERPATH, 'config', 'system', existing_system))
100
+ end
101
+
102
+ # Create the new cmd_tlm_server config and update the TITLE
103
+ data = get_config_contents(existing_suffix, cmd_tlm_server_path, 'cmd_tlm_server')
104
+ data.sub!(/\s*TITLE.*/, "TITLE 'COSMOS Command and Telemetry Server - #{@system_name.text} Configuration'")
105
+ File.open(new_cmd_tlm_server, 'w') {|file| file.puts data }
106
+
107
+ # Create the new launcher config and update the TITLE and Server LAUNCH commands
108
+ data = get_config_contents(existing_suffix, launcher_path, 'launcher')
109
+ data.sub!(/\s*TITLE.*/, "TITLE 'Launcher - #{@system_name.text} Configuration'")
110
+ data.gsub!(/LAUNCH\s+(\w+)/, "LAUNCH \\1 --system system_#{new_suffix}.txt")
111
+ # Convert all --config to -c to make it easier to replace in the next step
112
+ data.gsub!(/(.*LAUNCH\s+CmdTlmServer.*)(--config)(.*)/, "\\1-c\\3")
113
+ data.gsub!(/(.*LAUNCH\s+CmdTlmServer.*)-c\s+(\w+)(.*)/, "\\1-c cmd_tlm_server_#{new_suffix}\\3")
114
+ File.open(new_launcher, 'w') {|file| file.puts data }
115
+
116
+ File.open(new_batch, 'w') do |file|
117
+ file.puts "call tools\\Launcher.bat --config launcher_#{new_suffix}.txt --system system_#{new_suffix}.txt"
118
+ end
119
+
120
+ @parent.file_open(new_batch)
121
+ @parent.file_open(new_launcher)
122
+ @parent.file_open(new_cmd_tlm_server)
123
+ @parent.file_open(new_system)
124
+ Qt::MessageBox.information(self, "System Config Creation Success",
125
+ "The new system configuration was successfully created.\n\n"\
126
+ "The newly created files have been opened for further customization.")
127
+ end
128
+
129
+ def file_exist?(path)
130
+ if File.exist?(path)
131
+ Qt::MessageBox.warning(self, "Config file exists!", "#{path} already exists!")
132
+ return true
133
+ else
134
+ return false
135
+ end
136
+ end
137
+
138
+ def get_config_contents(existing_suffix, base_path, file_name)
139
+ contents = ''
140
+ if existing_suffix
141
+ existing_file = File.join(Cosmos::USERPATH, base_path, "#{file_name}_#{existing_suffix}.txt")
142
+ if File.exist?(existing_file)
143
+ contents = File.read(existing_file)
144
+ end
145
+ else
146
+ # Otherwise see if there is a basic one we can copy
147
+ basic_config = File.join(Cosmos::USERPATH, base_path, "#{file_name}.txt")
148
+ if File.exist?(basic_config)
149
+ contents = File.read(basic_config)
150
+ else
151
+ # Otherwise use the install config
152
+ contents = File.read(File.join(Cosmos::PATH, 'install', base_path, "#{file_name}.txt"))
153
+ end
154
+ end
155
+ return contents
156
+ end
157
+ end
158
+ end
@@ -156,7 +156,7 @@ module Cosmos
156
156
  msg << "PDF Handbooks created successfully"
157
157
  progress_dialog.append_text(msg)
158
158
  else
159
- progress_dialog.append_text("\nPDF Handbooks could not be created.\n\nIs wkhtmltopdf in your PATH and are all existing pdfs closed?\n\nUsing version 0.11.0_rc1 of wkhtmltox is recommended which can be found at: http://download.gna.org/wkhtmltopdf/obsolete/\n\nVersion 0.12.x has shown issues with Handbook Creator's default templates.")
159
+ progress_dialog.append_text("\nPDF Handbooks could not be created.\n\nIs wkhtmltopdf in your PATH and are all existing pdfs closed?\n\nwkhtmltopdf can be found at: https://wkhtmltopdf.org/downloads.html.")
160
160
  end
161
161
  rescue => error
162
162
  progress_dialog.append_text("\n\nError processing:\n#{error.formatted}")
@@ -115,7 +115,7 @@ module Cosmos
115
115
  cover, cover_file = make_pdf_detail('cover', @pdf_cover_filename, @pdf_cover_title, target_name)
116
116
  header, header_file = make_pdf_detail('--header-spacing 3 --header-html', @pdf_header_filename, @pdf_header_title, target_name)
117
117
  footer, footer_file = make_pdf_detail('--footer-spacing 3 --footer-html', @pdf_footer_filename, @pdf_footer_title, target_name)
118
- system_call = "wkhtmltopdf -L #{@pdf_side_margin} -R #{@pdf_side_margin} -T #{@pdf_top_margin} -B #{@pdf_bottom_margin} -s Letter #{header} #{footer} #{cover} #{@pdf_toc} \"#{tmp_html_file.path}\" \"#{File.dirname(filename)}/#{File.basename(filename, '.*')}.pdf\""
118
+ system_call = "wkhtmltopdf --enable-local-file-access -L #{@pdf_side_margin} -R #{@pdf_side_margin} -T #{@pdf_top_margin} -B #{@pdf_bottom_margin} -s Letter #{header} #{footer} #{cover} #{@pdf_toc} \"#{tmp_html_file.path}\" \"#{File.dirname(filename)}/#{File.basename(filename, '.*')}.pdf\""
119
119
  status = nil
120
120
  begin
121
121
  Cosmos.set_working_dir(System.paths['HANDBOOKS']) do
@@ -594,12 +594,12 @@ module Cosmos
594
594
  "ScriptRunnerFrame.instance.pre_line_instrumentation('#{filename}', #{line_no}); "
595
595
 
596
596
  # Add the actual line
597
- instrumented_line << "__return_val = "
597
+ instrumented_line << "__return_val = begin; "
598
598
  instrumented_line << segment
599
599
  instrumented_line.chomp!
600
600
 
601
601
  # Add postline instrumentation
602
- instrumented_line << "; ScriptRunnerFrame.instance.post_line_instrumentation('#{filename}', #{line_no}); "
602
+ instrumented_line << " end; ScriptRunnerFrame.instance.post_line_instrumentation('#{filename}', #{line_no}); "
603
603
 
604
604
  # Complete begin block to catch exceptions
605
605
  unless inside_begin
@@ -973,8 +973,10 @@ module Cosmos
973
973
  if debug_text =~ /^@\S+$/ || @script_binding.local_variables.include?(debug_text.to_sym)
974
974
  debug_text = "puts #{debug_text}" # Automatically add puts to print it
975
975
  end
976
+ # Fortify: Dynamic Code Evaluation: Code Injection
976
977
  eval(debug_text, @script_binding, 'debug', 1)
977
978
  else
979
+ # Fortify: Dynamic Code Evaluation: Code Injection
978
980
  Object.class_eval(debug_text, 'debug', 1)
979
981
  end
980
982
  handle_output_io()
@@ -1489,7 +1491,7 @@ module Cosmos
1489
1491
  @@output_thread = nil
1490
1492
  end
1491
1493
 
1492
- @script.setReadOnly(false)
1494
+ @script.setReadOnly(false) unless @script.read_only
1493
1495
  @script.stop_highlight unless uncaught_exception
1494
1496
  select_tab_and_destroy_tabs_after_index(0)
1495
1497
  remove_tabs()
@@ -1722,7 +1724,8 @@ module Cosmos
1722
1724
  @active_script.setPlainText(data)
1723
1725
  end
1724
1726
  mark_breakpoints(filename)
1725
-
1727
+ @active_script.read_only = !File.writable?(filename)
1728
+ @active_script.setReadOnly(@active_script.read_only)
1726
1729
  @active_script.stop_highlight
1727
1730
  end
1728
1731
 
@@ -126,7 +126,7 @@ module Cosmos
126
126
  if result
127
127
  results << result
128
128
  yield result if block_given?
129
- raise StopScript if result.stopped
129
+ raise StopScript if (results[-1].exceptions and @@abort_on_exception) or results[-1].stopped
130
130
  end
131
131
 
132
132
  # Run each test case
@@ -141,7 +141,7 @@ module Cosmos
141
141
  if result
142
142
  results << result
143
143
  yield result if block_given?
144
- raise StopScript if result.stopped
144
+ raise StopScript if (results[-1].exceptions and @@abort_on_exception) or results[-1].stopped
145
145
  end
146
146
 
147
147
  results
@@ -176,7 +176,7 @@ module Cosmos
176
176
  end
177
177
  end
178
178
 
179
- object.send(method_name)
179
+ object.public_send(method_name)
180
180
  result.result = :PASS
181
181
 
182
182
  if defined? ScriptRunnerFrame
@@ -387,17 +387,20 @@ module Cosmos
387
387
  result = run_test_case(test_class, test_case, true)
388
388
  results << result
389
389
  yield result if block_given?
390
+ raise StopScript if (result.exceptions and test_class.abort_on_exception) or result.stopped
390
391
  when :TEST_SETUP
391
392
  result = run_test_setup(test_class, true)
392
393
  if result
393
394
  results << result
394
395
  yield result if block_given?
396
+ raise StopScript if (result.exceptions and test_class.abort_on_exception) or result.stopped
395
397
  end
396
398
  when :TEST_TEARDOWN
397
399
  result = run_test_teardown(test_class, true)
398
400
  if result
399
401
  results << result
400
402
  yield result if block_given?
403
+ raise StopScript if (result.exceptions and test_class.abort_on_exception) or result.stopped
401
404
  end
402
405
  end
403
406
  end
@@ -652,7 +652,7 @@ module Cosmos
652
652
  ScriptRunnerFrame.instance = @script_runner_frame
653
653
  build = false
654
654
  @utilities.each do |utility|
655
- if require_utility(utility)
655
+ if load_utility(utility)
656
656
  build = true
657
657
  end
658
658
  end
@@ -865,13 +865,13 @@ module Cosmos
865
865
  suite = CustomTestSuite.new
866
866
  begin
867
867
  # Remove any previously defined suite setup methods
868
- CustomTestSuite.send(:remove_method, :setup)
868
+ CustomTestSuite.public_send(:remove_method, :setup)
869
869
  rescue NameError
870
870
  # NameError is raised if no setup method was defined
871
871
  end
872
872
  begin
873
873
  # Remove any previously defined suite teardown methods
874
- CustomTestSuite.send(:remove_method, :teardown)
874
+ CustomTestSuite.public_send(:remove_method, :teardown)
875
875
  rescue NameError
876
876
  # NameError is raised if no teardown method was defined
877
877
  end
@@ -884,7 +884,7 @@ module Cosmos
884
884
  inst = @@test_suites.detect {|my_suite| my_suite.class.to_s == suite_node.text}
885
885
  # Create a lambda which will call that one setup method
886
886
  body = lambda { inst.setup }
887
- CustomTestSuite.send(:define_method, :setup, &body)
887
+ CustomTestSuite.public_send(:define_method, :setup, &body)
888
888
  end
889
889
  if test_node.text == 'teardown'
890
890
  cur_suite.teardown = true
@@ -892,7 +892,7 @@ module Cosmos
892
892
  inst = @@test_suites.detect {|my_suite| my_suite.class.to_s == suite_node.text}
893
893
  # Create a lambda which will call that one teardown method
894
894
  body = lambda { inst.teardown}
895
- CustomTestSuite.send(:define_method, :teardown, &body)
895
+ CustomTestSuite.public_send(:define_method, :teardown, &body)
896
896
  end
897
897
  end
898
898
 
@@ -999,7 +999,7 @@ module Cosmos
999
999
  when 'LOAD_UTILITY', 'REQUIRE_UTILITY'
1000
1000
  parser.verify_num_parameters(1, 1, "LOAD_UTILITY <filename>")
1001
1001
  begin
1002
- require_utility params[0]
1002
+ load_utility(params[0])
1003
1003
  @utilities << params[0]
1004
1004
  rescue Exception => err
1005
1005
  require_errors << "<b>#{params[0]}</b>:\n#{err.formatted}\n"
@@ -455,7 +455,7 @@ module Cosmos
455
455
  def self.post_options_parsed_hook(options)
456
456
  if options.input_files or options.dart
457
457
  normalize_config_options(options)
458
-
458
+
459
459
  # Process config file
460
460
  raise "Configuration File must be specified for command line processing" unless options.config_file
461
461
 
@@ -675,7 +675,7 @@ module Cosmos
675
675
  process_args = [batch_name, @input_filenames, @log_dir, output_extension, @batch_filenames, @packet_log_frame.time_start, @packet_log_frame.time_end]
676
676
  end
677
677
 
678
- @tlm_extractor_processor.send(process_method, *process_args) do |input_file_index, packet_count, file_progress|
678
+ @tlm_extractor_processor.public_send(process_method, *process_args) do |input_file_index, packet_count, file_progress|
679
679
  # Handle Cancel
680
680
  break if @cancel
681
681
 
@@ -760,7 +760,7 @@ module Cosmos
760
760
  process_args = [batch_name, @log_dir, output_extension, @batch_filenames, @packet_log_frame.time_start, @packet_log_frame.time_end, @dart_meta_frame.meta_filters]
761
761
  end
762
762
 
763
- @tlm_extractor_processor.send(process_method, *process_args) do |percentage, message|
763
+ @tlm_extractor_processor.public_send(process_method, *process_args) do |percentage, message|
764
764
  # Handle Cancel
765
765
  break if @cancel
766
766
  progress_dialog.append_text(message)
@@ -385,10 +385,7 @@ module Cosmos
385
385
 
386
386
  # Print column headings to output file
387
387
  @output_file.print "%" if @matlab_header
388
- column_names().each do |column_name|
389
- @output_file.print column_name
390
- @output_file.print @delimiter
391
- end
388
+ @output_file.print column_names.join(@delimiter)
392
389
  @output_file.puts ""
393
390
  @row_index += 1
394
391
  end
@@ -10,11 +10,11 @@
10
10
 
11
11
  require 'cosmos'
12
12
  require 'cosmos/tools/tlm_extractor/tlm_extractor_config'
13
+ require 'cosmos/dart/lib/dart_constants'
13
14
 
14
15
  module Cosmos
15
-
16
+ # Process the settings selected in the TlmExtractor to ultimately produce the output file
16
17
  class TlmExtractorProcessor
17
-
18
18
  attr_accessor :packet_log_reader
19
19
 
20
20
  def initialize
@@ -31,7 +31,7 @@ module Cosmos
31
31
  configs[-1].output_filename = File.join(output_dir, batch_name.tr(' ', '_') + '_' + filename_no_extension.tr(' ', '_') + output_extension)
32
32
  end
33
33
  process(input_filenames, configs, time_start, time_end, &block)
34
- end # def process_batch
34
+ end
35
35
 
36
36
  def process(input_filenames, configs, time_start = nil, time_end = nil)
37
37
  Cosmos.set_working_dir do
@@ -50,10 +50,10 @@ module Cosmos
50
50
  end
51
51
  yield input_file_index, packet_count, 1.0 if block_given?
52
52
  end
53
- end # Cosmos.set_working_dir
53
+ end
54
54
  ensure
55
55
  configs.each { |config| config.close_output_file }
56
- end # def process
56
+ end
57
57
 
58
58
  def process_dart_batch(batch_name, output_dir, output_extension, config_filenames, time_start = nil, time_end = nil, meta_filters = [], &block)
59
59
  configs = []
@@ -72,13 +72,13 @@ module Cosmos
72
72
  items = []
73
73
  configs.each { |config| config.mode = :dart; items.concat(config.normal_items); config.open_output_file }
74
74
  items.uniq!
75
-
75
+
76
76
  time_start = Time.utc(1970, 1, 1) unless time_start
77
77
  time_end = Time.now unless time_end
78
78
 
79
79
  results = {}
80
80
  begin
81
- server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'])
81
+ server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'], 1.0, Cosmos::System.x_csrf_token)
82
82
 
83
83
  index = 0
84
84
  items.each do |item_type, target_name, packet_name, item_name, value_type, dart_reduction, dart_reduced_type|
@@ -96,21 +96,27 @@ module Cosmos
96
96
  request['reduction'] = dart_reduction.to_s
97
97
  request['cmd_tlm'] = 'TLM'
98
98
  request['offset'] = 0
99
- request['limit'] = 10000
99
+ request['limit'] = DartConstants::MAX_DECOM_RESULTS
100
100
  if dart_reduction == :NONE
101
101
  request['value_type'] = value_type.to_s
102
102
  else
103
103
  request['value_type'] = value_type.to_s + "_#{dart_reduced_type}"
104
104
  end
105
105
  request['meta_filters'] = meta_filters if meta_filters.length > 0
106
- result = server.query(request)
107
- results[query_string] = result
106
+ results[query_string] = []
107
+ while true
108
+ result = server.query(request)
109
+ results[query_string].concat(result)
110
+ break if result.length < DartConstants::MAX_DECOM_RESULTS
111
+ yield(index.to_f / items.length, " Total results: #{results[query_string].length}") if block_given?
112
+ request['offset'] += DartConstants::MAX_DECOM_RESULTS
113
+ end
108
114
  index += 1
109
- yield(index.to_f / items.length, " Received #{result.length} values") if block_given?
115
+ yield(index.to_f / items.length, " Total results: #{results[query_string].length}") if block_given?
110
116
  rescue Exception => error
111
117
  yield(index.to_f / items.length, "Error querying #{query_string} : #{error.class}:#{error.message}\n#{error.backtrace.join("\n")}\n") if block_given?
112
118
  return # Bail out because something bad happened
113
- end
119
+ end
114
120
  end
115
121
 
116
122
  configs.each { |config| config.process_dart(results) }
@@ -121,7 +127,5 @@ module Cosmos
121
127
  ensure
122
128
  configs.each { |config| config.close_output_file }
123
129
  end
124
-
125
- end # class TlmExtractorProcessor
126
-
127
- end # module Cosmos
130
+ end
131
+ end
@@ -11,9 +11,9 @@
11
11
  require 'cosmos'
12
12
  require 'cosmos/gui/qt'
13
13
  require 'cosmos/io/json_drb_object'
14
+ require 'cosmos/dart/lib/dart_constants'
14
15
 
15
16
  module Cosmos
16
-
17
17
  # Thread used to gather telemetry from DART and process it using a TabbedPlotsDefinition
18
18
  class TabbedPlotsDartThread
19
19
  # Array of exceptions that occurred
@@ -45,7 +45,7 @@ module Cosmos
45
45
 
46
46
  # Execute each query
47
47
  results = {}
48
- server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'])
48
+ server = JsonDRbObject.new(System.connect_hosts['DART_DECOM'], System.ports['DART_DECOM'], 1.0, Cosmos::System.x_csrf_token)
49
49
  time_start = Time.utc(1970, 1, 1) unless time_start
50
50
  time_end = Time.now unless time_end
51
51
  progress_dialog.set_step_progress(0) if progress_dialog
@@ -67,23 +67,29 @@ module Cosmos
67
67
  request['reduction'] = dart_reduction.to_s
68
68
  request['cmd_tlm'] = 'TLM'
69
69
  request['offset'] = 0
70
- request['limit'] = 10000
70
+ request['limit'] = DartConstants::MAX_DECOM_RESULTS
71
71
  if dart_reduction == :NONE
72
72
  request['value_type'] = value_type.to_s
73
73
  else
74
74
  request['value_type'] = value_type.to_s + "_#{dart_reduced_type}"
75
75
  end
76
76
  request['meta_filters'] = meta_filters unless meta_filters.empty?
77
- query_result = server.query(request)
78
- result = query_result
79
- if array_index
80
- result = []
81
- query_result.each do |qr|
82
- result << [qr[0][array_index], qr[1], qr[2], qr[3], qr[4]]
77
+ results[query_string] = []
78
+ while true
79
+ query_result = server.query(request)
80
+ result = query_result
81
+ if array_index
82
+ result = []
83
+ query_result.each do |qr|
84
+ result << [qr[0][array_index], qr[1], qr[2], qr[3], qr[4]]
85
+ end
83
86
  end
87
+ results[query_string].concat(result)
88
+ break if query_result.length < DartConstants::MAX_DECOM_RESULTS
89
+ progress_dialog.append_text(" Total results: #{results[query_string].length}") if progress_dialog
90
+ request['offset'] += DartConstants::MAX_DECOM_RESULTS
84
91
  end
85
- results[query_string] = result
86
- progress_dialog.append_text(" Received #{result.length} values") if progress_dialog
92
+ progress_dialog.append_text(" Total results: #{results[query_string].length}") if progress_dialog
87
93
  progress_dialog.set_step_progress((index + 1).to_f / required_queries.length) if progress_dialog
88
94
  rescue Exception => error
89
95
  @errors << error
@@ -134,7 +140,7 @@ module Cosmos
134
140
  @done = true
135
141
  end
136
142
  end
137
- end # def initialize
143
+ end
138
144
 
139
145
  # Indicates if processing is complete
140
146
  def done?
@@ -149,12 +155,10 @@ module Cosmos
149
155
  @thread = nil
150
156
  @done = true
151
157
  return true, false
152
- end # def kill
158
+ end
153
159
 
154
160
  def graceful_kill
155
161
  # Just to remove warnings
156
162
  end
157
-
158
- end # class TabbedPlotsLogfileThread
159
-
160
- end # module Cosmos
163
+ end
164
+ end