diff --git a/config/settings.properties b/config/settings.properties index a1ffb18..7d23382 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,18 +1,18 @@ -#Mon Dec 14 22:42:49 CET 2020 +#Tue Dec 15 15:03:43 CET 2020 HARMONIC_ID_1=1 RSYNC_USER= OUTLIERS_THRESHOLD=1000000000 NORM_FILE=/sls/X11MA/data/X11MA/Data1/public/PEEM/2020_09/i1904_1_0.tif AUTO_SWITCH_VALVE=true -DRY_RUN=false -POL_ID_2=Lin_Hor +DRY_RUN=true +POL_ID_2=Circ_Plus OFFSET_ID_1=-1.5 -ID=ID2 +ID=ID1_ID2 OFFSET_ID_2=-1.3 proposal=proposal ENERGY=707.3 proposer=proposer -POL_ID_1=Circ_Plus +POL_ID_1=Circ_Minus RSYNC_HOST= sample=sample RSYNC_PATH=Kagome_Triangular_b100 diff --git a/config/variables.properties b/config/variables.properties index aeebe01..7a7d2fc 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Tue Dec 15 09:30:04 CET 2020 +#Tue Dec 15 15:18:30 CET 2020 LastRunDate=201215 -FileSequentialNumber=4915 -DaySequentialNumber=6 +FileSequentialNumber=4965 +DaySequentialNumber=117 diff --git a/plugins/Eiger.form b/plugins/Eiger.form index 4c127ca..b9961da 100644 --- a/plugins/Eiger.form +++ b/plugins/Eiger.form @@ -554,14 +554,14 @@ - + - + - + @@ -626,12 +626,14 @@ + + @@ -646,18 +648,26 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -671,12 +681,12 @@ - + - + @@ -699,6 +709,12 @@ + + + + + + @@ -803,14 +819,14 @@ - + - + @@ -823,6 +839,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Eiger.java b/plugins/Eiger.java index 2c0633c..06de50d 100644 --- a/plugins/Eiger.java +++ b/plugins/Eiger.java @@ -49,6 +49,11 @@ public class Eiger extends Panel { Tune_Detune } + public enum Sequence { + A, + B + } + public enum SingleSwitching { Normal } @@ -76,6 +81,8 @@ public class Eiger extends Panel { initComponents(); SwingUtils.setEnumCombo(comboSwitch, Switching.class, true); comboSwitch.setSelectedIndex(1); + SwingUtils.setEnumCombo(comboSeq, Sequence.class, true); + comboSeq.setSelectedIndex(0); SwingUtils.setEnumCombo(comboImgMethod, ImgMethod.class, true); Component[] parameterControls = new Component[0]; @@ -173,12 +180,14 @@ public class Eiger extends Panel { if (editable) { comboSwitch.setEnabled(comboImgMethod.getSelectedItem() == ImgMethod.Two_Pol.toString()); + comboSeq.setEnabled(comboImgMethod.getSelectedItem() == ImgMethod.Two_Pol.toString()); } labelImgEng1.setVisible(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); labelImgEng2.setVisible(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); - spinnerImgEng1.setVisible(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); spinnerImgEng2.setVisible(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); + spinnerImgEng1.setVisible(comboImgMethod.getSelectedItem() == ImgMethod.Two_Energies.toString()); + checkSwitchPol.setVisible(comboImgMethod.getSelectedItem() == ImgMethod.Take_Image.toString()); //panelSecondImage.setVisible(comboImgMethod.getSelectedItem() != ImgMethod.Take_Image.toString()); @@ -307,12 +316,14 @@ public class Eiger extends Panel { HashMap args = new HashMap(); args.put("METHOD", comboImgMethod.getSelectedItem()); args.put("SWITCHING", comboSwitch.getSelectedItem()); + args.put("SEQUENCE", comboSeq.getSelectedItem()); args.put("MEASUREMENTS", spinnerImgMeasurements.getValue()); args.put("AUTO_SAVE", checkImgAutosave.isSelected()); args.put("EXPOSURE", spinnerImgExp.getValue()); args.put("AVERAGE", spinnerImgAvg.getValue()); args.put("ENERGY_1", spinnerImgEng1.getValue()); args.put("ENERGY_2", spinnerImgEng2.getValue()); + args.put("SWITCH_POL", checkSwitchPol.isSelected()); runAsync("templates/Eiger2Img", args).handle((ret, t) -> { if ((t != null) && (!getContext().isAborted())) { @@ -450,9 +461,12 @@ public class Eiger extends Panel { jLabel9 = new javax.swing.JLabel(); spinnerImgAvg = new javax.swing.JSpinner(); labelImgEng2 = new javax.swing.JLabel(); - spinnerImgEng2 = new javax.swing.JSpinner(); spinnerImgEng1 = new javax.swing.JSpinner(); + spinnerImgEng2 = new javax.swing.JSpinner(); labelImgEng1 = new javax.swing.JLabel(); + labelSwitching1 = new javax.swing.JLabel(); + comboSeq = new javax.swing.JComboBox<>(); + checkSwitchPol = new javax.swing.JCheckBox(); jPanel9 = new javax.swing.JPanel(); dvpEnergya3 = new ch.psi.pshell.swing.DeviceValuePanel(); dvpOffID1b = new ch.psi.pshell.swing.DeviceValuePanel(); @@ -899,13 +913,19 @@ public class Eiger extends Panel { labelImgEng2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); labelImgEng2.setText("Energy 1:"); - spinnerImgEng2.setModel(new javax.swing.SpinnerNumberModel(1000.0d, 90.0d, 2000.0d, 1.0d)); - spinnerImgEng1.setModel(new javax.swing.SpinnerNumberModel(1000.0d, 90.0d, 2000.0d, 1.0d)); + spinnerImgEng2.setModel(new javax.swing.SpinnerNumberModel(1000.0d, 90.0d, 2000.0d, 1.0d)); + labelImgEng1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); labelImgEng1.setText("Energy 2:"); + labelSwitching1.setText("Sequence:"); + + comboSeq.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + + checkSwitchPol.setText("Switch pol after scan"); + javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( @@ -917,12 +937,14 @@ public class Eiger extends Panel { .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel21, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(labelSwitching, javax.swing.GroupLayout.Alignment.TRAILING)) + .addComponent(labelSwitching, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(labelSwitching1, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(comboSwitch, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(spinnerImgMeasurements) - .addComponent(comboImgMethod, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(comboImgMethod, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(comboSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel5Layout.createSequentialGroup() .addGap(118, 118, 118) .addComponent(checkImgAutosave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) @@ -932,22 +954,27 @@ public class Eiger extends Panel { .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerImgAvg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerImgExp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 62, Short.MAX_VALUE) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(labelImgEng1, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(labelImgEng2, javax.swing.GroupLayout.Alignment.TRAILING)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerImgEng2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerImgEng1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel5Layout.createSequentialGroup() + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerImgAvg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerImgExp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 62, Short.MAX_VALUE) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(labelImgEng1, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(labelImgEng2, javax.swing.GroupLayout.Alignment.TRAILING)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerImgEng1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerImgEng2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel5Layout.createSequentialGroup() + .addComponent(checkSwitchPol) + .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerImgAvg, spinnerImgEng1, spinnerImgEng2, spinnerImgExp}); - jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {checkImgAutosave, comboImgMethod, comboSwitch, spinnerImgMeasurements}); + jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {checkImgAutosave, comboImgMethod, comboSeq, comboSwitch, spinnerImgMeasurements}); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -957,11 +984,11 @@ public class Eiger extends Panel { .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(labelImgEng2) - .addComponent(spinnerImgEng2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(spinnerImgEng1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(labelImgEng1) - .addComponent(spinnerImgEng1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(spinnerImgEng2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(comboImgMethod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -977,7 +1004,12 @@ public class Eiger extends Panel { .addGap(6, 6, 6) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(labelSwitching) - .addComponent(comboSwitch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(comboSwitch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(checkSwitchPol)) + .addGap(6, 6, 6) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelSwitching1) + .addComponent(comboSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(checkImgAutosave) .addContainerGap(17, Short.MAX_VALUE)) @@ -1102,13 +1134,13 @@ public class Eiger extends Panel { .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(panelImgControls, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 41, Short.MAX_VALUE) + .addGap(18, 31, Short.MAX_VALUE) .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 42, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 32, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonImgStart) .addComponent(buttonImgAbort)) - .addContainerGap(65, Short.MAX_VALUE)) + .addContainerGap(55, Short.MAX_VALUE)) ); jTabbedPane1.addTab("2-Images", jPanel2); @@ -1733,7 +1765,9 @@ public class Eiger extends Panel { private javax.swing.JCheckBox checkSpecSaveSpectrum; private javax.swing.JCheckBox checkSpecSwitchPol; private javax.swing.JCheckBox checkSpecWithI0; + private javax.swing.JCheckBox checkSwitchPol; private javax.swing.JComboBox comboImgMethod; + private javax.swing.JComboBox comboSeq; private javax.swing.JComboBox comboSwitch; private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel10; private ch.psi.pshell.swing.DeviceValuePanel deviceValuePanel11; @@ -1801,6 +1835,7 @@ public class Eiger extends Panel { private javax.swing.JLabel labelOffID2a; private javax.swing.JLabel labelOffID2b; private javax.swing.JLabel labelSwitching; + private javax.swing.JLabel labelSwitching1; private javax.swing.JPanel panelImgControls; private javax.swing.JPanel panelNorm; private javax.swing.JPanel panelNorm1; diff --git a/script/devices/id.py b/script/devices/id.py index 0599545..7702dec 100644 --- a/script/devices/id.py +++ b/script/devices/id.py @@ -1,27 +1,59 @@ POL_IDS={ "Circ_Plus": 1, "Circ_Minus": 2, "Lin_Hor":3, "Lin_Ver": 4, "Lin": 5} - +channel_id1_status=Channel("X11MA-ID1-USER:STATUS", 'i', monitored=True) +channel_id2_status=Channel("X11MA-ID2-USER:STATUS", 'i', monitored=True) +channel_id1_error=Channel("X11MA-ID1-USER:ERROR-SOURCE", 'i', monitored=True) +channel_id2_error=Channel("X11MA-ID2-USER:ERROR-SOURCE", 'i', monitored=True) +channel_id1_control=Channel("X11MA-ID1-GAP:SCTRL", 'i', monitored=True) +channel_id2_control=Channel("X11MA-ID2-GAP:SCTRL", 'i', monitored=True) +channel_ring_status=Channel("ACOAU-ACCU:OP-MODE", 'i', monitored=True) def get_id_status(id): # 0 = ok # 1 = Warning # 2 = Error # 3 = Not available - if id<1 or id>2: raise Exception("Invalid id") - return caget("X11MA-ID1-USER:STATUS" if (id==1) else "X11MA-ID2-USER:STATUS") - -def get_id_error(id): - # B0 (1) = PLC (Taper, Motor controller, Limitswitch....) - # B1 (2) = Encoders (cabel, not referenced) - # B2 (4) = FeedForward (PS off, PS defect, FF ausgeschaltet) - # B3 (8) = Operator COntrol - # B4 (16)= Moving Timeout (moving longer then 120 sec) - # B5 (32)= Interlock (Orbit, Temperature...)\ if id<1 or id>2: raise Exception("Invalid id") - return caget("X11MA-ID1-USER:ERROR-SOURCE" if (id==1) else "X11MA-ID2-USER:ERROR-SOURCE") + return channel_id1_status.get() if (id==1) else channel_id2_status.get() +def get_id_error(id): + # B0 (1) = PLC (Taper, Motor controller, Limitswitch....) + # B1 (2) = Encoders (cabel, not referenced) + # B2 (4) = FeedForward (PS off, PS defect, FF ausgeschaltet) + # B3 (8) = Operator COntrol + # B4 (16)= Moving Timeout (moving longer then 120 sec) + # B5 (32)= Interlock (Orbit, Temperature...)\ + if id<1 or id>2: + raise Exception("Invalid id") + return channel_id1_error.get() if (id==1)else channel_id2_error.get() + + +def get_id_control(id): + #0 = SLS control, 1 = experiment + if id<1 or id>2: raise Exception("Invalid id") + return channel_id1_control.get() if (id==1) else channel_id2_control.get() + +def get_ring_status(): + #ACOAU-ACCU:OP-MODE kann Werte zwischen 0 und 5 annehmen: + # rule from 24.8.04 + #If (PCT beam current <0.09) -> State 0: "Machine Down" + #Else If (GUN Trigger OFF) -> State 1: "Inj. Stopped" + #Else If (INJ_MODE == Normal) -> State 2: "Accumulating." + #Else If !(reached Top-Up Current) -> State 3: "Accumulating" + #Else If (OP-READY == Wait) -> State 4: "Top-up ready" + #Else If (OFB off) -> State 5: "Light-Available" (former State 4) + #Else -> State 6: "Light Available" (former State 5) + return channel_ring_status.get() + + + +def get_pol_as_string(pol): + for (k,v) in POL_IDS.items(): + if v==pol: + return k + return "Unknown" def get_id_pol(id, as_string=False): @@ -49,10 +81,7 @@ def get_id_pol(id, as_string=False): else: ret = -1 if as_string: - for (k,v) in POL_IDS.items(): - if v==ret: - return k - return "Unknown" + return get_pol_as_string(ret) return ret def get_alpha_id(id): @@ -84,6 +113,9 @@ def put_id_pol(id, pol, alpha=None): if id<1 or id>2: raise Exception("Invalid id") + + if get_dry_run(): + return mode_dev = id1_mode if (id==1) else id2_mode alpha_dev = id1_alpha if (id==1) else id2_alpha @@ -114,6 +146,9 @@ def put_id_pol(id, pol, alpha=None): def tune_detune(active_id): + if get_dry_run(): + return + offset_1 = float(get_setting("OFFSET_ID_1")) offset_2 = float(get_setting("OFFSET_ID_2")) @@ -196,6 +231,8 @@ def init_pol_switch(switching_type, sid = None, pol_id1=None, pol_id2=None): else: if _switching_id == "ID1_ID2": put_id_pol(2, _switching_current_pol) #Force both IDs to same polarization + if get_dry_run(): + return wait_channel("X11PHS:alldone", 1) @@ -216,10 +253,8 @@ def nextpol(): def switch_pol(): global _switching_type, _switching_active_id, _switching_current_pol, _switching_pol_id1, _switching_pol_id2, _switching_id - if DRY_RUN: - return newpol=nextpol() - print "Switch pol: ", newpol + print "Switch pol: ", get_pol_as_string(newpol) if _switching_id == "ID1": put_id_pol(1,newpol) elif _switching_id == "ID2": diff --git a/script/local.py b/script/local.py index 6b9382e..f94d289 100644 --- a/script/local.py +++ b/script/local.py @@ -246,62 +246,24 @@ for dev in ["eiger", "id", "chopper", "LEEM2000", "diag"]: ################################################################################################### -#ID and Machine status +#Beamline and Machine status ################################################################################################### - -def get_id_status(id): - # 0 = ok - # 1 = Warning - # 2 = Error - # 3 = Not available - if id<1 or id>2: - raise Exception("Invalid id") - return caget("X11MA-ID1-USER:STATUS" if (id==1) else "X11MA-ID2-USER:STATUS") - -def get_id_error(id): - # B0 (1) = PLC (Taper, Motor controller, Limitswitch....) - # B1 (2) = Encoders (cabel, not referenced) - # B2 (4) = FeedForward (PS off, PS defect, FF ausgeschaltet) - # B3 (8) = Operator COntrol - # B4 (16)= Moving Timeout (moving longer then 120 sec) - # B5 (32)= Interlock (Orbit, Temperature...)\ - if id<1 or id>2: - raise Exception("Invalid id") - return caget("X11MA-ID1-USER:ERROR-SOURCE" if (id==1) else "X11MA-ID2-USER:ERROR-SOURCE") - - -def get_id_control(id): - #0 = SLS control, 1 = experiment - if id<1 or id>2: raise Exception("Invalid id") - return caget("X11MA-ID1-GAP:SCTRL" if id==1 else "X11MA-ID2-GAP:SCTRL") - -def get_ring_status(): - #ACOAU-ACCU:OP-MODE kann Werte zwischen 0 und 5 annehmen: - # rule from 24.8.04 - #If (PCT beam current <0.09) -> State 0: "Machine Down" - #Else If (GUN Trigger OFF) -> State 1: "Inj. Stopped" - #Else If (INJ_MODE == Normal) -> State 2: "Accumulating." - #Else If !(reached Top-Up Current) -> State 3: "Accumulating" - #Else If (OP-READY == Wait) -> State 4: "Top-up ready" - #Else If (OFB off) -> State 5: "Light-Available" (former State 4) - #Else -> State 6: "Light Available" (former State 5) - return caget("ACOAU-ACCU:OP-MODE", 'i') - + def assert_machine_ok(wait = True): print "Checking machine..." - ID1status=get_id_control(1) - ID2status=get_id_control(2) - Ringstatus=get_ring_status() - - oldRingstatus=Ringstatus + if get_dry_run(): + return + + ring_status=get_ring_status() + old_ring_status=ring_status checkRing=0 - if Ringstatus==5: + if ring_status==5: log ("FB off") #checkRing=1 - if Ringstatus==0: + if ring_status==0: log ("Machine down") checkRing=2 @@ -309,83 +271,76 @@ def assert_machine_ok(wait = True): status=False while not status: - ID1status=get_id_control(1) - ID2status=get_id_control(2) - Ringstatus=get_ring_status() - if oldRingstatus != Ringstatus: - if Ringstatus == 0: + id1_status=get_id_control(1) + id2_status=get_id_control(2) + ring_status=get_ring_status() + if old_ring_status != ring_status: + if ring_status == 0: log("Machine down") checkRing=2 - oldRingstatus=Ringstatus - elif Ringstatus == 1: + elif ring_status == 1: log("Inj. Stopped") checkRing=2 - oldRingstatus=Ringstatus - elif Ringstatus == 2: + elif ring_status == 2: log("Accumulating.") checkRing=2 - oldRingstatus=Ringstatus - elif Ringstatus == 3: + elif ring_status == 3: log("Accumulating") checkRing=2 - oldRingstatus=Ringstatus - elif Ringstatus == 4: + elif ring_status == 4: log("Top-up ready, Gap still open") checkRing=2 - oldRingstatus=Ringstatus - elif Ringstatus == 5: + elif ring_status == 5: log("Light-Available, no OFB") checkRing=2 - oldRingstatus=Ringstatus - elif Ringstatus == 6: + elif ring_status == 6: log("Light Available") checkRing=2 - oldRingstatus=Ringstatus - status= (Ringstatus ==6) and (ID1status==1) and (ID2status==1) + old_ring_status=ring_status + status= (ring_status ==6) and (id1_status==1) and (id2_status==1) if not wait: - raise Exception ("Ring error: " + str(Ringstatus)) + raise Exception ("Ring error: " + str(ring_status)) time.sleep(1) - if checkRing==2: - log("wait 120 s") - time.sleep(120) - log("continue") - elif checkRing==2: - log("wait 10 s") - time.sleep(10) - log("continue") print "Machine ok" -def assert_bemline_ok(): +def assert_beamline_ok(): print "Checking beamline..." + if get_dry_run(): + return + checkbeamline=0 message=[ "PLC error","Encoder error", "Feedforward error","Operator control", "Moving timeout", "Interlock"] - + ID = get_setting("ID") if ID == "ID1": - ID1status=get_id_status(1) - ID2status=0 + id1_status=get_id_status(1) + id2_status=0 elif ID == "ID2": - ID1status=0 - ID2status=get_id_status(2) + id1_status=0 + id2_status=get_id_status(2) if ID == "ID1_ID2": - ID1status=get_id_status(1) - ID2status=get_id_status(2) - if ID1status >= 1: - ID1error=get_id_error(1) + id1_status=get_id_status(1) + id2_status=get_id_status(2) + if id1_status >= 1: + id1_error=get_id_error(1) for bit in range (5,-1, -1): - if ID1error & (2**bit): + if id1_error & (2**bit): log ("ID1 "+ str(message[bit])) - ID1error=ID1error-(2**bit) - if ID2status >= 1: - ID2error=get_id_error(2) + id1_error=id1_error-(2**bit) + if id2_status >= 1: + id2_error=get_id_error(2) for bit in range (5,-1, -1): - if ID2error & (2**bit): + if id2_error & (2**bit): log ("ID2 "+ str(message[bit])) - ID2error=ID2error-(2**bit) - if ID1status >= 1: - raise Exception("ID1 error") - if ID2status >= 1: - raise Exception("ID2 error") + id2_error=id2_error-(2**bit) + if id1_status >= 1: + raise Exception("ID1 error: " + str(id1_status)) + if id2_status >= 1: + raise Exception("ID2 error: "+ str(id2_status)) + +def assert_status_ok(wait = True): + assert_machine_ok(wait) + assert_beamline_ok() ################################################################################################### #Manual log file @@ -438,7 +393,7 @@ def change_energy(v): if v<91 or v>2500: raise Exception ("Invalid energy: " + str(v)) print "Setting energy: " + str(v) - if DRY_RUN: + if get_dry_run(): return put_energy(v) diff --git a/script/templates/Eiger2Img.py b/script/templates/Eiger2Img.py index 980f9fb..4a8e179 100644 --- a/script/templates/Eiger2Img.py +++ b/script/templates/Eiger2Img.py @@ -1,17 +1,19 @@ - #If running from editor if get_exec_pars().source == CommandSource.ui: METHOD = "Two_Pol" SWITCHING = "Tune_Detune" + SEQUENCE = "A" MEASUREMENTS = 4 AUTO_SAVE = True EXPOSURE = 1.0 AVERAGE = 2.0 ENERGY_1 = 850.0 ENERGY_2= 900.0 - + SWITCH_POL=False -DRY_RUN = get_dry_run() +#SEQUENCE = "A": C+,C-,C-,C+,C+;C-,C-,C+, +#SEQUENCE = "B": C+,C-,C+,C-,C+,-;C+,C-. + SHOW_IMAGES = True SAVE_DIAGS = True @@ -68,32 +70,12 @@ def getLEEM(): """ - - -def assert_status_ok(): - if DRY_RUN: return - assert_machine_ok() - #assert_beamline_ok() - """ - getbeamline - getLEEM - Rem check status of machine - If checkRing = 3 Then - Close - Exit Sub - End If - Rem check status of the beamline - If checkbeamline = 3 Then - Close - Exit Sub - """ - #Initialize vartiables -if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": +if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": open_vg10() #rbkEnergy=energy_rbk.read() -if METHOD == "Two_Pol": +if METHOD == "Two_Pol" or (SWITCH_POL and (METHOD == "Take_Image")): init_pol_switch(SWITCHING) def imageinfo(info): @@ -112,21 +94,21 @@ def save_image_file(frame, cycle=-1, frame_index=0): # log("SV:"+Format(startvoltage,"0.000")+" OB:"+Format(objective,"0.00")+" ST:"+Format(LEEMtemp,"0.0")) init_eiger(exposure=EXPOSURE) + #print "Startup time: " + str(time.time() - start) try: #Do the measurement loop for cycle in range(1, MEASUREMENTS + 1): frames = [] if MEASUREMENTS > 1: - log("") log("nround = " + str(cycle) + " / " + str(MEASUREMENTS)) - if METHOD == "Two_Energies": - change_energy(ENERGY_1) for i in range(2): - if (cycle == 1) or (METHOD != "Take_Image"): + if (cycle == 1) or (METHOD != "Take_Image"): assert_status_ok() + if METHOD == "Two_Energies": + change_energy(ENERGY[i]) print "--- Grabing " + str(AVERAGE)+ " frames - cycle: " + str(cycle) + " step: " + str(i) #s=time.time() av = average_eiger_frames(AVERAGE, roi=None, wait_next=True) @@ -137,21 +119,19 @@ try: if METHOD == "Take_Image": break - - - if METHOD == "Two_Pol": - print "--- Switching polatization..." - switch_pol() - if METHOD == "Two_Energies": - change_energy(ENERGY_2) + + if METHOD == "Two_Pol": + if (i==0) or (SEQUENCE == "B"): + switch_pol() #time.sleep(1) if (METHOD == "Two_Pol") or (METHOD == "Two_Energies"): - if (METHOD == "Two_Energies") or (get_cur_pol() in (2,3)): - ###??? autocontrast??? + if (METHOD == "Two_Energies") or (SEQUENCE == "B") or ((cycle%2)==1): + #print "Divide first frame by second" frames.append(frames[0].copy()) frames[2].div(frames[1]) else: + #print "Divide second frame by first" frames.append(frames[1].copy()) frames[2].div(frames[0]) save_image_file(frames[2],cycle, 2) @@ -187,11 +167,33 @@ try: else: integration =integrate_ips ([integration, ip], as_float=True) av=op_const(integration, "divide", float(MEASUREMENTS), in_place=True) - save_image_file(av, -1, i) + save_image_file(av, -1, i) + + + if SWITCH_POL and (METHOD == "Take_Image"): + switch_pol() + SWITCH_POL = False + set_exec_pars(then_success="run('templates/Eiger2Img')") + + """ + get_context().incrementDaySequentialNumber() + set_exec_pars(open=False) + set_exec_pars(open=True) + + for cycle in range(1, MEASUREMENTS + 1): + frames = [] + if MEASUREMENTS > 1: + log("nround = " + str(cycle) + " / " + str(MEASUREMENTS)) + print "--- Grabing " + str(AVERAGE)+ " frames - cycle: " + str(cycle) + " step: " + str(i) + av = average_eiger_frames(AVERAGE, roi=None, wait_next=True) + imageinfo("I") + save_image_file(av, cycle, i) + + """ finally: for i in range(max_index): get_context().incrementDaySequentialNumber() - if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": + if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() restore_eiger() print "Running time: " + str(time.time() - start) \ No newline at end of file diff --git a/script/templates/EigerAbsSpec.py b/script/templates/EigerAbsSpec.py index 32e260e..f69b882 100644 --- a/script/templates/EigerAbsSpec.py +++ b/script/templates/EigerAbsSpec.py @@ -10,7 +10,6 @@ if get_exec_pars().source == CommandSource.ui: NUMBER_SCANS =1 RANGES = [[500.0, 1000.0, 100.0]] -DRY_RUN = get_dry_run() SAVE_DIAGS = True if SWITCH_POL: @@ -44,7 +43,7 @@ frames=[] class SyncEnergy(Writable): def write(self,pos): - if not DRY_RUN: + if not get_dry_run(): put_energy(pos) else: print "Energy=" + str(pos) @@ -82,7 +81,7 @@ set_device_alias(averager, "Image") #Set display name sensors.append(averager) #sensors.append(eiger.getDataMatrix()) #Initialize vartiables -if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": +if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": open_vg10() #put_id_offset(1, OFFSET_ID_1) #offset on ID1 @@ -120,7 +119,7 @@ finally: if AVERAGE>1: for i in range(len(rois)): rois[i].parent.monitored = False # Remove listeners on the image - if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": + if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() restore_eiger() print "Running time: " + str(time.time() - start) \ No newline at end of file diff --git a/script/templates/ObjectiveScan.py b/script/templates/ObjectiveScan.py index d1e108d..718a1d3 100644 --- a/script/templates/ObjectiveScan.py +++ b/script/templates/ObjectiveScan.py @@ -32,7 +32,7 @@ init_eiger(EXPOSURE_TIME) try: lscan(objective, sensors, SCAN_RANGE[0], SCAN_RANGE[1], float(STEP_SIZE), latency=SETTLING_TIME, before_read=trigger_eiger, keep=False) finally: - if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": + if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": close_vg10() restore_eiger() print "Running time: " + str(time.time() - start) \ No newline at end of file