Class: Roby::Log::DataStream
Overview
Displaying log data
Data display is done in three objects:
-
a DataStream object which is the data source itself. It gives information about available samples, time of samples and extracts raw data. An example of data stream is the EventStream object which reads Roby’s event logs, returning one cycle worth of data at a time.
-
a DataDecoder object which takes the raw data returned by a DataStream object and turns it into a more usable representation. For instance, the PlanBuilder decoder takes an event stream from an EventStream object and rebuilds a plan-like structure from it.
-
a display which takes its information from the decoder. The RelationDisplay displays the information included in the PlanRebuilder decoder and displays it as a graph.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, type) ⇒ DataStream
Returns a new instance of DataStream.
40
41
42
43
44
45
46
47
|
# File 'lib/roby/log/data_stream.rb', line 40
def initialize(name, type)
@id = object_id
@name = name
@type = type
@range = [nil, nil]
@decoders = []
end
|
Instance Attribute Details
The set of decoders attached to this stream
73
74
75
|
# File 'lib/roby/log/data_stream.rb', line 73
def decoders
@decoders
end
|
The stream ID, which has to be unique on a single Roby core
18
19
20
|
# File 'lib/roby/log/data_stream.rb', line 18
def id
@id
end
|
The stream name. A [name, type] has to be globally unique
20
21
22
|
# File 'lib/roby/log/data_stream.rb', line 20
def name
@name
end
|
The [min, max] range of available samples. Initially
- nil, nil
70
71
72
|
# File 'lib/roby/log/data_stream.rb', line 70
def range
@range
end
|
The stream type, as a string.
22
23
24
|
# File 'lib/roby/log/data_stream.rb', line 22
def type
@type
end
|
Class Method Details
.open(basename) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/roby/log/data_stream.rb', line 24
def self.open(basename)
stream = new(basename)
stream.open
if block_given?
begin
yield(stream)
ensure
stream.logfile.close
end
else
stream
end
end
|
Instance Method Details
#==(other) ⇒ Object
131
132
133
134
135
|
# File 'lib/roby/log/data_stream.rb', line 131
def ==(other)
other.kind_of?(DataStream) &&
name == other.name &&
type == other.type
end
|
#added_decoder(dec) ⇒ Object
99
100
101
|
# File 'lib/roby/log/data_stream.rb', line 99
def added_decoder(dec)
super if defined? super
end
|
Do a read - decode - feed cycle
104
105
106
107
108
109
|
# File 'lib/roby/log/data_stream.rb', line 104
def advance
data = decode(read)
decoders.each do |dec|
dec.process(data)
end
end
|
75
76
77
|
# File 'lib/roby/log/data_stream.rb', line 75
def clear
decoders.each { |dec| dec.clear }
end
|
#clear_integrated ⇒ Object
118
119
120
121
122
|
# File 'lib/roby/log/data_stream.rb', line 118
def clear_integrated
decoders.each do |decoder|
decoder.clear_integrated
end
end
|
51
|
# File 'lib/roby/log/data_stream.rb', line 51
def close; end
|
#decode(data) ⇒ Object
114
115
116
|
# File 'lib/roby/log/data_stream.rb', line 114
def decode(data)
self.class.decode(data)
end
|
#decoder(klass) ⇒ Object
Reuse or creates a decoder of the given class for this data stream
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/roby/log/data_stream.rb', line 88
def decoder(klass)
if dec = decoders.find { |d| d.kind_of?(klass) }
dec
else
decoders << (dec = klass.new(name))
dec.stream = self
added_decoder(dec)
dec
end
end
|
125
126
127
128
129
|
# File 'lib/roby/log/data_stream.rb', line 125
def display
decoders.each do |decoder|
decoder.display
end
end
|
#displayed? ⇒ Boolean
True if there is at least one display attached to this data stream
80
81
82
83
84
|
# File 'lib/roby/log/data_stream.rb', line 80
def displayed?
decoders.any? do |dec|
!dec.displays.empty?
end
end
|
#eql?(other) ⇒ Boolean
136
|
# File 'lib/roby/log/data_stream.rb', line 136
def eql?(other); self == other end
|
#has_sample? ⇒ Boolean
53
|
# File 'lib/roby/log/data_stream.rb', line 53
def has_sample?; false end
|
137
|
# File 'lib/roby/log/data_stream.rb', line 137
def hash; [name, type].hash end
|
#init(data) ⇒ Object
111
112
113
|
# File 'lib/roby/log/data_stream.rb', line 111
def init(data)
self.class.init(data)
end
|
50
|
# File 'lib/roby/log/data_stream.rb', line 50
def open; end
|
62
|
# File 'lib/roby/log/data_stream.rb', line 62
def read_all; end
|
#read_and_decode ⇒ Object
64
65
66
|
# File 'lib/roby/log/data_stream.rb', line 64
def read_and_decode
self.class.decode(read)
end
|
56
57
58
59
60
61
|
# File 'lib/roby/log/data_stream.rb', line 56
def reinit!
@range = [nil, nil]
@reinit = false
clear
end
|
#reinit? ⇒ Boolean
55
|
# File 'lib/roby/log/data_stream.rb', line 55
def reinit?; end
|
49
|
# File 'lib/roby/log/data_stream.rb', line 49
def to_s; "#{name} [#{type}]" end
|