mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
sendFileBlock_V3
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Core/recognizesystem.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
QObject(parent),
|
||||
@@ -22,6 +23,8 @@ void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versi
|
||||
this->client = client;
|
||||
}
|
||||
|
||||
const int BLOCK_SIZE = 1024 * 1024; // Размер блока
|
||||
|
||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
{
|
||||
qDebug() << "RecognizeThreadId " << QThread::currentThreadId();
|
||||
@@ -120,44 +123,67 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
tmpBlock.clear();
|
||||
sizeReceiveData = 0;
|
||||
countSend = 0;
|
||||
|
||||
file.open(QFile::WriteOnly);
|
||||
|
||||
file.open(QFile::Append);
|
||||
|
||||
forever
|
||||
if(! file.isOpen())
|
||||
{
|
||||
stream.startTransaction();
|
||||
stream >> tmpBlock;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
|
||||
if(socket->state() == QAbstractSocket::UnconnectedState){
|
||||
postProcessorSystem->socketDisable();
|
||||
//emit sigSocketDisabled();
|
||||
return;
|
||||
int marker = 0;
|
||||
QMessageBox::critical(nullptr, "P31", "POINT 31");
|
||||
}
|
||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
||||
if(! file.isWritable())
|
||||
{
|
||||
int marker = 0;
|
||||
QMessageBox::critical(nullptr, "P32", "POINT 32");
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
socket->waitForReadyRead(10);
|
||||
|
||||
if(socket->bytesAvailable() <= 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(fileSize - sizeReceiveData >= BLOCK_SIZE)
|
||||
tmpBlock = socket->read(BLOCK_SIZE);
|
||||
else
|
||||
tmpBlock = socket->read(fileSize - sizeReceiveData);
|
||||
|
||||
qint64 bytesReceived = tmpBlock.length();
|
||||
|
||||
if(bytesReceived <= 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
quint64 toFile = file.write(tmpBlock);
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: toFile :" + toFile);
|
||||
|
||||
sizeReceiveData += toFile;
|
||||
sizeReceiveData += bytesReceived;
|
||||
countSend++;
|
||||
|
||||
qint64 toFile = file.write(tmpBlock);
|
||||
|
||||
if(toFile <= 0)
|
||||
{
|
||||
//emit sigUpdateBytesAvailable();
|
||||
QMessageBox::critical(nullptr, "P2", "POINT 33");
|
||||
break;
|
||||
}
|
||||
|
||||
tmpBlock.clear();
|
||||
|
||||
if(sizeReceiveData == fileSize){
|
||||
if(sizeReceiveData == fileSize)
|
||||
{
|
||||
emit sigSendDebugLog(Tools::getTime() + "FINAL Count send: " + QString::number(countSend));
|
||||
emit sigSendDebugLog(Tools::getTime() + "FINAL Size received: " + QString::number(sizeReceiveData));
|
||||
emit sigSendDebugLog(Tools::getTime() + "FINAL File size" + QString::number(fileSize));
|
||||
emit sigUpdateBytesAvailable();
|
||||
break;
|
||||
}
|
||||
else if(sizeReceiveData > fileSize)
|
||||
{
|
||||
int marker = 0;
|
||||
QMessageBox::critical(nullptr, "P40", "POINT 34");
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
Reference in New Issue
Block a user