示例#1
0
  /**
   * Returns <code>true</code> if the specified instrument run value is equal to the value of the
   * configured other parameter.
   *
   * @param runValue instrument run value
   * @param runService instrument run service
   * @return <code>true</code> if instrument run value equals value of configured other parameter
   */
  public boolean checkParameterValue(
      InstrumentParameter checkedParameter,
      Data paramData,
      InstrumentRunService runService,
      ActiveInstrumentRunService activeRunService) {
    // If the other parameter has not been specified, there is nothing to check!
    if (parameterCode == null) {
      return true;
    }

    //
    // Get the other parameter's value.
    //
    log.debug("Retrieving parameter value : {}", parameterCode);

    InstrumentRunValue otherRunValue = activeRunService.getInstrumentRunValue(parameterCode);
    Data otherData = null;

    if (otherRunValue != null) {
      InstrumentParameter otherParam =
          activeRunService
              .getInstrumentType()
              .getInstrumentParameter(otherRunValue.getInstrumentParameter());

      if (!otherParam.getDataType().equals(paramData.getType())) {
        InstrumentRunValue targetRunValue = new InstrumentRunValue();
        targetRunValue.setInstrumentParameter(checkedParameter.getCode());
        UnitParameterValueConverter converter = new UnitParameterValueConverter();
        converter.convert(activeRunService, targetRunValue, otherRunValue);
        otherData = targetRunValue.getData(paramData.getType());
      } else {
        InstrumentParameter otherParameter =
            activeRunService.getInstrumentType().getInstrumentParameter(parameterCode);
        otherData = otherRunValue.getData(otherParameter.getDataType());
      }
    } else {
      log.debug("Value is : null");
    }

    // Lazily instantiate the equalsValueCheck.
    EqualsValueCheck equalsValueCheck = new EqualsValueCheck();

    // Update the equalsValueCheck accordingly.
    equalsValueCheck.setData(otherData);
    equalsValueCheck.setOperator(operator);

    return equalsValueCheck.checkParameterValue(
        checkedParameter, paramData, runService, activeRunService);
  }
示例#2
0
  @Override
  public boolean checkParameterValue(
      InstrumentParameter checkedParameter,
      Data paramData,
      InstrumentRunService runService,
      ActiveInstrumentRunService activeRunService) {
    if (parameterCode != null && (percent != null || offset != null)) {
      //
      // Get the other parameter's value.
      //
      InstrumentRunValue otherRunValue = activeRunService.getInstrumentRunValue(parameterCode);

      Data otherData = null;
      if (otherRunValue != null) {
        otherData = otherRunValue.getData(paramData.getType());
      }

      if (otherData != null && otherData.getValue() != null) {
        // Lazily instantiate the rangeCheck.
        if (rangeCheck == null) {
          rangeCheck = new RangeCheck();
        }

        if (checkedParameter.getDataType() == DataType.INTEGER) {
          initIntegerRangeCheck(paramData, otherData);
        } else if (checkedParameter.getDataType() == DataType.DECIMAL) {
          initDecimalRangeCheck(paramData, otherData);
        } else {
          return false;
        }

        return rangeCheck.checkParameterValue(
            checkedParameter, paramData, runService, activeRunService);
      } else { // no need to check the spread if the other parameter does not yet have a value
        return true;
      }
    } else { // nothing to check!
      return true;
    }
  }
示例#3
0
 protected Object[] getDescriptionArgs(
     InstrumentParameter checkedParameter, ActiveInstrumentRunService activeRunService) {
   InstrumentParameter otherParameter =
       activeRunService.getInstrumentType().getInstrumentParameter(parameterCode);
   if (percent != null && offset == null) {
     return new Object[] {checkedParameter.getLabel(), otherParameter.getLabel(), percent};
   } else if (percent == null && offset != null) {
     return new Object[] {
       checkedParameter.getLabel(),
       otherParameter.getLabel(),
       offset,
       checkedParameter.getMeasurementUnit()
     };
   } else {
     return new Object[] {
       checkedParameter.getLabel(),
       otherParameter.getLabel(),
       percent,
       offset,
       checkedParameter.getMeasurementUnit()
     };
   }
 }
示例#4
0
 protected Object[] getDescriptionArgs(
     InstrumentParameter checkedParameter, ActiveInstrumentRunService activeRunService) {
   InstrumentParameter otherParameter =
       activeRunService.getInstrumentType().getInstrumentParameter(parameterCode);
   return new Object[] {checkedParameter.getLabel(), otherParameter.getLabel()};
 }