You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
6.1 KiB
C++
226 lines
6.1 KiB
C++
#include "StdAfx.h"
|
|
#include "MainFrm.h"
|
|
#include "ModuleMgr.h"
|
|
#include "LogMgr.h"
|
|
#include "PropertieMgr.h"
|
|
#include "GlobalDrawMgr.h"
|
|
#include "MarkObjPropertieMgr.h"
|
|
#include "GlobalFunction.h"
|
|
#include "PltReader.h"
|
|
#include "Laser.h"
|
|
#include "ApplicationPriority.h"
|
|
#include "WorkAreaMgr.h"
|
|
#include "Ruler.h"
|
|
#include "WorkFileLable.h"
|
|
#include "CStringFuc.h"
|
|
#include "WorkFileMgr.h"
|
|
#include "FileMgr.h"
|
|
|
|
|
|
CModuleMgr::CModuleMgr(void)
|
|
{
|
|
}
|
|
CModuleMgr::~CModuleMgr(void)
|
|
{
|
|
|
|
}
|
|
void CModuleMgr::DeleteAllModule()
|
|
{
|
|
//释放组资源
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
if((*iter))
|
|
{
|
|
(*iter)->GetModuleType();
|
|
delete (*iter);
|
|
(*iter) = NULL;
|
|
}
|
|
}
|
|
}
|
|
#if 1
|
|
//记录所有的module 有哪些需要保存的属性
|
|
void CModuleMgr::SaveAllModuleProperty()
|
|
{
|
|
gDevicePropertieMgr.SetSaveAllPropertie(true);
|
|
gDrawPropertieMgr.SetSaveAllPropertie(true);
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
CMFCPropertyGridProperty* pProp = (*iter)->CreatGridProperty();
|
|
if(pProp)
|
|
{
|
|
delete pProp;
|
|
}
|
|
}
|
|
gDevicePropertieMgr.SetSaveAllPropertie(false);
|
|
gDrawPropertieMgr.SetSaveAllPropertie(false);
|
|
}
|
|
//所有模块初始化
|
|
void CModuleMgr::AllModuleOnAppInitialize()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->OnAppInitialize();
|
|
}
|
|
//GetCurViewPtr()->RefreshView();
|
|
}
|
|
//初始化所有模块属性,但是不插入属性页
|
|
void CModuleMgr::PropertiesOnAppInitialize()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
CMFCPropertyGridProperty* pProp = (*iter)->CreatGridProperty();//模块自己负责创建属性
|
|
if(pProp)
|
|
{
|
|
delete pProp;
|
|
}
|
|
}
|
|
}
|
|
//将指定的属性页插入wnd
|
|
void CModuleMgr::InsertPropertiesToWnd(set<MODULE> &Set,CPanePropertiesWnd &Wnd)
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
if(Set.count((*iter)->GetModuleType()))
|
|
{
|
|
CMFCPropertyGridProperty* pProp = (*iter)->CreatGridProperty();//模块自己负责创建属性
|
|
if(pProp)
|
|
{
|
|
Wnd.InsertGridProperty(pProp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void CModuleMgr::InsertPropertiesToGrid(set<MODULE> &Set,CMFCPropertyGridCtrl &PropertyGrid)
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
if(Set.count((*iter)->GetModuleType()))
|
|
{
|
|
CMFCPropertyGridProperty* pProp = (*iter)->CreatGridProperty();//模块自己负责创建属性
|
|
if(pProp)
|
|
{
|
|
PropertyGrid.AddProperty(pProp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//导出所有模块的参数设置信息到文件
|
|
void CModuleMgr::ExportDevicePar(ofstream *pFile)
|
|
{
|
|
|
|
}
|
|
//模块参数写入文件
|
|
void CModuleMgr::SaveWorkFile(vector<CLab> &LabVec)
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->SaveWorkFile(LabVec);
|
|
}
|
|
}
|
|
//返回是否找到相应的读取模块
|
|
bool CModuleMgr::ReadWorkFile(CLabVecRang &LabVecRang)
|
|
{
|
|
//获取模块索引
|
|
CWorkFileMgr WorkFileMgr;
|
|
CLab StartLab = WorkFileMgr.FindLab(LabVecRang,LAB_MODULE_TYPE);
|
|
if(StartLab.m_ValType == _TYPE_NULL)
|
|
return false;
|
|
MODULE ModuleType = (MODULE)(StartLab.m_Int);
|
|
//分给指定的模块处理
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
if((*iter)->GetModuleType()==ModuleType)
|
|
{
|
|
(*iter)->ReadWorkFile(LabVecRang);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
#endif
|
|
#if 1
|
|
//初始化
|
|
void CModuleMgr::InitPar()
|
|
{
|
|
//创建模块对象
|
|
CreatAllModule();
|
|
//检查并创见不存在的文件夹
|
|
CreatModuleDir();
|
|
//初始化模块的属性
|
|
PropertiesOnAppInitialize();
|
|
|
|
//所有模块初始化
|
|
AllModuleOnAppInitialize();
|
|
//默认图形属性
|
|
//InsertModuleGridProperty(_COMB_OBJ_PROP);
|
|
}
|
|
|
|
//模块可以绘制一些自己的内容
|
|
void CModuleMgr::Draw(CDC* pDC)
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->Draw(pDC);
|
|
}
|
|
}
|
|
//检查每个模块的文件夹是否存在,不存在则自动创建
|
|
void CModuleMgr::CreatModuleDir()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
CString DirName = (*iter)->GetParDirName();
|
|
if(DirName != "")
|
|
{
|
|
CString DirPath;
|
|
CString FileName = "\\Parameter\\"+DirName;
|
|
CFileMgr FileMgr;
|
|
FileMgr.GetFullFilePath(DirPath,FileName);
|
|
if(!FileMgr.IsDirectoryExists(DirPath))
|
|
FileMgr.CreatDir(DirPath);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#if 1
|
|
void CModuleMgr::OnExitApp()
|
|
{
|
|
gExitApp = true;
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->OnExitApp();
|
|
}
|
|
Sleep(1000);
|
|
}
|
|
//响应设备初始化
|
|
void CModuleMgr::OnDeviceInit()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->OnDeviceInit();
|
|
}
|
|
}
|
|
#endif |