Ejemplo n.º 1
0
 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()]);
       }
     }
   }
 }
Ejemplo n.º 2
0
 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();
     }
   }
 }
Ejemplo n.º 3
0
 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");
   }
 }
Ejemplo n.º 4
0
 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);
     }
   }
 }
Ejemplo n.º 5
0
  public synchronized boolean isRecordingStarted(final Actor actor) throws DevFailed {
    final Director dir = actor.getDirector();
    if (dir instanceof RecordingDirector) {
      final String dataRecorderName =
          ((RecordingDirector) actor.getDirector()).getDataRecorderName();

      // bug 22954
      if (TangoAccess.isCurrentStateEqualStateRequired(dataRecorderName, DevState.ON)) {
        return false;
      } else {
        return true;
      }
    } else {
      return false;
    }
  }
Ejemplo n.º 6
0
 public synchronized boolean isSaveActive(final Actor actor) {
   final Director dir = actor.getDirector();
   if (dir instanceof RecordingDirector) {
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 7
0
 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());
       }
     }
   }
 }
Ejemplo n.º 8
0
  /**
   * 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");
      }
    }
  }
Ejemplo n.º 9
0
 /*
  * (non-Javadoc)
  * @see com.isencia.passerelle.actor.Actor#doInitialize()
  */
 @Override
 protected void doInitialize() throws InitializationException {
   // TODO Auto-generated method stub
   super.doInitialize();
   firstOperandHandler = new PortHandler(firstOperand);
   if (firstOperand.getWidth() > 0) {
     firstOperandHandler.start();
   }
   if (secondOperand != null) {
     secondOperandHandler = new PortHandler(secondOperand);
     if (secondOperand.getWidth() > 0) {
       secondOperandHandler.start();
     }
   }
 }
Ejemplo n.º 10
0
  @Override
  @SuppressWarnings("unchecked")
  protected void doInitialize() throws InitializationException {
    getLogger().trace("{} - doInitialize() - entry", getFullName());
    super.doInitialize();

    blockingInputHandlers.clear();
    blockingInputFinishRequests.clear();

    iterationCount = 0;
    currentProcessRequest = new ProcessRequest();
    currentProcessRequest.setIterationCount(++iterationCount);
    currentProcessResponse = null;

    List<Port> inputPortList = this.inputPortList();
    for (Port _p : inputPortList) {
      if (_p.isInput() && !(_p instanceof ControlPort)) {
        if (_p.isBlocking()) {
          blockingInputHandlers.add(createPortHandler(_p));
          blockingInputFinishRequests.put(_p, Boolean.FALSE);
        }
        isSource = false;
      }
    }
    for (int i = 0; i < blockingInputHandlers.size(); ++i) {
      PortHandler h = blockingInputHandlers.get(i);
      if (h.getWidth() > 0) {
        blockingInputFinishRequests.put(h.getPort(), Boolean.FALSE);
        h.start();
      } else {
        blockingInputFinishRequests.put(h.getPort(), Boolean.TRUE);
      }
    }

    try {
      triggerFirstIteration();
    } catch (IllegalActionException e) {
      throw new InitializationException(
          ErrorCode.FLOW_EXECUTION_FATAL,
          "Error triggering a fire iteration for source actor " + getFullName(),
          this,
          e);
    }

    getLogger().trace("{} - doInitialize() - exit", getFullName());
  }
Ejemplo n.º 11
0
 @Override
 public void attributeChanged(final Attribute attribute) throws IllegalActionException {
   try {
     if (attribute == function) {
       final String functionName = function.stringValue();
       if (functionName.equals("exp")) {
         _function = _EXP;
         if (secondOperand != null) {
           secondOperand.setContainer(null);
         }
       } else if (functionName.equals("log")) {
         _function = _LOG;
         if (secondOperand != null) {
           secondOperand.setContainer(null);
         }
       } else if (functionName.equals("modulo")) {
         _function = _MODULO;
         _createSecondPort();
       } else if (functionName.equals("sign")) {
         _function = _SIGN;
         if (secondOperand != null) {
           secondOperand.setContainer(null);
         }
       } else if (functionName.equals("square")) {
         _function = _SQUARE;
         if (secondOperand != null) {
           secondOperand.setContainer(null);
         }
       } else if (functionName.equals("sqrt")) {
         _function = _SQRT;
         if (secondOperand != null) {
           secondOperand.setContainer(null);
         }
       } else {
         throw new IllegalActionException(this, "Unrecognized math function: " + functionName);
       }
     } else {
       super.attributeChanged(attribute);
     }
   } catch (final NameDuplicationException nameDuplication) {
     throw new InternalErrorException(this, nameDuplication, "Unexpected name duplication");
   }
 }
Ejemplo n.º 12
0
  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()]);
        }
      }
    }
  }
Ejemplo n.º 13
0
 @Override
 protected void doPreInitialize() throws InitializationException {
   super.doPreInitialize();
   pushedMessages = newMessageQueue();
 }