use of io.engineblock.activityimpl.input.ProgressCapable in project engineblock by engineblock.
the class ActivityExecutor method getProgress.
@Override
public synchronized double getProgress() {
ArrayList<Input> inputs = motors.stream().map(Motor::getInput).distinct().collect(Collectors.toCollection(ArrayList::new));
double startCycle = getActivityDef().getStartCycle();
double endCycle = getActivityDef().getEndCycle();
double totalCycles = endCycle - startCycle;
double total = 0.0D;
double progress = 0.0D;
for (Input input : inputs) {
if (input instanceof ProgressCapable) {
ProgressCapable progressInput = (ProgressCapable) input;
total += progressInput.getTotal();
progress += progressInput.getProgress();
} else {
logger.warn("input does not support activity progress: " + input);
return Double.NaN;
}
}
return progress / total;
}
Aggregations