Commit dc7dd582 authored by Alexab's avatar Alexab
Browse files

Merge with MockCompsTest

......@@ -58,6 +58,7 @@
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<BCC_wpch>false</BCC_wpch>
<TLIB_PageSize>8192</TLIB_PageSize>
<_TCHARMapping>char</_TCHARMapping>
<SanitizedProjectName>rdk_bcb_static</SanitizedProjectName>
......@@ -173,6 +174,10 @@
<CppCompile Include="..\..\..\Core\Application\UProject.cpp">
<BuildOrder>94</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\UProjectDeployer.cpp">
<DependentOn>..\..\..\Core\Application\UProjectDeployer.h</DependentOn>
<BuildOrder>127</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\URpcCommand.cpp">
<BuildOrder>95</BuildOrder>
</CppCompile>
......@@ -226,6 +231,21 @@
<CppCompile Include="..\..\..\Core\Engine\UAModel.cpp">
<BuildOrder>62</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UBasePropCreator.cpp">
<BuildOrder>125</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UBasePropCreatorMatrix.cpp">
<BuildOrder>130</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UBasePropCreatorStd.cpp">
<BuildOrder>131</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UBasePropCreatorTempl.cpp">
<BuildOrder>129</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UBasePropCreatorVector.cpp">
<BuildOrder>128</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UBinaryEnvSerialize.cpp">
<DependentOn>..\..\..\Core\Engine\UBinaryEnvSerialize.h</DependentOn>
<BuildOrder>63</BuildOrder>
......@@ -296,6 +316,9 @@
<DependentOn>..\..\..\Core\Engine\ULoggerEnv.h</DependentOn>
<BuildOrder>119</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UMockUNet.cpp">
<BuildOrder>126</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\UModule.cpp">
<BuildOrder>80</BuildOrder>
</CppCompile>
......@@ -1005,13 +1028,13 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
</Deployment>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
......
unix {
QMAKE_CXXFLAGS += -Wno-misleading-indentation
}
DEFINES += LIBRDK_LIBRARY_EXPORT
DEFINES += RDK_UNICODE_RUN
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ RdkQTcpThread::RdkQTcpThread()
}
RdkQTcpThread::RdkQTcpThread(QTcpSocket *socket, RDK::UTransferReader &packetReader, bool CreateSuspended, QObject *parent):
_socket(socket), QThread(parent), PacketReader(&packetReader)
_socket(socket), QThread(parent), PacketReader(&packetReader), Terminated(false)
{
CalcEnable = UCreateEvent(true);
CalcStarted = UCreateEvent(true);
......@@ -46,7 +46,7 @@ void RdkQTcpThread::AfterCalculate(void)
void RdkQTcpThread::run()
{
while(isRunning()) //???
while(!Terminated) //???
{
//if(WaitForSingleObject(CalcStarted,30) == WAIT_TIMEOUT)
// continue;
......@@ -122,7 +122,7 @@ void RdkQTcpThread::run()
}
}
PacketReaderUnlockEvent->exclusive_unlock();
//PacketReaderUnlockEvent->exclusive_unlock();
//in.commitTransaction();
......@@ -156,10 +156,16 @@ void RdkQTcpThread::run()
CalculationInProgress->set();
//Sleep(1);
// Sleep(1);
this->msleep(1);
this->msleep(10);
}
}
void RdkQTcpThread::MarkForDeletion()
{
//connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
Terminated = true;
}
//=====================================================================================================
......@@ -167,7 +173,9 @@ RdkQTcpClient::RdkQTcpClient()
{
//TODO: , ?
TcpSocket = new QTcpSocket();
Thread = new RdkQTcpThread(TcpSocket, PacketReader,false, this);
Thread = new RdkQTcpThread(TcpSocket, PacketReader,false, NULL);
connect(Thread, SIGNAL(finished()), this, SLOT(deleteLater()));
Thread->PacketReceivedEvent = UCreateEvent(true);
Thread->PacketReaderUnlockEvent = UCreateMutex();
EraseTimer = new QTimer(this);
......@@ -178,13 +186,16 @@ RdkQTcpClient::RdkQTcpClient()
RdkQTcpClient::~RdkQTcpClient()
{
EraseTimer->stop();
if(Thread!=NULL)
{
Thread->terminate();
Thread->CalculationInProgress->wait(-1);
UDestroyEvent(Thread->PacketReceivedEvent);
UDestroyMutex(Thread->PacketReaderUnlockEvent);
Thread->CalculationNotInProgress->reset();
//Thread->MarkForDeletion();
//Thread->exit(0);
delete Thread;
}
if(EraseTimer!=NULL)
......@@ -383,7 +394,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 +433,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();
......
......@@ -44,6 +44,8 @@ public: //
public://
void run() override;
void MarkForDeletion();
// --------------------------
//
// --------------------------
......
......@@ -258,6 +258,11 @@ int Rpc_UnInit(void)
return 0;
}
bool Rpc_IsInit()
{
return (ClientsArray.size()>0);
}
///
int Rpc_Ping(int server_index, int timeout)
......@@ -408,6 +413,11 @@ int Rpc_AddServer(void)
return 0;
}
int Rpc_LastServerId()
{
return (int)ClientsArray.size()-1;
}
int Rpc_DelServer(int server_index)
{
if((int)ClientsArray.size()-1 < server_index)
......@@ -420,12 +430,16 @@ int Rpc_DelServer(int server_index)
{
if(ClientsArray[server_index]->SocketIsConnected())
Rpc_Disconnect(server_index);
ClientsArray[server_index]->Thread->MarkForDeletion();
//ClientsArray[server_index]->Thread->exit(0);
//ClientsArray[server_index]->Thread->wait();
}
catch(QException &exception)
{
return RDK_RPC_CONNECTION_ERROR;
}
delete ClientsArray[server_index];
//26.11.2020 - dele
//delete ClientsArray[server_index];
ClientsArray.erase(ClientsArray.begin()+server_index);
return 0;
......@@ -449,6 +463,12 @@ int Rpc_StopChannel(int server_index, int channel_index, int timeout)
return ProcessSimpleCommand("StopChannel", server_index, channel_index, timeout, request, response);
}
int Rpc_StartTraining(int server_index, int channel_index, int timeout)
{
RDK::USerStorageXML request, response;
return ProcessSimpleCommand("StartTraining", server_index, channel_index, timeout, request, response);
}
int Rpc_GetNumChannels(int server_index, int &results, int timeout)
{
RDK::USerStorageXML request,response;
......@@ -491,6 +511,74 @@ int Rpc_GetChannelName(int server_index, int channel_index, const char* &result,
return 0;
}
int Rpc_GetLastError(int server_index, const char* &result, int timeout)
{
RDK::USerStorageXML request,response;
int res=ProcessSimpleCommand("GetLastError", server_index, -1, timeout, request, response);
if(res)
return res;
static std::string res_string;
res_string=response.ReadString("Data", "").c_str();
result=res_string.c_str();
return 0;
}
int Rpc_GetDeploymentState(int server_index, int &dp_state, int& dp_progress, int& dp_cap, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
request.Create("Request");
request.WriteInteger("Test", -1);
int res=ProcessSimpleCommand("GetDeploymentState", server_index, -1, timeout, request, response);
if(res)
return res;
static std::string res_string;
res_string=response.ReadString("Data", "").c_str();
QString rs_str = res_string.c_str();
dp_state = -1;
dp_progress = -1;
dp_cap = -1;
last_error = "Wrong dep state data received";
static std::string le_string;
// qDebug()<<"rs_str = "<<rs_str;
if(rs_str.size()>0)
{
QStringList rs_split = rs_str.split("|-|");
if(rs_split.size()>=4)
{
dp_state = rs_split[0].toInt();
dp_progress = rs_split[1].toInt();
dp_cap = rs_split[2].toInt();
qDebug()<<"rs_split[3] = "<<rs_split[3];
qDebug()<<"rs_split[3].toUtf8().constData() = "<<rs_split[3].toUtf8().constData();
le_string = rs_split[3].toUtf8().constData();
last_error = le_string.c_str();
}
}
return res;
}
int Rpc_GetLastError(int server_index, int channel_indes, int timeout, const char* &err_str)
{
RDK::USerStorageXML request,response;
request.Create("Request");
int res=ProcessSimpleCommand("GetLastError", server_index, -1, timeout, request, response);
/*if(res)
return res;*/
static std::string res_string;
res_string=response.ReadString("Data", "").c_str();
err_str = res_string.c_str();
return res;
}
int Rpc_SetChannelName(int server_index, int channel_index, const char* channel_name, int timeout)
{
RDK::USerStorageXML request,response;
......@@ -516,3 +604,200 @@ int Rpc_LoadProject(int server_index, const char* project_path, int timeout)
request.WriteString("FileName", project_path);
return ProcessSimpleCommand("LoadProject", server_index, -1, timeout, request, response);
}
int Rpc_DeployProject(int server_index, int task_index, int &resp, int timeout)
{
RDK::USerStorageXML request,response;
request.Create("Request");
request.WriteInteger("TaskId", task_index);
int res=ProcessSimpleCommand("DeployProject", server_index, 0, timeout, request, response);
static std::string res_string;
res_string=response.ReadString("Data", "").c_str();
resp = atoi(res_string.c_str());
//result=res_string.c_str();
if(res)
return res;
}
int Rpc_PrepareProject(int server_index, const char* &verbose_response, int timeout)
{
RDK::USerStorageXML request,response;
return ProcessSimpleCommand("PrepareProject", server_index, -1, timeout, request, response);
}
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();
static std::string msg="";
QString qs = res_string.c_str();
QStringList spl = qs.split("|-|");
int rs = spl[0].trimmed().toInt();
msg = spl[1].toUtf8().constData();
verbose_response = msg.c_str();
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);
static std::string s="";
if(res==0)
{
std::string res_string = response.ReadString("Data", "").c_str();
QString qsl = res_string.c_str();
qDebug()<<qsl;
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];
s = msg.toUtf8().constData();
message = s.c_str();
}
else
{
s = "Wrong result: '" + res_string + "'";
message = s.c_str();
}
}
}
return res;
}
int Rpc_FinishCalculation(int server_index, bool& result, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("FinishCalculation", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
static std::string le="";
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|-|");
if(spl.size()>=2)
{
result = spl[0].trimmed().toInt();
le = spl[1].toUtf8().constData();
last_error = le.c_str();
}
}
return res;
}
int Rpc_UploadCalculationResults(int server_index, bool& result, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("UploadCalculationResults", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|-|");
if(spl.size()>=2)
{
result = spl[0].trimmed().toInt();
if(!result)
last_error = spl[1].toUtf8().constData();
}
}
return res;
}
int Rpc_GetUploadState(int server_index, int& upload_state, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("GetUploadState", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
static std::string le_str="";
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|-|");
if(spl.size()>=2)
{
upload_state = spl[0].trimmed().toInt();
le_str = spl[1].toUtf8().constData();
last_error = le_str.c_str();
}
}
if(res)
return res;
}
int Rpc_CloseSolver(int server_index, bool& result, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("CloseSolver", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|-|");
if(spl.size()>=2)
{
result = spl[0].trimmed().toInt();
if(!result)
last_error = spl[1].toUtf8().constData();
}
}
return res;
}
......@@ -64,6 +64,8 @@ int Rpc_Init(int num_serverPtz_MoveZoom);
int Rpc_UnInit(void);
bool Rpc_IsInit();
///
int Rpc_Ping(int server_index, int timeout);
......@@ -75,12 +77,16 @@ int Rpc_AddServer(void);
int Rpc_DelServer(int server_index);
int Rpc_LastServerId();
///////////////
int Rpc_StartChannel(int server_index, int channel_index, int timeout);
int Rpc_StopChannel(int server_index, int channel_index, int timeout);
int Rpc_StartTraining(int server_index, int channel_index, int timeout);
int Rpc_ResetChannel(int server_index, int channel_index, int timeout);
int Rpc_GetNumChannels(int server_index, int &results, int timeout);
......@@ -89,10 +95,41 @@ int Rpc_SetNumChannels(int server_index, int num_channels, int timeout);
int Rpc_GetChannelName(int server_index, int channel_index, const char* &result, int timeout);
int Rpc_GetDeploymentState(int server_index, int &dp_state, int& dp_progress, int& dp_cap, const char *&last_error, int timeout);
int Rpc_SetChannelName(int server_index, int channel_index, const char* channel_name, int timeout);
int Rpc_GetLastError(int server_index, const char* &result, int timeout);
int Rpc_SaveProject(int server_index, int timeout);
int Rpc_LoadProject(int server_index, const char* project_path, int timeout);
int Rpc_DeployProject(int server_index, int task_index, int &resp, int timeout=-1);
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);
int Rpc_FinishCalculation(int server_index, bool& result, const char* &last_error, int timeout);
int Rpc_UploadCalculationResults(int server_index, bool& result, const char* &last_error, int timeout);
int Rpc_GetUploadState(int server_index, int& upload_state, const char* &last_error, int timeout);
int Rpc_CloseSolver(int server_index, bool& result, const char* &last_error, int timeout);
#endif // RDKQTCPCLIENTLIB_H
......@@ -10,8 +10,12 @@ DEFINES += RDK_QT
CONFIG += c++11
INCLUDEPATH += ../RdkQTcpClientLib
LIBS+= -L../../../Bin/Platform/Linux/RdkQTcpClientLib -lRdkQTcpClientLib
linux {
LIBS+= -L../../../Bin/Platform/Linux/RdkQTcpClientLib -lRdkQTcpClientLib
} else:windows {
LIBS+= -L../../../Bin/Platform/Win/RdkQTcpClientLib -lRdkQTcpClientLib
}
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
......
......@@ -213,3 +213,15 @@ void RdkQTcpClientWidget::onPushButtonPingClick()
std::cerr<<"onPushButtonTestClick sum: "<<sum;
}
*/
void RdkQTcpClientWidget::on_pushButtonStartTraining_clicked()
{
const char* serverAnswer=NULL;
int res=Rpc_StartTraining(0, ui->lineEditChannelIndex->text().toInt(), 60000);
if(WriteLogError(res))
{
serverAnswer=Rpc_GetServerAnswerDebug(0);
if(serverAnswer != NULL && ui->checkBoxWriteServerResponse->isChecked())