|
|
@@ -349,7 +349,7 @@ namespace OTSModelSharp
|
|
|
return m_pMsrThread.IsMeasureStopped();
|
|
|
}
|
|
|
|
|
|
- bool IsSampleOver(COTSImgScanPrm a_pScanParam, int a_nTotalFields)
|
|
|
+ bool IsSampleOver(COTSImgScanPrm a_pScanParam)
|
|
|
{
|
|
|
|
|
|
|
|
|
@@ -393,7 +393,7 @@ namespace OTSModelSharp
|
|
|
{
|
|
|
case (int)OTS_MEASURE_STOP_MODE.CoverMode:
|
|
|
// completed fields number
|
|
|
- if (nCompeltedField == a_nTotalFields)
|
|
|
+ if (nCompeltedField == m_Sample.GetFieldsData().Count)
|
|
|
{
|
|
|
|
|
|
bRet = true;
|
|
|
@@ -511,11 +511,7 @@ namespace OTSModelSharp
|
|
|
return pBSEImage;
|
|
|
}
|
|
|
|
|
|
- //public virtual bool FieldImageProcess(Point fldCenter, CBSEImgClr imageData)
|
|
|
- //{
|
|
|
- // return true;
|
|
|
-
|
|
|
- //}
|
|
|
+
|
|
|
public virtual void ClassifyFieldParticles()
|
|
|
{
|
|
|
return;
|
|
|
@@ -524,18 +520,38 @@ namespace OTSModelSharp
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ private class SEMStateObject
|
|
|
+ {
|
|
|
+ private Point pos;
|
|
|
+ private double workingDistance;
|
|
|
+ private CSEMDataGnr semdata;
|
|
|
+ private double magnification;
|
|
|
+ public Point Pos { get => pos; set => pos = value; }
|
|
|
+ public double WorkingDistance { get => workingDistance; set => workingDistance = value; }
|
|
|
+ public CSEMDataGnr Semdata { get => semdata; set => semdata = value; }
|
|
|
+ public double Magnification { get => magnification; set => magnification = value; }
|
|
|
+ }
|
|
|
private class AutoResetSEMControl:IDisposable
|
|
|
{
|
|
|
CSmplMeasure sm;
|
|
|
+ private SEMStateObject semState=null;
|
|
|
public AutoResetSEMControl(CSmplMeasure s)
|
|
|
{
|
|
|
sm = s;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ public SEMStateObject SemState { get => semState; set => semState = value; }
|
|
|
|
|
|
public void Dispose()
|
|
|
{
|
|
|
+ if (semState == null)
|
|
|
+ {
|
|
|
+ sm.MoveSEMToPoint(semState.Pos);
|
|
|
+ sm.m_SemHardwareMgr.SetMagnification(semState.Magnification);
|
|
|
+ sm.m_SemHardwareMgr.SetWorkingDistance(semState.WorkingDistance);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
sm.SetSEMExteralOff();
|
|
|
}
|
|
|
}
|
|
|
@@ -605,17 +621,17 @@ namespace OTSModelSharp
|
|
|
m_pSampleRstFile.SetSEMStage(pStage);
|
|
|
|
|
|
// calculate field centers
|
|
|
- List<System.Drawing.Point> umMeasuredlistFieldCenter;
|
|
|
- List<System.Drawing.Point> alllistFieldCenter;
|
|
|
-
|
|
|
- if (!CalculateUnMeasuredFieldsCenters(out alllistFieldCenter,out umMeasuredlistFieldCenter))
|
|
|
- {// failed to calculate field centers
|
|
|
- log.Error("DoMeasure: failed to calculate field centers.");
|
|
|
- pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
|
|
|
- // record end time
|
|
|
- pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
|
|
|
- return;
|
|
|
- }
|
|
|
+ //List<System.Drawing.Point> umMeasuredlistFieldCenter;
|
|
|
+ //List<System.Drawing.Point> alllistFieldCenter;
|
|
|
+
|
|
|
+ //if (!CalculateUnMeasuredFieldsCenters(out alllistFieldCenter,out umMeasuredlistFieldCenter))
|
|
|
+ //{// failed to calculate field centers
|
|
|
+ // log.Error("DoMeasure: failed to calculate field centers.");
|
|
|
+ // pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
|
|
|
+ // // record end time
|
|
|
+ // pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
|
|
|
+ // return;
|
|
|
+ //}
|
|
|
//-----save the static measure result file data into xml file and the dynamic data of every field will be saved into sqlite database
|
|
|
log.Info("Create result file!");
|
|
|
if (!m_pSampleRstFile.CreateResultFiles())
|
|
|
@@ -629,12 +645,19 @@ namespace OTSModelSharp
|
|
|
//------
|
|
|
|
|
|
|
|
|
- int nNewFieldId = 0;
|
|
|
- int numOfAllFields = pStatus.GetCompletedFields() + umMeasuredlistFieldCenter.Count;//
|
|
|
- int completedFields = pStatus.GetCompletedFields();
|
|
|
- log.Info("Unmeasured fields:" + umMeasuredlistFieldCenter.Count);
|
|
|
- for (int i = 0; i < (int)umMeasuredlistFieldCenter.Count; ++i)
|
|
|
+ //int nNewFieldId = 0;
|
|
|
+ //int numOfAllFields = pStatus.GetCompletedFields() + umMeasuredlistFieldCenter.Count;//
|
|
|
+ //int completedFields = pStatus.GetCompletedFields();
|
|
|
+ //log.Info("Unmeasured fields:" + umMeasuredlistFieldCenter.Count);
|
|
|
+ var FldDatas = m_Sample.GetFieldsData();
|
|
|
+ for (int i = 0; i < FldDatas.Count; ++i)
|
|
|
{// check and break if stop button is clicked
|
|
|
+
|
|
|
+ var curFld = FldDatas[i];
|
|
|
+ if (curFld.GetIsMeasureComplete())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (IsAborted())
|
|
|
{// measure stopped
|
|
|
pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.STOPPED);
|
|
|
@@ -650,18 +673,18 @@ namespace OTSModelSharp
|
|
|
|
|
|
// check if sample measurement completes
|
|
|
COTSImgScanPrm pScanParam = m_Sample.GetMsrParams().GetImageScanParam();
|
|
|
- int nTotalFieldSize = (int)umMeasuredlistFieldCenter.Count;
|
|
|
+ //int nTotalFieldSize = (int)umMeasuredlistFieldCenter.Count;
|
|
|
|
|
|
|
|
|
|
|
|
- if (IsSampleOver(pScanParam, numOfAllFields))
|
|
|
+ if (IsSampleOver(pScanParam))
|
|
|
{
|
|
|
pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// get a field center
|
|
|
- System.Drawing.Point poiFieldCentre = umMeasuredlistFieldCenter[i];
|
|
|
+ System.Drawing.Point poiFieldCentre = curFld.GetOTSPosition();
|
|
|
|
|
|
// update thread measure status class, let the main thread know that starts a new field
|
|
|
|
|
|
@@ -671,7 +694,7 @@ namespace OTSModelSharp
|
|
|
MsgFieldStart.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
|
|
|
MsgFieldStart.STMSampleRetData.SMsrField.FieldPos = poiFieldCentre;
|
|
|
m_pMsrThread.SendMessageToMeasureApp(MsgFieldStart);
|
|
|
- int fldNo = completedFields + i + 1;
|
|
|
+ int fldNo = curFld.GetId();
|
|
|
log.Warn("Current field:" + fldNo.ToString());
|
|
|
|
|
|
|
|
|
@@ -720,13 +743,13 @@ namespace OTSModelSharp
|
|
|
|
|
|
// image process
|
|
|
|
|
|
- var rst = FieldImageProcess(poiFieldCentre, pBSEImg);
|
|
|
+ var rst = FieldImageProcess(curFld, pBSEImg);
|
|
|
if (rst == true)
|
|
|
{
|
|
|
-
|
|
|
- // add the field into the field
|
|
|
- m_pSampleRstFile.AddAField(curFldData);
|
|
|
|
|
|
+ // add the field into the field
|
|
|
+ //m_pSampleRstFile.AddAField(curFldData);
|
|
|
+ curFld.SetIsMeasureComplete(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -734,13 +757,14 @@ namespace OTSModelSharp
|
|
|
|
|
|
|
|
|
|
|
|
- ++nNewFieldId;
|
|
|
+ //++nNewFieldId;
|
|
|
|
|
|
double measuredArea = 0; // this area should be the field area
|
|
|
var a_pBSEImg = curFldData.GetBSEImage();
|
|
|
-
|
|
|
- double dPixelSize = m_Sample.CalculatePixelSize();
|
|
|
-
|
|
|
+
|
|
|
+ double dPixelSize = curFldData.GetPixelSize();
|
|
|
+
|
|
|
+
|
|
|
measuredArea = a_pBSEImg.GetHeight() * a_pBSEImg.GetWidth()* dPixelSize * dPixelSize + 0.5; //Get measured area
|
|
|
if (!CumulateFieldData(curFldData.GetListAnalysisParticles(), measuredArea))
|
|
|
{ // failed to call SaveFieldFile method
|
|
|
@@ -749,13 +773,8 @@ namespace OTSModelSharp
|
|
|
return;
|
|
|
}
|
|
|
log.Info("Send field data to screen!");
|
|
|
- // completed fields
|
|
|
- pStatus.SetCompletedFields(pStatus.GetCompletedFields() + 1);
|
|
|
-
|
|
|
- // completed fieldCenter
|
|
|
- List<System.Drawing.Point> listCpltedCenter = pStatus.GetCompletedFieldsCenter();
|
|
|
- listCpltedCenter.Add(poiFieldCentre);
|
|
|
-
|
|
|
+
|
|
|
+ pStatus.AddCompletedFieldCenter(poiFieldCentre);
|
|
|
//Field Data
|
|
|
// record end time
|
|
|
pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
|
|
|
@@ -763,7 +782,7 @@ namespace OTSModelSharp
|
|
|
MsgFieldEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
|
|
|
MsgFieldEnd.STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
|
|
|
MsgFieldEnd.STMSampleRetData.SFieldData.iCompleteFieldCount = pStatus.GetCompletedFields();
|
|
|
- MsgFieldEnd.STMSampleRetData.SFieldData.iMeasureFieldCount = numOfAllFields;
|
|
|
+ MsgFieldEnd.STMSampleRetData.SFieldData.iMeasureFieldCount = m_Sample.GetFieldsData().Count;
|
|
|
MsgFieldEnd.STMSampleRetData.SFieldData.iSParticleCount = (int)curFldData.GetListAnalysisParticles().Count;
|
|
|
MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.X = Convert.ToInt32(poiFieldCentre.X);
|
|
|
MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(poiFieldCentre.Y);
|
|
|
@@ -823,19 +842,17 @@ namespace OTSModelSharp
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- public bool FieldImageProcess(Point fldCenter, CBSEImgClr a_pBSEImg)
|
|
|
+ public bool FieldImageProcess(COTSFieldData curFldData, CBSEImgClr a_pBSEImg)
|
|
|
{
|
|
|
- int nNewFieldId;
|
|
|
- nNewFieldId = m_pSampleRstFile.GetIdForANewField();
|
|
|
|
|
|
- // create a field
|
|
|
- curFldData = new COTSFieldData(a_pBSEImg, m_Sample.CalculatePixelSize());
|
|
|
- curFldData.SetId(nNewFieldId);
|
|
|
- curFldData.SetOTSPosition(fldCenter);
|
|
|
+ Point fldCenter = curFldData.OTSPos;
|
|
|
+
|
|
|
+ curFldData.SetBSEImage(a_pBSEImg);
|
|
|
CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
|
|
|
Point semPos = new Point();
|
|
|
a_pCSEMStageData.ConverOTSToSEMPoint(fldCenter, ref semPos);
|
|
|
- curFldData.SemPos = semPos;
|
|
|
+
|
|
|
+ curFldData.SetSemPos(semPos);
|
|
|
|
|
|
//first step:remove background of the bse image and compound all the finded particles.
|
|
|
|
|
|
@@ -1060,9 +1077,26 @@ namespace OTSModelSharp
|
|
|
{
|
|
|
using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this))
|
|
|
{
|
|
|
+ //----------memorize the state of sem
|
|
|
+ var semstate = new SEMStateObject();
|
|
|
+
|
|
|
+ double dMagnification = m_Sample.GetSEMDataMsr().GetMagnification();
|
|
|
+ double wd = m_Sample.GetSEMDataMsr().GetWorkingDistance();
|
|
|
+ SemController sem = m_SemHardwareMgr;
|
|
|
+ double posX=0, posY=0,posR=0;
|
|
|
+ sem.GetSemPositionXY(ref posX, ref posY, ref posR);
|
|
|
+
|
|
|
+ Point pos = new Point((int)posX, (int)posY);
|
|
|
+ semstate.Pos = pos;
|
|
|
+ semstate.Magnification = dMagnification;
|
|
|
+ semstate.WorkingDistance = wd;
|
|
|
+
|
|
|
+ autoReset.SemState = semstate;
|
|
|
+ //-------------------------------------
|
|
|
+
|
|
|
|
|
|
- // let the main thread to know that this sample measurement starts
|
|
|
- CMsrSampleStatus pStatus = m_Sample.GetMsrStatus();
|
|
|
+ // let the main thread to know that this sample measurement starts
|
|
|
+ CMsrSampleStatus pStatus = m_Sample.GetMsrStatus();
|
|
|
pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.INPROCESS);
|
|
|
|
|
|
// set current time to current time
|
|
|
@@ -1143,12 +1177,12 @@ namespace OTSModelSharp
|
|
|
|
|
|
|
|
|
|
|
|
- if (IsSampleOver(pScanParam, nTotalFieldSize))
|
|
|
- {
|
|
|
- pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
|
|
|
+ //if (IsSampleOver(pScanParam))
|
|
|
+ //{
|
|
|
+ // pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
|
|
|
|
|
|
- break;
|
|
|
- }
|
|
|
+ // break;
|
|
|
+ //}
|
|
|
|
|
|
// get a field center
|
|
|
System.Drawing.Point poiFieldCentre = listFieldCenter[i];
|
|
|
@@ -1358,7 +1392,7 @@ namespace OTSModelSharp
|
|
|
|
|
|
log.Warn("Start saving particle data.");
|
|
|
|
|
|
- var fldcmd = fldDB.GetSavingAFieldcmdObj(fldData.GetId(), fldData.GetOTSPosition(), fldData.SemPos);
|
|
|
+ var fldcmd = fldDB.GetSavingAFieldcmdObj(fldData.GetId(), fldData.GetOTSPosition(), fldData.GetSemPos());
|
|
|
|
|
|
List<KeyValuePair<string, System.Data.SQLite.SQLiteParameter[]>> fldcmds = new List<KeyValuePair<string, System.Data.SQLite.SQLiteParameter[]>>();
|
|
|
fldcmds.Add(fldcmd);
|