Class: Distem::DataCollection::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/distem/datacollection/collector.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Collector) initialize(ref_time, desc)

Returns a new instance of Collector



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/distem/datacollection/collector.rb', line 9

def initialize(ref_time, desc)
  @probes = []
  @data = {}
  drift = ref_time - Time.now.to_f
  desc.each_pair { |k,params|
    klass = nil
    begin
      klass = DataCollection.const_get(k)
      raise if (klass.superclass != DataCollection::Probe)
    rescue
      raise Lib::InvalidProbeError, k
    end
    raise Lib::ParameterError unless (params.has_key?('frequency') && (params['frequency'].is_a?(Float) || params['frequency'].is_a?(Fixnum)))
    raise Lib::ParameterError unless (params.has_key?('name') && params['name'].is_a?(String))
    @data[params['name']] = []
    @probes << klass.new(drift, @data[params['name']], params)
  }
end

Instance Attribute Details

- (Object) data (readonly)

Returns the value of attribute data



7
8
9
# File 'lib/distem/datacollection/collector.rb', line 7

def data
  @data
end

Instance Method Details

- (Object) restart



36
37
38
# File 'lib/distem/datacollection/collector.rb', line 36

def restart
  @probes.each { |i| i.restart }
end

- (Object) run



28
29
30
# File 'lib/distem/datacollection/collector.rb', line 28

def run
  @probes.each { |i| i.run }
end

- (Object) stop



32
33
34
# File 'lib/distem/datacollection/collector.rb', line 32

def stop
  @probes.each { |i| i.stop }
end