public function ProccessFlightData($extTempFileName, $extBort, $extVoyage, $extCopyCreationTime, $extCopyCreationDate, $extBruType, $extPerformer, $extDepartureAirport, $extArrivalAirport, $extAditionalInfo, $extUploadedFile, $extTotalPersentage)
 {
     $tempFile = $extTempFileName;
     $tempFilePath = UPLOADED_FILES_PATH . "proccessStatus/" . $tempFile;
     $bort = $extBort;
     $voyage = $extVoyage;
     $copyCreationTime = $extCopyCreationTime;
     $copyCreationDate = $extCopyCreationDate;
     $totalPersentage = $extTotalPersentage;
     if (strlen($copyCreationTime) > 5) {
         $startCopyTime = strtotime($copyCreationDate . " " . $copyCreationTime);
     } else {
         $startCopyTime = strtotime($copyCreationDate . " " . $copyCreationTime . ":00");
     }
     $bruType = $extBruType;
     $performer = $extPerformer;
     if ($performer == null) {
         $performer = $this->_user->username;
     }
     $departureAirport = $extDepartureAirport;
     $arrivalAirport = $extArrivalAirport;
     $uploadedFile = $extUploadedFile;
     $aditionalInfo = $extAditionalInfo;
     $Fl = new Flight();
     $flightId = $Fl->InsertNewFlight($bort, $voyage, $startCopyTime, $bruType, $performer, $departureAirport, $arrivalAirport, $uploadedFile, $aditionalInfo);
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $tableNameAp = $flightInfo['apTableName'];
     $tableNameBp = $flightInfo['bpTableName'];
     $flightId = $flightInfo['id'];
     $fileName = $flightInfo['fileName'];
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     $frameLength = $bruInfo['frameLength'];
     $stepLength = $bruInfo['stepLength'];
     $wordLength = $bruInfo['wordLength'];
     $headerLength = $bruInfo['headerLength'];
     $headerScr = $bruInfo['headerScr'];
     $frameSyncroCode = $bruInfo['frameSyncroCode'];
     //$cycloAp = $Bru->GetBruApGradi($bruType);
     $cycloApByPrefixes = $Bru->GetBruApCycloPrefixOrganized($bruType);
     $prefixFreqArr = $Bru->GetBruApCycloPrefixFreq($bruType);
     $cycloBpByPrefixes = $Bru->GetBruBpCycloPrefixOrganized($bruType);
     $prefixBpFreqArr = $Bru->GetBruBpCycloPrefixFreq($bruType);
     unset($Bru);
     $apTables = $Fl->CreateFlightParamTables($flightId, $cycloApByPrefixes, $cycloBpByPrefixes);
     unset($Fl);
     $Fr = new Frame();
     $syncroWordOffset = $Fr->SearchSyncroWord($frameSyncroCode, $headerLength, $fileName);
     $fileDesc = $Fr->OpenFile($fileName);
     $fileSize = $Fr->GetFileSize($fileName);
     $frameNum = 0;
     $totalFrameNum = floor(($fileSize - $syncroWordOffset) / $frameLength);
     $tmpProccStatusFilesDir = UPLOADED_FILES_PATH . "proccessStatus";
     if (!is_dir($tmpProccStatusFilesDir)) {
         mkdir($tmpProccStatusFilesDir);
     }
     $fileNameApArr = array();
     $fileNameApDescArr = array();
     foreach ($cycloApByPrefixes as $prefix => $item) {
         $fileNameAp = $tmpProccStatusFilesDir . "/" . $tableNameAp . "_" . $prefix . ".tbl";
         $fileNameApArr[$prefix] = $fileNameAp;
         $fileNameApDesc = fopen($fileNameAp, "w");
         $fileNameApDescArr[$prefix] = $fileNameApDesc;
     }
     $fileNameBpArr = array();
     $fileNameBpDescArr = array();
     foreach ($cycloBpByPrefixes as $prefix => $item) {
         $fileNameBp = $tmpProccStatusFilesDir . "/" . $tableNameBp . "_" . $prefix . ".tbl";
         $fileNameBpArr[$prefix] = $fileNameBp;
         $fileNameBpDesc = fopen($fileNameBp, "w");
         $fileNameBpDescArr[$prefix] = $fileNameBpDesc;
     }
     fseek($fileDesc, $syncroWordOffset, SEEK_SET);
     $curOffset = $syncroWordOffset;
     //file can be accesed by ajax while try to open what can cause warning
     error_reporting(E_ALL ^ E_WARNING);
     $algHeap = array();
     if ($frameSyncroCode != '') {
         while ($frameNum < $totalFrameNum && $curOffset < $fileSize) {
             $curOffset = ftell($fileDesc);
             $frame = $Fr->ReadFrame($fileDesc, $frameLength);
             $unpackedFrame = unpack("H*", $frame);
             if ($Fr->CheckSyncroWord($frameSyncroCode, $unpackedFrame[1]) === true) {
                 $splitedFrame = str_split($unpackedFrame[1], $wordLength * 2);
                 // div 2 because each byte 2 hex digits. $unpackedFrame[1] - dont know why [1], but hexdec($b[$i]) what we need
                 $apPhisicsByPrefixes = array();
                 foreach ($cycloApByPrefixes as $prefix => $cycloAp) {
                     $channelFreq = $prefixFreqArr[$prefix];
                     $phisicsFrame = $Fr->ConvertFrameToPhisics($splitedFrame, $startCopyTime, $stepLength, $channelFreq, $frameNum, $cycloAp, $algHeap);
                     $apPhisicsByPrefixes[$prefix] = $phisicsFrame;
                 }
                 $bpPhisicsByPrefixes = array();
                 foreach ($cycloBpByPrefixes as $prefix => $cycloBp) {
                     $channelFreq = $prefixBpFreqArr[$prefix];
                     $convBinFrame = $Fr->ConvertFrameToBinaryParams($splitedFrame, $frameNum, $startCopyTime, $stepLength, $channelFreq, $cycloBp, $apPhisicsByPrefixes, $algHeap);
                     $bpPhisicsByPrefixes[$prefix] = $convBinFrame;
                 }
                 $Fr->AppendFrameToFile($apPhisicsByPrefixes, $fileNameApDescArr);
                 $Fr->AppendFrameToFile($bpPhisicsByPrefixes, $fileNameBpDescArr);
                 $frameNum++;
             } else {
                 $syncroWordOffset = $Fr->SearchSyncroWord($frameSyncroCode, $curOffset, $fileName);
                 fseek($fileDesc, $syncroWordOffset, SEEK_SET);
                 $framesLeft = floor(($fileSize - $syncroWordOffset) / $frameLength);
                 $totalFrameNum = $frameNum + $framesLeft;
             }
             $tmpStatus = round($totalPersentage / $fileSize * $frameNum * $frameLength) . "%";
             $fp = fopen($tempFilePath, "w");
             fwrite($fp, json_encode($tmpStatus));
             fclose($fp);
         }
     } else {
         while ($frameNum < $totalFrameNum && $curOffset < $fileSize) {
             $curOffset = ftell($fileDesc);
             $frame = $Fr->ReadFrame($fileDesc, $frameLength);
             $unpackedFrame = unpack("H*", $frame);
             $splitedFrame = str_split($unpackedFrame[1], $wordLength * 2);
             // div 2 because each byte 2 hex digits. $unpackedFrame[1] - dont know why [1], but hexdec($b[$i]) what we need
             $apPhisicsByPrefixes = array();
             foreach ($cycloApByPrefixes as $prefix => $cycloAp) {
                 $channelFreq = $prefixFreqArr[$prefix];
                 $phisicsFrame = $Fr->ConvertFrameToPhisics($splitedFrame, $startCopyTime, $stepLength, $channelFreq, $frameNum, $cycloAp, $algHeap);
                 $apPhisicsByPrefixes[$prefix] = $phisicsFrame;
             }
             $bpPhisicsByPrefixes = array();
             foreach ($cycloBpByPrefixes as $prefix => $cycloBp) {
                 $channelFreq = $prefixBpFreqArr[$prefix];
                 $convBinFrame = $Fr->ConvertFrameToBinaryParams($splitedFrame, $frameNum, $startCopyTime, $stepLength, $channelFreq, $cycloBp, $apPhisicsByPrefixes, $algHeap);
                 $bpPhisicsByPrefixes[$prefix] = $convBinFrame;
             }
             $Fr->AppendFrameToFile($apPhisicsByPrefixes, $fileNameApDescArr);
             $Fr->AppendFrameToFile($bpPhisicsByPrefixes, $fileNameBpDescArr);
             $frameNum++;
             $tmpStatus = round($totalPersentage / $fileSize * $frameNum * $frameLength) . "%";
             $fp = fopen($tempFilePath, "w");
             fwrite($fp, json_encode($tmpStatus));
             fclose($fp);
         }
     }
     $tmpStatus = $this->lang->uploadingToDb;
     $fp = fopen($tempFilePath, "w");
     fwrite($fp, json_encode($tmpStatus));
     fclose($fp);
     error_reporting(E_ALL);
     //not need any more
     $Fr->CloseFile($fileDesc);
     unlink($uploadedFile);
     foreach ($fileNameApArr as $prefix => $fileNameAp) {
         fclose($fileNameApDescArr[$prefix]);
         $Fr->LoadFileToTable($tableNameAp . "_" . $prefix, $fileNameAp);
         unlink($fileNameAp);
     }
     foreach ($fileNameBpArr as $prefix => $fileNameBp) {
         fclose($fileNameBpDescArr[$prefix]);
         $Fr->LoadFileToTable($tableNameBp . "_" . $prefix, $fileNameBp);
         unlink($fileNameBp);
     }
     $this->_user->SetFlightAvaliable($this->_user->username, $flightId);
     $userId = $this->_user->GetUserIdByName($this->_user->username);
     $Fd = new Folder();
     $Fd->PutFlightInFolder($flightId, 0, $userId);
     //we put currently uploaded file in root
     unset($Fd);
     unset($Fr);
     unlink($tempFilePath);
     return $flightId;
 }