Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Loader)
  6. *
  7. * @ Version : 2.0.0.4
  8. * @ Author : DeZender
  9. * @ Release on : 21.10.2015
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Tag {
  15.  
  16.  
  17. public static $tagsValue = array();
  18. public static $readError = array();
  19. public static $writeError = array();
  20. const READ_DELAY = 1;
  21. const STOP_READING = 60;
  22. const HISTORIAN_COMMAND = "ReadHistorian";
  23. const WRITE_TAGS_COMMAND = "WriteTags";
  24. const READ_TAGS_COMMAND = "ReadTags";
  25. const HISTORIAN_RATE_GAP = "0.8";
  26. const HISTORIAN_KEY = "vTcJhn8ufz8QceV";
  27.  
  28. public static function readHistorian() {
  29.  
  30. $locals = Local::getAll();
  31. if ($locals != null)
  32. {
  33. foreach ($locals as $local)
  34. {
  35. $localControlId = $local["controlId"];
  36. $bbIp = ObjMeta::getValueV($local["id"], "beagle_bone_ip");
  37. $bbPort = ObjMeta::getValueV($local["id"], "beagle_bone_port");
  38. $isAllowReadHistorian = ObjMeta::getValueV($local["id"], "read_historian");
  39. if (!($localControlId != null && $bbIp != null && $bbPort != null && $local["disabled"] != true && $isAllowReadHistorian == 1))
  40. {
  41. continue;
  42. }
  43. $package = new Package(Package::NTSC_ID, $localControlId, Package::REQUEST, self::HISTORIAN_COMMAND, null, null, null);
  44. $data = ClientSocket::read($package, $bbIp, $bbPort);
  45. if ($data === false)
  46. {
  47. self::$readError[$local["nameControl"]] = ClientSocket::$readError;
  48. continue;
  49. }
  50. if (!(isset($data[0]) && isset($data[1])))
  51. {
  52. continue;
  53. }
  54. $socket = $data[0];
  55. $output = $data[1];
  56. $historianData = self::processHistorianOutput($output, $local["id"]);
  57. if (HistorianValue::insertData($historianData))
  58. {
  59. ClientSocket::confirm($socket, true);
  60. continue;
  61. }
  62. ClientSocket::confirm($socket, false);
  63. self::$readError[$local["nameControl"]] = "Historian data error or can't not update to database";
  64. continue;
  65. }
  66. }
  67. return;
  68. }
  69.  
  70. public static function timeSync() {
  71.  
  72. $return = null;
  73. $locals = Local::getAll();
  74. if ($locals != null)
  75. {
  76. foreach ($locals as $local)
  77. {
  78. $localControlId = $local["controlId"];
  79. $bbIp = ObjMeta::getValueV($local["id"], "beagle_bone_ip");
  80. $bbPort = ObjMeta::getValueV($local["id"], "beagle_bone_port");
  81. if (!($localControlId != null && $bbIp != null && $bbPort != null && $local["disabled"] != true))
  82. {
  83. continue;
  84. }
  85. $package = new Package(Package::NTSC_ID, $localControlId, Package::REQUEST, self::WRITE_TAGS_COMMAND, self::createTimeSyncInput(), null, null);
  86. $return = ClientSocket::write($package, $bbIp, $bbPort);
  87. if (($return == false))
  88. {
  89. self::$writeError[$local["nameControl"]] = ClientSocket::$writeError;
  90. }
  91. continue;
  92. }
  93. }
  94. return;
  95. }
  96.  
  97. public static function rByName($objNameControl, $tagName, $isFrDb = false, $isFrStation = false) {
  98.  
  99. $objModel = Obj::getModelByNameControl($objNameControl);
  100. if ($objModel != null)
  101. {
  102. $tagInfo = ObjTag::getDataByName($objModel["id"], $tagName);
  103. }
  104. if (isset($tagInfo))
  105. {
  106. return self::rById($objModel, $tagInfo, $isFrDb, $isFrStation);
  107. }
  108. return;
  109. }
  110.  
  111. public static function rById($objModel, $tagInfo, $isFrDb = false, $isFrStation = false) {
  112.  
  113. $tagValue = null;
  114. $tagId = $tagInfo["id"];
  115. if (isset(self::$readError[$objModel->name_control]) && self::$readError[$objModel->name_control] != "")
  116. {
  117. return $tagValue;
  118. }
  119. if (Yii::app()->controller->isFirstRequest)
  120. {
  121. $isFrDb = true;
  122. }
  123. if ((($isFrStation != false) || !isset(self::$tagsValue[$tagId])) || self::$tagsValue[$tagId] == null)
  124. {
  125. $tagLastRead = LastReadValue::getData($tagId);
  126. if ($isFrDb == true)
  127. .........................................................................
  128. .........................................
  129. ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement