Exemplo n.º 1
0
 @Override
 public synchronized Map<String, Object> getProperties() {
   Map<String, Object> properties = new HashMap<String, Object>();
   if (channel != null) {
     properties.put("Channel name", channel.getChannelName());
     properties.put("Connection state", channel.getConnectionState().name());
     properties.put("Provider name", channel.getProvider().getProviderName());
     if (channel.getConnectionState() == Channel.ConnectionState.CONNECTED) {
       properties.put("Remote address", channel.getRemoteAddress());
       properties.put("Channel type", channelType.getID());
       // properties.put("Read access", channel.getReadAccess());
       // properties.put("Write access", channel.getWriteAccess());
     }
   }
   return properties;
 }
Exemplo n.º 2
0
  @Override
  public void addReader(ChannelHandlerReadSubscription subscription) {
    super.addReader(subscription);

    if (!monitorCreated.getAndSet(true)) {
      // TODO remove this....
      for (int i = 0;
          i < 100 && channel.getConnectionState() == ConnectionState.NEVER_CONNECTED;
          i++) {
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
        }
      }
      // TODO optimize fields
      channel.createMonitor(this, CreateRequestFactory.createRequest("field()", this));
    }
  }
Exemplo n.º 3
0
  @Override
  public void write(Object newValue, ChannelWriteCallback callback) {

    boolean wasEmpty;
    synchronized (writeRequests) {
      wasEmpty = writeRequests.isEmpty();
      writeRequests.add(new WriteRequest(newValue, callback));
    }

    if (!channelPutCreated.getAndSet(true)) {
      channel.createChannelPut(this, isChannelEnumType ? enumPutPVRequest : standardPutPVRequest);
    } else if (wasEmpty) {
      doNextWrite();
    }
  }
Exemplo n.º 4
0
  @Override
  public void channelStateChange(Channel channel, ConnectionState connectionState) {
    try {

      // introspect
      if (connectionState == ConnectionState.CONNECTED) {
        channel.getField(this, null);
      } else {
        processConnection(this);
      }

    } catch (Exception ex) {
      reportExceptionToAllReadersAndWriters(ex);
    }
  }
Exemplo n.º 5
0
  /* (non-Javadoc)
   * @see org.epics.pvaccess.client.GetFieldRequester#getDone(org.epics.pvdata.pv.Status, org.epics.pvdata.pv.Field)
   */
  @Override
  public void getDone(Status status, Field field) {
    reportStatus("Failed to instrospect channel '" + channel.getChannelName() + "'", status);

    if (status.isSuccess()) {
      channelType = field;

      Field valueField = ((Structure) channelType).getField("value");
      if (valueField != null && valueField.getID().equals("enum_t")) {
        isChannelEnumType = true;
        // TODO could create a monitor just to get value.choices
      } else isChannelEnumType = false;
    }

    processConnection(this);
  }
Exemplo n.º 6
0
  @Override
  public void disconnect() {
    // Close the channel
    try {
      channel.destroy();
    } finally {
      channel = null;

      // monitor = null;
      monitorCreated.set(false);

      channelType = null;

      channelPut = null;
      channelPutValueField = null;
      channelPutCreated.set(false);
    }
  }
Exemplo n.º 7
0
 @Override
 protected boolean isWriteConnected(PVAChannelHandler channel) {
   // NOTE: access-rights not yet supported
   final Channel c = channel.getChannel();
   return c != null && c.isConnected();
 }
Exemplo n.º 8
0
 @Override
 public boolean isConnected(PVAChannelHandler channel) {
   final Channel c = channel.getChannel();
   return c != null && c.isConnected();
 }
Exemplo n.º 9
0
 @Override
 public void channelCreated(Status status, Channel channel) {
   reportStatus("Failed to create channel instance '" + channel.getChannelName(), status);
   this.channel = channel;
 }