This commit is contained in:
2018-08-24 12:07:28 +02:00
parent 3e41debde1
commit c6cd6123b0
22 changed files with 1010 additions and 132 deletions

View File

@@ -1,6 +1,7 @@
dispatcher=ch.psi.pshell.bs.Provider|tcp://localhost:9999|||
cam_server_local=ch.psi.pshell.bs.PipelineServer|localhost:8889|||true
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||true
#monit_cam=ch.psi.pshell.imaging.MjpegSource|http://axis-accc8e9cc87b.psi.ch/axis-cgi/mjpg/video.cgi?camera=2 reopen||-200|false
#stream=ch.psi.pshell.bs.Stream|<dispatcher> #false:boolean|||
#scalar=ch.psi.pshell.bs.Scalar|stream Int8Scalar|||
#cam=ch.psi.pshell.bs.StreamCamera|"tcp://gfa-lc6-64:10100" 1|||true
@@ -9,13 +10,13 @@ cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||true
#rp=ch.psi.pshell.epics.Positioner|TESTIOC:TESTCALCOUT:Input null rr|||
#webcam=ch.psi.pshell.webcam.Webcam|:2|||true
#det=ch.psi.pshell.epics.AreaDetector|13SIM1|||false
PiezoRoll1=ch.psi.pshell.epics.ControlledVariable|"TESTIOC:TESTCALCOUT:Input" TESTIOC:TESTCALCOUT:Output false|||true
$ser=ch.psi.pshell.serial.TcpDevice||||
$beam_ok=ch.psi.pshell.epics.ChannelString|CHANNEL|||
#PiezoRoll1=ch.psi.pshell.epics.ControlledVariable|"TESTIOC:TESTCALCOUT:Input" TESTIOC:TESTCALCOUT:Output false|||true
#$ser=ch.psi.pshell.serial.TcpDevice||||
#$beam_ok=ch.psi.pshell.epics.ChannelString|CHANNEL|||
#sc1=ch.psi.pshell.epics.Scaler|MTEST-HW3:JS|||true
#bragg=ch.psi.pshell.crlogic.CrlogicPositioner|MTEST-HW3:MOT1|||
#wago=ch.psi.pshell.modbus.ModbusTCP|SF-TEST-WAGO1:502|||
testd=ch.psi.pshell.device.DummyPositioner||||
#testd=ch.psi.pshell.device.DummyPositioner||||
#ralays=ch.psi.pshell.modbus.DigitalOutputArray|wago 0 16||1000|
#relay1=ch.psi.pshell.modbus.DigitalOutput|wago 0||1000|
#relay2=ch.psi.pshell.modbus.DigitalOutput|wago 1||1000|
@@ -30,10 +31,11 @@ testd=ch.psi.pshell.device.DummyPositioner||||
#m1=ch.psi.pshell.epics.Motor|MTEST-HW3:MOT1|||true
#ai1=ch.psi.pshell.epics.ChannelDouble|MTEST-HW3-AI1:AI_01|||true
#ai2=ch.psi.pshell.epics.ChannelDouble|MTEST-HW3-AI1:AI_05|||true
#mb=ch.psi.pshell.modbus.ModbusTCP|MTEST-CWAG-OFF:502|||
#$mb=ch.psi.pshell.modbus.ModbusTCP|MTEST-CWAG-OFF:502|||
#mbs=ch.psi.pshell.modbus.ModbusSerial||||
#mb_delay=ch.psi.pshell.modbus.Register|mb 0x1037|||
#mbdo=ch.psi.pshell.modbus.DigitalOutput|mb 4||50|
#mbdi=ch.psi.pshell.modbus.DigitalInput|mb 0||50|false
#$mbdi=ch.psi.pshell.modbus.DigitalInput|mb 0||50|false
#mbdoa=ch.psi.pshell.modbus.DigitalOutputArray|mb 0 10||50|
#mbdia=ch.psi.pshell.modbus.DigitalInputArray|mb 0 10||50|
#mbao=ch.psi.pshell.modbus.AnalogOutput|mb 0||100|
@@ -41,19 +43,19 @@ testd=ch.psi.pshell.device.DummyPositioner||||
#mbaoa=ch.psi.pshell.modbus.AnalogOutputArray|mb 0 10||100|
#mbaia=ch.psi.pshell.modbus.AnalogInputArray|mb 0 10||100|
#mot=ch.psi.pshell.epics.ChannelDouble|MTEST-GOBBO:MOT1 5|||true
dp=ch.psi.pshell.epics.DiscretePositioner|TESTIOC:CMD|||true
dev=ch.psi.pshell.device.DummyRegister|6|||
#dp=ch.psi.pshell.epics.DiscretePositioner|TESTIOC:CMD|||true
#dev=ch.psi.pshell.device.DummyRegister|6|||
#dev2=ch.psi.pshell.device.MyDevice||||
$vhq=ch.psi.pshell.epics.ChannelDouble|T-MMDV5:IST:2 6|Read||
outc=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTCALCOUT:Output|||true
inpc=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTCALCOUT:Input|||true
#$vhq=ch.psi.pshell.epics.ChannelDouble|T-MMDV5:IST:2 6|Read||
#outc=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTCALCOUT:Output|||true
#inpc=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTCALCOUT:Input|||true
out=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTCALCOUT:Output 6|||true
#outx=ch.psi.pshell.epics.ProcessVariable|TESTIOC:TESTCALCOUT:Output|||true
inp=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTCALCOUT:Input|||true
sin=ch.psi.pshell.epics.ChannelDouble|TESTIOC:TESTSINUS:SinCalc 3 true|||true
#sinx=ch.psi.pshell.epics.ProcessVariable|TESTIOC:TESTSINUS:SinCalc|||true
#average=ch.psi.pshell.device.Averager|sin||2000|
isin=ch.psi.pshell.epics.ChannelInteger|TESTIOC:TESTSINUS:SinCalc|||true
#isin=ch.psi.pshell.epics.ChannelInteger|TESTIOC:TESTSINUS:SinCalc|||true
arr=ch.psi.pshell.epics.ChannelDoubleArray|TESTIOC:TESTWF2:MyWF 6 -1 false|||true
pv=ch.psi.pshell.epics.ProcessVariable|TESTIOC:TESTCALCOUT:Input|||true
shutter=ch.psi.pshell.epics.BinaryPositioner|TESTIOC:TESTBO:MyBO TESTIOC:TESTBO:MyBO|||true
@@ -97,17 +99,17 @@ tst=ch.psi.pshell.imaging.FileSource|/Users/gobbo_a/dev/pshell/config/mxsc/image
#img2=ch.psi.pshell.imaging.FileSource|C:\\Users\\gobbo_a\\Pictures\\Chrysanthemum.jpg|||
#mxd=ch.psi.pshell.epics.AreaDetector|MX-SAMCAM|||
#mx=ch.psi.pshell.imaging.CameraSource|mxd||-1000|
$mymot=ch.psi.pshell.epics.Motor|TEST|||true
$mypos=ch.psi.pshell.epics.Positioner|SETPOINT READBACK|||true
$mycv=ch.psi.pshell.epics.ProcessVariable|SETPOINT|||true
#$mymot=ch.psi.pshell.epics.Motor|TEST|||true
#$mypos=ch.psi.pshell.epics.Positioner|SETPOINT READBACK|||true
#$mycv=ch.psi.pshell.epics.ProcessVariable|SETPOINT|||true
mu=ch.psi.pshell.device.DummyMotor||||true
delta=ch.psi.pshell.device.DummyMotor||||true
gam=ch.psi.pshell.device.DummyMotor||||true
gamma=ch.psi.pshell.device.DummyMotor||||true
eta=ch.psi.pshell.device.DummyMotor||||true
chi=ch.psi.pshell.device.DummyMotor||||true
phi=ch.psi.pshell.device.DummyMotor||||true
sixc=ch.psi.pshell.device.MotorGroupBase|mu delta gam eta chi phi|||
fivec=ch.psi.pshell.device.MotorGroupBase|delta gam eta chi phi|||
sixc=ch.psi.pshell.device.MotorGroupBase|mu delta gamma eta chi phi|||
fivec=ch.psi.pshell.device.MotorGroupBase|delta gamma eta chi phi|||
fourc=ch.psi.pshell.device.MotorGroupBase|delta eta chi phi|||
fourcv=ch.psi.pshell.device.MotorGroupBase|mu delta gam eta|||
en=ch.psi.pshell.device.DummyPositioner||||true
fourcv=ch.psi.pshell.device.MotorGroupBase|mu delta gamma eta|||
energy=ch.psi.pshell.device.DummyPositioner||||true

View File

@@ -1,11 +1,11 @@
#Thu Apr 26 17:55:10 CEST 2018
#Fri Aug 24 11:15:23 CEST 2018
ch.psi.jcae.ContextFactory.addressList=127.0.0.1\:54321
ch.psi.jcae.ContextFactory.maxArrayBytes=10000000
ch.psi.jcae.ChannelFactory.timeout=100
ch.psi.jcae.ChannelFactory.retries=1
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.impl.DefaultChannelService.retries=4
ch.psi.jcae.impl.DefaultChannelService.timeout=5000
ch.psi.jcae.impl.DefaultChannelService.retries=1
ch.psi.jcae.impl.DefaultChannelService.timeout=500
ch.psi.jcae.ContextFactory.autoAddressList=true
ch.psi.jcae.ContextFactory.useShellVariables=false
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false

View File

@@ -1,3 +1,4 @@
MXSC-1.10.0.jar=disabled
ScreenPanel3.java=disabled
Tomaz.java=disabled
ScreenPanel2.java=disabled

View File

@@ -1,7 +1,7 @@
#Tue Jun 19 17:19:37 CEST 2018
defaultSpeed=10.0
#Fri Aug 24 11:05:04 CEST 2018
defaultSpeed=50.0
estbilizationDelay=0
maxSpeed=10.0
maxSpeed=50.0
maxValue=360.0
minSpeed=0.1
minValue=-360.0

View File

@@ -1,4 +1,4 @@
#Tue Jun 19 17:19:36 CEST 2018
#Fri Aug 24 11:04:46 CEST 2018
defaultSpeed=50.0
estbilizationDelay=0
maxSpeed=50.0

10
devices/energy.properties Normal file
View File

@@ -0,0 +1,10 @@
#Fri Aug 24 11:58:39 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
unit=null

View File

@@ -1,7 +1,7 @@
#Tue Jun 19 17:19:37 CEST 2018
defaultSpeed=10.0
#Fri Aug 24 11:04:56 CEST 2018
defaultSpeed=50.0
estbilizationDelay=0
maxSpeed=10.0
maxSpeed=50.0
maxValue=360.0
minSpeed=0.1
minValue=-360.0

15
devices/gamma.properties Normal file
View File

@@ -0,0 +1,15 @@
#Fri Aug 24 11:49:29 CEST 2018
defaultSpeed=50.0
estbilizationDelay=0
maxSpeed=50.0
maxValue=180.0
minSpeed=0.1
minValue=-180.0
offset=0.0
precision=2
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
startRetries=1
unit=mm

View File

@@ -0,0 +1,20 @@
#Thu Aug 23 17:19:22 CEST 2018
flipHorizontally=false
flipVertically=false
grayscale=false
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
roiWidth=-1
roiX=0
roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=NaN
spatialCalOffsetY=NaN
spatialCalScaleX=NaN
spatialCalScaleY=NaN
spatialCalUnits=mm
transpose=false

View File

@@ -1,7 +1,7 @@
#Tue Jun 19 17:19:36 CEST 2018
defaultSpeed=10.0
#Fri Aug 24 11:05:25 CEST 2018
defaultSpeed=50.0
estbilizationDelay=0
maxSpeed=10.0
maxSpeed=50.0
maxValue=360.0
minSpeed=0.1
minValue=-360.0

View File

@@ -1,7 +1,7 @@
#Tue Jun 19 17:19:37 CEST 2018
defaultSpeed=10.0
#Fri Aug 24 11:05:11 CEST 2018
defaultSpeed=50.0
estbilizationDelay=0
maxSpeed=10.0
maxSpeed=50.0
maxValue=360.0
minSpeed=0.1
minValue=-360.0

View File

@@ -0,0 +1,61 @@
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.LayoutManager;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.WindowConstants;
public class SpinnerLayoutTest {
public JComponent makeUI() {
SpinnerNumberModel m = new SpinnerNumberModel(10, 0, 1000, 1);
JSpinner spinner = new JSpinner(m) {
@Override public void setLayout(LayoutManager mgr) {
super.setLayout(new SpinnerLayout());
}
};
spinner.set
JPanel p = new JPanel(new BorderLayout(5,5));
p.add(new JSpinner(m), BorderLayout.NORTH);
p.add(spinner, BorderLayout.SOUTH);
p.setBorder(BorderFactory.createEmptyBorder(16,16,16,16));
return p;
}
class SpinnerLayout extends BorderLayout {
@Override
public void addLayoutComponent(Component comp, Object constraints) {
if("Editor".equals(constraints)) {
constraints = "Center";
} else if("Next".equals(constraints)) {
constraints = "North";
} else if("Previous".equals(constraints)) {
constraints = "South";
}
super.addLayoutComponent(comp, constraints);
}
}
public static void createAndShowGUI() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(new SpinnerLayoutTest().makeUI());
f.setSize(320, 160);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
createAndShowGUI();
}
});
}
}

