class Pocolog::DisplayConfig

Constants

Spec

Public Class Methods

optname() click to toggle source
# File bin/pocolog, line 370
def self.optname; "--show" end

Public Instance Methods

display_file_info() click to toggle source
# File bin/pocolog, line 393
def display_file_info
    logfiles.read_prologue
    mode = if logfiles.endian_swap ^ Pocolog.big_endian?
                   "big endian"
           else
                   "little endian"
           end

    puts "File data is in #{mode} byte order" 
    empty_streams = Hash.new
    info = Hash.new

    streams = logfiles.streams
    if streams.empty?
        puts "empty log file"
        return
    end

    streams.each do |stream|
        first_sample, last_sample = stream.time_interval
        count = stream.size

        if count == 0
            empty_streams[stream.name] = "#{stream.name} [#{stream.typename}]\n"
            if !stream.metadata.empty? && @show_metadata
                stream.metadata.sort.each do |key, value|
                    empty_streams[stream.name] << "    #{key}: #{value}\n"
                end
            end
        else
            info[stream.name] = "#{stream.name} [#{stream.typename}]\n"
            if !stream.metadata.empty? && @show_metadata
                stream.metadata.sort.each do |key, value|
                    info[stream.name] << "  #{key}: #{value}\n"
                end
            end
            info[stream.name] <<
                "  #{count} samples"

            diff = last_sample - first_sample
            diff = Time.at(diff).to_hms if diff > 0
            first_sample = first_sample.strftime("%a %d/%m/%Y %H:%M:%S")
            last_sample  = last_sample.strftime("%a %d/%m/%Y %H:%M:%S")
            info[stream.name] << " from #{first_sample} to #{last_sample} [#{diff}]"
        end
    end
    info.keys.sort.each do |name|
        puts "Stream #{info[name]}"
    end
    if !empty_streams.empty?
        print "No samples for\n  "
        puts empty_streams.values_at(*empty_streams.keys.sort).join("  ")
    end
end
execute() click to toggle source
# File bin/pocolog, line 376
def execute
    if specs.empty?
        return display_file_info
    elsif @show_type
        specs.each do |s|
            stream = s.samples.stream
            pp stream.type
        end

    else specs.each { |s| s.execute }
    end
end
show_metadata() click to toggle source
# File bin/pocolog, line 372
def show_metadata
    @show_metadata = true
end
type() click to toggle source
# File bin/pocolog, line 389
def type
    @show_type = true
end