From 6870ba24f31947d576518e6395b47f225a51140b Mon Sep 17 00:00:00 2001 From: Stuart Auld Date: Mon, 16 May 2016 11:38:55 +1000 Subject: [PATCH 1/4] add #current_annual_load for AEMO::NMI --- lib/aemo/nmi.rb | 9 ++++++++- spec/lib/aemo/nmi_spec.rb | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/aemo/nmi.rb b/lib/aemo/nmi.rb index f0ee6b0..bd52020 100644 --- a/lib/aemo/nmi.rb +++ b/lib/aemo/nmi.rb @@ -603,13 +603,20 @@ def data_streams_by_status(status = 'A') @data_streams.select { |x| x.status == status.to_s } end - # The current daily load + # The current daily load in kWh # # @return [Integer] the current daily load for the meter def current_daily_load data_streams_by_status.map { |x| x.averaged_daily_load.to_i }.inject(0, :+) end + # The current annual load in MWh + # + # @return [Integer] the current annual load for the meter + def current_annual_load + (current_daily_load * 365.25 / 1000).to_i + end + # A function to validate the NMI provided # # @param nmi [String] the nmi to be checked diff --git a/spec/lib/aemo/nmi_spec.rb b/spec/lib/aemo/nmi_spec.rb index a8acef7..24ff310 100644 --- a/spec/lib/aemo/nmi_spec.rb +++ b/spec/lib/aemo/nmi_spec.rb @@ -146,6 +146,13 @@ end end + describe '#current_annual_load' do + it 'should return zero for no data' do + @nmi = AEMO::NMI.new('4001234567') + expect(@nmi.current_daily_load).to eq(0) + end + end + describe '#meters_by_status' do before(:each) do @nmi = AEMO::NMI.new('4001234567') From c55cfbbfb8deb7918a1a130af2fee6d32b7ac290 Mon Sep 17 00:00:00 2001 From: Stuart Auld Date: Mon, 16 May 2016 16:29:33 +1000 Subject: [PATCH 2/4] bump version --- lib/aemo/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aemo/version.rb b/lib/aemo/version.rb index 685e8ad..085cc6f 100644 --- a/lib/aemo/version.rb +++ b/lib/aemo/version.rb @@ -22,7 +22,7 @@ # @author Joel Courtney module AEMO # aemo version - VERSION = '0.1.28'.freeze + VERSION = '0.1.29'.freeze # aemo version split amongst different revisions MAJOR_VERSION, MINOR_VERSION, REVISION = VERSION.split('.').map(&:to_i) From de7ee9e83450cef3e4cd2c67d7c01623ebca7d52 Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Tue, 14 Jun 2016 15:02:18 +1000 Subject: [PATCH 3/4] Update to use proper year length of 365.2425 --- lib/aemo/nmi.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/aemo/nmi.rb b/lib/aemo/nmi.rb index 4bfa11e..eb1133e 100644 --- a/lib/aemo/nmi.rb +++ b/lib/aemo/nmi.rb @@ -606,16 +606,16 @@ def data_streams_by_status(status = 'A') # The current daily load in kWh # - # @return [Integer] the current daily load for the meter + # @return [Integer] the current daily load for the meter in kWh def current_daily_load data_streams_by_status.map { |x| x.averaged_daily_load.to_i }.inject(0, :+) end # The current annual load in MWh # - # @return [Integer] the current annual load for the meter + # @return [Integer] the current annual load for the meter in MWh def current_annual_load - (current_daily_load * 365.25 / 1000).to_i + (current_daily_load * 365.2425 / 1000).to_i end # A function to validate the NMI provided From 5542944d24cfa334c152e8e93817dcbf43f17012 Mon Sep 17 00:00:00 2001 From: Joel Courtney Date: Tue, 14 Jun 2016 15:03:05 +1000 Subject: [PATCH 4/4] Gemfile version updates --- aemo.gemspec | 2 +- lib/aemo/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aemo.gemspec b/aemo.gemspec index f4e2919..3f79a68 100644 --- a/aemo.gemspec +++ b/aemo.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = 'aemo' s.version = AEMO::VERSION s.platform = Gem::Platform::RUBY - s.date = '2016-05-24' + s.date = '2016-06-14' s.summary = 'Gem providing functionality for the Australian Energy Market Operator data' s.description = 'Gem providing functionality for the Australian Energy Market Operator data. Supports NMIs, NEM12, MSATS Web Services and more' s.authors = ['Joel Courtney', 'Stuart Auld'] diff --git a/lib/aemo/version.rb b/lib/aemo/version.rb index 085cc6f..16f2445 100644 --- a/lib/aemo/version.rb +++ b/lib/aemo/version.rb @@ -22,7 +22,7 @@ # @author Joel Courtney module AEMO # aemo version - VERSION = '0.1.29'.freeze + VERSION = '0.1.30'.freeze # aemo version split amongst different revisions MAJOR_VERSION, MINOR_VERSION, REVISION = VERSION.split('.').map(&:to_i)