Cablemodem.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <?php
  2. namespace StatsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  5. use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use JMS\Serializer\Annotation as JMS;
  8. use Base\AdminBundle\Traits\TenancyIdTrait;
  9. use Base\AdminBundle\Traits\TenancyIdTraitInterface;
  10. /**
  11. * @ORM\Table
  12. * @ORM\Entity(repositoryClass="StatsBundle\Repository\CablemodemRepository")
  13. * @UniqueEntity(fields={"deviceServer", "cmtsDeviceId", "mac"}, message="errors.duplicate_key")
  14. * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"device_server_id", "cmts_device_id", "mac"})})
  15. */
  16. class Cablemodem implements TenancyIdTraitInterface
  17. {
  18. use ExtraDataTrait;
  19. use TenancyIdTrait;
  20. /**
  21. * @var int
  22. *
  23. * @ORM\Column(name="id", type="integer", nullable=false)
  24. * @ORM\Id
  25. * @ORM\GeneratedValue(strategy="AUTO")
  26. */
  27. private $id;
  28. /**
  29. * @var int
  30. *
  31. * @ORM\Column(type="integer", nullable=true)
  32. */
  33. private $cmtsDeviceId;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="DeviceServer", inversedBy="devices", fetch="EXTRA_LAZY")
  36. *
  37. * @JMS\MaxDepth(1)
  38. */
  39. protected $deviceServer;
  40. /**
  41. * @var int
  42. *
  43. * @ORM\Column(type="integer", nullable=true)
  44. */
  45. private $deviceId;
  46. /**
  47. * @var string
  48. *
  49. * @ORM\Column(type="string", length=255, nullable=true)
  50. *
  51. * @Assert\Ip
  52. */
  53. private $ip;
  54. /**
  55. * @var string
  56. *
  57. * @ORM\Column(type="string", length=12, nullable=true)
  58. */
  59. private $mac;
  60. /**
  61. * @ORM\Column(type="string", length=255, nullable=true)
  62. */
  63. private $index;
  64. /**
  65. * @ORM\Column(type="string", length=255, nullable=true)
  66. */
  67. private $upIf;
  68. /**
  69. * @ORM\Column(type="string", length=255, nullable=true)
  70. */
  71. private $downIf;
  72. /**
  73. * @ORM\Column(name="status", type="boolean", nullable=true, columnDefinition="BOOLEAN DEFAULT FALSE")
  74. */
  75. public $status = false;
  76. /**
  77. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  78. */
  79. public $txPower;
  80. /**
  81. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  82. */
  83. public $rxPower;
  84. /**
  85. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  86. */
  87. public $signal;
  88. /**
  89. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  90. */
  91. public $microreflection;
  92. /**
  93. * @ORM\Column(type="integer", nullable=true, columnDefinition="integer unsigned")
  94. */
  95. public $correcteds;
  96. /**
  97. * @ORM\Column(type="integer", nullable=true, columnDefinition="integer unsigned")
  98. */
  99. public $unerroreds;
  100. /**
  101. * @ORM\Column(type="integer", nullable=true, columnDefinition="integer unsigned")
  102. */
  103. public $uncorrectables;
  104. /**
  105. * @ORM\Column(type="string", length=255, nullable=true)
  106. */
  107. public $uptime;
  108. /**
  109. * @ORM\Column(type="datetime")
  110. */
  111. protected $updated;
  112. /**
  113. * @ORM\Column(type="decimal", precision=10, scale=7, nullable=true)
  114. */
  115. public $lat;
  116. /**
  117. * @ORM\Column(type="decimal", precision=10, scale=7, nullable=true)
  118. */
  119. public $lng;
  120. /**
  121. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  122. */
  123. public $rxPowerCmts;
  124. /**
  125. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  126. */
  127. public $signalCmts;
  128. /**
  129. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  130. */
  131. public $microreflectionCmts;
  132. /**
  133. * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
  134. */
  135. public $inOctets;
  136. /**
  137. * @ORM\Column(type="decimal", precision=16, scale=3, nullable=true, options={"comment":"Bandwidth in b/s"})
  138. */
  139. public $outOctets;
  140. /**
  141. * Get id
  142. *
  143. * @return integer
  144. */
  145. public function getId()
  146. {
  147. return $this->id;
  148. }
  149. /**
  150. * Set cmtsDeviceId
  151. *
  152. * @param integer $cmtsDeviceId
  153. *
  154. * @return Cablemodem
  155. */
  156. public function setCmtsDeviceId($cmtsDeviceId)
  157. {
  158. $this->cmtsDeviceId = $cmtsDeviceId;
  159. return $this;
  160. }
  161. /**
  162. * Get cmtsDeviceId
  163. *
  164. * @return integer
  165. */
  166. public function getCmtsDeviceId()
  167. {
  168. return $this->cmtsDeviceId;
  169. }
  170. /**
  171. * Set deviceId
  172. *
  173. * @param integer $deviceId
  174. *
  175. * @return Cablemodem
  176. */
  177. public function setDeviceId($deviceId)
  178. {
  179. $this->deviceId = $deviceId;
  180. return $this;
  181. }
  182. /**
  183. * Get deviceId
  184. *
  185. * @return integer
  186. */
  187. public function getDeviceId()
  188. {
  189. return $this->deviceId;
  190. }
  191. /**
  192. * Set ip
  193. *
  194. * @param string $ip
  195. *
  196. * @return Cablemodem
  197. */
  198. public function setIp($ip)
  199. {
  200. $this->ip = $ip;
  201. return $this;
  202. }
  203. /**
  204. * Get ip
  205. *
  206. * @return string
  207. */
  208. public function getIp()
  209. {
  210. return $this->ip;
  211. }
  212. /**
  213. * Set mac
  214. *
  215. * @param string $mac
  216. *
  217. * @return Cablemodem
  218. */
  219. public function setMac($mac)
  220. {
  221. $this->mac = $mac;
  222. return $this;
  223. }
  224. /**
  225. * Get mac
  226. *
  227. * @return string
  228. */
  229. public function getMac()
  230. {
  231. return strtoupper($this->mac);
  232. }
  233. /**
  234. * Set index
  235. *
  236. * @param string $index
  237. *
  238. * @return Cablemodem
  239. */
  240. public function setIndex($index)
  241. {
  242. $this->index = $index;
  243. return $this;
  244. }
  245. /**
  246. * Get index
  247. *
  248. * @return string
  249. */
  250. public function getIndex()
  251. {
  252. return $this->index;
  253. }
  254. /**
  255. * Set upIf
  256. *
  257. * @param string $upIf
  258. *
  259. * @return Cablemodem
  260. */
  261. public function setUpIf($upIf)
  262. {
  263. $this->upIf = $upIf;
  264. return $this;
  265. }
  266. /**
  267. * Get upIf
  268. *
  269. * @return string
  270. */
  271. public function getUpIf()
  272. {
  273. return $this->upIf;
  274. }
  275. /**
  276. * Set downIf
  277. *
  278. * @param string $downIf
  279. *
  280. * @return Cablemodem
  281. */
  282. public function setDownIf($downIf)
  283. {
  284. $this->downIf = $downIf;
  285. return $this;
  286. }
  287. /**
  288. * Get downIf
  289. *
  290. * @return string
  291. */
  292. public function getDownIf()
  293. {
  294. return $this->downIf;
  295. }
  296. /**
  297. * Set status
  298. *
  299. * @param boolean $status
  300. *
  301. * @return Cablemodem
  302. */
  303. public function setStatus($status)
  304. {
  305. $this->status = $status;
  306. return $this;
  307. }
  308. /**
  309. * Get status
  310. *
  311. * @return boolean
  312. */
  313. public function getStatus()
  314. {
  315. return $this->status;
  316. }
  317. /**
  318. * Set txPower
  319. *
  320. * @param string $txPower
  321. *
  322. * @return Cablemodem
  323. */
  324. public function setTxPower($txPower)
  325. {
  326. $this->txPower = $txPower;
  327. return $this;
  328. }
  329. /**
  330. * Get txPower
  331. *
  332. */
  333. public function getTxPower()
  334. {
  335. return $this->txPower;
  336. }
  337. /**
  338. * Set rxPower
  339. *
  340. * @param string $rxPower
  341. *
  342. * @return Cablemodem
  343. */
  344. public function setRxPower($rxPower)
  345. {
  346. $this->rxPower = $rxPower;
  347. return $this;
  348. }
  349. /**
  350. * Get rxPower
  351. *
  352. * @return string
  353. */
  354. public function getRxPower()
  355. {
  356. return $this->rxPower;
  357. }
  358. /**
  359. * Set signal
  360. *
  361. * @param string $signal
  362. *
  363. * @return Cablemodem
  364. */
  365. public function setSignal($signal)
  366. {
  367. $this->signal = $signal;
  368. return $this;
  369. }
  370. /**
  371. * Get signal
  372. *
  373. */
  374. public function getSignal()
  375. {
  376. return $this->signal;
  377. }
  378. /**
  379. * Set microreflection
  380. *
  381. * @param string $microreflection
  382. *
  383. * @return Cablemodem
  384. */
  385. public function setMicroreflection($microreflection)
  386. {
  387. $this->microreflection = $microreflection;
  388. return $this;
  389. }
  390. /**
  391. * Get microreflection
  392. *
  393. */
  394. public function getMicroreflection()
  395. {
  396. return $this->microreflection;
  397. }
  398. /**
  399. * Set correcteds
  400. *
  401. * @param integer $correcteds
  402. *
  403. * @return Cablemodem
  404. */
  405. public function setCorrecteds($correcteds)
  406. {
  407. $this->correcteds = $correcteds;
  408. return $this;
  409. }
  410. /**
  411. * Get correcteds
  412. *
  413. * @return integer
  414. */
  415. public function getCorrecteds()
  416. {
  417. return $this->correcteds;
  418. }
  419. /**
  420. * Set unerroreds
  421. *
  422. * @param integer $unerroreds
  423. *
  424. * @return Cablemodem
  425. */
  426. public function setUnerroreds($unerroreds)
  427. {
  428. $this->unerroreds = $unerroreds;
  429. return $this;
  430. }
  431. /**
  432. * Get unerroreds
  433. *
  434. * @return integer
  435. */
  436. public function getUnerroreds()
  437. {
  438. return $this->unerroreds;
  439. }
  440. /**
  441. * Set uncorrectables
  442. *
  443. * @param integer $uncorrectables
  444. *
  445. * @return Cablemodem
  446. */
  447. public function setUncorrectables($uncorrectables)
  448. {
  449. $this->uncorrectables = $uncorrectables;
  450. return $this;
  451. }
  452. /**
  453. * Get uncorrectables
  454. *
  455. * @return integer
  456. */
  457. public function getUncorrectables()
  458. {
  459. return $this->uncorrectables;
  460. }
  461. /**
  462. * Set uptime
  463. *
  464. * @param string $uptime
  465. *
  466. * @return Cablemodem
  467. */
  468. public function setUptime($uptime)
  469. {
  470. $this->uptime = $uptime;
  471. return $this;
  472. }
  473. /**
  474. * Get uptime
  475. *
  476. * @return string
  477. */
  478. public function getUptime()
  479. {
  480. return $this->uptime;
  481. }
  482. /**
  483. * Set updated
  484. *
  485. * @param \DateTime $updated
  486. *
  487. * @return Cablemodem
  488. */
  489. public function setUpdated($updated)
  490. {
  491. $this->updated = $updated;
  492. return $this;
  493. }
  494. /**
  495. * Get updated
  496. *
  497. * @return \DateTime
  498. */
  499. public function getUpdated()
  500. {
  501. return $this->updated;
  502. }
  503. /**
  504. * Set lat
  505. *
  506. * @param string $lat
  507. *
  508. * @return Cablemodem
  509. */
  510. public function setLat($lat)
  511. {
  512. $this->lat = $lat;
  513. return $this;
  514. }
  515. /**
  516. * Get lat
  517. *
  518. * @return string
  519. */
  520. public function getLat()
  521. {
  522. return (double) $this->lat;
  523. }
  524. /**
  525. * Set lng
  526. *
  527. * @param string $lng
  528. *
  529. * @return Cablemodem
  530. */
  531. public function setLng($lng)
  532. {
  533. $this->lng = $lng;
  534. return $this;
  535. }
  536. /**
  537. * Get lng
  538. *
  539. * @return string
  540. */
  541. public function getLng()
  542. {
  543. return (double) $this->lng;
  544. }
  545. /**
  546. * Set deviceServer
  547. *
  548. * @param \StatsBundle\Entity\DeviceServer $deviceServer
  549. *
  550. * @return Cablemodem
  551. */
  552. public function setDeviceServer(\StatsBundle\Entity\DeviceServer $deviceServer = null)
  553. {
  554. $this->deviceServer = $deviceServer;
  555. return $this;
  556. }
  557. /**
  558. * Get deviceServer
  559. *
  560. * @return \StatsBundle\Entity\DeviceServer
  561. */
  562. public function getDeviceServer()
  563. {
  564. return $this->deviceServer;
  565. }
  566. /**
  567. * Set rxPowerCmts
  568. *
  569. * @param string $rxPowerCmts
  570. *
  571. * @return Cablemodem
  572. */
  573. public function setRxPowerCmts($rxPowerCmts)
  574. {
  575. $this->rxPowerCmts = $rxPowerCmts;
  576. return $this;
  577. }
  578. /**
  579. * Get rxPowerCmts
  580. *
  581. * @return string
  582. */
  583. public function getRxPowerCmts()
  584. {
  585. return $this->rxPowerCmts;
  586. }
  587. /**
  588. * Set signalCmts
  589. *
  590. * @param string $signalCmts
  591. *
  592. * @return Cablemodem
  593. */
  594. public function setSignalCmts($signalCmts)
  595. {
  596. $this->signalCmts = $signalCmts;
  597. return $this;
  598. }
  599. /**
  600. * Get signalCmts
  601. *
  602. */
  603. public function getSignalCmts()
  604. {
  605. return $this->signalCmts;
  606. }
  607. /**
  608. * Set microreflectionCmts
  609. *
  610. * @param string $microreflectionCmts
  611. *
  612. * @return Cablemodem
  613. */
  614. public function setMicroreflectionCmts($microreflectionCmts)
  615. {
  616. $this->microreflectionCmts = $microreflectionCmts;
  617. return $this;
  618. }
  619. /**
  620. * Get microreflectionCmts
  621. *
  622. */
  623. public function getMicroreflectionCmts()
  624. {
  625. return $this->microreflectionCmts;
  626. }
  627. /**
  628. * @return string
  629. */
  630. public function getCustomId()
  631. {
  632. return sprintf('%s~%s~%s', strtolower($this->mac), $this->cmtsDeviceId, $this->deviceServer->getId());
  633. }
  634. /**
  635. * @return string
  636. */
  637. public function __toString()
  638. {
  639. return sprintf('%s', strtoupper($this->mac));
  640. }
  641. /**
  642. * Set inOctets
  643. *
  644. * @param float $inOctets
  645. *
  646. * @return Cablemodem
  647. */
  648. public function setInOctets($inOctets)
  649. {
  650. $this->inOctets = $inOctets;
  651. return $this;
  652. }
  653. /**
  654. * Get inOctets
  655. *
  656. * @return float
  657. */
  658. public function getInOctets()
  659. {
  660. return (float) $this->inOctets;
  661. }
  662. /**
  663. * Set outOctets
  664. *
  665. * @param float $outOctets
  666. *
  667. * @return Cablemodem
  668. */
  669. public function setOutOctets($outOctets)
  670. {
  671. $this->outOctets = $outOctets;
  672. return $this;
  673. }
  674. /**
  675. * Get outOctets
  676. *
  677. * @return float
  678. */
  679. public function getOutOctets()
  680. {
  681. return (float) $this->outOctets;
  682. }
  683. }