灵符lingfu

LingSys

↓ 0 downloads

Your machine's memory, GPU, motherboard and network, drawn and played in the Ling design system: LingSys, a small build for USB liquid-cooler displays, LingNet for IPv4/IPv6, DNS and packets, and a LingOS edition. 64-bit and 32-bit Windows builds included.

Keywords system-monitor, visualization, network, ipv6, gpu, lcd, lingos, ling
lingfu install LingSys
LicenseMIT
AuthorsLing Lin <taellinglin@gmail.com>
READMECode / FilesVersionsDependency GraphDependentsSecurityBuildsSettings

Code / Files (48)

src/85_drive.ling
# ───────────────────────────── drive ─────────────────────────────────────────
# What each section feeds the shared machinery (look, pulses, sound), from its own readings:
#   used   how full it is, 0..1: saturation and the root pitch
#   tg     four activity targets, 0..1: [in, out, third, fourth] -> rotation, hue drift, pulse rates
#   en     seven channel energies, 0..1: how lit each ring / lane / hue is
#   rw/ww  how pulses of each kind are spread over the seven channels
#   alc    the channel that allocations (the fourth activity) belong to
#   pwr/pww  how pulses are spread over the section's bodies (processes, cores, connections)
bind DR_USED = 0
bind DR_TG = 1
bind DR_EN = 2
bind DR_RW = 3
bind DR_WW = 4
bind DR_ALC = 5
bind DR_PWR = 6
bind DR_PWW = 7
bind DR_STAT = 8

fn add_all(l, v) {
    bind out = []
    bind i = 0
    while i < len(l) {
        bind out = list_push(out, l[i] + v)
        bind i = i + 1
    }
    return out
}

fn ones(n) {
    bind out = []
    bind i = 0
    while i < max(n, 1) {
        bind out = list_push(out, 1.0)
        bind i = i + 1
    }
    return out
}

