javaioc epics meeting ssrf march 12-14 2008 presented by: marty kraimer

46
JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

Upload: ami-flynn

Post on 13-Jan-2016

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

JavaIOC

EPICS MeetingSSRF March 12-14 2008

Presented by:Marty Kraimer

Page 2: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

Overview

JavaIOC – What is it. Features. What is implemented. What is missing. Example of Implementing a “Device”

positioner record.

Page 3: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 3

JavaIOC – What Is It?

IOC - Input/Output Controller

Has a “smart” real time database

Record instances can be processed.

Records can be accessed via Channel Access.

Records can link to hardware, other records, etc. Has functionality like an EPICS IOC but

Structured data

Better Array data

Generic Support

Written in Java

Page 4: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 4

Features

PV (Process Variable) Database

DBD - Database Definition Database

DB – Runtime Database of record instances

XML Parsers for DBD and DB

Record Processing and Monitoring

Record Scanning: Periodic and Event

Channel Access

Generic structure/recordTypes and support

Page 5: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 5

PV Database

Field types

Primitive: all Java primitives except char

boolean, byte, short, int, long, float, double string: implemented as a Java String

structure: has fields. Each field can be any type

array: has elementType which can be any type

Complex Structures fully supported

Introspection and Data interfaces:Provide access to any field.

Page 6: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 6

PV Introspection

Introspection Interfaces, i.e. no data

Field: Methods: getType, getFieldName, ...

Array: extends Field: Method: getElementType

Structure: extends Field Methods: getFields, getStructureName

FieldFactory

Implements introspection interfaces

Can be extended but probably not necessary

Page 7: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 7

PV Data Interfaces

PVField: Base for data: Methods: getField, ...

PVBoolean,...,PVString : Methods: get,put

PVArray: Base for array data interfaces

PVBooleanArray,...,PVArrayArray : Methods get,put PVStructure provides access to a structure. PVRecord provides access to a record instance.

PVDataFactory

Default implementation.

Any PVField can be replaced. Often useful ConvertFactory: Convert between data types

Page 8: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 8

org.epics.ioc.pv

Self Contained Java package for PV Data

Can be used for purposes other than JavaIOC Database

Example: Channel Access Local and EPICS client use PVData It is designed to be used for other purposes.

Via structures it could support

Vector/Matrix Data Image Data etc.

Page 9: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 9

XML Parsers

DBD - Database Definitions

structure

recordType - A top level structure

create – defines factory that replaces default data implementation.

support – defines a factory that implements support for a field. DB – Database of record Instances

Macro Substitution and Include supported for both DBD and DB

Page 10: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 10

DB Database and Record Processing

DB Database provides

Record Locking – A record instance can be locked. Ability to monitor puts to any field of a record instance. Register and locate support for record and fields of a record.

Record Processing

Coordinates processing of a record instance. Both synchronous and asynchronous processing are supported. Each instance can have at most one record processor.

A record can be self processed. Simulates multiple processors. Get and Put support

Can process after put. Also supported by EPICS. Can process before get. Not supported by EPICS. Can put, then process, then get. Not supported by EPICS.

Page 11: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 11

Record Processing

A record instance is basic process unit

It is locked during any processing or I/O

RecordProcess is master. It calls support for record instance.

Support modules implement semantics

ANY field can optionally have support

Record instance must have support

Page 12: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 12

Record Scanning

Scan

Types: passive, periodic, event

Priority Uses Java priorities

Threads created as required

Periodic

Arbitrary rate: minRate,deltaRate

Event

Based on eventName

Replaces EPICS event and I/O Inter

Page 13: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 13

Support

Implements Record Processing Semantics

Each record instance has support

Each field can optionally have support

Support can call other support

Support provided with javaIOC is as generic as possible

During initialization looks for required fields and support If required fields not found then does not start

Example: generic – support for a structure or array

Calls support for each sub field that has support

Each support must finish before next is called

Supports a recordType or a structure or an array of arrays or structures

Page 14: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 14

Channel Access

Local: Within javaIOC Server: Channel Access Client <=> javaIOC Database

Any field that is primitive or array of primitive. Support for all DBR types. Support for process, getProcess, and putProcess

Client: javaIOC <=> EPICS IOC or CAS Support for all EPICS data types. Support for DBR types, i.e. Can get display, control, alarm, etc. Link support for javaIOC records.

Both Server and Client implemented via JCA/CAJ. Cosylab extended JCA/CAJ to support CA Server as well as Client Matej Sekoranja from Cosylab implemented the javaIOC Server.

Currently no full javaIOC Channel Access, e.g. No support for structures.

Page 15: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 15

