# Usage

This plugin implements the PV & PVFactory defined in org.csstudio.utility.pv for EPICS (Channel Access). Ordinarily, one would use org.csstudio.utility.pv.PVFactory, so refer to its javadoc. For tests or standalone programs that don't use the platform registry, one can directly use the EPICS_V3_PV as described in here. 1) Required imports import org.csstudio.utility.pv.PV; import org.csstudio.utility.pv.epics.EPICS_V3_PV; 2) Required Property Settings Ordinarily, the org.csstudio.platform.libs.epics plugin that provides the JCA/CAJ jar files will initialize the required system properties from Eclipse preference settings (and org.csstudio.platform.libs.epics.ui would offer a GUI preference page for end users to change those settings). When we're running without the platform, we need to set those properties directly: // Set system properties for Channel Access because // we're not running with the whole preferences etc. System.setProperty("com.cosylab.epics.caj.CAJContext.addr_list", "127.0.0.1 160.91.228.17"); System.setProperty("com.cosylab.epics.caj.CAJContext.auto_addr_list", "false"); 3) Create PV String name = ...; // Instead of PVFactory.create(name), use PV pv = new EPICS_V3_PV(name); 4) Usage of PV .. is just like using a PV created via the PVFactory, so see there.

# Implementation Details

Uses internal reference counting. When one requests the same PV more than once from the pure java CA client library, one always receives the same channel instance.

When several plug-ins use CA, it is on one hand desired that they use the same CA client library context, but the above feature means that they receive the same channel reference without knowing.

This makes it impossible to write proper cleanup code: If the channel is left open, resources are wasted, also on the IOC. If it is closed, one might accidentally close a channel that is still used by another plugin.

If all plugins go through this PV interface, the PV interface will perform the reference counting for the one and only channel that is obtained from the CA client libraries.