kopia lustrzana https://github.com/jbruce12000/kiln-controller
initial changes for cost calculation
rodzic
8fbb3ab649
commit
e45709a5a4
15
config.py
15
config.py
|
@ -16,8 +16,15 @@ log_format = '%(asctime)s %(levelname)s %(name)s: %(message)s'
|
|||
listening_ip = "0.0.0.0"
|
||||
listening_port = 8082
|
||||
|
||||
### Cost Estimate
|
||||
kwh_rate = 0.1319 # Rate in currency_type to calculate cost to run job
|
||||
########################################################################
|
||||
# Cost Information
|
||||
#
|
||||
# This is used to calculate a cost estimate before a run. It's also used
|
||||
# to produce the actual cost at the end of a run. My kiln has three
|
||||
# elements that when my switches are set to high, consume 9460 watts.
|
||||
|
||||
kwh_rate = 0.1319 # cost per kilowatt hour per currency_type to calculate cost to run job
|
||||
kw_elements = 0.9460 # if the kiln elements are on, the wattage in kilowatts
|
||||
currency_type = "$" # Currency Symbol to show when calculating cost to run job
|
||||
|
||||
########################################################################
|
||||
|
@ -178,6 +185,6 @@ automatic_restart_state_file = os.path.abspath(os.path.join(os.path.dirname( __f
|
|||
# created a repo where anyone can contribute profiles. The objective is
|
||||
# to load profiles from this repository by default.
|
||||
# See https://github.com/jbruce12000/kiln-profiles
|
||||
#kiln_profiles_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ),"storage", "profiles"))
|
||||
kiln_profiles_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ),'..','kiln-profiles','pottery'))
|
||||
kiln_profiles_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ),"storage", "profiles"))
|
||||
#kiln_profiles_directory = os.path.abspath(os.path.join(os.path.dirname( __file__ ),'..','kiln-profiles','pottery'))
|
||||
|
||||
|
|
11
lib/oven.py
11
lib/oven.py
|
@ -204,6 +204,7 @@ class Oven(threading.Thread):
|
|||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
self.cost = 0
|
||||
self.state = "IDLE"
|
||||
self.profile = None
|
||||
self.start_time = 0
|
||||
|
@ -296,6 +297,13 @@ class Oven(threading.Thread):
|
|||
log.info("schedule ended, shutting down")
|
||||
self.abort_run()
|
||||
|
||||
def update_cost(self):
|
||||
if self.heat:
|
||||
cost = (config.kwh_rate * config.kw_elements) * ((self.heat)/3600)
|
||||
else:
|
||||
cost = 0
|
||||
self.cost = self.cost + cost
|
||||
|
||||
def get_state(self):
|
||||
temp = 0
|
||||
try:
|
||||
|
@ -306,6 +314,7 @@ class Oven(threading.Thread):
|
|||
pass
|
||||
|
||||
state = {
|
||||
'cost': self.cost,
|
||||
'runtime': self.runtime,
|
||||
'temperature': temp,
|
||||
'target': self.target,
|
||||
|
@ -368,6 +377,7 @@ class Oven(threading.Thread):
|
|||
profile_json = json.dumps(json.load(infile))
|
||||
profile = Profile(profile_json)
|
||||
self.run_profile(profile,startat=startat)
|
||||
self.cost = d["cost"]
|
||||
time.sleep(1)
|
||||
self.ovenwatcher.record(profile)
|
||||
|
||||
|
@ -383,6 +393,7 @@ class Oven(threading.Thread):
|
|||
time.sleep(1)
|
||||
continue
|
||||
if self.state == "RUNNING":
|
||||
self.update_cost()
|
||||
self.save_automatic_restart_state()
|
||||
self.kiln_must_catch_up()
|
||||
self.update_runtime()
|
||||
|
|
Ładowanie…
Reference in New Issue