Class: Cosmos::TlmExtractor
- Defined in:
- lib/cosmos/tools/tlm_extractor/tlm_extractor.rb
Overview
TlmExtractor class
This class implements the TlmExtractor. This application breaks a binary log of telemetry into a csv type file
Defined Under Namespace
Classes: MyListWidget
Constant Summary collapse
- FORMATTING_OPTIONS =
%w(CONVERTED RAW FORMATTED WITH_UNITS)
Class Method Summary collapse
-
.post_options_parsed_hook(options) ⇒ Object
def initialize.
-
.run(option_parser = nil, options = nil) ⇒ Object
Runs the application.
Instance Method Summary collapse
-
#context_menu(point) ⇒ Object
def self.run.
-
#initialize(options) ⇒ TlmExtractor
constructor
Constructor.
- #initialize_actions ⇒ Object
- #initialize_central_widget ⇒ Object
- #initialize_menus ⇒ Object
Methods inherited from QtTool
#about, #closeEvent, #complete_initialize, create_default_options, graceful_kill, #initialize_help_menu, pre_window_new_hook, redirect_io, restore_io
Constructor Details
#initialize(options) ⇒ TlmExtractor
Constructor
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 70 def initialize() super() # MUST BE FIRST - All code before super is executed twice in RubyQt Based classes Cosmos.load_cosmos_icon("tlm_extractor.png") # Define instance variables @input_filenames = [] @log_dir = System.paths['LOGS'] @config_dir = File.join(Cosmos::USERPATH, 'config', 'tools', 'tlm_extractor', '') @cancel = false initialize_actions() () () complete_initialize() # Bring up slash screen for long duration tasks after creation Splash.execute(self) do |splash| # Configure CosmosConfig to interact with splash screen ConfigParser.splash = splash System.telemetry @search_box.completion_list = System.telemetry.all_item_strings(true, splash) @tlm_extractor_config = TlmExtractorConfig.new(.config_file) @tlm_extractor_processor = TlmExtractorProcessor.new Qt.execute_in_main_thread(true) do @telemetry_chooser.update sync_config_to_gui() end # Unconfigure CosmosConfig to interact with splash screen ConfigParser.splash = nil end end |
Class Method Details
.post_options_parsed_hook(options) ⇒ Object
def initialize
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 385 def self.() if .input_files # Process config file raise "Configuration File must be specified for command line processing" unless .config_file # Process the input file(s) tlm_extractor_config = TlmExtractorConfig.new(.config_file) tlm_extractor_processor = TlmExtractorProcessor.new unless .output_file filename = .input_files[0] extension = File.extname(filename) filename_no_extension = filename[0..-(extension.length + 1)] if tlm_extractor_config.delimiter.to_s.strip == ',' filename = filename_no_extension << '.csv' else filename = filename_no_extension << '.txt' end .output_file = File.join(System.paths['LOGS'], File.basename(filename)) end tlm_extractor_config.output_filename = .output_file tlm_extractor_processor.process(.input_files, [tlm_extractor_config]) puts "Created #{.output_file}" return false else return true end end |
.run(option_parser = nil, options = nil) ⇒ Object
Runs the application
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 415 def self.run(option_parser = nil, = nil) Cosmos.catch_fatal_exception do unless option_parser and option_parser, = () .width = 700 .height = 425 .auto_size = false .restore_size = false # always render this the correct size .title = "Telemetry Extractor" option_parser.separator "Telemetry Extractor Specific Options:" option_parser.on("-c", "--config FILE", "Use the specified configuration file") do |arg| .config_file = File.join(Cosmos::USERPATH, 'config', 'tools', 'tlm_extractor', arg) end option_parser.on("-i", "--input FILE", "Process the specified input file") do |arg| .input_files ||= [] if arg[0..0] != '/' and arg[1..1] != ':' # Relative path to default of log folder arg = File.join(System.paths['LOGS'], arg) end .input_files << arg end option_parser.on("-o", "--output FILE", "Output results to the specified file") do |arg| .output_file = arg end end super(option_parser, ) end end |
Instance Method Details
#context_menu(point) ⇒ Object
def self.run
445 446 447 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 445 def (point) @item_menu.exec(@config_item_list.mapToGlobal(point)) end |
#initialize_actions ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 104 def initialize_actions super() # File Menu Actions @open_config = Qt::Action.new(tr('Open &Config'), self) @open_config.statusTip = tr('Open configuration file') @open_config.connect(SIGNAL('triggered()')) { () } @save_config = Qt::Action.new(tr('&Save Config'), self) @save_config_keyseq = Qt::KeySequence.new(tr('Ctrl+S')) @save_config.shortcut = @save_config_keyseq @save_config.statusTip = tr('Save current configuration') @save_config.connect(SIGNAL('triggered()')) { () } @file_options = Qt::Action.new(tr('O&ptions'), self) @file_options.statusTip = tr('Open the options dialog') @file_options.connect(SIGNAL('triggered()')) { () } # Mode Menu Actions @fill_down_check = Qt::Action.new(tr('&Fill Down'), self) @fill_down_check_keyseq = Qt::KeySequence.new(tr('Ctrl+F')) @fill_down_check.shortcut = @fill_down_check_keyseq @fill_down_check.statusTip = tr('Fill Down') @fill_down_check.setCheckable(true) @matlab_header_check = Qt::Action.new(tr('&Matlab Header'), self) @matlab_header_check_keyseq = Qt::KeySequence.new(tr('Ctrl+M')) @matlab_header_check.shortcut = @matlab_header_check_keyseq @matlab_header_check.statusTip = tr('Add a Matlab header to the output data') @matlab_header_check.setCheckable(true) @share_columns_check = Qt::Action.new(tr('&Share Columns'), self) @share_columns_check.statusTip = tr('Share columns for items with the same name') @share_columns_check.setCheckable(true) @unique_only_check = Qt::Action.new(tr('&Unique Only'), self) @unique_only_check_keyseq = Qt::KeySequence.new(tr('Ctrl+U')) @unique_only_check.shortcut = @unique_only_check_keyseq @unique_only_check.statusTip = tr('Only output rows where data has changed') @unique_only_check.setCheckable(true) @batch_mode_check = Qt::Action.new(tr('&Batch Mode'), self) @batch_mode_check_keyseq = Qt::KeySequence.new(tr('Ctrl+B')) @batch_mode_check.shortcut = @batch_mode_check_keyseq @batch_mode_check.statusTip = tr('Process multiple config files with the same input files') @batch_mode_check.setCheckable(true) @batch_mode_check.connect(SIGNAL('triggered()')) { batch_mode_changed() } # Item Menu Actions @item_edit = Qt::Action.new(tr('&Edit Items'), self) @item_edit_keyseq = Qt::KeySequence.new(tr('Ctrl+E')) @item_edit.shortcut = @item_edit_keyseq @item_edit.statusTip = tr('Options') @item_edit.connect(SIGNAL('triggered()')) { item_edit() } @item_delete = Qt::Action.new(tr('&Delete Items'), self) @item_delete.statusTip = tr('Options') @item_delete.connect(SIGNAL('triggered()')) { item_delete() } end |
#initialize_central_widget ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 192 def # Create the central widget @central_widget = Qt::Widget.new setCentralWidget(@central_widget) @top_layout = Qt::VBoxLayout.new @config_box = Qt::GroupBox.new("Configuration") @config_box_layout = Qt::VBoxLayout.new @config_box.setLayout(@config_box_layout) @top_layout.addWidget(@config_box) # Configuration File Selector @config_layout = Qt::HBoxLayout.new @config_layout_label = Qt::Label.new('Configuration File:') @config_layout.addWidget(@config_layout_label) @config_field = Qt::LineEdit.new @config_field.setReadOnly(true) @config_layout.addWidget(@config_field) @save_button = Qt::PushButton.new('Save...') @config_layout.addWidget(@save_button) @save_button.connect(SIGNAL('clicked()')) { () } @browse_button = Qt::PushButton.new('Browse...') @config_layout.addWidget(@browse_button) @browse_button.connect(SIGNAL('clicked()')) { () } @config_box_layout.addLayout(@config_layout) # Separator before editor @sep1 = Qt::Frame.new(@central_widget) @sep1.setFrameStyle(Qt::Frame::HLine | Qt::Frame::Sunken) @config_box_layout.addWidget(@sep1) # Configuration File Editor @config_item_list = MyListWidget.new(self) @config_item_list.setContextMenuPolicy(Qt::CustomContextMenu) @config_item_list.setDragDropMode(Qt::AbstractItemView::InternalMove) @config_item_list.setSelectionMode(Qt::AbstractItemView::ExtendedSelection) @config_item_list.setMinimumHeight(150) # Allow either double click or enter / return key to bring up the item editor @config_item_list.connect(SIGNAL('itemDoubleClicked(QListWidgetItem*)')) { item_list_editor() } @config_item_list.connect(SIGNAL('enterKeyPressed(int)')) { item_list_editor() } connect(@config_item_list, SIGNAL('customContextMenuRequested(const QPoint&)'), self, SLOT('context_menu(const QPoint&)')) @config_box_layout.addWidget(@config_item_list) # Telemetry Search @search_layout = Qt::HBoxLayout.new @search_box = FullTextSearchLineEdit.new(self) @search_box.setStyleSheet("padding-right: 20px;padding-left: 5px;background: url(#{File.join(Cosmos::PATH, 'data', 'search-14.png')});background-position: right;background-repeat: no-repeat;") @search_add_item_button = Qt::PushButton.new('Add Item') @search_add_item_button.connect(SIGNAL('clicked()')) do split_tlm = @search_box.text.to_s.split(" ") if split_tlm.length == 3 target_name = split_tlm[0].to_s.upcase packet_name = split_tlm[1].to_s.upcase item_name = split_tlm[2].to_s.upcase begin System.telemetry.packet_and_item(target_name, packet_name, item_name) add_item_callback(target_name, packet_name, item_name) rescue # Does not exist end end end @search_add_packet_button = Qt::PushButton.new('Add Packet') @search_add_packet_button.connect(SIGNAL('clicked()')) do split_tlm = @search_box.text.to_s.split(" ") if split_tlm.length >= 2 target_name = split_tlm[0].to_s.upcase packet_name = split_tlm[1].to_s.upcase begin System.telemetry.packet(target_name, packet_name) add_packet_callback(target_name, packet_name) rescue # Does not exist end end end @search_add_target_button = Qt::PushButton.new('Add Target') @search_add_target_button.connect(SIGNAL('clicked()')) do split_tlm = @search_box.text.to_s.split(" ") if split_tlm.length >= 1 target_name = split_tlm[0].to_s.upcase if System.telemetry.target_names.include?(target_name) add_target_callback(target_name) end end end @search_layout.addWidget(@search_box) @search_layout.addWidget(@search_add_item_button) @search_layout.addWidget(@search_add_packet_button) @search_layout.addWidget(@search_add_target_button) @config_box_layout.addLayout(@search_layout) # Telemetry Chooser tlm_chooser_layout = Qt::BoxLayout.new(Qt::Horizontal) = Qt::PushButton.new('Add Target') .connect(SIGNAL('clicked()')) do add_target_callback(@telemetry_chooser.target_name) end tlm_chooser_layout.addWidget() = Qt::PushButton.new('Add Packet') .connect(SIGNAL('clicked()')) do add_packet_callback(@telemetry_chooser.target_name, @telemetry_chooser.packet_name) end tlm_chooser_layout.addWidget() @telemetry_chooser = TelemetryChooser.new(self, Qt::Horizontal, true, true, false, true) @telemetry_chooser. = 'Add Item' @telemetry_chooser. = method(:add_item_callback) tlm_chooser_layout.addWidget(@telemetry_chooser) @config_box_layout.addLayout(tlm_chooser_layout) # Text Item Chooser @text_item_chooser = TextItemChooser.new(self) @text_item_chooser. = method(:add_text_item_callback) @config_box_layout.addWidget(@text_item_chooser) # Downsample @downsample_entry = FloatChooser.new(self, 'Downsample Seconds:', 0.0, 0.0, nil, 20, true) @config_box_layout.addWidget(@downsample_entry) # Batch Configuration @batch_config_box = Qt::GroupBox.new("Batch Configuration") @batch_config_layout = Qt::GridLayout.new @batch_config_layout.setColumnStretch(1, 1) @batch_config_box.setLayout(@batch_config_layout) @top_layout.addWidget(@batch_config_box) row = 0 # Chooser for Log Files label = Qt::Label.new('Config Files:') @batch_config_layout.addWidget(label, row, 0) @batch_fill_widget = Qt::Widget.new @batch_fill_widget.setMinimumWidth(360) @batch_config_layout.addWidget(@batch_fill_widget, row, 1, 0, 3) @batch_browse_button = Qt::PushButton.new('Browse...') @batch_browse_button.connect(SIGNAL('clicked()')) { () } @batch_config_layout.addWidget(@batch_browse_button, row, 2) @batch_remove_button = Qt::PushButton.new('Remove') @batch_remove_button.connect(SIGNAL('clicked()')) { () } @batch_config_layout.addWidget(@batch_remove_button, row, 3) row += 1 @batch_filenames_entry = Qt::ListWidget.new(self) @batch_filenames_entry.setSelectionMode(Qt::AbstractItemView::ExtendedSelection) @batch_filenames_entry.setSortingEnabled(true) @batch_filenames_entry.setMinimumHeight(90) @batch_config_layout.addWidget(@batch_filenames_entry, row, 0, 3, 4) row += 3 # Batch Name @batch_name_label = Qt::Label.new('Batch Name:') @batch_config_layout.addWidget(@batch_name_label, row, 0) @batch_name_entry = Qt::LineEdit.new @batch_name_entry.setMinimumWidth(340) @batch_config_layout.addWidget(@batch_name_entry, row, 1, 1, 3) row += 1 @batch_config_box.hide @file_box = Qt::GroupBox.new("File Selection") @file_box_layout = Qt::VBoxLayout.new @file_box.setLayout(@file_box_layout) @top_layout.addWidget(@file_box) # Packet Log Frame @packet_log_frame = PacketLogFrame.new(self, @log_dir, System.default_packet_log_reader.new, @input_filenames, nil, true, true, true, Cosmos::TLM_FILE_PATTERN, Cosmos::TXT_FILE_PATTERN) @packet_log_frame.change_callback = method(:change_callback) @file_box_layout.addWidget(@packet_log_frame) # Process and Open Buttons @button_layout = Qt::HBoxLayout.new @process_button = Qt::PushButton.new('&Process Files') @process_button.connect(SIGNAL('clicked()')) { process_log_files() } @button_layout.addWidget(@process_button) @open_button = Qt::PushButton.new('&Open in Text Editor') @open_button.connect(SIGNAL('clicked()')) { () } @open_button.setEnabled(false) @button_layout.addWidget(@open_button) if Kernel.is_windows? @open_excel_button = Qt::PushButton.new('&Open in Excel') @open_excel_button.connect(SIGNAL('clicked()')) { () } @open_excel_button.setEnabled(false) @button_layout.addWidget(@open_excel_button) end @top_layout.addLayout(@button_layout) @central_widget.setLayout(@top_layout) end |
#initialize_menus ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 164 def # File Menu @file_menu = .addMenu(tr('&File')) @file_menu.addAction(@open_config) @file_menu.addAction(@save_config) @file_menu.addSeparator() @file_menu.addAction(@file_options) @file_menu.addSeparator() @file_menu.addAction(@exit_action) # Mode Menu @mode_menu = .addMenu(tr('&Mode')) @mode_menu.addAction(@fill_down_check) @mode_menu.addAction(@matlab_header_check) @mode_menu.addAction(@share_columns_check) @mode_menu.addAction(@unique_only_check) @mode_menu.addAction(@batch_mode_check) # Item Menu @item_menu = .addMenu(tr('&Item')) @item_menu.addAction(@item_edit) @item_menu.addAction(@item_delete) # Help Menu @about_string = "COSMOS Telemetry Extractor allows processing of telemetry log files and breaking out specified items." () end |