Title: EPICS Lab Part 2: Channel Access Clients
Author: Andrew Johnson
Last saved by: mboyes

EPICS EDM Lab: Channel Access Clients
For all of the following exercises, a test IOC must be running. A test IOC has already been created for you and is running on lcls-dev2. There are 5 different PV records for each person/team to use. The PV names are as follows with teamname replaced with team1 through team19. A teamname will be assigned to you.
teamnameHost:aiExample
teamnameHost:aiExample1
teamnameHost:calcExample
teamnameHost:calcExample1
teamnameHost:compressExample
teamnameHost:xxxExample

Note: There are some useful EDM tips at the end of this document; you might want to review them now.
Open a SecureCRT or Putty window and connect to lcls-dev2.  Do the following exercises in this new SecureCRT or Putty window.
Command line utilities: caget, caput, camonitor
To check the value of a record,
$ caget teamnameHost:xxxExample
Note that this gives the same result as
$ caget teamnameHost:xxxExample.VAL
To change the value of the record,
$ caput teamnameHost:xxxExample 15
To monitor a record, 
$ camonitor teamnameHost:xxxExample  
Type ctrl-c to exit camonitor.
A more interesting record to monitor is teamnameHost:aiExample1.
Now use caget, caput, and camonitor to look at other fields of these records.  For example, to see the engineering units of a record:
$ caget teamnameHost:xxxExample.EGU
Look at some other fields of your records.  Some interesting fields are:
	DESC (description)
	EGU (engineering units)
	LOLO, LOW, HIGH, HIHI (alarm thresholds)
	LLSV, LSV, HSV, HHSV (alarm severities associated with those thresholds)
	LOPR, HOPR (low and high operating limits)

Probe
Launch Probe from the command line:
$ probe
In the window, type the PV name teamnameHost:xxxExample and press enter.
Use the Adjust button to change the value of the record.
Click the Info button to see various fields of the record.
Click Start and Stop to start and stop monitoring the record.
Do the same for the record teamnameHost:aiExample.
Press Quit to quit Probe.
EDM
Create a directory in your project folder for display files:
$ mkdir edm
Go to your display file directory and launch edm:
$ cd edm
$ edm -m user=teamname&

EDM Exercise 1: Editing
From the edm main window, create a new display using File/New.
Save the empty display with filename example1 in your edm folder:
	Middle-button menu/Save As... 
(From now on, save every once in a while just in case…)
Turn on the grid and snap-to-grid options:
	Middle-button menu/Display Properties: snap-to-grid, show grid.
Create:
Two labels “Calc Example” and “XXX Example":
Left-button-rubberband the approximate area. Select Graphics/Static Text. Enter “Calc Example” as the text. Select a font such as helvetica 18. Press OK.
Repeat for “XXX Example”.
Two Monitor/Textupdate objects. For PV names use “$(user)Host:calcExample” and “$(user)Host:xxxExample”.
One Control/Textentry object.  For PV name use "$(user)Host:xxxExample".
Two Graphics/Rectangles, make them “filled” and change the fill color to light blue.
Note: To change the stacking order, select objects, then use the middle-button menu to raise or lower them.
Select, move, resize, align, … to make the display look how you want it to look.
These may help you to finish quicker:
Middle-button menu/Copy/paste
Switch to “execute” mode: de-select all objects, click the middle mouse button, and choose execute from the menu.
Change the value of XXX Example PV.  Notice how the alarm color changes for different values from 0 to 10.
To switch back to "edit" mode: click the middle mouse button and choose edit from the menu.
Save your work: click the middle mouse button and choose save from the menu.

EDM Exercise 2: More Editing
Create a new display, save it as example2.
Use Graphics objects (circles, text and lines) to create a simple diagram or schematic.
For help: 
	Middle-button menu/Help/Objects 
	Middle-button menu/Help/Line Objects 
Select several objects at once, change color or font or via the Middle-button menu “Edit/Display Info” option.

EDM Exercise 3: PVs
We will see how different PVs can be represented in different ways.
Execute edm as before and open example1. Save the display file as “example3”.
In your display there is a text update for the record “$(user)Host:calcExample”.
Add a Monitor/Meter that uses the same PV. Set the Bg Color = light gray, Label Intervals = 5, Majors per Label = 2. – execute.
Add a Monitor/X-Y Graph that uses the same PV. Set the Bg Color = light gray, Set the Y Trace to be the PV. – execute
Add a text entry control to the .CALC field of the record:
Create a Control/Textentry, set “$(user)Host:calcExample.CALC”as the PV name.
Add a Control/Menu Button to the .SCAN field of the same record (e.g. PV name “$(user)Host:calcExample.SCAN”) - execute.
Change the SCAN field and see what happens.
Change the calculation from (A<B)?(A+C):D to (A<B-1)?(A+C):D and see what happens.
Optional: Usually calculations are done in the database using CALC records, but EDM itself can also be used to do calculations.  To try this out, add a text update and enter the following as the PV name: “CALC\sum($(user)Host:calcExample, 2)” - execute.

