ardtweeno 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING +12 -5
- data/Gemfile +10 -19
- data/Gemfile.lock +49 -41
- data/INSTALL +8 -6
- data/README.md +2 -2
- data/Rakefile +20 -3
- data/lib/ardtweeno.rb +19 -1
- data/lib/ardtweeno/api.rb +94 -11
- data/lib/ardtweeno/configreader.rb +20 -3
- data/lib/ardtweeno/db.rb +20 -3
- data/lib/ardtweeno/dispatcher.rb +42 -23
- data/lib/ardtweeno/exceptions.rb +27 -1
- data/lib/ardtweeno/node.rb +21 -3
- data/lib/ardtweeno/nodemanager.rb +20 -3
- data/lib/ardtweeno/packet.rb +24 -6
- data/lib/ardtweeno/restapi.rb +40 -7
- data/lib/ardtweeno/ringbuffer.rb +19 -2
- data/lib/ardtweeno/serialparser.rb +19 -2
- data/public/main.css +3 -8
- data/resources/puma.rb +7 -0
- data/test/api_test.rb +24 -0
- data/test/debug/tty0tty-1.1/pts/tty0tty +0 -0
- data/test/dispatcher_test.rb +19 -2
- data/test/node_test.rb +19 -2
- data/test/nodemanager_test.rb +19 -2
- data/test/packet_test.rb +23 -6
- data/test/parser_test.rb +19 -2
- data/test/rest_api_test.rb +24 -0
- data/test/ringbuffer_test.rb +19 -2
- data/test/serialport_mock.rb +19 -2
- data/test/test_helper.rb +19 -2
- data/views/index.erb +5 -9
- data/views/lineplot.erb +55 -0
- data/views/status.erb +1 -1
- metadata +35 -8
- data/Procfile +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e5dbc57fff437a1ee58663fdebc105f4470a45d
|
4
|
+
data.tar.gz: a1db5c7da0ec79f0eaf6b55c95bd2708e881925c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26d88093c6b9d59acc5d02c92f7682d5b4810163244cf3f65be1c434c1f1ecaf481143c57225c6e0a62bda6e76a2f820f763adc934a2fddf4374d97d97eccd33
|
7
|
+
data.tar.gz: 67a021570361f954ad74b7c64a9d73e80ea0008bb94bd92041914e9ce18597609152c9cfe4e9339afad3b51094b7f81568cd132cca00d69162b1a166d0254848
|
data/COPYING
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
This
|
2
|
-
for more information see: http://creativecommons.org/licenses/by-nc/3.0/
|
1
|
+
This file is part of Ardtweeno.
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
Ardtweeno 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
|
+
any later version.
|
7
7
|
|
8
|
+
Ardtweeno 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 Ardtweeno. If not, see <http://www.gnu.org/licenses/>.
|
data/Gemfile
CHANGED
@@ -1,28 +1,19 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
# The Ardtweeno Application Gateway
|
4
|
-
gem "ardtweeno"
|
5
|
-
|
6
|
-
# Utility
|
7
|
-
gem "rake"
|
8
|
-
gem "nokogiri"
|
9
|
-
gem "rack", ">= 1.1"
|
10
|
-
gem "foreman"
|
11
|
-
gem "json"
|
12
|
-
gem "typhoeus", ">= 0.6.3"
|
13
|
-
|
14
|
-
# For the Database
|
15
|
-
gem "mongo", ">= 1.6.2"
|
16
|
-
gem "bson_ext", ">= 1.6.2"
|
17
3
|
|
18
4
|
# For Testing
|
19
5
|
gem "rack-test"
|
20
6
|
gem "test-unit"
|
7
|
+
gem "pry"
|
8
|
+
gem "pry-byebug"
|
21
9
|
gem "rspec", :require => "spec"
|
22
10
|
|
23
|
-
# For the SerialParser
|
24
|
-
gem "serialport", ">= 1.1.0"
|
25
|
-
|
26
11
|
# For the HTTP REST API
|
27
|
-
gem "
|
28
|
-
gem "
|
12
|
+
gem "ardtweeno", "0.6.0", :path => "./"
|
13
|
+
gem "rake"
|
14
|
+
gem "sinatra"
|
15
|
+
gem "puma"
|
16
|
+
gem "typhoeus", ">= 0.6.3"
|
17
|
+
gem "serialport", ">= 1.1.0"
|
18
|
+
gem "mongo"
|
19
|
+
gem "bson_ext"
|
data/Gemfile.lock
CHANGED
@@ -1,60 +1,65 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
ardtweeno (0.
|
4
|
+
ardtweeno (0.5.0)
|
5
5
|
bson_ext (>= 1.6.2)
|
6
6
|
bundler (>= 1.2.3)
|
7
7
|
mongo (>= 1.6.2)
|
8
8
|
sinatra (>= 1.3.3)
|
9
9
|
thin (>= 1.5.0)
|
10
10
|
typhoeus (>= 0.6.3)
|
11
|
-
bson (1.
|
12
|
-
bson_ext (1.
|
13
|
-
bson (~> 1.
|
14
|
-
daemons (1.
|
11
|
+
bson (1.12.5)
|
12
|
+
bson_ext (1.12.5)
|
13
|
+
bson (~> 1.12.5)
|
14
|
+
daemons (1.2.3)
|
15
15
|
diff-lcs (1.2.5)
|
16
|
-
|
17
|
-
ethon (0.7.0)
|
16
|
+
ethon (0.8.1)
|
18
17
|
ffi (>= 1.3.0)
|
19
|
-
eventmachine (1.0.
|
20
|
-
ffi (1.9.
|
21
|
-
foreman (0.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
rack (1.
|
31
|
-
rack-protection (1.5.
|
18
|
+
eventmachine (1.0.9.1)
|
19
|
+
ffi (1.9.10)
|
20
|
+
foreman (0.78.0)
|
21
|
+
thor (~> 0.19.1)
|
22
|
+
json (1.8.3)
|
23
|
+
mini_portile2 (2.0.0)
|
24
|
+
mongo (1.12.5)
|
25
|
+
bson (= 1.12.5)
|
26
|
+
nokogiri (1.6.7.2)
|
27
|
+
mini_portile2 (~> 2.0.0.rc2)
|
28
|
+
power_assert (0.2.7)
|
29
|
+
rack (1.6.4)
|
30
|
+
rack-protection (1.5.3)
|
32
31
|
rack
|
33
|
-
rack-test (0.6.
|
32
|
+
rack-test (0.6.3)
|
34
33
|
rack (>= 1.0)
|
35
|
-
rake (10.
|
36
|
-
rspec (
|
37
|
-
rspec-core (~>
|
38
|
-
rspec-expectations (~>
|
39
|
-
rspec-mocks (~>
|
40
|
-
rspec-core (
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
rake (10.5.0)
|
35
|
+
rspec (3.4.0)
|
36
|
+
rspec-core (~> 3.4.0)
|
37
|
+
rspec-expectations (~> 3.4.0)
|
38
|
+
rspec-mocks (~> 3.4.0)
|
39
|
+
rspec-core (3.4.1)
|
40
|
+
rspec-support (~> 3.4.0)
|
41
|
+
rspec-expectations (3.4.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.4.0)
|
44
|
+
rspec-mocks (3.4.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.4.0)
|
47
|
+
rspec-support (3.4.1)
|
48
|
+
serialport (1.3.1)
|
49
|
+
sinatra (1.4.6)
|
46
50
|
rack (~> 1.4)
|
47
51
|
rack-protection (~> 1.4)
|
48
|
-
tilt (
|
49
|
-
test-unit (
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
tilt (>= 1.3, < 3)
|
53
|
+
test-unit (3.1.7)
|
54
|
+
power_assert
|
55
|
+
thin (1.6.4)
|
56
|
+
daemons (~> 1.0, >= 1.0.9)
|
57
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
58
|
+
rack (~> 1.0)
|
54
59
|
thor (0.19.1)
|
55
|
-
tilt (
|
56
|
-
typhoeus (0.
|
57
|
-
ethon (>= 0.
|
60
|
+
tilt (2.0.2)
|
61
|
+
typhoeus (1.0.1)
|
62
|
+
ethon (>= 0.8.0)
|
58
63
|
|
59
64
|
PLATFORMS
|
60
65
|
ruby
|
@@ -75,3 +80,6 @@ DEPENDENCIES
|
|
75
80
|
test-unit
|
76
81
|
thin (>= 1.5.0)
|
77
82
|
typhoeus (>= 0.6.3)
|
83
|
+
|
84
|
+
BUNDLED WITH
|
85
|
+
1.11.2
|
data/INSTALL
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
# @author David Kirwan https://github.com/davidkirwan/ardtweeno
|
3
3
|
# @description Ardtweeno Gem Installation Instructions
|
4
4
|
#
|
5
|
-
# @date
|
5
|
+
# @date 2014-05-20
|
6
6
|
####################################################################################################
|
7
7
|
|
8
|
-
# Ardtweeno
|
8
|
+
# Ardtweeno - Installation instructions
|
9
9
|
The Ardtweeno system can be installed from https://rubygems.org/gems/ardtweeno through the _gem_ utility, or by checking
|
10
10
|
out the code from the git repository on https://github.com/davidkirwan/ardtweeno. To install change directory to the
|
11
|
-
_ardtweeno-gem_ directory then
|
12
|
-
install the gem.
|
11
|
+
_ardtweeno-gem_ directory then:
|
13
12
|
|
14
|
-
|
13
|
+
_bundle install_
|
14
|
+
_rake install_
|
15
15
|
|
16
|
-
|
16
|
+
Tests can be run with the _rake test_ command from the ./ardtweeno-gem folder.
|
17
|
+
|
18
|
+
To launch the system, simply type _rackup_ from the _ardtweeno-gem_ folder.
|
data/README.md
CHANGED
@@ -28,8 +28,8 @@ If you would like to collaborate with me on this project please fork the reposit
|
|
28
28
|
through a pull request! I gladly welcome constructive input!
|
29
29
|
|
30
30
|
# COPYING / Licence
|
31
|
-
This software is released under the
|
32
|
-
for more information see the full details of this licence here: http://
|
31
|
+
This software is released under the GNU General Public License 3.0 (GPL 3.0)
|
32
|
+
for more information see the full details of this licence here: http://www.gnu.org/licenses/
|
33
33
|
|
34
34
|
For information regarding commercial use of the Ardtweeno Gateway, please contact the author at:
|
35
35
|
davidkirwanirl (_at_) gmail dot com or through Twitter at @kirwan\_david
|
data/Rakefile
CHANGED
@@ -1,10 +1,27 @@
|
|
1
|
+
=begin
|
1
2
|
####################################################################################################
|
2
3
|
# @author David Kirwan https://github.com/davidkirwan/ardtweeno
|
3
|
-
# @description Ardtweeno
|
4
|
+
# @description Ardtweeno Gateway
|
4
5
|
#
|
5
|
-
# @date
|
6
|
+
# @date 2014-08-12
|
6
7
|
####################################################################################################
|
7
8
|
|
9
|
+
This file is part of Ardtweeno.
|
10
|
+
|
11
|
+
Ardtweeno is free software: you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU General Public License as published by
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
14
|
+
any later version.
|
15
|
+
|
16
|
+
Ardtweeno is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU General Public License
|
22
|
+
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
=end
|
24
|
+
|
8
25
|
begin
|
9
26
|
require 'bundler'
|
10
27
|
Bundler::GemHelper.install_tasks
|
@@ -13,7 +30,7 @@ rescue Exception => e
|
|
13
30
|
end
|
14
31
|
|
15
32
|
|
16
|
-
task :default => '
|
33
|
+
task :default => 'test'
|
17
34
|
|
18
35
|
task :menu do
|
19
36
|
puts welcomeMsg = <<-MSG
|
data/lib/ardtweeno.rb
CHANGED
@@ -1,12 +1,30 @@
|
|
1
|
+
=begin
|
1
2
|
####################################################################################################
|
2
3
|
# @author David Kirwan https://github.com/davidkirwan/ardtweeno
|
3
4
|
# @description Ardtweeno Gateway
|
4
5
|
#
|
5
|
-
# @date
|
6
|
+
# @date 2014-08-12
|
6
7
|
####################################################################################################
|
7
8
|
|
9
|
+
This file is part of Ardtweeno.
|
10
|
+
|
11
|
+
Ardtweeno is free software: you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU General Public License as published by
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
14
|
+
any later version.
|
15
|
+
|
16
|
+
Ardtweeno is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU General Public License
|
22
|
+
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
=end
|
24
|
+
|
8
25
|
require 'logger'
|
9
26
|
require 'fileutils'
|
27
|
+
require 'pry'
|
10
28
|
require 'ardtweeno/serialparser'
|
11
29
|
require 'ardtweeno/dispatcher'
|
12
30
|
require 'ardtweeno/exceptions'
|
data/lib/ardtweeno/api.rb
CHANGED
@@ -1,15 +1,33 @@
|
|
1
|
+
=begin
|
1
2
|
####################################################################################################
|
2
3
|
# @author David Kirwan https://github.com/davidkirwan/ardtweeno
|
3
|
-
# @description
|
4
|
+
# @description Ardtweeno Gateway
|
4
5
|
#
|
5
|
-
# @date
|
6
|
+
# @date 2014-08-12
|
6
7
|
####################################################################################################
|
7
8
|
|
9
|
+
This file is part of Ardtweeno.
|
10
|
+
|
11
|
+
Ardtweeno is free software: you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU General Public License as published by
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
14
|
+
any later version.
|
15
|
+
|
16
|
+
Ardtweeno is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU General Public License
|
22
|
+
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
=end
|
24
|
+
|
8
25
|
# Imports
|
9
26
|
require 'logger'
|
10
27
|
require 'yaml'
|
11
28
|
require 'json'
|
12
29
|
require 'date'
|
30
|
+
require 'time'
|
13
31
|
|
14
32
|
module Ardtweeno
|
15
33
|
|
@@ -479,18 +497,25 @@ module Ardtweeno
|
|
479
497
|
@log.debug "handleLength function executing"
|
480
498
|
|
481
499
|
modifiedArray = Array.new
|
500
|
+
length = 0
|
482
501
|
|
483
502
|
if theParams.has_key?(:length) and theParams[:length].to_i < 100
|
484
503
|
length = theParams[:length].to_i
|
504
|
+
|
485
505
|
@log.debug "theParams has a length value of #{length}"
|
486
506
|
else
|
487
507
|
length = 100
|
488
508
|
@log.debug "Defaulting to the default length of #{length}"
|
489
509
|
end
|
490
510
|
|
491
|
-
|
492
511
|
if theArray.size > length
|
493
512
|
@log.debug "Length is smaller than the size of theArray"
|
513
|
+
|
514
|
+
if theParams[:graph]
|
515
|
+
length = theArray.size;
|
516
|
+
@log.debug "This is a graph, setting packets length to max size"
|
517
|
+
end
|
518
|
+
|
494
519
|
(0..(length - 1)).step(1) do |i|
|
495
520
|
modifiedArray << theArray[i]
|
496
521
|
end
|
@@ -708,7 +733,6 @@ module Ardtweeno
|
|
708
733
|
end
|
709
734
|
|
710
735
|
|
711
|
-
|
712
736
|
##
|
713
737
|
# Ardtweeno::API#buildPunchcard generate the data used in the Punchcard graph
|
714
738
|
#
|
@@ -724,20 +748,17 @@ module Ardtweeno
|
|
724
748
|
@log = Ardtweeno.options[:log] ||= Logger.new(STDOUT)
|
725
749
|
@log.level = Ardtweeno.options[:level] ||= Logger::WARN
|
726
750
|
|
727
|
-
theParams = Hash.new
|
728
|
-
theParams[:node] = params[:node]
|
729
|
-
|
730
751
|
data = Array.new
|
731
752
|
days = Array.new
|
732
753
|
|
733
754
|
today = DateTime.now
|
734
|
-
|
755
|
+
|
735
756
|
theStart = today - 6
|
736
757
|
|
737
758
|
theStartDay = "%02d" % theStart.day
|
738
759
|
theStartMonth = "%02d" % theStart.month
|
739
760
|
theStartYear = theStart.year.to_s
|
740
|
-
|
761
|
+
|
741
762
|
theEndDay = "%02d" % today.day
|
742
763
|
theEndMonth = "%02d" % today.month
|
743
764
|
theEndYear = today.year.to_s
|
@@ -752,12 +773,12 @@ module Ardtweeno
|
|
752
773
|
theDay = theStart.strftime('%a')
|
753
774
|
days << theDay
|
754
775
|
@log.debug theDay
|
755
|
-
|
776
|
+
|
756
777
|
(0..23).each do |j|
|
757
778
|
theDate = theStart.year.to_s + "-" + "%02d" % theStart.month + "-" + "%02d" % i.day
|
758
779
|
theHour = "%02d" % j
|
759
780
|
|
760
|
-
theParams = {:hour=>theHour, :date=>theDate}
|
781
|
+
theParams = {:hour=>theHour, :date=>theDate, :node=>params[:node], :graph=>true}
|
761
782
|
|
762
783
|
nodes = Ardtweeno::API.retrievepackets(nodeList, theParams)
|
763
784
|
|
@@ -773,6 +794,68 @@ module Ardtweeno
|
|
773
794
|
end
|
774
795
|
|
775
796
|
|
797
|
+
##
|
798
|
+
# Ardtweeno::API#buildLineplot generate the data used in the Line Plot graph
|
799
|
+
#
|
800
|
+
# * *Args* :
|
801
|
+
# - ++ -> Array of Ardtweeno::Node, Hash params
|
802
|
+
# * *Returns* :
|
803
|
+
# - Array Fixnum, 168 data hourly packet total values for last week,
|
804
|
+
# Array String previous 7 day names
|
805
|
+
# * *Raises* :
|
806
|
+
#
|
807
|
+
#
|
808
|
+
def buildLineplot(nodeList, params)
|
809
|
+
@log = Ardtweeno.options[:log] ||= Logger.new(STDOUT)
|
810
|
+
@log.level = Ardtweeno.options[:level] ||= Logger::WARN
|
811
|
+
|
812
|
+
colour_codes = ["#40FF00", "#FFFF00", "#FF8000", "#FF4000", "#FE2E2E", "#FF0080", "#FF00FF", "#8000FF", "#0000FF", "#0080FF"]
|
813
|
+
|
814
|
+
theParams = Hash.new
|
815
|
+
theParams[:node] = params[:node]
|
816
|
+
|
817
|
+
data = Array.new
|
818
|
+
|
819
|
+
nodes = Ardtweeno::API.retrievenodes(nodeList, {:name=>params[:node]})
|
820
|
+
packets = Ardtweeno::API.retrievepackets(nodeList, theParams)
|
821
|
+
|
822
|
+
nodes[:nodes][0][:sensors].each_with_index do |i, index|
|
823
|
+
data << {"label"=>i, "color"=>colour_codes[index], "data"=>[]}
|
824
|
+
end
|
825
|
+
|
826
|
+
unless packets[:packets].empty?
|
827
|
+
packets[:packets].each do |i|
|
828
|
+
|
829
|
+
year, month, day = i.date.split("-")
|
830
|
+
hour = i.hour
|
831
|
+
minute = i.minute
|
832
|
+
second = i.second
|
833
|
+
|
834
|
+
time = Time.new(year, month, day, hour, minute, second).to_i * 1000
|
835
|
+
|
836
|
+
unless i.data.empty?
|
837
|
+
i.data.each_with_index do |j, index|
|
838
|
+
data[index]["data"] << [time, j]
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
842
|
+
end
|
843
|
+
end
|
844
|
+
|
845
|
+
return data.to_json
|
846
|
+
end
|
847
|
+
|
848
|
+
|
849
|
+
##
|
850
|
+
# Ardtweeno::API#status generate a status report for the system
|
851
|
+
#
|
852
|
+
# * *Args* :
|
853
|
+
# - ++ ->
|
854
|
+
# * *Returns* :
|
855
|
+
# - {Fixednum :cpuload, Fixedmem :memload}
|
856
|
+
# * *Raises* :
|
857
|
+
#
|
858
|
+
#
|
776
859
|
def status
|
777
860
|
@log = Ardtweeno.options[:log] ||= Logger.new(STDOUT)
|
778
861
|
@log.level = Ardtweeno.options[:level] ||= Logger::DEBUG
|