Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Experimental Physics
Quantum Circuits
python-repo
Commits
e020241b
Commit
e020241b
authored
Jan 10, 2022
by
Christian Schneider
Browse files
Added function to reduce operation hours
parent
7d007ba1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
32 deletions
+40
-32
FridgeWatch/Fridge_SQL_ACQ.py
FridgeWatch/Fridge_SQL_ACQ.py
+40
-32
No files found.
FridgeWatch/Fridge_SQL_ACQ.py
View file @
e020241b
...
...
@@ -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,37 +430,44 @@ def operatinghours_reduce():
# Add DB entries
for
idx
,
m
in
enumerate
(
months
):
# Create dict for month
dev_dict
=
{
A
:
B
for
A
,
B
in
zip
(
dev_arr
,
op_hours
[
idx
])}
# Check if it already exists
d
=
OperationTimesMonths
.
query
\
.
filter_by
(
name
=
fridge
)
\
.
filter_by
(
time
=
m
)
\
.
first
()
# If it exsits, update value
if
d
:
d
.
compressor
=
dev_dict
[
'Compressor'
]
d
.
forepump
=
dev_dict
[
'ForePump'
]
d
.
pulsetube
=
dev_dict
[
'PulseTube'
]
d
.
turbopump
=
dev_dict
[
'TurboPump'
]
# If not, create new
else
:
d
=
OperationTimesMonths
(
name
=
fridge
,
time
=
m
,
compressor
=
dev_dict
[
'Compressor'
],
forepump
=
dev_dict
[
'ForePump'
],
pulsetube
=
dev_dict
[
'PulseTube'
],
turbopump
=
dev_dict
[
'TurboPump'
],
)
db_cryo
.
session
.
add
(
d
)
db_cryo
.
session
.
commit
()
db_cryo
.
session
.
close
()
# 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
])}
# Check if it already exists
d
=
OperationTimesMonths
.
query
\
.
filter_by
(
name
=
fridge
)
\
.
filter_by
(
time
=
m
)
\
.
first
()
# If it exsits, update value
if
d
:
d
.
compressor
=
dev_dict
[
'Compressor'
]
d
.
forepump
=
dev_dict
[
'ForePump'
]
d
.
pulsetube
=
dev_dict
[
'PulseTube'
]
d
.
turbopump
=
dev_dict
[
'TurboPump'
]
# If not, create new
else
:
d
=
OperationTimesMonths
(
name
=
fridge
,
time
=
m
,
compressor
=
dev_dict
[
'Compressor'
],
forepump
=
dev_dict
[
'ForePump'
],
pulsetube
=
dev_dict
[
'PulseTube'
],
turbopump
=
dev_dict
[
'TurboPump'
],
)
db_cryo
.
session
.
add
(
d
)
db_cryo
.
session
.
commit
()
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,7 +582,8 @@ def run_fridge_update(fridges):
def
run_operationTime_update
(
fridges
):
for
f
in
fridges
:
update_OPStates
(
f
)
operatinghours_reduce
()
operatinghours_reduce
()
# Delete old entries
db_cryo
.
session
.
execute
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment