Inline Motor Screen
Important
Make sure the PCASpy tutorial server is running
For this screen, we want to present useful information to the user to operate the motors, and also provide a way for them to access other less-commonly-used parameters via an “Expert” screen. To make this screen re-usable in other displays, it will be necessary to use Macro Substitution that will later be replaced by the proper information for each motor.
The finished result will look like this:
Step 1.
Let’s start by opening Qt Designer and creating a new
Widget
.Step 2.
With the new form available, let’s add a GridLayout widget to it. To make it fill the whole form let’s select
Layout Vertically
for the form.Step 3.
Now that we have a layout, let’s take a look at the widgets on this screen:
Step 3.1.
The first
PyDMLabel
will display the description of the motor:Drag and drop a
PyDMLabel
at the previously addedGridLayout
.Set the
Channel
property of this label to:ca://${MOTOR}.DESC
.${MOTOR} is a macro that will later be replaced by a value sent by screens using this widget in embedded displays, related displays, or when launching using the command line.
Set the
displayFormat
property of this label to:String
.Expand the
Font
property and mark the checkbox forBold
.
Step 3.2.
The second widget is a
PyDMLineEdit
which will be used to set the desired position for the motor:Drag and drop a
PyDMLineEdit
into theGridLayout
on the side of the previously addedPyDMLabel
(Note: The border will become blue showing that the widget will be placed on the side and not on top or under the other widget).Set the
Channel
property of this line edit to:ca://${MOTOR}.VAL
.Change its
displayFormat
property toDecimal
.Expand the
sizePolicy
property and setHorizontal Policy
andVertical Policy
toFixed
.This will make the widget respect the size on screen.
Expand the
minimumSize
property and setWidth
to75
.This property will indicate the minimum size constrains for the widget and avoid this widget from being hidden or reduced to an unusable size on window resizing.
Step 3.3.
The third widget is a
PyDMLabel
which will be used to monitor the readback value for the motor:Drag and drop a
PyDMLabel
at theGridLayout
on the side of the previously addedPyDMLineEdit
.Set the
Channel
property of this line edit to:ca://${MOTOR}.RBV
.Change its
displayFormat
property toDecimal
.Expand the
sizePolicy
property and setHorizontal Policy
andVertical Policy
toFixed
.This will make the widget respect the size on screen.
Expand the
minimumSize
property and setWidth
to75
.This property will indicate the minimum size constraints for the widget and avoid this widget becoming hidden or reduced to an unusable size when a user resizes the window.
Step 3.4.
The fourth widget is a
PyDMByteIndicator
which will be used for visual feedback that the motor is moving:Drag and drop a
PyDMByteIndicator
into theGridLayout
on the side of the previously addedPyDMLabel
.Set the
Channel
property of this line edit to:ca://${MOTOR}.MOVN
.Turn off the
showLabels
property since we are only interested on the color for this widget.Set the
circles
property so we have a circle instead of a square.Expand the
sizePolicy
property and setHorizontal Policy
andVertical Policy
toFixed
.Expand the
minimumSize
property and setWidth
andHeight
to32
.Repeat the same previous step for the
maximumSize
property.
Step 3.5.
The fifth widget is a
PyDMPushButton
which will be used to stop the motor:Drag and drop a
PyDMPushButton
at theGridLayout
on the side of the previously addedPyDMByteIndicator
.Set the
channel
property of this line edit to:ca://${MOTOR}.STOP
.Set the
pressValue
property to1
.This is the value that will be written to the channel once the button is pressed.
Set the
text
property toStop
.Expand the
sizePolicy
property and setHorizontal Policy
toMinimum
and theVertical Policy
toFixed
.Set the
styleSheet
property tobackground-color: red;
in order to give the button a nice look and feel and bring the attention to it in case of emergency.
Step 3.6.
The sixth widget is also a
PyDMPushButton
which will be used to tweak the motor a certain distance in the positive direction:Drag and drop a
PyDMPushButton
into theGridLayout
on the side of the previously addedPyDMPushButton
.Set the
channel
property of this line edit to:ca://${MOTOR}.VAL
.Set the
pressValue
property to10
.Set the
relativeChange
property so the new value written to the channel will be relative to the channel’s current value.Set the
text
property toTw +10
.
Step 3.7.
The seventh widget is also a
PyDMPushButton
which will be used to tweak the motor a certain distance in the negative direction:Drag and drop a
PyDMPushButton
into theGridLayout
on the side of the previously addedPyDMPushButton
.Set the
channel
property of this line edit to:ca://${MOTOR}.VAL
.Set the
pressValue
property to-10
.Set the
relativeChange
property so the new value written to the channel will be relative to the channel’s current value.Set the
text
property toTw -10
.
Step 3.8.
The final widget is a
PyDMRelatedDisplayButton
which will be used to launch the engineer screen so users can configure advanced parameters and troubleshoot possible issues with the motor:Drag and drop a
PyDMRelatedDisplayButton
at theGridLayout
on the side of the previously addedPyDMPushButton
.Set the
text
property toEngineer...
.Add the string
exper_motor.ui
to thefilenames
property.Note
We will create the
expert_motor.ui
file in the next section.Set the
openInNewWindow
property so the screen will show up in a standalone window.Expand the
minimumSize
property and setWidth
to125
andHeight
to24
.Repeat the same previous step for the
maximumSize
property.
Step 3.9.
After adding all the widgets to the layout, it will look like this:
Let’s adjust the sizes and reduce the top and bottom margins on the layout.
Using the Object Inspector on the top-right corner, select the
gridLayout
object and:Set the property
layoutRightMargin
to5
.Set the property
layoutBottomMargin
to5
.Set the property
layoutHorizontalSpacing
to10
.Set the property
layoutVerticalSpacing
to5
.
Using the Object Inspector on the top-right corner, select the
Form
object and:Expand the
geometry
property and setWidth
to700
andHeight
to32
.Expand the
sizePolicy
property and setVertical Policy
toFixed
.Expand the
minimumSize
property and setWidth
to700
andHeight
to32
.Scroll all the way down on the property editor and set
layoutLeftMargin
,layoutTopMargin
,layoutRightMargin
,layoutBottomMargin
andlayoutSpacing
to0
so the form is very tight.Expand the
maximumSize
property and setHeight
to38
.
The end result will be something like this:
Step 4.
Save this file as
inline_motor.ui
.Warning
For this tutorial it is important to use this file name as it will be referenced at the other sections. If you change it, please remember to also change it in the next steps when referenced.
Step 5.
Test the Inline Motor Screen:
pydm -m '{"MOTOR":"IOC:m1"}' inline_motor.ui
Note
You can download this file using this link
.