12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace Flowdat\Stats\App\Service\Huawei;
- use Flowdat\Stats\Domain\Huawei;
- class HuaweiOltService
- {
- /**
- * @var Huawei
- */
- private $huawei;
- private $sendData;
- /**
- * HuaweiOltService constructor.
- * @param $sendData
- */
- public function __construct(&$sendData)
- {
- $this->sendData = &$sendData;
- }
- public function configure(Huawei $huawei){
- $this->huawei = $huawei;
- return $this;
- }
- public function setVoltageOrTxPower($data, $subId, $metricName, $metricCodeName){
- if(isset($data[$this->huawei->getIndex()]) && !empty($data[$this->huawei->getIndex()])) {
- $metric = $subId.$metricCodeName;
- $m = "{$metric}{$this->huawei->getPonPort()}";
- $v = $data[$this->huawei->getIndex()] * 0.01;
- $this->sendData[$m] = "{$v}|g";
- $this->huawei->stats[$metricName] = $v;
- }
- return $this;
- }
- public function setTemperatureOrBiasCurrent($data, $subId, $metricName, $metricCodeName){
- if(isset($data[$this->huawei->getIndex()]) && !empty($data[$this->huawei->getIndex()])) {
- $metric = $subId.$metricCodeName;
- $m = "{$metric}{$this->huawei->getPonPort()}";
- $v = $data[$this->huawei->getIndex()];
- $this->sendData[$m] = "{$v}|g";
- $this->huawei->stats[$metricName] = $v;
- }
- return $this;
- }
- public function setRxPower($ponPortOnuId, $ponsCache, $subId, $rx, &$ponStatsCached){
- $indexPon = $ponPortOnuId[0];
- if(isset($ponsCache[$indexPon])) {
- $onuId = $ponPortOnuId[1];
- $ponPort = str_replace ('/','.',$ponsCache[$indexPon]['ponPort']);
- $m = "{$subId}_pon_rx_{$ponPort}.{$onuId}";
- $v = ($rx - 10000) * 0.01;
- if(isset($ponStatsCached[$indexPon]['rxPower'])) {
- $ponStatsCached[$indexPon]['rxPower'][$onuId] = $v;
- }
- $this->sendData[$m] = "{$v}|g";
- }
- }
- }
|