Преглед на файлове

FD3-209 Optimizo comando para generar shape de puertos. Agrego unos
links, actualizo unos métodos de las entidades ONU y PonPort. Se agrega
link al mapa desde el listado de puertos(para ahorrar el paso de tener
que entrar al perfil del puerto para acceder al mapa)

Maximiliano Schvindt преди 7 години
родител
ревизия
f89fdfdba8

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

@@ -67,7 +67,6 @@ class OnuAdmin extends BaseAdmin
         $listMapper
             ->add('deviceServer')
             ->add('oltDeviceId', 'string', array('template' => 'StatsBundle:Onu:base_list_field_olt.html.twig'))
-            //->add('tenancyId')
             ->add('ponSerialNumber', 'string', array('template' => 'StatsBundle:Onu:show_link.html.twig'))
             ->add('ponPort')
             ->add('status')

+ 0 - 5
src/StatsBundle/Admin/PonPortAdmin.php

@@ -69,14 +69,12 @@ class PonPortAdmin extends BaseAdmin
         $listMapper
             ->add('deviceServer')
             ->add('oltDeviceId', 'string', array('template' => 'StatsBundle:Onu:base_list_field_olt.html.twig'))
-            //->add('tenancyId')
             ->addIdentifier('ponPort')
             ->add('txPower', 'string', array('template' => 'StatsBundle:Onu:base_list_field_tx.html.twig'))
             ->add('arrayRxPower', 'ponport-rx-power', array('template' => 'StatsBundle:PonPort:base_list_field_rx.html.twig'))
             ->add('voltage', 'string', array('template' => 'StatsBundle:Onu:base_list_field_voltage.html.twig'))
             ->add('temperature', 'string', array('template' => 'StatsBundle:Onu:base_list_field_temperature.html.twig'))
             ->add('biasCurrent')
-            /* ->add('updated') */
         ;
     }
 
@@ -138,14 +136,11 @@ class PonPortAdmin extends BaseAdmin
 
         $showMapper
             ->add('oltDeviceId', 'string', array('template' => 'StatsBundle:Onu:base_show_field_olt.html.twig','oltName' => $oltName))
-            /* ->add('ponSerialNumber') */
             ->add('ponPort')
             ->add('txPower', 'string', array('template' => 'StatsBundle:Onu:base_show_field_tx.html.twig'))
-            /* ->add('rxPower', 'string', array('template' => 'StatsBundle:Onu:base_show_field_rx.html.twig')) */
             ->add('voltage', 'string', array('template' => 'StatsBundle:Onu:base_show_field_voltage.html.twig'))
             ->add('temperature', 'string', array('template' => 'StatsBundle:Onu:base_show_field_temperature.html.twig'))
             ->add('biasCurrent')
-            /* ->add('updated', 'string', array('template' => 'StatsBundle:Onu:base_show_field_uptime.html.twig')) */
         ;
     }
 

+ 12 - 46
src/StatsBundle/Command/StatsGeoPonPortCommand.php

@@ -46,41 +46,21 @@ class StatsGeoPonPortCommand extends BaseCommand
         
         $devicesOlt = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\OLT'));
         
