Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions _alp/Classes/Class.J_AccumulatorMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ public J_DataSetMap getDataSetMap( double startTime_h ) {
return dsm;
}

public J_DataSetMap getDataSetMap( double startTime_h, double dataSetSignalResolution_h ) {
J_DataSetMap dsm = new J_DataSetMap(this.enumClass);
for (var EC : this.enumSet) {
dsm.put(EC, this.get(EC).getDataSet(startTime_h, dataSetSignalResolution_h));
}
return dsm;
}

public String toString() {
if (this.accumulatorArray.length == 0) {
return "{}";
Expand Down
26 changes: 26 additions & 0 deletions _alp/Classes/Class.ZeroAccumulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,32 @@ public DataSet getDataSet(double startTime_h) {
}
}

public DataSet getDataSet(double startTime_h, double dataSetSignalResolution_h) {
if (this.hasTimeSeries) {
if (dataSetSignalResolution_h % this.signalResolution_h == 0) {
int accumulatorEntries = roundToInt(dataSetSignalResolution_h / this.signalResolution_h); // number of entries in accumulator per dataset entry
if (duration_h % dataSetSignalResolution_h == 0) {
int dataSetSize = roundToInt(duration_h / dataSetSignalResolution_h);
DataSet ds = new DataSet(dataSetSize);
for (int i = 0; i < dataSetSize; i++) {
double value = 0;
for (int j = 0; j < accumulatorEntries; j++) {
value += this.timeSeries[accumulatorEntries * i + j];
}
value /= accumulatorEntries;
ds.add(startTime_h + i * dataSetSignalResolution_h, roundToDecimal(value,3) );
}
return ds;
} else {
throw new RuntimeException("Impossible to create DataSet from accumulator: signal resolution does not divide into timeseries");
}
} else {
throw new RuntimeException("Impossible to create DataSet from accumulator with signal resolution that is not a multiple of the accumulator's signal resolution.");
}
} else {
throw new RuntimeException("Impossible to create DataSet from accumulator without timeSeries.");
}
}
public DataSet getDataSet(double startTime_h, double accStartTime_h, double accEndTime_h) {

double dataSetDuration_h = accEndTime_h - accStartTime_h;
Expand Down