<commit_before>module("luci.lucid.linkmeter.peaks", package.seeall)

local HMMODE_UNPLUG  = 1
local HMMODE_STARTUP = 2
local HMMODE_NORMAL  = 3
local HMMODE_LID     = 4
local HMMODE_RECOVER = 5

-- Last known setpoint, used to detect setpoint change
local hmSetPoint
-- Last n pit temperature measurements
local pitLog
-- Peaks state (published)
local peaks

local function resetUpdateCount()
  peaks.updatecnt = {}
  for i = HMMODE_UNPLUG, HMMODE_RECOVER do
    peaks.updatecnt[i] = 0
  end
end

local function initState()
  peaks = {
    C = { trend = 0 },
    H = { trend = 1 },
    L = { trend = -1 },

    -- Current detected mode, one of HMMODE_xxx
    mode = nil,

    -- Histogram of PID output percentage (NORMAL mode only) [1-26] = 0%-100%
    outhist = nil,

    -- Number of updates seen in each mode
    updatecnt = nil
  }
  resetUpdateCount()

  hmSetPoint = nil
  pitLog = {}
end

local function log(...)
  nixio.syslog("warning", ...)
  --print(...)
end

local function hmModeChange(newMode)
  peaks.mode = newMode
  log("newMode=" .. peaks.mode)
end

local function updateHmMode(vals)<commit_msg>[lm] Stop the newMode log spam from the peaks plugin<commit_after>module("luci.lucid.linkmeter.peaks", package.seeall)

local HMMODE_UNPLUG  = 1
local HMMODE_STARTUP = 2
local HMMODE_NORMAL  = 3
local HMMODE_LID     = 4
local HMMODE_RECOVER = 5

-- Last known setpoint, used to detect setpoint change
local hmSetPoint
-- Last n pit temperature measurements
local pitLog
-- Peaks state (published)
local peaks

local function resetUpdateCount()
  peaks.updatecnt = {}
  for i = HMMODE_UNPLUG, HMMODE_RECOVER do
    peaks.updatecnt[i] = 0
  end
end

local function initState()
  peaks = {
    C = { trend = 0 },
    H = { trend = 1 },
    L = { trend = -1 },

    -- Current detected mode, one of HMMODE_xxx
    mode = nil,

    -- Histogram of PID output percentage (NORMAL mode only) [1-26] = 0%-100%
    outhist = nil,

    -- Number of updates seen in each mode
    updatecnt = nil
  }
  resetUpdateCount()

  hmSetPoint = nil
  pitLog = {}
end

local function log(...)
  nixio.syslog("warning", ...)
  --print(...)
end

local function hmModeChange(newMode)
  peaks.mode = newMode
  --log("newMode=" .. peaks.mode)
end

local function updateHmMode(vals)
{'fraction_non_alphanumeric': 0.10841780520052886, 'fraction_numerical': 0.014103129131776113, 'mean_word_length': 3.068100358422939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016941', 'n_tokens_mistral': 819, 'n_tokens_neox': 763, 'n_words': 240}