Skip to content

Commit

Permalink
Merge pull request #61 from quintel/built-environment-heat
Browse files Browse the repository at this point in the history
Heat modelling changes for the built environment
  • Loading branch information
noracato authored Jan 19, 2024
2 parents 8f50dc1 + bab9b38 commit 5439199
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
10 changes: 6 additions & 4 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ agent:
blocks:
- name: RSpec
task:
prologue:
commands:
- checkout
- cache restore
- bundle install
- cache store
jobs:
- name: Test
commands:
- checkout
- cache restore
- bundle install
- cache store
- bundle exec rspec
matrix:
- env_var: RUBY_VERSION
Expand Down
7 changes: 7 additions & 0 deletions lib/refinery/calculators/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Base
# Public: The object which the calculator calculates.
attr_reader :model


# Public: Creates a new calculator responsible for figuring out the
# unknown attributes for the given +model+. Calculator is a base class
# and should be extended with the logic needed to compute the values.
Expand Down Expand Up @@ -58,6 +59,12 @@ def calculated?
@calculated
end

# Public: Returns true if the calculation of this part of the graph is
# paused
def paused?
@model.wait?
end

# Public: A human-readable version of the calculator for debugging.
#
# Returns a string.
Expand Down
2 changes: 1 addition & 1 deletion lib/refinery/catalyst/calculators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def calculate(calculator, order)
def uncalculated
@graph.tsort { |e| e.get(:type) != :overflow }.map do |node|
[ node.calculator, *node.out_edges.map(&:calculator).to_a ]
end.flatten.reject(&:calculated?).reverse
end.flatten.reject(&:calculated?).reject(&:paused?).reverse
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/refinery/edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ def demand
get(:demand)
end

def wait?
@paused || false
end

def wait!
@paused = true
end

def continue!
@paused = false
end

def inspect
super.sub(/>$/, " (type=#{get(:type)})>")
end
Expand Down
12 changes: 12 additions & 0 deletions lib/refinery/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ def demand
get(:demand)
end

def wait?
@paused || false
end

def wait!
@paused = true
end

def continue!
@paused = false
end

# Public: The demand of the node for a given +carrier+.
#
# If the node demands a total of 200 energy, and its incoming gas slot has
Expand Down

0 comments on commit 5439199

Please sign in to comment.