|
@@ -9,6 +9,8 @@ use Gedmo\Mapping\Annotation as Gedmo;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Component\Workflow\Exception\ExceptionInterface;
|
|
use Symfony\Component\Workflow\Exception\ExceptionInterface;
|
|
|
|
+use DeviceBundle\Validator\Constraints as ValidatorAssert;
|
|
|
|
+use DeviceBundle\Interfaces\DeviceInterface;
|
|
|
|
|
|
/**
|
|
/**
|
|
* ONU
|
|
* ONU
|
|
@@ -17,8 +19,10 @@ use Symfony\Component\Workflow\Exception\ExceptionInterface;
|
|
* @ORM\HasLifecycleCallbacks
|
|
* @ORM\HasLifecycleCallbacks
|
|
* @UniqueEntity(fields={"ponSerialNumber", "tenancyId"}, message="errors.duplicate_key")
|
|
* @UniqueEntity(fields={"ponSerialNumber", "tenancyId"}, message="errors.duplicate_key")
|
|
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"pon_serial_number", "tenancy_id"})})
|
|
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"pon_serial_number", "tenancy_id"})})
|
|
|
|
+ *
|
|
|
|
+ * @ValidatorAssert\Device
|
|
*/
|
|
*/
|
|
-class ONU
|
|
|
|
|
|
+class ONU implements DeviceInterface
|
|
{
|
|
{
|
|
|
|
|
|
use ExtraDataTrait;
|
|
use ExtraDataTrait;
|
|
@@ -508,7 +512,7 @@ class ONU
|
|
$log = $rootDir . "/../var/logs/" . $env . ".log";
|
|
$log = $rootDir . "/../var/logs/" . $env . ".log";
|
|
$out = array();
|
|
$out = array();
|
|
exec("tail -400 {$log} | grep 'ONU_id_{$this->id}'", $out);
|
|
exec("tail -400 {$log} | grep 'ONU_id_{$this->id}'", $out);
|
|
-
|
|
|
|
|
|
+
|
|
return implode("\n", $out);
|
|
return implode("\n", $out);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -588,7 +592,7 @@ class ONU
|
|
|
|
|
|
return $this;
|
|
return $this;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Si la ONU no tiene NAP retorna 0
|
|
* Si la ONU no tiene NAP retorna 0
|
|
* De lo contrario recorre y retorna la primer position
|
|
* De lo contrario recorre y retorna la primer position
|
|
@@ -611,15 +615,26 @@ class ONU
|
|
asort($positions);
|
|
asort($positions);
|
|
$position_range = range(1, end($positions));
|
|
$position_range = range(1, end($positions));
|
|
$position_diff = array_diff($position_range, $positions);
|
|
$position_diff = array_diff($position_range, $positions);
|
|
-
|
|
|
|
|
|
+
|
|
if (!empty($position_diff)) {
|
|
if (!empty($position_diff)) {
|
|
$position = array_shift($position_diff);
|
|
$position = array_shift($position_diff);
|
|
} else {
|
|
} else {
|
|
$position = $nap->getOnus()->count() + 1;
|
|
$position = $nap->getOnus()->count() + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- return $position;
|
|
|
|
|
|
+
|
|
|
|
+ return $position;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getDeviceData()
|
|
|
|
+ {
|
|
|
|
+ return array(
|
|
|
|
+ 'deviceType' => get_class($this),
|
|
|
|
+ 'deviceId' => $this->id,
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|