public synchronized void saveDevice(final Actor actor, final String deviceName) throws DevFailed {
   final Director dir = actor.getDirector();
   if (dir instanceof RecordingDirector) {
     if (isRecordingStarted(actor)) {
       final boolean autoChangeNX =
           ((RecordingDirector) actor.getDirector()).isAutoChangeNxEntry();
       if (autoChangeNX) {
         incNxEntryNameAndSaveContext(actor);
       }
       final String dataRecorderName =
           ((RecordingDirector) actor.getDirector()).getDataRecorderName();
       ExecutionTracerService.trace(
           actor, "saving device " + deviceName + " on datarecorder " + dataRecorderName);
       final TangoCommand command = new TangoCommand(dataRecorderName, "WriteTangoDeviceData");
       command.execute(deviceName);
       if (DataRecorder.asyncMode) {
         // Bug 22954
         final TangoCommand commandState = new TangoCommand(dataRecorderName, "State");
         logger.debug(
             "DR state :"
                 + TangoConst.Tango_DevStateName[
                     TangoAccess.getCurrentState(commandState).value()]);
         waitEndMoving(command.getDeviceProxy());
         logger.debug(
             "DR state :"
                 + TangoConst.Tango_DevStateName[
                     TangoAccess.getCurrentState(commandState).value()]);
       }
     }
   }
 }
 public synchronized void endRecording(final String dataRecorderName) throws DevFailed {
   if (isRecordingStarted(dataRecorderName)) {
     logger.debug("EndRecording is called");
     final TangoCommand comHelp = new TangoCommand(dataRecorderName, "EndRecording");
     comHelp.execute();
   }
   startRecording = false;
 }
 public synchronized void endRecording(final Actor actor) throws DevFailed {
   final Director dir = actor.getDirector();
   if (dir instanceof RecordingDirector) {
     if (isRecordingStarted(actor)) {
       final String deviceName = ((RecordingDirector) actor.getDirector()).getDataRecorderName();
       final TangoCommand comHelp = new TangoCommand(deviceName, "EndRecording");
       comHelp.execute();
     }
   }
 }
 public synchronized void startRecording(final Actor actor) throws DevFailed {
   firstRecord = true;
   final Director dir = actor.getDirector();
   if (dir instanceof RecordingDirector) {
     final String deviceName = ((RecordingDirector) actor.getDirector()).getDataRecorderName();
     final TangoCommand comHelp = new TangoCommand(deviceName, "StartRecording");
     comHelp.execute();
     startRecording = true;
   } else {
     ExecutionTracerService.trace(actor, "WARNING - there is no Recording director");
   }
 }
 public synchronized void setSymbol(
     final Actor actor, final String symbolName, final String symbolValue) throws DevFailed {
   final Director dir = actor.getDirector();
   if (dir instanceof RecordingDirector) {
     if (isRecordingStarted(actor)) {
       final String dataRecorderName =
           ((RecordingDirector) actor.getDirector()).getDataRecorderName();
       logger.debug("Setting symbol " + symbolName + " on " + dataRecorderName);
       final TangoCommand command = new TangoCommand(dataRecorderName, "SetSymbol");
       final Object[] argin = {symbolName, symbolValue};
       command.execute(argin);
     }
   }
 }
 public synchronized void savePostContext(final Actor actor) throws DevFailed {
   final Director dir = actor.getDirector();
   if (dir instanceof RecordingDirector) {
     if (isRecordingStarted(actor)) {
       // nxEntryCounter++;
       final String dataRecorderName =
           ((RecordingDirector) actor.getDirector()).getDataRecorderName();
       // write post technical data after the first loop
       final TangoCommand commandWritePostTechnicalData =
           new TangoCommand(dataRecorderName, "WritePostTechnicalData");
       commandWritePostTechnicalData.execute();
       if (DataRecorder.asyncMode) {
         waitEndMoving(commandWritePostTechnicalData.getDeviceProxy());
       }
     }
   }
 }
  /**
   * does not exist anymore on datarecorder
   *
   * @param actor
   * @param scanDeviceName
   * @param scan1DDeviceName
   * @param scan2DDeviceName
   * @throws DevFailed
   */
  @Deprecated
  public synchronized void saveScan(
      final Actor actor,
      final String scanDeviceName,
      final String scan1DDeviceName,
      final String scan2DDeviceName)
      throws DevFailed {
    final Director dir = actor.getDirector();
    if (dir instanceof RecordingDirector) {
      if (isRecordingStarted(actor)) {
        final String dataRecorderName =
            ((RecordingDirector) actor.getDirector()).getDataRecorderName();
        ExecutionTracerService.trace(actor, "saving scan data on datarecorder " + dataRecorderName);
        final TangoCommand command = new TangoCommand(dataRecorderName, "WriteScanData");

        final Object[] devicesNames = {scanDeviceName, scan1DDeviceName, scan2DDeviceName};
        command.execute(devicesNames);
        if (DataRecorder.asyncMode) {
          waitEndMoving(command.getDeviceProxy());
        }
        logger.debug("saved scan data");
      }
    }
  }
  public synchronized void setNxEntryNameAndSaveContext(final Actor actor, final String suffix)
      throws DevFailed {
    final Director dir = actor.getDirector();
    if (dir instanceof RecordingDirector) {
      if (isRecordingStarted(actor)) {
        final String dataRecorderName =
            ((RecordingDirector) actor.getDirector()).getDataRecorderName();
        final TangoCommand commandState = new TangoCommand(dataRecorderName, "State");
        /*
         * ExecutionTracerService.trace(actor, "incrementing experiment
         * and acquisition indexes");
         */

        if (!firstRecord) {
          // write post technical data after the first loop
          logger.debug("write post technical data");
          final TangoCommand commandWritePostTechnicalData =
              new TangoCommand(dataRecorderName, "WritePostTechnicalData");
          commandWritePostTechnicalData.execute();
          if (DataRecorder.asyncMode) {
            logger.debug(
                "DR state :"
                    + TangoConst.Tango_DevStateName[
                        TangoAccess.getCurrentState(commandState).value()]);
            waitEndMoving(commandWritePostTechnicalData.getDeviceProxy());
            logger.debug(
                "DR state :"
                    + TangoConst.Tango_DevStateName[
                        TangoAccess.getCurrentState(commandState).value()]);
          }
        } else {
          firstRecord = false;
        }

        if (cancel) {
          cancel = false;
          return;
        }

        // increment indexes
        logger.debug("incrementing experiment and acquisition indexes");
        final TangoCommand commandIncAcq =
            new TangoCommand(dataRecorderName, "IncAcquisitionIndex");
        commandIncAcq.execute();

        final TangoCommand commandExpAcq = new TangoCommand(dataRecorderName, "IncExperimentIndex");
        commandExpAcq.execute();

        // change acquisition name
        final TangoAttribute acqName = new TangoAttribute(dataRecorderName + "/acquisitionName");
        acqName.write(suffix);

        if (cancel) {
          cancel = false;
          return;
        }

        // write user data
        logger.debug("user data ");
        final TangoCommand commandWriteUserData =
            new TangoCommand(dataRecorderName, "WriteUserData");
        commandWriteUserData.execute();
        if (DataRecorder.asyncMode) {
          waitEndMoving(commandWriteUserData.getDeviceProxy());
        }

        if (cancel) {
          cancel = false;
          return;
        }

        // write pre technical data
        logger.debug("write pre technical data");
        final TangoCommand commandWritePreTechnicalData =
            new TangoCommand(dataRecorderName, "WritePreTechnicalData");
        commandWritePreTechnicalData.execute();
        if (DataRecorder.asyncMode) {
          logger.debug(
              "DR state :"
                  + TangoConst.Tango_DevStateName[
                      TangoAccess.getCurrentState(commandState).value()]);
          waitEndMoving(commandWritePreTechnicalData.getDeviceProxy());
          logger.debug(
              "DR state :"
                  + TangoConst.Tango_DevStateName[
                      TangoAccess.getCurrentState(commandState).value()]);
        }
      }
    }
  }