| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- #include "stdafx.h"
- #include "MsrThreadClr.h"
- #include "MsrThread.h"
- namespace OTSINTERFACE {
- CMsrThreadClr::CMsrThreadClr()
- {
- m_pMsrThread =new CMsrThreadPtr( new CMsrThread());
- }
- CMsrThreadClr::~CMsrThreadClr()
- {
- if (m_pMsrThread!=nullptr)
- {
- delete m_pMsrThread;
- m_pMsrThread = NULL;
- }
- }
- CMsrThreadClr::!CMsrThreadClr()
- {
- if (m_pMsrThread != nullptr)
- {
- delete m_pMsrThread;
- m_pMsrThread = NULL;
- }
- }
- CMsrThreadClr::CMsrThreadClr(CMsrThreadPtr pMsrThread)
- {
-
- m_pMsrThread = new CMsrThreadPtr(pMsrThread);
-
-
-
- }
- bool CMsrThreadClr::CheckMeasureParam(CProjMgrClr^ a_pProjMgrFile, COTSSamplesListClr^% a_listMeasurableSample, bool a_bAuto)
- {
- if (this == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CMsrThreadClr:invalid pointer."));
- return false;
- }
- // safety check
- if (a_pProjMgrFile == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CheckMeasureParam: invalid project manager file."));
- return false;
- }
- // get C++ pointer of work file pointer
- COTSProjMgrFilePtr pProjMgr = COTSProjMgrFilePtr(new COTSProjMgrFile());
- pProjMgr = a_pProjMgrFile->GetCProjMgrPtr();
- COTSSamplesList listMeasuableSamples;
- listMeasuableSamples.clear();
- a_listMeasurableSample->Clear();
- bool bRet = m_pMsrThread->get()->CheckMeasureParam(pProjMgr, listMeasuableSamples, a_bAuto);
- for (auto pSample : listMeasuableSamples)
- {
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CheckMeasureParam:invalid pointer."));
- return false;
- }
- COTSSampleClr^ pSampleClr = gcnew COTSSampleClr(pSample);
- ASSERT(pSampleClr);
- if (!pSampleClr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CheckMeasureParam:invalid clr pointer."));
- return false;
- }
- a_listMeasurableSample->Add(pSampleClr);
- }
- return bRet;
- }
- void CMsrThreadClr::DoMeasure()
- {
- m_pMsrThread->get()->DoMeasure();
- }
- void CMsrThreadClr::DoHolePreview(int a_nHoleID, CDomainClr^ a_pMeasureArea)
- {
- ASSERT(a_pMeasureArea);
- if (!a_pMeasureArea)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("DoHolePreview:invalid clr pointer."));
- return;
- }
- CDomainPtr pArea = a_pMeasureArea->GetDomainPtr();
- ASSERT(pArea);
- if (!pArea)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("DoHolePreview:can't get domain pointer."));
- return;
- }
- m_pMsrThread->get()->DoHolePreview(a_nHoleID, pArea);
- }
- bool CMsrThreadClr::Init(CProjMgrClr^ a_pProjMgrFile, COTSSamplesListClr^ a_listMeasuableSamples)
- {
- // safety check
- if (a_pProjMgrFile == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("Init: invalid project manager file."));
- return false;
- }
- // get C++ pointer of work file pointer
- COTSProjMgrFilePtr pProjMgr = a_pProjMgrFile->GetCProjMgrPtr();
- COTSSamplesList listMeasuableSamples;
- listMeasuableSamples.clear();
- int nSize = a_listMeasuableSamples->Count;
- for (int i = 0; i < nSize; i++)
- {
- COTSSamplePtr pSample = a_listMeasuableSamples[i]->GetSamplePtr();
- ASSERT(pSample);
- if(!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("Init: invalid sample pointer."));
- return false;
- }
- listMeasuableSamples.push_back(pSample);
- }
- bool bRet = m_pMsrThread->get()->Init(pProjMgr, listMeasuableSamples);
-
- return bRet;
- }
- bool CMsrThreadClr::Init(CProjMgrClr ^ a_pProjMgrFile)
- {// safety check
- if (a_pProjMgrFile == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("Init: invalid project manager file."));
- return false;
- }
- // get C++ pointer of work file pointer
- COTSProjMgrFilePtr pProjMgr = a_pProjMgrFile->GetCProjMgrPtr();
-
- bool bRet = m_pMsrThread->get()->Init(pProjMgr);
- return bRet;
- }
- void CMsrThreadClr::GetMeasureAppFormName(String^ csFormName)
- {
- m_pMsrThread->get()->GetMeasureAppFormName(csFormName);
- }
- void CMsrThreadClr::SetMsrThreadStatus(CMsrThreadStatusClr^ a_pThreadStatus)
- {
- CMsrThreadStatusPtr pMsrThreadStatus = a_pThreadStatus->GetMsrThreadStatusPtr();
- ASSERT(pMsrThreadStatus);
- if (!pMsrThreadStatus)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetMsrThreadStatus:invalid pointer."));
- return;
- }
- m_pMsrThread->get()->SetMsrThreadStatus(pMsrThreadStatus);
- }
- CMsrThreadStatusClr^ CMsrThreadClr::GetMsrThreadStatus()
- {
- CMsrThreadStatusPtr pMsrThreadStatus = m_pMsrThread->get()->GetMsrThreadStatus();
-
- ASSERT(pMsrThreadStatus);
- if (!pMsrThreadStatus)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetMsrThreadStatus:invalid pointer."));
- return nullptr;
- }
-
- return gcnew CMsrThreadStatusClr(pMsrThreadStatus);
- }
- void CMsrThreadClr::SetMsrLoopStatus(int a_nMsrLoopStatus)
- {
- m_pMsrThread->get()->SetMsrLoopStatus((OTS_MSR_THREAD_STATUS)a_nMsrLoopStatus);
- }
- bool CMsrThreadClr::CheckProjFileSave()
- {
- bool bRet = m_pMsrThread->get()->CheckProjFileSave();
- return bRet;
- }
-
- CProjMgrClr^ CMsrThreadClr::GetProjMgr()
- {
- COTSProjMgrFilePtr pProjMgrFile = COTSProjMgrFilePtr(new COTSProjMgrFile());
- pProjMgrFile = m_pMsrThread->get()->GetProjMgrFile();
-
- return gcnew CProjMgrClr(pProjMgrFile);
- }
- void CMsrThreadClr::SetProjMgr(CProjMgrClr^ a_pProjMgrFile)
- {
-
-
- COTSProjMgrFilePtr pProjMgrFile = a_pProjMgrFile->GetCProjMgrPtr();
- m_pMsrThread->get()->SetProjMgrFile(pProjMgrFile);
- }
- int CMsrThreadClr::GetClassifyParticleId(CPartSTDDataClr^ a_pPartSTDData, int steelTech, String^ a_ElementName)
- {
- //------------------------------------------------------
- //编辑测量数据
- //实力新元素对象指针
- array<System::String^>^ strArrayElement=a_ElementName->Split('\n');
- CElementChemistriesList a_listChemistriesElements;
- if (strArrayElement->Length > 0)
- {
- //循环生成CElementChemistryPtr 对象 记录元素名称与质量百分比
- for each (String^ str in strArrayElement)
- {
- if (str!="")
- {
- CString tempName = str->Split(':')[0]->ToString();
- double tempPercentage = Convert::ToDouble(str->Split(':')[1]->ToString());
- CElementChemistryPtr pElementChemistrieNewO = CElementChemistryPtr(new CElementChemistry(tempName, tempPercentage));
- a_listChemistriesElements.push_back(pElementChemistrieNewO);
- }
- }
- }
- int a_nIncId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
- BOOL result = m_pMsrThread->get()->GetClassifyParticleId(a_pPartSTDData->GetPartSTDDataPtr(), steelTech, a_listChemistriesElements, a_nIncId);
- if (result)
- {
- return a_nIncId;
- }
- return a_nIncId;
- }
- /*void CMsrThreadClr::FreeDll()
- {
- if (NULL != m_pMsrThread)
- {
- delete m_pMsrThread;
- m_pMsrThread = NULL;
- }
- }*/
- }
|