Onu.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. /**
  7. * @ORM\Table
  8. * @ORM\Entity(repositoryClass="StatsBundle\Repository\OnuRepository")
  9. * @UniqueEntity(fields={"deviceServer", "oltDeviceId", "ponSerialNumber"}, message="errors.duplicate_key")
  10. * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"device_server_id", "olt_device_id", "pon_serial_number"})})
  11. */
  12. class Onu
  13. {
  14. /**
  15. * @var int
  16. *
  17. * @ORM\Column(name="id", type="integer", nullable=false)
  18. * @ORM\Id
  19. * @ORM\GeneratedValue(strategy="AUTO")
  20. */
  21. private $id;
  22. /**
  23. * @var string
  24. *
  25. * @ORM\Column(type="string", length=25, nullable=true)
  26. */
  27. private $ponSerialNumber;
  28. /**
  29. * @var int
  30. *
  31. * @ORM\Column(type="integer", nullable=true)
  32. */
  33. private $oltDeviceId;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="DeviceServer", inversedBy="devices", fetch="EXTRA_LAZY")
  36. */
  37. protected $deviceServer;
  38. /**
  39. * @var int
  40. *
  41. * @ORM\Column(type="integer", nullable=true)
  42. */
  43. private $deviceId;
  44. /**
  45. * @var int
  46. *
  47. * @ORM\Column(type="integer", nullable=false, options={"default":1})
  48. */
  49. protected $tenancyId = 1;
  50. /**
  51. * @var string
  52. *
  53. * @ORM\Column(type="string", length=255, nullable=true)
  54. *
  55. * @Assert\Ip
  56. */
  57. private $ip;
  58. /**
  59. * @var string
  60. *
  61. * @ORM\Column(type="string", length=12, nullable=true)
  62. */
  63. private $mac;
  64. /**
  65. * @var string
  66. *
  67. * @ORM\Column(type="string", length=25, nullable=true)
  68. */
  69. private $serialNumber;
  70. /**
  71. * @ORM\Column(type="string", length=25, nullable=true)
  72. */
  73. private $ponPort;
  74. /**
  75. * @ORM\Column(name="status", type="boolean", nullable=true, columnDefinition="BOOLEAN DEFAULT FALSE")
  76. */
  77. public $status = false;
  78. /**
  79. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  80. */
  81. public $txPower;
  82. /**
  83. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  84. */
  85. public $rxPower;
  86. /**
  87. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  88. */
  89. public $voltage;
  90. /**
  91. * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
  92. */
  93. public $temperature;
  94. /**
  95. * @ORM\Column(type="string", length=25, nullable=true)
  96. */
  97. public $uptime;
  98. /**
  99. * @ORM\Column(type="datetime")
  100. */
  101. protected $updated;
  102. /**
  103. * @return int
  104. */
  105. public function getId()
  106. {
  107. return $this->id;
  108. }
  109. /**
  110. * @return string
  111. */
  112. public function getCustomId()
  113. {
  114. return sprintf('%s~%s~%s', strtolower($this->ponSerialNumber), $this->oltDeviceId, $this->deviceServer->getId());
  115. }
  116. /**
  117. * @return string
  118. */
  119. public function __toString()
  120. {
  121. return sprintf('%s', strtoupper($this->ponSerialNumber));
  122. }
  123. /**
  124. * @param string $ip
  125. *
  126. * @return Device
  127. */
  128. public function setIp($ip = null)
  129. {
  130. $this->ip = $ip;
  131. return $this;
  132. }
  133. /**
  134. * @return string
  135. */
  136. public function getIp()
  137. {
  138. return $this->ip;
  139. }
  140. /**
  141. * Set mac
  142. *
  143. * @param string $mac
  144. *
  145. * @return ONU
  146. */
  147. public function setMac($mac)
  148. {
  149. $this->mac = $mac;
  150. return $this;
  151. }
  152. /**
  153. * Get mac
  154. *
  155. * @return string
  156. */
  157. public function getMac()
  158. {
  159. return $this->mac;
  160. }
  161. /**
  162. * Set serialNumber
  163. *
  164. * @param string $serialNumber
  165. *
  166. * @return ONU
  167. */
  168. public function setSerialNumber($serialNumber)
  169. {
  170. $this->serialNumber = $serialNumber;
  171. return $this;
  172. }
  173. /**
  174. * Get serialNumber
  175. *
  176. * @return string
  177. */
  178. public function getSerialNumber()
  179. {
  180. return $this->serialNumber;
  181. }
  182. /**
  183. * Set ponSerialNumber
  184. *
  185. * @param string $ponSerialNumber
  186. *
  187. * @return ONU
  188. */
  189. public function setPonSerialNumber($ponSerialNumber)
  190. {
  191. $this->ponSerialNumber = $ponSerialNumber;
  192. return $this;
  193. }
  194. /**
  195. * Get ponSerialNumber
  196. *
  197. * @return string
  198. */
  199. public function getPonSerialNumber()
  200. {
  201. return strtoupper($this->ponSerialNumber);
  202. }
  203. /**
  204. * Set ponPort
  205. *
  206. * @param string $ponPort
  207. *
  208. * @return ONU
  209. */
  210. public function setPonPort($ponPort)
  211. {
  212. $this->ponPort = $ponPort;
  213. return $this;
  214. }
  215. /**
  216. * Get ponPort
  217. *
  218. * @return string
  219. */
  220. public function getPonPort()
  221. {
  222. return $this->ponPort;
  223. }
  224. /**
  225. * @param int $deviceId
  226. *
  227. * @return ONU
  228. */
  229. public function setDeviceId($deviceId)
  230. {
  231. $this->deviceId = $deviceId;
  232. return $this;
  233. }
  234. /**
  235. * @return int
  236. */
  237. public function getDeviceId()
  238. {
  239. return $this->deviceId;
  240. }
  241. /**
  242. * @param int $oltDeviceId
  243. *
  244. * @return ONU
  245. */
  246. public function setOltDeviceId($oltDeviceId)
  247. {
  248. $this->oltDeviceId = $oltDeviceId;
  249. return $this;
  250. }
  251. /**
  252. * @return int
  253. */
  254. public function getOltDeviceId()
  255. {
  256. return $this->oltDeviceId;
  257. }
  258. /**
  259. * @return DeviceServer
  260. */
  261. public function getDeviceServer()
  262. {
  263. return $this->deviceServer;
  264. }
  265. /**
  266. * @param DeviceServer $deviceServer
  267. *
  268. * @return ONU
  269. */
  270. public function setDeviceServer($deviceServer)
  271. {
  272. $this->deviceServer = $deviceServer;
  273. return $this;
  274. }
  275. public function getShortType()
  276. {
  277. return str_replace("FTTHBundle\\Entity\\", "", $this->deviceType);
  278. }
  279. /**
  280. * Set tenancyId
  281. *
  282. * @param int $tenancyId
  283. *
  284. * @return ONU
  285. */
  286. public function setTenancyId($tenancyId)
  287. {
  288. $this->tenancyId = $tenancyId;
  289. return $this;
  290. }
  291. /**
  292. * Get tenancyId
  293. *
  294. * @return int
  295. */
  296. public function getTenancyId()
  297. {
  298. return $this->tenancyId;
  299. }
  300. /**
  301. * Set updated
  302. *
  303. * @param Datetime $tenancyId
  304. *
  305. * @return ONU
  306. */
  307. public function setUpdated($updated)
  308. {
  309. $this->updated = $updated;
  310. return $this;
  311. }
  312. /**
  313. * Get updated
  314. *
  315. * @return \DateTime
  316. */
  317. public function getUpdated()
  318. {
  319. return $this->updated;
  320. }
  321. /**
  322. * Set txPower
  323. *
  324. * @param decimal $txPower
  325. * @return ONU
  326. */
  327. public function setTxPower($txPower)
  328. {
  329. $this->txPower = $txPower;
  330. return $this;
  331. }
  332. /**
  333. * Get txPower
  334. *
  335. * @return decimal
  336. */
  337. public function getTxPower()
  338. {
  339. return $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. return $this->rxPower;
  360. }
  361. /**
  362. * Set voltage
  363. *
  364. * @param decimal $voltage
  365. * @return ONU
  366. */
  367. public function setVoltage($voltage)
  368. {
  369. $this->voltage = $voltage;
  370. return $this;
  371. }
  372. /**
  373. * Get voltage
  374. *
  375. * @return decimal
  376. */
  377. public function getVoltage()
  378. {
  379. return $this->voltage;
  380. }
  381. /**
  382. * Set temperature
  383. *
  384. * @param decimal $temperature
  385. * @return ONU
  386. */
  387. public function setTemperature($temperature)
  388. {
  389. $this->temperature = $temperature;
  390. return $this;
  391. }
  392. /**
  393. * Get temperature
  394. *
  395. * @return decimal
  396. */
  397. public function getTemperature()
  398. {
  399. return $this->temperature;
  400. }
  401. /**
  402. * Set uptime
  403. *
  404. * @param string $uptime
  405. * @return ONU
  406. */
  407. public function setUptime($uptime)
  408. {
  409. $this->uptime = $uptime;
  410. return $this;
  411. }
  412. /**
  413. * Get uptime
  414. *
  415. * @return string
  416. */
  417. public function getUptime()
  418. {
  419. return $this->uptime;
  420. }
  421. }