Пример #1
0
 // ChannelPutRequester
 @Override
 public void putDone(final Status status, final ChannelPut channelPut) {
   if (status.isSuccess())
     logger.log(Level.FINE, "Write {0} = {1} completed", new Object[] {pv.getName(), new_value});
   else {
     error =
         new Exception(
             "Write " + pv.getName() + " = " + new_value + " failed, " + status.toString());
     logger.log(Level.WARNING, "", error);
   }
   updates.countDown();
   channelPut.destroy();
 }
Пример #2
0
 // Future
 @Override
 public Object get(final long timeout, final TimeUnit unit)
     throws InterruptedException, ExecutionException, TimeoutException {
   if (!updates.await(timeout, unit)) throw new TimeoutException(pv.getName() + " write timeout");
   if (error != null) throw new ExecutionException(error);
   return null;
 }
Пример #3
0
  // ChannelPutRequester
  @Override
  public void channelPutConnect(
      final Status status, final ChannelPut channelPut, final Structure structure) {
    if (!status.isSuccess()) {
      error = new Exception("Failed to connect 'put' for " + pv.getName() + ": " + status);
      updates.countDown();
      return;
    }

    try {
      final PVStructure write_structure =
          PVDataFactory.getPVDataCreate().createPVStructure(structure);
      final BitSet bit_set = new BitSet(write_structure.getNumberFields());

      // Locate the value field at deepest level in structure
      PVField field = null;
      PVStructure search = write_structure;
      while (search != null) {
        final PVField[] fields = search.getPVFields();
        if (fields.length != 1)
          throw new Exception(
              "Can only write to simple struct.element.value path, got " + structure);
        if (fields[0].getFieldName().equals("value")) {
          field = fields[0];
          break;
        } else if (fields[0] instanceof PVStructure) search = (PVStructure) fields[0];
        else search = null;
      }
      if (field == null) throw new Exception("Cannot locate 'value' to write in " + structure);

      // Enumerated? Write to value.index
      if (field instanceof PVStructure && "enum_t".equals(field.getField().getID()))
        field = ((PVStructure) field).getSubField("index");

      // Indicate what's changed & change it
      bit_set.set(field.getFieldOffset());
      PVStructureHelper.setField(field, new_value);

      // Perform write
      channelPut.put(write_structure, bit_set);
    } catch (Exception ex) {
      logger.log(Level.WARNING, "Failed to write " + pv.getName() + " = " + new_value, ex);
      error = new Exception("Failed to write " + pv.getName() + " = " + new_value, ex);
      updates.countDown();
    }
  }
Пример #4
0
 @Override
 public void disconnected(PV pv) {
   logger.log(Level.WARNING, "Mask PV Disconnected: " + pv.getName());
   updateState(jumper, null);
 }
Пример #5
0
 @Override
 public void disconnected(PV pv) {
   logger.log(Level.WARNING, "Jumper PV Disconnected: " + pv.getName());
   updateState(null, mask);
 }
Пример #6
0
 /** @return Name of the Mask PV, for example "Ring_Vac:SGV_AB:FPL_Ring_swmask" */
 public String getMaskPVName() {
   return mask_pv.getName();
 }
Пример #7
0
 /** @return Name of the Jumper PV, for example "Ring_Vac:SGV_AB:FPL_Ring_sw_jump_status" */
 public String getJumperPVName() {
   return jumper_pv.getName();
 }