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.
197 lines
5.1 KiB
C++
197 lines
5.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 "PciPortMgr.h"
|
|
#include "PciCh365Mgr.h"
|
|
#include "PlatformXY.h"
|
|
#include "Laser.h"
|
|
#include "Motor.h"
|
|
#include "ApplicationPriority.h"
|
|
#include "WorkAreaMgr.h"
|
|
#include "CameraHawkvis.h"
|
|
#include "GratingRuler.h"
|
|
#include "Ruler.h"
|
|
#include "WorkFileLable.h"
|
|
#include "CStringFuc.h"
|
|
#include "WorkFileMgr.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)->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::AllModuleIni()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->Ini();
|
|
}
|
|
}
|
|
//初始化所有模块属性,但是不插入属性页
|
|
void CModuleMgr::PropertiesIni()
|
|
{
|
|
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::ExportDevicePar(ofstream *pFile)
|
|
{
|
|
if(pFile)
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->ExportPar(pFile);
|
|
}
|
|
}
|
|
}
|
|
//返回是否找到相应的读取模块
|
|
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::Ini()
|
|
{
|
|
//创建模块对象
|
|
CreatAllModule();
|
|
//初始化模块的属性
|
|
PropertiesIni();
|
|
//所有模块初始化
|
|
AllModuleIni();
|
|
//默认图形属性
|
|
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);
|
|
}
|
|
}
|
|
#endif
|
|
#if 1
|
|
void CModuleMgr::OnWorkStart()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->OnWorkStart();
|
|
}
|
|
}
|
|
void CModuleMgr::OnWorkEnd()
|
|
{
|
|
vector<CModule*>::iterator iter = m_ModuleVec.begin();
|
|
vector<CModule*>::iterator iter_end = m_ModuleVec.end();
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
(*iter)->OnWorkEnd();
|
|
}
|
|
}
|
|
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(2000);
|
|
}
|
|
#endif |