コード例 #1
0
 public JCAConnectionPayload(
     JCAChannelHandler channleHandler, Channel channel, JCAConnectionPayload previousPayload) {
   this.jcaDataSource = channleHandler.getJcaDataSource();
   this.channel = channel;
   this.connected =
       channel != null && channel.getConnectionState() == Channel.ConnectionState.CONNECTED;
   this.longString = channleHandler.isLongString();
   if (channel.getFieldType().getClass() == null && previousPayload != null) {
     // JNI sets the type to unknown on disconnect. We need
     // to remember the type before the disconnection
     this.fieldType = previousPayload.fieldType;
   } else {
     this.fieldType = channel.getFieldType();
   }
 }
コード例 #2
0
 /** PV is connected. Get meta info, or subscribe right away. */
 private void handleConnected(final Channel channel) {
   try {
     if (channel.getConnectionState() != Channel.CONNECTED) {
       return;
     }
   } catch (Exception ex) {
     logger.warn("Exception handling connection state change for " + this.name, ex);
     return;
   }
   if (state == PVConnectionState.Connected) return;
   state = PVConnectionState.Connected;
   hostName = channel_ref.getChannel().getHostName();
   totalMetaInfo.setHostName(hostName);
   for (final PVListener listener : listeners) {
     listener.pvConnected(this);
   }
   // If we're "running", we need to get the meta data and
   // then subscribe.
   // Otherwise, we're done.
   if (!running) {
     connected = true;
     // meta = null;
     synchronized (this) {
       this.notifyAll();
     }
     return;
   }
   // else: running, get meta data, then subscribe
   try {
     DBRType type = channel.getFieldType();
     if (!(plain || type.isSTRING())) {
       state = PVConnectionState.GettingMetadata;
       if (type.isDOUBLE() || type.isFLOAT()) type = DBRType.CTRL_DOUBLE;
       else if (type.isENUM()) type = DBRType.LABELS_ENUM;
       else if (type.isINT()) type = DBRType.CTRL_INT;
       else type = DBRType.CTRL_SHORT;
       channel.get(type, 1, meta_get_listener);
       return;
     }
   } catch (final Exception ex) {
     logger.error("exception when handleConnect " + name, ex);
     return;
   }
   // Meta info is not requested, not available for this type,
   // or there was an error in the get call.
   // So reset it, then just move on to the subscription.
   // meta = null;
   subscribe();
 }
コード例 #3
0
 /** 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);
     }
   }
 }