Commit 6d428c36 authored by Lars Bittrich's avatar Lars Bittrich

simulatedraman: bugfix in positionlist index

parent 4a04d651
...@@ -33,7 +33,7 @@ class ExpExcelDialog(QtWidgets.QDialog): ...@@ -33,7 +33,7 @@ class ExpExcelDialog(QtWidgets.QDialog):
def __init__(self, datastats, parent): def __init__(self, datastats, parent):
super(ExpExcelDialog, self).__init__(parent) super(ExpExcelDialog, self).__init__(parent)
self.setWindowTitle('Export Options') self.setWindowTitle('Export Options')
self.setGeometry(200,200, 300, 300) self.setGeometry(200, 200, 300, 300)
self.datastats = datastats self.datastats = datastats
self.particles = self.datastats.getParticleStats() self.particles = self.datastats.getParticleStats()
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
GEPARD - Gepard-Enabled PARticle Detection GEPARD - Gepard-Enabled PARticle Detection
Copyright (C) 2018 Lars Bittrich and Josef Brandt, Leibniz-Institut für Copyright (C) 2018 Lars Bittrich and Josef Brandt, Leibniz-Institut für
Polymerforschung Dresden e. V. <bittrich-lars@ipfdd.de> Polymerforschung Dresden e. V. <bittrich-lars@ipfdd.de>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program, see COPYING. along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>. If not, see <https://www.gnu.org/licenses/>.
Simualted Raman interface module for testing without actual raman system connected Simualted Raman interface module for testing without actual raman system connected
""" """
from time import sleep from time import sleep
import numpy as np import numpy as np
from shutil import copyfile from shutil import copyfile
from ramancom.ramanbase import RamanBase from ramancom.ramanbase import RamanBase
class SimulatedRaman(RamanBase): class SimulatedRaman(RamanBase):
magn = 20 magn = 20
ramanParameters = {} ramanParameters = {}
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.currentpos = None, 0., 0. self.currentpos = None, 0., 0.
self.currentZ = 0. self.currentZ = 0.
# some plausible data to simulate consecutively changing positions # some plausible data to simulate consecutively changing positions
self.positionlist = np.array([[ 1526. , -1379.9, -131. ], self.positionlist = np.array([[ 1526. , -1379.9, -131. ],
[ 3762.5, -1197.7, -138.1], [ 3762.5, -1197.7, -138.1],
[ 2313.7, -2627.2, -138.1], [ 2313.7, -2627.2, -138.1],
[ 2704.1, -1788.2, -138.1], [ 2704.1, -1788.2, -138.1],
[ 3884. , -2650.8, -138.1]]) [ 3884. , -2650.8, -138.1]])
self.znum = 4 self.znum = 4
self.gridnum = 36 self.gridnum = 36
self.positionindex = 0 self.positionindex = 0
self.imageindex = 0 self.imageindex = 0
def getRamanPositionShift(self): def getRamanPositionShift(self):
return 0., 0. return 0., 0.
def connect(self): def connect(self):
self.connected = True self.connected = True
self.imageindex = 0 self.imageindex = 0
return True return True
def disconnect(self): def disconnect(self):
self.connected = False self.connected = False
def getPosition(self): def getPosition(self):
if self.currentpos[0] is None: if self.currentpos[0] is None:
pos = self.positionlist[self.positionindex] pos = self.positionlist[self.positionindex]
self.positionindex = (self.positionindex+1)%len(self.positionlist) self.positionindex = (self.positionindex+1)%len(self.positionlist)
else: else:
pos = self.currentpos pos = self.currentpos
return pos return pos
def getSoftwareZ(self): def getSoftwareZ(self):
return self.currentpos[2] return self.currentpos[2]
def getUserZ(self): def getUserZ(self):
assert self.connected assert self.connected
if self.currentpos[0] is None: if self.currentpos[0] is None:
return self.positionlist[self.positionindex][2] index = (self.positionindex-1)%len(self.positionlist)
else: return self.positionlist[index][2]
return self.currentZ else:
return self.currentZ
def moveToAbsolutePosition(self, x, y, z=None, epsxy=0.11, epsz=0.011, debugReturn=False, measurementRunning=False):
assert self.connected def moveToAbsolutePosition(self, x, y, z=None, epsxy=0.11, epsz=0.011, debugReturn=False, measurementRunning=False):
if z is None: assert self.connected
self.currentpos = x, y, self.currentpos[2] if z is None:
else: self.currentpos = x, y, self.currentpos[2]
self.currentpos = x, y, z else:
sleep(0.1) self.currentpos = x, y, z
sleep(0.1)
def moveZto(self, z, epsz=0.011):
assert self.connected def moveZto(self, z, epsz=0.011):
self.currentpos = self.currentpos[0], self.currentpos[1], z assert self.connected
self.currentpos = self.currentpos[0], self.currentpos[1], z
def saveImage(self, fname):
assert self.connected def saveImage(self, fname):
copyfile(f"fakeData/image.bmp", fname) assert self.connected
self.imageindex = (self.imageindex+1)%(self.znum*self.gridnum) copyfile(f"fakeData/image.bmp", fname)
sleep(.01) self.imageindex = (self.imageindex+1)%(self.znum*self.gridnum)
sleep(.01)
def getImageDimensions(self, mode = 'df'):
""" Get the image width and height in um and the orientation angle in degrees. def getImageDimensions(self, mode = 'df'):
""" """ Get the image width and height in um and the orientation angle in degrees.
assert self.connected """
width, height, angle = 463.78607177734375, 296.0336608886719, -0.04330849274992943 assert self.connected
return width, height, angle width, height, angle = 463.78607177734375, 296.0336608886719, -0.04330849274992943
return width, height, angle
def startSinglePointScan(self):
assert self.connected def startSinglePointScan(self):
print("Fake scan") assert self.connected
sleep(.3) print("Fake scan")
sleep(.3)
def initiateMeasurement(self, label, numberofscans, accumulations, integrtime):
assert self.connected def initiateMeasurement(self, label, numberofscans, accumulations, integrtime):
print("Scanning ",numberofscans, "particle positions") assert self.connected
self.timeseries = numberofscans print("Scanning ",numberofscans, "particle positions")
sleep(.1) self.timeseries = numberofscans
sleep(.1)
def triggerMeasurement(self, num):
assert self.timeseries def triggerMeasurement(self, num):
print("Scan number:", num) assert self.timeseries
sleep(.1) print("Scan number:", num)
if num==self.timeseries-1: sleep(.1)
if num==self.timeseries-1:
self.timeseries = False self.timeseries = False
\ No newline at end of file
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