Example #1
0
  /**
   * Record the setpoint and readback values as described in the Element Scan Table. These will be
   * used for reference in the relative scan mode.
   *
   * @throws NotificationException
   * @throws ChannelAccessException
   */
  private void readInitialValues() throws NotificationException, ChannelAccessException {
    /** Read the initial setpoint values of PVs */
    initialSetpointValues = PVConnection.readPvValues(getPVs());
    // System.out.println(initialSetpointValues.toString());

    /** Read the initial readback values of corresponding PVs */
    initialReadbackValues = PVConnection.readPvValues(thresholdPVs);
  }
Example #2
0
  /**
   * Steps
   *
   * @throws NotificationException
   */
  @Override
  public Integer setNextStep(Scenario model) throws NotificationException {

    /** Read from table new value to set */
    Map<String, Double> newPvValues = new HashMap<String, Double>();
    for (String pv : getPVs()) {
      String newValue = getPvValueByName(getStepNumber(), pv);
      if (newValue.equals("SKIP")) {
        // Do Nothing
      } else {
        try {
          // Check if real number
          newPvValues.put(pv, Double.valueOf(newValue));
        } catch (Exception e) {
          throw new NotificationException(
              newValue + " Is not a valid number format. Plean use a valid format or \"SKIP\"");
        }
      }
    }

    /** If relative flag, add initial setpoint value. Applies to all values in current step. */
    if (useRelative.get(getStepNumber()) == 1) {
      for (String pv : newPvValues.keySet()) {
        newPvValues.put(pv, newPvValues.get(pv) + initialSetpointValues.get(pv));
      }
    }

    /** Set PVs */
    try {
      PVConnection.setPvValues(newPvValues);
    } catch (ChannelAccessException e) {
      throw new NotificationException("ChannelAccessException");
    }

    /** Return information about use of acquisition */
    return useAcquisition.get(getStepNumber());
  }
Example #3
0
  @Override
  public boolean checkThresholds() throws NotificationException, ThresholdException {

    for (int i = 0; i < thresholdPVs.size(); i++) {
      if (thresholdPVs.get(i).equals("EMPTY"))
        throw new NotificationException(
            "The \"EMPTY\" input is depricated. Please use \"IGNORE\" in comparison method line");

      if (thresholdCheckMethod.get(i).equals("IGNORE")) {
        continue;
      }

      String setValueString = getPvByIndex(getStepNumber(), i);
      if (setValueString.equals("SKIP")) continue; // Don't compare to values never set

      Double actual = Double.NaN;
      Double expected = Double.valueOf(setValueString);
      Double comparisonValue = thresholdValues.get(i);

      try {
        actual = PVConnection.readPvValue(thresholdPVs.get(i));
      } catch (ChannelAccessException e) {
        throw new NotificationException(
            "Error accessing threshold channel: " + thresholdPVs.get(i));
      }

      if (thresholdCheckMethod.get(i).equals("RATIO")) { // Ratio
        if (Math.abs((expected - actual) / expected) > comparisonValue)
          throw new ThresholdException(getPVs().get(i), expected, actual);
      } else if (!thresholdCheckMethod.get(i).equals("DIFFERENCE")) { // Difference
        if (Math.abs(expected - actual) > comparisonValue)
          throw new ThresholdException(getPVs().get(i), expected, actual);
      }
    }
    return true;
  }