const stepRateHistory = [];
// Setup time dependant model to trick simulator into running
flux.on("setup", (event) => {
});
flux.on("afterStep", (event) => {
const stepsPerSecond = 1000 / event.time_since_last_step;
stepRateHistory.push(stepsPerSecond);
if (stepRateHistory.length > 60) {
stepRateHistory.shift();
}
const avgStepRate = average(stepRateHistory);
const avgStepsPerSecondOutput = flux.createOutputNode("StepFrequency");
avgStepsPerSecondOutput.name = "Step frequency";
avgStepsPerSecondOutput.value = Math.round(avgStepRate);
avgStepsPerSecondOutput.unit = "Hz";
avgStepsPerSecondOutput.displayInline = true;
const timePerStepOutput = flux.createOutputNode("timePerStepOutput");
timePerStepOutput.name = "Time per Step";
timePerStepOutput.value = Math.round(event.time_since_last_step * 1000).toString();
timePerStepOutput.unit = "ns";
timePerStepOutput.displayInline = true;
const realtimeTimeRatioOutput = flux.createOutputNode("realtimeTimeRatioOutput");
realtimeTimeRatioOutput.name = "Real World Time Ratio";