using OTSDataType; using OTSMeasureApp._0_OTSModel.OTSDataType; using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow; using OTSModelSharp; using OTSModelSharp.ServiceCenter; using System; using System.Collections; using System.Drawing; using System.Threading; using System.Windows.Forms; namespace OTSMeasureApp._5_OTSMeasureStatuImageFun { public partial class frmBCRegulate : Form { public PointF stdPos; public string brightphaseMaterial; public int brightphasevalue; public string darkphaseMaterial; public int darkphasevalue; public bool isToRun = false; public double initialBrightness; public double initialContrast; public int mag = 100; //放大倍数 public AutoRegulateType autoregulateType = AutoRegulateType.EveryPeriod; //自动调节类型 public int period = 60; //minutes to run the regulation public CMeasure m_measureobj; private ISemController semController = SemController.GetSEMController(); public CSEMStageData stageData = null; public frmBCRegulate() { InitializeComponent(); } private void frmBCRegulate_Load_1(object sender, EventArgs e) { // 国际化 OTSCommon.Language lan = new OTSCommon.Language(this); Hashtable table = lan.GetNameTable(this.Name); this.Text = table["frmcaption"].ToString(); this.label1.Text = table["stdpos"].ToString(); this.label2.Text = table["bright"].ToString(); this.label3.Text = table["dark"].ToString(); this.label4.Text = table["initbright"].ToString(); this.label5.Text = table["initcontrast"].ToString(); this.label6.Text = table["mag"].ToString(); //this.label7.Text = table["label7"].ToString(); this.button2.Text = table["autobctest"].ToString(); this.button1.Text = table["read"].ToString(); this.button4.Text = table["read"].ToString(); this.button5.Text = table["read"].ToString(); this.button6.Text = table["write"].ToString(); this.button8.Text = table["stop"].ToString(); //this.button7.Text = table["ok"].ToString(); this.button3.Text = table["record"].ToString(); this.EnableAutoBC.Text = table["enableautobc"].ToString(); this.radiobtnEveryPeriod.Text = table["everyperiod"].ToString(); this.radiobtnEverySample.Text = table["everysample"].ToString(); txtstdpos.Text = stdPos.ToString(); cbobrele.Text = brightphaseMaterial; cbodarkele.Text = darkphaseMaterial; txtbrvalue.Text = brightphasevalue.ToString(); txtdarkvalue.Text = darkphasevalue.ToString(); txtinitbr.Text = initialBrightness.ToString(); txtinitcontrast.Text = initialContrast.ToString(); txtMag.Text = mag.ToString(); radiobtnEveryPeriod.Checked = autoregulateType == AutoRegulateType.EveryPeriod; radiobtnEverySample.Checked = autoregulateType == AutoRegulateType.EverySample; txtperiod.Text = period.ToString(); EnableAutoBC.Checked = isToRun; } private void button1_Click(object sender, EventArgs e) { stdPos = Point.Empty; double r = 0; double x=0, y = 0; semController.GetSemPositionXY(ref x, ref y, ref r); stageData.ConvertSEMToOTSCoord( new Point((int)x, (int)y),ref stdPos); txtstdpos.Text = stdPos.ToString(); } private void button2_Click(object sender, EventArgs e) { var param = m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam; param.stdMaterialOTSPos=new Point((int)stdPos.X,(int)stdPos.Y); param.brightphaseelement = cbobrele.Text; param.brightphaseGrayvalue = int.Parse(txtbrvalue.Text); param.darkphaseelement = cbodarkele.Text; param.darkphaseGrayvalue = int.Parse(txtdarkvalue.Text); param.mag = txtMag.Text == "" ? 100 : int.Parse(txtMag.Text); param.initialBrightness = double.Parse(txtinitbr.Text); param.initialContrast = double.Parse(txtinitcontrast.Text); param.toRun = EnableAutoBC.Checked; m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam = param; Thread thread = new Thread(new ThreadStart(m_measureobj.DoBrightnessContrastAdjust)); thread.Start(); } private void button3_Click(object sender, EventArgs e) { var param = m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam; param.stdMaterialOTSPos = new Point((int)stdPos.X, (int)stdPos.Y); param.brightphaseelement = cbobrele.Text; param.brightphaseGrayvalue = int.Parse(txtbrvalue.Text); param.darkphaseelement = cbodarkele.Text; param.darkphaseGrayvalue = int.Parse(txtdarkvalue.Text); param.mag = txtMag.Text == "" ? 100 : int.Parse(txtMag.Text); param.initialBrightness = double.Parse(txtinitbr.Text); param.initialContrast = double.Parse(txtinitcontrast.Text); param.toRun = EnableAutoBC.Checked; param.period= txtperiod.Text == "" ? 60 : int.Parse(txtperiod.Text); param.autoRegulateType =radiobtnEveryPeriod.Checked ? AutoRegulateType.EveryPeriod : AutoRegulateType.EverySample; m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam = param; Close(); } private void button4_Click(object sender, EventArgs e) { CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj); int dark = 0, bright = 0; regulater.GetCurrentTwoProminentGray(ref dark, ref bright); txtbrvalue.Text = bright.ToString(); txtdarkvalue.Text = dark.ToString(); } private void button5_Click(object sender, EventArgs e) { CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj); double br = 0, contra = 0; regulater.GetCurrentBrightnessAndContrast(ref br, ref contra); txtinitbr.Text = br.ToString(); txtinitcontrast.Text = contra.ToString(); } private void button6_Click(object sender, EventArgs e) { CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj); double br = double.Parse(txtinitbr.Text), contra =double.Parse(txtinitcontrast.Text); regulater.WriteBrightnessAndContrast(ref br,ref contra); } private void button7_Click(object sender, EventArgs e) { CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj); regulater.MoveSEMToPoint(new PointF(stdPos.X, stdPos.Y)); } private void button8_Click(object sender, EventArgs e) { m_measureobj.GetMsrThreadStatus().SetStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED); } } }