Exercise 4: Colors, Macros
We will see how macros get passed to related displays.
Open example3 and save it as “example4”. This will be our main display that launches two related displays.
Add a label (Graphic/Static text) that shows “User $(user)”.
Add two Control/Related Display buttons:
Set “File” to “relatedDsp”, macros to “param=1”, label to “Rel. 1”
Button #2: File: “relatedDsp”, macros: “param=2”, Label: “Rel. 2”
Add a text entry control, and set its Control PV to “$(user)Host:xxxExample”. This PV name will also be used in a color rule inside the related display.
Add an exit button. Check the “Exit Program” option.
Create a new display to be used as the related display, save it as “relatedDsp”:
Create a static text object with Text Value  set to “Related Display, param=$(param)”
Create a rectangle, choose a dynamic color “test1” for line color, use the PV name “$(user)Host:xxxExample” for Color PV.
Create an exit button. Do not check the “Exit Program”  option.
Save “relatedDsp”  and close it.
Execute “example4”
Click the Related Display button, the associated display should appear and the static text object should display the symbol value
Change the value of the PV from the example1 text control, the rectangle color should be determined by the color rule. Try values -1,5,10, and 20.
Click the Exit Button on each related display.
Click the Exit Button on “example4”, the main screen.
Does this exit edm?

Exercise 5: Command Button and Embedded Displays
Open any of the examples.
Add a shell command button to start StripTool:
	Create a Control/Shell Command, set “Shell Command” to “StripTool”.		 
Execute.
Note how you can drag & drop (middle button) PV names from an edm object to StripTool’s channel name field.

Go back to Edit mode.
Add Graphics/Embedded Display by rubber banding a large area and Selecting Graphics/Embedded Window: Set “File” to “relatedDsp”, Set “Display Source” to “Form”.
Execute.
Note: You might need to set “Display Size” to be larger of the file “relatedDsp” and edit the Embedded Window Properties. Change the Display size by Middle Clicking the display background   and selecting “Display Properties” Change the height to a smaller size like 200 and the width to 400. Make sure all of your items are still visible.

Exercise 6: Display Schemes (Optional)
Create a new display using File/New
From the middle mouse button menu, select “Display Properties”.
In here, you can change the background color and select default fonts and colors for newly created display elements. Select a background color, click OK.
You should save the “Display Scheme” in case you want to create a standard setup (background color etc.) for part or all of your displays. In fact EDM automatically loads the file names “$EDMFILES/default.scheme” on startup, so by saving a scheme under that name, you determine the start-up defaults.
One quirk/feature is that EDM wants to save & load all display schemes in a global EDM configuration directory ($EDMFILES). That makes sense when you want to share display schemes with others, especially for the “default.scheme”. For this training however, keep all your files in your home/edm directory. 
Invoke the middle-button menu again, select Save Display Scheme, navigate to your home/edm directory, and create “training.scheme” (yes, the Motif-type file dialog is strange).
From the main window, choose File/Exit. There will be a warning because you didn’t save the display. That’s OK: We don’t care about the display, we only wanted to create a “Scheme”!
Restart edm, load one of your example displays, select “Load Display Scheme...” and load your “training.scheme” file. What changes when you do that?

Exercise 7: Symbols (Optional)
Create a new display, save it as “switch”.
Follow the “Creating symbol” slides to create the states of a simple switch:
broken, open, closed
Details:
Create an invisible rectangle
Draw invariant symbol components
Copy image and paste two copies to the display
Draw state dependent components
Arrange images in a rows/columns ordering, first state is upper-left, last is lower-right
If any objects have been grouped, un-group them now
Click middle button, choose Auto make symbol
Save symbol file as “switch” & close the display.
Create new display “example7”
Add text entry to control e.g. “$(user)Host:aiExample”
Add a symbol instance (Monitor/Symbol)
Use symbol file recently created, use same PV as referenced in text entry object. Select 3 items, configure each as follows:
Item 1:     0 >= PV value < 1
Item 2:     1 >= PV value < 2
Item 3:     2 >= PV value < 3
Execute example7

EDM Tips
EDM makes use of all three mouse buttons.  This makes it tricky to use at first.  Here are some tips:
•	Left-click selects an existing widget.
•	Left-double-click opens the properties window for an existing widget.  
•	Left-drag adds a widget to your display.  Left-drag the mouse ("left-rubber-band") to make a rectangle that is the size of the widget you want to create.  When you let go of the mouse button, a menu pops up and you can select the type of widget you want to add.
•	Middle-click on a blank area of the window opens a menu that allows you to save your file, switch between edit mode and execute mode, and paste a copied widget.
•	Middle-click on a selected widget allows you to copy, paste, raise, lower, and rotate the widget.
•	Middle-drag a region selects multiple widgets.
EDM has good online help.  To open it, middle-click an empty area of your display and select Help.  In the window that pops up, click Objects or Line Objects.

EPICS_EDM_Lab_Channel_Access_Clients		page  of