# Presentation: 000995

## JavaIOC

***Marty Kraimer***
***EPICS Collaboration Meeting***
***ICALEPCS October 13-14 2007***

## Overview

- Brief review of JavaIOC features
- types link, enum, and  menu gone
- JavaIOC Data Model
- Generic structures and recordTypes
- Support – All support is generic
- PortDriver – JavaIOC version of asyn

- ICALEPCS/EPICS Meeting

- October 2007

## JavaIOC Features

- Rich Set of Data Types
- Smart soft real-time Database
- Record Instances can be processed.
- Any field can optionally have support.
- Connect to Hardware or other records.
- Defines Data Model
- General Purpose Clients can easily find data.
- Generic Support can easily find data.
- Rich set of record/structures and support.

- ICALEPCS/EPICS Meeting

- October 2007

## Implemented

- PV (Process Variable) Database
- XML Parsers: DBD and Record Instance
- Record Processing/Scanning/Monitoring
- Channel Access Local
- COSYLab: CA Server for CSS/V3 clients
- Generic record/structures and support
- PortDriver – JavaIOC ASYN Support
- SWTSHELL: GUI iocshell

- ICALEPCS/EPICS Meeting

- October 2007

## Not Implemented

- Remote Channel Access
- JavaIOC client <-> JavaIOC server
- JavaIOC client <-> V3 server
- VDCT: Visual Database Configuration Tool
- Access security
- Error logging
- ???
- Lots to do!!

- ICALEPCS/EPICS Meeting

- October 2007

## 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.

- ICALEPCS 2007

- October 2007

## 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

- ICALEPCS 2007

- October 2007

## 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

- ICALEPCS 2007

- October 2007

## 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 - Record Instance
- Macro Substitution and Include

- ICALEPCS/EPICS Meeting

- October 2007

## Types Removed

- Previously javaIOC had types
- link
- enum
- menu
- link replaced by support for structure
- enum and menu replaced by enumerated structure

- ICALEPCS/EPICS Meeting

- October 2007

## Enumerated structure

***<structure name = "enumerated" createName = "enumerated" >***
***  ******<field name = "index" type = "int" />***
***  ******<field name = "choice" type = "string" />***
***  ******<field name = "choices" type = "array"***
***                 ******elementType = "string" />***
***</structure>***
***<create name = "enumerated"***
***  ******factoryName = "org.epics.ioc.create.EnumeratedFactory" />***

- ICALEPCS/EPICS Meeting

- October 2007

## enumerated

- An enumerated structure has fields
- index – an int that selects one of choices
- choice – a string that is the current choice
- choices – an array of strings
- The enumerated create
- Replaces the default implementation
- A put to index also changes choice
- A put to choice also changes index

- ICALEPCS/EPICS Meeting

- October 2007

## alarmSeverity

***An enumerated structure with default choices***
***<structure name="alarmSeverity" createName = "enumerated" >***
***  ******<field name = "index" type = "int" />***
***  ******<field name = "choice" type = "string" />***
***  ******<field name = "choices" type = "array"***
***     ******elementType = "string"***
***     ******default = "none minor major invalid" />***
***</structure>***

- ICALEPCS/EPICS Meeting

- October 2007

## Java IOC Database

- Has a set of record instances.
- Each record and field is accessed via interfaces.
- Each instance can be processed
- Periodically scanned
- Event scanned
- Passively scanned: by client or other record
- Factories: Data and Introspection

- ICALEPCS/EPICS Meeting

- October 2007

## PV Naming

- EPICS pvname is <record>.field
- JavaIOC is <record>.name.name. ...
- name can be field name or a property
- Some examples
- <record>.value<record>.value.display.limit.low<powerSupply>.power.value<psArray>.supply[0].power.value

- ICALEPCS 2007

- October 2007

## JavaIOC Data Model

- Simple: All related data appears together in a structure
- Intended for Client tools and for Support
- Field name can be a property name
- A null structure(no fields and no support) is not a property.
- If a structure has a field named “value” than every other field is a property unless it is a null structure.

- ICALEPCS 2007

- October 2007

## Finding Properties

- PVField provides method findProperty
- PVField findProperty(String fieldName);
- Two examples for  fieldName are:
- “value”
- “supply[0].power.value”
- If pvField refers to the value field than
- “display”
- “display.limit.low”

- ICALEPCS 2007

- October 2007

## Generic structure/recordType

- The JavaIOC now has DBD definitions for
- Each primitive type
- An array with a primitive element type
- A structure and recordType for each
- Record instances can
- Just hold data
- Be an input record, an output record, etc
- The structure versions are for device records

- ICALEPCS/EPICS Meeting

- October 2007

## structure/recordType double

- XML definitions on next two slides
- Follows JavaIOC Data Model
- recordType double is defined. It can:
- Just holds data
- Be an input or output or both
- Be an analog input or analog output
- Structure double is defined
- It can be embeded in other recordTypes
- Building block for “device” records

