Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Climate Lab Test Stand
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MSK-SW
Low-Level Radio Frequency
Climate Lab
Climate Lab Test Stand
Commits
cd852ee9
Commit
cd852ee9
authored
1 year ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
feat: use multiprocess instead of threads
parent
c286e3c8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Python_script/MeasurementPlot.py
+5
-1
5 additions, 1 deletion
Python_script/MeasurementPlot.py
Python_script/prototype.py
+10
-7
10 additions, 7 deletions
Python_script/prototype.py
with
15 additions
and
8 deletions
Python_script/MeasurementPlot.py
+
5
−
1
View file @
cd852ee9
...
...
@@ -2,6 +2,7 @@ import pandas as pd
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
time
from
multiprocessing
import
Queue
import
queue
import
sys
...
...
@@ -144,7 +145,7 @@ class MeasurementPlot:
plt
.
rcParams
.
update
({
'
font.size
'
:
16
})
self
.
data_queue
=
queue
.
Queue
(
10
)
self
.
data_queue
=
Queue
(
10
)
def
stop
(
self
):
self
.
data_queue
.
put
((
None
,
None
,
True
))
...
...
@@ -160,9 +161,12 @@ class MeasurementPlot:
def
drawing_loop
(
self
):
while
True
:
print
(
'
drawing loop getting
'
)
data_frame
,
pdf_name
,
stop_thread
=
self
.
data_queue
.
get
()
print
(
'
drawing loop got. stop is
'
+
str
(
stop_thread
))
if
stop_thread
:
return
print
(
'
drawing loop drawing
'
)
self
.
draw_in_this_thread
(
data_frame
,
pdf_name
=
''
)
def
draw_in_this_thread
(
self
,
data_frame
,
pdf_name
=
''
):
...
...
This diff is collapsed.
Click to expand it.
Python_script/prototype.py
+
10
−
7
View file @
cd852ee9
...
...
@@ -13,7 +13,7 @@ import json
import
MeasurementPlot
import
sys
import
analysis
import
threading
from
multiprocessing
import
Process
import
external_sensors
import
PostPlot
import
os
...
...
@@ -174,12 +174,15 @@ class Measurements:
This is a
"
chamber measurement point
"
. It consists out of multiple measurements sets. The data for all
measurement sets of this chamber point are taken for this measurement.
"""
measurement_thread
=
threading
.
Thread
(
target
=
self
.
perform_single_measurement_impl
,
args
=
(
output
,
target_temp
,
target_hum
,
soaking_time
,
n_stable_reads
))
measurement_thread
.
start
()
self
.
measurement_plot
.
drawing_loop
()
measurement_thread
.
join
()
measurement_process
=
Process
(
target
=
self
.
perform_single_measurement_impl
,
args
=
(
output
,
target_temp
,
target_hum
,
soaking_time
,
n_stable_reads
))
measurement_process
.
start
()
#turn interactive plotting (back) on (is deactivated by starting the process)
plt
.
ion
()
try
:
self
.
measurement_plot
.
drawing_loop
()
finally
:
measurement_process
.
join
()
def
perform_single_measurement_impl
(
self
,
output
,
target_temp
,
target_hum
,
soaking_time
,
n_stable_reads
):
with
open
(
output
,
mode
=
'
w
'
,
newline
=
''
)
as
csv_file
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment