# Presentation: 500764

## Post-VMS (Java) Controls Program DevelopmentJ. PatrickSeptember 4, 2003

## Overview

- May or may not be appropriate for TeV BPM programming
- Limited time for details here
- Longer tutorial given in June
- Slides from all 4 talks from that tutorial are on the web
- _[http://www-bd.fnal.gov/controls/java/tutorial_june_2003](http://www-bd.fnal.gov/controls/java/tutorial_june_2003)_
- Linked from controls home page
- Also talk at Thursday meeting on July 31
- In document database; beams-doc-757-v1

## Post-VMS Development

- Based on the Java language
- Operating system agnostic
- We support Windows and unix equivalently
- Cluster of ~90+ Sun machines runs detached processes
- Control room (GUI applications) is all Windows PCs
- Controls developers mostly Windows, some FreeBSD, Sun
- Mac to the extent the Java distribution is up to date
- Limited Linux presence in BD, though some code has been tested
- Extremely limited support for C/C++ except in front-ends
- There has to be a very compelling case
- We have a substantial Java infrastructure that will not be replicated in C/C++
- Supporting large scale cross-development on Windows/Unix is resource intensive.
- If you are worried about speed, remember we currently run on 25 MHz VAXes...

## VMS or Java?

- Any new detached (non-GUI processes) should be in Java
- All but a handful of equivalent VMS programs have been migrated
- For console applications, depends on:
- Desired time scale
- Skills of code developers
- Extent of modifications required in VMS applications
- Modest modifications or complete rewrite?
- Simultaneous old/new BPM operation?
- If console applications are done in Java, we would attempt to keep in mind reusability for other machines.

## Why Java?

- Modern, Object-Oriented Language
- Very much easier to learn, program and maintain than C++
- Focus on learning object-oriented programming
- Very popular and well supported
- Modern programming tools (Integrated Developer Environments)
- Basically platform independent
- Same **object** code runs on Windows, unix, Mac
- Web integration
- Launch programs from web browsers
- Excellent bundled libraries
- Graphical User Interface
- Threads
- Networking
- I/O
- Database access

## Control System Overview

- Sun Netras
- (computer room)

- PCs
- (anywhere)

- Front Ends
- (anywhere)

- ..................

- (16)

- ...........

- ..................

**RMI**

**ACNET**

**ACNET**

## Control System Overview

- Applications access front-ends through intermediate layer(s)
- “Data Acquisition Engines”
- Consolidate front-end requests
- Analogous to Datapool process on VMS, but on separate CPU
- Translates application protocol (Java RMI) to/from front-end protocol (ACNET)
- So front-ends can be accessed equivalently by VMS and Java applications without change.
- Although it is simple to access devices in Java, often additional “library support” is desirable when developing applications.

## Data Acquisition API

- VMS ACNET API (dio_, datalogger_, etc.) reorganized
- DaqJob (what, from, to, when, who, control)
**what**: device(s)
**from**: Accelerator, DataLogger, SaveFile, SDA, Mirror, Model, ...
**to**: your code, Accelerator, Mirror, Model, DataLogger, SaveFile...
**when**: now, later, clock event (+delay), state transition (+delay), ...
**who**: who is making the request and from where (privileges)
- Start DaqJob, receive callback when complete
- Still based on “power supply” device paradigm
- Required for compatibility with old system
- The infrastructure allows the potential of manipulating structured sets of devices
- “Library support” encapsulated in “**what**” (item) subclasses, other places

## What Infrastructure Exists

- Application framework
- Provides common infrastructure for applications
- Capture, mail, etc. utilities like VAX program tools
- Message capture, application monitoring
- Post images directly to e-log!
- Management of dXe connection
- Open Access Client (OAC) framework
- Makes it rather easy to write an OAC
- Access to entire control system (readings/settings)
- Database access
- Plotting
- Both internally written (fast) package, and JFreeChart (prettier/more options)
- Synoptic display infrastructure/drag&drop builder
- Finite State Machine infrastructure including graphical builder
- NOT a straight port of CLIB/User Libraries
- There are certainly missing pieces in the above

## Graphical User Interface[JControlsFrame]

## What Infrastructure Doesn’t Exist

- Functionality of most machine specific VAX User Libraries
- Though functional equivalents exist in some cases
- Numerical methods/linear algebra use not extensive so far
- Usage in autotune, some other places
- Some fitting, FFT code in gov tree
- Third party packages exist that should satisfy requirements
- Full support for GPIB/specific scope models
- Lowest level infrastructure exists, needs to be built up
- We will do this as people ask for it.
- We will provide any infrastructure needed
- Ask us please before you write (or download) such packages

## Application Startup

- Application Index
- Catalog of applications, analogous to VMS index pages
- Web page (http://www-bd.fnal.gov/appix)
- Standalone program (like Windows Explorer)
- Click to start programs
- Can start both normal and browser based applications
- Java Web Start
- Most efficient startup method
- Only Java need be installed on your PC
- All required code is automatically copied to your PC and cached
- Program starts and runs on your PC

## Application Home Page

## Application Index

## Parameter Page

## Code Overview

- Single rooted tree – the “gov tree”
- gov/fnal/controls/applicationsgov/fnal/controls/toolsgov/fnal/controls/daq...
- Following standard Java package naming conventions
- ~3000 classes, ~500K non-comment lines of code
- ~70 third party jar files
- Currently released as a whole package
- Done <once/day> as requested
- Not much of a problem so far, but we realize this won’t scale to many developers and many applications
- Developing a system by which a developer can release their individual applications
- Some version should be out soon

## Code Management

- Code kept in CVS repository
- nova.fnal.gov
- Access over network using pserver
- CD check_access provides write permission granularity
- Code and history is viewable on the web via cvsweb
- GUI (we use jCVS) and command line interfaces
- Global gov tree builds use “ant”
- Developers cvs tag new versions to go into build as “Ready4Alpha”
- Test builds each evening to catch problems early
- For individual development, people set up individual IDE and/or command line configuration
- Not as convenient as MECCA in various ways
- Some better command line environment is under consideration

## CVS Web

## Integrated Developer Environments

- Integrated editor, compiler, code browser, debugger
- CVS integration
- Potentially more efficient development
- But requires investment to master
- Several choices of free and/or inexpensive products
- Controls developers use JBuilder/Netbeans/SlickEdit/Eclipse/command line

## Integrated Developer Environments

## Security

- Must be on Beams network for
- Direct access to control system devices
- Direct access to the database
- And therefore to run most applications
- The VPN is currently not of help for detailed technical reasons
- CVS access from anywhere on FNAL network
- However:
- Versions of primary infrastructure applications have been written that can be run from outside the beams network
- Parameter page, Data Logger Plotter, Device Database, Others
- Some of these use the web browser as the client and “servlets” as the server part inside the firewall, proxied through www-bd.fnal.gov
- This has a big rate penalty and should not be used for applications primarily run within the BD (which presumably applies here...)
- Settings not allowed via this mechanism

## If you want to start writing...

- Talk to us
- Look at examples
- Read tutorial slides
- Read “Application Guidelines”
- http://www-bd.fnal.gov/controls/java/guidelines/ApplicationGuidelines.html
- Read “Application Development Guide”
-  _[http://www-bd.fnal.gov/controls/java/getting_started_guide/GettingStarted.html](http://www-bd.fnal.gov/controls/java/getting_started_guide/GettingStarted.html)_
- Read “Application Framework”
- _[http://www-bd.fnal.gov/controls/java/framework/guide/index.html](http://www-bd.fnal.gov/controls/java/framework/guide/index.html)_
- Talk to us some more
- If there is something you need in the infrastructure, we will provide it
- We will provide whatever assistance people need

## Summary

- Extensive Java infrastructure exists
- Code management/development
- Data Acquisition
- Application Framework
- Should be the default for any non-GUI processes
- May or may not be appropriate for initial console application work for the TeV BPM upgrade
- Maybe for programs requiring complete rewrite
- Particularly hardware diagnostics
- Will have to be done some day if the Tevatron lasts...