Esempio n. 1
0
  @Override
  public int match(ValueCache<?> cache, JCAConnectionPayload connPayload) {
    Channel channel = connPayload.getChannel();

    // If the generated type can't be put in the cache, no match
    if (!cache.getType().isAssignableFrom(typeClass)) return 0;

    // If the type of the channel does not match, no match
    if (!dbrTypeMatch(epicsValueType, connPayload.getFieldType())) return 0;

    // If processes array, but count is 1, no match
    if (array != null && array && channel.getElementCount() == 1) return 0;

    // If processes scalar, but the count is not 1, no match
    if (array != null && !array && channel.getElementCount() != 1) return 0;

    // Everything matches
    return 1;
  }
Esempio n. 2
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);
     }
   }
 }