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

Use events in fan controler #10

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion demos/cpu/cpu/systems/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .cpu import CPU
from .heatexchanger import HeatExchanger
from .fancontroller import FanController
from .fancontroler import FanControler
from .fan import Fan
from .cpusystem import CPUSystem
4 changes: 2 additions & 2 deletions demos/cpu/cpu/systems/cpusystem.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from cosapp.systems import System

from cpu.systems import CPU, HeatExchanger, Fan, FanController
from cpu.systems import CPU, HeatExchanger, Fan, FanControler


class CPUSystem(System):

def setup(self):

# children
self.add_child(FanController("controler"))
self.add_child(FanControler("controler"))
self.add_child(Fan("fan"))
self.add_child(HeatExchanger("exchanger"))
self.add_child(CPU("cpu"), pulling={"T" : "T_cpu"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from cosapp.systems import System


class FanController(System):
class FanControler(System):
"""
Define tension for fan from the level of CPU temperature
"""
Expand All @@ -13,14 +13,23 @@ def setup(self):
self.add_inward("low_tension", 0.0, unit="V", desc="Output low tension")
self.add_inward("medium_tension", 6.0, unit="V", desc="Output medium tension")
self.add_inward("max_tension", 12.0, unit="V", desc="Output max tension")
self.add_inward("tension_command", 12.0, unit="V", desc="Output command tension")

# outputs
self.add_outward("tension", 0.0, unit="V", desc="Output tension")

self.add_event('null_to_low_tension', trigger="T >= low_threshold")
self.add_event('low_to_max_tension', trigger="T >= high_threshold")
self.add_event('low_to_null_tension', trigger="T <= low_threshold")
self.add_event('max_to_low_tension', trigger="T <= high_threshold")

def compute(self):
if self.T_cpu <= self.low_threshold:
self.tension = self.low_tension
elif self.T_cpu <= self.high_threshold:
self.tension = self.medium_tension
self.tension = self.tension_command

def transition(self):
if self.low_to_null_tension.present:
self.tension_command = 0.
elif self.null_to_low_tension.present or self.max_to_low_tension.present:
self.tension_command = self.medium_tension
else:
self.tension = self.max_tension
self.tension_command = self.max_tension