initial changes for cost calculation

master
jbruce 2022-08-31 21:45:34 -04:00
rodzic 8fbb3ab649
commit e45709a5a4
2 zmienionych plików z 22 dodań i 4 usunięć

Wyświetl plik

@ -16,8 +16,15 @@ log_format = '%(asctime)s %(levelname)s %(name)s: %(message)s'
listening_ip = "0.0.0.0" listening_ip = "0.0.0.0"
listening_port = 8082 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 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 # created a repo where anyone can contribute profiles. The objective is
# to load profiles from this repository by default. # to load profiles from this repository by default.
# See https://github.com/jbruce12000/kiln-profiles # 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__ ),"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__ ),'..','kiln-profiles','pottery'))

Wyświetl plik

@ -204,6 +204,7 @@ class Oven(threading.Thread):
self.reset() self.reset()
def reset(self): def reset(self):
self.cost = 0
self.state = "IDLE" self.state = "IDLE"
self.profile = None self.profile = None
self.start_time = 0 self.start_time = 0
@ -296,6 +297,13 @@ class Oven(threading.Thread):
log.info("schedule ended, shutting down") log.info("schedule ended, shutting down")
self.abort_run() 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): def get_state(self):
temp = 0 temp = 0
try: try:
@ -306,6 +314,7 @@ class Oven(threading.Thread):
pass pass
state = { state = {
'cost': self.cost,
'runtime': self.runtime, 'runtime': self.runtime,
'temperature': temp, 'temperature': temp,
'target': self.target, 'target': self.target,
@ -368,6 +377,7 @@ class Oven(threading.Thread):
profile_json = json.dumps(json.load(infile)) profile_json = json.dumps(json.load(infile))
profile = Profile(profile_json) profile = Profile(profile_json)
self.run_profile(profile,startat=startat) self.run_profile(profile,startat=startat)
self.cost = d["cost"]
time.sleep(1) time.sleep(1)
self.ovenwatcher.record(profile) self.ovenwatcher.record(profile)
@ -383,6 +393,7 @@ class Oven(threading.Thread):
time.sleep(1) time.sleep(1)
continue continue
if self.state == "RUNNING": if self.state == "RUNNING":
self.update_cost()
self.save_automatic_restart_state() self.save_automatic_restart_state()
self.kiln_must_catch_up() self.kiln_must_catch_up()
self.update_runtime() self.update_runtime()