Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.1 today

Commit 939f39f5 authored by Aleksandr Bakhshiev's avatar Aleksandr Bakhshiev
Browse files

Core interface refactoring.

--HG--
branch : Refactoring
parent d39728f6032d
......@@ -255,7 +255,7 @@ bool UApplication::SetEngineControl(const UEPtr<UEngineControl> &value)
if(EngineControl)
{
EngineControl->PauseEngine(-1);
EngineControl->PauseChannel(-1);
EngineControl->SetApplication(0);
}
......@@ -327,11 +327,11 @@ bool UApplication::Init(void)
Engine_SetBufObjectsMode(1);
std::string font_path=extract_file_path(ApplicationFileName);
SetSystemDir(font_path.c_str());
Core_SetSystemDir(font_path.c_str());
// SetLogDir(font_path);
MLog_SetExceptionHandler(RDK_SYS_MESSAGE,(void*)ExceptionHandler);
MCore_ChannelInit(0,0,(void*)ExceptionHandler);
Engine_LoadFonts();
Core_LoadFonts();
SetWorkDirectory(font_path);
EngineControl->Init();
......@@ -345,7 +345,7 @@ bool UApplication::UnInit(void)
{
if(EngineControl)
{
EngineControl->PauseEngine(-1);
EngineControl->PauseChannel(-1);
EngineControl->StopEngineStateThread();
}
Sleep(10);
......@@ -368,7 +368,7 @@ bool UApplication::CreateProject(const std::string &file_name, RDK::TProjectConf
Project->SetProjectPath(ProjectPath);
ProjectFileName=file_name;
UApplication::SetNumEngines(project_config.NumChannels);
UApplication::SetNumChannels(project_config.NumChannels);
for(int i=0;i<project_config.NumChannels;i++)
{
......@@ -420,10 +420,10 @@ bool UApplication::OpenProject(const std::string &filename)
try{
EngineControl->SetNumEngines(config.NumChannels);
EngineControl->SetNumChannels(config.NumChannels);
ProjectXml.SelectNodeRoot("Project/MultiGeneral");
int selected_channel_index=ProjectXml.ReadInteger("SelectedEngineIndex",0);
int selected_channel_index=ProjectXml.ReadInteger("SelectedChannelIndex",0);
ProjectXml.SelectNodeRoot("Project/General");
......@@ -441,7 +441,7 @@ try{
EngineControl->SetCalculationTimeSource(i, config.CalcSourceTimeMode);
EngineControl->SetMinInterstepsInterval(i,channel_config.MinInterstepsInterval);
SelectEngine(i);
Core_SelectChannel(i);
if(!Core_IsChannelInit())
Core_ChannelInit(channel_config.PredefinedStructure,(void*)ExceptionHandler);
else
......@@ -505,10 +505,10 @@ try{
Sleep(0);
}
if(selected_channel_index>=GetNumEngines())
if(selected_channel_index>=GetNumChannels())
selected_channel_index=0;
SelectEngine(selected_channel_index);
Core_SelectChannel(selected_channel_index);
InterfaceXml.Destroy();
if(!config.InterfaceFileName.empty())
......@@ -520,7 +520,7 @@ try{
InterfaceXml.SelectNodeRoot(std::string("Interfaces"));
}
ServerControl->SetNumEngines(config.NumChannels);
ServerControl->SetNumChannels(config.NumChannels);
RDK::UIVisualControllerStorage::LoadParameters(InterfaceXml);
......@@ -557,7 +557,7 @@ bool UApplication::SaveProject(void)
if(!ProjectOpenFlag)
return false;
int selected_channel_index=GetSelectedEngineIndex();
int selected_channel_index=Core_GetSelectedChannelIndex();
Project->WriteToXml(ProjectXml);
......@@ -587,7 +587,7 @@ try
for(int i=0;i<config.NumChannels;i++)
{
SelectEngine(i);
Core_SelectChannel(i);
TProjectChannelConfig &channel_config=config.ChannelsConfig[i];
......@@ -612,7 +612,7 @@ try
Sleep(0);
}
SelectEngine(selected_channel_index);
Core_SelectChannel(selected_channel_index);
ProjectXml.SaveToFile(ProjectPath+ProjectFileName);
......@@ -633,7 +633,7 @@ bool UApplication::SaveProjectAs(const std::string &filename)
///
bool UApplication::CloseProject(void)
{
PauseEngine(-1);
PauseChannel(-1);
RDK::TProjectConfig config=GetProjectConfig();
......@@ -649,9 +649,9 @@ bool UApplication::CloseProject(void)
SetProjectPath("");
}
SetProjectOpenFlag(false);
for(int i=GetNumEngines()-1;i>=0;i--)
for(int i=GetNumChannels()-1;i>=0;i--)
{
SelectEngine(i);
Core_SelectChannel(i);
if(GetEngine())
{
Env_UnInit();
......@@ -671,20 +671,20 @@ bool UApplication::CloneProject(const std::string &filename)
bool UApplication::CloneProject(int source_id, int cloned_id)
{
if(source_id>=GetNumEngines() || cloned_id >= GetNumEngines())
if(source_id>=GetNumChannels() || cloned_id >= GetNumChannels())
return false;
/*
try {
RDK::TProjectConfig config=GetProjectConfig();
PredefinedStructure.resize(GetNumEngines());
PredefinedStructure.resize(GetNumChannels());
PredefinedStructure[cloned_id]=PredefinedStructure[source_id];
//
DefaultTimeStep.resize(GetNumEngines());
DefaultTimeStep.resize(GetNumChannels());
DefaultTimeStep[cloned_id]=DefaultTimeStep[source_id];
//
GlobalTimeStep.resize(GetNumEngines());
GlobalTimeStep.resize(GetNumChannels());
GlobalTimeStep[cloned_id]=GlobalTimeStep[source_id];
if(!ProjectXml.SelectNodeRoot("Project/General"))
......@@ -692,19 +692,19 @@ bool UApplication::CloneProject(int source_id, int cloned_id)
ReflectionFlag=ProjectXml.ReadBool("ReflectionFlag",true);
CalculationMode.resize(GetNumEngines());
CalculationMode.resize(GetNumChannels());
CalculationMode[cloned_id]=CalculationMode[source_id];
InitAfterLoadFlag.resize(GetNumEngines());
InitAfterLoadFlag.resize(GetNumChannels());
InitAfterLoadFlag[cloned_id]=InitAfterLoadFlag[source_id];
ResetAfterLoadFlag.resize(GetNumEngines());
ResetAfterLoadFlag.resize(GetNumChannels());
ResetAfterLoadFlag[cloned_id]=ResetAfterLoadFlag[source_id];
DebugModeFlag.resize(GetNumEngines());
DebugModeFlag.resize(GetNumChannels());
DebugModeFlag[cloned_id]=DebugModeFlag[source_id];
MinInterstepsInterval.resize(GetNumEngines());
MinInterstepsInterval.resize(GetNumChannels());
MinInterstepsInterval[cloned_id]=MinInterstepsInterval[source_id];
......@@ -712,8 +712,8 @@ bool UApplication::CloneProject(int source_id, int cloned_id)
//
ProjectXml.WriteInteger("ProjectAutoSaveStateFlag",ProjectAutoSaveStateFlag);
int selected_engine=GetSelectedEngineIndex();
SelectEngine(cloned_id);
int selected_engine=GetSelectedChannelIndex();
Core_SelectChannel(cloned_id);
String modelfilename;
if(source_id == 0)
......@@ -722,7 +722,7 @@ bool UApplication::CloneProject(int source_id, int cloned_id)
modelfilename=ProjectXml.ReadString(std::string("ModelFileName_")+RDK::sntoa(source_id),"").c_str();
if(!IsEngineInit())
if(!IsChannelInit())
GraphicalEngineInit(PredefinedStructure[cloned_id],NumEnvInputs,NumEnvOutputs,InputEnvImageWidth, InputEnvImageHeight ,ReflectionFlag,ExceptionHandler);
else
Env_SetPredefinedStructure(PredefinedStructure[cloned_id]);
......@@ -781,7 +781,7 @@ bool UApplication::CloneProject(int source_id, int cloned_id)
if(ResetAfterLoadFlag[cloned_id])
MEnv_Reset(cloned_id,0);
}
SelectEngine(selected_engine);
Core_SelectChannel(selected_engine);
}
catch(RDK::UException &exception)
{
......@@ -807,10 +807,10 @@ void UApplication::ReloadParameters(void)
if(!ProjectOpenFlag)
return;
int channel_index=GetSelectedEngineIndex();
int channel_index=Core_GetSelectedChannelIndex();
TProjectConfig config=Project->GetConfig();
std::string params_file_name=config.ChannelsConfig[GetSelectedEngineIndex()].ParametersFileName;
std::string params_file_name=config.ChannelsConfig[Core_GetSelectedChannelIndex()].ParametersFileName;
if(params_file_name.empty())
{
config.ChannelsConfig[channel_index].ParametersFileName="Parameters.xml";
......@@ -876,40 +876,40 @@ bool UApplication::SaveProjectConfig(void)
//
// --------------------------
///
int UApplication::GetNumEngines(void) const
int UApplication::GetNumChannels(void) const
{
return EngineControl->GetNumEngines();
return EngineControl->GetNumChannels();
}
bool UApplication::SetNumEngines(int num)
bool UApplication::SetNumChannels(int num)
{
int old_num=GetNumEngines();
if(!EngineControl->SetNumEngines(num))
int old_num=GetNumChannels();
if(!EngineControl->SetNumChannels(num))
return false;
if(!ServerControl->SetNumEngines(old_num))
if(!ServerControl->SetNumChannels(old_num))
return false;
return true;
}
bool UApplication::InsertEngine(int index)
bool UApplication::InsertChannel(int index)
{
if(!EngineControl->InsertEngine(index))
if(!EngineControl->InsertChannel(index))
return false;
if(!ServerControl->InsertEngine(index))
if(!ServerControl->InsertChannel(index))
return false;
return true;
}
bool UApplication::DeleteEngine(int index)
bool UApplication::DeleteChannel(int index)
{
if(!EngineControl->DeleteEngine(index))
if(!EngineControl->DeleteChannel(index))
return false;
if(!ServerControl->DeleteEngine(index))
if(!ServerControl->DeleteChannel(index))
return false;
return true;
......@@ -920,31 +920,31 @@ bool UApplication::DeleteEngine(int index)
//
// --------------------------
/// , , channel_index == -1
void UApplication::StartEngine(int channel_index)
void UApplication::StartChannel(int channel_index)
{
EngineControl->StartEngine(channel_index);
EngineControl->StartChannel(channel_index);
}
/// , , channel_index == -1
void UApplication::PauseEngine(int channel_index)
void UApplication::PauseChannel(int channel_index)
{
EngineControl->PauseEngine(channel_index);
EngineControl->PauseChannel(channel_index);
}
/// , , channel_index == -1
void UApplication::ResetEngine(int channel_index)
void UApplication::ResetChannel(int channel_index)
{
EngineControl->ResetEngine(channel_index);
EngineControl->ResetChannel(channel_index);
}
/// , , channel_index == -1
void UApplication::StepEngine(int channel_index)
void UApplication::StepChannel(int channel_index)
{
EngineControl->StepEngine(channel_index);
EngineControl->StepChannel(channel_index);
}
/// true
bool UApplication::IsEngineStarted(int channel_index)
bool UApplication::IsChannelStarted(int channel_index)
{
if(!EngineControl)
return false;
......@@ -1031,10 +1031,10 @@ bool UApplication::LoadStatesFromFile(int channel_index, const std::string file_
if(!data.empty())
{
int i=GetSelectedEngineIndex();
SelectEngine(channel_index);
int i=Core_GetSelectedChannelIndex();
Core_SelectChannel(channel_index);
Model_LoadComponentState("",&data[0]);
SelectEngine(i);
Core_SelectChannel(i);
return true;
}
return false;
......@@ -1045,8 +1045,8 @@ bool UApplication::SaveStatesToFile(int channel_index, const std::string file_na
if(!MCore_IsChannelInit(channel_index))
return false;
int i=GetSelectedEngineIndex();
SelectEngine(channel_index);
int i=Core_GetSelectedChannelIndex();
Core_SelectChannel(channel_index);
const char *p_buf=Model_SaveComponentState("");
bool res=true;
if(p_buf)
......@@ -1054,7 +1054,7 @@ bool UApplication::SaveStatesToFile(int channel_index, const std::string file_na
res=SaveFile(file_name,p_buf);
}
Engine_FreeBufString(p_buf);
SelectEngine(i);
Core_SelectChannel(i);
return res;
}
......
......@@ -216,29 +216,29 @@ virtual bool SaveProjectConfig(void);
//
// --------------------------
///
int GetNumEngines(void) const;
bool SetNumEngines(int num);
bool InsertEngine(int index);
bool DeleteEngine(int index);
int GetNumChannels(void) const;
bool SetNumChannels(int num);
bool InsertChannel(int index);
bool DeleteChannel(int index);
// --------------------------
// --------------------------
//
// --------------------------
/// , , channel_index == -1
virtual void StartEngine(int channel_index);
virtual void StartChannel(int channel_index);
/// , , channel_index == -1
virtual void PauseEngine(int channel_index);
virtual void PauseChannel(int channel_index);
/// , , channel_index == -1
virtual void ResetEngine(int channel_index);
virtual void ResetChannel(int channel_index);
/// , , channel_index == -1
virtual void StepEngine(int channel_index);
virtual void StepChannel(int channel_index);
/// true
virtual bool IsEngineStarted(int channel_index);
virtual bool IsChannelStarted(int channel_index);
// --------------------------
// --------------------------
......
......@@ -49,7 +49,7 @@ void UEngineControl::SetThreadMode(int mode)
if(ThreadMode == mode)
return;
PauseEngine(-1);
PauseChannel(-1);
ThreadMode=mode;
}
......@@ -66,7 +66,7 @@ void UEngineControl::SetUseControllersMode(int value)
if(UseControllersMode == value)
return;
PauseEngine(-1);
PauseChannel(-1);
UseControllersMode=value;
return;
}
......@@ -218,7 +218,7 @@ UEngineStateThread* UEngineControl::CreateEngineStateThread(UEngineControl* engi
//
double UEngineControl::GetServerTimeStamp(int channel_index) const
{
if(channel_index>=GetNumEngines())
if(channel_index>=GetNumChannels())
return 0.0;
return EngineControlThreads[channel_index]->GetServerTimeStamp();
......@@ -226,24 +226,24 @@ double UEngineControl::GetServerTimeStamp(int channel_index) const
void UEngineControl::SetServerTimeStamp(int channel_index, double stamp)
{
if(channel_index>=GetNumEngines())
if(channel_index>=GetNumChannels())
return;
EngineControlThreads[channel_index]->SetServerTimeStamp(stamp);
EngineControlThreads[channel_index]->EnableCalculation();
}
/// , , channel_index == -1
void UEngineControl::StartEngine(int channel_index)
void UEngineControl::StartChannel(int channel_index)
{
if(channel_index>=GetNumEngines())
if(channel_index>=GetNumChannels())
return;
EngineStateThread->RecreateEventsLogFile();
switch(ThreadMode)
{
case 0:
if(EngineControlThreads[GetSelectedEngineIndex()]->GetCalculateMode() == 1)
ResetEngine(-1);
if(EngineControlThreads[Core_GetSelectedChannelIndex()]->GetCalculateMode() == 1)
ResetChannel(-1);
// Timer->Interval=1;
// Timer->Enabled=true;
// for(size_t i=0; i<EngineControlThreads.size(); i++)
......@@ -276,9 +276,9 @@ void UEngineControl::StartEngine(int channel_index)
}
/// , , channel_index == -1
void UEngineControl::PauseEngine(int channel_index)
void UEngineControl::PauseChannel(int channel_index)
{
if(channel_index>=GetNumEngines())
if(channel_index>=GetNumChannels())
return;
// if(Timer->Enabled == false)
......@@ -336,9 +336,9 @@ void UEngineControl::PauseEngine(int channel_index)
}
/// , , channel_index == -1
void UEngineControl::ResetEngine(int channel_index)
void UEngineControl::ResetChannel(int channel_index)
{
if(channel_index>=GetNumEngines())
if(channel_index>=GetNumChannels())
return;
EngineStateThread->RecreateEventsLogFile();
......@@ -351,7 +351,7 @@ void UEngineControl::ResetEngine(int channel_index)
}
RDK::UIVisualControllerStorage::BeforeReset();
for(int i=0;i<GetNumEngines();i++)
for(int i=0;i<GetNumChannels();i++)
{
RDK::UIControllerStorage::BeforeReset(i);
EngineControlThreads[i]->Reset();
......@@ -378,9 +378,9 @@ void UEngineControl::ResetEngine(int channel_index)
}
/// , , channel_index == -1
void UEngineControl::StepEngine(int channel_index)
void UEngineControl::StepChannel(int channel_index)
{
if(channel_index>=GetNumEngines())
if(channel_index>=GetNumChannels())
return;
RDK::UIVisualControllerStorage::BeforeCalculate();
......@@ -390,9 +390,9 @@ void UEngineControl::StepEngine(int channel_index)
if(channel_index <0)
{
for(int i=0;i<GetNumEngines();i++)
for(int i=0;i<GetNumChannels();i++)
{
if(MIsEngineInit(i) && MModel_Check(i))
if(MCore_IsChannelInit(i) && MModel_Check(i))
{
EngineControlThreads[i]->EnableCalculation();
EngineControlThreads[i]->Calculate();
......@@ -401,7 +401,7 @@ void UEngineControl::StepEngine(int channel_index)
}
else
{
if(MIsEngineInit(channel_index) && MModel_Check(channel_index))
if(MCore_IsChannelInit(channel_index) && MModel_Check(channel_index))
{
EngineControlThreads[channel_index]->EnableCalculation();
EngineControlThreads[channel_index]->Calculate();
......@@ -417,7 +417,7 @@ void UEngineControl::StepEngine(int channel_index)
if(channel_index <0)
{
for(int i=0;i<GetNumEngines();i++)
for(int i=0;i<GetNumChannels();i++)
{
EngineControlThreads[i]->GetProfiler()->Calculate();
}
......@@ -435,7 +435,7 @@ void UEngineControl::TimerExecute(void)
{
case 0:
{
StepEngine(-1);
StepChannel(-1);
}
break;
......@@ -446,11 +446,11 @@ void UEngineControl::TimerExecute(void)
SendMetadata();
RDK::UIVisualControllerStorage::AfterCalculate();
RDK::UIVisualControllerStorage::ResetCalculationStepUpdatedFlag();
for(int i=0;i<GetNumEngines();i++)
for(int i=0;i<GetNumChannels();i++)
EngineControlThreads[i]->GetProfiler()->CalcProfilerOutputData();
RDK::UIVisualControllerStorage::UpdateInterface();
for(int i=0;i<GetNumEngines();i++)
for(int i=0;i<GetNumChannels();i++)
{
EngineControlThreads[i]->GetProfiler()->CalculateGui();
EngineControlThreads[i]->GetProfiler()->CalcProfilerOutputData();
......@@ -465,7 +465,7 @@ void UEngineControl::TimerExecute(void)
/// 1 -
int UEngineControl::CheckCalcState(int channel_id) const
{
if(channel_id<0 || channel_id>GetNumEngines())
if(channel_id<0 || channel_id>GetNumChannels())
return 0;
switch(ThreadMode)
......@@ -614,17 +614,17 @@ void UEngineControl::LoadParameters(RDK::USerStorageXML &xml)
///
// --------------------------
///
int UEngineControl::GetNumEngines(void) const
int UEngineControl::GetNumChannels(void) const
{
return ::GetNumEngines();
return ::Core_GetNumChannels();
}
bool UEngineControl::SetNumEngines(int num)
bool UEngineControl::SetNumChannels(int num)
{
if(num == int(EngineControlThreads.size()))
return true;
int old_num=GetNumEngines();
::SetNumEngines(num);
int old_num=GetNumChannels();
::Core_SetNumChannels(num);
int old_size=int(EngineControlThreads.size());
for(int i=num;i<old_size;i++)
......@@ -652,11 +652,11 @@ bool UEngineControl::SetNumEngines(int num)
return true;
}
bool UEngineControl::InsertEngine(int index)
bool UEngineControl::InsertChannel(int index)
{
int old_num=GetNumEngines();
Engine_Add(index);
int new_num=GetNumEngines();
int old_num=GetNumChannels();
Core_AddChannel(index);
int new_num=GetNumChannels();
EngineControlThreads.resize(new_num);
......@@ -676,9 +676,9 @@ bool UEngineControl::InsertEngine(int index)
return true;
}
bool UEngineControl::DeleteEngine(int index)
bool UEngineControl::DeleteChannel(int index)
{
int old_num=GetNumEngines();
int old_num=GetNumChannels();
// if(index<0 || index>=int(ThreadChannels.size()))
// return true;
......@@ -692,8 +692,8 @@ bool UEngineControl::DeleteEngine(int index)
EngineControlThreads[index]=0;
}
int del_res=Engine_Del(index);
int new_num=GetNumEngines();
int del_res=Core_DelChannel(index);
int new_num=Core_GetNumChannels();
if(new_num == old_num)
return true;
......
......@@ -127,16 +127,16 @@ double GetServerTimeStamp(int channel_index) const;
void SetServerTimeStamp(int channel_index, double stamp);
/// Запускает аналитику выбранного канала, или всех, если channel_index == -1
virtual void StartEngine(int channel_index);
virtual void StartChannel(int channel_index);
/// Останавливает аналитику выбранного канала, или всех, если channel_index == -1
virtual void PauseEngine(int channel_index);
virtual void PauseChannel(int channel_index);
/// Сбрасывает аналитику выбранного канала, или всех, если channel_index == -1
virtual void ResetEngine(int channel_index);
virtual void ResetChannel(int channel_index);
/// Делает шаг расчета выбранного канала, или всех, если channel_index == -1
virtual void StepEngine(int channel_index);
virtual void StepChannel(int channel_index);