Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
GEPARD
GEPARD
Commits
bddc18b2
Commit
bddc18b2
authored
Dec 03, 2018
by
Raman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RamanScanUI also works with the more stable dataqueue setup.
parent
26ef709d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
31 deletions
+42
-31
WITecCOM.py
WITecCOM.py
+3
-2
dataset.py
dataset.py
+1
-1
helperfunctions.py
helperfunctions.py
+9
-5
ramanscanui.py
ramanscanui.py
+29
-23
No files found.
WITecCOM.py
View file @
bddc18b2
...
...
@@ -208,8 +208,9 @@ class WITecCOM(RamanBase):
while
distance
>
epsxy
:
# and (lastpos is None or lastpos!=curpos):
curpos
=
self
.
getPosition
()
distance
=
max
(
abs
(
curpos
[
0
]
-
x
),
abs
(
curpos
[
1
]
-
y
))
if
((
time
()
-
t0
>
0.5
)
and
max
(
abs
(
curpos
[
0
]
-
initpos
[
0
]),
abs
(
curpos
[
1
]
-
initpos
[
1
]))
<
epsxy
)
or
(
time
()
-
t0
>
10.
):
print
(
"WARNING: signal ignored:"
,
time
()
-
t0
,
x
,
y
,
curpos
,
initpos
)
# if ((time()-t0>0.5) and max(abs(curpos[0]-initpos[0]), abs(curpos[1]-initpos[1]))<epsxy) or (time()-t0>10.):
if
((
time
()
-
t0
>
2
)
and
max
(
abs
(
curpos
[
0
]
-
initpos
[
0
]),
abs
(
curpos
[
1
]
-
initpos
[
1
]))
<
epsxy
)
or
(
time
()
-
t0
>
10.
):
print
(
"WARNING: signal ignored; time: {} s, x, y: {}, {}, curPos: {}, initPos: {}"
.
format
((
time
()
-
t0
),
x
,
y
,
curpos
,
initpos
))
sys
.
stdout
.
flush
()
break
sleep
(.
01
)
...
...
dataset.py
View file @
bddc18b2
helperfunctions.py
View file @
bddc18b2
...
...
@@ -24,6 +24,10 @@ import cv2
import
os
def
cv2imread_fix
(
fname
,
flags
=
cv2
.
IMREAD_COLOR
):
if
not
os
.
path
.
exists
(
fname
):
#This seems to be a source of potential errors. Having these lines here probably aids finding errors for other groups?
print
(
'Error, image file not found\Please check if the used save-Image command returns before the image was fully written to disk.'
)
return
with
open
(
fname
,
"rb"
)
as
fp
:
cont
=
fp
.
read
()
img
=
cv2
.
imdecode
(
np
.
fromstring
(
cont
,
dtype
=
np
.
uint8
),
flags
)
...
...
ramanscanui.py
View file @
bddc18b2
...
...
@@ -21,10 +21,11 @@ If not, see <https://www.gnu.org/licenses/>.
from
PyQt5
import
QtCore
,
QtWidgets
import
numpy
as
np
from
multiprocessing
import
Process
,
Pipe
from
time
import
sleep
,
tim
e
from
externalmodules
import
tsp
from
multiprocessing
import
Process
,
Queue
,
Event
import
queu
e
from
time
import
sleep
,
time
,
localtime
,
strftime
import
datetime
from
externalmodules
import
tsp
import
sys
def
reorder
(
points
,
N
=
20
):
...
...
@@ -45,7 +46,8 @@ def reorder(points, N=20):
assert
np
.
unique
(
newind
).
shape
[
0
]
==
allind
.
shape
[
0
]
return
newind
def
scan
(
name
,
accu
,
inttime
,
positions
,
controlclass
,
connection
):
def
scan
(
name
,
accu
,
inttime
,
positions
,
controlclass
,
dataqueue
,
stopevent
):
with
open
(
"ramanscanlog.txt"
,
"a"
)
as
fp
:
sys
.
stderr
=
fp
sys
.
stdout
=
fp
...
...
@@ -53,22 +55,20 @@ def scan(name, accu, inttime, positions, controlclass, connection):
ramanctrl
=
controlclass
()
ramanctrl
.
connect
()
ramanctrl
.
initiateTimeSeriesScan
(
name
,
len
(
positions
),
accu
,
inttime
)
print
(
"starting Raman Scan at: "
+
strftime
(
"%d %b %Y %H:%M:%S"
,
localtime
()))
for
i
,
p
in
enumerate
(
positions
):
x
,
y
,
z
=
p
print
(
"time:"
,
time
())
print
(
"position:"
,
x
,
y
,
z
)
print
(
'Measuring particle index {} at location {}, time = {}'
.
format
(
i
,
(
x
,
y
,
z
),
strftime
(
"%H:%M:%S"
,
localtime
())))
sys
.
stdout
.
flush
()
#remove after testing
ramanctrl
.
moveToAbsolutePosition
(
x
,
y
,
z
)
ramanctrl
.
nextTimeSeriesScan
(
i
)
if
connection
.
poll
():
instruction
=
connection
.
recv
()
if
instruction
==
"stop"
:
if
stopevent
.
is_set
():
ramanctrl
.
disconnect
()
return
connection
.
send
(
i
)
dataqueue
.
put
(
i
)
ramanctrl
.
disconnect
()
while
not
connection
.
poll
():
sleep
(.
1
)
connection
.
recv
()
class
RamanScanUI
(
QtWidgets
.
QWidget
):
imageUpdate
=
QtCore
.
pyqtSignal
(
name
=
'imageUpdate'
)
...
...
@@ -148,8 +148,11 @@ class RamanScanUI(QtWidgets.QWidget):
QtWidgets
.
QMessageBox
.
No
,
QtWidgets
.
QMessageBox
.
No
)
if
reply
==
QtWidgets
.
QMessageBox
.
Yes
:
self
.
timer
.
stop
()
self
.
connection
.
send
(
"stop"
)
# self.connection.send("stop")
self
.
processstopevent
.
set
()
self
.
process
.
join
()
self
.
dataqueue
.
close
()
self
.
dataqueue
.
join_thread
()
self
.
view
.
unblockUI
()
else
:
return
...
...
@@ -205,9 +208,9 @@ class RamanScanUI(QtWidgets.QWidget):
self
.
progressbar
.
setRange
(
0
,
len
(
scanpoints
))
self
.
progressbar
.
setValue
(
0
)
self
.
ramanctrl
.
disconnect
()
parent_conn
,
child_conn
=
Pipe
()
self
.
connection
=
parent_conn
self
.
process
=
Process
(
target
=
scan
,
args
=
(
self
.
dataset
.
name
,
accu
,
inttime
,
scanpoints
,
self
.
ramanctrl
.
__class__
,
child_conn
))
self
.
processstopevent
=
Event
()
self
.
dataqueue
=
Queue
()
self
.
process
=
Process
(
target
=
scan
,
args
=
(
self
.
dataset
.
name
,
accu
,
inttime
,
scanpoints
,
self
.
ramanctrl
.
__class__
,
self
.
dataqueue
,
self
.
processstopevent
))
self
.
process
.
start
()
self
.
starttime
=
time
()
self
.
timer
=
QtCore
.
QTimer
(
self
)
...
...
@@ -217,8 +220,11 @@ class RamanScanUI(QtWidgets.QWidget):
@
QtCore
.
pyqtSlot
()
def
checkOnScan
(
self
):
if
self
.
connection
.
poll
():
i
=
self
.
connection
.
recv
()
try
:
i
=
self
.
dataqueue
.
get_nowait
()
except
queue
.
Empty
:
i
=
-
1
if
i
>=
0
:
self
.
progressbar
.
setValue
(
i
+
1
)
self
.
view
.
highLightRamanIndex
(
i
+
1
)
Npoints
=
len
(
self
.
dataset
.
ramanpoints
)
...
...
@@ -228,9 +234,9 @@ class RamanScanUI(QtWidgets.QWidget):
time2go
=
ttot
-
timerunning
self
.
progresstime
.
setText
(
self
.
timelabeltext
+
str
(
datetime
.
timedelta
(
seconds
=
round
(
time2go
))))
if
i
==
Npoints
-
1
:
self
.
connection
.
send
(
"stop"
)
self
.
process
.
join
()
self
.
connection
.
close
()
self
.
dataqueue
.
close
()
self
.
dataqueue
.
join_thread
()
self
.
dataset
.
ramanscandone
=
True
self
.
view
.
saveDataSet
()
self
.
view
.
unblockUI
()
...
...
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