- ICALEPCS/EPICS Meeting

- October 2007

## doubleCommon.xml

***<?xml version="1.0" ?>***
***<DBDefinition>***
***  ******<field name = "value" type = "double" />***
***  ******<field name = "alarm" type = "structure"/>***
***  ******<field name = "timeStamp" type = "structure" />  ***
***  ******<field name = "input" type = "structure" />***
***  ******<field name = "valueAlarm" type = "structure" />***
***  ******<field name = "output" type = "structure" />***
***  ******<field name = "display" type = "structure" />***
***  ******<field name = "control" type = "structure" />***
***  ******<field name = "history" type = "structure" />***
***</DBDefinition>***

- ICALEPCS/EPICS Meeting

- October 2007

## doubleRecord.xml

***<?xml version="1.0" ?>***
***<DBDefinition>***
***<structure name = "double" supportName = "generic" >***
***  ******<include href = "doubleCommon.xml" />***
***</structure>***
***<recordType name = "double" supportName = "generic" >***
***  ******<include href = "common.xml" />***
***  ******<include href = "doubleCommon.xml" />***
***  ******<field name = "supportArray" type = "array"***
***     ******elementType = "structure" supportName = "supportArray" />***
***</recordType>***
***</DBDefinition>***

- ICALEPCS/EPICS Meeting

- October 2007

## Fields in doubleCommon

- value has type double
- All other fields are a null structure
- A record instance can override
- If not overridden than NOT a property
- Following two slides show example
- The definition of display
- An example record instance

- ICALEPCS/EPICS Meeting

- October 2007

## display.xml

***<structure name = "display">***
***    ******<field name = "description" type = "string" />***
***    ******<field name = "format" type = "string" />***
***    ******<field name = "units" type = "string" />***
***    ******<field name = "resolution" type = "int" />***
***    ******<field name = "limit" type = "structure"***
***        ******structureName = "doubleLimit" />***
***</structure>***

- ICALEPCS/EPICS Meeting

- October 2007

## record instance

***Note that example.value will have property display.***
***<record name = "example" type = “double” >***
***    ******<display structureName = “display”>***
***        ******<units>volts</units>***
***        ******<limit>***
***            ******<low>0.0</low>***
***            ******<high>10.0</high>***
***        ******</limit>***
***    ******</display>***
***</structure>***

- ICALEPCS/EPICS Meeting

- October 2007

## Support Overview

- Implements record processing semantics
- Each record instance has support
- Each field of a record instance can optionally have support
- Support should always be as generic as possible
- Look for required fields and ignore all others
- If required fields not found don’t start

- ICALEPCS/EPICS Meeting

- October 2007

## generic support

- Is often the default support
- Supports both recordType and structure
- Algorithm
- For each field that has support call it.
- Each support must complete before support for the next field is called.
- If any support does not report success don’t call any more support.

- ICALEPCS/EPICS Meeting

- October 2007

## Analog Input Example

- The recordType is double
- Input has structureName linearConvert
- This has fields including value and input
- The default support is generic
- The following support is used
- generic
- linearConvertInput
- pdrvInt32Input

- ICALEPCS/EPICS Meeting

- October 2007

## Analog Input Instance

***pdrvInt32Input puts input.value; linearConvertInput puts value.***
***<record name = "ai" type = "double" >***
***    ******<input structureName = "linearConvertInput">***
***        ******<input supportName = "pdrvInt32Input"***
***              ******structureName = "pdrvSupport">***
***            ******<portName>aPortDriver</portName>***
***            ******<addr>0</addr>***
***            ******<timeout>.2</timeout>***
***            ******<size>20</size>***
***        ******</input>***
***        ******<linearConvert>***
***            ******<engUnitsLow>0.0</engUnitsLow>***
***            ******<engUnitsHigh>10.0</engUnitsHigh>***
***        ******</linearConvert>***
***    ******</input>***
***</record>***

- ICALEPCS/EPICS Meeting

- October 2007

## Analog Input Semantics

- The generic support for ai calls the support for field input
- The generic support for input
- Calls the pdrvInt32Support
- It puts a value into input.value
- Calls the linearConvertInput support
- It gets a value from input.value, converts it to engineering units, and puts the result into ai.value

- ICALEPCS/EPICS Meeting

- October 2007

## powerSupply Example

- This is an example of a “device” record
- Only new support is powerSupplyCurrent
- It gets power.value and voltage.value
- From these it computes the current
- Puts the current into current.value

- ICALEPCS/EPICS Meeting

- October 2007

## powerSupplyCommon.xml

