Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1023140 // Estimate when hard disk will be full (hard disk doom estimator)

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 6315K of libraries. Click here for Pure Java version (4713L/24K).

!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);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023140
Snippet name: Estimate when hard disk will be full (hard disk doom estimator)
Eternal ID of this version: #1023140/29
Text MD5: ff7e7e1d0766f07b53bd9de18197f776
Transpilation MD5: ecd54f2122bb81a44b78037039c1c431
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-19 23:07:00
Source code size: 1311 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 259 / 677
Version history: 28 change(s)
Referenced in: [show references]