PV Naming for CA Server

EPICS pvname is <record>.field

JavaIOC is <record>.name.name. ...{options}

name can be field name or a property Some examples

example.valueexample (same as example.value)example.value.display.limit.lowpowerSupply.power.valuepsArray.supply[0].power.value

Options are of the form name=value. Currently only

getProcess=true and putProcess=true Examples using EPICS base ca utilities

caget example.value{getProcess=true} camonitor psArray[1].power caput powerSupply.power{putProcess=true} 10.0

Page 16: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 16

Swtshell Shell for javaIOC

GUI shell for javaIOC implemented via Eclipse SWT. My most important tool for testing javaIOC.

Before Channel Access support only convenient way to test. Still very usefull.

GUI part should be remote.

Not until full Channel Access Support for javaIOC Next slide shows appearance.

Page 17: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 17

Page 18: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 18

Implemented

PV (Process Variable) Database

XML Parsers: DBD and Record Instance

Record Processing/Scanning/Monitoring

Channel Access

Channel Access Local EPICS CA Server EPICS CA Client

Generic record/structures and support

PortDriver – JavaIOC implementation of ASYN Support

SWTSHELL: GUI iocshell

Page 19: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 19

Not Implemented

Replacement for EPICS calc support.

Replacement for EPICS sequencer.

Channel Access

JavaIOC client <-> JavaIOC server

Full Introspection and structure support

VDCT: Visual Database Configuration Tool

Access security

Error logging

???

Lots to do!!

BUT – It is ready for at least soft IOC Support.

Page 20: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 20

Device Record Example: Positioner

Positioner Requirements

Coordinate the movement of a set of motors A movement consists of

Start all motors. Monitor motors for movement When all motors have stopped finish processing.

Example Usage – Xray beam line

Scan Sample – repeat following until done. Move sample to new position Take data

Positioner coordinates two steps. Design must also support a single motor

Page 21: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 21

Structure and enum Definition For MotorCommand

<structure name = "motorCommand" createName = "enumerated" > <field name = "index" type = "int" /> <field name = "choice" type = "string" /> <field name = "choices" type = "array" elementType = "string" default = "idle stop move monitor jog reset" /></structure>

public enum MotorCommand { idle,stop,move,monitor,jog,reset}

structure definition

Commands can be issued via Channel Access

For EPICS V3 Channel Access the field appears as a DBR_ENUM

enum definition for use by code

This talk mostly about move and monitor

Page 22: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 22

Structure and enum Definition For MotorMonitorCommand

<structure name = "motorMonitorCommand" createName = "enumerated" > <field name = "index" type = "int" /> <field name = "choice" type = "string" /> <field name = "choices" type = "array" elementType = "string" default = "idle monitor" /></structure>

public enum MotorMonitorCommand { idle,monitor}

Structure Definition

Commands can be issued via Channel Access For EPICS V3 Channel Access the field appears as a DBR_ENUM

Enum definition for use by code.

Page 23: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 23

Monitor Not Compatible With Other Commands

All commands except monitor start some action Monitor (get current position) must be done repeatedly until motors stop Solution: Two record instances Record type positioner – Has an array of embeded motors

Motor is both a structure and a recordType The structure is embeded in positioner The recordType is for single motor

Record type motorMonitor

Has link to a positioner or motor record Action for a putProcess to command.monitor

Monitor linked record until not moving Finish processing

Page 24: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 24

Positioner vs synAPPS

SynAPPS (Beam line Control Software used by many EPICS facilities)

Has table record which is positioner It links to motor or other records.

Positioner record encapsulates all motors within a single record

Makes sense when motors only used for positioning The user thinks of the positioner as a single device that happens to

have components

Page 25: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 25

Typical Client Usage

Assume

A three motor positioner named P and a motorMonitor named M To start movement the client does a put to a field named command

Put P.command move PutProcess M.command monitor

To make a move to a new position the client:

put P.axis[0].move value put P.axis[0].speed value ... same for axis[1] and axis[2] Put P.command move putProcess M.command monitor

The operation does not complete until all motors have stopped moving.

Page 26: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 26

Additional Requirements

Support multiple types of motor Generic Support

Motor Support should be usable for purposes other than in a positioner For maintainability, monitoring, and diagnosis it must be possible to

access each motor individually.

Page 27: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 27

Design: Five Support Modules

The five Support Modules are:

motorMonitor positioner motor Hardware Specific Motor Support PortDriver

MotorMonitor is generic and supports a recordType positioner is generic and supports a recordType motor

Is generic. It can support a record or a structure impeded in another record.

Hardware Specific Motor Support and portDriver: next slide

