예제 #1
0
 private static boolean dbrTypeMatch(DBRType aType, DBRType anotherType) {
   if (aType.getClass() == null && anotherType.getClass() != null) {
     return false;
   }
   if (aType.getClass() != null && anotherType.getClass() == null) {
     return false;
   }
   return aType.isBYTE() && anotherType.isBYTE()
       || aType.isDOUBLE() && anotherType.isDOUBLE()
       || aType.isENUM() && anotherType.isENUM()
       || aType.isFLOAT() && anotherType.isFLOAT()
       || aType.isINT() && anotherType.isINT()
       || aType.isSHORT() && anotherType.isSHORT()
       || aType.isSTRING() && anotherType.isSTRING();
 }
예제 #2
0
 @Override
 public void updateTotalMetaInfo() throws IllegalStateException, CAException {
   GetListener getListener =
       new GetListener() {
         @Override
         public void getCompleted(final GetEvent event) {
           // This runs in a CA thread
           if (event.getStatus().isSuccessful()) {
             state = PVConnectionState.GotMetaData;
             final DBR dbr = event.getDBR();
             logger.debug("Updating metadata (EGU/PREC etc) for pv " + EPICS_V3_PV.this.name);
             totalMetaInfo.applyBasicInfo(
                 EPICS_V3_PV.this.name, dbr, EPICS_V3_PV.this.configservice);
           } else {
             logger.error("The meta get listener was not successful for EPICS_V3_PV " + name);
           }
         }
       };
   if (channel_ref != null) {
     if (channel_ref.getChannel().getConnectionState() == ConnectionState.CONNECTED) {
       DBRType type = channel_ref.getChannel().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_ref.getChannel().get(type, 1, getListener);
       }
     }
   }
 }
예제 #3
0
 /** @return TIME_... type for this channel. */
 public static DBRType getTimeType(final boolean plain, final DBRType type) {
   if (type.isDOUBLE()) return plain ? DBRType.DOUBLE : DBRType.TIME_DOUBLE;
   else if (type.isFLOAT()) return plain ? DBRType.FLOAT : DBRType.TIME_FLOAT;
   else if (type.isINT()) return plain ? DBRType.INT : DBRType.TIME_INT;
   else if (type.isSHORT()) return plain ? DBRType.SHORT : DBRType.TIME_SHORT;
   else if (type.isENUM()) return plain ? DBRType.SHORT : DBRType.TIME_ENUM;
   else if (type.isBYTE()) return plain ? DBRType.BYTE : DBRType.TIME_BYTE;
   // default: get as string
   return plain ? DBRType.STRING : DBRType.TIME_STRING;
 }
예제 #4
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();
 }