frmBCRegulate.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using OTSDataType;
  2. using OTSMeasureApp._0_OTSModel.OTSDataType;
  3. using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
  4. using OTSModelSharp;
  5. using OTSModelSharp.ServiceCenter;
  6. using System;
  7. using System.Collections;
  8. using System.Drawing;
  9. using System.Threading;
  10. using System.Windows.Forms;
  11. namespace OTSMeasureApp._5_OTSMeasureStatuImageFun
  12. {
  13. public partial class frmBCRegulate : Form
  14. {
  15. public PointF stdPos;
  16. public string brightphaseMaterial;
  17. public int brightphasevalue;
  18. public string darkphaseMaterial;
  19. public int darkphasevalue;
  20. public bool isToRun = false;
  21. public double initialBrightness;
  22. public double initialContrast;
  23. public int mag = 100; //放大倍数
  24. public AutoRegulateType autoregulateType = AutoRegulateType.EveryPeriod; //自动调节类型
  25. public int period = 60; //minutes to run the regulation
  26. public CMeasure m_measureobj;
  27. private ISemController semController = SemController.GetSEMController();
  28. public CSEMStageData stageData = null;
  29. public frmBCRegulate()
  30. {
  31. InitializeComponent();
  32. }
  33. private void frmBCRegulate_Load_1(object sender, EventArgs e)
  34. {
  35. // 国际化
  36. OTSCommon.Language lan = new OTSCommon.Language(this);
  37. Hashtable table = lan.GetNameTable(this.Name);
  38. this.Text = table["frmcaption"].ToString();
  39. this.label1.Text = table["stdpos"].ToString();
  40. this.label2.Text = table["bright"].ToString();
  41. this.label3.Text = table["dark"].ToString();
  42. this.label4.Text = table["initbright"].ToString();
  43. this.label5.Text = table["initcontrast"].ToString();
  44. this.label6.Text = table["mag"].ToString();
  45. //this.label7.Text = table["label7"].ToString();
  46. this.button2.Text = table["autobctest"].ToString();
  47. this.button1.Text = table["read"].ToString();
  48. this.button4.Text = table["read"].ToString();
  49. this.button5.Text = table["read"].ToString();
  50. this.button6.Text = table["write"].ToString();
  51. this.button8.Text = table["stop"].ToString();
  52. //this.button7.Text = table["ok"].ToString();
  53. this.button3.Text = table["record"].ToString();
  54. this.EnableAutoBC.Text = table["enableautobc"].ToString();
  55. this.radiobtnEveryPeriod.Text = table["everyperiod"].ToString();
  56. this.radiobtnEverySample.Text = table["everysample"].ToString();
  57. txtstdpos.Text = stdPos.ToString();
  58. cbobrele.Text = brightphaseMaterial;
  59. cbodarkele.Text = darkphaseMaterial;
  60. txtbrvalue.Text = brightphasevalue.ToString();
  61. txtdarkvalue.Text = darkphasevalue.ToString();
  62. txtinitbr.Text = initialBrightness.ToString();
  63. txtinitcontrast.Text = initialContrast.ToString();
  64. txtMag.Text = mag.ToString();
  65. radiobtnEveryPeriod.Checked = autoregulateType == AutoRegulateType.EveryPeriod;
  66. radiobtnEverySample.Checked = autoregulateType == AutoRegulateType.EverySample;
  67. txtperiod.Text = period.ToString();
  68. EnableAutoBC.Checked = isToRun;
  69. }
  70. private void button1_Click(object sender, EventArgs e)
  71. {
  72. stdPos = Point.Empty;
  73. double r = 0;
  74. double x=0, y = 0;
  75. semController.GetSemPositionXY(ref x, ref y, ref r);
  76. stageData.ConvertSEMToOTSCoord( new Point((int)x, (int)y),ref stdPos);
  77. txtstdpos.Text = stdPos.ToString();
  78. }
  79. private void button2_Click(object sender, EventArgs e)
  80. {
  81. var param = m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam;
  82. param.stdMaterialOTSPos=new Point((int)stdPos.X,(int)stdPos.Y);
  83. param.brightphaseelement = cbobrele.Text;
  84. param.brightphaseGrayvalue = int.Parse(txtbrvalue.Text);
  85. param.darkphaseelement = cbodarkele.Text;
  86. param.darkphaseGrayvalue = int.Parse(txtdarkvalue.Text);
  87. param.mag = txtMag.Text == "" ? 100 : int.Parse(txtMag.Text);
  88. param.initialBrightness = double.Parse(txtinitbr.Text);
  89. param.initialContrast = double.Parse(txtinitcontrast.Text);
  90. param.toRun = EnableAutoBC.Checked;
  91. m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam = param;
  92. Thread thread = new Thread(new ThreadStart(m_measureobj.DoBrightnessContrastAdjust));
  93. thread.Start();
  94. }
  95. private void button3_Click(object sender, EventArgs e)
  96. {
  97. var param = m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam;
  98. param.stdMaterialOTSPos = new Point((int)stdPos.X, (int)stdPos.Y);
  99. param.brightphaseelement = cbobrele.Text;
  100. param.brightphaseGrayvalue = int.Parse(txtbrvalue.Text);
  101. param.darkphaseelement = cbodarkele.Text;
  102. param.darkphaseGrayvalue = int.Parse(txtdarkvalue.Text);
  103. param.mag = txtMag.Text == "" ? 100 : int.Parse(txtMag.Text);
  104. param.initialBrightness = double.Parse(txtinitbr.Text);
  105. param.initialContrast = double.Parse(txtinitcontrast.Text);
  106. param.toRun = EnableAutoBC.Checked;
  107. param.period= txtperiod.Text == "" ? 60 : int.Parse(txtperiod.Text);
  108. param.autoRegulateType =radiobtnEveryPeriod.Checked ? AutoRegulateType.EveryPeriod : AutoRegulateType.EverySample;
  109. m_measureobj.m_pMeasureParam.GetDefaultParam().BrightnessContrastRegulationParam = param;
  110. Close();
  111. }
  112. private void button4_Click(object sender, EventArgs e)
  113. {
  114. CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj);
  115. int dark = 0, bright = 0;
  116. regulater.GetCurrentTwoProminentGray(ref dark, ref bright);
  117. txtbrvalue.Text = bright.ToString();
  118. txtdarkvalue.Text = dark.ToString();
  119. }
  120. private void button5_Click(object sender, EventArgs e)
  121. {
  122. CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj);
  123. double br = 0, contra = 0;
  124. regulater.GetCurrentBrightnessAndContrast(ref br, ref contra);
  125. txtinitbr.Text = br.ToString();
  126. txtinitcontrast.Text = contra.ToString();
  127. }
  128. private void button6_Click(object sender, EventArgs e)
  129. {
  130. CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj);
  131. double br = double.Parse(txtinitbr.Text), contra =double.Parse(txtinitcontrast.Text);
  132. regulater.WriteBrightnessAndContrast(ref br,ref contra);
  133. }
  134. private void button7_Click(object sender, EventArgs e)
  135. {
  136. CBrightnessContrastAdjust regulater = new CBrightnessContrastAdjust(m_measureobj);
  137. regulater.MoveSEMToPoint(new PointF(stdPos.X, stdPos.Y));
  138. }
  139. private void button8_Click(object sender, EventArgs e)
  140. {
  141. m_measureobj.GetMsrThreadStatus().SetStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  142. }
  143. }
  144. }