# mm = [cats, total, rd, wr, fl, used, al, names, ws, ior, iow]
fn drive(sec, mm, gp, bp, np, A, gsel) {
    bind cats = mm[0]
    bind total = mm[1]
    bind bv = bp[BP_BV]
    bind nv = np[NP_NV]
    bind netA = lg(nv[NV_RX] + nv[NV_TX], 9.0)
    bind memAct = (lg(mm[2], 3.6) + lg(mm[3], 3.6)) / 2.0
    # GPU readings of the selected card, and the busiest card for the overview
    bind gv = gp[GP_VEC][gsel]
    bind ge = gp[GP_ENG][gsel]
    bind gmax = 0.0
    bind g = 0
    while g < gp[GP_N] {
        bind gmax = max(gmax, gp[GP_VEC][g][GV_UTIL])
        bind g = g + 1
    }
    bind vfrac = clamp(gv[GV_VUSED] / max(gv[GV_VTOTAL], 1.0), 0.0, 1.0)
    bind pfrac = clamp(gv[GV_POWER] / max(gv[GV_PLIM], 1.0), 0.0, 1.0)
    bind heat = clamp((bv[BV_TEMP] - 20.0) / 60.0, 0.0, 1.0)

    if sec == 1 {
        bind en = [clamp(0.25 * A[2] + 0.2 * A[0], 0.0, 1.0), A[0], clamp(0.6 * A[2] + 0.5 * A[1], 0.0, 1.0), A[1],
                   clamp(0.7 * A[0] + 0.2 * A[1], 0.0, 1.0), clamp(0.5 * A[1] + 0.3 * A[0], 0.0, 1.0), A[3]]
        bind rw = []
        bind ww = []
        bind q = 0
        while q < 7 {
            bind sh = 0.12 + sqrt(cats[q] / total)
            bind rw = list_push(rw, READ_W[q] * sh)
            bind ww = list_push(ww, WRITE_W[q] * sh)
            bind q = q + 1
        }
        bind ws = mm[8]
        bind pr = []
        bind pw = []
        bind q = 0
        while q < len(ws) {
            bind pr = list_push(pr, 0.2 + mm[9][q] + sqrt(ws[q]) * 0.03)
            bind pw = list_push(pw, 0.2 + mm[10][q] + sqrt(ws[q]) * 0.03)
            bind q = q + 1
        }
        bind stat = "RD " + fmt_rate(mm[2]) + "/S   WR " + fmt_rate(mm[3]) + "/S   FLT " + fmt_rate(mm[4]) + "/S   TOTAL " + fmt_mb(total)
        return [mm[5], [lg(mm[2], 3.6), lg(mm[3], 3.6), lg(mm[4], 5.0), lg(mm[6], 5.0)], en, rw, ww, 6, pr, pw, stat]
    }
    if sec == 2 {
        bind e0 = ge[0] / 100.0
        bind e1 = ge[1] / 100.0
        bind e2 = ge[2] / 100.0
        bind e3 = ge[3] / 100.0
        bind e4 = ge[4] / 100.0
        bind en = [e0, e1, e2, e3, e4, vfrac, pfrac]
        bind pr = gp[GP_PROC][gsel]
        bind pn = pr[0]
        bind pw = []
        bind q = 0
        while q < len(pn) {
            bind pw = list_push(pw, 0.1 + pr[3][q] * 0.05 + sqrt(pr[1][q]) * 0.02)
            bind q = q + 1
        }
        if len(pw) == 0 { bind pw = [1.0] }
        bind stat = "GPU" + num_str(gsel) + " " + pct(gv[GV_UTIL]) + "%   VRAM " + fmt_mb(gv[GV_VUSED]) + " OF " + fmt_mb(gv[GV_VTOTAL]) + "   " + pct(gv[GV_TEMP]) + "C   " + pct(gv[GV_POWER]) + "W   CORE " + pct(gv[GV_CLK]) + " MHZ"
        return [vfrac, [e0, clamp(e1 + e2, 0.0, 1.0), pfrac, clamp((e3 + e4) / 0.6, 0.0, 1.0)], en,
                [e0 + 0.05, 0.1, 0.0, e3, 0.0, 0.15, 0.1], [0.1 * e0 + 0.02, e1 + 0.05, e2 + 0.05, 0.0, e4, 0.15, 0.1], 5, pw, pw, stat]
    }
    if sec == 3 {
        bind u = bv[BV_UTIL] / 100.0
        bind en = [u, memAct, gmax / 100.0, 0.6 * lg(bv[BV_INTR], 6.0) + 0.4 * lg(bv[BV_DPC], 5.0), lg(bv[BV_DRD] + bv[BV_DWR], 9.0), netA, heat]
        bind cu = bp[BP_CU]
        bind pw = []
        bind q = 0
        while q < len(cu) {
            bind pw = list_push(pw, 0.1 + cu[q] / 25.0)
            bind q = q + 1
        }
        bind stat = "CPU " + pct(bv[BV_UTIL]) + "%  " + num_str(round(bv[BV_MHZ] / 100.0) / 10.0) + "GHZ   ACPI " + num_str(round(bv[BV_TEMP] * 10.0) / 10.0) + "C   IRQ " + fmt_rate(bv[BV_INTR]) + "/S   DISK R " + fmt_bytes(bv[BV_DRD]) + " W " + fmt_bytes(bv[BV_DWR])
        return [u, [u, lg(bv[BV_DWR], 9.0), lg(bv[BV_INTR], 6.0), lg(bv[BV_DPC], 5.0)], en, add_all(en, 0.08), add_all(en, 0.08), 3, pw, pw, stat]
    }
    if sec == 4 {
        bind en = [lg(nv[NV_RX], 9.0), lg(nv[NV_TX], 9.0), lg(nv[NV_PRX], 6.0), lg(nv[NV_PTX], 6.0), lg(nv[NV_EST], 3.5), lg(nv[NV_UDP], 4.0), lg(nv[NV_RETX], 3.0)]
        bind rs = "---"
        if nv[NV_RTT] > 0.0 { bind rs = num_str(round(nv[NV_RTT])) + "MS" }
        bind stat = "IN " + fmt_bytes(nv[NV_RX]) + "/S   OUT " + fmt_bytes(nv[NV_TX]) + "/S   TCP " + fmt_rate(nv[NV_EST]) + "   UDP " + fmt_rate(nv[NV_UDP]) + "/S   GATEWAY " + rs
        return [netA, [lg(nv[NV_RX], 8.0), lg(nv[NV_TX], 8.0), lg(nv[NV_PRX] + nv[NV_PTX], 5.0), lg(nv[NV_UDP], 4.0)], en,
                [en[0] + 0.02, 0.0, en[2] + 0.02, 0.0, 0.4 * en[4], 0.5 * en[5], 0.0], [0.0, en[1] + 0.02, 0.0, en[3] + 0.02, 0.4 * en[4], 0.5 * en[5], en[6]],
                4, ones(len(np[NP_NODE])), ones(len(np[NP_NODE])), stat]
    }
    # MAIN
    bind cpu = bv[BV_UTIL] / 100.0
    bind mu = mm[5]
    bind en = [mu, gmax / 100.0, cpu, netA, vfrac, bv[BV_DBUSY] / 100.0, heat]
    bind stat = "MEM " + pct(mu * 100.0) + "%   GPU " + pct(gmax) + "%   CPU " + pct(bv[BV_UTIL]) + "%   NET " + fmt_bytes(nv[NV_RX] + nv[NV_TX]) + "/S   UP " + fmt_up(bv[BV_UP])
    return [(mu + cpu + gmax / 100.0) / 3.0, [cpu, gmax / 100.0, netA, memAct], en, add_all(en, 0.05), add_all(en, 0.05), 3, [1.0], [1.0], stat]
}

← Back to index