# Presentation: 004592

## Lab #1CA Clients

## Lab #1EPICS CA Clients

- Real Life Example #1 : After assembling the ioc and configuring the EPICS database, the application developer left on vacation right before your scheduled commissioning shift. Using a variety of tools (Channel Access Clients), you will interact with the new LINAC and try to achieve your commissioning milestones.
- Your goals for the shift are to :
- Transport beam to the end of the LINAC
- Optimize beam transport
- Measure the beam energy using a bending magnet and faraday cup
- Stabilize beam current with simple closed-loop control
- Full documentation on the Knob Manger, BURT, and ALH can be found at :  http://csg.lbl.gov/EPICS/RecommendedDocs.html

## “Virtual” LINACTheory of Operation

- Beam is generated from the electron gun when the cathode temperature (*studnt_:cathodeTempM*) is > 130 degrees and the gun is enabled (*studnt_:gunOnC* = 1). The cathode is heated by adjusting its current  (*studnt_:cathodeCurrentC*)
- Beam is steered down the linac using 5 sets of correctors. Each set consists of a horizontal corrector (*studnt_:Hn:setCurrentC*) and a vertical corrector (*studnt_:Vn:setCurrentC*) [*n*=1-5]
- The gate valve must be opened to get beam past PM2 (*studnt_:GV1:positionC* = 1)
- Diagnostics:
- one current monitor (*studnt_:CM1:intensityM*),
- five BPMs (*studnt_:PMn:X:positionM*, *studnt_:PMn:Y:positionM*, *studnt_:PMn:intensityM*)
- two faraday cups (*studnt_:FCn:intensityM*)

## Tasks

- Complete an medm display to interact with the virtual linac
- Write a shell script to calculate a useful parameter (transport efficiency)
- Use the Knob Manager to provide convenient control of power supplies to maximize transport
- Configure a StripTool to trend important parameters
- Use burtrb/burtwb to save/restore settings
- Configure the Alarm Handler to monitor critical parameters
- Use some APS OAG tools to find optimum settings and implement closed loop control
- Write a script to automate linac startup/shutdown
- Experiment with other clients (cau, wingz, etc)
- HINT : If you need assistance, ~studnt0 has already completed the lab exercises

## MEDM

- Develop an medm display that allows interactive control of the power supplies, electron gun, and gate valve (begin with ‘~/host/medm/linac.adl’)
- Suggestions :
- Add ‘sliders’ for control of corrector power supplies
- Add ‘text entries’ for control of cathode heater and bending magnet supply
- Add ‘Choice Buttons ‘ for *studnt_:gunOnC *and* studnt_:GV1:positionC*
- Transport beam down your linac
- Increase the cathode current until Cathode Temperature exceeds 120 degrees.
- Turn on beam using *studnt_:gunOnC *
- Steer beam down linac using corrector supplies
- Open Gate Valve
- Optimize steering to end of linac

## MEDM(cont.)

- More features ...
- Make a warning message appear on the display whenever the “Beam On” button is depressed (*studnt_:gunOnC* != 0). Use a text widget with ‘Visibility’ set appropriately.
- Create a new display that has a *strip chart* to trend the cathode temperature. Place a *related display* menu on the main display to call up the strip chart display. Try using the *invisible* attribute to make a hot button on the image of the gun that brings up the strip chart display.

## Unix shell commands

- Experiment with the shell tools provided in the EPICS distribution (type the command without any arguments for a usage line) :
- caget
- caput
- cavget
- cavput
- caGet
- caPut
- cawait
- caInfo
- Write a simple shell script (csh, perl, etc.) to calculate transport efficiency (FC1/CM1). Write this calculated value (caput) to a spare PV in the ioc (*studnt_:opVariable1*). Add a *text monitor* on your medm screen to display this value.
- Help files for c-shell and perl are located in ~/host/scripts.

## Knob Manager(km)

- Start the knob manager client (km &)
- Drag and drop PV names of corrector supplies into knob manager knobs
- Use knobs to optimize steering down the LINAC
- Investigate Knob Manager capabilities
- Knob Disable
- Memory
- Up/Down Arrows
- Save the knob manager configuration in the ~/host/km directory
- Add a *shell command* menu to the medm display to call up a pre-configured knob manager
- e.g.    km -filename <configFile> &

## StripTool

