Re-implement Printer as a class based module (#12605)

* Re-implement Printer as a class based module

* Rename toner table

* wip

* wip

* Rename to printersupplies

* Fixes

* Rename

* wip

* wip
This commit is contained in:
Jellyfrog
2021-03-27 16:09:14 +01:00
committed by GitHub
parent c8c8bc3a81
commit e00eba327d
59 changed files with 1332 additions and 1124 deletions

View File

@@ -1678,52 +1678,6 @@ function q_bridge_bits2indices($hex_data)
return $indices;
}
/**
* @param array $device
* @param int|string $raw_value The value returned from snmp
* @param int $capacity the normalized capacity
* @return int the toner level as a percentage
*/
function get_toner_levels($device, $raw_value, $capacity)
{
// -3 means some toner is left
if ($raw_value == '-3') {
return 50;
}
// -2 means unknown
if ($raw_value == '-2') {
return false;
}
// -1 mean no restrictions
if ($raw_value == '-1') {
return 0; // FIXME: is 0 what we should return?
}
// Non-standard snmp values
if ($device['os'] == 'ricoh' || $device['os'] == 'nrg' || $device['os'] == 'lanier') {
if ($raw_value == '-100') {
return 0;
}
} elseif ($device['os'] == 'brother') {
if (! Str::contains($device['hardware'], 'MFC-L8850')) {
switch ($raw_value) {
case '0':
return 100;
case '1':
return 5;
case '2':
return 0;
case '3':
return 1;
}
}
}
return round($raw_value / $capacity * 100);
}
/**
* Intialize global stat arrays
*/