Esempio n. 1
0
  public void update(final VType value) {
    display_info = Optional.ofNullable(ValueUtil.displayOf(value));
    if (display_info.isPresent()) value_dbl = ValueUtil.numericValueOf(value).doubleValue();

    if (value instanceof VNumber)
      value_str = Double.toString(((VNumber) value).getValue().doubleValue());
    else if (value instanceof VEnum) {
      final VEnum ev = (VEnum) value;
      if (ev.getIndex() >= 0 && ev.getIndex() < ev.getLabels().size())
        value_str = ev.getLabels().get(ev.getIndex());
      else value_str = Integer.toString(ev.getIndex());
    } else if (value instanceof VString) value_str = ((VString) value).getValue();
    else value_str = Objects.toString(value);

    final Time vtime = ValueUtil.timeOf(value);
    if (vtime == null) return;

    final Timestamp stamp = vtime.getTimestamp();
    final Instant new_time = Instant.ofEpochSecond(stamp.getSec(), stamp.getNanoSec());
    if (time != null) {
      final Duration duration = Duration.between(time, new_time);
      final double period = duration.getSeconds() + duration.getNano() * 1e-9;
      value_period.add(period);
    } else value_period.reset();
    time = new_time;
  }
Esempio n. 2
0
 /**
  * Default toString implementation for VString.
  *
  * @param vString the object
  * @return the string representation
  */
 public static String toString(VString vString) {
   StringBuilder builder = new StringBuilder();
   Class type = ValueUtil.typeOf(vString);
   builder.append(type.getSimpleName()).append("[").append(vString.getValue());
   appendAlarm(builder, vString);
   appendTime(builder, vString);
   builder.append(']');
   return builder.toString();
 }
Esempio n. 3
0
 /**
  * Default toString implementation for VNumber.
  *
  * @param vNumber the object
  * @return the string representation
  */
 public static String toString(VNumber vNumber) {
   StringBuilder builder = new StringBuilder();
   Class type = ValueUtil.typeOf(vNumber);
   builder.append(type.getSimpleName()).append('[').append(vNumber.getValue());
   appendAlarm(builder, vNumber);
   appendTime(builder, vNumber);
   builder.append(']');
   return builder.toString();
 }
Esempio n. 4
0
 /**
  * Default toString implementation for VEnumArray.
  *
  * @param vEnumArray the object
  * @return the string representation
  */
 public static String toString(VEnumArray vEnumArray) {
   StringBuilder builder = new StringBuilder();
   Class type = ValueUtil.typeOf(vEnumArray);
   builder.append(type.getSimpleName()).append("[");
   builder.append(format.format(vEnumArray));
   builder.append(", size ").append(vEnumArray.getData().size());
   appendAlarm(builder, vEnumArray);
   appendTime(builder, vEnumArray);
   builder.append(']');
   return builder.toString();
 }
Esempio n. 5
0
 /**
  * Default toString implementation for VEnum.
  *
  * @param vEnum the object
  * @return the string representation
  */
 public static String toString(VEnum vEnum) {
   StringBuilder builder = new StringBuilder();
   Class type = ValueUtil.typeOf(vEnum);
   builder
       .append(type.getSimpleName())
       .append("[")
       .append(vEnum.getValue())
       .append("(")
       .append(vEnum.getIndex())
       .append(")");
   appendAlarm(builder, vEnum);
   appendTime(builder, vEnum);
   builder.append(']');
   return builder.toString();
 }
Esempio n. 6
0
  @Override
  public Graph2DResult readValue() {
    VType vType = tableData.readValue();
    xColumnName.readNext();
    yColumnName.readNext();
    tooltipColumnName.readNext();

    // Table and columns must be available
    if (vType == null || xColumnName.isMissing() || yColumnName.isMissing()) {
      return null;
    }

    // Prepare new dataset
    Point2DDataset dataset;
    if (vType instanceof VNumberArray) {
      dataset = Point2DDatasets.lineData(((VNumberArray) vType).getData());
    } else {
      dataset =
          DatasetConversions.point2DDatasetFromVTable(
              (VTable) vType, xColumnName.getValue(), yColumnName.getValue());
    }

    // Process all renderer updates
    List<LineGraph2DRendererUpdate> updates = rendererUpdateQueue.readValue();
    for (LineGraph2DRendererUpdate rendererUpdate : updates) {
      renderer.update(rendererUpdate);
    }

    // If no size is set, don't calculate anything
    if (renderer.getImageHeight() == 0 && renderer.getImageWidth() == 0) return null;

    BufferedImage image =
        new BufferedImage(
            renderer.getImageWidth(), renderer.getImageHeight(), BufferedImage.TYPE_3BYTE_BGR);
    renderer.draw(image.createGraphics(), dataset);

    previousImage = ValueUtil.toVImage(image);
    return new Graph2DResult(
        vType,
        previousImage,
        new GraphDataRange(
            renderer.getXPlotRange(), dataset.getXStatistics(), renderer.getXAggregatedRange()),
        new GraphDataRange(
            renderer.getYPlotRange(), dataset.getYStatistics(), renderer.getYAggregatedRange()),
        renderer.getFocusValueIndex());
  }
Esempio n. 7
0
 @Override
 public List<ArrayDimensionDisplay> getDimensionDisplay() {
   return ValueUtil.defaultArrayDisplay(this);
 }