Page 28: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 28

Hardware Specific Motor Support

Hardware Specific Motor Support and portDriver

Must be created for each different type of motor/controller Example is for a Hytec8601 which is an Industry Pack four axis motor

controller. Supports an embeded structure.

For example a field in a motor record or structure. PortDriver for Hytec8601

Coordinates access to the four axis controller

Page 29: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 29

motorMonitorRecord.xml

<DBDefinition><structure name = "monitor" > <field name = "priority" type = "structure" structureName = "scanPriority" /> <field name = "rate" type = "double" default = "0.1" /></structure>

<recordType name = "motorMonitor" supportName = "generic" > <field name = "command" type = "structure" structureName = "motorMonitorCommand" supportName = "motorMonitor" /> <field name = "moving" type = "boolean" /> <field name = "recordName" type = "string" /> <field name = "monitor" type = "structure" structureName = "monitor" /> <field name = "alarm" type = "structure" structureName = "alarm"/> <field name = "timeStamp" type = "structure" structureName = "timeStamp"/></recordType>

<support name = "motorMonitor" factoryName = "org.epics.ioc.sbirDemo.MotorMonitorFactory" />

</DBDefinition>

Page 30: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 30

MotorMonitor Support

The linked record must have following two fields:

command which must be a motorCommand structure moving which must have type boolean.

motorMonitor spawns a thread that monitors the linked record

The thread is only active while the linked record is moving. Monitoring is done be issuing a put, process, get to the linked record

The put is a monitor command to the linked record The process waits until the linked record completes the monitor The get reads the moving field from the linked record

When a putProcess to command is issued

Sets moving true. Activates the monitor thread When the monitor thread detects that the linked record is not moving

Sets moving false and command to idle Completes processing.

Page 31: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 31

Design: Five Support Levels

The five levels are:

motorMonitor positioner motor Hardware Specific Motor Support PortDriver

motorMonitor is generic and supports a recordType positioner is generic and supports a recordType motor

Is generic. It can support a record or a structure impeded in a positioner.

Hardware Specific Motor Support and portDriver

Page 32: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 32

positionerRecord.xml

<DBDefinition><recordType name = "positioner" supportName = "generic" > <field name = "command" type = "structure" structureName = "motorCommand" supportName = "positioner" /> <field name = "moving" type = "boolean" /> <field name = "axis" type = "array" elementType = "structure" /> <field name = "alarm" type = "structure" structureName = "alarm"/> <field name = "timeStamp" type = "structure" structureName = "timeStamp"/></recordType>

<support name = "positioner" factoryName = "org.epics.ioc.sbirDemo.PositionerFactory" />

</DBDefinition>

Page 33: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 33

positioner Support

Each element of the array field axis must be a structure that has the fields

command which must be a motorCommand structure command must have Support MotorSupport

moving which must have type boolean. positioner monitors it’s command field

When a command is issued, it issues the same command to each axis. It’s process method just waits for the command to complete NOTE: A move command completes when the move has started NOT

when the move completes Any command except monitor sets moving true if not already true When a monitor command is given

A monitor command is issued to each axis After each axis has completed the monitor

The moving field of each axis is read If any axis is moving the positioner is moving.

Page 34: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 34

Design: Five Support Levels

The five levels are:

motorMonitor positioner motor Hardware Specific Motor Support PortDriver

motorMonitor is generic and supports a recordType positioner is generic and supports a recordType motor

Is generic. It can support a record or a structure impeded in a positioner.

Hardware Specific Motor Support and portDriver

Page 35: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 35

motorCommon.xml

<DBDefinition> <!-- value is the current motor position --> <field name = "value" type = "double" /> <field name = "command" type = "structure" structureName = "motorCommand" supportName = "motor" /> <field name = "moving" type = "boolean" /> <!-- move is amount to move when command move is specified --> <field name = "move" type = "structure" structureName = "double" /> <!-- speed is how fast to move when go or jog is specified --> <field name = "speed" type = "structure" structureName = "double" /> <!-- motor is a hardware specific structure --> <field name = "motor" type = "structure"/> <field name = "display" type = "structure" structureName = "display" /> <field name = "alarm" type = "structure"/> <field name = "timeStamp" type = "structure" /></DBDefinition>

Page 36: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 36

motorRecord.xml

<DBDefinition>

<structure name = "motor" supportName = "generic" > <include href = "motorCommon.xml" /></structure>

<recordType name = "motor" supportName = "generic" > <include href = "motorCommon.xml" /></recordType>

</DBDefinition>

Page 37: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 37

Structure double

