openplacos 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/openplacos.rb +1 -2
- data/lib/openplacos/libclient.rb +364 -127
- data/lib/openplacos/libcomponent.rb +550 -0
- data/lib/openplacos/template_client.rb +17 -0
- data/lib/openplacos/widget/Analog.rb +63 -0
- data/lib/openplacos/widget/Digital.rb +55 -0
- data/lib/openplacos/widget/modules.rb +19 -0
- data/openplacos.gemspec +5 -3
- metadata +75 -58
- data/lib/openplacos/libdriver.rb +0 -129
- data/lib/openplacos/libplugin.rb +0 -76
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
|
4
|
+
require 'digest/sha1'
|
5
|
+
require File.dirname(__FILE__) + "/libclient_oauth.rb"
|
6
|
+
|
7
|
+
HOST = 'http://0.0.0.0:4567'
|
8
|
+
REDIRECT_URI = "http://0.0.0.0:2000"
|
9
|
+
ID = Digest::SHA1.file(__FILE__).hexdigest
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
client = Openplacos::Client.new(HOST, "TRUC", ["read", "user"] , "auth_code")
|
14
|
+
|
15
|
+
puts client.objects["/home/temperature"]["analog.sensor.temperature.celcuis"].read
|
16
|
+
puts client.objects["/home/fan"]["analog.order.dimmer"].write(0.5)
|
17
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# This file is part of Openplacos.
|
2
|
+
#
|
3
|
+
# Openplacos is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Openplacos is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.s.instance
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with Openplacos. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
|
17
|
+
module Openplacos
|
18
|
+
|
19
|
+
# Namespace for Analog signals.
|
20
|
+
module Analog
|
21
|
+
|
22
|
+
# convert an analog value to a string
|
23
|
+
# supposed to be generic to all clients
|
24
|
+
# can be easily overloaded if needed
|
25
|
+
def to_s
|
26
|
+
read({}).round(2).to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
# render method is supposed to be overlaoded
|
30
|
+
# this method is like a view
|
31
|
+
# this method returns a string formatted as needed for the client to express an analog value
|
32
|
+
def render
|
33
|
+
return to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
module Analog::Order
|
39
|
+
include Analog
|
40
|
+
|
41
|
+
def set(arg_)
|
42
|
+
write(arg_.to_f, {})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Analog::Regul
|
47
|
+
include Analog::Order
|
48
|
+
end
|
49
|
+
|
50
|
+
module Analog::Sensor
|
51
|
+
include Analog
|
52
|
+
|
53
|
+
def render
|
54
|
+
return to_s + " " + unit
|
55
|
+
end
|
56
|
+
|
57
|
+
def unit
|
58
|
+
@name.split(".").last
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# This file is part of Openplacos.
|
2
|
+
#
|
3
|
+
# Openplacos is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Openplacos is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.s.instance
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with Openplacos. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
module Openplacos
|
17
|
+
module Digital
|
18
|
+
def to_s
|
19
|
+
read({})
|
20
|
+
end
|
21
|
+
|
22
|
+
def render
|
23
|
+
return to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
module Order
|
28
|
+
include Digital
|
29
|
+
|
30
|
+
module Switch
|
31
|
+
include Order
|
32
|
+
|
33
|
+
def set(arg_)
|
34
|
+
if (arg_ == "True" || (arg_ == "true") || (arg_ == "on")|| (arg_ == "ON"))
|
35
|
+
return write(true, {})
|
36
|
+
end
|
37
|
+
if (arg_ == "False" || (arg_ == "false")|| (arg_ == "off")|| (arg_ == "OFF"))
|
38
|
+
return write(false, {})
|
39
|
+
end
|
40
|
+
puts "Action not recognized, please use ON/OFF"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
module Regul
|
47
|
+
include Digital
|
48
|
+
|
49
|
+
module Switch
|
50
|
+
include Order::Switch
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file is part of Openplacos.
|
2
|
+
#
|
3
|
+
# Openplacos is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Openplacos is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with Openplacos. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
|
17
|
+
require File.dirname(__FILE__) + "/Analog.rb"
|
18
|
+
require File.dirname(__FILE__) + "/Digital.rb"
|
19
|
+
|
data/openplacos.gemspec
CHANGED
@@ -12,10 +12,12 @@ GEMSPEC = Gem::Specification.new do |s|
|
|
12
12
|
s.version = File.read("VERSION").strip
|
13
13
|
s.license = 'GPL-3'
|
14
14
|
s.author = "Openplacos Team"
|
15
|
-
s.email = "openplacos
|
16
|
-
s.homepage = "http://openplacos.
|
15
|
+
s.email = "openplacos@lists.tuxfamily.org"
|
16
|
+
s.homepage = "http://openplacos.tuxfamily.org/"
|
17
17
|
s.files = FileList["{lib}/**/*", "openplacos.gemspec", "VERSION"].to_a.sort
|
18
18
|
s.require_path = "lib"
|
19
19
|
s.has_rdoc = false
|
20
|
-
s.
|
20
|
+
s.add_runtime_dependency 'ruby-dbus-openplacos', '~> 0.7.0'
|
21
|
+
s.add_runtime_dependency 'json', '~> 1.7.0'
|
22
|
+
s.add_runtime_dependency 'oauth2', '~> 0.7.1'
|
21
23
|
end
|
metadata
CHANGED
@@ -1,87 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: openplacos
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 0.0.8
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Openplacos Team
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: ruby-dbus-openplacos
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.7.0
|
22
|
+
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.7.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
25
33
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 6
|
33
|
-
- 2
|
34
|
-
version: 0.6.2
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.7.0
|
35
38
|
type: :runtime
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: oauth2
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.7.1
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.1
|
62
|
+
description: ! " Openplacos Gem is a set of libraries for openplacos software.\n
|
63
|
+
\ These libraries allow an easier coding of openplacos clients, plugins or drivers
|
64
|
+
in ruby.\n"
|
65
|
+
email: openplacos@lists.tuxfamily.org
|
39
66
|
executables: []
|
40
|
-
|
41
67
|
extensions: []
|
42
|
-
|
43
68
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
69
|
+
files:
|
46
70
|
- VERSION
|
47
71
|
- lib/openplacos.rb
|
48
72
|
- lib/openplacos/libclient.rb
|
49
|
-
- lib/openplacos/
|
50
|
-
- lib/openplacos/
|
73
|
+
- lib/openplacos/libcomponent.rb
|
74
|
+
- lib/openplacos/template_client.rb
|
75
|
+
- lib/openplacos/widget/Analog.rb
|
76
|
+
- lib/openplacos/widget/Digital.rb
|
77
|
+
- lib/openplacos/widget/modules.rb
|
51
78
|
- openplacos.gemspec
|
52
|
-
|
53
|
-
|
54
|
-
licenses:
|
79
|
+
homepage: http://openplacos.tuxfamily.org/
|
80
|
+
licenses:
|
55
81
|
- GPL-3
|
56
82
|
post_install_message:
|
57
83
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
84
|
+
require_paths:
|
60
85
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
87
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
68
|
-
- 0
|
69
|
-
version: "0"
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
93
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
79
98
|
requirements: []
|
80
|
-
|
81
99
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 1.8.23
|
83
101
|
signing_key:
|
84
102
|
specification_version: 3
|
85
|
-
summary:
|
103
|
+
summary: ! 'Openplacos libraries : Libclient, LibPlugin, LibDriver'
|
86
104
|
test_files: []
|
87
|
-
|
data/lib/openplacos/libdriver.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
# This file is part of Openplacos.
|
2
|
-
#
|
3
|
-
# Openplacos is free software: you can redistribute it and/or modify
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
6
|
-
# (at your option) any later version.
|
7
|
-
#
|
8
|
-
# Openplacos is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with Openplacos. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
#
|
16
|
-
|
17
|
-
ENV["DBUS_THREADED_ACCESS"] = "1" #activate threaded dbus
|
18
|
-
require 'dbus-openplacos'
|
19
|
-
|
20
|
-
|
21
|
-
module Openplacos
|
22
|
-
module Driver
|
23
|
-
|
24
|
-
class GenericPin < DBus::Object
|
25
|
-
|
26
|
-
def set_off(iface_req_)
|
27
|
-
if (@init != iface_req_) # Iface changed, turn off previous one
|
28
|
-
if(self.methods.include?("exit_"+@init))
|
29
|
-
eval("exit_"+@init+"()")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def write(iface_, value_, option_)
|
36
|
-
|
37
|
-
set_off(iface_)
|
38
|
-
if (@input == 1)# Set output
|
39
|
-
if(self.methods.include?("set_output"))
|
40
|
-
self.set_output()
|
41
|
-
end
|
42
|
-
@input = 0;
|
43
|
-
end
|
44
|
-
|
45
|
-
if (@init != iface_) # If the iface needs to be init
|
46
|
-
if(self.methods.include?("init_"+iface_))
|
47
|
-
eval("init_#{iface_}()")
|
48
|
-
end
|
49
|
-
@init = iface_
|
50
|
-
end
|
51
|
-
eval("write_#{iface_}(value_, option_)")
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def add_write(iface_)
|
56
|
-
dbusdef = "dbus_interface 'org.openplacos.driver.#{iface_}' do
|
57
|
-
dbus_method :write, 'out return:v, in value:v, in option:a{sv}' do |value, option|
|
58
|
-
return self.write( \"#{iface_}\", value,option)
|
59
|
-
end
|
60
|
-
end"
|
61
|
-
|
62
|
-
self.singleton_class.instance_eval(dbusdef)
|
63
|
-
end
|
64
|
-
|
65
|
-
def read(iface_, option_)
|
66
|
-
set_off(iface_)
|
67
|
-
if (@input == 0)# Set input
|
68
|
-
if(self.methods.include?("set_input"))
|
69
|
-
self.set_input()
|
70
|
-
end
|
71
|
-
@input = 1;
|
72
|
-
end
|
73
|
-
|
74
|
-
eval("read_#{iface_}( option_)")
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
def add_read(iface_)
|
80
|
-
dbusdef = "dbus_interface 'org.openplacos.driver.#{iface_}' do
|
81
|
-
dbus_method :read, 'out return:v, in option:a{sv}' do |option|
|
82
|
-
return self.read(\"#{iface_}\", option)
|
83
|
-
end
|
84
|
-
end"
|
85
|
-
self.singleton_class.instance_eval(dbusdef)
|
86
|
-
end
|
87
|
-
|
88
|
-
def add_read_and_write(iface_) # dbus do not merge methods in interface if they are not define in the same time
|
89
|
-
dbusdef = "dbus_interface 'org.openplacos.driver.#{iface_}' do
|
90
|
-
dbus_method :read, 'out return:v, in option:a{sv}' do |option|
|
91
|
-
return self.read(\"#{iface_}\",option)
|
92
|
-
end
|
93
|
-
dbus_method :write, 'out return:v, in value:v, in option:a{sv}' do |value, option|
|
94
|
-
return self.write(\"#{iface_}\", value,option)
|
95
|
-
end
|
96
|
-
end"
|
97
|
-
|
98
|
-
self.singleton_class.instance_eval(dbusdef)
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def initialize(path_, write_intfs_, read_intfs_) # path name , an array of string of interface wich write methods, an array of
|
103
|
-
@init = ""
|
104
|
-
@input = nil
|
105
|
-
|
106
|
-
(write_intfs_ & read_intfs_).each { |iface|
|
107
|
-
self.add_read_and_write(iface)
|
108
|
-
self.instance_eval("self.extend(Module_write_#{iface})")
|
109
|
-
self.instance_eval("self.extend(Module_read_#{iface})")
|
110
|
-
write_intfs_.delete(iface)
|
111
|
-
read_intfs_.delete(iface)
|
112
|
-
}
|
113
|
-
|
114
|
-
write_intfs_.each{ |iface|
|
115
|
-
self.add_write(iface)
|
116
|
-
self.instance_eval("self.extend(Module_write_#{iface})")
|
117
|
-
}
|
118
|
-
|
119
|
-
read_intfs_.each{ |iface|
|
120
|
-
self.add_read(iface)
|
121
|
-
self.instance_eval("self.extend(Module_read_#{iface})")
|
122
|
-
}
|
123
|
-
super(path_)
|
124
|
-
self.extend(Other_common_fonctions)
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|