gom-sensor-ports 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.mkd +27 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/bin/gom-sensor-ports +41 -0
- data/lib/gom-sensor-ports.rb +3 -0
- data/lib/gom-sensor-ports/sensor-ports.rb +45 -0
- data/spec/gom-sensor-ports/sensor-ports_spec.rb +33 -0
- data/spec/gom-sensor-ports_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +13 -0
- metadata +139 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 dirk luesebrink
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.mkd
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# gom-sensor-ports
|
2
|
+
|
3
|
+
Easy access over the wire to a remote GOM node. This gem includes a GNP
|
4
|
+
callback server, support for automatic observer refreshments and command line
|
5
|
+
tools for reading, writing and observing GOM entries.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
use the jewler tasks:
|
10
|
+
|
11
|
+
$ rake gemspec build install
|
12
|
+
|
13
|
+
## Dependencies
|
14
|
+
|
15
|
+
## Note on Patches/Pull Requests
|
16
|
+
|
17
|
+
* Fork the project.
|
18
|
+
* Make your feature addition or bug fix.
|
19
|
+
* Add tests for it. This is important so I don't break it in a
|
20
|
+
future version unintentionally.
|
21
|
+
* Commit, do not mess with rakefile, version, or history.
|
22
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
23
|
+
* Send me a pull request. Bonus points for topic branches.
|
24
|
+
|
25
|
+
## Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2010 art+com AG/dirk luesebrink. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "gom-sensor-ports"
|
8
|
+
gem.summary = %Q{
|
9
|
+
gateway for barebone TCP/UCP reporting sensors to GOM/HTTP protocoll
|
10
|
+
}
|
11
|
+
gem.description = %Q{
|
12
|
+
This gems implements a gateway server to allow barebone basic sensor
|
13
|
+
components to report state change updates as simple protocol free udates
|
14
|
+
over TCP/UDP ports without the 'overhead' of the HTTP protocoll. For
|
15
|
+
example, a power sensor might just broadcast a four byte floating point
|
16
|
+
binary number once every second to an UCP port
|
17
|
+
}
|
18
|
+
gem.email = "dirk.luesebrink@gmail.com"
|
19
|
+
gem.homepage = "http://github.com/crux/gom-sensor-ports"
|
20
|
+
gem.authors = ["art+com AG/dirk luesebrink"]
|
21
|
+
|
22
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
23
|
+
gem.add_development_dependency "fakeweb"
|
24
|
+
|
25
|
+
gem.add_runtime_dependency "applix"
|
26
|
+
gem.add_runtime_dependency "gom-script"
|
27
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
28
|
+
end
|
29
|
+
Jeweler::GemcutterTasks.new
|
30
|
+
rescue LoadError
|
31
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'spec/rake/spectask'
|
35
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
36
|
+
spec.libs << 'lib' << 'spec'
|
37
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
38
|
+
end
|
39
|
+
|
40
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
41
|
+
spec.libs << 'lib' << 'spec'
|
42
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
43
|
+
spec.rcov = true
|
44
|
+
end
|
45
|
+
|
46
|
+
task :spec => :check_dependencies
|
47
|
+
|
48
|
+
task :default => :spec
|
49
|
+
|
50
|
+
require 'rake/rdoctask'
|
51
|
+
Rake::RDocTask.new do |rdoc|
|
52
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "gom-sensor-ports #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'applix'
|
5
|
+
|
6
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
7
|
+
require 'gom-sensor-ports'
|
8
|
+
|
9
|
+
#Thread.abort_on_exception = true
|
10
|
+
$stderr.sync = true
|
11
|
+
$stdout.sync = true
|
12
|
+
|
13
|
+
class Usage < ArgumentError; end
|
14
|
+
|
15
|
+
def main argv
|
16
|
+
options = Hash.from_argv argv
|
17
|
+
args = (options.delete :args)
|
18
|
+
#options[:callback_port] ||= 32119
|
19
|
+
|
20
|
+
sensor_url = args.shift
|
21
|
+
sensor_url or (raise Usage, "no <sensor_url>")
|
22
|
+
puts " -- starting gom-sensor-port daemon: #{Time.now}"
|
23
|
+
|
24
|
+
Gom::Remote::Daemon.new(sensor_url, options) do |daemon, path|
|
25
|
+
sp = Gom::SensorPorts.new path, options
|
26
|
+
daemon.sensor_loop { sp.listen }
|
27
|
+
end
|
28
|
+
|
29
|
+
rescue Usage => e
|
30
|
+
puts <<-TXT
|
31
|
+
|
32
|
+
usage: #{__FILE__} <sensor port URL>
|
33
|
+
|
34
|
+
## #{e}
|
35
|
+
TXT
|
36
|
+
rescue => e
|
37
|
+
puts " ## #{e}\n -> #{e.backtrace.join "\n "}"
|
38
|
+
end
|
39
|
+
|
40
|
+
main ARGV
|
41
|
+
# vim: syntax=ruby
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Gom
|
2
|
+
class SensorPorts < Gom::Remote::Entry
|
3
|
+
|
4
|
+
Defaults = {
|
5
|
+
:interface => '0.0.0.0',
|
6
|
+
:port => 99123,
|
7
|
+
:mode => :udp,
|
8
|
+
}
|
9
|
+
|
10
|
+
include OAttr
|
11
|
+
oattr :interface, :port, :mode
|
12
|
+
|
13
|
+
def initialize path, options = {}
|
14
|
+
@path = path
|
15
|
+
@options = Defaults.merge(gnode @path).merge(options)
|
16
|
+
puts " -- new sensor port: #{self.inspect}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def listen
|
20
|
+
puts " -- listen: #{self.inspect}"
|
21
|
+
self.send "listen_#{mode}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def listen_udp
|
25
|
+
socket = UDPSocket.new
|
26
|
+
socket.bind(interface, port)
|
27
|
+
loop do
|
28
|
+
msg, sender = socket.recvfrom(1024)
|
29
|
+
puts "-->#{msg}<-- #{sender.inspect}"
|
30
|
+
end
|
31
|
+
ensure
|
32
|
+
socket.close rescue nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def status
|
36
|
+
puts @options.inspect
|
37
|
+
#t = Net::Telnet::new(
|
38
|
+
# "Host" => device_ip, "Timeout" => 10, "Prompt" => /[$%#>] \z/n
|
39
|
+
#)
|
40
|
+
#t.login(user, password) { |c| puts c }
|
41
|
+
"not implemented"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Gom::SensorPorts" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
$gom = Gom::Remote.connection = Object.new
|
7
|
+
(Gom::Remote::Connection.stub! :new).and_return $gom
|
8
|
+
($gom.stub! :read).with('/gom/sensor-ports.json').and_return(<<-JSON)
|
9
|
+
{
|
10
|
+
"node": {
|
11
|
+
"uri": "/services/viko/work",
|
12
|
+
"mtime": "2010-01-06T15:14:57+01:00",
|
13
|
+
"ctime": "2010-01-06T15:14:57+01:00",
|
14
|
+
"entries": [
|
15
|
+
{ "attribute": {
|
16
|
+
"name": "status",
|
17
|
+
"node": "/services/viko/work",
|
18
|
+
"value": "<void>",
|
19
|
+
"type": "string",
|
20
|
+
"mtime": "2010-01-07T19:30:36+01:00",
|
21
|
+
"ctime": "2010-01-07T19:30:36+01:00"
|
22
|
+
} }
|
23
|
+
]
|
24
|
+
}
|
25
|
+
}
|
26
|
+
JSON
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should dump status" do
|
30
|
+
station = Gom::SensorPorts.new '/gom/sensor-ports'
|
31
|
+
station.status.should_not == nil
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --backtrace --debugger
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#$:.unshift(File.dirname(__FILE__))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
require 'gom-sensor-ports'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
require 'fakeweb'
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
config.before :each do
|
11
|
+
FakeWeb.allow_net_connect = false
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gom-sensor-ports
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- art+com AG/dirk luesebrink
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-15 00:00:00 +02:00
|
19
|
+
default_executable: gom-sensor-ports
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: fakeweb
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: applix
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: gom-script
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
type: :runtime
|
78
|
+
version_requirements: *id004
|
79
|
+
description: "\n This gems implements a gateway server to allow barebone basic sensor\n components to report state change updates as simple protocol free udates\n over TCP/UDP ports without the 'overhead' of the HTTP protocoll. For\n example, a power sensor might just broadcast a four byte floating point\n binary number once every second to an UCP port\n "
|
80
|
+
email: dirk.luesebrink@gmail.com
|
81
|
+
executables:
|
82
|
+
- gom-sensor-ports
|
83
|
+
extensions: []
|
84
|
+
|
85
|
+
extra_rdoc_files:
|
86
|
+
- LICENSE
|
87
|
+
- README.mkd
|
88
|
+
files:
|
89
|
+
- .document
|
90
|
+
- .gitignore
|
91
|
+
- LICENSE
|
92
|
+
- README.mkd
|
93
|
+
- Rakefile
|
94
|
+
- VERSION
|
95
|
+
- bin/gom-sensor-ports
|
96
|
+
- lib/gom-sensor-ports.rb
|
97
|
+
- lib/gom-sensor-ports/sensor-ports.rb
|
98
|
+
- spec/gom-sensor-ports/sensor-ports_spec.rb
|
99
|
+
- spec/gom-sensor-ports_spec.rb
|
100
|
+
- spec/spec.opts
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
has_rdoc: true
|
103
|
+
homepage: http://github.com/crux/gom-sensor-ports
|
104
|
+
licenses: []
|
105
|
+
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options:
|
108
|
+
- --charset=UTF-8
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
requirements: []
|
130
|
+
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 1.3.7
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: gateway for barebone TCP/UCP reporting sensors to GOM/HTTP protocoll
|
136
|
+
test_files:
|
137
|
+
- spec/gom-sensor-ports/sensor-ports_spec.rb
|
138
|
+
- spec/gom-sensor-ports_spec.rb
|
139
|
+
- spec/spec_helper.rb
|