コード例 #1
0
 private void waitEndMoving(final DeviceProxy proxy) throws DevFailed {
   waitTask = new WaitStateTask(proxy.get_name(), DevState.MOVING, 100, false);
   waitTask.run();
   if (waitTask.hasFailed()) {
     throw waitTask.getDevFailed();
   }
 }
コード例 #2
0
  protected DeviceProxy createTangoUnit() throws DevFailed, TimeoutException {
    DeviceProxy result = null;

    DeviceData data = proxy.command_inout("CreateDevice");
    result = new DeviceProxy(data.extractString());
    WaitStateUtilities.waitForState(result, DevState.STANDBY, 20000);

    return result;
  }
コード例 #3
0
  private DeviceData executeCommand(
      final String cmdAttribute, final String originalCommand, final DeviceData cmdData) {

    try {
      final String timeout = System.getProperty("org.dawb.tango.spec.command.timeout");
      tangoProxy.set_timeout_millis(
          timeout != null ? Integer.parseInt(timeout) : Integer.MAX_VALUE);
      DeviceData ret = tangoProxy.command_inout(cmdAttribute, cmdData);

      // For fast scans this returns before the spec events have finished being sent
      // over by tango.
      while ((System.currentTimeMillis() - lastEvent) < 1000)
        try {
          Thread.sleep(500); // Fudge
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      TangoConnectionEvent event =
          new TangoConnectionEvent(
              TangoConnectionImpl.this, new TangoMockEvent(), "Finished '" + originalCommand + "'");
      event.setFinished(true);
      fireTangoConnectionListeners(event);

      return ret;

    } catch (DevFailed e) {
      TangoConnectionEvent event =
          new TangoConnectionEvent(
              TangoConnectionImpl.this, new TangoMockEvent(), "Failed '" + originalCommand + "'");

      if (e.errors != null && e.errors.length > 0) {
        event.setErrorMessage(e.errors[e.errors.length - 1].desc);
      } else {
        event.setErrorMessage(e.getLocalizedMessage());
      }

      event.setFinished(true);
      fireTangoConnectionListeners(event);

      return null;
    }
  }
コード例 #4
0
  @Override
  public void setValue(DeviceAttribute value) throws Exception {

    if (attributeName == null) throw new NullPointerException("Cannot read attribute " + null);
    tangoProxy.write_attribute(value); // Does not block for spec motors!

    // TODO Talk to Andy about blocking until setValue has completed? Spec does not...

    // For now we check value
    // FIXME
    // START BODGE WARNING

    try {
      Thread.sleep(50); // Fudge incase tango is not blocking properly again.
    } catch (Exception ignored) {

    }

    try {
      double current = getValue().extractDouble();
      double required = value.extractDouble();
      double tolerance = 0.001; // That does not really work!!

      int total = 0;
      while (current > (required + tolerance) || current < (required - tolerance)) {

        if (total > 5000) {
          logger.error("TIMEOUT: Cannot set motor value " + getUri() + " synchronously!");
          return;
        }
        try {
          Thread.sleep(200);
        } catch (Exception ne) {
          break;
        }
        total += 200;
        current = getValue().extractDouble();
      }
    } catch (Exception ignored) {
      return;
    }
    // END BODGE WARNING
  }
コード例 #5
0
 @Override
 public DeviceAttribute getValue() throws Exception {
   if (attributeName == null) throw new NullPointerException("Cannot read attribute " + null);
   return tangoProxy.read_attribute(attributeName);
 }
コード例 #6
0
 protected void releaseTangoUnit(String device) throws DevFailed {
   DeviceData argin = new DeviceData();
   argin.insert(device);
   proxy.command_inout("ReleaseDevice", argin);
 }