@Test public void replayValues() { Instant start = Instant.now(); Replay replay = (Replay) NameParser.createFunction("replay(\"./src/test/resources/org/diirt/datasource/replay/parse1.xml\")"); List<VDouble> values = replay.createValues(TimeInterval.after(ofMillis(1000), start)); assertThat(values.size(), equalTo(4)); VDouble value = values.get(0); assertThat(value.getValue(), equalTo(0.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.NONE)); assertThat(value.getAlarmName(), equalTo("NONE")); assertThat(value.getTimeUserTag(), equalTo(0)); assertThat(value.getLowerCtrlLimit(), equalTo(-10.0)); assertThat(value.getLowerDisplayLimit(), equalTo(-10.0)); assertThat(value.getLowerAlarmLimit(), equalTo(-9.0)); assertThat(value.getLowerWarningLimit(), equalTo(-8.0)); assertThat(value.getUpperWarningLimit(), equalTo(8.0)); assertThat(value.getUpperAlarmLimit(), equalTo(9.0)); assertThat(value.getUpperCtrlLimit(), equalTo(10.0)); assertThat(value.getUpperDisplayLimit(), equalTo(10.0)); value = values.get(1); assertThat(value.getValue(), equalTo(1.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0).plus(ofMillis(100)))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.INVALID)); assertThat(value.getAlarmName(), equalTo("RECORD")); assertThat(value.getTimeUserTag(), equalTo(0)); value = values.get(2); assertThat(value.getValue(), equalTo(2.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0).plus(ofMillis(200)))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.NONE)); assertThat(value.getAlarmName(), equalTo("NONE")); assertThat(value.getTimeUserTag(), equalTo(0)); value = values.get(3); assertThat(value.getValue(), equalTo(3.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0).plus(ofMillis(500)))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.NONE)); assertThat(value.getAlarmName(), equalTo("NONE")); assertThat(value.getTimeUserTag(), equalTo(0)); }
@Override List<VDouble> createValues(TimeInterval interval) { offset = Duration.between(interval.getStart(), ((VDouble) values.getValues().get(0)).getTimestamp()).abs(); TimeInterval originalInterval = interval.minus(offset); List<VDouble> newValues = new ArrayList<VDouble>(); for (ReplayValue value : values.getValues()) { if (originalInterval.contains(value.getTimestamp())) { ReplayValue copy = value.copy(); if (values.isAdjustTime()) { copy.adjustTime(offset); } newValues.add((VDouble) copy); } } return newValues; }
Replay extends Simulation<VDouble> { @Override List<VDouble> createValues(TimeInterval interval) { offset = Duration.between(interval.getStart(), ((VDouble) values.getValues().get(0)).getTimestamp()).abs(); TimeInterval originalInterval = interval.minus(offset); List<VDouble> newValues = new ArrayList<VDouble>(); for (ReplayValue value : values.getValues()) { if (originalInterval.contains(value.getTimestamp())) { ReplayValue copy = value.copy(); if (values.isAdjustTime()) { copy.adjustTime(offset); } newValues.add((VDouble) copy); } } return newValues; } }
Replay extends Simulation<VDouble> { @Override List<VDouble> createValues(TimeInterval interval) { offset = Duration.between(interval.getStart(), ((VDouble) values.getValues().get(0)).getTimestamp()).abs(); TimeInterval originalInterval = interval.minus(offset); List<VDouble> newValues = new ArrayList<VDouble>(); for (ReplayValue value : values.getValues()) { if (originalInterval.contains(value.getTimestamp())) { ReplayValue copy = value.copy(); if (values.isAdjustTime()) { copy.adjustTime(offset); } newValues.add((VDouble) copy); } } return newValues; } Replay(String uri); }
Replay extends Simulation<VDouble> { @Override List<VDouble> createValues(TimeInterval interval) { offset = Duration.between(interval.getStart(), ((VDouble) values.getValues().get(0)).getTimestamp()).abs(); TimeInterval originalInterval = interval.minus(offset); List<VDouble> newValues = new ArrayList<VDouble>(); for (ReplayValue value : values.getValues()) { if (originalInterval.contains(value.getTimestamp())) { ReplayValue copy = value.copy(); if (values.isAdjustTime()) { copy.adjustTime(offset); } newValues.add((VDouble) copy); } } return newValues; } Replay(String uri);  }
Replay extends Simulation<VDouble> { @Override List<VDouble> createValues(TimeInterval interval) { offset = Duration.between(interval.getStart(), ((VDouble) values.getValues().get(0)).getTimestamp()).abs(); TimeInterval originalInterval = interval.minus(offset); List<VDouble> newValues = new ArrayList<VDouble>(); for (ReplayValue value : values.getValues()) { if (originalInterval.contains(value.getTimestamp())) { ReplayValue copy = value.copy(); if (values.isAdjustTime()) { copy.adjustTime(offset); } newValues.add((VDouble) copy); } } return newValues; } Replay(String uri);   }