/** Subscribe for value updates. */ private void subscribe() { synchronized (this) { // Prevent multiple subscriptions. if (subscription != null) { return; } // Late callback, channel already closed? final RefCountedChannel ch_ref = channel_ref; if (ch_ref == null) { return; } final Channel channel = ch_ref.getChannel(); // final Logger logger = Activator.getLogger(); try { if (channel.getConnectionState() != Channel.CONNECTED) { return; } // // the RefCountedChannel should maintain a single // subscription to the underlying CAJ/JCA channel. // So even with N PVs for the same channel, it's // only one subscription on the network instead of // N subscriptions. final DBRType type = DBR_Helper.getTimeType(plain, channel.getFieldType()); state = PVConnectionState.Subscribing; totalMetaInfo.setStartTime(System.currentTimeMillis()); // isnotTimestampDBR if (this.name.endsWith(".RTYP")) { subscription = channel.addMonitor(MonitorMask.ARCHIVE.getMask(), this); } else { subscription = channel.addMonitor( type, channel.getElementCount(), MonitorMask.ARCHIVE.getMask(), this); } } catch (final Exception ex) { logger.error("exception when subscribing pv " + name, ex); } } }