Onu.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <?php
  2. namespace StatsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use JMS\Serializer\Annotation as JMS;
  7. use Base\AdminBundle\Traits\TenancyIdTrait;
  8. use Base\AdminBundle\Traits\TenancyIdTraitInterface;
  9. /**
  10. * @ORM\Table
  11. * @ORM\Entity(repositoryClass="StatsBundle\Repository\OnuRepository")
  12. * @UniqueEntity(fields={"deviceServer", "oltDeviceId", "ponSerialNumber"}, message="errors.duplicate_key")
  13. * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"device_server_id", "olt_device_id", "pon_serial_number"})})
  14. */
  15. class Onu implements TenancyIdTraitInterface
  16. {
  17. use TenancyIdTrait;
  18. /**
  19. * @var int
  20. *
  21. * @ORM\Column(name="id", type="integer", nullable=false)
  22. * @ORM\Id
  23. * @ORM\GeneratedValue(strategy="AUTO")
  24. */
  25. private $id;
  26. /**
  27. * @ORM\Column(type="integer", nullable=true)
  28. */
  29. private $index;
  30. /**
  31. * @var string
  32. *
  33. * @ORM\Column(type="string", length=25, nullable=true)
  34. */
  35. private $ponSerialNumber;
  36. /**
  37. * @var int
  38. *
  39. * @ORM\Column(type="integer", nullable=true)
  40. */
  41. private $oltDeviceId;
  42. /**
  43. * @ORM\ManyToOne(targetEntity="DeviceServer", inversedBy="devices", fetch="EXTRA_LAZY")
  44. *
  45. * @JMS\MaxDepth(1)
  46. */
  47. protected $deviceServer;
  48. /**
  49. * @var int
  50. *
  51. * @ORM\Column(type="integer", nullable=true)
  52. */
  53. private $deviceId;
  54. /**
  55. * @var string
  56. *
  57. * @ORM\Column(type="string", length=255, nullable=true)
  58. *
  59. * @Assert\Ip
  60. */
  61. private $ip;
  62. /**
  63. * @var string
  64. *
  65. * @ORM\Column(type="string", length=12, nullable=true)
  66. */
  67. private $mac;
  68. /**
  69. * @var string
  70. *
  71. * @ORM\Column(type="string", length=25, nullable=true)
  72. */
  73. private $serialNumber;
  74. /**
  75. * @ORM\Column(type="string", length=25, nullable=true)
  76. */
  77. private $ponPort;
  78. /**
  79. * @ORM\Column(name="status", type="boolean", nullable=true, columnDefinition="BOOLEAN DEFAULT FALSE")
  80. */
  81. public $status = false;
  82. /**
  83. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  84. */
  85. public $txPower;
  86. /**
  87. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  88. */
  89. public $rxPower;
  90. /**
  91. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  92. */
  93. public $voltage;
  94. /**
  95. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  96. */
  97. public $temperature;
  98. /**
  99. * @ORM\Column(type="string", length=25, nullable=true)
  100. */
  101. public $uptime;
  102. /**
  103. * @ORM\Column(type="datetime")
  104. */
  105. protected $updated;
  106. /**
  107. * @ORM\Column(type="decimal", precision=10, scale=7, nullable=true)
  108. */
  109. public $lat;
  110. /**
  111. * @ORM\Column(type="decimal", precision=10, scale=7, nullable=true)
  112. */
  113. public $lng;
  114. /**
  115. * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
  116. */
  117. public $inOctets;
  118. /**
  119. * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
  120. */
  121. public $outOctets;
  122. /**
  123. * @return int
  124. */
  125. public function getId()
  126. {
  127. return $this->id;
  128. }
  129. /**
  130. * @return string
  131. */
  132. public function getCustomId()
  133. {
  134. return sprintf('%s~%s~%s', strtolower($this->ponSerialNumber), $this->oltDeviceId, $this->deviceServer->getId());
  135. }
  136. /**
  137. * @return string
  138. */
  139. public function __toString()
  140. {
  141. return sprintf('%s', strtoupper($this->ponSerialNumber));
  142. }
  143. /**
  144. * @param string $ip
  145. *
  146. * @return Device
  147. */
  148. public function setIp($ip = null)
  149. {
  150. $this->ip = $ip;
  151. return $this;
  152. }
  153. /**
  154. * @return string
  155. */
  156. public function getIp()
  157. {
  158. return $this->ip;
  159. }
  160. /**
  161. * Set mac
  162. *
  163. * @param string $mac
  164. *
  165. * @return ONU
  166. */
  167. public function setMac($mac)
  168. {
  169. $this->mac = $mac;
  170. return $this;
  171. }
  172. /**
  173. * Get mac
  174. *
  175. * @return string
  176. */
  177. public function getMac()
  178. {
  179. return $this->mac;
  180. }
  181. /**
  182. * Set serialNumber
  183. *
  184. * @param string $serialNumber
  185. *
  186. * @return ONU
  187. */
  188. public function setSerialNumber($serialNumber)
  189. {
  190. $this->serialNumber = $serialNumber;
  191. return $this;
  192. }
  193. /**
  194. * Get serialNumber
  195. *
  196. * @return string
  197. */
  198. public function getSerialNumber()
  199. {
  200. return $this->serialNumber;
  201. }
  202. /**
  203. * Set ponSerialNumber
  204. *
  205. * @param string $ponSerialNumber
  206. *
  207. * @return ONU
  208. */
  209. public function setPonSerialNumber($ponSerialNumber)
  210. {
  211. $this->ponSerialNumber = $ponSerialNumber;
  212. return $this;
  213. }
  214. /**
  215. * Get ponSerialNumber
  216. *
  217. * @return string
  218. */
  219. public function getPonSerialNumber()
  220. {
  221. return strtoupper($this->ponSerialNumber);
  222. }
  223. /**
  224. * Set ponPort
  225. *
  226. * @param string $ponPort
  227. *
  228. * @return ONU
  229. */
  230. public function setPonPort($ponPort)
  231. {
  232. $this->ponPort = $ponPort;
  233. return $this;
  234. }
  235. /**
  236. * Get ponPort
  237. *
  238. * @return string
  239. */
  240. public function getPonPort()
  241. {
  242. return $this->ponPort;
  243. }
  244. /**
  245. * @param int $deviceId
  246. *
  247. * @return ONU
  248. */
  249. public function setDeviceId($deviceId)
  250. {
  251. $this->deviceId = $deviceId;
  252. return $this;
  253. }
  254. /**
  255. * @return int
  256. */
  257. public function getDeviceId()
  258. {
  259. return $this->deviceId;
  260. }
  261. /**
  262. * @param int $oltDeviceId
  263. *
  264. * @return ONU
  265. */
  266. public function setOltDeviceId($oltDeviceId)
  267. {
  268. $this->oltDeviceId = $oltDeviceId;
  269. return $this;
  270. }
  271. /**
  272. * @return int
  273. */
  274. public function getOltDeviceId()
  275. {
  276. return $this->oltDeviceId;
  277. }
  278. /**
  279. * @return DeviceServer
  280. */
  281. public function getDeviceServer()
  282. {
  283. return $this->deviceServer;
  284. }
  285. /**
  286. * @param DeviceServer $deviceServer
  287. *
  288. * @return ONU
  289. */
  290. public function setDeviceServer($deviceServer)
  291. {
  292. $this->deviceServer = $deviceServer;
  293. return $this;
  294. }
  295. public function getShortType()
  296. {
  297. return str_replace("FTTHBundle\\Entity\\", "", $this->deviceType);
  298. }
  299. /**
  300. * Set updated
  301. *
  302. * @param Datetime $tenancyId
  303. *
  304. * @return ONU
  305. */
  306. public function setUpdated($updated)
  307. {
  308. $this->updated = $updated;
  309. return $this;
  310. }
  311. /**
  312. * Get updated
  313. *
  314. * @return \DateTime
  315. */
  316. public function getUpdated()
  317. {
  318. return $this->updated;
  319. }
  320. /**
  321. * Set txPower
  322. *
  323. * @param decimal $txPower
  324. * @return ONU
  325. */
  326. public function setTxPower($txPower)
  327. {
  328. $this->txPower = $txPower;
  329. return $this;
  330. }
  331. /**
  332. * Get txPower
  333. *
  334. * @return decimal
  335. */
  336. public function getTxPower()
  337. {
  338. if(is_null($this->txPower)) return null;
  339. return (float)$this->txPower;
  340. }
  341. /**
  342. * Set rxPower
  343. *
  344. * @param decimal $rxPower
  345. * @return ONU
  346. */
  347. public function setRxPower($rxPower)
  348. {
  349. $this->rxPower = $rxPower;
  350. return $this;
  351. }
  352. /**
  353. * Get rxPower
  354. *
  355. * @return decimal
  356. */
  357. public function getRxPower()
  358. {
  359. if(is_null($this->rxPower)) return null;
  360. return (float)$this->rxPower;
  361. }
  362. /**
  363. * Set voltage
  364. *
  365. * @param decimal $voltage
  366. * @return ONU
  367. */
  368. public function setVoltage($voltage)
  369. {
  370. $this->voltage = $voltage;
  371. return $this;
  372. }
  373. /**
  374. * Get voltage
  375. *
  376. * @return decimal
  377. */
  378. public function getVoltage()
  379. {
  380. if(is_null($this->voltage)) return null;
  381. return (float)$this->voltage;
  382. }
  383. /**
  384. * Set temperature
  385. *
  386. * @param decimal $temperature
  387. * @return ONU
  388. */
  389. public function setTemperature($temperature)
  390. {
  391. $this->temperature = $temperature;
  392. return $this;
  393. }
  394. /**
  395. * Get temperature
  396. *
  397. * @return decimal
  398. */
  399. public function getTemperature()
  400. {
  401. if(is_null($this->temperature)) return null;
  402. return (float)$this->temperature;
  403. }
  404. /**
  405. * Set uptime
  406. *
  407. * @param string $uptime
  408. * @return ONU
  409. */
  410. public function setUptime($uptime)
  411. {
  412. $this->uptime = $uptime;
  413. return $this;
  414. }
  415. /**
  416. * Get uptime
  417. *
  418. * @return string
  419. */
  420. public function getUptime()
  421. {
  422. return $this->uptime;
  423. }
  424. /**
  425. * Set lat
  426. *
  427. * @param decimal $lat
  428. * @return ONU
  429. */
  430. public function setLat($lat)
  431. {
  432. $this->lat = $lat;
  433. return $this;
  434. }
  435. /**
  436. * Get lat
  437. *
  438. * @return decimal
  439. */
  440. public function getLat()
  441. {
  442. if(is_null($this->lat)) return null;
  443. return (float)$this->lat;
  444. }
  445. /**
  446. * Set lng
  447. *
  448. * @param decimal $lng
  449. * @return ONU
  450. */
  451. public function setLng($lng)
  452. {
  453. $this->lng = $lng;
  454. return $this;
  455. }
  456. /**
  457. * Get lng
  458. *
  459. * @return decimal
  460. */
  461. public function getLng()
  462. {
  463. if(is_null($this->lng)) return null;
  464. return (float)$this->lng;
  465. }
  466. /**
  467. * Set status
  468. *
  469. * @param boolean $status
  470. * @return ONU
  471. */
  472. public function setStatus($status)
  473. {
  474. $this->status = $status;
  475. return $this;
  476. }
  477. /**
  478. * Get status
  479. *
  480. * @return boolean
  481. */
  482. public function getStatus()
  483. {
  484. if(is_null($this->status)) return null;
  485. return (boolean)$this->status;
  486. }
  487. /**
  488. * Set index
  489. *
  490. * @param integer $index
  491. *
  492. * @return ONU
  493. */
  494. public function setIndex($index)
  495. {
  496. $this->index = $index;
  497. return $this;
  498. }
  499. /**
  500. * Get index
  501. *
  502. * @return integer
  503. */
  504. public function getIndex()
  505. {
  506. return $this->index;
  507. }
  508. /**
  509. * Set inOctets
  510. *
  511. * @param float $inOctets
  512. *
  513. * @return ONU
  514. */
  515. public function setInOctets($inOctets)
  516. {
  517. $this->inOctets = $inOctets;
  518. return $this;
  519. }
  520. /**
  521. * Get inOctets
  522. *
  523. * @return float
  524. */
  525. public function getInOctets()
  526. {
  527. return (float) $this->inOctets;
  528. }
  529. /**
  530. * Set outOctets
  531. *
  532. * @param float $outOctets
  533. *
  534. * @return ONU
  535. */
  536. public function setOutOctets($outOctets)
  537. {
  538. $this->outOctets = $outOctets;
  539. return $this;
  540. }
  541. /**
  542. * Get outOctets
  543. *
  544. * @return float
  545. */
  546. public function getOutOctets()
  547. {
  548. return (float) $this->outOctets;
  549. }
  550. }