<structure name = "double" supportName = "generic" > <field name = "value" type = "double" /> <field name = "alarm" type = "structure"/> <field name = "control" type = "structure" structureName = “control” /> <!-- other fields are also defined--></structure>

Is used for fields speed and move

Structure control has fields limit.low and limit.high Attempting to set a value outside the limits causes an alarm Note that Motor Support and HYTEC8601 Support do not have to check

the limits. There is generic support that enforces the limits.

Page 38: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 38

Generic Motor Support

The field motor is a hardware specific structureThe structure must have a field named command

command must be a motorCommand structure command must have Support MotorSupport

Units

Generic motor support uses engineering units Hardware specific motor support does what it wants display.limit.low and display.limit.high are engUnitsLow and

endUnitsHigh motor support calls motorSupport.setEngUnits

When motor support receives a command the same command is given to hardware specific support.

When speed is modified motorSupport.setSpeed is called. When move is modified motorSupport.setMove is called.

Page 39: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 39

MotorSupport Interface

interface MotorSupport extends Support{ void setSpeed(double speed); void setMove(double distance); double getPosition(); boolean isMoving(); boolean command(MotorCommand command); void setEngUnits(double engLow,double engHigh);}

Implemented by Motor Support

Called by positioner For now positioner only calls command. Could do more.

Implemented by Hardware Specific Motor Support

Called by Motor Support Converts from Engineering Units to Steps.

Page 40: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 40

Design: Five Support Levels

The five levels are:

motorMonitor positioner motor Hardware Specific Motor Support PortDriver

motorMonitor is generic and supports a recordType positioner is generic and supports a recordType motor

Is generic. It can support a record or a structure impeded in a positioner.

Hardware Specific Motor Support and portDriver

Page 41: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 41

Design: Hardware Level Support

portDriver - Hytec8601Driver

Implements interface HYTEC8601 which is called by supportHYTEC8601

Uses JNI because linux driver requires ioctl file commands. PortDriver synchronizes access to 8601, which is a four axis controller.

Hardware Specific Motor Support – HYTEC8601 Support

Understands commands for Hytec8601 Structure for configuration and low level commands Implements MotorSupport which is called by motor support

Page 42: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 42

PortDriver Interface HYTEC8601

public interface HYTEC8601 { void setStartSpeed(short speed); short getStartSpeed(); void setAcceleration(short acceleration); short getAcceleration(); void setSpeed(short velocity); short getSpeed(); void setSteps(int steps); int getSteps(); void setPosition(int position); int getPosition(); short getCSR(); void setCSR(short value); void start(byte value);}

Page 43: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 43

Structure Definition for HYTEC8601

<structure name = "HYTEC8601" supportName = "supportHYTEC8601" > <field name = "position" type = "int" /> <field name = "moving" type = "boolean" /> <field name = "io" type = "structure" structureName = "pdrvSupport" /> <field name = "stepsLow" type = "int" /> <field name = "stepsHigh" type = "int" /> <field name = "command" type = "structure" structureName = "motorCommand" /> <field name = "direction" type = "structure" structureName = "motorDirection" /> <field name = "stepCounter" type = "int" /> <field name = "startSpeed" type = "short" /> <field name = "rampRate" type = "short" /> <field name = "speed" type = "short" /> <field name = "maxSpeed" type = "short" /> <field name = "status" type = "short" /></structure>

Page 44: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 44

Comments about Hardware Specific Design

Can be used by generic motor support The hardware specific structure allows low level access

Generic tools, e.g. Edm, can access hardware specific details Needed for maintenance and diagnosis.

Page 45: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 45

Positioner Record Instance

<IOCDatabase><substitute from = "name" to = "positioner" /><include href = "motorCommandTemplateDB.xml" /><record name = "${name}" type = "positioner" > <axis capacity = "3"> <element structureName = "motor" > <substitute from = "addr" to = "0" /> <include href = "hytec8601TemplateDB.xml" /> </element> <element structureName = "motor" > <substitute from = "addr" to = "1" /> <include href = "hytec8601TemplateDB.xml" /> </element> <element structureName = "motor" > <substitute from = "addr" to = "2" /> <include href = "hytec8601TemplateDB.xml" /> </element> </axis></record></IOCDatabase>

Page 46: JavaIOC EPICS Meeting SSRF March 12-14 2008 Presented by: Marty Kraimer

March 8-10 2008 EPICS Meeting SSRF 46

Record Instance Continued

<IOCDatabase><record name = "${name}MotorCommand" type = "motorCommand" > <recordName>${name}</recordName></record></IOCDatabase>

Above is motorCommandTemplateDB.xml hytec8601TemplateDB.xml is too long to show on one slide