From 3d630ba389c01e113389b1c74b216d0b7fc57ba8 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 16 Apr 2017 18:40:52 -0700 Subject: [PATCH] Decouple `temperature` from `coderack`. --- copycat/coderack.py | 4 ++-- copycat/copycat.py | 2 +- copycat/temperature.py | 11 +++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/copycat/coderack.py b/copycat/coderack.py index 173c6b3..8bf6867 100644 --- a/copycat/coderack.py +++ b/copycat/coderack.py @@ -9,6 +9,8 @@ import workspaceFormulas from slipnet import slipnet from codelet import Codelet from coderackPressure import CoderackPressures +from temperature import temperature + NUMBER_OF_BINS = 7 @@ -36,8 +38,6 @@ class CodeRack(object): self.postings = {} def reset(self): - from temperature import temperature - self.codelets = [] self.codeletsRun = 0 temperature.clamped = True diff --git a/copycat/copycat.py b/copycat/copycat.py index 17f7348..aa18dc7 100644 --- a/copycat/copycat.py +++ b/copycat/copycat.py @@ -15,7 +15,7 @@ def updateEverything(): def mainLoop(lastUpdate): - temperature.tryUnclamp() + temperature.tryUnclamp(coderack.codeletsRun) result = lastUpdate if not coderack.codeletsRun: updateEverything() diff --git a/copycat/temperature.py b/copycat/temperature.py index 22d22da..afc33f3 100644 --- a/copycat/temperature.py +++ b/copycat/temperature.py @@ -10,15 +10,10 @@ class Temperature(object): def update(self, value): self.value = value - def tryUnclamp(self): - from coderack import coderack - - if self.clamped and coderack.codeletsRun >= self.clampTime: - logging.info('unclamp temperature at %d', coderack.codeletsRun) + def tryUnclamp(self, currentTime): + if self.clamped and currentTime >= self.clampTime: + logging.info('unclamp temperature at %d', currentTime) self.clamped = False - def log(self): - logging.debug('temperature.value: %f', self.value) - temperature = Temperature()