Commit e020241b authored by Christian Schneider's avatar Christian Schneider
Browse files

Added function to reduce operation hours

parent 7d007ba1
......@@ -304,7 +304,7 @@ def operatinghours_reduce():
"""Function to calculate operating hours for pumps"""
op_times_all = {}
for cryo_id in cryolist:
for cryo_id in fridges:
op_times_all[cryo_id] = {}
runtimes = {}
op_times = {}
......@@ -415,7 +415,7 @@ def operatinghours_reduce():
for fridge, json_f in op_times_all.items():
# Obtain months
months = [datetime.datetime.strptime(m['x'], "%Y/%B") for
months = [datetime.strptime(m['x'], "%Y/%B") for
m in json_f['Compressor']]
# Obtain operation hours
......@@ -430,6 +430,12 @@ def operatinghours_reduce():
# Add DB entries
for idx, m in enumerate(months):
# Only add current month
today = datetime.now()
this_month = datetime(today.year, today.month, 1)
if m == this_month:
# Create dict for month
dev_dict = {A: B for A, B in zip(dev_arr, op_hours[idx])}
......@@ -461,6 +467,7 @@ def operatinghours_reduce():
db_cryo.session.close()
return op_times_all
def check_cooldowntime(fridge_name, log_folder=logpath):
# Read file
data = read_fridge(fridge_name, log_folder)
......@@ -575,6 +582,7 @@ def run_fridge_update(fridges):
def run_operationTime_update(fridges):
for f in fridges:
update_OPStates(f)
operatinghours_reduce()
# Delete old entries
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment