Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heat modelling changes for the built environment #61

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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