460 likes | 562 Views
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. JavaIOC – What Is It?. IOC - Input/Output Controller
E N D
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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
<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 and enum Definition For MotorCommand • 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 EPICS Meeting SSRF
<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 and enum Definition For MotorMonitorCommand • 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. EPICS Meeting SSRF
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
<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> motorMonitorRecord.xml EPICS Meeting SSRF
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
<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> positionerRecord.xml EPICS Meeting SSRF
EPICS Meeting SSRF 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.
EPICS Meeting SSRF 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
<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> motorCommon.xml EPICS Meeting SSRF
<DBDefinition> <structure name = "motor" supportName = "generic" > <include href = "motorCommon.xml" /> </structure> <recordType name = "motor" supportName = "generic" > <include href = "motorCommon.xml" /> </recordType> </DBDefinition> motorRecord.xml EPICS Meeting SSRF
<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> Structure double • 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. EPICS Meeting SSRF
EPICS Meeting SSRF 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.
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); } MotorSupport Interface • 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. EPICS Meeting SSRF
EPICS Meeting SSRF 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
EPICS Meeting SSRF 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
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); } PortDriver Interface HYTEC8601 EPICS Meeting SSRF
<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> Structure Definition for HYTEC8601 EPICS Meeting SSRF
EPICS Meeting SSRF 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.
<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> Positioner Record Instance EPICS Meeting SSRF
<IOCDatabase> <record name = "${name}MotorCommand" type = "motorCommand" > <recordName>${name}</recordName> </record> </IOCDatabase> Record Instance Continued • Above is motorCommandTemplateDB.xml • hytec8601TemplateDB.xml is too long to show on one slide EPICS Meeting SSRF