humble_rpi 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/humble_rpi.rb +33 -26
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ffdfa5b1856d9b677acaa738dc04e241b65f5fc
|
4
|
+
data.tar.gz: b288e9256b2ad0772acabe3a1ab2755ababf2024
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0529c2c23c93ad08118d894f75afd8e0fcc1a7bb27daa00d4cf5f187ab90aa03caa7f53e895daa15a5fec4ee8dd1c92d4dc1094a9e8bf46cef20bed7b8d4475b
|
7
|
+
data.tar.gz: a44c927c22c111d1b5208ac3d0c73e35527dffbcb8f5d60a52ada5cbe5fa664e269bf8ff8ba9992b5ead31bae3e5c349888fadbf636fab5830f0338c9d166efb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/humble_rpi.rb
CHANGED
@@ -15,36 +15,37 @@ class DummyNotifier
|
|
15
15
|
|
16
16
|
end
|
17
17
|
|
18
|
-
class HumbleRPi
|
18
|
+
class HumbleRPi
|
19
19
|
|
20
20
|
def initialize(device_name: 'rpi', sps_address: nil, sps_port: 59000, \
|
21
|
-
|
21
|
+
plugins: {}, group_id: 'root')
|
22
22
|
|
23
23
|
@device_name, @sps_address, @sps_port = device_name, sps_address, sps_port
|
24
|
+
@group_id = group_id
|
24
25
|
|
25
26
|
@publisher, @subscriber = sps_address ? initialize_sps() \
|
26
27
|
: [DummyNotifier.new, nil]
|
27
28
|
|
28
29
|
@plugins = initialize_plugins(plugins || [])
|
29
|
-
|
30
|
+
|
30
31
|
end
|
31
32
|
|
32
33
|
# triggered from a sps-sub callback
|
33
34
|
#
|
34
35
|
def ontopic(topic, msg)
|
35
|
-
|
36
|
+
|
36
37
|
component = topic[/\w+$/]
|
37
|
-
|
38
|
+
|
38
39
|
method_name = "on_#{component}_message".to_sym
|
39
|
-
|
40
|
+
|
40
41
|
@plugins.each do |x|
|
41
|
-
|
42
|
-
if x.respond_to? method_name then
|
43
|
-
x.method(method_name).call(msg)
|
42
|
+
|
43
|
+
if x.respond_to? method_name then
|
44
|
+
x.method(method_name).call(msg)
|
44
45
|
end
|
45
|
-
|
46
|
+
|
46
47
|
end
|
47
|
-
end
|
48
|
+
end
|
48
49
|
|
49
50
|
def start()
|
50
51
|
|
@@ -56,15 +57,18 @@ class HumbleRPi
|
|
56
57
|
end
|
57
58
|
|
58
59
|
if @subscriber then
|
59
|
-
|
60
|
-
Thread.new do
|
60
|
+
|
61
|
+
Thread.new do
|
61
62
|
sp = SPSSubPing.new host: @sps_address, port: @sps_port, \
|
62
|
-
|
63
|
+
identifier: "HumbleRPi/%s/%s" % [@group_id, @device_name]
|
63
64
|
sp.start
|
64
65
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
subtopics = %w(output do)
|
68
|
+
topics = subtopics\
|
69
|
+
.map {|x| "HumbleRPi/%s/%s/%s/#" % [@group_id, @device_name, x]}\
|
70
|
+
.join(' | ')
|
71
|
+
@subscriber.subscribe topic: topics
|
68
72
|
|
69
73
|
else
|
70
74
|
loop while true
|
@@ -72,15 +76,16 @@ class HumbleRPi
|
|
72
76
|
|
73
77
|
end
|
74
78
|
|
75
|
-
|
79
|
+
|
76
80
|
private
|
77
|
-
|
81
|
+
|
78
82
|
def initialize_sps()
|
79
|
-
|
83
|
+
|
80
84
|
publisher = SPSPub.new address: @sps_address, port: @sps_port
|
81
|
-
publisher.notice
|
82
|
-
|
83
|
-
|
85
|
+
publisher.notice "HumbleRPi/%s/%s/info: initialized" \
|
86
|
+
% [@group_id, @device_name]
|
87
|
+
subscriber = SPSSub.new address: @sps_address, port: @sps_port,\
|
88
|
+
callback: self
|
84
89
|
[publisher, subscriber]
|
85
90
|
|
86
91
|
end
|
@@ -93,10 +98,12 @@ class HumbleRPi
|
|
93
98
|
return r if settings[:active] == false and !settings[:active]
|
94
99
|
|
95
100
|
klass_name = 'HumbleRPiPlugin' + name.to_s
|
96
|
-
|
97
|
-
vars = {device_id: @device_name, notifier: @publisher}
|
98
101
|
|
99
|
-
|
102
|
+
device_id = "HumbleRPi/%s/%s" % [@group_id, @device_name]
|
103
|
+
vars = {device_id: device_id, notifier: @publisher}
|
104
|
+
|
105
|
+
r << Kernel.const_get(klass_name)\
|
106
|
+
.new(settings: settings, variables: vars)
|
100
107
|
|
101
108
|
end
|
102
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humble_rpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
999CZL08Zqxa+1DKwhW/XqeiQ9eIZ+1fLAK+XbAKgv6ghNYEPtZLUFiD73uUbsKd
|
32
32
|
sBqeV1LF1yKYmA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-06-
|
34
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sps-pub
|
metadata.gz.sig
CHANGED
Binary file
|