***<?xml version="1.0" ?>***
***<DBDefinition>***
***  ******<field name = "power" type = "structure"***
***      ******structureName = "double" />***
***  ******<field name = "voltage" type = "structure"***
***      ******structureName = "double" />***
***  ******<field name = "current" type = "structure"***
***      ******structureName = "double" />***
***  ******<field name = "alarm" type = "structure"/>***
***  ******<field name = "timeStamp" type = "structure" />  ***
***</DBDefinition>***

- ICALEPCS/EPICS Meeting

- October 2007

## powerSupplyRecord.xml

***<?xml version="1.0" ?>***
***<DBDefinition>***
***<structure name = "powerSupply" supportName = "generic" >***
***  ******<include href = "powerSupplyCommon.xml" />***
***</structure>***
***<recordType name = "powerSupply" supportName = "generic" >***
***  ******<include href = "common.xml" />***
***  ******<include href = "powerSupplyCommon.xml" />***
***  ******<field name = "supportArray" type = "array"***
***     ******elementType = "structure" supportName = "supportArray" />***
***</recordType>***
***<support name = "powerSupplyCurrent"***
***   ******factoryName = "org.epics.ioc.support.PowerSupplyFactory" />***
***</DBDefinition>***

- ICALEPCS/EPICS Meeting

- October 2007

## powerSupplyExample.xml

***<record name = "ps" type = "powerSupply" >***
***    ******<voltage>***
***        ******<!-- do something to get voltage -->***
***    ******</voltage>***
***    ******<current>***
***        ******<input supportName = "powerSupplyCurrent" />***
***    ******</current>***
***</record>***

- ICALEPCS/EPICS Meeting

- October 2007

## powerSupplyArray

***The following defines a recordType that can hold an array of powerSupply***
***<?xml version="1.0" ?>***
***<DBDefinition>***
***<recordType name = "powerSupplyArray" supportName = "generic" >***
***  ******<include href = "common.xml" />***
***  ******<!-- instance must each element a powerSupply structure -->***
***  ******<field name = "supply" type = "array”***
***      ******elementType = “structure”/>***
***  ******<field name = "alarm" type = "structure"/>***
***  ******<field name = "timeStamp" type = "structure" /> ***
***</recordType>***

- ICALEPCS/EPICS Meeting

- October 2007

## psArrayExample.xml

***<record name = "psArray" type = "powerSupplyArray" >***
***    ******<supply capacity = “2”>***
***        ******<value structureName = “powerSupply” >***
***            ******<!-- do something to get voltage -->***
***            ******<current>***
***                ******<input supportName = "powerSupplyCurrent" />***
***            ******</current>***
***        ******</value>***
***        ******<value structureName = “powerSupply” >***
***            ******<!-- do something to get voltage -->***
***            ******<current>***
***                ******<input supportName = "powerSupplyCurrent" />***
***            ******</current>***
***        ******</value>***
***    ******</supply>***
***</record>***

- ICALEPCS/EPICS Meeting

- October 2007

## Finding Fields

- A V3 client could ask for
- ai.value
- ai.input.value
- ps.power.value
- ps.current.value
- ps.voltage.value
- psArray.supply[0].power.value
- psArray.supply[1].current.value

- ICALEPCS/EPICS Meeting

- October 2007

## portDriver

- Same functionality as asyn
- AsynManager does not exist
- Methods moved to User, Port, or Device
- Easier to understand: Code and Doc
- See javaDoc for org.epics.ioc.pdrv
- NOT Ready for use
- NO real drivers have been implemented
- STREAMS not implemented
- devGpib will not be implemented

- ICALEPCS/EPICS Meeting

- October 2007

## User.java

***Interface User {***
***    ******public static final int REASON_SIGNAL = -1;***
***    ******User duplicateUser(QueueRequestCallback***
***         ******queueRequestCallback);***
***    ******Port connectPort(String portName);***
***    ******void disconnectPort();***
***    ******Port getPort();***
***    ******Device connectDevice(int addr);***
***    ******void disconnectDevice();***
***    ******Device getDevice(); ***
***    ******void queueRequest(QueuePriority queuePriority);***
***    ******void cancelRequest();***
***    ******Status lockPort();***
***    ******void unlockPort();***
***    ******void setMessage(String message);***
***    ******String getMessage();***
***    ******void setTimeout(double timeout);***
***    ******double getTimeout();***

- ICALEPCS/EPICS Meeting

- October 2007

## User.java continued

***    ******void setDeviceDriverPvt(Object deviceDriverPvt);***
***    ******Object getDeviceDriverPvt();***
***    ******void setUserPvt(Object userPvt);***
***    ******Object getUserPvt();***
***    ******void setReason(int reason);***
***    ******int getReason();***
***    ******void setAuxStatus(int auxStatus);***
***    ******int getAuxStatus();***
***    ******void setInt(int value);***
***    ******int getInt();***
***    ******void setDouble(double value);***
***    ******double getDouble();***
***    ******void setString(String value);***
***     ******String getString();***
***}***
***    ***

- ICALEPCS/EPICS Meeting

- October 2007