Sha256: 8aa82a342a49ed306fd8e8dd1cc26ca0ffd26ebb1c13a0325d14f3e122d7af1f

Contents?: true

Size: 1.8 KB

Versions: 38

Compression:

Stored size: 1.8 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'cosmos'
require 'cosmos/ccsds/ccsds_packet'

module Cosmos
  class CmdSequenceExporter
    def initialize(parent)
      @parent = parent
    end

    def export(filename, sequence_dir, sequence_list)
      basename = File.basename(filename, ".*")
      filename = Qt::FileDialog::getSaveFileName(@parent,   # parent
                                                 'Export', # caption
                                                 sequence_dir + "/#{basename}.bin", # dir
                                                 'Sequence Binary (*.bin)') # filter
      return if filename.nil? || filename.empty?

      data = ''
      sequence_list.each do |item|
        begin
          time = Time.parse(item.time)
          day, ms, us = Time.mdy2ccsds(time.year, time.month, time.day, time.hour, time.min, time.sec, time.usec)
          data << [day].pack("N") # UINT32
          data << [ms].pack("N") # UINT32
        rescue
          time = item.time.to_f * 1000
          data << [0].pack("N") # UINT32
          data << [time].pack("N") # UINT32
        end
        data << item.command.buffer
      end
      ccsds = CcsdsPacket.new
      ccsds.write("CCSDSTYPE", CcsdsPacket::COMMAND)
      ccsds.write('CCSDSSHF', 0)
      ccsds.write("CCSDSAPID", 505)
      ccsds.write("CCSDSSEQFLAGS", CcsdsPacket::STANDALONE)
      ccsds.write("CCSDSDATA", data)
      ccsds.write("CCSDSLENGTH", data.length - 1)
      File.open(filename, 'wb') { |file| file.write ccsds.buffer }
    end
  end
end

Version data entries

38 entries across 28 versions & 1 rubygems

Version Path
cosmos-4.5.2-java autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.5.2-java demo/lib/cmd_sequence_exporter.rb
cosmos-4.5.2 demo/lib/cmd_sequence_exporter.rb
cosmos-4.5.2 autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.5.1-java demo/lib/cmd_sequence_exporter.rb
cosmos-4.5.1-java autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.5.1 autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.5.1 demo/lib/cmd_sequence_exporter.rb
cosmos-4.5.0-java demo/lib/cmd_sequence_exporter.rb
cosmos-4.5.0-java autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.5.0 autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.5.0 demo/lib/cmd_sequence_exporter.rb
cosmos-4.4.2-java demo/lib/cmd_sequence_exporter.rb
cosmos-4.4.2-java autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.4.2 autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.4.2 demo/lib/cmd_sequence_exporter.rb
cosmos-4.4.1-java demo/lib/cmd_sequence_exporter.rb
cosmos-4.4.1-java autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.4.1 autohotkey/lib/cmd_sequence_exporter.rb
cosmos-4.4.1 demo/lib/cmd_sequence_exporter.rb