Commit 6c5674e0 authored by vlad_burin's avatar vlad_burin
Browse files

Слияние с DeploymentQt

--HG--
branch : MockCompsTest
......@@ -122,7 +122,7 @@ void RdkQTcpThread::run()
}
}
PacketReaderUnlockEvent->exclusive_unlock();
//PacketReaderUnlockEvent->exclusive_unlock();
//in.commitTransaction();
......@@ -156,7 +156,7 @@ void RdkQTcpThread::run()
CalculationInProgress->set();
//Sleep(1);
// Sleep(1);
this->msleep(1);
this->msleep(10);
}
}
......@@ -383,7 +383,7 @@ int RdkQTcpClient::SendControlCommand(RDK::USerStorageXML &xml)
int RdkQTcpClient::FindPacketById(int cmdId, RDK::USerStorageXML &xml, bool erase_found, std::list<RDK::UTransferPacket>::iterator &it)
{
//if(WaitForSingleObject(Thread->PacketReaderUnlockEvent,INFINITE) != WAIT_TIMEOUT)
if(Thread->PacketReaderUnlockEvent->exclusive_lock())
if(Thread->PacketReaderUnlockEvent->shared_lock())
{
// ResetEvent(Thread->PacketReaderUnlockEvent);
std::list<RDK::UTransferPacket> &packetList=PacketReader.GetPacketList();
......@@ -422,7 +422,7 @@ int RdkQTcpClient::FindPacketById(int cmdId, RDK::USerStorageXML &xml, bool eras
int RdkQTcpClient::FindPacketById(int cmdId, RDK::USerStorageXML &xml, std::vector<RDK::UParamT> &binary_data, bool erase_found, std::list<RDK::UTransferPacket>::iterator &it)
{
//if(WaitForSingleObject(Thread->PacketReaderUnlockEvent,INFINITE) != WAIT_TIMEOUT)
if(Thread->PacketReaderUnlockEvent->exclusive_lock())
if(Thread->PacketReaderUnlockEvent->shared_lock())
{
// ResetEvent(Thread->PacketReaderUnlockEvent);
std::list<RDK::UTransferPacket> &packetList=PacketReader.GetPacketList();
......
......@@ -601,10 +601,71 @@ int Rpc_PrepareProject(int server_index, const char* &verbose_response, int time
return ProcessSimpleCommand("PrepareProject", server_index, -1, timeout, request, response);
}
int Rpc_OpenPreparedProject(int server_index, const char* &verbose_response, int timeout)
int Rpc_GetPreparationResult(int server_index, const char* &verbose_response, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("GetPreparationResult", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
QString qs = res_string.c_str();
QStringList spl = qs.split("|");
int rs = spl[0].trimmed().toInt();
verbose_response = spl[1].toUtf8().constData();
if(res)
return res;
}
int Rpc_OpenPreparedProject(int server_index, const char* &verbose_response, int timeout)
{
RDK::USerStorageXML request,response;
return ProcessSimpleCommand("OpenPreparedProject", server_index, -1, timeout, request, response);
}
int Rpc_RunPreparedProject(int server_index, int timeout)
{
RDK::USerStorageXML request,response;
return ProcessSimpleCommand("RunPreparedProject", server_index, -1, timeout, request, response);
}
int Rpc_GetCalculationState(int server_index,
int& calculation_state,
int& capture_state,
unsigned long long& capture_frid,
unsigned long long& capture_maxfrid,
const char* &message,
int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("GetCalculationState", server_index, -1, timeout, request, response);
if(res==0)
{
std::string res_string = response.ReadString("Data", "").c_str();
QString qsl = res_string.c_str();
if(qsl.length()>0)
{
QStringList spl = qsl.split("|");
if(spl.size()==5)
{
calculation_state = spl[0].toInt();
capture_state = spl[1].toInt();
capture_frid = spl[2].toInt();
capture_maxfrid = spl[3].toInt();
QString msg = spl[4];
message = msg.toUtf8().constData();
}
else
{
std::string s = "Wrong result: '" + res_string + "'";
message = s.c_str();
}
}
}
return res;
}
......@@ -107,6 +107,18 @@ int Rpc_GetLastError(int server_index, const char* &result, int timeout);
int Rpc_PrepareProject(int server_index, const char* &verbose_response, int timeout);
int Rpc_GetPreparationResult(int server_index, const char* &verbose_response, int timeout);
int Rpc_OpenPreparedProject(int server_index, const char* &verbose_response, int timeout);
int Rpc_RunPreparedProject(int server_index, int timeout);
int Rpc_GetCalculationState(int server_index,
int& calculation_state,
int& capture_state,
unsigned long long& capture_frid,
unsigned long long& capture_maxfrid,
const char* &message,
int timeout);
#endif // RDKQTCPCLIENTLIB_H
This diff is collapsed.
......@@ -26,11 +26,27 @@ struct MLlibDescr
std::string LibScriptFileTagName; //
std::string LibWeightFileTagName; //
std::string LibConfigFileTagName; //
std::string LibClassCountTagName; //
MLlibDescr(){
LibName="";
LibScriptFileTagName="";
LibWeightFileTagName="";
LibConfigFileTagName="";
LibClassCountTagName="";
}
};
struct CaptureLibDescr
{
std::string LibName;
std::string LibFrameIdStateName;
std::string LibCaptureStateTagName;
CaptureLibDescr(){
LibName="";
LibFrameIdStateName="";
LibCaptureStateTagName="";
}
};
......@@ -74,6 +90,12 @@ enum DeploymentState
DS_ProjectPrepared=13,
DS_OpenProject=14,
DS_ProjectOpened=15,
DS_Calculation=16,
DS_ProjectClosed=17,
DS_CopyResults=18,
DS_PackResults=19,
DS_UploadResults=20,
DS_UploadFinished=21,
DS_Error=100
};
......@@ -154,6 +176,55 @@ private:
CURLcode res;
};
class RDK_LIB_TYPE UProjectResultsUploadingThread: public QThread
{
Q_OBJECT
public:
UProjectResultsUploadingThread();
~UProjectResultsUploadingThread();
void run() override;
void SetProjectResultsDirPath(const QString& results_dir);
QString GetProjectResultsDirPath();
void SetStorageResultsDirPath(const QString& results_dir);
QString GetStorageResultsDirPath();
void SetDatabasePath(const QString& database_path);
QString GetDatabasePath();
void SetRemoteFtpPath(const QString& ftp_path);
QString GetRemoteFtpPath();
QString GetLastError();
DeploymentState GetUploadState();
private:
bool CopyResultsToDestinationDir();
bool ZipResults();
bool UploadResultsViaFtp();
bool RecursiveCopyFiles(const QString& src_dir_path, const QString& dts_dir_path);
private slots:
void processReadyReadStandardError();
void processReadyReadStandardOutput();
private:
QString projectResultsDir;
QString storageResultsDir;
QString databasePath;
QString remoteFtpPath;
QString lastError;
DeploymentState uploadState;
QProcess zip_process;
};
class RDK_LIB_TYPE UProjectDeployerQt: public UProjectDeployer
{
......@@ -164,13 +235,13 @@ protected: //
///
QSqlDatabase *db;
protected: //
//protected: //
protected: //
//
QString task_name; //
QString task_name; //
int task_id; // ( / )
int task_template_id; //
int task_weights_id; //
int task_src_type; // (0-, 1- )
......@@ -182,8 +253,9 @@ bool task_template_download_required;
QString task_template_name;
// ()
QString task_template_path;
// ZIP ,
//std::string task_template_zip_url;
// (project.ini, project_full.ini ) ,
// ,
QString task_template_file_name;
//
//
......@@ -192,10 +264,13 @@ QString task_weights_path;
bool task_weights_download_required;
// ( ,
bool task_weights_conf_download_required;
//
int weights_classes_number;
// -
QString task_weights_config_path;
// ( )
QString absolute_config_file;
// ( )
QString absolute_weights_file;
//
//std::string task_weights_zip_url;
......@@ -208,43 +283,55 @@ int task_script_id;
QString task_script_path;
//
bool task_script_download_required;
//
QString absolute_script_file;
//
//std::string task_script_zip_url;
//
// ( )
QString task_src_path;
// ( )
QString task_src_fullpath;
//
bool task_src_download_required;
// ( )
QString task_src_zip_url;
// ( {Database}/Temp )
QString download_temp_path;
// ( ,
// )
int task_src_frame_length;
// FTP
UProjectDeployProcessingThread *deployProcessingThread;
// ////
std::string lastError;
//
// GetPreparationResult
int preparationResult;
//
DeploymentState deploymentState;
// /
//
// ( )
std::map<std::string, MLlibDescr> file_tags;
std::vector<std::string> component_classes;
/*
//?
// (- 1)
std::string project_path;
std::string project_url;
std::map<std::string, CaptureLibDescr> capture_tags;
//
//std::vector<std::string> capture_classes;
//
std::string capture_class_name;
std::string capture_component_name;
//
int project_gt_id;
int project_sln_id;
int project_weigts_id;
int project_script_id;
*/
//
QDateTime processing_start_datetime;
QDateTime processing_end_datetime;
UProjectResultsUploadingThread *projectResultsUploadingThread;
protected://
......@@ -254,31 +341,59 @@ bool DestroyProcessingThread();
public: //
/// , ( )
virtual int StartProjectDeployment(int task_id);
virtual int StartProjectDeployment(int deploy_task_id);
/// :
/// 1.
/// 2. ?
/// 3.
virtual int PrepareProject(std::string &response);
///
virtual int GetPreparationResult(std::string &response);
///
virtual int OpenPreparedProject(std::string &response);
///
virtual int RunPreparedProject();
///
//virtual void SetDatabaseAccess(const std::string &db_address, const std::string &db_name, const std::string &db_login, const std::string &db_password);
//virtual void SetProjectIndices(int gt_id, int sln_id, int weights_id, int script_id);
///
/// , 2
/// ( )
virtual void AConnectToDatabase();
///
virtual int GetDeploymentState();
///
virtual int GetStageCap();
///
virtual int GetStageProgress();
///
virtual std::string GetLastError();
/// (, ?)
virtual std::string GetProjectFileName();
/// ( -2/0/1 )
virtual int GetCalculationState();
///
/// false
/// @state -
/// @frame_id -
virtual bool GetCaptureState(int &state, unsigned long long& frame_id, unsigned long long& max_frame_id);
///
/// false , true
/// @error -
virtual bool ProcessCalculationLog(std::string &error);
/// ,
virtual bool FinishCalculation();
/// ( Results) ,
///
virtual bool UploadCalculationResults();
/// ,
/// , ..
virtual bool CloseSolver();
public: //
///
QSqlDatabase *GetDatabase() {return db;};
// --------------------------
......@@ -304,26 +419,18 @@ int CloseMockProject();
/// ( )
//int OpenPreparedProject();
///
/// (0-2, Unknown, Fatal, Error)
/// : -1 - , 0-2 -
int AnalyzeLogForErrors(std::string &problem_string);
QString GetTimeStampInPSqlFormat(const QDateTime &now);
/// ,
///
//virtual int ReadIncomingBytes(std::string &bind, std::vector<unsigned char> &bytes);
};
}//namespace RDK
#endif
......@@ -7,7 +7,7 @@
#include "../UApplication.h"
#include "UServerTransportTcpQt.h"
#include <QDataStream>
#include <QCoreApplication>
///
//extern RDK::UApplication RdkApplication;
......@@ -82,13 +82,12 @@ UServerTransportTcpQt::UServerTransportTcpQt()
{
server=new QTcpServer();
connect(server, SIGNAL(newConnection()), this, SLOT(ServerNewConnection()));
commandQueueTimer = new QTimer(this);
commandQueueTimer->setInterval(10);
commandQueueTimer->setSingleShot(false);
commandQueueTimer->start();
connect(commandQueueTimer, SIGNAL(timeout()), this, SLOT(CommandQueueTimerTimeout()));
//commandQueueTimer = new QBasicTimer();
//commandQueueTimer->
//commandQueueTimer->moveToThread(QCoreApplication::instance()->thread());
//commandQueueTimer->setSingleShot(false);
//commandQueueTimer->start(10, this);
//connect(commandQueueTimer, SIGNAL(timeout()), this, SLOT(CommandQueueTimerTimeout()));
}
UServerTransportTcpQt::~UServerTransportTcpQt()
......@@ -216,6 +215,23 @@ void UServerTransportTcpQt::CommandQueueTimerTimeout()
}
}
void UServerTransportTcpQt::timerEvent(QTimerEvent *event)
{
try
{
Application->GetServerControl()->ProcessCommandQueue(Application->GetServerControl()->GetServerTransport());
}
catch(...)
{
Log_LogMessage(RDK_EX_WARNING, "UTcpServerControlWidget::TcpCommandTimerTick() Global catcher error");
}
}
void UServerTransportTcpQt::ProcessEventQueueExternally()
{
CommandQueueTimerTimeout();
}
int UServerTransportTcpQt::GetSocketState(std::string bind)
{
std::map<std::string, UServerSocketQt*>::iterator I = serverSockets.find(bind);
......@@ -293,7 +309,7 @@ int UServerTransportTcpQt::ReadIncomingBytes(std::string &bind, std::vector<unsi
QDataStream in;
in.setDevice(socket);
in.setVersion(QDataStream::Qt_5_0);
in.startTransaction();
//in.startTransaction();
char *buffer;
uint length=0;
in.readBytes(buffer, length);
......@@ -390,7 +406,7 @@ void UServerTransportTcpQt::SendResponseBuffer(std::vector<unsigned char> buffer
QDataStream out;
out.setDevice(socket);
out.setVersion(QDataStream::Qt_5_0);
out.startTransaction();
//out.startTransaction();
char* buf;
buf = new char[buffer.size()];
......
......@@ -63,6 +63,10 @@ public:
bool ServerIsActive();
virtual void timerEvent(QTimerEvent *event);
virtual void ProcessEventQueueExternally();
public slots:
void ServerNewConnection();
void SocketReadyRead(std::string bind);
......@@ -75,7 +79,7 @@ private:
std::string server_address;
int server_port;
QTimer *commandQueueTimer;
QBasicTimer *commandQueueTimer;
};
......
......@@ -101,6 +101,19 @@ int UProjectDeployer::OpenPreparedProject(std::string &response)
return -1;
}
int UProjectDeployer::GetPreparationResult(std::string &response)
{
response="base class called";
return -1;
}
///
int UProjectDeployer::RunPreparedProject()
{
return -1;
}
std::string UProjectDeployer::GetLastError()
{
return std::string();
......@@ -111,6 +124,39 @@ std::string UProjectDeployer::GetProjectFileName()
return std::string();
}
/// ( -2/0/1 )
int UProjectDeployer::GetCalculationState()
{
return -1;
}
///
/// false
/// @state -
/// @frame_id -
bool UProjectDeployer::GetCaptureState(int &state, unsigned long long& frame_id, unsigned long long &max_frame_id)
{
state=-1;
frame_id=-1;
max_frame_id=-1;
return false;
}
///
/// false , true
/// @error -
bool UProjectDeployer::ProcessCalculationLog(std::string &error)
{
error="ProcessCalculationLog in base class called!";
return false;
}
/// true /
/// false
/*bool UProjectDeployer::CaptureProcessingFinished(int frame_number)
{
return false;
}*/
/*
void UProjectDeployer::SetProjectIndices(int gt_id, int sln_id, int weights_id, int script_id)
{
......
......@@ -61,8 +61,12 @@ virtual int StartProjectDeployment(int task_id);
/// 2. ?
/// 3.
virtual int PrepareProject(std::string &response);
///
virtual int GetPreparationResult(std::string &response);
///
virtual int OpenPreparedProject(std::string &response);
///
virtual int RunPreparedProject();
/// -
virtual void SetDatabaseAccess(const std::string &db_address, const std::string &db_name, const std::string &db_login, const std::string &db_password);
......@@ -83,6 +87,30 @@ virtual void SetTempProjectDeploymentPath(const std::string &path);
virtual std::string GetTempProjectDeploymentPath();
/// ( -2/0/1 )
virtual int GetCalculationState();
///
/// false
/// @state -
/// @frame_id -
virtual bool GetCaptureState(int &state, unsigned long long& frame_id, unsigned long long& max_frame_id);
///
/// false , true
/// @error -
virtual bool ProcessCalculationLog(std::string &error);
/// true /
/// false
//virtual bool CaptureProcessingFinished(int frame_number);
/// ,