public static function parse($filePath, $folderSeq) { $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); echo "\n Total Rows Found:" . ($numLines - 2); $lineRow = $lineRow + 1; for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $totalChannels = (count($lineVals) - 3) / 2; $reportNo = substr($lineVals[1], 0, 3); if ($reportNo != "001") { continue; } $dateNumeric = $lineVals[2]; $dated = $dateNumeric; //self::DateConvert($dateNumeric); $channels = array(); $varLocation = 3; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelValue = $lineVals[$varLocation]; $channelValue = 0 + $channelValue; $channelValue = round($channelValue, 2); $channelStatus = $lineVals[$varLocation + 1]; $varLocation = $varLocation + 2; $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = $channelStatus; $channels[$channelNo] = $channelInfo; } $checkSum = $lineVals[0]; $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate($dated); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum($checkSum); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
public static function parse($filePath, $folderSeq) { //$content = file("../files/AQMS.WQD"); //$folderSeq = 9; //$filePath = "G:/accgagal.txt"; $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); $lineRow = 0; for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $totalChannels = (count($lineVals) - 3) / 3; $reportNo = $lineVals[1]; if ($reportNo != "1") { continue; } $dateStr = $lineVals[2]; $dated = new DateTime($dateStr); $channels = array(); $varLocation = 3; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelNumber = $lineVals[$varLocation++]; $channelValue = $lineVals[$varLocation++]; $channelStatus = $lineVals[$varLocation]; $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = $channelStatus; $channels[$channelNumber] = $channelInfo; $varLocation++; } $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
public static function parse($filePath, $folderSeq) { $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $totalChannels = count($lineVals) - 2; $dateStr = $lineVals[0]; $timeStr = $lineVals[1]; $dated = self::DateConvert($dateStr . $timeStr); $channels = array(); $varLocation = 2; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelValue = $lineVals[$varLocation++]; $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = 128; $channels[$channelNo] = $channelInfo; } $WQDData->setReportNo(1); $WQDData->setFolderSeq($folderSeq); //$WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setDataDate($dated); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
public static function parseWQD($filePath, $folderSeq) { //$content = file("../files/AQMS.WQD"); $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $channelNumbers = explode(',', trim($content[$lineRow])); $lineRow = $lineRow + 1; $channelNames = explode(',', trim($content[$lineRow])); $totalChannels = count($channelNumbers); $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); echo "\n Total Rows Found:" . ($numLines - 2); $lineRow = $lineRow + 1; for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $reportNo = substr($lineVals[0], 0, 3); if ($reportNo != "001") { continue; } $dateNumeric = substr($lineVals[0], 3, 12); //calculating first channel value $channelValue = substr($lineVals[0], 15); $channelStatus = $lineVals[1]; $dated = self::DateConvert($dateNumeric); $channels = array(); $varLocation = 1; foreach ($channelNumbers as $channel) { if ($varLocation != 1) { $channelValue = $lineVals[$varLocation]; $channelStatus = $lineVals[$varLocation + 1]; $varLocation = $varLocation + 2; } else { $varLocation++; } $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = $channelStatus; $channels[$channel] = $channelInfo; } $checkSum = $lineVals[$varLocation]; $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate($dated); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum($checkSum); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
public static function parse($filePath, $folderSeq) { //$content = file("../files/AQMS.WQD"); $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } //$channelNumbers = explode(',', trim($content[$lineRow])); // $lineRow = $lineRow +1; // $channelNames = explode(',', trim($content[$lineRow])); // $totalChannels = count($channelNumbers); $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); $lineRow = $lineRow + 1; for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $totalChannels = (count($lineVals) - 3) / 3; $reportNo = $lineVals[1]; if ($reportNo != "1") { continue; } $dateStr = $lineVals[2]; $dated = new DateTime($dateStr); //calculating first channel value $channels = array(); $varLocation = 4; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelValue = $lineVals[$varLocation++]; $channelStatus = $lineVals[$varLocation++]; $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = $channelStatus; $channels[$channelNo] = $channelInfo; $varLocation++; } //foreach($channelNumbers as $channel){ // if($varLocation != 1){ // $channelValue = $lineVals[$varLocation]; // $channelStatus = $lineVals[$varLocation+1]; // $varLocation = $varLocation +2; // }else{ // $varLocation++; // } // $channelInfo = array(); // $channelInfo['value'] = $channelValue; // $channelInfo['status'] = $channelStatus; // $channels[$channel] = $channelInfo; // } //$checkSum = $lineVals[$varLocation]; $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
$wqdChannel3 = new WQDChannel(); $wqdChannel3->setChannelName("testChannelName3"); $wqdChannel3->setChannelNumber("1233"); $wqdChannel3->setChannelStatus(13); $wqdChannel3->setChannelValue(1.23); $wqdChannelArr1[0] = $wqdChannel2; $wqdChannelArr1[1] = $wqdChannel3; //<------------------------> $wqdData = new WQDData(); $wqdDataarr = array(); $wqdData->setChannels($wqdChannelArr); $wqdData->setChecksum("testCheckSum"); $wqdData->setDataDate($date); $wqdData->setReportNo(1); $wqdData->setTotalChannels(count($wqdChannelArr)); $wqdData1 = new WQDData(); $wqdData1->setChannels($wqdChannelArr1); $wqdData1->setChecksum("testCheckSum1"); $wqdData1->setDataDate($date); $wqdData1->setReportNo(1); $wqdData1->setTotalChannels(count($wqdChannelArr1)); $wqdDataarr[0] = $wqdData; $wqdDataarr[1] = $wqdData1; $wqdFile = new WQDFile(); $wqdFile->setFileDate($date); $wqdFile->setFolderSeq(5); $wqdFile->setLocationSeq(4); $wqdFile->setName("testFileName.txt"); $wqdFile->setData($wqdDataarr); $WFDS = WQDFileDataStore::getInstance(); $WFDS->Save($wqdFile);
private function getFileDataObj($synchDate, $folderSeq) { $fileDataObj = new WQDData(); $fileDataObj->setChecksum(0); $syncdate = DateTime::createFromFormat('d-m-Y H:i:s', $synchDate); $d = $syncdate->format('Y-m-d H:i:s'); $fileDataObj->setDataDate($d); $fileDataObj->setFolderSeq($folderSeq); $fileDataObj->setReportNo(1); return $fileDataObj; }
public static function parse($filePath, $folderSeq) { $gagalFolderSeq = array(33, 40, 35); //$content = file("D:/dat.lsi"); //$folderSeq = 33; $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $line = rtrim($line, ','); $lineVals = explode(',', $line); $totalChannels = count($lineVals) - 2; $totalChannels = $totalChannels / 2; $reportNo = $lineVals[0]; if ($reportNo != "1") { continue; } $dateStr = $lineVals[1]; $dateStr = preg_replace('~\\x{00a0}~u', ' ', $dateStr); $dateStr = trim(html_entity_decode($dateStr)); if (in_array($folderSeq, $gagalFolderSeq)) { $dateStr = ParserStackLsi::convertDate($dateStr); } //$dateStr = ParserStackLsi::convertDate($dateStr); $dated = new DateTime($dateStr); $channels = array(); $varLocation = 2; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelValue = $lineVals[$varLocation]; $channelStatus = $lineVals[$varLocation + 1]; if ($channelStatus == "1" || $channelStatus == "Ok") { $channelStatus = "128"; } if ($channelStatus == "Abnormal") { $channelStatus = "0"; } $channelInfo = array(); $channelInfo['value'] = round($channelValue, 2); $channelInfo['status'] = $channelStatus; $channels[$channelNo] = $channelInfo; $varLocation++; $varLocation++; } $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }