Startup
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#Wed Apr 12 16:02:36 CEST 2017
|
||||
#Wed Apr 12 18:41:46 CEST 2017
|
||||
colormap=Flame
|
||||
colormapAutomatic=false
|
||||
colormapMax=4000.0
|
||||
colormapAutomatic=true
|
||||
colormapMax=1500.0
|
||||
colormapMin=0.0
|
||||
flipHorizontally=false
|
||||
flipVertically=false
|
||||
grayscale=false
|
||||
imageHeight=1680
|
||||
imageWidth=1744
|
||||
imageHeight=2160
|
||||
imageWidth=2560
|
||||
invert=false
|
||||
regionStartX=433
|
||||
regionStartY=241
|
||||
regionStartX=1
|
||||
regionStartY=1
|
||||
rescaleFactor=1.0
|
||||
rescaleOffset=0.0
|
||||
roiHeight=-1
|
||||
@@ -21,9 +21,9 @@ rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
serverURL=localhost\:10000
|
||||
spatialCalOffsetX=-861.4939970777481
|
||||
spatialCalOffsetY=-820.4883730911062
|
||||
spatialCalScaleX=-18.90359092620482
|
||||
spatialCalScaleY=-19.37984500632817
|
||||
spatialCalOffsetX=-1223.477868576451
|
||||
spatialCalOffsetY=-1024.4742906541314
|
||||
spatialCalScaleX=-8.699279809007425
|
||||
spatialCalScaleY=-8.747949625839508
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.jcae.ChannelException;
|
||||
import ch.psi.pshell.device.DescStatsDouble;
|
||||
import ch.psi.pshell.epics.Epics;
|
||||
import ch.psi.pshell.plot.LinePlotErrorSeries;
|
||||
@@ -11,18 +10,10 @@ import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.ui.App;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JSpinner;
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,6 +70,7 @@ public class WireScan extends Panel {
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
|
||||
|
||||
run("Devices/Elements")
|
||||
run("Devices/WireScanner")
|
||||
|
||||
#BPM_SENSORS = {"x":"X1", "y":"Y1", "q":"Q1"}
|
||||
BPM_SENSORS = {"x":"X1"}
|
||||
BPM_SENSORS = {"x":"X1", "y":"Y1", "q":"Q1"}
|
||||
|
||||
#Paramter parsing
|
||||
if is_panel:
|
||||
prefix = args[0]
|
||||
sel = args[1]
|
||||
@@ -21,76 +22,66 @@ else:
|
||||
cycles = 5
|
||||
velocity = 200
|
||||
bpm3 = None
|
||||
print "WireScan parameters: ", prefix, sel, start, end, cycles, cycles, bpm3
|
||||
|
||||
print prefix, sel, start, end, cycles, cycles, bpm3
|
||||
#Creating WireScanner object
|
||||
print "Creating scanner..."
|
||||
if prefix not in get_wire_scans():
|
||||
raise Exception("Invalid wire scan: " + prefix)
|
||||
scanner = WireScanner(prefix, sel, start, end, cycles, velocity, True)
|
||||
scanner.init()
|
||||
scanner.waitValue("At start", 60000)
|
||||
|
||||
#Stream channels
|
||||
bs_position = scanner.motor_bs_readback.get_name()
|
||||
bpms = get_wire_scans_bpms(prefix)
|
||||
if bpms is None:
|
||||
raise Exception("Cannot determine wire scan bpms: " + prefix)
|
||||
#List of stream channels
|
||||
channels = [("w_pos", scanner.motor_bs_readback.get_name()),
|
||||
("cur_cycle", scanner.curr_cycl.get_name()),
|
||||
("scanning", scanner.status_channels[0].get_name())]
|
||||
bpms = get_wire_scans_bpms(prefix)
|
||||
if bpms is None:
|
||||
raise Exception("Cannot determine wire scan bpms: " + prefix)
|
||||
if bpm3 is not None:
|
||||
bpms.append(bpm3)
|
||||
|
||||
bpms = ["SINDI01-DBPM060", "SINDI02-DBPM010"]
|
||||
#bpms = ["SINDI01-DBPM060", "SINDI02-DBPM010"] #For testing
|
||||
for i in range (len(bpms)):
|
||||
for sensor in BPM_SENSORS.keys():
|
||||
channels.append (("bpm" + str(i+1) + "_" + sensor, bpms[i] + ":" + BPM_SENSORS[sensor]))
|
||||
channels.append (("timer", "SINDI01-RLLE-STA:SLAVE1-CPUTIMER"))
|
||||
|
||||
#Stream creation
|
||||
print "Starting stream..."
|
||||
st = Stream("pulse_id", dispatcher)
|
||||
#st.setFilter(scanner.status_channels[0].get_name() + ">0") #Not used because we must the reansition to know when the finished
|
||||
scanner.curr_cycl.write(0)
|
||||
st.setFilter(scanner.curr_cycl.get_name() + ">0")
|
||||
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the reansition to know when the finished
|
||||
for c in channels:
|
||||
print c[1]
|
||||
st.addScalar(c[0], c[1], 10, 0)
|
||||
st.initialize()
|
||||
st.start()
|
||||
st.waitCacheChange(10000)
|
||||
scanner.scan()
|
||||
scanner.waitState(State.Busy, 60000)
|
||||
st.waitCacheChange(10000) #Wait stream be running before starting scan
|
||||
|
||||
#End of scan checking
|
||||
scan_complete=False
|
||||
cur_cycle = scanner.curr_cycl.get()
|
||||
cur_cycle = 1
|
||||
def check_end_scan(record, scan):
|
||||
global scan_complete
|
||||
global cur_cycle
|
||||
#print record[1] ,scanner.readback
|
||||
global scan_complete,cur_cycle
|
||||
if record[3]<1:
|
||||
print "Data aquisition completed"
|
||||
scan_complete=True
|
||||
scan.abort()
|
||||
elif record[2] != cur_cycle:
|
||||
print "New step"
|
||||
print cur_cycle, record[2]
|
||||
cur_cycle = record[2]
|
||||
scan.abort()
|
||||
scan.start()
|
||||
get_context().dataManager.splitScanData(scan)
|
||||
|
||||
|
||||
#Metadata
|
||||
def write_metadata(path):
|
||||
try:
|
||||
set_attribute(path, "Wire Scan", prefix)
|
||||
set_attribute(path, "Selection", sel)
|
||||
set_attribute(path, "Range", scaner.scan_range)
|
||||
set_attribute(path, "Cycles", scanner.cycles )
|
||||
set_attribute(path, "Velocity", scanner.velocity )
|
||||
except:
|
||||
pass
|
||||
set_attribute("/", "Wire Scan", prefix)
|
||||
set_attribute("/", "Selection", sel)
|
||||
set_attribute("/", "Range", scanner.scan_range)
|
||||
set_attribute("/", "Cycles", scanner.cycles )
|
||||
set_attribute("/", "Velocity", scanner.velocity )
|
||||
|
||||
#Scan
|
||||
try:
|
||||
print "Starting scan..."
|
||||
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
|
||||
mscan (st, st.getReadables(), -1, -1, after_read = check_end_scan)
|
||||
except:
|
||||
if not scanner.isReady():
|
||||
@@ -99,9 +90,9 @@ except:
|
||||
if not scan_complete:
|
||||
raise
|
||||
finally:
|
||||
write_metadata(get_exec_pars().scanPath)
|
||||
print "Closing scanner"
|
||||
scanner.close()
|
||||
print "Closing stream"
|
||||
st.close()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user