-        $metrics = array("tx" => "onu_tx_", "rx" => "onu_rx_", "temp" => "onu_temperature_", "volt" => "onu_voltage_", "status" => "onu_status_");
-        
-        $data = array();
-
-        $devices = $this->getOnusFromDevices($oltServerId);
+        $metrics = array("tx" => "getTxPower", "rx" => "getRxPower", "temp" => "getTemperature", "volt" => "getVoltage", "status" => "getStatus");
         
         foreach($devicesOlt as $k => $deviceOlt) {
 
             $oltDeviceId = $deviceOlt->getDeviceId();
             $tenancyId = $deviceOlt->getTenancyId();
 
-            $onuStats = array();
-            foreach($metrics as $m => $metric) {
-                $key_onu_stats = "{$metric}d_{$oltDeviceId}_s_{$oltServerId}";
-                $onuStats[$metric] = $this->getData($key_onu_stats, true);
-            }
-            
-            $key_pon_stats = "olt_stats_pons_d_{$oltDeviceId}_s_{$oltServerId}";
-
-            $ponsCached = $this->getData($key_pon_stats, true);
-
-            if(empty($ponsCached)) {
-                $this->output->writeln("Se requiere {$key_pon_stats}.");
-                continue;
-            }
-
-            $ponStats = array();
-            foreach($ponsCached as $p) {$ponStats[$p['ponPort']] = $p;}
-
             $ponPorts = $doctrine->getRepository('\StatsBundle\Entity\PonPort')->findBy(array('deviceServer' => $oltServerId, 'oltDeviceId' => $oltDeviceId));
             
             foreach($ponPorts as $ponPort) {
 
                 //$ponIndex = str_replace("/","_",$ponPort->getPonPort());
                 $ponIndex = $ponPort->getPonPort();
+                $rxPon = $ponPort->getArrayRxPower();
+                $txPon = $ponPort->getTxPower();
                 
                 $geo = array();
                 $geo['type'] = "FeatureCollection";
@@ -105,29 +85,22 @@ class StatsGeoPonPortCommand extends BaseCommand
                     $lowSn = strtolower($sn);
                     $pon = explode("/", $onu->getPonPort());
                     
-                    if(!isset($devices[$lowSn])) {
-                        continue;
-                    } elseif(is_null($devices[$lowSn]['lat']) || is_null($devices[$lowSn]['lng'])) {
-                        continue;
-                    }
+                    $lat = $onu->getLat();
+                    $lng = $onu->getLng();
+
+                    if(is_null($lat) || is_null($lng)) continue;
 
                     $row = array();
                     $row['type'] = "Feature";
                     $row['id'] = "onu.{$lowSn}";
                     
-                    $lat = $devices[$lowSn]['lat'];
-                    $lng = $devices[$lowSn]['lng'];
-                    
                     $row['geometry'] = array('type' => "Point", 'coordinates' => array(0 => $lng, 1 => $lat));
                     $row['geometry_name'] = "the_geom";
                     $row['properties'] = array();
                     
-                    foreach($metrics as $m => $metric) {
-                        if(isset($onuStats[$metric][$lowSn])) {
-                            $row['properties'][$m] = $onuStats[$metric][$lowSn];
-                        } else {
-                            $row['properties'][$m] = "null";
-                        }
+                    foreach($metrics as $m => $method) {
+                        $value = $onu->$method();
+                        (is_null($value))? $row['properties'][$m] = "null" : $row['properties'][$m] = $value;
                     }
                     
                     $row['properties']["muestreo"] = date("d-m H:i");
@@ -137,15 +110,8 @@ class StatsGeoPonPortCommand extends BaseCommand
                     $_ponPort = "{$pon[0]}/{$pon[1]}";
                     $_onuId = $pon[2];
                     
-                    $row['properties']['txPon'] = "null";
-                    $row['properties']['rxPon'] = "null";
-                    if(isset($ponStats[$_ponPort]) && isset($ponStats[$_ponPort]['txPower'])) {
-                        $row['properties']['txPon'] = $ponStats[$_ponPort]['txPower'];
-                    }
-                    
-                    if(isset($ponStats[$_ponPort]) && isset($ponStats[$_ponPort]['rxPower'][$_onuId])) {
-                        $row['properties']['rxPon'] = $ponStats[$_ponPort]['rxPower'][$_onuId];
-                    }
+                    (is_null($txPon))? $row['properties']['txPon'] = "null" : $row['properties']['txPon'] = $txPon;
+                    (isset($rxPon[$_onuId]))? $row['properties']['rxPon'] = $rxPon[$_onuId] : $row['properties']['rxPon'] = "null";
                     
                     $geo['features'][] = $row;
                 }

+ 42 - 6
src/StatsBundle/Entity/Onu.php

@@ -382,7 +382,9 @@ class Onu implements TenancyIdTraitInterface
      */
     public function getTxPower()
     {
-        return $this->txPower;
+        if(is_null($this->txPower)) return null;
+        
+        return (float)$this->txPower;
     }
 
     /**
@@ -404,7 +406,9 @@ class Onu implements TenancyIdTraitInterface
      */
     public function getRxPower()
     {
-        return $this->rxPower;
+        if(is_null($this->rxPower)) return null;
+        
+        return (float)$this->rxPower;
     }
 
     /**
@@ -426,7 +430,9 @@ class Onu implements TenancyIdTraitInterface
      */
     public function getVoltage()
     {
-        return $this->voltage;
+        if(is_null($this->voltage)) return null;
+        
+        return (float)$this->voltage;
     }
 
     /**
@@ -448,7 +454,9 @@ class Onu implements TenancyIdTraitInterface
      */
     public function getTemperature()
     {
-        return $this->temperature;
+        if(is_null($this->temperature)) return null;
+        
+        return (float)$this->temperature;
     }
 
     /**
@@ -492,7 +500,9 @@ class Onu implements TenancyIdTraitInterface
      */
     public function getLat()
     {
-        return $this->lat;
+        if(is_null($this->lat)) return null;
+
+        return (float)$this->lat;
     }
     
     /**
@@ -514,7 +524,33 @@ class Onu implements TenancyIdTraitInterface
      */
     public function getLng()
     {
-        return $this->lng;
+        if(is_null($this->lng)) return null;
+
+        return (float)$this->lng;
+    }
+
+    /**
+     * Set status
+     *
+     * @param boolean $status
+     * @return ONU
+     */
+    public function setStatus($status)
+    {
+        $this->status = $status;
+        return $this;
+    }
+  
+    /**
+     * Get status
+     *
+     * @return boolean
+     */
+    public function getStatus()
+    {
+       if(is_null($this->status)) return null;
+       
+       return (boolean)$this->status;
     }
 
 }

+ 12 - 4
src/StatsBundle/Entity/PonPort.php

@@ -200,7 +200,9 @@ class PonPort implements TenancyIdTraitInterface
      */
     public function getTxPower()
     {
-        return $this->txPower;
+        if(is_null($this->txPower)) return null;
+
+        return (float)$this->txPower;
     }
 
     /**
@@ -258,7 +260,9 @@ class PonPort implements TenancyIdTraitInterface
      */
     public function getVoltage()
     {
-        return $this->voltage;
+        if(is_null($this->voltage)) return null;
+        
+        return (float)$this->voltage;
     }
 
     /**
@@ -280,7 +284,9 @@ class PonPort implements TenancyIdTraitInterface
      */
     public function getTemperature()
     {
-        return $this->temperature;
+        if(is_null($this->temperature)) return null;
+        
+        return (float)$this->temperature;
     }
 
     /**
@@ -302,7 +308,9 @@ class PonPort implements TenancyIdTraitInterface
      */
     public function getBiasCurrent()
     {
-        return $this->biasCurrent;
+        if(is_null($this->biasCurrent)) return null;
+        
+        return (float)$this->biasCurrent;
     }
 
 }

