forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Himoinsa gensets status state sensors (librenms#13456)
* Fix missing mib_dir in definition * Added state sensors * snmprec data * json data * delete unused snmprec * License and Author * remove unused json data * Fix style issues * Fix more style issues coz im blind * Fix more style issues coz im blind last * Refactored * Why do we loop? * Fix style issues * Update polling * Refactor to use methods * Fix a pair of style issues * Updated test files * Convert to yaml * Wrong description on Mode * Added another state + fixed some indexes * Dunno what happened * Fix for phpstan level 6 * Fix forstyleci Co-authored-by: Tony Murray <murraytony@gmail.com>
- Loading branch information
1 parent
364fa54
commit 82d008c
Showing
7 changed files
with
765 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
/** | ||
* HimoinsaGensets.php | ||
* | ||
* -Description- | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* @link https://www.librenms.org | ||
* | ||
* @copyright 2021 Daniel Baeza & Tony Murray | ||
* @author TheGreatDoc <doctoruve@gmail.com> & murrant <murraytony@gmail.com> | ||
*/ | ||
|
||
namespace LibreNMS\OS; | ||
|
||
use LibreNMS\OS; | ||
|
||
class HimoinsaGensets extends OS | ||
{ | ||
/* state parsing functions | ||
CEC7 (a.k.a CEA7CC2) bitmap status ( R G B T Mn Au Al) | ||
statusConm.0 | ||
R = Mains commutator closed | ||
G = Gen commutator closed | ||
B = Blocked mode | ||
T = Test mode | ||
Mn = Manual mode | ||
Au = Auto mode | ||
Al = Active commutator alarm | ||
In LibreNMS it equals to 3 state sensors: | ||
Closed commutator: Mains or Genset (what commutator is closed, so where the power comes from) | ||
Genset Mode: Block, Test, Manual, Auto (the 4 modes of the genset) | ||
Alarm: Yes or No (If there is a commutator alarm) | ||
Example: | ||
Value = 66 | ||
Value binary = 1000010 | ||
States equals to: | ||
- Alarm: No active alarm | ||
- Genset Mode: Auto | ||
- Closed commutator: Mains | ||
CEA7 / CEM7 (CEA7 is a combination of CEC7 + CEM7 in a single Central) bitmap status (R G Al Bt B T Mn Au P A) | ||
status.0 | ||
R = Mains commutator closed | ||
G = Gen commutator closed | ||
Al = Active Alarm | ||
Bt = Transfer Pump | ||
B = Blocked mode | ||
T = Test mode | ||
Mn = Manual mode | ||
Au = Auto mode | ||
P = Motor Stopped | ||
A = Motor Running | ||
*/ | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function motorStatus($value): int | ||
{ | ||
return ($value & 1) | ($value & 2); | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function modeStatus($value): int | ||
{ | ||
return ($value & 4) | ($value & 8) | ($value & 16) | ($value & 32); | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function alarmStatus($value): int | ||
{ | ||
return $value & 128; | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function transferPumpStatus($value): int | ||
{ | ||
return $value & 64; | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function commStatus($value): int | ||
{ | ||
return ($value & 512) | ($value & 256); | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function cec7CommStatus($value): int | ||
{ | ||
return ($value & 32) | ($value & 64); | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function cec7CommAlarmStatus($value): int | ||
{ | ||
return $value & 1; | ||
} | ||
|
||
/** | ||
* @param int $value | ||
*/ | ||
public static function cec7ModeStatus($value): int | ||
{ | ||
return ($value & 2) | ($value & 4) | ($value & 8) | ($value & 16); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,9 @@ | |
"string" | ||
] | ||
}, | ||
"user_func": { | ||
"type": "string" | ||
}, | ||
"states": { | ||
"type": "array", | ||
"items": { | ||
|
Oops, something went wrong.