Class: ITRP::Cmd_timeslices

Inherits:
Cmd
  • Object
show all
Defined in:
lib/handlers/timeslices.rb

Instance Attribute Summary

Attributes inherited from Cmd

#attach_cmd, #children, #enabled_in_state, #trigger

Instance Method Summary collapse

Methods inherited from Cmd

#appstate, #completions, #find_node, #is_root?, #place_node, #print_state, #set_time_window, #treeprint

Constructor Details

#initialize(e) ⇒ Cmd_timeslices

Returns a new instance of Cmd_timeslices.



4
5
6
7
8
9
# File 'lib/handlers/timeslices.rb', line 4

def initialize (e)
	super(e)
	@enabled_in_state = :any
	@attach_cmd  = ''
	@trigger = 'timeslices'
end

Instance Method Details

#enter(cmdline) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/handlers/timeslices.rb', line 11

def enter(cmdline)

		terms = cmdline.scan( /(\w+)\s*=\s*([\w\-_\.\:,\}\{]+)+/ )
		qparams = terms.inject({}) { |acc,t| acc.store( t[0].to_sym, t[1]);acc}


		p qparams 

		req =mk_request(TRP::Message::Command::TIMESLICES_REQUEST, 
{ }.merge(qparams) )

    rows = [] 
    rows_window  = [] 

		get_response_zmq(@appenv.zmq_endpt,req) do |resp|
        resp.slices.each do | slice |
            rows << [ Time.at(slice.time_interval.from.tv_sec), 
		  Time.at(slice.time_interval.to.tv_sec) ,
		  slice.name , slice.status, slice.disk_size
         ]
        end

        if resp.total_window 
            rows_window << [  Time.at(resp.total_window.from.tv_sec), 
                              Time.at(resp.total_window.to.tv_sec)]
        end
    end 



    p "Time Slices"
		table = Terminal::Table.new( 
:headings => %w(From  To Name Status DiskSz),
:rows => rows)
		puts(table) 

    p "Total Window"
		table = Terminal::Table.new( 
:headings => %w(From  To ),
:rows => rows_window)
		puts(table) 
end