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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53873386c274f4259d283b97c153f7edeb1649a7
4
- data.tar.gz: 9bec1a6d15af011369aa6b7e59c1e64ce3df77d1
3
+ metadata.gz: 1e5dbc57fff437a1ee58663fdebc105f4470a45d
4
+ data.tar.gz: a1db5c7da0ec79f0eaf6b55c95bd2708e881925c
5
5
  SHA512:
6
- metadata.gz: 9036d28f3317a76cc2a1ef61f7106916536507babf822a1b458ca7da206b9863e3c385ef01e803c358f43b3a9e4623d0e2ce2f79e4401affc24cd6b2f656e91f
7
- data.tar.gz: df69ac9c1589916f2b9450327a93d99d415b0d3b0bac67484d0e1e035be36792501621dae198d9882bf96f531dfd43926a3e11b72214abbd95e127ea6829ae63
6
+ metadata.gz: 26d88093c6b9d59acc5d02c92f7682d5b4810163244cf3f65be1c434c1f1ecaf481143c57225c6e0a62bda6e76a2f820f763adc934a2fddf4374d97d97eccd33
7
+ data.tar.gz: 67a021570361f954ad74b7c64a9d73e80ea0008bb94bd92041914e9ce18597609152c9cfe4e9339afad3b51094b7f81568cd132cca00d69162b1a166d0254848
data/COPYING CHANGED
@@ -1,7 +1,14 @@
1
- This software is released under the Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0) licence.
2
- for more information see: http://creativecommons.org/licenses/by-nc/3.0/
1
+ This file is part of Ardtweeno.
3
2
 
4
- All code is distributed in the hope that it will be useful, but WITHOUT
5
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6
- FITNESS FOR A PARTICULAR PURPOSE.
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 "sinatra", ">= 1.3.3"
28
- gem "thin", ">= 1.5.0"
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.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.10.0)
12
- bson_ext (1.10.0)
13
- bson (~> 1.10.0)
14
- daemons (1.1.9)
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
- dotenv (0.10.0)
17
- ethon (0.7.0)
16
+ ethon (0.8.1)
18
17
  ffi (>= 1.3.0)
19
- eventmachine (1.0.3)
20
- ffi (1.9.3)
21
- foreman (0.63.0)
22
- dotenv (>= 0.7)
23
- thor (>= 0.13.6)
24
- json (1.8.1)
25
- mini_portile (0.5.3)
26
- mongo (1.10.0)
27
- bson (~> 1.10.0)
28
- nokogiri (1.6.1)
29
- mini_portile (~> 0.5.0)
30
- rack (1.5.2)
31
- rack-protection (1.5.2)
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.2)
32
+ rack-test (0.6.3)
34
33
  rack (>= 1.0)
35
- rake (10.2.2)
36
- rspec (2.14.1)
37
- rspec-core (~> 2.14.0)
38
- rspec-expectations (~> 2.14.0)
39
- rspec-mocks (~> 2.14.0)
40
- rspec-core (2.14.8)
41
- rspec-expectations (2.14.5)
42
- diff-lcs (>= 1.1.3, < 2.0)
43
- rspec-mocks (2.14.6)
44
- serialport (1.3.0)
45
- sinatra (1.4.4)
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 (~> 1.3, >= 1.3.4)
49
- test-unit (2.5.5)
50
- thin (1.6.2)
51
- daemons (>= 1.0.9)
52
- eventmachine (>= 1.0.0)
53
- rack (>= 1.0.0)
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 (1.4.1)
56
- typhoeus (0.6.8)
57
- ethon (>= 0.7.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 02-07-2013
5
+ # @date 2014-05-20
6
6
  ####################################################################################################
7
7
 
8
- # Ardtweeno MVP - Installation instructions
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 use the _bundle_ utility to install the dependencies. Use the _rake_ utility to build and
12
- install the gem.
11
+ _ardtweeno-gem_ directory then:
13
12
 
14
- Tests can be run with the _rake test_ command from the _ardtweeno-gem_ folder.
13
+ _bundle install_
14
+ _rake install_
15
15
 
16
- To launch the system, simply type _foreman start -f Procfile -p <port>_ from the _ardtweeno-gem_ folder.
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 Creative Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)
32
- for more information see the full details of this licence here: http://creativecommons.org/licenses/by-nc/3.0/
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 Gem Rakefile
4
+ # @description Ardtweeno Gateway
4
5
  #
5
- # @date 02-07-2013
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 => 'menu'
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 14-06-2013
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 API class for the Ardtweeno system
4
+ # @description Ardtweeno Gateway
4
5
  #
5
- # @date 2013-08-05
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