JavaIOC Overview and Update EPICS Meeting INFN October 15-17 2008 Presented by: Marty Kraimer
EPICS Meeting: JavaIOC Overview Major changes in latest release Simplified Database Expression Calculator VXI11 portDriver Beginning of Hardware support Not tested!! Soon STREAM protocol files and IP (Internet Protocol) support When done than support message based devices: serial,gpib Not discussed in this talk See http://epics-doc.desy.de/ioc/javaIOC/ for documentation and download But First an Overview for those who do not know what the JavaIOC is. INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC Features PV (Process Variable) Database DB – Runtime Database that contains definitions for: structure – Structure of fields create – Name of factory for overriding default data implementation support – Name of factory for support for a field record – Record instance. XML Parsers for DB Record Processing and Monitoring Record Scanning: Periodic and Event Channel Access Generic structure, create, and support definitions and implementation INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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: elementType can be any type Complex Structures fully supported Introspection and Data interfaces: Provide access to any field. INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 PV Data It is designed to be used for other purposes. Via structures it could support Vector/Matrix Data Image Data etc. INFN October 13-17 2008 EPICS Meeting: JavaIOC
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. INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC XML Parser DB - Database Definitions structure - a set of fields create – names a factory that replaces default data implementation. support – names a factory that implements support for a field. record – record instance Macro Substitution and Include INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 No lock sets INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC Record Scanning Scan Types: passive, periodic, event Priority Uses Java priorities Threads created as required Periodic Arbitrary rate: minPeriod,deltaPeriod Event Based on eventName Replaces EPICS event and I/O Inter INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 structure or an array of arrays or structures INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC 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 Expression Calculator – features like EPICS calc. INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC Not Implemented Replacement for EPICS sequencer. JavaIOC Channel Access Full Introspection and structure support for JavaIOC client <-> JavaIOC server VDCT: Visual Database Configuration Tool Access security Error logging ??? Lots to do!! BUT It is ready for at least soft IOC Support and soon for serial, gpib, and vxi11. INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC Simplified Database Before latest release the following existed but no longer RecordType – A top level structure for a record instance DBD and DB XML syntax and databases Extensive set of recordType definitions Now When creating a record instance new fields can be appended to existing structure. This one feature made it possible to remove above features Structure generic Has no fields!! The default support is generic. Following slides show how record instances are created from generic. INFN October 13-17 2008 EPICS Meeting: JavaIOC
Really Simple Record Instance <record name = "reallySimple” > <value type = “double” /> </record> which is the same as <record name = "reallySimple” structureName = “generic” > The above record instance Has a single field named value of type double. This is the ONLY data associated with this record. The field value is appended to generic which has no fields The record can be processed but not much happens except monitoring INFN October 13-17 2008 EPICS Meeting: JavaIOC
Not So Simple Record Instance <record name = "notQuiteAsSimple"> <value type = "double" /> <alarm structureName = "alarm" /> <timeStamp structureName = "timeStamp" /> <display structureName = "display" /> <input structureName = "inputSupport"> <pvname>somePV</pvname> </input> <scan structureName = "scan"> <type><choice>periodic</choice></type> <rate>1.0</rate> </scan> </record> The above record instance has the following fields value – type is double alarm data and support timeStamp display – display properties. input – input is from another record. Could be EPICS V3 record scan – The record is scanned once a second INFN October 13-17 2008 EPICS Meeting: JavaIOC
Really Simple Expression <record name = "calcSimpleCounter" > <value type = "int" /> <alarm structureName = "alarm" /> <timeStamp structureName = "timeStamp" /> <input structureName = "calculation" > <calculator> <expression>value+1</expression> </calculator> </input> </record> The above record instance Has a field named value of type int. Has fields alarm and timeStamp Has a field input which performs a calculation The calculator is expressionCalculator The expression adds 1 to value each time record is processed Note that value has type int INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC Counter from 0 to 10 <record name = "calcSimpleCounter" > <value type = "int" /> <alarm structureName = "alarm" /> <timeStamp structureName = "timeStamp" /> <input structureName = "calculation" > <calculator> <expression>value+1<=10?value+1:0</expression> </calculator> </input> </record> The above record instance Expression is (value+1)<=10 ? (value+1) : 0 Like previous but counts from 0 to 10. Note that because of xml syntax must use xml escape sequence for < is < > is > & is & INFN October 13-17 2008 EPICS Meeting: JavaIOC
Counter With Named Arguments <record name = "calcCounter"> <value type = "double” /> <input structureName = "calculation" > <calcArgArray> <element structureName = "calcArg"> <value type = "double">0.0</value> <name>min</name> </element> <value type = "double">10.0</value> <name>max</name> <value type = "double">0.5</value> <name>inc</name> </calcArgArray> <calculator> <expression>((value+inc)<=max)?(value+inc):min</expression> </calculator> </input> </record> Example of expression with named arguments Expression is ((value+inc)<=max) ? (value+inc) : min INFN October 13-17 2008 EPICS Meeting: JavaIOC
Expression Calculator Features Syntax is a valid Java scalar expression Operators Binary + - * / % << >> >>> Unary + - ~ Logical < <= > >= == != Bitwise & | ^ Conditional && || IfThenElse ?: Result assigned to value field All Java scalar types except char are supported Boolean, byte, short, int, float, double Arguments can be Valid Java constant value – The current value of the field named value Variable – value is from calcArgArray element identified by name All Java lang.Math functions and constants are supported INFN October 13-17 2008 EPICS Meeting: JavaIOC
EPICS Meeting: JavaIOC Example Expressions The following are all valid expressions: A + b*(c+3.0) + Math.abs(d) (register&~mask)|((desiredValue<<offset)&mask) Means (register&~mask)|((desiredValue<<offset)&mask) Updates bits specified by mask Math.sin(2.0*Math.PI*position) (a<b)&&(c>d) ? e : 0.0 Means (a<b)&&(c>d) ? e : 0.0 INFN October 13-17 2008 EPICS Meeting: JavaIOC
Calculation Structure Definitions <structure name = "calcArg" supportName = "generic" > <!-- instance must define value --> <field name = "name" type = "string" /> </structure> <structure name = "expressionCalculator" supportName = "expressionCalculator" > <field name = "expression" type = "string" /> <structure name = "calculation" supportName = "generic" > <field name = "calcArgArray" elementType = "structure" supportName = "calcArgArray" /> <field name = "calculator" structureName = "expressionCalculator" /> <field name = "alarm" structureName = "alarm" /> Calculation is the structure for a calculation calcArgArray is an array of structures each of which must be a calcArg CalcArg describes a single argument for the calculation Name – the name of the argument that can be used in an expression Value – Must be added in each instance and given a scalar type Other fields can be defined Calculator identifies support. Default is expressionCalculator. INFN October 13-17 2008 EPICS Meeting: JavaIOC
Example Argument Definition <calcArgArray> <element structureName = "calcArg"> <value type = "double">0.0</value> <name>a</name> </element> <value type = "double"/> <name>b</name> <alarm structureName = “alarm”/> <input supportName = "pdrvFloat64Input" structureName = "pdrvSupport"> <portName>somePort</portName> <deviceName>someDevice</deviceName> </input> </calcArgArray> The first element assigns a value to the argument A client could change the value. The second element gets a value for the argument via a portDriver This can be hardware Can define other ways to get value. For example a link to another record. INFN October 13-17 2008 EPICS Meeting: JavaIOC