home_io_meas_receiver 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -12,6 +12,7 @@ module MeasReceiver
12
12
  @name = @meas_type.name
13
13
 
14
14
  @coefficients = _meas_type.coefficients
15
+ @after_proc = _meas_type.after_proc
15
16
  @storage = _meas_type.storage
16
17
  # index from which start storage algorithm
17
18
  @storage_last_i = 0
@@ -37,6 +38,15 @@ module MeasReceiver
37
38
 
38
39
  @logger.debug("Added #{v.to_s.yellow} to buffer, size #{@size.to_s.blue}") if @debug
39
40
  end
41
+
42
+ after_add
43
+ end
44
+
45
+ # Execute proc using last fetched measurement
46
+ def after_add
47
+ unless @after_proc.nil?
48
+ @after_proc.call(self.last)
49
+ end
40
50
  end
41
51
 
42
52
  def interval
@@ -78,7 +88,7 @@ module MeasReceiver
78
88
  end
79
89
 
80
90
  # Average/mean raw within buffer
81
- def mean_raw(i, count = @storage[:avg_side_count])
91
+ def mean_raw(i, count = @storage[:avg_side_count].to_i)
82
92
  return @buffer[i] if count == 0
83
93
 
84
94
  _from = i - count
@@ -10,6 +10,8 @@ module MeasReceiver
10
10
  DEFAULT_FETCH_INTERVAL = 0.5
11
11
  MIN_FETCH_INTERVAL = 0.1
12
12
 
13
+ # TODO convert all keys to Symbols
14
+
13
15
  def initialize(_options)
14
16
  @options = _options
15
17
 
@@ -29,6 +31,7 @@ module MeasReceiver
29
31
  @coefficients = @options[:coefficients] || Hash.new
30
32
  @coefficients[:linear] ||= 1.0
31
33
  @coefficients[:offset] ||= 0.0
34
+ @after_proc = @options[:after_proc]
32
35
  @storage = @options[:storage] || Hash.new
33
36
  @storage[:min_time_interval] ||= @fetch_interval
34
37
  @storage[:min_unit_interval] = (@storage[:min_time_interval] / @fetch_interval).floor
@@ -40,7 +43,7 @@ module MeasReceiver
40
43
  @meas_buffer = MeasTypeBuffer.new(self)
41
44
  end
42
45
 
43
- attr_reader :fetch_interval, :command, :response_size, :coefficients, :storage, :name, :logger, :debug
46
+ attr_reader :fetch_interval, :command, :response_size, :coefficients, :storage, :name, :logger, :debug, :after_proc
44
47
 
45
48
  def start
46
49
  @logger.debug("MeasReceiver started for #{self.name.red}") if @debug
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: home_io_meas_receiver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-16 00:00:00.000000000Z
12
+ date: 2012-12-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rufus-scheduler
16
- requirement: &15527060 !ruby/object:Gem::Requirement
16
+ requirement: &24261520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *15527060
24
+ version_requirements: *24261520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mean
27
- requirement: &15558520 !ruby/object:Gem::Requirement
27
+ requirement: &24294700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *15558520
35
+ version_requirements: *24294700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: colorize
38
- requirement: &15557820 !ruby/object:Gem::Requirement
38
+ requirement: &24294080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *15557820
46
+ version_requirements: *24294080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &15557180 !ruby/object:Gem::Requirement
49
+ requirement: &24293440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *15557180
57
+ version_requirements: *24293440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &15556540 !ruby/object:Gem::Requirement
60
+ requirement: &24292740 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *15556540
68
+ version_requirements: *24292740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &15555820 !ruby/object:Gem::Requirement
71
+ requirement: &24292040 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *15555820
79
+ version_requirements: *24292040
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &15555060 !ruby/object:Gem::Requirement
82
+ requirement: &24291320 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *15555060
90
+ version_requirements: *24291320
91
91
  description: Receive measurements from IoServer (part if HomeIO).
92
92
  email: bobikx@poczta.fm
93
93
  executables: []
@@ -121,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  segments:
123
123
  - 0
124
- hash: 2619819358904249746
124
+ hash: 1422264506347988898
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  none: false
127
127
  requirements: