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