- Start the StripTool (StripTool &) and create a configuration that trends the cathode temperature, cathode current, FC1 current, and transport efficiency (updated by previous shell script)
- Attempt to achieve maximum transport efficiency of beam by steering while monitoring the strip chart.
- Save the StripTool configuration in ~/host/stripTool/
- Add a *shell command* menu on the medm display to call start a pre-configured StripTool.
- StripTool <config_file> &
- Investigate other features of StripTool
- Drag other PVs directly to plotting area
- Zoom In/Out
- Right mouse button on plotting area menu

## Backup/Restore(burt)

- burtrb : saves the value of a list of PVs that are listed in a “request file” (filename1.req) to a snapshot file (filename2.snap).
- Type burtrb for a usage line
- Save settings : burtrb -f linac.req -o settings1.snap
- Request file syntax
- One PV name per line
- If PV is preceded with RO  (Read Only), the PV is stored in the snapshot file by burtrb but not restored by burtwb.
- Examine linac.req and settings1.snap
- burtwb : restores the value of PVs as saved in the “snapshot” file
- Type burtwb for a usage line
- Restore settings : burtwb -f settings1.snap
- Add a *shell command* menu on the medm display to save and restore power supply settings from the medm display. Provide two commands that store in different files and two restore commands.

## Alarm Handler (alh)

- Start the alarm handler (alh &) and open the configuration file ~/host/alh/linac.alhConfig.
- Create alarm situations and interact with the alarm handler
- Investigate other alh capabilities
- Add “alias” names for the PVs ($ALIAS)
- Add the capability to bring up the strip chart medm display *from the alarm handler* when the Cathode Temperature PV alarms ($COMMAND)
- Add simple HELP text for the operator for the Gate Valve PV ($GUIDANCE )
- Configure the alarm handler to ignore the cathode temperature alarm if *studnt_:gunBakeoutC* = 1 ($FORCEPV)
- Add a $GUIDANCE command for the top group to bring up your favorite web page
- Add a ‘shell command’ menu on the medm display to call up this pre-configured alh (e.g. alh/ linac.alhConfig).

## Miscellaneous OAG Tools

- Use quickExperiment to find the optimum BM1 current to bend the beam to FC2
- Obtain as much beam current as possible at FC1
- cd to ~/host/sdds. Start quickExperiment (a TCL/TK application) and configure :
- Measurement PV - *studnt_:FC2:intensityM* (use ‘NAME CAPTURE ...’ to drag/drop)
- Variables PV - *studnt_:BM1:setCurrentC*
- Steps : 50;    Initial : 200;     Final : 225
- Output File - ./bm1Scan
- Press ‘Run’. Wait for it to complete the ramping cycle
- Press ‘Plot ./bm1Scan’
- Select Mouse Tracker from the Options menu and determine optimum current for bending magnet.
- For more info on quickExperiment , use the context sensitive _H_elp

## Miscellaneous OAG Tools

- Use maintainReadback to stabilize cathode beam current (observe result using the StripTool).
- Obtain as much beam current as possible at FC1
- Start the StripTool to trend cathode temperature and FC1 current (use the previously developed configuration file). Note the oscillation in cathode temeperature.
- cd to ~/host/sdds. Start maintainReadback (a TCL/TK application) and configure :
- Readback : *studnt_:cathodeTempM*
- Actuator : *studnt_:cathodeCurrentC*
- Hold : 157 ; Change limit : 1 ; Gain : .2 ; Action limit : 0 ; Pause : 1 ; Steps : 100 ; Samples : 1 ; Mode : Integral
- Press ‘Run’
- Monitor the strip chart to see effect
- For more info on maintainReadback, use the context sensitive _H_elp

## Automate Routine Sequences

- Write a ‘LINAC ON’ shell script to perform the following:
- Launch medm with the appropriate display
- Heat up gun cathode to optimum temperature (*studnt_:cathodeTempM.SEVR* = 0)
- Restore optimum settings for best transport (use burwb and a previously saved snapshot file)
- Launch alarm handler to monitor LINAC
- Turn on the gun
- Open gate valve
- Write a ‘LINAC Off’ shell script to perform the following:
- Turn off gun, lower cathode heater current
- Close gate valve
- Turn off all power supplies (set current to 0)

## Additional Clients

- Probe
- Start probe :  probe &
- Drag/drop a PV from the medm display
- Investigate probe features
- wingz - Spreadsheet
- cd to ~/hosts/wingz
- Start wingz :  wingz caWingz.wkz &
- Replace *$(user): *with *studnt_:*
- Select a cell to the right of a PV name. Hit caGet to retrieve, caPut to send
- Select multiple cells to perform backup and restore functions
- cau - _C_hannel _A_ccess _U_tility
- Start cau :  cau
- type ? for a list of commands
- “monitor” several PVs from the LINAC