Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Loader)
- *
- * @ Version : 2.0.0.4
- * @ Author : DeZender
- * @ Release on : 21.10.2015
- * @ Official site : http://DeZender.Net
- *
- */
- class Tag {
- public static $tagsValue = array();
- public static $readError = array();
- public static $writeError = array();
- const READ_DELAY = 1;
- const STOP_READING = 60;
- const HISTORIAN_COMMAND = "ReadHistorian";
- const WRITE_TAGS_COMMAND = "WriteTags";
- const READ_TAGS_COMMAND = "ReadTags";
- const HISTORIAN_RATE_GAP = "0.8";
- const HISTORIAN_KEY = "vTcJhn8ufz8QceV";
- public static function readHistorian() {
- $locals = Local::getAll();
- if ($locals != null)
- {
- foreach ($locals as $local)
- {
- $localControlId = $local["controlId"];
- $bbIp = ObjMeta::getValueV($local["id"], "beagle_bone_ip");
- $bbPort = ObjMeta::getValueV($local["id"], "beagle_bone_port");
- $isAllowReadHistorian = ObjMeta::getValueV($local["id"], "read_historian");
- if (!($localControlId != null && $bbIp != null && $bbPort != null && $local["disabled"] != true && $isAllowReadHistorian == 1))
- {
- continue;
- }
- $package = new Package(Package::NTSC_ID, $localControlId, Package::REQUEST, self::HISTORIAN_COMMAND, null, null, null);
- $data = ClientSocket::read($package, $bbIp, $bbPort);
- if ($data === false)
- {
- self::$readError[$local["nameControl"]] = ClientSocket::$readError;
- continue;
- }
- if (!(isset($data[0]) && isset($data[1])))
- {
- continue;
- }
- $socket = $data[0];
- $output = $data[1];
- $historianData = self::processHistorianOutput($output, $local["id"]);
- if (HistorianValue::insertData($historianData))
- {
- ClientSocket::confirm($socket, true);
- continue;
- }
- ClientSocket::confirm($socket, false);
- self::$readError[$local["nameControl"]] = "Historian data error or can't not update to database";
- continue;
- }
- }
- return;
- }
- public static function timeSync() {
- $return = null;
- $locals = Local::getAll();
- if ($locals != null)
- {
- foreach ($locals as $local)
- {
- $localControlId = $local["controlId"];
- $bbIp = ObjMeta::getValueV($local["id"], "beagle_bone_ip");
- $bbPort = ObjMeta::getValueV($local["id"], "beagle_bone_port");
- if (!($localControlId != null && $bbIp != null && $bbPort != null && $local["disabled"] != true))
- {
- continue;
- }
- $package = new Package(Package::NTSC_ID, $localControlId, Package::REQUEST, self::WRITE_TAGS_COMMAND, self::createTimeSyncInput(), null, null);
- $return = ClientSocket::write($package, $bbIp, $bbPort);
- if (($return == false))
- {
- self::$writeError[$local["nameControl"]] = ClientSocket::$writeError;
- }
- continue;
- }
- }
- return;
- }
- public static function rByName($objNameControl, $tagName, $isFrDb = false, $isFrStation = false) {
- $objModel = Obj::getModelByNameControl($objNameControl);
- if ($objModel != null)
- {
- $tagInfo = ObjTag::getDataByName($objModel["id"], $tagName);
- }
- if (isset($tagInfo))
- {
- return self::rById($objModel, $tagInfo, $isFrDb, $isFrStation);
- }
- return;
- }
- public static function rById($objModel, $tagInfo, $isFrDb = false, $isFrStation = false) {
- $tagValue = null;
- $tagId = $tagInfo["id"];
- if (isset(self::$readError[$objModel->name_control]) && self::$readError[$objModel->name_control] != "")
- {
- return $tagValue;
- }
- if (Yii::app()->controller->isFirstRequest)
- {
- $isFrDb = true;
- }
- if ((($isFrStation != false) || !isset(self::$tagsValue[$tagId])) || self::$tagsValue[$tagId] == null)
- {
- $tagLastRead = LastReadValue::getData($tagId);
- if ($isFrDb == true)
- .........................................................................
- .........................................
- ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement