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).

1  
!7
2  
3  
cmodule EstimateDiskDoom > DynPrintLogAndEnabled {
4  
  switchable long timeHorizon = daysToMS(3); // don't report of longer than that away
5  
  transient new DoomEstimator estimator;
6  
  transient S status;
7  
8  
  start {
9  
    estimator.minValue = 3.0; // 3 percent free space
10  
    setModuleName("Calculating data (please wait one minute)...");
11  
    doEveryAndNow(60.0, r measure);
12  
  }
13  
  
14  
  void measure enter {
15  
    double value = 100-diskSpacePercentage_oshi();
16  
    printWithTime("Free space: " + formatDouble(value, 3) + " %");
17  
    if (!estimator.consumeValue(value)) ret;
18  
    long ms = or0(estimator.doomDate)-sysNow();
19  
    if (estimator.doomDate == null || ms >= timeHorizon) ret with setStatus("Hard disk is doom-free!");
20  
    if (ms == 0) ret with setStatus("HARD DISK FULL!!!!");
21  
    double days = toDays(ms), hours = toHours(ms);
22  
    S doomText = days >= 2
23  
        ? iround(days) + " days from now"
24  
      : hours >= 2 ?
25  
        iround(hours) + " hours from now"
26  
      : n2(iround(toMinutes(ms)), "minute") + "from now";
27  
    // formatDouble(100-estimator.minValue, 0)
28  
    setStatus("DOOM IN " + doomText + " (hard disk " +
29  
      formatDouble(100-estimator.value1, 1) + "% full)");
30  
  }
31  
  
32  
  void setStatus(S s) {
33  
    if (setField(status := s)) print(s);
34  
    setModuleName(s);
35  
  }
36  
}

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: 263 / 685
Version history: 28 change(s)
Referenced in: [show references]