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:

Inline Motor Screen

Inline Motor Screen

  • Step 1.

    Let’s start by opening Qt Designer and creating a new Widget.

    ../../_images/new_widget.gif
  • 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.

    ../../_images/inline_layout.gif
  • Step 3.

    Now that we have a layout, let’s take a look at the widgets on this screen:

    ../../_images/widgets1.png
    • Step 3.1.

      The first PyDMLabel will display the description of the motor:

      1. Drag and drop a PyDMLabel at the previously added GridLayout.

      2. 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.

      3. Set the displayFormat property of this label to: String.

      4. Expand the Font property and mark the checkbox for Bold.

      ../../_images/inline_desc.gif
    • Step 3.2.

      The second widget is a PyDMLineEdit which will be used to set the desired position for the motor:

      1. Drag and drop a PyDMLineEdit into the GridLayout on the side of the previously added PyDMLabel (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).

      2. Set the Channel property of this line edit to: ca://${MOTOR}.VAL.

      3. Change its displayFormat property to Decimal.

      4. Expand the sizePolicy property and set Horizontal Policy and Vertical Policy to Fixed.

        • This will make the widget respect the size on screen.

      5. Expand the minimumSize property and set Width to 75.

        • 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.

      ../../_images/inline_3_2.gif
    • Step 3.3.

      The third widget is a PyDMLabel which will be used to monitor the readback value for the motor:

      1. Drag and drop a PyDMLabel at the GridLayout on the side of the previously added PyDMLineEdit.

      2. Set the Channel property of this line edit to: ca://${MOTOR}.RBV.

      3. Change its displayFormat property to Decimal.

      4. Expand the sizePolicy property and set Horizontal Policy and Vertical Policy to Fixed.

        • This will make the widget respect the size on screen.

      5. Expand the minimumSize property and set Width to 75.

        • 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.

      ../../_images/inline_3_3.gif
    • Step 3.4.

      The fourth widget is a PyDMByteIndicator which will be used for visual feedback that the motor is moving:

      1. Drag and drop a PyDMByteIndicator into the GridLayout on the side of the previously added PyDMLabel.

      2. Set the Channel property of this line edit to: ca://${MOTOR}.MOVN.

      3. Turn off the showLabels property since we are only interested on the color for this widget.

      4. Set the circles property so we have a circle instead of a square.

      5. Expand the sizePolicy property and set Horizontal Policy and Vertical Policy to Fixed.

      6. Expand the minimumSize property and set Width and Height to 32.

      7. Repeat the same previous step for the maximumSize property.

      ../../_images/inline_3_4.gif
    • Step 3.5.

      The fifth widget is a PyDMPushButton which will be used to stop the motor:

      1. Drag and drop a PyDMPushButton at the GridLayout on the side of the previously added PyDMByteIndicator.

      2. Set the channel property of this line edit to: ca://${MOTOR}.STOP.

      3. Set the pressValue property to 1.

        • This is the value that will be written to the channel once the button is pressed.

      4. Set the text property to Stop.

      5. Expand the sizePolicy property and set Horizontal Policy to Minimum and the Vertical Policy to Fixed.

      6. Set the styleSheet property to background-color: red; in order to give the button a nice look and feel and bring the attention to it in case of emergency.

      ../../_images/inline_3_5.gif
    • 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:

      1. Drag and drop a PyDMPushButton into the GridLayout on the side of the previously added PyDMPushButton.

      2. Set the channel property of this line edit to: ca://${MOTOR}.VAL.

      3. Set the pressValue property to 10.

      4. Set the relativeChange property so the new value written to the channel will be relative to the channel’s current value.

      5. Set the text property to Tw +10.

      ../../_images/inline_3_6.gif
    • 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:

      1. Drag and drop a PyDMPushButton into the GridLayout on the side of the previously added PyDMPushButton.

      2. Set the channel property of this line edit to: ca://${MOTOR}.VAL.

      3. Set the pressValue property to -10.

      4. Set the relativeChange property so the new value written to the channel will be relative to the channel’s current value.

      5. Set the text property to Tw -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:

      1. Drag and drop a PyDMRelatedDisplayButton at the GridLayout on the side of the previously added PyDMPushButton.

      2. Set the text property to Engineer....

      3. Add the string exper_motor.ui to the filenames property.

        Note

        We will create the expert_motor.ui file in the next section.

      4. Set the openInNewWindow property so the screen will show up in a standalone window.

      5. Expand the minimumSize property and set Width to 125 and Height to 24.

      6. Repeat the same previous step for the maximumSize property.

      ../../_images/inline_3_8.gif
    • Step 3.9.

      After adding all the widgets to the layout, it will look like this:

      ../../_images/inline_all_widgets.png

      Let’s adjust the sizes and reduce the top and bottom margins on the layout.

      1. Using the Object Inspector on the top-right corner, select the gridLayout object and:

        • Set the property layoutRightMargin to 5.

        • Set the property layoutBottomMargin to 5.

        • Set the property layoutHorizontalSpacing to 10.

        • Set the property layoutVerticalSpacing to 5.

      2. Using the Object Inspector on the top-right corner, select the Form object and:

        • Expand the geometry property and set Width to 700 and Height to 32.

        • Expand the sizePolicy property and set Vertical Policy to Fixed.

        • Expand the minimumSize property and set Width to 700 and Height to 32.

        • Scroll all the way down on the property editor and set layoutLeftMargin, layoutTopMargin, layoutRightMargin, layoutBottomMargin and layoutSpacing to 0 so the form is very tight.

        • Expand the maximumSize property and set Height to 38.

      ../../_images/inline_3_9.gif

      The end result will be something like this:

      ../../_images/inline_all_widgets_ok.png
  • 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
    
    Inline Motor Screen

Note

You can download this file using this link.