Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

Commit 52fb5a49 authored by Aleksandr Bakhshiev's avatar Aleksandr Bakhshiev
Browse files

Some errors fixed.

--HG--
branch : NewCore
parent e893e67880ed
......@@ -91,6 +91,7 @@ bool UApplication::SetProjectPath(const std::string& value)
if(ProjectPath == value)
return true;
ProjectPath=value;
EngineControl->GetEngineStateThread()->SetLogPath(ProjectPath);
CalcAppCaption();
return true;
}
......@@ -206,10 +207,10 @@ bool UApplication::SetEngineControl(const UEPtr<UEngineControl> &value)
}
///
UEPtr<UProject> UApplication::GetProject(void)
/*UEPtr<UProject> UApplication::GetProject(void)
{
return Project;
}
} */
///
///
......@@ -234,7 +235,11 @@ bool UApplication::SetProjectConfig(const TProjectConfig& value)
{
if(!Project)
return false;
return Project->SetConfig(value);
if(!Project->SetConfig(value))
return false;
EngineControl->GetEngineStateThread()->SetLogFlag(value.EventsLogFlag);
return true;
}
///
......@@ -341,11 +346,13 @@ bool UApplication::OpenProject(const std::string &filename)
Project->ReadFromXml(ProjectXml);
TProjectConfig config=Project->GetConfig();
EngineControl->GetEngineStateThread()->SetLogFlag(config.EventsLogFlag);
EngineControl->GetEngineStateThread()->SetLogPath(ProjectPath);
// ProjectXml.SelectNodeRoot("Project/MultiGeneral");
// int engines_mode=ProjectXml.ReadInteger("EnginesMode",0);
EngineControl->SetThreadMode(config.MultiThreadingMode);
CalcAppCaption();
/*
UShowProgressBarForm->SetBarHeader(1,Lang_LoadingData);
UShowProgressBarForm->SetBarHeader(2,Lang_Total);
......
......@@ -141,7 +141,7 @@ virtual UEPtr<UEngineControl> GetEngineControl(void);
virtual bool SetEngineControl(const UEPtr<UEngineControl> &value);
///
virtual UEPtr<UProject> GetProject(void);
//virtual UEPtr<UProject> GetProject(void);
///
///
......
......@@ -57,6 +57,7 @@ UEngineStateThread::UEngineStateThread(UEngineControl* engine_control)
NumAvgIterations=200;
AvgThreshold=5.0;
EventsLogFlag=true;
LogFlag=true;
}
UEngineStateThread::~UEngineStateThread(void)
......@@ -85,6 +86,37 @@ UEngineStateThread::~UEngineStateThread(void)
// --------------------------
// Управление параметрами
// --------------------------
/// Путь до папки с логами
std::string UEngineStateThread::GetLogPath(void) const
{
return LogPath;
}
bool UEngineStateThread::SetLogPath(const std::string& value)
{
if(LogPath == value)
return true;
LogPath=value;
RecreateEventsLogFile();
return true;
}
/// Флаг разрешения логгирования
bool UEngineStateThread::GetLogFlag(void) const
{
return LogFlag;
}
bool UEngineStateThread::SetLogFlag(bool value)
{
if(LogFlag == value)
return true;
LogFlag=value;
RecreateEventsLogFile();
return true;
}
// --------------------------
// --------------------------
......@@ -243,7 +275,21 @@ void UEngineStateThread::RecreateEventsLogFile(void)
delete EventsLogFile;
EventsLogFile=0;
}
EventsLogFlag=true;
/// Сохраняем лог в файл если это необходимо
if(!LogFlag)
EventsLogFlag=false;
else
EventsLogFlag=true;
if(LogFlag && !LogPath.Get().empty())
{
if(CreateNewDirectory((LogPath.Get()+"EventsLog").c_str()) != 0)
EventsLogFlag=false;
EventsLogFilePath=LogPath.Get()+"EventsLog/";
}
CalculationNotInProgress->set();
}
......@@ -327,38 +373,11 @@ void UEngineStateThread::ProcessLog(void)
try
{
if(global_error_level>=0 && global_error_level<3)
/* if(global_error_level>=0 && global_error_level<3)
{
EngineControl->GetApplication()->PauseEngine(-1);
/* TTabSheet *tab=dynamic_cast<TTabSheet*>(Parent);
if(tab)
{
tab->PageControl->ActivePage=tab;
}
else
{
Show();
WindowState=wsNormal;
} */
}
if(EngineControl->GetApplication())
{
/// Сохраняем лог в файл если это необходимо
RDK::TProjectConfig config=EngineControl->GetApplication()->GetProject()->GetConfig();
if(EventsLogFlag)
EventsLogFlag=config.EventsLogFlag;
if(!UnsentLog.empty() && EventsLogFlag && !EngineControl->GetApplication()->GetProjectPath().empty())
{
if(CreateNewDirectory((EngineControl->GetApplication()->GetProjectPath()+"EventsLog").c_str()) != 0)
EventsLogFlag=false;
EventsLogFilePath=EngineControl->GetApplication()->GetProjectPath()+"EventsLog/";
}
}
*/
bool is_logged=false;
while(!UnsentLog.empty())
{
......@@ -371,7 +390,7 @@ void UEngineStateThread::ProcessLog(void)
time_t time_data;
time(&time_data);
file_name=RDK::get_text_time(time_data, '.', '_');
EventsLogFile= new std::ofstream((EventsLogFilePath+file_name+".txt").c_str(),std::ios_base::out | std::ios_base::app);
EventsLogFile= new std::ofstream((EventsLogFilePath.Get()+file_name+".txt").c_str(),std::ios_base::out | std::ios_base::app);
}
if(*EventsLogFile)
......@@ -380,7 +399,6 @@ void UEngineStateThread::ProcessLog(void)
}
}
// EngineMonitorFrame->RichEdit->Lines->Add(UnsentLog.front().c_str());
UnsentLog.pop_front();
}
......@@ -388,12 +406,6 @@ void UEngineStateThread::ProcessLog(void)
{
if(EventsLogFlag && EventsLogFile && *EventsLogFile)
EventsLogFile->flush();
/*
EngineMonitorFrame->RichEdit->SelStart =
EngineMonitorFrame->RichEdit->Perform(EM_LINEINDEX, EngineMonitorFrame->RichEdit->Lines->Count-1, 0);
EngineMonitorFrame->RichEdit->Update();
EngineMonitorFrame->RichEdit->Repaint();
*/
}
}
catch(...)
......
......@@ -19,6 +19,11 @@ class UEngineControl;
class RDK_LIB_TYPE UEngineStateThread
{
protected: // Параметры
/// Путь до папки с логами
RDK::UELockVar<std::string> LogPath;
/// Флаг разрешения логгирования
RDK::UELockVar<bool> LogFlag;
protected: // Данные состояния модулей
/// Состояние тредов расчета
......@@ -53,7 +58,7 @@ protected: // Данные логгирования
RDK::UEPtr<std::ofstream> EventsLogFile;
/// Путь до файла логов
std::string EventsLogFilePath;
RDK::UELockVar<std::string> EventsLogFilePath;
/// Флаг сохранения в лог данных
bool EventsLogFlag;
......@@ -97,6 +102,13 @@ virtual ~UEngineStateThread(void);
// --------------------------
// Управление параметрами
// --------------------------
/// Путь до папки с логами
std::string GetLogPath(void) const;
bool SetLogPath(const std::string& value);
/// Флаг разрешения логгирования
bool GetLogFlag(void) const;
bool SetLogFlag(bool value);
// --------------------------
// --------------------------
......
......@@ -270,7 +270,7 @@ const char* RDK_CALL URpcDecoderCommon::RemoteCall(const char *request, int &ret
else
if(cmd == "GetChannelName")
{
response=GetApplication()->GetProject()->GetConfig().ChannelsConfig[engine_index].ChannelName;
response=GetApplication()->GetProjectConfig().ChannelsConfig[engine_index].ChannelName;
return_value=0;
}
else
......@@ -279,9 +279,9 @@ const char* RDK_CALL URpcDecoderCommon::RemoteCall(const char *request, int &ret
std::string ch_name=xml.ReadString("Name","");
if(!ch_name.empty())
{
TProjectConfig config=GetApplication()->GetProject()->GetConfig();
TProjectConfig config=GetApplication()->GetProjectConfig();
config.ChannelsConfig[engine_index].ChannelName=ch_name;
GetApplication()->GetProject()->SetConfig(config);
GetApplication()->SetProjectConfig(config);
}
return_value=0;
}
......
......@@ -241,12 +241,12 @@ void UServerControl::LoadParameters(RDK::USerStorageXML &xml)
int source_num_channels=xml.ReadInteger("NumberOfChannels",GetNumEngines());
// SetNumEngines(source_num_channels);
TProjectConfig config=GetApplication()->GetProject()->GetConfig();
for(size_t i=0;i<GetApplication()->GetProject()->GetConfig().ChannelsConfig.size();i++)
TProjectConfig config=GetApplication()->GetProjectConfig();
for(size_t i=0;i<GetApplication()->GetProjectConfig().ChannelsConfig.size();i++)
{
config.ChannelsConfig[i].ChannelName=xml.ReadString(std::string("ChannelName_")+RDK::sntoa(i),RDK::sntoa(i));
}
GetApplication()->GetProject()->SetConfig(config);
GetApplication()->SetProjectConfig(config);
SetAutoStartFlag(xml.ReadInteger("AutoStartFlag",true));
SetServerName(xml.ReadString("ServerName","Server"));
......
......@@ -536,7 +536,7 @@ int TTVideoRegistratorFrame::InitRecordingSettings(void)
VideoGrabber->RecordingMethod = RecordingMethodComboBox->ItemIndex;
if(StoragePathRadioGroup->ItemIndex == 0 || StoragePathLabeledEdit->Text=="")
{
VideoGrabber->StoragePath=RdkApplication.GetProject()->GetProjectPath().c_str();
VideoGrabber->StoragePath=RdkApplication.GetProjectPath().c_str();
}
else
{
......
......@@ -183,6 +183,10 @@ inherited TVideoRegistratorFrame: TTVideoRegistratorFrame
object RecordingTabSheet: TTabSheet
Caption = 'RecordingTabSheet'
ImageIndex = 1
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object RecordingSettingsScrollBox: TScrollBox
Left = 0
Top = 0
......
......@@ -22,9 +22,6 @@
#pragma resource "*.dfm"
TUEngineMonitorFrame *UEngineMonitorFrame;
///
extern UEngineControlVcl RdkEngineControl;
///
extern RDK::UApplication RdkApplication;
......@@ -212,7 +209,7 @@ RDK::UEngineStateThread* UEngineControlVcl::CreateEngineStateThread(RDK::UEngine
void UEngineControlVcl::StartEngine(int channel_index)
{
RDK::UEngineControl::StartEngine(channel_index);
switch(RdkEngineControl.GetThreadMode())
switch(GetThreadMode())
{
case 0:
TUVisualControllerFrame::CalculationModeFlag=true;
......@@ -235,7 +232,7 @@ void UEngineControlVcl::StartEngine(int channel_index)
void UEngineControlVcl::PauseEngine(int channel_index)
{
RDK::UEngineControl::PauseEngine(channel_index);
switch(RdkEngineControl.GetThreadMode())
switch(GetThreadMode())
{
case 0:
TUVisualControllerFrame::CalculationModeFlag=false;
......@@ -284,7 +281,7 @@ void TUEngineMonitorFrame::AUpdateInterface(void)
double rt_calc_duration(0.0);
double rt_model_duration(0.0), rt_performance(0.0);
if(RdkEngineControl.GetThreadMode() == 1)
if(RdkApplication.GetEngineControl()->GetThreadMode() == 1)
{
rt_calc_duration=Env_GetRTLastDuration();
rt_model_duration=Env_GetRTModelCalcTime();
......@@ -294,7 +291,7 @@ void TUEngineMonitorFrame::AUpdateInterface(void)
double model_time=Model_GetDoubleTime();
double real_time=Model_GetDoubleRealTime();
double diff=real_time-model_time;
if(RdkEngineControl.GetThreadMode() == 1)
if(RdkApplication.GetEngineControl()->GetThreadMode() == 1)
{
string str_model_time=RDK::get_text_time_from_seconds(model_time);
string str_diff_time=RDK::get_text_time_from_seconds(diff);
......@@ -314,7 +311,7 @@ void TUEngineMonitorFrame::AUpdateInterface(void)
StatusBar->Panels->Items[0]->Width=width;
}
if(RdkEngineControl.GetThreadMode() == 1)
if(RdkApplication.GetEngineControl()->GetThreadMode() == 1)
{
StatusBar->Panels->Items[1]->Text=String("RT: ")+FloatToStrF(rt_performance,ffFixed,3,3)+String("=")+FloatToStrF(rt_model_duration,ffFixed,3,3)+String("/")+FloatToStrF(rt_calc_duration,ffFixed,3,3);
}
......@@ -327,7 +324,7 @@ void TUEngineMonitorFrame::AUpdateInterface(void)
int width=StatusBar->Canvas->TextWidth(StatusBar->Panels->Items[1]->Text)+25;
StatusBar->Panels->Items[1]->Width=width;
if(RdkEngineControl.GetThreadMode() != 1)
if(RdkApplication.GetEngineControl()->GetThreadMode() != 1)
{
if(instperf)
{
......@@ -390,19 +387,19 @@ void TUEngineMonitorFrame::ALoadParameters(RDK::USerStorageXML &xml)
///
const TEngineMonitorThread* TUEngineMonitorFrame::GetEngineMonitorThread(void) const
{
return dynamic_cast<TEngineMonitorThread*>(RdkEngineControl.GetEngineStateThread());
return dynamic_cast<TEngineMonitorThread*>(RdkApplication.GetEngineControl()->GetEngineStateThread());
}
TEngineThread* TUEngineMonitorFrame::GetThreadChannel(int i)
{
return dynamic_cast<TEngineThread*>(RdkEngineControl.GetEngineThread(i));
return dynamic_cast<TEngineThread*>(RdkApplication.GetEngineControl()->GetEngineThread(i));
}
//---------------------------------------------------------------------------
void __fastcall TUEngineMonitorFrame::TimerTimer(TObject *Sender)
{
RdkEngineControl.TimerExecute();
RdkApplication.GetEngineControl()->TimerExecute();
}
//---------------------------------------------------------------------------
......@@ -454,7 +451,7 @@ void __fastcall TUEngineMonitorFrame::ShowDebugMessagesCheckBoxClick(TObject *Se
return;
int size=GetNumEngines();
RDK::TProjectConfig config=RdkApplication.GetProject()->GetConfig();
RDK::TProjectConfig config=RdkApplication.GetProjectConfig();
if(config.ChannelsConfig.size() != size)
{
......@@ -466,7 +463,7 @@ void __fastcall TUEngineMonitorFrame::ShowDebugMessagesCheckBoxClick(TObject *Se
config.ChannelsConfig[i].DebugMode=ShowDebugMessagesCheckBox->Checked;
MEnv_SetDebugMode(i,config.ChannelsConfig[i].DebugMode);
}
RdkApplication.GetProject()->SetConfig(config);
RdkApplication.SetProjectConfig(config);
}
//---------------------------------------------------------------------------
......
......@@ -1115,6 +1115,7 @@ catch(...)
throw;
}
UShowProgressBarForm->Hide();
/*
if(!ProjectOpenFlag)
return;
......@@ -2063,7 +2064,7 @@ void __fastcall TUGEngineControlForm::ProjectOptions1Click(TObject *Sender)
int channel_index=GetSelectedEngineIndex();
RDK::TProjectConfig config=RdkApplication.GetProjectConfig();
UCreateProjectWizardForm->ProjectDirectoryLabeledEdit->Text=RdkApplication.GetProject()->GetProjectPath().c_str();
UCreateProjectWizardForm->ProjectDirectoryLabeledEdit->Text=RdkApplication.GetProjectPath().c_str();
UCreateProjectWizardForm->ProjectNameLabeledEdit->Text=config.ProjectName.c_str();
UCreateProjectWizardForm->ProjectDescriptionRichEdit->Text=config.ProjectDescription.c_str();
UCreateProjectWizardForm->ProjectTypeRadioGroup->ItemIndex=1;
......
......@@ -277,7 +277,7 @@ object UGEngineControlForm: TUGEngineControlForm
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
ExplicitTop = 150
ExplicitTop = 144
ExplicitWidth = 315
ExplicitHeight = 45
end
......@@ -651,10 +651,6 @@ object UGEngineControlForm: TUGEngineControlForm
Margins.Right = 4
Margins.Bottom = 4
Caption = 'Logs'
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
end
object TabSheet2: TTabSheet
Margins.Left = 4
......@@ -1042,7 +1038,7 @@ object UGEngineControlForm: TUGEngineControlForm
Margins.Right = 4
Margins.Bottom = 4
ExplicitWidth = 566
ExplicitHeight = 427
ExplicitHeight = 421
inherited ScrollBox: TScrollBox
Width = 564
Height = 419
......@@ -1051,7 +1047,7 @@ object UGEngineControlForm: TUGEngineControlForm
Margins.Right = 4
Margins.Bottom = 4
ExplicitWidth = 564
ExplicitHeight = 425
ExplicitHeight = 419
inherited Image: TImage
Left = -1
Top = -3
......@@ -1276,7 +1272,6 @@ object UGEngineControlForm: TUGEngineControlForm
Visible = False
OnClick = ChannelsStringGridClick
OnSelectCell = ChannelsStringGridSelectCell
ExplicitHeight = 702
end
object ToolBar: TToolBar
Left = 0
......@@ -1607,7 +1602,7 @@ object UGEngineControlForm: TUGEngineControlForm
Left = 360
Top = 65528
Bitmap = {
494C01011B005C03880310001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C01011B005C03940310001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000007000000001002000000000000070
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
......
......@@ -206,13 +206,13 @@ bool UServerControlVcl::ASetNumEngines(int old_num)
#endif
// ChannelNames.resize(value);
TProjectConfig config=RdkApplication.GetProject()->GetConfig();
TProjectConfig config=RdkApplication.GetProjectConfig();
for(size_t i=0;i<config.ChannelsConfig.size();i++)
{
if(config.ChannelsConfig[i].ChannelName.empty())
config.ChannelsConfig[i].ChannelName=RDK::sntoa(i);
}
RdkApplication.GetProject()->SetConfig(config);
RdkApplication.SetProjectConfig(config);
//UEngineMonitorForm->EngineMonitorFrame->SetNumChannels(value);
......@@ -639,7 +639,7 @@ const std::vector<RDK::ULongTime> &model_avg=RdkApplication.GetServerControl()->
}
ChannelNamesStringGrid->RowCount=RdkApplication.GetProject()->GetConfig().ChannelsConfig.size()+1;
ChannelNamesStringGrid->RowCount=RdkApplication.GetProjectConfig().ChannelsConfig.size()+1;
if(ChannelNamesStringGrid->RowCount>1)
ChannelNamesStringGrid->FixedRows=1;
......@@ -647,10 +647,10 @@ const std::vector<RDK::ULongTime> &model_avg=RdkApplication.GetServerControl()->
ChannelNamesStringGrid->Cells[1][0]="Channel Name";
ChannelNamesStringGrid->ColWidths[0]=25;
ChannelNamesStringGrid->ColWidths[1]=ChannelNamesStringGrid->Width-ChannelNamesStringGrid->ColWidths[0]-25;
for(int i=0;i<int(RdkApplication.GetProject()->GetConfig().ChannelsConfig.size());i++)
for(int i=0;i<int(RdkApplication.GetProjectConfig().ChannelsConfig.size());i++)
{
ChannelNamesStringGrid->Cells[0][i+1]=StrToInt(i);
ChannelNamesStringGrid->Cells[1][i+1]=RdkApplication.GetProject()->GetConfig().ChannelsConfig[i].ChannelName.c_str();
ChannelNamesStringGrid->Cells[1][i+1]=RdkApplication.GetProjectConfig().ChannelsConfig[i].ChannelName.c_str();
}
NumberOfChannelsLabeledEdit->Text=IntToStr(GetNumEngines());
......@@ -686,9 +686,9 @@ void TUServerControlForm::ASaveParameters(RDK::USerStorageXML &xml)
xml.WriteString("MetadataComponentName",RdkApplication.GetServerControl()->GetMetaComponentName());
xml.WriteString("MetadataComponentStateName",RdkApplication.GetServerControl()->GetMetaComponentStateName());
*/
for(size_t i=0;i<RdkApplication.GetProject()->GetConfig().ChannelsConfig.size();i++)
for(size_t i=0;i<RdkApplication.GetProjectConfig().ChannelsConfig.size();i++)
{
xml.WriteString(std::string("ChannelName_")+RDK::sntoa(i),RdkApplication.GetProject()->GetConfig().ChannelsConfig[i].ChannelName);
xml.WriteString(std::string("ChannelName_")+RDK::sntoa(i),RdkApplication.GetProjectConfig().ChannelsConfig[i].ChannelName);
}
}
......@@ -703,12 +703,12 @@ void TUServerControlForm::ALoadParameters(RDK::USerStorageXML &xml)
int source_num_channels=xml.ReadInteger("NumberOfChannels",RdkApplication.GetNumEngines());
RdkApplication.SetNumEngines(source_num_channels);
TProjectConfig config=RdkApplication.GetProject()->GetConfig();
for(size_t i=0;i<RdkApplication.GetProject()->GetConfig().ChannelsConfig.size();i++)
TProjectConfig config=RdkApplication.GetProjectConfig();
for(size_t i=0;i<RdkApplication.GetProjectConfig().ChannelsConfig.size();i++)
{
config.ChannelsConfig[i].ChannelName=xml.ReadString(std::string("ChannelName_")+RDK::sntoa(i),RDK::sntoa(i));
}
RdkApplication.GetProject()->SetConfig(config);
RdkApplication.SetProjectConfig(config);
RdkApplication.GetServerControl()->SetAutoStartFlag(xml.ReadInteger("AutoStartFlag",true));
RdkApplication.GetServerControl()->SetServerName(xml.ReadString("ServerName","Server"));
......@@ -918,9 +918,9 @@ void __fastcall TUServerControlForm::ChannelNamesStringGridKeyDown(TObject *Send
if(Key == VK_RETURN)
{
TProjectConfig config=RdkApplication.GetProject()->GetConfig();
TProjectConfig config=RdkApplication.GetProjectConfig();
config.ChannelsConfig[ChannelNamesStringGrid->Row-1].ChannelName=AnsiString(ChannelNamesStringGrid->Cells[1][ChannelNamesStringGrid->Row]).c_str();
RdkApplication.GetProject()->SetConfig(config);
RdkApplication.SetProjectConfig(config);
UpdateInterface(true);
}
}
......@@ -931,7 +931,7 @@ void __fastcall TUServerControlForm::PageControlChange(TObject *Sender)
ServerControlPortLabeledEdit->Text=IdTCPServer->Bindings->Items[0]->Port;//TcpServer->LocalPort;
NumberOfChannelsLabeledEdit->Text=IntToStr(RdkApplication.GetNumEngines());
TProjectConfig config=RdkApplication.GetProject()->GetConfig();
TProjectConfig config=RdkApplication.GetProjectConfig();
ChannelNamesStringGrid->RowCount=config.ChannelsConfig.size()+1;
ChannelNamesStringGrid->ColWidths[0]=20;
ChannelNamesStringGrid->ColWidths[1]=ChannelNamesStringGrid->Width-ChannelNamesStringGrid->ColWidths[0]-20;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment