<commit_before>local BasePowerD = {
	fl_min = 0,      -- min frontlight intensity
	fl_max = 10,     -- max frontlight intensity
	flIntensity = nil,   -- frontlight intensity
	battCapacity = nil,  -- battery capacity
	model = nil   -- device model
}

function BasePowerD:new(o)
	local o = o or {}
	setmetatable(o, self)
	self.__index = self
	if o.init then o:init() end
	return o
end

function BasePowerD:init() end
function BasePowerD:toggleFrontlight() end
function BasePowerD:setIntensityHW() end
function BasePowerD:getCapacityHW() end
function BasePowerD:isChargingHW() end
function BasePowerD:suspendHW() end
function BasePowerD:wakeUpHW() end

function BasePowerD:read_int_file(file)
	local f =  io.open(file, "r")
	local sysint = tonumber(f:read("*all"):match("%d+"))
	f:close()
	return sysint
end

function BasePowerD:setIntensity(intensity)
	intensity = intensity < self.fl_min and self.fl_min or intensity
	intensity = intensity > self.fl_max and self.fl_max or intensity
	self.flIntensity = intensity
	self:setIntensityHW()
end

function BasePowerD:getCapacity()
	return self:getCapacityHW()
end

function BasePowerD:isCharging()
	return self:isChargingHW()
end

function BasePowerD:suspend()<commit_msg>cache battery level in BasePowerD Since we need to pull it frequently but usually it doesn't change that often.<commit_after>local BasePowerD = {
	fl_min = 0,      -- min frontlight intensity
	fl_max = 10,     -- max frontlight intensity
	flIntensity = nil,   -- frontlight intensity
	battCapacity = nil,  -- battery capacity
	model = nil,     -- device model
	
	capacity_pulled_count = 0,
	capacity_cached_count = 10,
}

function BasePowerD:new(o)
	local o = o or {}
	setmetatable(o, self)
	self.__index = self
	if o.init then o:init() end
	return o
end

function BasePowerD:init() end
function BasePowerD:toggleFrontlight() end
function BasePowerD:setIntensityHW() end
function BasePowerD:getCapacityHW() end
function BasePowerD:isChargingHW() end
function BasePowerD:suspendHW() end
function BasePowerD:wakeUpHW() end

function BasePowerD:read_int_file(file)
	local f =  io.open(file, "r")
	local sysint = tonumber(f:read("*all"):match("%d+"))
	f:close()
	return sysint
end

function BasePowerD:setIntensity(intensity)
	intensity = intensity < self.fl_min and self.fl_min or intensity
	intensity = intensity > self.fl_max and self.fl_max or intensity
	self.flIntensity = intensity
	self:setIntensityHW()
end

function BasePowerD:getCapacity()
	if capacity_pulled_count == capacity_cached_count then
		capacity_pulled_count = 0
		return self:getCapacityHW()
	else
		capacity_pulled_count = capacity_pulled_count + 1
		return self.battCapacity or self:getCapacityHW()
	end
end

function BasePowerD:isCharging()
	return self:isChargingHW()
end

function BasePowerD:suspend()
{'fraction_non_alphanumeric': 0.09250627465041233, 'fraction_numerical': 0.003944065973467192, 'mean_word_length': 5.3122171945701355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3290013', 'n_tokens_mistral': 932, 'n_tokens_neox': 915, 'n_words': 252}