+ 10 - 2
src/StatsBundle/Resources/views/PonPort/base_list_field_rx.html.twig

@@ -7,7 +7,15 @@
         <span class="text_column_stats">{{ 'macroFields.notavailable'|trans({},'StatsBundle') }}</span>
     {% else %}
         <div class="ponport_div_rx_power">
-        <table><tr>
+        <table>
+        <tr>
+            <td class="ponport_td_rx_power">
+                <span style="font-size:14px;">
+                    <a class="sonata-action-element" href="{{ path('ponport_stats_map',{'id':object.getId()}) }}" title="{{ 'link_action_show_ponport_in_map'|trans({}, 'StatsBundle') }}">
+                        <i class="fa fa-map-marker" aria-hidden="true"></i>
+                    </a>
+                </span>
+            </td>
         {% for key,value in rx %}
             {% set style = "rx_ftth_bordo" %}
             {% if value < -30 %}
@@ -24,7 +32,7 @@
                 {% set style = "rx_ftth_rojo" %}
             {% endif %}
             <td class="ponport_td_rx_power" title="{{ponPort ~ '/' ~ key}} {{ value|number_format(2, '.', ',')}} dBm">
-            <span class="ponport_td_span_rx_power">{{key}} <span class="{{style}}"> {{ value|number_format(2, '.', ',')}}</span></span>
+                <span class="ponport_td_span_rx_power">{{key}} <span class="{{style}}"> {{ value|number_format(2, '.', ',')}}</span></span>
             </td>
         
         {% endfor %}