humble_rpi-plugin-magneticswitch 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3881e137d35f35f75eeedde484a7d66ba591148
4
- data.tar.gz: 80615bfbc04dcb9c718965fb38d0d6275104beae
3
+ metadata.gz: 39803a831996ad98dfb92a77dc83ade5a507a794
4
+ data.tar.gz: 449d5f6f18364666c9aeb6c60a5dd6fc20ab986e
5
5
  SHA512:
6
- metadata.gz: 0a5e75789d29796fd26314a6de8f95febde54e8269a34596ce2cd9683306db2fb0594ab664c8f346ba52cb35fd221fe8e5f3ad6c59fcdde96cdf2e42a44264f3
7
- data.tar.gz: 946ca0e54dff90a247f9f73fd49c3e0758b1e87af54e48fe12956042ddc43215d06c397d3cbe4045d3c34b725b05c0fb02c9169ad47708ee10aaf9f79a27b1ed
6
+ metadata.gz: f742502cf5a026513f28e0fbc70a3f7b330b683ffb4d76fd3b70dbf2ccabb7b85a5d1cac3f3bd6e8de02526a2b429b8be9cf5d30765e958c4bd30b7e8528fc7c
7
+ data.tar.gz: a3a2d5c677cfa7872ee421ae984ea361a14ac1a70b28866183c59fab98a0b2fc5f3756d6466ef61ff778c38edcd74d4d33472649c03c951c5cdaa0f618afdc96
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -7,6 +7,11 @@ require 'rpi_pinin'
7
7
  require 'self-defense'
8
8
 
9
9
 
10
+ Thread.abort_on_exception=true
11
+
12
+ class PluginMagneticSwitchException < Exception
13
+ end
14
+
10
15
  class HumbleRPiPluginMagneticSwitch
11
16
 
12
17
 
@@ -16,6 +21,7 @@ class HumbleRPiPluginMagneticSwitch
16
21
  @pins = settings[:pins].map {|x| RPiPinIn.new x, pull: :up}
17
22
  @notifier = variables[:notifier]
18
23
  @device_id = variables[:device_id] || 'pi'
24
+
19
25
 
20
26
  end
21
27
 
@@ -26,6 +32,7 @@ class HumbleRPiPluginMagneticSwitch
26
32
  nc = @nc
27
33
 
28
34
  puts 'ready to detect magnetic switches'
35
+
29
36
 
30
37
  @pins.each.with_index do |pin, i|
31
38
 
@@ -33,8 +40,9 @@ class HumbleRPiPluginMagneticSwitch
33
40
 
34
41
  n = (i+1).to_s
35
42
 
36
- Thread.new do
37
-
43
+ threads = []
44
+ threads << Thread.new do
45
+
38
46
  pin.watch do |value|
39
47
 
40
48
  state = value == 0 ? :opened : :closed
@@ -55,10 +63,10 @@ class HumbleRPiPluginMagneticSwitch
55
63
  SelfDefense.new(&strategy) if state == :opened
56
64
 
57
65
  if input_operation == :erratic then
58
-
66
+
59
67
  notifier.notice "%s/magneticswitch/%s: " + \
60
68
  " door error: Erratic input operation" % [device_id, i]
61
- raise 'humble_rpi-plugin-magneticwitch: Erratic input operation'
69
+ raise PluginMagneticSwitchException, 'Erratic input operation'
62
70
  end
63
71
 
64
72
  notifier.notice "%s/magneticswitch/%s: door %s" % \
@@ -67,6 +75,7 @@ class HumbleRPiPluginMagneticSwitch
67
75
  end
68
76
 
69
77
  end
78
+ threads.each(&:join)
70
79
 
71
80
  end
72
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humble_rpi-plugin-magneticswitch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  bPWFwNbEi9CiEPveT/uvh62PLy8oXqUUvXHHxIjvpQICBlT6wc8vkY+Lz86rQ+xY
32
32
  nKxNwaysAN6TFg==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-11-21 00:00:00.000000000 Z
34
+ date: 2016-12-15 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rpi_pinin
@@ -42,7 +42,7 @@ dependencies:
42
42
  version: '0.1'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.1
45
+ version: 0.1.2
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  version: '0.1'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.1.1
55
+ version: 0.1.2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: self-defense
58
58
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file