View File

@@ -16,19 +16,39 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="133" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="219" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="66" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="117" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSpinner1" min="-2" pref="138" max="-2" attributes="0"/>
<Component id="jSpinner2" min="-2" pref="138" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="48" max="-2" attributes="0"/>
<Component id="spinner" min="-2" pref="138" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="31" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="70" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jSpinner1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSpinner2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinner" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="16" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -42,5 +62,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="jSpinner1">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="now" stepSize="5" type="date"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="jSpinner2">
</Component>
<Component class="javax.swing.JSpinner" name="spinner">
</Component>
</SubComponents>
</Form>

View File

@@ -7,15 +7,186 @@ import ch.psi.pshell.ui.Console;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.Config;
import ch.psi.utils.State;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.WindowConstants;
/**
*
*/
public class Tomaz extends Panel {
/*
public JComponent makeUI() {
SpinnerNumberModel m = new SpinnerNumberModel(10, 0, 1000, 1);
JSpinner spinner = new JSpinner(m) {
@Override public void setLayout(LayoutManager mgr) {
super.setLayout(new SpinnerLayout());
}
};
JPanel p = new JPanel(new BorderLayout(5,5));
p.add(new JSpinner(m), BorderLayout.NORTH);
p.add(spinner, BorderLayout.SOUTH);
p.setBorder(BorderFactory.createEmptyBorder(16,16,16,16));
return p;
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
createAndShowGUI();
}
});
}
public static void createAndShowGUI() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(new SpinnerLayoutTest().makeUI());
f.setSize(320, 160);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
class SpinnerLayout extends BorderLayout {
@Override public void addLayoutComponent(Component comp, Object constraints) {
if("Editor".equals(constraints)) {
constraints = "Center";
} else if("Next".equals(constraints)) {
constraints = "North";
} else if("Previous".equals(constraints)) {
constraints = "South";
}
super.addLayoutComponent(comp, constraints);
}
} */
private static class HorizontalSpinnerLayoutManager implements LayoutManager
{
final Component bup;
final Component bdown;
final Component txt;
int buttom_width;
int buttom_height;
HorizontalSpinnerLayoutManager(JSpinner sp)
{
Component[] components = sp.getComponents();
bup = components[0];
bdown = components[1];
txt = components[2];
//((javax.swing.JButton)bup).getBorder()
buttom_width=bdown.getPreferredSize().width-3;
}
public void addLayoutComponent(String name, Component comp) {
}
public void removeLayoutComponent(Component comp) {
}
public Dimension preferredLayoutSize(Container parent) {
Insets in = parent.getInsets();
//return parent.getPreferredSize();
return new Dimension(2*buttom_width + Math.max(txt.getPreferredSize().width,12) , //Compressing a bit+ not considering insets on width
txt.getPreferredSize().height + in.top + in.bottom);
//Insets insets = parent.getInsets();
//insets
}
public Dimension minimumLayoutSize(Container parent) {
Insets in = parent.getInsets();
return new Dimension(2*buttom_width + txt.getMinimumSize().width ,
bdown.getMinimumSize().height + in.top + in.bottom);
}
public void layoutContainer(Container parent) {
Insets in = parent.getInsets();
int top=1;
int bottom=parent.getHeight()-1;
int left=1;
int right=parent.getWidth()-1;
int width=right-left;
int height=bottom-top;
// if ( isStyleXP())
// {
// bdown.setBounds(left, top+1, buttom_width, height-1);
// bup.setBounds(right-buttom_width, top, buttom_width, height-1);
// }
// else
{
bdown.setBounds(left, top, buttom_width, height);
bup.setBounds(right-buttom_width, top, buttom_width, height);
}
txt.setBounds( left+buttom_width, top, width- (2*buttom_width),height);
}
}
public static boolean setHorizontalSpinner(javax.swing.JSpinner sp)
{
if (sp.getLayout() instanceof HorizontalSpinnerLayoutManager)
return true;
if (sp.getComponents().length!=3)
return false;
sp.setLayout(new HorizontalSpinnerLayoutManager(sp));
//final Component bup = components[0];
//final Component bdown = components[1];
//final Component txt = components[2];
//sp.setComponentZOrder(bdown,0);
//sp.setComponentZOrder(txt,1);
//sp.setComponentZOrder(bup,2);
//javax.swing.BoxLayout layout = new javax.swing.BoxLayout(sp, javax.swing.BoxLayout.LINE_AXIS);
/*
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(sp);
layout.setAutoCreateGaps(false);
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addComponent(bdown, javax.swing.GroupLayout.PREFERRED_SIZE, bup.getPreferredSize().width, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt, javax.swing.GroupLayout.DEFAULT_SIZE, txt.getPreferredSize().width, Short.MAX_VALUE)
.addComponent(bup, javax.swing.GroupLayout.PREFERRED_SIZE, bup.getPreferredSize().width, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(bdown, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
sp.setLayout(layout);
*/
return true;
}
public static void setHorizontalSpinners(java.awt.Container container)
{
for (java.awt.Component c:container.getComponents())
{
if (c instanceof javax.swing.JSpinner)
setHorizontalSpinner((javax.swing.JSpinner)c);
else if (c instanceof java.awt.Container)
setHorizontalSpinners((java.awt.Container)c);
}
}
final Console console;
public Tomaz() {
@@ -29,6 +200,8 @@ public class Tomaz extends Panel {
}
}
};
setHorizontalSpinners(this);
setHorizontalSpinner(spinner);
}
@Override
@@ -68,6 +241,9 @@ public class Tomaz extends Panel {
private void initComponents() {
jButton1 = new javax.swing.JButton();
jSpinner1 = new javax.swing.JSpinner();
jSpinner2 = new javax.swing.JSpinner();
spinner = new javax.swing.JSpinner();
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
@@ -76,21 +252,38 @@ public class Tomaz extends Panel {
}
});
jSpinner1.setModel(new javax.swing.SpinnerDateModel());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(133, 133, 133)
.addComponent(jButton1)
.addContainerGap(219, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(66, 66, 66)
.addComponent(jButton1)
.addGap(117, 117, 117)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(spinner, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(31, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jButton1)
.addContainerGap(70, Short.MAX_VALUE))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(16, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@@ -108,5 +301,8 @@ public class Tomaz extends Panel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JSpinner jSpinner2;
private javax.swing.JSpinner spinner;
// End of variables declaration//GEN-END:variables
}

View File

@@ -28,7 +28,7 @@ from __future__ import absolute_import
import traceback
import Jama.Matrix
import Jama.Matrix
diffcalc_path = os.path.abspath(get_context().setup.expandPath("{script}/Lib/diffcalc"))
if not diffcalc_path in sys.path:
sys.path.append(diffcalc_path)
@@ -47,6 +47,7 @@ import ch.psi.pshell.device.PositionerConfig as PositionerConfig
import ch.psi.pshell.device.RegisterConfig as RegisterConfig
import ch.psi.pshell.device.Register as Register
_difcalc_names = {}
#
# Disable error handling designed for interactive use
@@ -76,21 +77,33 @@ class PositionerScannable(ScannableBase):
def getPosition(self):
return self.positioner.getPosition()
def _get_diffcalc_axis_names():
nu_name=diffcalc.hkl.you.constraints.NUNAME
return ("mu", "delta", nu_name, "eta", "chi", "phi")
class PositionerScannableGroup(ScannableGroup):
def __init__(self, name, motors):
def __init__(self, name, motors, diffcalc_axis_names=None):
self.name = name
print self.getInputNames()
global _difcalc_names
_difcalc_names = {}
positioners = []
for m in motors:
exec('self.' + m.name + ' = PositionerScannable(' + m.name + ', "' + m.name + '")')
exec('positioners.append(self.' + m.name + ')' )
if diffcalc_axis_names is None:
if len(motors) == 6: diffcalc_axis_names = _get_diffcalc_axis_names()
elif len(motors) == 5: diffcalc_axis_names = ("delta", "gam", "eta", "chi", "phi")
elif len(motors) == 4: diffcalc_axis_names = ("delta", "eta", "chi", "phi")
for i in range(len(motors)):
_difcalc_names[motors[i]] = diffcalc_axis_names[i]
exec('self.' + diffcalc_axis_names[i] + ' = PositionerScannable(' + motors[i].name + ', "' +diffcalc_axis_names[i] + '")')
exec('positioners.append(self.' + diffcalc_axis_names[i] + ')' )
#for m in motors:
# exec('self.' + m.name + ' = PositionerScannable(' + m.name + ', "' + m.name + '")')
# exec('positioners.append(self.' + m.name + ')' )
ScannableGroup.__init__(self, self.name, positioners)
class MotorGroupScannable(PositionerScannableGroup):
def __init__(self, motor_group):
def __init__(self, motor_group, diffcalc_axis_names=None):
self.motor_group = motor_group
PositionerScannableGroup.__init__(self, motor_group.name, motor_group.motors)
PositionerScannableGroup.__init__(self, motor_group.name, motor_group.motors, diffcalc_axis_names)
class ScannableAdapter(HardwareAdapter):
@@ -123,8 +136,8 @@ class ScannableAdapter(HardwareAdapter):
return self.diffractometer.getName()
class MotorGroupAdapter(ScannableAdapter):
def __init__(self, diffractometer, energy, energy_multiplier_to_kev=1):
self.diffractometer = MotorGroupScannable(diffractometer)
def __init__(self, diffractometer, energy, energy_multiplier_to_kev=1, diffcalc_axis_names=None):
self.diffractometer = MotorGroupScannable(diffractometer, diffcalc_axis_names)
self.energy = PositionerScannable(energy)
self.energy.level = 3
ScannableAdapter.__init__(self, self.diffractometer, self.energy, energy_multiplier_to_kev)
@@ -132,12 +145,12 @@ class MotorGroupAdapter(ScannableAdapter):
class Wavelength(RegisterBase):
def doRead(self):
try:
return get_wl().getPosition()
return get_wavelength().getPosition()
except:
return None
def doWrite(self, val):
get_wl().asynchronousMoveTo(val)
get_wavelength().asynchronousMoveTo(val)
###################################################################################################
@@ -197,28 +210,60 @@ class HklGroup(RegisterBase, Register.RegisterArray):
self.hkl.asynchronousMoveTo(pos)
def sim(self, pos):
self.hkl.simulateMoveTo(pos)
return self.hkl.simulateMoveTo(pos)
###################################################################################################
# System setup
###################################################################################################
def setup_axis(motor, min=None, max=None, cut=None):
name = _difcalc_names[motor]
if min is not None: hardware.setmin(name, min)
if max is not None: hardware.setmax(name, max)
if cut is not None: hardware.setcut(name, cut)
you = None
dc, ub, hardware, hkl = None, None, None, None
_motor_group = None
def setup_diff(diffractometer, energy, geometry=None):
def setup_diff(diffractometer, energy, diffcalc_axis_names = None, geometry=None):
"""
diffractometer: Motor group containing:
- mu, delta, gam, eta, chi, phi (six circle) or
- delta, gam, eta, chi, phi (ficve circle) or
- delta, eta, chi, phi (four circle)
diffractometer: Diffraction motor group
energy: Positioner having energy in kev
geometry: YouGeometry extension. If none, uses default
diffcalc_axis_names: if None use defaults:
- mu, delta, gam, eta, chi, phi (six circle)
- delta, gam, eta, chi, phi (ficve circle)
- delta, eta, chi, phi (four circle)
"""
global you, dc, ub, hardware, hkl, _motor_group
_motor_group = diffractometer
you = None
if geometry is not None:
settings.geometry = geometry
elif diffcalc_axis_names is not None:
class CustomGeometry(YouGeometry):
def __init__(self):
self.all_axis_names = _get_diffcalc_axis_names()
self.my_axis_names = diffcalc_axis_names
fixed_constraints = {}
for axis in self.all_axis_names:
if not axis in self.my_axis_names:
fixed_constraints[axis] = 0
YouGeometry.__init__(self, diffractometer.name, fixed_constraints)
def physical_angles_to_internal_position(self, physical_angle_tuple):
pos=[]
index = 0
for axis in self.all_axis_names:
pos.append(physical_angle_tuple[index] if (axis in self.my_axis_names) else 0)
index = index+1
return YouPosition(*pos)
def internal_position_to_physical_angles(self, internal_position):
pos = internal_position.totuple()
ret = []
for i in range (len(self.all_axis_names)):
if self.all_axis_names[i] in self.my_axis_names:
ret.append(pos[i])
return tuple(ret)
settings.geometry = CustomGeometry()
elif len(diffractometer.motors) == 6:
settings.geometry = SixCircle()
elif len(diffractometer.motors) == 5:
@@ -227,7 +272,7 @@ def setup_diff(diffractometer, energy, geometry=None):
settings.geometry = FourCircle()
else:
raise Exception("Invalid motor group")
settings.hardware = MotorGroupAdapter(diffractometer, energy)
settings.hardware = MotorGroupAdapter(diffractometer, energy, diffcalc_axis_names = diffcalc_axis_names)
settings.ubcalc_persister = UbCalculationNonPersister()
settings.axes_scannable_group = settings.hardware.diffractometer
settings.energy_scannable = settings.hardware.energy
@@ -243,17 +288,31 @@ def setup_diff(diffractometer, energy, geometry=None):
from diffcalc.hkl.you import hkl
add_device(HklGroup("hkl_group"), True)
add_device(Wavelength("wl", 6), True)
add_device(Wavelength("wavelength", 6), True)
hkl_group.polling = 250
wl.polling = 250
wavelength.polling = 250
def setup_axis(name, min=None, max=None, cut=None):
if min is not None: hardware.setmin(name, min)
if max is not None: hardware.setmax(name, max)
if cut is not None: hardware.setcut(name, cut)
#Initialize ranges to motors config
for m in diffractometer.motors:
setup_axis(m, m.minValue, m.maxValue)
def close_diff():
try:
hkl_group.close()
wavelength.close()
remove_device(hkl_group)
remove_device(wavelength)
except:
pass
def print_axis_setup():
print "Diffcalc names:"
for m in _difcalc_names.keys():
print " \t" + m.name + " = " + _difcalc_names[m]
print "------------------------------------------------------"
hardware.hardware()
###################################################################################################
# Acceess functions
@@ -267,7 +326,7 @@ def get_en():
def get_motor_group():
return _motor_group
def get_wl():
def get_wavelength():
return you.wl
def get_hkl():
@@ -277,7 +336,16 @@ def hkl_to_angles(h, k, l, energy=None):
return dc.hkl_to_angles(h, k, l, energy)
def angles_to_hkl(positions, energy=None):
return dc.angles_to_hkl(positions, energy=None)
return dc.angles_to_hkl(positions, energy)
def hkl_read():
return hkl_group.read()
def hkl_write(h, k, l):
hkl_group.write([h,k,l])
def hkl_simulate(h, k, l):
return hkl_group.sim([h,k,l])
def con(*args):
hkl.con(*args)
@@ -334,6 +402,7 @@ def hklscan(vector, readables,latency = 0.0, passes = 1, **pars):
def test_diffcalc():
print "Start test"
en.move(20.0)
delta.config.maxSpeed = 50.0
delta.speed = 50.0
@@ -341,10 +410,10 @@ def test_diffcalc():
#Setup
setup_diff(sixc, en)
setup_axis('gam', 0, 179)
setup_axis('delta', 0, 179)
setup_axis('delta', min=0)
setup_axis('phi', cut=-180.0)
setup_axis(gamma, 0, 179)
setup_axis(delta, 0, 179)
setup_axis(delta, min=0)
setup_axis(phi, cut=-180.0)
print_axis_setup()
#Orientation
@@ -356,7 +425,7 @@ def test_diffcalc():
# Add 1st reflection (demonstrating the hardware adapter)
settings.hardware.wavelength = 1
ub.c2th([1, 0, 0]) # energy from hardware
settings.hardware.position = 0, 60, 0, 30, 0, 0
settings.hardware.position = 0, 20, 10, 10, 0, 0
ub.addref([1, 0, 0])# energy and position from hardware
# Add 2nd reflection (this time without the harware adapter)
ub.c2th([0, 1, 0], 12.39842)
@@ -377,8 +446,8 @@ def test_diffcalc():
print hkl_to_angles(1, 0, 0)
sixc.write([0, 60, 0, 30, 90, 0])
print "sixc=" , sixc.position
wl.write(1.0)
print "wl = ", wl.read()
wavelength.write(1.0)
print "wavelength = ", wavelength.read()
ub.lastub()
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
ub.showref()

View File

@@ -0,0 +1,401 @@
###################################################################################################\
# Diffcalc utilities
###################################################################################################
###################################################################################################\
# Installaling
###################################################################################################
#1- Download from: https://github.com/DiamondLightSource/diffcalc/archive/master.zip
#2- Extract the contents to {script}/Lib/diffcalc
#3- Download http://central.maven.org/maven2/gov/nist/math/jama/1.0.3/jama-1.0.3.jar
# to the extensions folder.
###################################################################################################\
# Library loading and Hardware setup
###################################################################################################
#1- Create a MotorGroup with the diffractometer motors
# e.g. 'sixc', containing mu, delta, gam, eta, chi, phi motors (gam = nu)
# or 'fivec', containing delta, gam, eta, chi, phi motors
# or 'fourc', containing delta, eta, chi, phi motors
#2- Create positioner to read/set the energy in kEv, e.g. named 'en'
#3- Execute: run("diffutils")
#4- Execute: setup_diff(sixc, en)
from __future__ import absolute_import
import traceback
import Jama.Matrix
diffcalc_path = os.path.abspath(get_context().setup.expandPath("{script}/Lib/diffcalc"))
if not diffcalc_path in sys.path:
sys.path.append(diffcalc_path)
import diffcalc
from diffcalc import settings
from diffcalc.hkl.you.geometry import YouGeometry,SixCircle, FiveCircle, FourCircle, YouPosition
from diffcalc.hardware import HardwareAdapter
from diffcalc.ub.persistence import UbCalculationNonPersister
from diffcalc.gdasupport.minigda.scannable import ScannableBase, ScannableGroup
#from diffcalc.gdasupport.minigda import command
from diffcalc.hardware import HardwareAdapter
import ch.psi.pshell.device.PositionerConfig as PositionerConfig
import ch.psi.pshell.device.RegisterConfig as RegisterConfig
import ch.psi.pshell.device.Register as Register
#
# Disable error handling designed for interactive use
#diffcalc.util.DEBUG = True
###################################################################################################
# Device mapping to difcalc
###################################################################################################
class PositionerScannable(ScannableBase):
def __init__(self, positioner, name = None):
self.positioner = positioner
self.name = positioner.name if name is None else name
self.inputNames = [self.name]
self.outputFormat = ['% 6.4f']
self.level = 3
def isBusy(self):
return self.positioner.state == State.Busy
def waitWhileBusy(self):
self.positioner.waitReady(-1)
def asynchronousMoveTo(self, new_position):
#print "Moving " , self.name, " to: ", new_position
self.positioner.moveAsync(float(new_position), -1)
def getPosition(self):
return self.positioner.getPosition()
class PositionerScannableGroup(ScannableGroup):
def __init__(self, name, motors):
self.name = name
print self.getInputNames()
positioners = []
for m in motors:
exec('self.' + m.name + ' = PositionerScannable(' + m.name + ', "' + m.name + '")')
exec('positioners.append(self.' + m.name + ')' )
ScannableGroup.__init__(self, self.name, positioners)
class MotorGroupScannable(PositionerScannableGroup):
def __init__(self, motor_group):
self.motor_group = motor_group
PositionerScannableGroup.__init__(self, motor_group.name, motor_group.motors)
class ScannableAdapter(HardwareAdapter):
def __init__(self, diffractometer, energy, energy_multiplier_to_kev=1):
self.diffractometer = diffractometer
self.energy = energy
self.energy_multiplier_to_kev = energy_multiplier_to_kev
input_names = diffractometer.getInputNames()
HardwareAdapter.__init__(self, input_names)
#Returns the current physical POSITIONS
def get_position(self):
"""
pos = getDiffractometerPosition() -- returns the current physical
diffractometer position as a list in degrees
"""
return self.diffractometer.getPosition()
#returns energy in kEv
def get_energy(self):
"""energy = get_energy() -- returns energy in kEv (NOT eV!) """
multiplier = self.energy_multiplier_to_kev
energy = self.energy.getPosition() * multiplier
if energy is None:
raise DiffcalcException("Energy has not been set")
return energy
@property
def name(self):
return self.diffractometer.getName()
class MotorGroupAdapter(ScannableAdapter):
def __init__(self, diffractometer, energy, energy_multiplier_to_kev=1):
self.diffractometer = MotorGroupScannable(diffractometer)
self.energy = PositionerScannable(energy)
self.energy.level = 3
ScannableAdapter.__init__(self, self.diffractometer, self.energy, energy_multiplier_to_kev)
class Wavelength(RegisterBase):
def doRead(self):
try:
return get_wl().getPosition()
except:
return None
def doWrite(self, val):
get_wl().asynchronousMoveTo(val)
###################################################################################################
# HKL Pseudo-devices
###################################################################################################
class HklPositoner (PositionerBase):
def __init__(self, name, index, hkl_group):
PositionerBase.__init__(self, name, PositionerConfig())
self.setParent(hkl_group)
self.index = index
def doRead(self):
return self.getParent()._setpoint[self.index]
def doWrite(self, value):
#print "Setting " , self.getName(), "to: ", value
pos = [None, None, None]
pos[self.index] = value
self.getParent().write(pos)
def doReadReadback(self):
if java.lang.Thread.currentThread() != self.getParent()._updating_thread:
self.getParent().update()
return self.getParent()._readback[self.index]
class HklGroup(RegisterBase, Register.RegisterArray):
def __init__(self, name):
RegisterBase.__init__(self, name, RegisterConfig())
self.hkl=get_hkl()
self.h, self.k, self.l = HklPositoner("h", 0, self), HklPositoner("k", 1, self), HklPositoner("l", 2, self)
add_device(self.h, True)
add_device(self.k, True)
add_device(self.l, True)
self._setpoint = self.doRead()
self._updating = False
def getSize(self):
return 3
def doRead(self):
try:
self._readback = self.hkl.getPosition()
self._updating_thread = java.lang.Thread.currentThread()
self.h.update()
self.k.update()
self.l.update()
except:
#traceback.print_exc()
self._readback = (None, None, None)
finally:
self._updating_thread = None
return self._readback
def doWrite(self, pos):
self._setpoint = pos
#print "Moving to: " + str(pos)
self.hkl.asynchronousMoveTo(pos)
def sim(self, pos):
self.hkl.simulateMoveTo(pos)
###################################################################################################
# System setup
###################################################################################################
you = None
dc, ub, hardware, hkl = None, None, None, None
_motor_group = None
def setup_diff(diffractometer, energy, geometry=None, nu_name = None):
"""
diffractometer: Motor group containing:
- mu, delta, gam, eta, chi, phi (six circle) or
- delta, gam, eta, chi, phi (ficve circle) or
- delta, eta, chi, phi (four circle)
energy: Positioner having energy in kev
geometry: YouGeometry extension. If none, uses default
nu_name: specify the name of nu motor (default = "gam")
"""
global you, dc, ub, hardware, hkl, _motor_group
_motor_group = diffractometer
you = None
diffcalc.hkl.you.constraints.NUNAME = "gam" if (nu_name is None) else nu_name
if geometry is not None:
settings.geometry = geometry
elif len(diffractometer.motors) == 6:
settings.geometry = SixCircle()
elif len(diffractometer.motors) == 5:
settings.geometry = FiveCircle()
elif len(diffractometer.motors) == 4:
settings.geometry = FourCircle()
else:
raise Exception("Invalid motor group")
settings.hardware = MotorGroupAdapter(diffractometer, energy)
settings.ubcalc_persister = UbCalculationNonPersister()
settings.axes_scannable_group = settings.hardware.diffractometer
settings.energy_scannable = settings.hardware.energy
settings.ubcalc_strategy = diffcalc.hkl.you.calc.YouUbCalcStrategy()
settings.angles_to_hkl_function = diffcalc.hkl.you.calc.youAnglesToHkl
from diffcalc.gdasupport import you
reload(you)
# These must be imported AFTER the settings have been configured
from diffcalc.dc import dcyou as dc
from diffcalc.ub import ub
from diffcalc import hardware
from diffcalc.hkl.you import hkl
add_device(HklGroup("hkl_group"), True)
add_device(Wavelength("wl", 6), True)
hkl_group.polling = 250
wl.polling = 250
def setup_axis(name, min=None, max=None, cut=None):
if min is not None: hardware.setmin(name, min)
if max is not None: hardware.setmax(name, max)
if cut is not None: hardware.setcut(name, cut)
def print_axis_setup():
hardware.hardware()
###################################################################################################
# Acceess functions
###################################################################################################
def get_diff():
return settings.hardware.diffractometer
def get_en():
return settings.hardware.energy
def get_motor_group():
return _motor_group
def get_wl():
return you.wl
def get_hkl():
return you.hkl
def hkl_to_angles(h, k, l, energy=None):
return dc.hkl_to_angles(h, k, l, energy)
def angles_to_hkl(positions, energy=None):
return dc.angles_to_hkl(positions, energy=None)
def con(*args):
hkl.con(*args)
def uncon(name):
hkl.uncon(name)
def print_con():
hkl.con()
###################################################################################################
# HKL Combined Scan
###################################################################################################
def hklscan(vector, readables,latency = 0.0, passes = 1, **pars):
"""
HKL Scan:
Args:
vector(list of lists): HKL values to be scanned
readables(list of Readable): Sensors to be sampled on each step.
latency(float, optional): settling time for each step before readout, defaults to 0.0.
passes(int, optional): number of passes
pars(keyworded variable length arguments, optional): scan optional named arguments:
- title(str, optional): plotting window name.
- hidden(bool, optional): if true generates no effects on user interface.
- before_read (function, optional): callback on each step, before sampling. Arguments: positions, scan
- after_read (function, optional): callback on each step, after sampling. Arguments: record, scan.
- before_pass (function, optional): callback before each scan pass execution. Arguments: pass_num, scan.
- after_pass (function, optional): callback after each scan pass execution. Arguments: pass_num, scan.
- Aditional arguments defined by set_exec_pars.
Returns:
ScanResult object.
"""
readables=to_list(string_to_obj(readables))
pars["initial_move"] = False
scan = ManualScan([h,k,l], readables ,vector[0], vector[-1], [len(vector)-1] * 3, dimensions = 1)
if not "domain_axis" in pars.keys():
pars["domain_axis"] = "Index"
processScanPars(scan, pars)
scan.start()
try:
for pos in vector:
#print "Writing ", pos
hkl_group.write(pos)
time.sleep(0.1) #Make sure is busy
get_motor_group().update()
get_motor_group().waitReady(-1)
time.sleep(latency)
hkl_group.update()
scan.append ([h.take(), k.take(), l.take()], [h.getPosition(), k.getPosition(), l.getPosition()], [readable.read() for readable in readables ])
finally:
scan.end()
return scan.result
def test_diffcalc():
en.move(20.0)
delta.config.maxSpeed = 50.0
delta.speed = 50.0
delta.move(1.0)
#Setup
setup_diff(sixc, en)
setup_axis('gam', 0, 179)
setup_axis('delta', 0, 179)
setup_axis('delta', min=0)
setup_axis('phi', cut=-180.0)
print_axis_setup()
#Orientation
help(ub.ub)
ub.listub()
# Create a new ub calculation and set lattice parameters
ub.newub('test')
ub.setlat('cubic', 1, 1, 1, 90, 90, 90)
# Add 1st reflection (demonstrating the hardware adapter)
settings.hardware.wavelength = 1
ub.c2th([1, 0, 0]) # energy from hardware
settings.hardware.position = 0, 60, 0, 30, 0, 0
ub.addref([1, 0, 0])# energy and position from hardware
# Add 2nd reflection (this time without the harware adapter)
ub.c2th([0, 1, 0], 12.39842)
ub.addref([0, 1, 0], [0, 60, 0, 30, 0, 90], 12.39842)
# check the state
ub.ub()
ub.checkub()
#Constraints
help(hkl.con)
hkl.con('qaz', 90)
hkl.con('a_eq_b')
hkl.con('mu', 0)
hkl.con()
#Motion
print angles_to_hkl((0., 60., 0., 30., 0., 0.))
print hkl_to_angles(1, 0, 0)
sixc.write([0, 60, 0, 30, 90, 0])
print "sixc=" , sixc.position
wl.write(1.0)
print "wl = ", wl.read()
ub.lastub()
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
ub.showref()
ub.swapref(1,2)
#print you.hkl
#pos(get_hkl())
hkl_group.read()
#you.hkl.simulateMoveTo([0,1,1])
#sim(get_hkl(), [0,1,1])
hkl_group.sim([0.0,1.0,1.0])
#pos(get_hkl(), [0,1,1])
hkl_group.write([0.0,1.0,1.0])
#Scans
lscan(l, [sin], 1.0, 1.5, 0.1)
ascan([k,l], [sin], [1.0, 1.0], [1.2, 1.3], [0.1, 0.1], zigzag=True, parallel_positioning = False)
vector = [[1.0,1.0,1.0], [1.0,1.0,1.1], [1.0,1.0,1.2], [1.0,1.0,1.4]]
hklscan(vector, [sin, arr], 0.9)

View File

@@ -1,6 +1,4 @@
en.move(20.0)
delta.config.maxSpeed = 50.0
delta.speed = 50.0
energy.move(20.0)
delta.move(1.0)
run("diffcalc/diffutils")
@@ -8,12 +6,12 @@ run("diffcalc/diffutils")
#Setup
###################################################################################################
setup_diff(fivec, en)
setup_diff(fivec, energy)
# Set some limits
setup_axis('gam', 0, 179)
setup_axis('delta', 0, 179)
setup_axis('delta', min=0)
setup_axis('phi', cut=-180.0)
setup_axis(gamma, 0, 120)
setup_axis(delta, 0, 179)
setup_axis(delta, min=0)
setup_axis(phi, cut=-180.0)
print_axis_setup()
@@ -58,15 +56,15 @@ print angles_to_hkl((60., 0., 30., 0., 0.))
print hkl_to_angles(1, 0, 0)
fivec.write([60, 0, 30, 90, 0])
print "fivec=" , fivec.position
wl.write(1.0)
print "wl = ", wl.read()
wavelength.write(1.0)
print "wavelength = ", wavelength.read()
"""
# Load the last ub calculation used
ub.lastub()
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
ub.showref()
ub.swapref(1,2)
"""
#print you.hkl
#pos(get_hkl())
hkl_group.read()

View File

@@ -1,6 +1,4 @@
en.move(20.0)
delta.config.maxSpeed = 50.0
delta.speed = 50.0
energy.move(20.0)
delta.move(1.0)
run("diffcalc/diffutils")
@@ -8,11 +6,11 @@ run("diffcalc/diffutils")
#Setup
###################################################################################################
setup_diff(fourc, en)
setup_diff(fourc, energy)
# Set some limits
setup_axis('delta', 0, 179)
setup_axis('delta', min=0)
setup_axis('phi', cut=-180.0)
setup_axis(delta, 0, 179)
setup_axis(delta, min=0)
setup_axis(phi, cut=-180.0)
print_axis_setup()
@@ -47,6 +45,7 @@ ub.checkub()
###################################################################################################
help(hkl.con)
hkl.con('a_eq_b')
#hkl.con('chi',0)
hkl.con()
###################################################################################################\
@@ -56,14 +55,16 @@ print angles_to_hkl((60., 30., 0., 0.))
print hkl_to_angles(1, 0, 0)
fourc.write([60, 30, 90, 0])
print "fourc=" , fourc.position
wl.write(1.0)
print "wl = ", wl.read()
wavelength.write(1.0)
print "wavelength = ", wavelength.read()
"""
# Load the last ub calculation used
ub.lastub()
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
ub.showref()
ub.swapref(1,2)
"""
#print you.hkl
#pos(get_hkl())
@@ -78,7 +79,7 @@ hkl_group.write([0.0,1.0,1.0])
###################################################################################################\
#Scans
###################################################################################################
#lscan(l, [sin], 1.0, 1.5, 0.1)
#ascan([k,l], [sin], [1.0, 1.0], [1.2, 1.3], [0.1, 0.1], zigzag=True, parallel_positioning = False)
lscan(l, [sin], 1.0, 1.5, 0.1)
ascan([k,l], [sin], [1.0, 1.0], [1.2, 1.3], [0.1, 0.1], zigzag=True, parallel_positioning = False)
vector = [[1.0,1.0,1.0], [1.0,1.0,1.1], [1.0,1.0,1.2], [1.0,1.0,1.4]]
hklscan(vector, [sin, arr])

View File

@@ -0,0 +1,64 @@
run("diffcalc/diffutils")
###################################################################################################\
#Setup
###################################################################################################
energy.move(8.0)
#alpha, delta, gamma, omegaV
setup_diff(fourcv, energy, ("mu", "delta", "gam", "eta"))
print_axis_setup()
setup_axis(mu, mu.getMinValue(), mu.getMaxValue())
setup_axis(delta, delta.getMinValue(), 90) #delta.getMaxValue())
setup_axis(gamma, 0, gamma.getMaxValue())
setup_axis(eta, eta.getMinValue(), eta.getMaxValue())
###################################################################################################\
#Orientation
###################################################################################################
help(ub.ub)
ub.listub()
#alpha delta gamma omegaV
# Create a new ub calculation and set lattice parameters
ub.newub('test')
ub.setlat('cubic', 5.114, 5.8361, 11.058, 90, 90, 90)
en = 8
#ub.c2th([0, 0, 4], en)
#ub.addref([0, 0, 4]) #From current position and ekergy
ub.addref([0, 0, 4], [16.2785, 0.0, 32.5568, 0.0], en)
#ub.c2th([2, 0, 12], en)
ub.addref([2, 0, 12], [71.8285, 37.3082, 138.7440, 0.0], en)
#ub.c2th([1, -4, 10], en)
ub.addref([1, -4, 10], [27.7185, 17.6409 , 128.4220, 0.0], en)
ub.ub()
#ub.setub([[1.22862,0.00000,0.00000], [-0.00000,1.07663,0.00000], [-0.00000,-0.00000,0.56820]])
# check the state
ub.checkub()
###################################################################################################\
#Constraints
###################################################################################################
help(hkl.con)
#hkl.con('a_eq_b')
#hkl.con('eta:0')
hkl.con( 'eta', 0)
###################################################################################################\
#Motion
###################################################################################################
#print angles_to_hkl((16.278, 0.0000, 32.5568, 0.0))
print angles_to_hkl((44.3400, 0.0000, 123.7322 , 0.0))
print hkl_to_angles(2, -2, 10)

View File

@@ -1,19 +1,20 @@
en.move(20.0)
delta.config.maxSpeed = 50.0
delta.speed = 50.0
energy.move(20.0)
delta.move(1.0)
run("diffcalc/diffutils")
###################################################################################################\
#Setup
###################################################################################################
setup_diff(sixc, en)
setup_diff(sixc, energy)
# Set some limits
setup_axis('gam', 0, 179)
setup_axis('delta', 0, 179)
setup_axis('delta', min=0)
setup_axis('phi', cut=-180.0)
setup_axis(gamma, 0, 179)
setup_axis(delta, 0, 179)
setup_axis(delta, min=0)
setup_axis(phi, cut=-180.0)
print_axis_setup()
@@ -59,13 +60,15 @@ print angles_to_hkl((0., 60., 0., 30., 0., 0.))
print hkl_to_angles(1, 0, 0)
sixc.write([0, 60, 0, 30, 90, 0])
print "sixc=" , sixc.position
wl.write(1.0)
print "wl = ", wl.read()
wavelength.write(1.0)
print "wavelength = ", wavelength.read()
"""
ub.lastub()
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
ub.showref()
ub.swapref(1,2)
"""
#print you.hkl
#pos(get_hkl())

View File

@@ -14,7 +14,7 @@ import ch.psi.pshell.crlogic.CrlogicSensor as CrlogicSensor
###################################################################################################
import ch.psi.pshell.data.LayoutSF as LayoutSF
LayoutSF.setExperimentArguments([PiezoRoll1, testd, pv, motor, pe, cv, en, sin])
LayoutSF.setExperimentArguments([pv, motor, pe, cv, en, sin])
@@ -121,7 +121,7 @@ class SimulatedInput(Readable):
sout = SimulatedOutput()
sinp = SimulatedInput()
for m in mu, delta, gam, eta, chi, phi:
for m in mu, delta, gamma, eta, chi, phi:
m.setSpeed(m.config.defaultSpeed)
#Controler Evenrt Listener
@@ -756,4 +756,11 @@ waveform1.setPolling(1000)
image1.setPolling(-200)
add_device(DummyPositioner("phase"),True)
"""
"""
class DigitalInput(ReadonlyRegisterBase):
def doRead(self):
return False if (int(time.time()) %2 == 0 ) else True
add_device(DigitalInput("di"),True)
di.polling=1000

View File

@@ -1,6 +1,4 @@
en.move(20.0)
delta.config.maxSpeed = 50.0
delta.speed = 50.0
energy.move(20.0)
delta.move(1.0)
run("diffcalc/diffutils")
@@ -32,14 +30,13 @@ class FourCircleX04SA_V(YouGeometry):
###################################################################################################
#alp, del, gam, ov
FourCircleX04SA_V()
setup_diff(fourcv, en, FourCircleX04SA_V())
setup_diff(fourcv, energy, ("mu", "delta", "gam", "eta"), geometry=FourCircleX04SA_V())
# Set some limits
setup_axis('delta', 0, 90)
setup_axis('delta', min=0)
#setup_axis('gam', 0, 180)
#setup_axis('eta', cut=-180.0)
setup_axis(delta, 0, 90)
setup_axis(delta, min=0)
#setup_axis(gamma, 0, 180)
#setup_axis(eta, cut=-180.0)
print_axis_setup()
@@ -83,14 +80,16 @@ print angles_to_hkl((0.0, 60., 0.0, 30.))
print hkl_to_angles(1, 0, 0)
fourc.write([60, 30, 90, 0])
print "fourc=" , fourc.position
wl.write(1.0)
print "wl = ", wl.read()
wavelength.write(1.0)
print "wavelength = ", wavelength.read()
"""
# Load the last ub calculation used
ub.lastub()
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
ub.showref()
ub.swapref(1,2)
"""
#print you.hkl
#pos(get_hkl())