plantwatchdog 0.0.1
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/History.txt +4 -0
- data/License.txt +674 -0
- data/Manifest.txt +42 -0
- data/README.txt +91 -0
- data/Rakefile +22 -0
- data/bin/plantwatchdog +8 -0
- data/bin/upload_measurements +2 -0
- data/config.ru +35 -0
- data/config/app_config.yaml +10 -0
- data/lib/plantwatchdog/aggregation.rb +220 -0
- data/lib/plantwatchdog/aggregation_methods.rb +90 -0
- data/lib/plantwatchdog/data.rb +126 -0
- data/lib/plantwatchdog/db.rb +37 -0
- data/lib/plantwatchdog/gems.rb +5 -0
- data/lib/plantwatchdog/main.rb +76 -0
- data/lib/plantwatchdog/model.rb +442 -0
- data/lib/plantwatchdog/sinatra.rb +206 -0
- data/public/images/arrow-down.gif +0 -0
- data/public/images/arrow-left.gif +0 -0
- data/public/images/arrow-right.gif +0 -0
- data/public/images/arrow-up.gif +0 -0
- data/public/images/spinner.gif +0 -0
- data/public/images/tabs.png +0 -0
- data/public/js/customflot.js +120 -0
- data/public/js/jquery-1.3.2.min.js +19 -0
- data/public/js/jquery.flot.crosshair.js +157 -0
- data/public/js/jquery.flot.js +2119 -0
- data/public/js/jquery.flot.navigate.js +272 -0
- data/public/js/jquery.flot.selection.js +299 -0
- data/public/js/select-chain.js +71 -0
- data/public/js/tools.tabs-1.0.4.js +285 -0
- data/public/tabs.css +87 -0
- data/sample/solar/create_solar.rb +31 -0
- data/sample/solar/measurements/client.sqlite3 +0 -0
- data/sample/solar/static/devices.yml +17 -0
- data/sample/solar/static/metadata.yml +30 -0
- data/sample/solar/static/plants.yml +3 -0
- data/sample/solar/static/users.yml +4 -0
- data/sample/solar/upload_measurements +26 -0
- data/templates/graph.erb +134 -0
- data/templates/index.erb +24 -0
- data/templates/monthly_graph.erb +41 -0
- data/test/test_aggregation.rb +161 -0
- data/test/test_aggregation_methods.rb +50 -0
- data/test/test_base.rb +83 -0
- data/test/test_data.rb +118 -0
- data/test/test_model.rb +142 -0
- data/test/test_sync.rb +71 -0
- data/test/test_web.rb +87 -0
- metadata +167 -0
data/test/test_web.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__),"..")
|
3
|
+
require 'rubygems'
|
4
|
+
require 'plantwatchdog/sinatra'
|
5
|
+
require 'plantwatchdog/aggregation'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'rack/test'
|
8
|
+
require 'test/test_base'
|
9
|
+
|
10
|
+
set :environment, :test
|
11
|
+
|
12
|
+
module PlantWatchdog
|
13
|
+
class WebTest < Test::Unit::TestCase
|
14
|
+
include TestUtil
|
15
|
+
include Rack::Test::Methods
|
16
|
+
def app
|
17
|
+
PlantWatchdog::UI::SinatraApp
|
18
|
+
end
|
19
|
+
|
20
|
+
def prepare
|
21
|
+
inverter = create_inverter
|
22
|
+
sync("#{syncTime.tv_sec},20,#{etotal}")
|
23
|
+
sync("#{syncTime.tv_sec+3600*24},20,#{etotal+1}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def etotal
|
27
|
+
1003
|
28
|
+
end
|
29
|
+
|
30
|
+
def syncTime
|
31
|
+
Time.utc(2006, "jan", 20 , 12, 0, 0)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_available
|
35
|
+
prepare
|
36
|
+
get '/availabledata/2006'
|
37
|
+
assert last_response.ok?
|
38
|
+
assert_equal([{ "id" => 1, "label" => "1"}], ActiveSupport::JSON.decode( last_response.body ))
|
39
|
+
get '/availabledata/2006/1'
|
40
|
+
assert last_response.ok?
|
41
|
+
assert_equal([{ "id" => 20, "label" => "20"},{ "id" => 21, "label" => "21"}], ActiveSupport::JSON.decode( last_response.body ))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_timeseries
|
45
|
+
prepare
|
46
|
+
get '/rawdata/2006/1/20'
|
47
|
+
assert last_response.ok?
|
48
|
+
ts = ActiveSupport::JSON.decode( last_response.body )
|
49
|
+
assert_equal("123: etotal = 0", ts.first["label"])
|
50
|
+
assert_equal(etotal, ts.first["data"][0][1])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_monthly_plant
|
54
|
+
prepare
|
55
|
+
gen = user.plant
|
56
|
+
gen.aggrules = { "eday" => [:sum, "eday"] }
|
57
|
+
gen.save!
|
58
|
+
#Aggregation::Runner.new.run
|
59
|
+
get '/monthly/plant/2006/1'
|
60
|
+
ts = ActiveSupport::JSON.decode( last_response.body )
|
61
|
+
assert last_response.ok?
|
62
|
+
assert_equal(31, ts.first["data"].size)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_upload
|
66
|
+
authorize user.name, user.password
|
67
|
+
|
68
|
+
# the user has not created a device
|
69
|
+
assert_raise(Model::SyncError) do
|
70
|
+
get '/latestupload/device/123'
|
71
|
+
end
|
72
|
+
|
73
|
+
# user has not synced any data for the device
|
74
|
+
inverter = create_inverter
|
75
|
+
get '/latestupload/device/123'
|
76
|
+
assert last_response.ok?
|
77
|
+
assert_equal(0, last_response.body.to_i )
|
78
|
+
|
79
|
+
put '/upload/device/123', "#{syncTime.tv_sec},20,#{etotal}"
|
80
|
+
raise last_response.body unless last_response.ok?
|
81
|
+
# now the user has synced once
|
82
|
+
get '/latestupload/device/123'
|
83
|
+
assert last_response.ok?
|
84
|
+
assert_equal(syncTime.tv_sec, last_response.body.to_i )
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plantwatchdog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Plant Watchdog Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-09 00:00:00 +01:00
|
13
|
+
default_executable: plantwatchdog
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sinatra
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.4
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activerecord
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.5
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: patir
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.6.4
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: hoe
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.3.3
|
54
|
+
version:
|
55
|
+
description: |-
|
56
|
+
A watchdog for your technical plant, e.g. a photovoltaic generator. The plant
|
57
|
+
watchdog listens to data loggers, which continuously upload measurements of
|
58
|
+
plant parameters. Based on that data the watchdog creates reports about the
|
59
|
+
operational status.
|
60
|
+
|
61
|
+
== DESCRIPTION:
|
62
|
+
|
63
|
+
This software is being developed to monitor a photovoltaic generator. We found
|
64
|
+
that it would make sense to keep the domain specific knowledge out of the code
|
65
|
+
and instead provide a DSL to allow users to define their rules. Therefore this
|
66
|
+
software should be useful to monitor any kind of technical plant.
|
67
|
+
|
68
|
+
At the time being the focus of development is to
|
69
|
+
- make it reasonably stable
|
70
|
+
- run per-day aggregations
|
71
|
+
- show intraday and monthly diagrams
|
72
|
+
|
73
|
+
With more data being available the task of finding deviations from regular
|
74
|
+
operation is becoming feasible. Therefore expected values of parameters must
|
75
|
+
be calculated and compared with actual values: the users must be allowed to
|
76
|
+
define a model of the plant.
|
77
|
+
email: mbarchfe@rubyforge.org
|
78
|
+
executables:
|
79
|
+
- plantwatchdog
|
80
|
+
- upload_measurements
|
81
|
+
extensions: []
|
82
|
+
|
83
|
+
extra_rdoc_files:
|
84
|
+
- History.txt
|
85
|
+
- License.txt
|
86
|
+
- Manifest.txt
|
87
|
+
- README.txt
|
88
|
+
files:
|
89
|
+
- config.ru
|
90
|
+
- History.txt
|
91
|
+
- License.txt
|
92
|
+
- Manifest.txt
|
93
|
+
- README.txt
|
94
|
+
- Rakefile
|
95
|
+
- bin/plantwatchdog
|
96
|
+
- bin/upload_measurements
|
97
|
+
- config/app_config.yaml
|
98
|
+
- lib/plantwatchdog/aggregation.rb
|
99
|
+
- lib/plantwatchdog/aggregation_methods.rb
|
100
|
+
- lib/plantwatchdog/data.rb
|
101
|
+
- lib/plantwatchdog/db.rb
|
102
|
+
- lib/plantwatchdog/gems.rb
|
103
|
+
- lib/plantwatchdog/main.rb
|
104
|
+
- lib/plantwatchdog/model.rb
|
105
|
+
- lib/plantwatchdog/sinatra.rb
|
106
|
+
- public/images/arrow-down.gif
|
107
|
+
- public/images/arrow-left.gif
|
108
|
+
- public/images/arrow-right.gif
|
109
|
+
- public/images/arrow-up.gif
|
110
|
+
- public/images/spinner.gif
|
111
|
+
- public/images/tabs.png
|
112
|
+
- public/js/customflot.js
|
113
|
+
- public/js/jquery-1.3.2.min.js
|
114
|
+
- public/js/jquery.flot.crosshair.js
|
115
|
+
- public/js/jquery.flot.js
|
116
|
+
- public/js/jquery.flot.navigate.js
|
117
|
+
- public/js/jquery.flot.selection.js
|
118
|
+
- public/js/select-chain.js
|
119
|
+
- public/js/tools.tabs-1.0.4.js
|
120
|
+
- public/tabs.css
|
121
|
+
- sample/solar/create_solar.rb
|
122
|
+
- sample/solar/measurements/client.sqlite3
|
123
|
+
- sample/solar/static/devices.yml
|
124
|
+
- sample/solar/static/metadata.yml
|
125
|
+
- sample/solar/static/plants.yml
|
126
|
+
- sample/solar/static/users.yml
|
127
|
+
- sample/solar/upload_measurements
|
128
|
+
- templates/graph.erb
|
129
|
+
- templates/index.erb
|
130
|
+
- templates/monthly_graph.erb
|
131
|
+
has_rdoc: true
|
132
|
+
homepage:
|
133
|
+
licenses: []
|
134
|
+
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options:
|
137
|
+
- --main
|
138
|
+
- README.txt
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: "0"
|
146
|
+
version:
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: "0"
|
152
|
+
version:
|
153
|
+
requirements: []
|
154
|
+
|
155
|
+
rubyforge_project: pwd
|
156
|
+
rubygems_version: 1.3.5
|
157
|
+
signing_key:
|
158
|
+
specification_version: 3
|
159
|
+
summary: Plant Watchdog
|
160
|
+
test_files:
|
161
|
+
- test/test_aggregation.rb
|
162
|
+
- test/test_aggregation_methods.rb
|
163
|
+
- test/test_base.rb
|
164
|
+
- test/test_data.rb
|
165
|
+
- test/test_model.rb
|
166
|
+
- test/test_sync.rb
|
167
|
+
- test/test_web.rb
|