Files
librenms-librenms/app/Models/Sensor.php
Ramūnas Lukoševičius 10eb7b2c2a Added support for Motorola and Thomson DOCSIS Cable Modems. (#12386)
* Added tv_signal sensor class (TV signal in dBmV (decibells to millivolt))

* Added OS motorola-cm (Motorolla DOCSIS Cable Modem)

* Added OS thomson-cm (Thomson DOCSIS Cable Modem)
2021-01-03 22:35:32 +01:00

81 lines
2.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Sensor extends DeviceRelatedModel
{
use HasFactory;
public $timestamps = false;
protected $primaryKey = 'sensor_id';
protected static $icons = [
'airflow' => 'angle-double-right',
'ber' => 'sort-amount-desc',
'charge' => 'battery-half',
'chromatic_dispersion' => 'indent',
'cooling' => 'thermometer-full',
'count' => 'hashtag',
'current' => 'bolt fa-flip-horizontal',
'dbm' => 'sun-o',
'delay' => 'clock-o',
'eer' => 'snowflake-o',
'fanspeed' => 'refresh',
'frequency' => 'line-chart',
'humidity' => 'tint',
'load' => 'percent',
'loss' => 'percentage',
'power' => 'power-off',
'power_consumed' => 'plug',
'power_factor' => 'calculator',
'pressure' => 'thermometer-empty',
'quality_factor' => 'arrows',
'runtime' => 'hourglass-half',
'signal' => 'wifi',
'snr' => 'signal',
'state' => 'bullseye',
'temperature' => 'thermometer-three-quarters',
'tv_signal' => 'signal',
'voltage' => 'bolt',
'waterflow' => 'tint',
'percent' => 'percent',
];
// ---- Helper Functions ----
public function classDescr()
{
$nice = collect([
'ber' => 'BER',
'dbm' => 'dBm',
'eer' => 'EER',
'snr' => 'SNR',
]);
return $nice->get($this->sensor_class, ucwords(str_replace('_', ' ', $this->sensor_class)));
}
public function icon()
{
return collect(self::$icons)->get($this->sensor_class, 'delicius');
}
public static function getTypes()
{
return array_keys(self::$icons);
}
// for the legacy menu
public static function getIconMap()
{
return self::$icons;
}
// ---- Define Relationships ----
public function events()
{
return $this->morphMany(Eventlog::class, 'events', 'type', 'reference');
}
}