Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.1 today

Commit 40777f3e authored by Aleksandr Bakhshiev's avatar Aleksandr Bakhshiev
Browse files

Gui/Bcb/UEngineMonitroFrame & UServerControlForm partially moved to core

--HG--
branch : NewCore
parent 6892fdf975f7
......@@ -172,6 +172,10 @@
<CppCompile Include="..\..\..\Core\Application\URpcDecoder.cpp">
<BuildOrder>97</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\URpcDecoderCommon.cpp">
<DependentOn>..\..\..\Core\Application\URpcDecoderCommon.h</DependentOn>
<BuildOrder>115</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\URpcDecoderInternal.cpp">
<BuildOrder>98</BuildOrder>
</CppCompile>
......@@ -181,6 +185,18 @@
<CppCompile Include="..\..\..\Core\Application\URpcDispatcherQueues.cpp">
<BuildOrder>100</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\UServerControl.cpp">
<DependentOn>..\..\..\Core\Application\UServerControl.h</DependentOn>
<BuildOrder>112</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\UServerTransport.cpp">
<DependentOn>..\..\..\Core\Application\UServerTransport.h</DependentOn>
<BuildOrder>113</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Application\UServerTransportTcp.cpp">
<DependentOn>..\..\..\Core\Application\UServerTransportTcp.h</DependentOn>
<BuildOrder>114</BuildOrder>
</CppCompile>
<CppCompile Include="..\..\..\Core\Engine\Engine.cpp">
<BuildOrder>60</BuildOrder>
</CppCompile>
......@@ -943,12 +959,12 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
</Deployment>
</BorlandProject>
......
......@@ -25,7 +25,7 @@ namespace RDK {
// --------------------------
UApplication::UApplication(void)
{
Name="Application";
}
UApplication::~UApplication(void)
......@@ -48,6 +48,18 @@ bool UApplication::SetWorkDirectory(const std::string& value)
WorkDirectory=value;
return true;
}
//
bool UApplication::GetProjectOpenFlag(void) const
{
return ProjectOpenFlag;
}
bool UApplication::SetProjectOpenFlag(bool value)
{
ProjectOpenFlag=value;
return true;
}
// --------------------------
// --------------------------
......@@ -63,7 +75,13 @@ UEPtr<URpcDispatcher> UApplication::GetRpcDispatcher(void)
///
bool UApplication::SetRpcDispatcher(const UEPtr<URpcDispatcher> &value)
{
if(RpcDispatcher == value)
return true;
if(RpcDispatcher)
RpcDispatcher->SetApplication(0);
RpcDispatcher=value;
RpcDispatcher->SetApplication(this);
return true;
}
......@@ -77,12 +95,54 @@ UEPtr<UEngineControl> UApplication::GetEngineControl(void)
///
bool UApplication::SetEngineControl(const UEPtr<UEngineControl> &value)
{
if(EngineControl == value)
return true;
if(EngineControl)
EngineControl->PauseEngine(-1);
EngineControl=value;
return true;
}
///
UEPtr<UProject> UApplication::GetProject(void)
{
return Project;
}
///
///
bool UApplication::SetProject(const UEPtr<UProject> &value)
{
if(Project == value)
return true;
// TODO: - .
Project=value;
return true;
}
///
UEPtr<UServerControl> UApplication::GetServerControl(void) const
{
return ServerControl;
}
///
///
bool UApplication::SetServerControl(const UEPtr<UServerControl> &value)
{
if(ServerControl == value)
return true;
// TODO: -
if(ServerControl)
ServerControl->SetApplication(0);
ServerControl=value;
ServerControl->SetApplication(this);
return true;
}
///
bool UApplication::Init(void)
{
......@@ -137,6 +197,79 @@ bool UApplication::CloneProject(const std::string &filename)
}
// --------------------------
// --------------------------
//
// --------------------------
///
int UApplication::GetNumEngines(void) const
{
return EngineControl->GetNumEngines();
}
bool UApplication::SetNumEngines(int num)
{
if(!EngineControl->SetNumEngines(num))
return false;
if(!ServerControl->SetNumEngines(num))
return false;
return true;
}
bool UApplication::InsertEngine(int index)
{
if(!EngineControl->InsertEngine(index))
return false;
if(!ServerControl->InsertEngine(index))
return false;
return true;
}
bool UApplication::DeleteEngine(int index)
{
if(!EngineControl->DeleteEngine(index))
return false;
if(!ServerControl->DeleteEngine(index))
return false;
return true;
}
// --------------------------
// --------------------------
//
// --------------------------
/// , , engine_index == -1
void UApplication::StartEngine(int engine_index)
{
EngineControl->StartEngine(engine_index);
}
/// , , engine_index == -1
void UApplication::PauseEngine(int engine_index)
{
EngineControl->PauseEngine(engine_index);
}
/// , , engine_index == -1
void UApplication::ResetEngine(int engine_index)
{
EngineControl->ResetEngine(engine_index);
}
/// , , engine_index == -1
void UApplication::StepEngine(int engine_index)
{
EngineControl->StepEngine(engine_index);
}
// --------------------------
}
#endif
......
......@@ -8,12 +8,14 @@
#include "URpcDispatcher.h"
#include "URpcDecoder.h"
#include "URpcDecoderInternal.h"
#include "URpcDecoderCommon.h"
#include "URpcCommand.h"
#include "URpcCommandInternal.h"
#include "UEngineControl.h"
#include "UEngineControlThread.h"
#include "UEngineStateThread.h"
#include "UBroadcasterInterface.h"
#include "UServerControl.h"
#ifdef __BORLANDC__
#include "Bcb/Application.bcb.h"
......@@ -22,13 +24,17 @@
namespace RDK {
class UEngineControl;
class UServerControl;
class RDK_LIB_TYPE UApplication
class RDK_LIB_TYPE UApplication: public UAppController
{
protected: //
///
std::string WorkDirectory;
//
bool ProjectOpenFlag;
protected: //
///
UEPtr<URpcDispatcher> RpcDispatcher;
......@@ -39,6 +45,9 @@ UEPtr<UProject> Project;
///
UEPtr<UEngineControl> EngineControl;
///
UEPtr<UServerControl> ServerControl;
public:
// --------------------------
//
......@@ -53,6 +62,10 @@ virtual ~UApplication(void);
///
const std::string& GetWorkDirectory(void) const;
bool SetWorkDirectory(const std::string& value);
//
bool GetProjectOpenFlag(void) const;
bool SetProjectOpenFlag(bool value);
// --------------------------
// --------------------------
......@@ -72,6 +85,20 @@ virtual UEPtr<UEngineControl> GetEngineControl(void);
///
virtual bool SetEngineControl(const UEPtr<UEngineControl> &value);
///
virtual UEPtr<UProject> GetProject(void);
///
///
virtual bool SetProject(const UEPtr<UProject> &value);
///
virtual UEPtr<UServerControl> GetServerControl(void) const;
///
///
virtual bool SetServerControl(const UEPtr<UServerControl> &value);
///
virtual bool Init(void);
......@@ -98,6 +125,32 @@ virtual bool CloseProject(void);
///
virtual bool CloneProject(const std::string &filename);
// --------------------------
// --------------------------
//
// --------------------------
///
int GetNumEngines(void) const;
bool SetNumEngines(int num);
bool InsertEngine(int index);
bool DeleteEngine(int index);
// --------------------------
// --------------------------
//
// --------------------------
/// , , engine_index == -1
virtual void StartEngine(int engine_index);
/// , , engine_index == -1
virtual void PauseEngine(int engine_index);
/// , , engine_index == -1
virtual void ResetEngine(int engine_index);
/// , , engine_index == -1
virtual void StepEngine(int engine_index);
// --------------------------
};
}
......
......@@ -16,7 +16,11 @@ UEngineControl::UEngineControl(void)
EngineStateThread=0;
UseControllersMode=0;
InitFlag=false;
Name="EngineControl";
}
UEngineControl::~UEngineControl(void)
......@@ -45,6 +49,23 @@ void UEngineControl::SetThreadMode(int mode)
ThreadMode=mode;
}
///
/// 0 -
/// 1 -
int UEngineControl::GetUseControllersMode(void) const
{
return UseControllersMode;
}
void UEngineControl::SetUseControllersMode(int value)
{
if(UseControllersMode == value)
return;
PauseEngine(-1);
UseControllersMode=value;
return;
}
//
int UEngineControl::GetCalculateMode(int engine_index) const
......@@ -167,13 +188,6 @@ UEngineStateThread* UEngineControl::CreateEngineStateThread(UEngineControl* engi
return new UEngineStateThread(engine_control);
}
///
int UEngineControl::GetNumEngines(void) const
{
return ::GetNumEngines();
}
//
double UEngineControl::GetServerTimeStamp(int engine_index) const
{
......@@ -191,85 +205,6 @@ void UEngineControl::SetServerTimeStamp(int engine_index, double stamp)
EngineControlThreads[engine_index]->EnableCalculation();
}
bool UEngineControl::SetNumEngines(int num)
{
if(num == int(EngineControlThreads.size()))
return true;
int old_num=GetNumEngines();
::SetNumEngines(num);
int old_size=int(EngineControlThreads.size());
for(int i=num;i<old_size;i++)
{
delete EngineControlThreads[i];
}
EngineControlThreads.resize(num);
for(int i=old_size;i<num;i++)
{
EngineControlThreads[i]=CreateEngineThread(this, i);
#ifdef RDK_MUTEX_DEADLOCK_DEBUG
TUThreadInfo info;
info.Pid=ThreadChannels[i]->ThreadID;
info.Name=string("ThreadChannels ")+RDK::sntoa(i);
GlobalThreadInfoMap[info.Pid]=info;
#endif
EngineControlThreads[i]->SetPriority(RDK_DEFAULT_THREAD_PRIORITY);
// ThreadChannels[i]->FreeOnTerminate=false;
}
return true;
}
bool UEngineControl::InsertEngine(int index)
{
int old_num=GetNumEngines();
Engine_Add(index);
int new_num=GetNumEngines();
EngineControlThreads.resize(new_num);
for(int i=new_num-1;i>index;i--)
{
EngineControlThreads[i]=EngineControlThreads[i-1];
}
EngineControlThreads[index]=CreateEngineThread(this, index);
EngineControlThreads[index]->SetPriority(RDK_DEFAULT_THREAD_PRIORITY);
return true;
}
bool UEngineControl::DeleteEngine(int index)
{
int old_num=GetNumEngines();
// if(index<0 || index>=int(ThreadChannels.size()))
// return true;
if(EngineControlThreads[index])
{
// ThreadChannels[index]->Terminate();
delete EngineControlThreads[index];
EngineControlThreads[index]=0;
}
int del_res=Engine_Del(index);
int new_num=GetNumEngines();
if(new_num == old_num)
return true;
for(int i=index;i<new_num;i++)
{
EngineControlThreads[i]=EngineControlThreads[i+1];
}
EngineControlThreads.resize(new_num);
return true;
}
/// , , engine_index == -1
void UEngineControl::StartEngine(int engine_index)
{
......@@ -389,7 +324,9 @@ void UEngineControl::ResetEngine(int engine_index)
RDK::UIVisualControllerStorage::BeforeReset();
for(int i=0;i<GetNumEngines();i++)
{
RDK::UIControllerStorage::BeforeReset(i);
EngineControlThreads[i]->Reset();
RDK::UIControllerStorage::AfterReset(i);
}
RDK::UIVisualControllerStorage::AfterReset();
RDK::UIVisualControllerStorage::UpdateInterface();
......@@ -403,7 +340,9 @@ void UEngineControl::ResetEngine(int engine_index)
}
RDK::UIVisualControllerStorage::BeforeReset();
RDK::UIControllerStorage::BeforeReset(engine_index);
EngineControlThreads[engine_index]->Reset();
RDK::UIControllerStorage::AfterReset(engine_index);
RDK::UIVisualControllerStorage::AfterReset();
RDK::UIVisualControllerStorage::UpdateInterface();
}
......@@ -415,39 +354,62 @@ void UEngineControl::StepEngine(int engine_index)
if(engine_index>=GetNumEngines())
return;
if(engine_index == -1)
{
if(!Model_Check())
{
RDK::UIVisualControllerStorage::UpdateInterface();
return;
}
RDK::UIVisualControllerStorage::BeforeCalculate();
int use_controllers_mode=UseControllersMode;
if(use_controllers_mode == 0)
RDK::UIControllerStorage::BeforeCalculate(engine_index);
RDK::UIVisualControllerStorage::BeforeReset();
if(engine_index <0)
{
for(int i=0;i<GetNumEngines();i++)
{
EngineControlThreads[i]->Calculate();
if(MIsEngineInit(i) && MModel_Check(i))
{
EngineControlThreads[i]->EnableCalculation();
EngineControlThreads[i]->Calculate();
}
}
RDK::UIVisualControllerStorage::AfterReset();
RDK::UIVisualControllerStorage::UpdateInterface();
}
else
{
if(!MModel_Check(engine_index))
if(MIsEngineInit(engine_index) && MModel_Check(engine_index))
{
RDK::UIVisualControllerStorage::UpdateInterface();
return;
EngineControlThreads[engine_index]->EnableCalculation();
EngineControlThreads[engine_index]->Calculate();
}
RDK::UIVisualControllerStorage::BeforeReset();
EngineControlThreads[engine_index]->Calculate();
// RealLastCalculationTime[engine_index]=0;
RDK::UIVisualControllerStorage::AfterReset();
RDK::UIVisualControllerStorage::UpdateInterface();
}
if(use_controllers_mode == 0)
RDK::UIControllerStorage::AfterCalculate(engine_index);
SendMetadata();
RDK::UIVisualControllerStorage::AfterCalculate();
RDK::UIVisualControllerStorage::ResetCalculationStepUpdatedFlag();
RDK::UIVisualControllerStorage::UpdateInterface();
}
void UEngineControl::TimerExecute(void)
{
switch(ThreadMode)
{
case 0:
{
StepEngine(-1);
}
break;
case 1:
{
if(UseControllersMode == 0)
RDK::UIControllerStorage::AfterCalculate(-1);
SendMetadata();
RDK::UIVisualControllerStorage::AfterCalculate();
RDK::UIVisualControllerStorage::ResetCalculationStepUpdatedFlag();
RDK::UIVisualControllerStorage::UpdateInterface();
}
break;
}
}
///
/// 0 -
......@@ -477,97 +439,6 @@ void UEngineControl::StopEngineStateThread(void)
}
}
/*
///
double TUEngineMonitorFrame::GetSourceTime(int i) const
{
if(CalculationTimeSourceMode == 0)
{
TDateTime dt=TDateTime::CurrentDateTime();
return dt.operator double();
}
else
if(CalculationTimeSourceMode == 1 && i<ServerTimeStamp.size())
{
return ServerTimeStamp[i]/(86400.0*1000.0);
}
return 0.0;
} */
//---------------------------------------------------------------------------
/*
void __fastcall UEngineControl::TimerTimer(TObject *Sender)
{
switch(ChannelsMode)
{
case 0:
{
RDK::UIVisualControllerStorage::BeforeCalculate();
for(int i=0;i<GetNumEngines();i++)
{
if(!MIsEngineInit(i) || !MModel_Check(i))
{
continue;
}
if(CalculateMode[i] == 2)
{
if(!CalculateSignal[i])
continue;
}
else
if(CalculateMode[i] == 0)
{
if(RDK::CalcDiffTime(RDK::GetCurrentStartupTime(),RealLastCalculationTime[i])<MinInterstepsInterval[i])
continue;
}
CalculateSignal[i]=false;
if(CalculationTimeSourceMode == 0)
{
TDateTime dt=TDateTime::CurrentDateTime();
MModel_SetDoubleSourceTime(i,dt.operator double());
}
else
if(CalculationTimeSourceMode == 1)
MModel_SetDoubleSourceTime(i,ServerTimeStamp[i]/(86400.0*1000.0));
switch(CalculateMode[i])
{
case 0:
MEnv_Calculate(i,0);
break;
case 1: