Class: Distem::DataCollection::Probe
- Inherits:
-
Object
- Object
- Distem::DataCollection::Probe
- Defined in:
- lib/distem/datacollection/probe.rb
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) data
readonly
Returns the value of attribute data.
Instance Method Summary (collapse)
- - (Object) get_value
-
- (Probe) initialize(drift, data, opts)
constructor
A new instance of Probe.
- - (Object) restart
- - (Object) run
- - (Object) stop
Constructor Details
- (Probe) initialize(drift, data, opts)
Returns a new instance of Probe
13 14 15 16 17 18 19 |
# File 'lib/distem/datacollection/probe.rb', line 13 def initialize(drift, data, opts) @drift = drift @data = data @opts = opts @frequency = opts['frequency'] @finished = false end |
Instance Attribute Details
- (Object) data (readonly)
Returns the value of attribute data
11 12 13 |
# File 'lib/distem/datacollection/probe.rb', line 11 def data @data end |
Instance Method Details
- (Object) get_value
42 43 44 |
# File 'lib/distem/datacollection/probe.rb', line 42 def get_value raise Lib::NotImplementedError end |
- (Object) restart
31 32 33 34 |
# File 'lib/distem/datacollection/probe.rb', line 31 def restart @finished = false run end |
- (Object) run
21 22 23 24 25 26 27 28 29 |
# File 'lib/distem/datacollection/probe.rb', line 21 def run @tid = Thread.new { while !@finished sleep(1 / @frequency) val = get_value @data << [(@drift + Time.now.to_f).round(3), val] if val end } end |
- (Object) stop
36 37 38 39 40 |
# File 'lib/distem/datacollection/probe.rb', line 36 def stop @finished = true sleep(1 + (1 / @frequency)) Thread.kill(@tid) if @tid.alive? end |