!7 cmodule EstimateDiskDoom > DynPrintLogAndEnabled { switchable long timeHorizon = daysToMS(3); // don't report of longer than that away transient new DoomEstimator estimator; transient S status; start { estimator.minValue = 3.0; // 3 percent free space setModuleName("Calculating data (please wait one minute)..."); doEveryAndNow(60.0, r measure); } void measure enter { double value = 100-diskSpacePercentage_oshi(); printWithTime("Free space: " + formatDouble(value, 3) + " %"); if (!estimator.consumeValue(value)) ret; long ms = or0(estimator.doomDate)-sysNow(); if (estimator.doomDate == null || ms >= timeHorizon) ret with setStatus("Hard disk is doom-free!"); if (ms == 0) ret with setStatus("HARD DISK FULL!!!!"); double days = toDays(ms), hours = toHours(ms); S doomText = days >= 2 ? iround(days) + " days from now" : hours >= 2 ? iround(hours) + " hours from now" : n2(iround(toMinutes(ms)), "minute") + "from now"; // formatDouble(100-estimator.minValue, 0) setStatus("DOOM IN " + doomText + " (hard disk " + formatDouble(100-estimator.value1, 1) + "% full)"); } void setStatus(S s) { if (setField(status := s)) print(s); setModuleName(s); } }