| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using OTSDataType;
- using static OTSDataType.otsdataconst;
- namespace OTSModelSharp
- {
- class CSmplMsrResultFile
- {
- //----------全局定义------------------
- // sample measure result file mark
- public int SMPL_MSR_RESULT_FILE_MARK = 'S' + 'M' + 'P' + 'L' + 'M' + 'S' + 'R' + 'R' + 'E' + 'S' + 'U' + 'L' + 'T';
- // sample measure result file version
- public string SMPL_MSR_RESULT_FILE_VERSION = ("1.1.1");
- // sample measure result file extension
- public string SMPL_MSR_RESULT_FILE_EXT = (".rst");
- public string SMPL_MSR_RESULT_FILE_FILTER = ("Sample Measure Result Files (*.rst)|*.rst||");
- // fields file sub-directory string
- public string SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER = ("FIELD_FILES");
- // BSE file name
- public string SMPL_MSR_RESULT_FIELDS_BSE = ("Field");
- // search x-ray file name
- public string SMPL_MSR_RESULT_SEARCH_X_RAY_FILE = ("SearchXray.db");
- // analysis x-ray file name
- public string SMPL_MSR_RESULT_ANALYSIS_X_RAY_FILE = ("Inclusion.db");
- // Inclusion file name
- public string SMPL_MSR_RESULT_INCLUSION_FILE = ("Inclusion.db");//put all the table in one db file so that report can make join query.
- //----------定义----------------------
- // file version string
- string m_strFileVersion;
- // SEM sample stage
- CSEMStageData m_pSEMStageData;
- // sample stage
- CStage m_pStage;
- //CSEMStageDataPtr m_pSEMData;
- CSEMDataGnr m_pSEMData;
- // sample setting
- COTSSample m_pSample;
- // switch
- bool m_bSwitch;
- // fields
- List<COTSFieldData> m_listFieldData;
- //----------public-------------------
- public CSmplMsrResultFile()
- {
- Init();
- }
- public CSmplMsrResultFile(CSmplMsrResultFile a_oSource)
- {
- // can't copy itself
- if (a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- public virtual void Dispose()
- {
- Cleanup();
- }
- public bool Equals(CSmplMsrResultFile a_oSource)
- {
- Duplicate(a_oSource);
-
- return false;
- }
- // cleanup
- public void Cleanup()
- {
- m_listFieldData.Clear();
- }
- // file version string
- public string GetFileVersion()
- {
- return m_strFileVersion;
- }
- public void SetFileVersion(string a_strFileVersion)
- {
- m_strFileVersion = a_strFileVersion;
- }
- // SEM sample stage
- public CSEMStageData GetSEMStageData()
- {
- return m_pSEMStageData;
- }
- public void SetSEMStageData(CSEMStageData a_pSEMStageData )
- {
- if (a_pSEMStageData!=null)
- {
- return;
- }
- m_pSEMStageData = a_pSEMStageData;
- }
- // sample stage
- public CStage GetStage()
- {
- return m_pStage;
- }
- public void SetStage(CStage a_pStage)
- {
- if (a_pStage!=null)
- {
- return;
- }
- m_pStage = a_pStage;
- }
- // SEM condition
- public CSEMDataGnr GetSEMStage()
- {
- return m_pSEMData;
- }
- public void SetSEMStage(CSEMDataGnr a_pSEMData)
- {
- if (a_pSEMData !=null)
- {
- return;
- }
- m_pSEMData = a_pSEMData;
- }
- // sample setting
- public COTSSample GetSample()
- {
- return m_pSample;
- }
- public void SetSample (COTSSample a_pSample)
- {
- if (a_pSample!=null)
- {
- return;
- }
- m_pSample = a_pSample;
- SetFieldData(a_pSample.GetFieldsData());
- }
- // switch
- public bool GetSwitch()
- {
- return m_bSwitch;
- }
- public void SetSwitch(bool a_bSwitch)
- {
- m_bSwitch = a_bSwitch;
- }
- //fields
- public List<COTSFieldData> GetFieldData()
- {
- return m_listFieldData;
- }
- public void SetFieldData(List<COTSFieldData> a_listFieldData)
- {
- m_listFieldData.Clear();
- foreach(COTSFieldData pFieldData in a_listFieldData)
- {
- m_listFieldData.Add(pFieldData);
- }
- }
- public List<COTSParticle> GetAllParticles()
- {
- List<COTSParticle> listParticle = new List<COTSParticle>();
- List< COTSFieldData> listFieldData = GetFieldData();
- foreach (var pFieldData in listFieldData)
- {
- List< COTSParticle> listParticlenew = pFieldData.GetParticleList();
- foreach (var pParticle in listParticlenew)
- {
- listParticle.Add(pParticle);
- }
- }
- return listParticle;
- }
- //----------protected----------------
- // initialization
- protected void Init()
- {
- // file version string
- m_strFileVersion = ("");
- // SEM sample stage
- m_pSEMStageData = new CSEMStageData();
- // sample stage
- m_pStage = new CStage();
- // SEM condition??
- //CSEMStageDataPtr m_pSEMData;
- m_pSEMData = new CSEMDataGnr();
- // sample setting
- m_pSample =new COTSSample();
- // switch
- m_bSwitch = false;
- // fields
- m_listFieldData.Clear();
- }
- protected void Duplicate(CSmplMsrResultFile a_oSource)
- {
- // initialization
- Init();
- // copy data over
- // file version string
- m_strFileVersion = a_oSource.m_strFileVersion;
- // SEM sample stage
- m_pSEMStageData = a_oSource.m_pSEMStageData;
- // sample stage
- m_pStage = a_oSource.m_pStage;
- // SEM condition??
- //CSEMStageDataPtr m_pSEMData;
- m_pSEMData = a_oSource.m_pSEMData;
- // sample setting
- m_pSample = a_oSource.m_pSample;
- // switch
- m_bSwitch = a_oSource.m_bSwitch;
- // fields
- m_listFieldData.Clear();
- foreach (COTSFieldData pFieldData in a_oSource.m_listFieldData)
- {
- COTSFieldData pFieldDataNew = pFieldData;
- m_listFieldData.Add(pFieldDataNew);
- }
- }
- public void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
-
- xInt xnFileMark = new xInt();
- xString xnVersion = new xString();
- xBool xbSwitch = new xBool();
- Collection<COTSFieldData> xfields = new Collection<COTSFieldData>();
- Collection<CSEMStageData> m_pSEMStageData = new Collection<CSEMStageData>();
- Collection<CStage> m_pStage = new Collection<CStage>();
- Collection<CSEMDataGnr> m_pSEMData = new Collection<CSEMDataGnr>();
- Collection<COTSSample> m_pSample = new Collection<COTSSample>();
- Slo slo = new Slo();
- slo.Register("xnFileMark", xnFileMark);
- slo.Register("xnVersion", xnVersion);
- slo.Register("xbSwitch", xbSwitch);
- slo.Register("SEMStageData", m_pSEMStageData);
- slo.Register("Stage", m_pStage);
- slo.Register("SEMData", m_pSEMData);
- slo.Register("Sample", m_pSample);
- slo.Register("Fields", xfields);
- if (isStoring)
- {
- xnFileMark.AssignValue(SMPL_MSR_RESULT_FILE_MARK);
- xnVersion.AssignValue(SMPL_MSR_RESULT_FILE_VERSION);
- xbSwitch.AssignValue(m_bSwitch);
- xfields.Clear();
- /*for (auto pFildData : m_listFieldData)
- {
- xfields.addItem(pFildData.get());
- }*/
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- m_bSwitch = xbSwitch.value();
- m_strFileVersion = xnVersion.value().ToString();
- m_listFieldData.Clear();
- /*for (unsigned int i = 0;i < xfields.size(); i++)
- {
- m_listFieldData.push_back(COTSFieldDataPtr(xfields.getItem(i)));
- }*/
- }
- }
- public bool GetSTDMapedParticleList(Dictionary<string, List<COTSParticle>> mapSameSTDPartList)
- {
- //把颗粒根据类型分组,类型 ID做key,颗粒列表做value
- Dictionary < string, List<COTSParticle>> partListIter;
- var listParticle = GetAllParticles();
- //get the same type particle together
- foreach (var pParticle in listParticle)
- {
- string sType = pParticle.TypeName();
- int nType = pParticle.GetType();
- //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
- if (nType >= (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED_SIC)
- {
- partListIter = mapSameSTDPartList;
- if (partListIter == mapSameSTDPartList)
- {
- List<COTSParticle> listParticles = new List<COTSParticle>();
- listParticles.Add(pParticle);
- mapSameSTDPartList.Insert(new KeyValuePair<string, List<COTSParticle>>(sType, listParticles));
-
- }
- else
- {
- partListIter.second.Add(pParticle);
- }
- }
- }
- return true;
- }
- }
- }
|