浏览代码

Se añadió rxPower de una ONU en la OLT(PonPort)

Maxi Schvindt 7 年之前
父节点
当前提交
82700d9640

+ 2 - 1
src/StatsBundle/Admin/OnuAdmin.php

@@ -77,8 +77,9 @@ class OnuAdmin extends BaseAdmin
             ->add('temperature', 'string', array('template' => 'StatsBundle:Onu:field_temperature.html.twig'))
             ->add('inOctets',null, array('template' => 'StatsBundle:Onu:field_octets.html.twig'))
             ->add('outOctets',null, array('template' => 'StatsBundle:Onu:field_octets.html.twig'))
+            ->add('rxPowerOlt', 'string', array('template' => 'StatsBundle:Onu:field_rx_in_olt.html.twig'))
             ->add('uptime', 'string', array('template' => 'StatsBundle:Onu:field_uptime.html.twig'))
-            ->add('updated')
+            /* ->add('updated') */
         ;
     }
 

+ 24 - 2
src/StatsBundle/Command/StatsOnuCommand.php

@@ -50,6 +50,7 @@ class StatsOnuCommand extends BaseCommand
         $data = $stats = array();
 
         $bandwidth = $this->getBandwidth($oltServerId, $oltDeviceId);
+        $oltRx = $this->getPortRx($oltServerId, $oltDeviceId);
 
         foreach($metrics as $m => $metric) {
             $key_onu_stats = "{$metric}d_{$oltDeviceId}_s_{$oltServerId}";
@@ -65,6 +66,7 @@ class StatsOnuCommand extends BaseCommand
             $lowSn = strtolower($sn);
             $row = array();
             $row['deviceServer'] = $deviceServerId;
+            $ponPort = $onu['ponport'];
             
             $lat = $lng = "NULL";
             if(isset($devices[$lowSn])) {
@@ -80,7 +82,7 @@ class StatsOnuCommand extends BaseCommand
             $row['mac'] = "NULL";
             $row['serialNumber'] = "NULL";
             $row['ponSerialNumber'] = "'".strtolower($sn)."'";
-            $row['ponPort'] = "'".$onu['ponport']."'";
+            $row['ponPort'] = "'".$ponPort."'";
 
             foreach($metrics as $m => $metric) {
                 if(isset($stats[$metric][$sn])) {
@@ -106,6 +108,8 @@ class StatsOnuCommand extends BaseCommand
                 $row['outOctets'] = "NULL";
             }
 
+            (isset($oltRx[$ponPort]))? $row['rxPowerOlt'] = $oltRx[$ponPort] : $row['rxPowerOlt'] = "NULL";
+
             $data[] = "(".implode(",",$row).")".PHP_EOL;
         }
 
@@ -116,7 +120,7 @@ class StatsOnuCommand extends BaseCommand
             $conn->close();
             
             $conn = $doctrine->getConnection();
-            $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`,`index`,`in_octets`,`out_octets`) VALUES ".  implode(",", $data).";";
+            $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`,`lat`,`lng`,`index`,`in_octets`,`out_octets`,`rx_power_olt`) VALUES ".  implode(",", $data).";";
             $conn->query($sql);
             $conn->close();
         } else {
@@ -163,4 +167,22 @@ class StatsOnuCommand extends BaseCommand
         return $bandwidth;
             
     }
+
+    private function getPortRx($server, $olt) {
+        $key_pon_stats = "olt_stats_pons_d_{$olt}_s_{$server}";
+        
+        $ponsCached = $this->getData($key_pon_stats, true);
+
+        $rx = array();
+        foreach ($ponsCached as $index => $data) {
+            if($data['rxPower']) {
+                foreach($data['rxPower'] as $i => $value) {
+                    $ponPort = $data['ponPort']."/".$i;
+                    $rx[$ponPort] = $value;
+                }
+            }
+        }
+
+        return $rx;
+    }
 }

+ 31 - 0
src/StatsBundle/Entity/Onu.php

@@ -146,6 +146,11 @@ class Onu implements TenancyIdTraitInterface
      */
     public $outOctets;
 
+    /**
+     * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
+     */
+    public $rxPowerOlt;
+
 
     /**
      * @return int
@@ -640,4 +645,30 @@ class Onu implements TenancyIdTraitInterface
         return (float) $this->outOctets;
     }
 
+    /**
+     * Set rxPowerOlt
+     *
+     * @param decimal $rxPowerOlt
+     *
+     * @return ONU
+     */
+    public function setRxPowerOlt($rxPowerOlt)
+    {
+        $this->rxPowerOlt = $rxPowerOlt;
+
+        return $this;
+    }
+
+    /**
+     * Get rxPowerOlt
+     *
+     * @return decimal
+     */
+    public function getRxPowerOlt()
+    {
+        if(is_null($this->rxPowerOlt)) return null;
+
+        return  (float) $this->rxPowerOlt;
+    }
+
 }

+ 4 - 0
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -47,6 +47,7 @@ filter:
     label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
+    label_rx_power_olt: RX Power Port
 
 form:
     label_name: Nombre
@@ -77,6 +78,7 @@ form:
     label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
+    label_rx_power_olt: RX Power Port
 
 show:
     label_name: Nombre
@@ -120,6 +122,7 @@ show:
     label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflection Ups
+    label_rx_power_olt: RX Power Port
 
 list:
     label_name: Nombre
@@ -167,6 +170,7 @@ list:
     label_rx_power_cmts: RX Power Ups
     label_signal_cmts: SNR Ups
     label_microreflection_cmts: Microreflexiones Ups
+    label_rx_power_olt: RX Power Port
     
 help:
     url: Url a consultar dispositivos

+ 7 - 0
src/StatsBundle/Resources/views/Onu/field_rx_in_olt.html.twig

@@ -0,0 +1,7 @@
+{% extends 'StatsBundle:Templates:base_field.html.twig' %}
+
+{% block field %}
+    
+    {% include 'StatsBundle:Templates:onu_field_rx.html.twig' with {'value': object.getRxPowerOlt()} only %}
+    
+{% endblock %}