HuaweiOltService.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Flowdat\Stats\App\Service\Huawei;
  3. use Flowdat\Stats\Domain\Huawei;
  4. class HuaweiOltService
  5. {
  6. /**
  7. * @var Huawei
  8. */
  9. private $huawei;
  10. private $sendData;
  11. /**
  12. * HuaweiOltService constructor.
  13. * @param $sendData
  14. */
  15. public function __construct(&$sendData)
  16. {
  17. $this->sendData = &$sendData;
  18. }
  19. public function configure(Huawei $huawei){
  20. $this->huawei = $huawei;
  21. return $this;
  22. }
  23. public function setVoltageOrTxPower($data, $subId, $metricName, $metricCodeName){
  24. if(isset($data[$this->huawei->getIndex()]) && !empty($data[$this->huawei->getIndex()])) {
  25. $metric = $subId.$metricCodeName;
  26. $m = "{$metric}{$this->huawei->getPonPort()}";
  27. $v = $data[$this->huawei->getIndex()] * 0.01;
  28. $this->sendData[$m] = "{$v}|g";
  29. $this->huawei->stats[$metricName] = $v;
  30. }
  31. return $this;
  32. }
  33. public function setTemperatureOrBiasCurrent($data, $subId, $metricName, $metricCodeName){
  34. if(isset($data[$this->huawei->getIndex()]) && !empty($data[$this->huawei->getIndex()])) {
  35. $metric = $subId.$metricCodeName;
  36. $m = "{$metric}{$this->huawei->getPonPort()}";
  37. $v = $data[$this->huawei->getIndex()];
  38. $this->sendData[$m] = "{$v}|g";
  39. $this->huawei->stats[$metricName] = $v;
  40. }
  41. return $this;
  42. }
  43. public function setRxPower($ponPortOnuId, $ponsCache, $subId, $rx, &$ponStatsCached){
  44. $indexPon = $ponPortOnuId[0];
  45. if(isset($ponsCache[$indexPon])) {
  46. $onuId = $ponPortOnuId[1];
  47. $ponPort = str_replace ('/','.',$ponsCache[$indexPon]['ponPort']);
  48. $m = "{$subId}_pon_rx_{$ponPort}.{$onuId}";
  49. $v = ($rx - 10000) * 0.01;
  50. if(isset($ponStatsCached[$indexPon]['rxPower'])) {
  51. $ponStatsCached[$indexPon]['rxPower'][$onuId] = $v;
  52. }
  53. $this->sendData[$m] = "{$v}|g";
  54. }
  55. }
  56. }