123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using static OTSDataType.otsdataconst;
- namespace OTSDataType
- {
- public class COTSImgScanPrm : ISlo
- {
- private string m_nStopMode;
- private int m_nStopParamMeasTime;
- private int m_nStopParamFields;
- private int m_nStopParamParticles;
- private int m_nStopParamArea;
- private OTS_GET_IMAGE_MODE m_nSatrtImageMode;
- private OTS_IMAGE_SCANSPEED_OPTIONS m_nScanImageSpeed;
- private OTS_IMAGE_RESULOTION_OPTIONS m_nImageResulotion;
- private OTS_MEASURE_FIELD_STOP_MODE m_nFieldStopMode;
- private int m_nFieldAreaPercentage;
- private int m_nFieldLargeParticles;
- private int m_nFieldLargeParticlesPercentage;
- private int m_nFieldSmallParticles;
- private int m_nFieldSmallParticlesPercentage;
- //private int m_OverlapParam;
- //const OTS_MEASURE_STOP_MODE DEFUALT_MEASURE_STOP_MODE = OTS_MEASURE_STOP_MODE.CoverMode;
- // stop parameters
- const int DEFUALT_PARAM_FIELD = 500;
- const int DEFUALT_PARAM_TIME = 300;
- const int DEFUALT_PARAM_PARTICLE = 5000;
- const int DEFUALT_PARAM_AREA = 100;
- // image mode
- const OTS_GET_IMAGE_MODE DEFAULT_IMAGEMODE = OTS_GET_IMAGE_MODE.Spiral;
- // scan speed
- const OTS_IMAGE_SCANSPEED_OPTIONS DEFAULE_SCAN_SPEED = OTS_IMAGE_SCANSPEED_OPTIONS.meddium;
- // image size
- const OTS_IMAGE_RESULOTION_OPTIONS DEFAULE_IMAGE_SIZE = OTS_IMAGE_RESULOTION_OPTIONS._1024_768;
- void Init()
- {
- m_nStopMode = ((int)OTS_MEASURE_STOP_MODE.CoverMode+1).ToString(); //测量终止方式
- m_nStopParamMeasTime = DEFUALT_PARAM_TIME; //测量时间
- m_nStopParamFields = DEFUALT_PARAM_FIELD; //帧图数
- m_nStopParamParticles = DEFUALT_PARAM_PARTICLE; //夹杂物数
- m_nSatrtImageMode = DEFAULT_IMAGEMODE; //取图方式
- m_nScanImageSpeed = DEFAULE_SCAN_SPEED;
- m_nImageResulotion = DEFAULE_IMAGE_SIZE;
- m_nStopParamArea = DEFUALT_PARAM_AREA;
- m_nFieldStopMode = OTS_MEASURE_FIELD_STOP_MODE.ParticlesPercentage;
- m_nFieldAreaPercentage = 100;
- m_nFieldLargeParticles = 1000;
- m_nFieldLargeParticlesPercentage = 100;
- m_nFieldSmallParticles = 10000;
- m_nFieldSmallParticlesPercentage = 100;
- }
- public COTSImgScanPrm ()
- {
- // copy data over
- Init();
- }
- void Duplicate( COTSImgScanPrm a_oSource)
- {
- // copy data over
- m_nStopMode = a_oSource.m_nStopMode;
- m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
- m_nStopParamFields = a_oSource.m_nStopParamFields;
- m_nStopParamParticles = a_oSource.m_nStopParamParticles;
- m_nStopParamArea = a_oSource.m_nStopParamArea;
- m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
- m_nImageResulotion = a_oSource.m_nImageResulotion;
- m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
- m_nFieldStopMode = a_oSource.m_nFieldStopMode;
- m_nFieldAreaPercentage = a_oSource.m_nFieldAreaPercentage;
- m_nFieldLargeParticles = a_oSource.m_nFieldLargeParticles;
- m_nFieldLargeParticlesPercentage = a_oSource.m_nFieldLargeParticlesPercentage;
- m_nFieldSmallParticles = a_oSource.m_nFieldSmallParticles;
- m_nFieldSmallParticlesPercentage = a_oSource.m_nFieldSmallParticlesPercentage;
- //m_OverlapParam = a_oSource.m_OverlapParam;
-
- }
- public COTSImgScanPrm ( COTSImgScanPrm a_oSource)
- {
-
- // copy data over
- Duplicate(a_oSource);
- }
- public bool Equals(COTSImgScanPrm a_oSource)
- {
- // return test result
- return((m_nStopMode == a_oSource.m_nStopMode) &&
- (m_nStopParamMeasTime == a_oSource.m_nStopParamMeasTime) &&
- (m_nStopParamFields == a_oSource.m_nStopParamFields) &&
- (m_nStopParamParticles == a_oSource.m_nStopParamParticles) &&
- (m_nStopParamArea == a_oSource.m_nStopParamArea) &&
- (m_nSatrtImageMode == a_oSource.m_nSatrtImageMode) &&
- (m_nImageResulotion == a_oSource.m_nImageResulotion));
- }
- //测量终止方式
- public string GetStopMode() { return m_nStopMode; }
- public void SetStopMode(string a_nStopMode) { m_nStopMode = a_nStopMode; }
- //测量时间
- public int GetStopParamMeasTime() { return m_nStopParamMeasTime; }
- public void SetStopParamMeasTime(int a_nStopParamMeasTime) { m_nStopParamMeasTime = a_nStopParamMeasTime; }
- //帧图数
- public int GetStopParamFields() { return m_nStopParamFields; }
- public void SetStopParamFields(int a_nStopParamFields) { m_nStopParamFields = a_nStopParamFields; }
- //夹杂物数
- public int GetStopParamParticles() { return m_nStopParamParticles; }
- public void SetStopParamParticles(int a_nStopParamParticles) { m_nStopParamParticles = a_nStopParamParticles; }
- //测量面积
- public int GetStopParamArea() { return m_nStopParamArea; }
- public void SetStopParamArea(int a_nStopParamArea) { m_nStopParamArea = a_nStopParamArea; }
- //测量帧终止方式
- //no longer consider the field stop mode ,for we can get the same result by regulate the min size of particle to filter the too small particles.
- public OTS_MEASURE_FIELD_STOP_MODE GetFieldStopMode() { return m_nFieldStopMode; }
- public void SetFieldStopMode(OTS_MEASURE_FIELD_STOP_MODE a_nFieldStopMode) { m_nFieldStopMode = a_nFieldStopMode; }
- //帧完成面积百分比
- public int GetFieldAreaPercentage() { return m_nFieldAreaPercentage; }
- public void SetFieldAreaPercentage(int a_nAreaPercentage) { m_nFieldAreaPercentage = a_nAreaPercentage; }
- //帧完成大颗粒数
- public int GetFieldLargeParticleNum() { return m_nFieldLargeParticles; }
- public void SetFieldLargeParticleNum(int a_nLargeParticles) { m_nFieldLargeParticles = a_nLargeParticles; }
- //帧完成大颗粒百分比
- public int GetFieldLargeParticlesPercentage() { return m_nFieldLargeParticlesPercentage; }
- public void SetFieldLargeParticlePercentage(int a_nLargeParticlesPercentage) { m_nFieldLargeParticlesPercentage = a_nLargeParticlesPercentage; }
- //帧完成小颗粒数
- public int GetFieldSmallParticleNum() { return m_nFieldSmallParticles; }
- public void SetFieldSmallParticleNum(int a_nSmallParticles) { m_nFieldSmallParticles = a_nSmallParticles; }
- //帧完成小颗粒数百分比
- public int GetFieldSmallParticlesPercentage() { return m_nFieldSmallParticlesPercentage; }
- public void SetFieldSmallParticlePercentage(int a_nSmallParticlesPercentage) { m_nFieldSmallParticlesPercentage = a_nSmallParticlesPercentage; }
- //取图方式
- public OTS_GET_IMAGE_MODE GetFieldStartMode() { return m_nSatrtImageMode; }
- public void SetStartImageMode(OTS_GET_IMAGE_MODE a_nSatrtImageMode) { m_nSatrtImageMode = a_nSatrtImageMode; }
- //扫描图尺寸
- public OTS_IMAGE_RESULOTION_OPTIONS GetImageResulotion() { return m_nImageResulotion; }
- public CSize GetImageResolutionSize()
- {
- string sReso = m_nImageResulotion.ToString();
- int w=Convert.ToInt32(sReso.Split('_')[1]);
- int h = Convert.ToInt32(sReso.Split('_')[2]);
-
- return new CSize(w,h);
- }
- public void SetImageResulotion(OTS_IMAGE_RESULOTION_OPTIONS a_nImagePixelSize) { m_nImageResulotion = a_nImagePixelSize; }
- //扫描图精度
- public OTS_IMAGE_SCANSPEED_OPTIONS GetScanImageSpeed() { return m_nScanImageSpeed; }
- public void SetScanImageSpeed(OTS_IMAGE_SCANSPEED_OPTIONS a_nScanImageSpeed) { m_nScanImageSpeed = a_nScanImageSpeed; }
-
- public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
- xString xnStopMode=new xString();
- xInt xnStopParamMeasTime=new xInt();
- xInt xnStopParamFields = new xInt();
- xInt xnStopParamParticles = new xInt();
- xInt xnStopParamArea = new xInt();
- xString xnSatrtImageMode = new xString();
- xString xnScanImageSpeed = new xString();
- xString xnImageSize = new xString();
-
- Slo slo=new Slo();
- slo.Register("StopMode", xnStopMode);
- slo.Register("StopParamMeasTime", xnStopParamMeasTime);
- slo.Register("StopParamFields", xnStopParamFields);
- slo.Register("StopParamParticles", xnStopParamParticles);
-
- slo.Register("StopParamArea", xnStopParamArea);
- slo.Register("SatrtImageMode", xnSatrtImageMode);
- slo.Register("ScanImageSpeed", xnScanImageSpeed);
- slo.Register("ImageResolution", xnImageSize);
-
- if (isStoring)
- {
- string[] st = m_nStopMode.Replace(" ","").Split('+');
- string str = "";
- for (int k = 0; k < st.Length; k++)
- {
- str += (int.Parse(st[k]) - 1).ToString() + ":" + ((OTS_MEASURE_STOP_MODE)int.Parse(st[k])-1).ToString()+",";
- }
- xnStopMode.AssignValue(str.Substring(0, str.Length-1));//
- xnStopParamMeasTime.AssignValue( m_nStopParamMeasTime);
- xnStopParamFields.AssignValue(m_nStopParamFields);
- xnStopParamParticles.AssignValue(m_nStopParamParticles);
-
- xnStopParamArea.AssignValue(m_nStopParamArea);
- xnSatrtImageMode.AssignValue((int)m_nSatrtImageMode+":"+m_nSatrtImageMode.ToString());
- xnScanImageSpeed.AssignValue((int)m_nScanImageSpeed+":"+ m_nScanImageSpeed.ToString());
- xnImageSize.AssignValue( (int)m_nImageResulotion+":"+m_nImageResulotion.ToString());
-
-
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- string[] st = xnStopMode.value().Split(',');
- string str = "";
- for (int k = 0; k < st.Length; k++)
- {
- str += (int.Parse(st[k].Split(':')[0])+1) + " + ";
- }
- m_nStopMode = str.Substring(0, str.Length - 3);
- m_nStopParamMeasTime = xnStopParamMeasTime.value();
- m_nStopParamFields = xnStopParamFields.value();
- m_nStopParamParticles = xnStopParamParticles.value();
- m_nStopParamArea = xnStopParamArea.value();
-
- m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)Convert.ToInt32(xnSatrtImageMode.value().Split(':')[0]);
- m_nScanImageSpeed = (OTS_IMAGE_SCANSPEED_OPTIONS)Convert.ToInt32(xnScanImageSpeed.value().Split(':')[0]);
- m_nImageResulotion = (OTS_IMAGE_RESULOTION_OPTIONS)Convert.ToInt32(xnImageSize.value().Split(':')[0]);
-
- }
- }
-
- }
- }
|