OTSIncAMeasureAppForm.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using OTS.WinFormsUI.Docking;
  6. using System.Runtime.InteropServices;
  7. using System.Collections;
  8. using OTSDataType;
  9. using OTSModelSharp;
  10. using OTSModelSharp.ResourceManage;
  11. using static OTSDataType.otsdataconst;
  12. using System.Diagnostics;
  13. using OTSCLRINTERFACE;
  14. using System.IO;
  15. using System.Management;
  16. using System.Xml;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Runtime.Remoting.Channels.Ipc;
  20. using System.Runtime.Remoting.Channels;
  21. using System.Runtime.Remoting;
  22. using OTSMeasureApp.ServiceCenter;
  23. using OTSMeasureApp._10_OTSSplashScreen;
  24. using System.Threading;
  25. namespace OTSMeasureApp
  26. {
  27. public enum ShapeType
  28. {
  29. CIRCUL = 0, //圆形
  30. RECTANGLE = 1 //矩形
  31. };
  32. enum MessageBoxRev
  33. {
  34. DIALOG_YES = 0,
  35. DIALOG_NO = 1,
  36. DIALOG_CANCEL = 2
  37. }
  38. public partial class OTSIncAMeasureAppForm : Form
  39. {
  40. Thread th = new Thread(new ThreadStart(DoSplash));
  41. public static string m_SamplespaceWindowName = "样品台";
  42. public static string m_MeasureStauWindowName = "测量状态";
  43. public static string m_MeasureRetWindowName = "测量结果";
  44. public static string m_NoWindowName = "未知工作窗口";
  45. //国际化
  46. OTSCommon.Language lan;
  47. Hashtable table;
  48. public OTSRibbonFun m_RibbonFun = null;
  49. // 初始化日志类
  50. NLog.Logger log ;
  51. private PostLogMsg m_LogMsg;
  52. public const int MsgID = 0x0464;
  53. public const int LogMsgID = 0x0465;
  54. // Control m_ControlWindow = null;
  55. public OTSMeasureResultWindow m_MeasureResultWindow = null;
  56. public OTSMeasureStatusWindow m_MessureStatuWindow = null;
  57. public OTSSamplespaceWindow m_SamplepaceWindow = null;
  58. public OTSMeasureOutputNlog m_OTSMeasureOutputNlog = null;
  59. public COTSMeasureParam m_ProjParam = null;
  60. public COTSMsrPrjResultData m_ProjRstData;
  61. public OTSSolutionWindow m_SolutionWindows = null;
  62. public OTSPropertyWindow m_SPropertyWindows = null;
  63. //测量线程对象
  64. public CMeasureThreadWrapper m_MsrThreadWrapper = null;
  65. // 测量线程当前状态 True: 正在测量; False: 测量结束
  66. public bool MeasureThreadRunFlag { get => m_MsrThreadWrapper.BGWorkThreadIsRunning(); }
  67. public MSR_RUN_TYPE GetRunType()
  68. {
  69. return m_MsrThreadWrapper.GetDoRunType();
  70. }
  71. public void SetRunType(MSR_RUN_TYPE value)
  72. {
  73. m_MsrThreadWrapper.SetDoRunType(value);
  74. }
  75. public FileSystemWatcher fileWatcher = new FileSystemWatcher(Application.StartupPath+ @"\Config\SysData");
  76. public OTSIncAMeasureAppForm()
  77. {
  78. th.Start();
  79. InitializeComponent();
  80. //国际化
  81. lan = new OTSCommon.Language(this);
  82. table = lan.GetNameTable(this.Name);
  83. m_SamplespaceWindowName = table["m_samplespacewindowname"].ToString();
  84. m_MeasureStauWindowName = table["m_measurestauwindowname"].ToString();
  85. m_MeasureRetWindowName = table["m_measureretwindowname"].ToString();
  86. m_NoWindowName = table["m_nowindowname"].ToString();
  87. m_OTSMeasureOutputNlog = new OTSMeasureOutputNlog();
  88. m_OTSMeasureOutputNlog.Show();
  89. // 初始化Docpanle
  90. m_SolutionWindows = new OTSSolutionWindow(this);
  91. m_SPropertyWindows = new OTSPropertyWindow(this);
  92. m_MeasureResultWindow = new OTSMeasureResultWindow(this);
  93. m_MeasureResultWindow.Text = m_MeasureRetWindowName;
  94. m_MessureStatuWindow = new OTSMeasureStatusWindow(this);
  95. m_MessureStatuWindow.Text = m_MeasureStauWindowName;
  96. m_SamplepaceWindow = new OTSSamplespaceWindow(this);
  97. m_SamplepaceWindow.Text = m_SamplespaceWindowName;
  98. m_ProjParam = new COTSMeasureParam(this);
  99. m_ProjRstData = m_ProjParam.GetResultData();
  100. //初始化Ribbon类,操作Ribbon按钮的可用或者不可用
  101. m_RibbonFun = new OTSRibbonFun(this);
  102. //初始化测量线程
  103. m_MsrThreadWrapper = new CMeasureThreadWrapper(this);//must be the last sentence of this procedure.
  104. fileWatcher.Changed += FileWatcher_Changed;
  105. fileWatcher.EnableRaisingEvents=true;
  106. }
  107. private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
  108. {
  109. if (e.Name == "SpecialGrayConfig.xml")
  110. {
  111. m_ProjParam.SpecialRanges.IsInited = false;
  112. foreach (var s in this.m_ProjRstData.GetSampleList())
  113. {
  114. s.GetMsrParams().GetSpecialGrayRangeParam().IsInited = false;
  115. }
  116. }
  117. }
  118. private void OTSIncAMeasureAppForm_Load(object sender, EventArgs e)
  119. {
  120. try
  121. {
  122. ArrangWorkspaceWindow();
  123. log = NLog.LogManager.GetCurrentClassLogger();
  124. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  125. {
  126. m_ProjParam.LoadSpecialGrayRangeParamFile();
  127. if (m_ProjParam.InitResultData())
  128. {
  129. m_RibbonFun.SetAllRibbonButnStatus(true);
  130. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(),m_ProjRstData.GetSEMStageData());
  131. //添加启动系统界面显示
  132. if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.IncA)
  133. {
  134. this.Text += "(Inclusion)";
  135. }
  136. else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
  137. {
  138. this.Text += "(Cleanness)";
  139. }
  140. }
  141. else
  142. {
  143. log.Error(" InitResultData() failed");
  144. }
  145. }
  146. else
  147. {
  148. log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) (LoadParamFile() && LoadStageParamFile()) failed");
  149. }
  150. if (!m_MsrThreadWrapper.ConnectSEM())
  151. {
  152. MessageBox.Show("Connect SEM failed!Please goto the SysMgrApp.exe to setup the proper parameter or check other parameter of the EDS software");
  153. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  154. process.FileName = "OTSSysMgrApp.exe";//打开app的路径
  155. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  156. System.Diagnostics.Process.Start(process);
  157. this.rbConnectHardware.Enabled = true;
  158. this.rbDisconnectHardware.Enabled = false;
  159. }
  160. this.rbConnectHardware.Enabled = false;
  161. this.rbDisconnectHardware.Enabled = true;
  162. log.Warn("SEM connect success!");
  163. PrepareIpcServer();
  164. log.Info("Ipc server start success!");
  165. //----------------------Test Code, Don't delete
  166. //var f = new BaseFunctionTest();
  167. //f.ShowDialog();
  168. //----------------------
  169. }
  170. catch (Exception ex)
  171. {
  172. log.Error(" OTSIncAMeasureAppForm_Load:" + ex.ToString());
  173. }
  174. th.Abort();
  175. this.Activate();
  176. }
  177. public void ArrangWorkspaceWindow()
  178. {
  179. //Show 样品台窗口
  180. m_SamplepaceWindow.Show(dockPanel);
  181. //Show 测量状态窗口
  182. m_MessureStatuWindow.Show(dockPanel);
  183. //Show 测量结果窗口
  184. m_MeasureResultWindow.Show(dockPanel);
  185. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  186. //Show 测量过程中Log显示窗口
  187. //m_OTSMeasureOutputNlog.Show();
  188. m_OTSMeasureOutputNlog.Show(dockPanel, DockState.DockRight);
  189. dockPanel.DockRightPortion = 365;
  190. m_SPropertyWindows.Show(dockPanel);
  191. m_SamplepaceWindow.Activate();
  192. }
  193. static private void DoSplash()
  194. {
  195. string path = @".\Config\SysData\OTSProgMgrParam.pmf";
  196. XmlDocument xmlDocument = new XmlDocument();
  197. xmlDocument.Load(path);
  198. XmlNode node = xmlDocument.SelectSingleNode("XMLData");
  199. XmlElement xe = (XmlElement)node;
  200. string str = xe.GetAttribute("SysType");
  201. if (str == "IncA")
  202. {
  203. OTSSplashScreen_IncA sp = new OTSSplashScreen_IncA();
  204. sp.ShowDialog();
  205. }
  206. else if (str == "CleannessA")
  207. {
  208. OTSSplashScreen_Cleanness sp = new OTSSplashScreen_Cleanness();
  209. sp.ShowDialog();
  210. }
  211. }
  212. private void rbReport_Click(object sender, EventArgs e)
  213. {
  214. //测量结果文件路径列表
  215. List<string> mrFilePathList = new List<string>();
  216. //获取测量结果文件路径列表
  217. bool result = m_ProjParam.GetCompletedMeasureFileName(ref mrFilePathList);
  218. if (result)
  219. {
  220. for (int i = 0; i < mrFilePathList.Count; i++)
  221. {
  222. mrFilePathList[i] = mrFilePathList[i].Replace(" ", "^");
  223. }
  224. //转换为数组
  225. string[] resultFilePath = mrFilePathList.ToArray();
  226. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  227. process.FileName = "OTSIncAReportApp.exe";//打开app的路径
  228. string FilePath = string.Join(" ", resultFilePath);
  229. process.Arguments = FilePath;//多个参数用空格隔开
  230. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  231. System.Diagnostics.Process.Start(process);
  232. }
  233. }
  234. // sNewWorkSampleName: 新工作样品名
  235. public void SwitchWSample(string sNewWorkSampleName)
  236. {
  237. m_ProjParam.SetWorkSample(sNewWorkSampleName);
  238. m_SolutionWindows.SwitchSample(sNewWorkSampleName);
  239. //获取新工作样品属性值
  240. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  241. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  242. //发送想你的样品名给Sample
  243. m_SamplepaceWindow.SwitchWorkSample(sNewWorkSampleName);
  244. }
  245. public void SoluWindowCheckBoxStatuChange(string sSampleName, bool bCheckBoxStatu)
  246. {
  247. string sWSampleName = m_ProjParam.GetWorkSampleName();
  248. if ("" == sWSampleName)
  249. {
  250. //不修改Tteeview 的工作样品属性值
  251. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  252. return;
  253. }
  254. //Treeview更改的工作样品数的CHECKBOX 状态
  255. if (!m_ProjParam.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH, OTS_ITEM_TYPES.BOOL, bCheckBoxStatu))
  256. {
  257. //不修改Tteeview 的工作样品属性值
  258. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  259. return;
  260. }
  261. // 设置 开始 ,停止 和检查参数 按钮状态
  262. m_RibbonFun.SetMeasureRibbonButnStatu();
  263. //修改Grid工作样品的SWITCH值
  264. OTSSampleVisualPropertyInfo SMeasurenfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  265. m_SPropertyWindows.DisplaySampleMeasureInfo(SMeasurenfo);
  266. }
  267. public bool EditWorkSampleName(string sSampleOldName, string sSampleNewName)
  268. {
  269. if (!m_ProjParam.ChangeWorkSampleName(sSampleNewName))
  270. {
  271. return false;
  272. }
  273. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  274. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  275. m_SamplepaceWindow.ChangeWorkSampleName(sSampleNewName);
  276. return true;
  277. }
  278. public void SoluwindowReqAddSample()
  279. {
  280. //Treeview右键点击添加新样品
  281. this.AddNewSampleMeasure();
  282. }
  283. private void OTSIncAMeasureAppForm_FormClosing(object sender, FormClosingEventArgs e)
  284. {
  285. try
  286. {
  287. if (m_MsrThreadWrapper.BGWorkThreadIsRunning ()) //当前正在测量
  288. {
  289. e.Cancel = true;
  290. return;
  291. }
  292. if (m_MsrThreadWrapper.IsHavingNotCompleteSamples()) //当前正在测量
  293. {
  294. e.Cancel = true;
  295. MessageBox.Show("There is one sample is still in pausing state,please stop it!");
  296. return;
  297. }
  298. //判断测量结果文件修改后是否保存
  299. if (m_ProjRstData.IsModified())
  300. {
  301. string message = table["message2"].ToString();
  302. DialogResult lsdr = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
  303. if (lsdr == DialogResult.Yes)
  304. {
  305. //保存,退出
  306. m_ProjRstData.Save();
  307. //保存,直接退出
  308. Application.ExitThread();
  309. }
  310. else if (lsdr == DialogResult.No)
  311. {
  312. //不保存,直接退出
  313. Application.ExitThread();
  314. }
  315. else if (lsdr == DialogResult.Cancel)
  316. {
  317. //取消
  318. e.Cancel = true;
  319. return;
  320. }
  321. }
  322. log.Info("Disconnect SEM!");
  323. m_MsrThreadWrapper.DisconnectSEM();
  324. m_MsrThreadWrapper.SetWorkThreadPending();
  325. }
  326. catch (Exception ex)
  327. {
  328. string message = table["message3"].ToString();
  329. log.Error("OTSIncAMeasureAppForm_FormClosing-"+ message + ":" + ex.ToString());
  330. }
  331. Process.GetCurrentProcess().Kill();
  332. }
  333. //打开指定路径的文件
  334. private void ribbonOrbMenuItem1_OpenWorkspace_Click(object sender, EventArgs e)
  335. {
  336. OpenMeasureProjectFile();
  337. //UpdatePropertyVal();
  338. }
  339. //新建样品工作文件
  340. private void ribbonOrbMenuItem3_CreateWorkspace_Click(object sender, EventArgs e)
  341. {
  342. int iCreateNewFileResult = m_ProjParam.CreateNewFile();
  343. if (iCreateNewFileResult == 0)
  344. {
  345. log.Error("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Failed !");
  346. return;
  347. }
  348. else if(iCreateNewFileResult == 2)
  349. {
  350. log.Info("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Cancel !");
  351. return;
  352. }
  353. m_RibbonFun.SetAllRibbonButnStatus(true);
  354. //清除TREEVIEW和GRID上的显示的已经保存的样品信息
  355. m_SolutionWindows.m_TreeViewBase.DeleteAllTreeNode();
  356. m_SPropertyWindows.m_SampleGrid.HideGrid();
  357. //设置报告按钮
  358. rbPReport.Enabled = false;
  359. rbReport.Enabled = false;
  360. rbReClassify.Enabled = true;
  361. //新建项目时,设置属性窗体中的两个按钮也为不可用状态
  362. m_SPropertyWindows.TSLoad.Enabled = false;
  363. m_SPropertyWindows.TSSaveAs.Enabled = false;
  364. //绘制样品台
  365. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  366. //隐藏XrayTable控件
  367. m_MessureStatuWindow.HideXRayTable();
  368. //新建时重新初始化结果窗体结果
  369. m_MeasureResultWindow.SetInit();
  370. }
  371. // 新建样品时提示保存样品信息Messagebox
  372. public int ShowSaveInfoMsgBox()
  373. {
  374. string message = table["message4"].ToString();
  375. DialogResult dResult = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
  376. if (dResult == DialogResult.Yes)
  377. {
  378. return (int)MessageBoxRev.DIALOG_YES;
  379. }
  380. else if (dResult == DialogResult.No)
  381. {
  382. return (int)MessageBoxRev.DIALOG_NO;
  383. }
  384. else
  385. {
  386. return (int)MessageBoxRev.DIALOG_CANCEL;
  387. }
  388. }
  389. //打开已经保存的工作文件
  390. private bool DisplayExistSampleFile()
  391. {
  392. List<CTreeSampleParam> TSampleParamList = new List<CTreeSampleParam>();
  393. List<SampleMeasurePara> SampleMeasureParaList = new List<SampleMeasurePara>();
  394. int iSampleCount = m_ProjRstData.GetSampleList().Count;
  395. if (0 == iSampleCount)
  396. {
  397. return false;
  398. }
  399. for (int i = 0; i < iSampleCount; i++)
  400. {
  401. CTreeSampleParam CTSampleParam = new CTreeSampleParam();
  402. COTSSample SampleClr = (m_ProjRstData.GetSampleList())[i];
  403. CTSampleParam.sSampleTitleName = m_ProjRstData.GetFileName();
  404. CTSampleParam.sWorkSampleName = SampleClr.GetName();
  405. CTSampleParam.bSwitch = SampleClr.GetSwitch();
  406. TSampleParamList.Add(CTSampleParam);
  407. }
  408. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  409. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  410. m_SolutionWindows.DisplayExistSampleFile(TSampleParamList, SMInfo.TSampleParam);
  411. if (!InitExistSampleMeasureParam(ref SampleMeasureParaList))
  412. {
  413. log.Error(" OpenExistSampleMeasureArea(ref SampleMeasureAreaList) Failed !");
  414. return false;
  415. }
  416. string sWSampleName = m_ProjParam.GetWorkSampleName();
  417. if ("" == sWSampleName)
  418. {
  419. log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile) m_DataMgrFun.GetWorkSampleName() = null !");
  420. return false;
  421. }
  422. m_SamplepaceWindow.DisplayVisualStage(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  423. m_SamplepaceWindow.DisplayExistSamples( SampleMeasureParaList);
  424. m_MeasureResultWindow.UpdateResultInfoBySampleName(sWSampleName);
  425. return true;
  426. }
  427. public bool InitExistSampleMeasureParam(ref List<SampleMeasurePara> SampleMeasureParaList)
  428. {
  429. int iSListCount = m_ProjRstData.GetSampleList().Count;
  430. if (0 == iSListCount)
  431. {
  432. return false;
  433. }
  434. for (int i = 0; i < iSListCount; i++)
  435. {
  436. SampleMeasurePara SampleMeasureParam =new SampleMeasurePara(m_ProjRstData.GetSampleList()[i]);
  437. SampleMeasureParaList.Add(SampleMeasureParam);
  438. }
  439. return true;
  440. }
  441. //打开指定路径的文件
  442. private void rbOpen_Click(object sender, EventArgs e)
  443. {
  444. OpenMeasureProjectFile();
  445. }
  446. private void rbDeleteSample_Click(object sender, EventArgs e)
  447. {
  448. //删除样品(样品必须先选中)
  449. string sWSampleName = m_ProjParam.GetWorkSampleName();
  450. if ("" == sWSampleName)
  451. {
  452. log.Error("(OTSIncAMeasureAppForm.rbDeleteSample_Click) m_DataMgrFun.GetWorkSampleName() = null Failed");
  453. return;
  454. }
  455. string message = table["message5"].ToString();
  456. string message6 = table["message6"].ToString();
  457. string sDeleteSampleName = message;
  458. sDeleteSampleName += sWSampleName;
  459. sDeleteSampleName += message6;
  460. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Tip", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  461. {
  462. //删除样品成功
  463. DeleteSample(sWSampleName);
  464. sWSampleName = m_ProjParam.GetWorkSampleName();
  465. if ("" != sWSampleName)
  466. {
  467. m_SolutionWindows.m_TreeViewBase.GetTreeWorkSampleNode(sWSampleName);
  468. m_SolutionWindows.treeView1.Focus();
  469. }
  470. }
  471. }
  472. //返回删除的工作样品名
  473. public void DeleteSample(string sDeleteWSampleName = "")
  474. {
  475. if (m_MsrThreadWrapper.m_measure.mapSmplMsr.ContainsKey(sDeleteWSampleName))
  476. {
  477. m_MsrThreadWrapper.m_measure.mapSmplMsr.Remove(sDeleteWSampleName);
  478. }
  479. m_ProjParam.DeleteWorkSample(sDeleteWSampleName);
  480. // 设置 开始 ,停止 和检查参数 按钮状态
  481. m_RibbonFun.SetMeasureRibbonButnStatu();
  482. //设置 删除,复位,圆形,矩形 按钮状态
  483. m_RibbonFun.SetSampleRibbonButnStatus();
  484. // 更新报告ribbon按钮状态
  485. m_RibbonFun.SetAllRibbonButnStatus(true);
  486. int iSampleCount = m_ProjParam.GetSampleCount();
  487. if (0 == iSampleCount)
  488. {
  489. //给工作样品台发送删除样品和新的工作样品名称
  490. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  491. m_SPropertyWindows.PropGrid.Hide();
  492. m_SolutionWindows.treeView1.Nodes.Clear();
  493. m_MessureStatuWindow.HideXRayTable();
  494. m_MeasureResultWindow.SetInit();
  495. return ;
  496. }
  497. else
  498. {
  499. string sNewWSName = m_ProjParam.GetWorkSampleName();
  500. if ("" == sNewWSName)
  501. {
  502. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetWorkSampleName() = null Failed");
  503. return ;
  504. }
  505. m_SolutionWindows.DeletCurrentSampleNode();
  506. m_SolutionWindows.DisplaySample(sNewWSName);
  507. //将测量状态初始化
  508. m_MessureStatuWindow.SetMeasureStatusInit();
  509. //给工作样品台发送删除样品和新的工作样品名称
  510. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  511. //设置工作样品
  512. SwitchWSample(sNewWSName);
  513. }
  514. return ;
  515. }
  516. private void rbAddSample_Click(object sender, EventArgs e)
  517. {
  518. this.AddNewSampleMeasure();//the system will choose the empty hole one by one according to the holeNo sequence.
  519. }
  520. public void AddNewSampleMeasure(string sSampleHoleName = "")
  521. {
  522. OTSSampleVisualPropertyInfo SMInfo = m_ProjParam.AddNewSampleMeasure(sSampleHoleName);
  523. if (null == SMInfo)
  524. {
  525. // 设置 开始 ,停止 和检查参数 按钮状态
  526. m_RibbonFun.SetMeasureRibbonButnStatu();
  527. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  528. return;
  529. }
  530. m_SPropertyWindows.TSSaveAs.Enabled = true;
  531. m_SPropertyWindows.TSLoad.Enabled = true;
  532. m_SPropertyWindows.TSEdit.Enabled = false;
  533. m_SPropertyWindows.TSEdit.Visible = false;
  534. //给SampleWindow 发送样品信息
  535. m_SamplepaceWindow.AddSampleArea(SMInfo.SMeasurePara);
  536. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  537. //给PropWindow 发送工作样品属性信息
  538. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  539. //给SoluWindow 发送样品显示信息
  540. m_SolutionWindows.AddSampleMeasure(SMInfo.TSampleParam);
  541. // 设置 开始 ,停止 和检查参数 按钮状态
  542. m_RibbonFun.SetMeasureRibbonButnStatu();
  543. //设置 删除,复位,圆形,矩形 按钮状态
  544. m_RibbonFun.SetSampleRibbonButnStatus();
  545. //清空帧图信息
  546. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  547. }
  548. public void InitCurrentSampleState()
  549. {
  550. OTSSampleVisualPropertyInfo SMInfo = m_ProjParam.GetWorkingSampleVisualPropertyInfo();
  551. if (null == SMInfo)
  552. {
  553. // 设置 开始 ,停止 和检查参数 按钮状态
  554. m_RibbonFun.SetMeasureRibbonButnStatu();
  555. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  556. return;
  557. }
  558. m_SPropertyWindows.TSSaveAs.Enabled = true;
  559. m_SPropertyWindows.TSLoad.Enabled = true;
  560. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  561. //给PropWindow 发送工作样品属性信息
  562. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  563. // 设置 开始 ,停止 和检查参数 按钮状态
  564. m_RibbonFun.SetMeasureRibbonButnStatu();
  565. //设置 删除,复位,圆形,矩形 按钮状态
  566. m_RibbonFun.SetSampleRibbonButnStatus();
  567. //清空帧图信息
  568. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  569. }
  570. private void rbSelectDlg_Click(object sender, EventArgs e)
  571. {
  572. //判断样品台是否有样品,如果有样品则不能设置默认参数
  573. if (m_ProjParam.GetSampleCount() > 0)
  574. {
  575. MessageBox.Show("Cann't setup preference parameter,for you have added some samples!");
  576. return;
  577. }
  578. ProgMgrInfoForm ProgMgrForm = new ProgMgrInfoForm();
  579. if (DialogResult.OK == ProgMgrForm.ShowDialog())
  580. {
  581. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  582. {
  583. if (m_ProjParam.InitResultData())
  584. {
  585. m_RibbonFun.SetAllRibbonButnStatus(true);
  586. //当样品台上有样品,则不更新样品台数据
  587. if (0 == m_ProjParam.GetSampleCount())
  588. {
  589. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  590. }
  591. }
  592. else
  593. {
  594. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) this.CheckMeasureSysFileExist() = false");
  595. }
  596. }
  597. else
  598. {
  599. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
  600. }
  601. }
  602. }
  603. // 主Windows框右下角显示鼠标点的SEM坐标(样品台)
  604. public void ShowSemCoordvAL(string sSemCoord)
  605. {
  606. STSemCoordinate.Text = sSemCoord;
  607. statusStrip1.Refresh();
  608. }
  609. //// 主Windows框右下角显示鼠标点的灰度值(测量图)
  610. public void ShowGrayVal(string sGrayVal)
  611. {
  612. TSGrayVal.Text = sGrayVal;
  613. statusStrip1.Refresh();
  614. }
  615. //获取工作样品测量锁
  616. public bool GetWorkSampleParamLock(ref CTreeSampleParam TSParamLock)
  617. {
  618. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  619. TSParamLock = SMInfo.TSampleParam;
  620. return true;
  621. }
  622. /// <summary>
  623. /// 更新属性窗口
  624. /// </summary>
  625. public void UpdatePropertyVal()
  626. {
  627. //获取新的工作样品属性值
  628. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  629. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  630. }
  631. private void ribbonOrbMenuItemSaveAs_Click(object sender, EventArgs e)
  632. {
  633. bool iRev = m_ProjRstData.SaveAs();
  634. if (!iRev)
  635. {
  636. return;
  637. }
  638. m_ProjParam.InitWorkingSampleData(0);
  639. this.InitCurrentSampleState();
  640. m_MeasureResultWindow.SetInit();
  641. m_SamplepaceWindow. PrepareMeasureField(m_SamplepaceWindow.GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  642. }
  643. private void rbSaveFile_Click(object sender, EventArgs e)
  644. {
  645. bool iRev = m_ProjRstData.Save();
  646. if (!iRev)
  647. {
  648. return;
  649. }
  650. }
  651. private void rbCheckParam_Click(object sender, EventArgs e)
  652. {
  653. //检查样品测量参数
  654. if (m_ProjParam.CheckSampleParam(true))
  655. {
  656. string message = table["message7"].ToString();
  657. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  658. }
  659. }
  660. private void ribReset_Click(object sender, EventArgs e)
  661. {
  662. //调用样品台窗口中的复位方法
  663. m_SamplepaceWindow.ResetWorkSampleMeasure();
  664. }
  665. //绘制圆形测量区域
  666. private void ribCircle_Click(object sender, EventArgs e)
  667. {
  668. //修改工作样品的测量区域为圆形
  669. m_SamplepaceWindow.DrawCircleMeasure();
  670. }
  671. private void rbThreePoints_Click(object sender, EventArgs e)
  672. {
  673. //修改工作样品的测量区域为圆形
  674. m_SamplepaceWindow.DrawCircleMeasureByThreePoints();
  675. }
  676. private void rbRingShape_Click(object sender, EventArgs e)
  677. {
  678. //修改工作样品的测量区域为圆形
  679. m_SamplepaceWindow.DrawRingShapeArea();
  680. }
  681. //绘制矩形测量区域
  682. private void ribRectangle_Click(object sender, EventArgs e)
  683. {
  684. //修改工作样品的测量区域为矩形
  685. m_SamplepaceWindow.DrawRectangleMeasure();
  686. }
  687. private void rbExitApp_Click(object sender, EventArgs e)
  688. {
  689. this.Close();
  690. }
  691. private void rbStart_Click(object sender, EventArgs e)
  692. {
  693. if (!m_ProjParam.CheckSampleParam(false))
  694. {
  695. return;
  696. }
  697. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning() && !m_MsrThreadWrapper.BgWorkIsPaused())
  698. {
  699. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  700. m_MsrThreadWrapper.StartBGWorkThread();
  701. m_RibbonFun.SetMeasureRibbonButnStatu();
  702. }
  703. else //thread is in pausing state
  704. {
  705. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  706. m_MsrThreadWrapper.SetMeasureThreadStatus(OTS_MSR_THREAD_STATUS.INPROCESS);
  707. m_RibbonFun.SetMeasureRibbonButnStatu();
  708. }
  709. }
  710. public void SetStartMeasureRibbonStatus()
  711. {
  712. ribView.Enabled = false;
  713. m_RibbonFun.SetToolButnStatu(false);
  714. //false: 将其他ribbon按钮设置为灰色
  715. rbPanelFile.Enabled = false;
  716. rbPanelSample.Enabled = false;
  717. m_SolutionWindows.Enabled = false;
  718. m_SPropertyWindows.Enabled = false;
  719. rbStart.Enabled = false;
  720. //rbPause.Enabled = true;
  721. rbStop.Enabled = true;
  722. rbCheckParam.Enabled = false;
  723. }
  724. private void rbStop_Click(object sender, EventArgs e)
  725. {
  726. //如果当前正在测量,则停止测量线程
  727. if (MeasureThreadRunFlag)
  728. {
  729. //停止测量线程
  730. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  731. }
  732. else if (m_MsrThreadWrapper.m_measure.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
  733. {
  734. foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_measure.mapSmplMsr)
  735. {
  736. if (smpl.Value.GetSample().GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
  737. {
  738. smpl.Value.TheLastWorkOfSampleMeasure();
  739. return;
  740. }
  741. }
  742. }
  743. }
  744. private void rbPause_Click(object sender, EventArgs e)
  745. {
  746. //如果当前正在测量,则停止测量线程
  747. if (MeasureThreadRunFlag)
  748. {
  749. //停止测量线程
  750. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.PAUSED);
  751. }
  752. }
  753. private void rbRuler_Click(object sender, EventArgs e)
  754. {
  755. m_SamplepaceWindow.ShowRulerLocation();
  756. }
  757. private void rbSmapleName_Click(object sender, EventArgs e)
  758. {
  759. //m_SamplepaceWindow.ChangeSampleHoleFont();
  760. }
  761. private void rbSmaplePhoto_Click(object sender, EventArgs e)
  762. {
  763. m_SamplepaceWindow.ChangeSampleHoleImage();
  764. }
  765. //当点击Ribbon停止按钮时,设置Ribbon状态
  766. public void SetStopMeasureRibbonStatus()
  767. {
  768. ribView.Enabled = true;
  769. m_RibbonFun.SetToolButnStatu(true);
  770. rbPanelFile.Enabled = true;
  771. rbPanelSample.Enabled = true;
  772. m_RibbonFun.SetMeasureRibbonButnStatu();
  773. m_SolutionWindows.Enabled = true;
  774. m_SPropertyWindows.Enabled = true;
  775. rbStart.Enabled = true;
  776. rbPause.Enabled = false;
  777. rbStop.Enabled = false;
  778. rbCheckParam.Enabled = true;
  779. //激活跳转至报告程序按钮
  780. rbPReport.Enabled = true;
  781. rbReport.Enabled = true;
  782. }
  783. public void SetPauseMeasureRibbonStatus()
  784. {
  785. ribView.Enabled = true;
  786. m_RibbonFun.SetToolButnStatu(true);
  787. rbPanelFile.Enabled = true;
  788. rbPanelSample.Enabled = true;
  789. m_RibbonFun.SetMeasureRibbonButnStatu();
  790. m_SolutionWindows.Enabled = true;
  791. m_SPropertyWindows.Enabled = true;
  792. rbStart.Enabled = true;
  793. rbPause.Enabled = false;
  794. rbStop.Enabled = true;
  795. rbCheckParam.Enabled = false;
  796. //激活跳转至报告程序按钮
  797. rbPReport.Enabled = true;
  798. rbReport.Enabled = true;
  799. }
  800. public bool SwitchDisplayMeasureSample(string sMsrSampleName)
  801. {
  802. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  803. m_SolutionWindows.SwitchSample(sMsrSampleName);
  804. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  805. return true;
  806. }
  807. #region 开始获取样品孔中的照片
  808. /// <summary>
  809. /// 开始获取样品孔中的照片
  810. /// </summary>
  811. /// <param name="doRunType"></param>
  812. /// <param name="HoleID"></param>
  813. /// <param name="c_DomainMessure"></param>
  814. public void StartSampleHoleBSEImage()
  815. {
  816. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  817. {
  818. m_MsrThreadWrapper.StartBGWorkThread();
  819. m_RibbonFun.SetMeasureRibbonButnStatu();
  820. }
  821. }
  822. #endregion
  823. private void rbRecover_Click(object sender, EventArgs e)
  824. {
  825. //关闭所有内容
  826. CloseAllContents();
  827. //显示样品属性窗口与树结构窗口
  828. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  829. m_SPropertyWindows.Show(dockPanel);
  830. //显示样品台窗口 测量状态与测量结果窗口
  831. m_SamplepaceWindow.Show(dockPanel);
  832. m_MessureStatuWindow.Show(dockPanel);
  833. m_MeasureResultWindow.Show(dockPanel);
  834. //此处将在父窗体选项卡上显示
  835. foreach (Form child in this.MdiChildren)
  836. {
  837. if (child.Name == "OTSSamplespaceWindow")
  838. {
  839. child.Activate();
  840. break;
  841. }
  842. }
  843. }
  844. private void CloseAllContents()
  845. {
  846. m_SolutionWindows.DockPanel = null;
  847. m_SPropertyWindows.DockPanel = null;
  848. m_SamplepaceWindow.DockPanel = null;
  849. m_MessureStatuWindow.DockPanel = null;
  850. m_MeasureResultWindow.DockPanel = null;
  851. CloseAllDocuments();
  852. }
  853. private void CloseAllDocuments()
  854. {
  855. if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
  856. {
  857. foreach (Form form in MdiChildren)
  858. form.Close();
  859. }
  860. else
  861. {
  862. IDockContent[] documents = dockPanel.DocumentsToArray();
  863. foreach (IDockContent content in documents)
  864. content.DockHandler.Close();
  865. }
  866. }
  867. private void rbMeasureCircle_Click(object sender, EventArgs e)
  868. {
  869. m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCUL);
  870. //修改工作样品的测量区域为圆形
  871. m_SamplepaceWindow.changeShape(ShapeType.CIRCUL);
  872. }
  873. private void rbMeasureRectangle_Click(object sender, EventArgs e)
  874. {
  875. m_ProjParam.SetMeasureAreaShape(ShapeType.RECTANGLE);
  876. //修改工作样品的测量区域为矩形
  877. m_SamplepaceWindow.changeShape(ShapeType.RECTANGLE);
  878. }
  879. //ctrl+s组合键进行保存
  880. private void OTSIncAMeasureAppForm_KeyDown(object sender, KeyEventArgs e)
  881. {
  882. if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
  883. {
  884. bool iRev = m_ProjRstData.Save();
  885. if (!iRev)
  886. {
  887. log.Error("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  888. return;
  889. }
  890. log.Error("(OTSIncAMeasureAppForm.rbSaveAs_Click) m_DataMgrFun.SaveFile() Success !");
  891. }
  892. }
  893. private void rbSTDEdit_Click_1(object sender, EventArgs e)
  894. {
  895. OpenFileDialog openFileDialog = new OpenFileDialog();
  896. openFileDialog.Filter = "(*.db)|*.db";
  897. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  898. openFileDialog.RestoreDirectory = true;
  899. openFileDialog.FilterIndex = 1;
  900. if (openFileDialog.ShowDialog() == DialogResult.OK)
  901. {
  902. try
  903. {
  904. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", "\""+openFileDialog.FileName+ "\"");
  905. p.WaitForExit();
  906. }
  907. catch (Exception ex)
  908. {
  909. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  910. }
  911. }
  912. //reload the setup data just now
  913. foreach (var s in this.m_ProjRstData.GetSampleList())
  914. {
  915. var stdname= s.GetMsrParams().GetSTDName();
  916. if (stdname != "NoSTDDB")
  917. {
  918. if (!stdname.Contains(".db"))
  919. {
  920. stdname += ".db";
  921. }
  922. var m_classifyEngine = new COTSClassifyEngineClr(EngineType.ExpressionClassifyEng, stdname);
  923. m_classifyEngine.ReloadEngineDB();
  924. }
  925. }
  926. }
  927. private void rbSysMgrApp_Click(object sender, EventArgs e)
  928. {
  929. try
  930. {
  931. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSSysMgrApp.exe");
  932. p.WaitForExit();
  933. }
  934. catch (Exception ex)
  935. {
  936. log.Error("OTSSysMgrApp:" + ex.ToString());
  937. }
  938. }
  939. private void ribPolygon_Click(object sender, EventArgs e)
  940. {
  941. //修改工作样品的测量区域为矩形
  942. m_SamplepaceWindow.DrawPolygonMeasure();
  943. }
  944. private void rbReClassify_Click(object sender, EventArgs e)
  945. {
  946. this.Cursor = Cursors.WaitCursor;
  947. if (m_ProjRstData.Reclassify())
  948. {
  949. m_ProjRstData.Save();
  950. MessageBox.Show("reclassification success");
  951. }
  952. else
  953. {
  954. MessageBox.Show("reclassification failed");
  955. }
  956. this.Cursor = Cursors.Default;
  957. }
  958. /// <summary>
  959. /// 打开测量项目文件
  960. /// </summary>
  961. private void OpenMeasureProjectFile()
  962. {
  963. bool bOpenFlag=false;
  964. COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
  965. string strPathName;
  966. // file open dialog
  967. OpenFileDialog openFileDialog = new OpenFileDialog();
  968. openFileDialog.Filter = "Probject Files (*.prj)|*.prj";
  969. if (openFileDialog.ShowDialog() != DialogResult.OK)
  970. {
  971. return ;
  972. }
  973. strPathName = openFileDialog.FileName;
  974. this.Cursor = Cursors.WaitCursor;
  975. if (ProjDataMgr.Load(strPathName))
  976. {
  977. m_ProjRstData = ProjDataMgr;
  978. m_ProjParam.SetResultData(m_ProjRstData);
  979. m_ProjParam.InitResultData();
  980. bOpenFlag = true;
  981. }
  982. this.Cursor = Cursors.Default;
  983. if (bOpenFlag)
  984. {
  985. if (!DisplayExistSampleFile())
  986. {
  987. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) OpenExistSampleFile() = false Failed !");
  988. return;
  989. }
  990. m_RibbonFun.SetAllRibbonButnStatus(true);
  991. }
  992. else
  993. {
  994. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) m_DataMgrFun.OpenExistSampleFile() Failed !");
  995. }
  996. }
  997. private void OTSIncAMeasureAppForm_FormClosed(object sender, FormClosedEventArgs e)
  998. {
  999. }
  1000. private void rbAbout_Click(object sender, EventArgs e)
  1001. {
  1002. if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.IncA)
  1003. {
  1004. OTSSplashScreen_IncA m_about = new OTSSplashScreen_IncA();
  1005. m_about.TopMost = false;
  1006. m_about.Show();
  1007. }
  1008. else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
  1009. {
  1010. OTSSplashScreen_Cleanness m_about = new OTSSplashScreen_Cleanness();
  1011. m_about.TopMost = false;
  1012. m_about.Show();
  1013. }
  1014. }
  1015. protected override void DefWndProc(ref Message m)
  1016. {
  1017. switch (m.Msg)
  1018. {
  1019. case MsgID:
  1020. break;
  1021. case LogMsgID:
  1022. m_LogMsg = new PostLogMsg();
  1023. m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
  1024. var log = NLog.LogManager.GetCurrentClassLogger();
  1025. string s = GetString(m_LogMsg.logMessage);
  1026. switch (m_LogMsg.logLevel)
  1027. {
  1028. case 1:
  1029. log.Trace(s);
  1030. break;
  1031. case 2:
  1032. log.Debug(s);
  1033. break;
  1034. case 3:
  1035. log.Info(s);
  1036. break;
  1037. case 4:
  1038. log.Warn(s);
  1039. break;
  1040. case 5:
  1041. log.Error(s);
  1042. break;
  1043. case 6:
  1044. log.Fatal(s);
  1045. break;
  1046. }
  1047. break;
  1048. default:
  1049. base.DefWndProc(ref m);
  1050. break;
  1051. }
  1052. }
  1053. private string GetString(char[] csStr)
  1054. {
  1055. int ilen = csStr.Length;
  1056. string csName = new string(csStr); //MSTMsg.STMSampleStu.cSName
  1057. csName.IndexOf('\0');
  1058. csName = csName.Substring(0, csName.IndexOf('\0'));
  1059. return csName;
  1060. }
  1061. private void PrepareIpcServer()
  1062. {
  1063. //Instantiate our server channel.
  1064. IpcServerChannel channel = new IpcServerChannel("ServerChannel");
  1065. //Register the server channel.
  1066. ChannelServices.RegisterChannel(channel, false);
  1067. //Register this service type.
  1068. RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcSEMController), "RemoteObject", WellKnownObjectMode.Singleton);
  1069. }
  1070. private void rbConnectHardware_Click_1(object sender, EventArgs e)
  1071. {
  1072. if (!m_MsrThreadWrapper.IsSEMConnected())
  1073. {
  1074. if (!m_MsrThreadWrapper.ConnectSEM())
  1075. {
  1076. MessageBox.Show("Connect failed!");
  1077. return;
  1078. }
  1079. }
  1080. this.rbConnectHardware.Enabled = false;
  1081. this.rbDisconnectHardware.Enabled = true;
  1082. log.Warn("SEM connect success!");
  1083. }
  1084. private void rbDisconnectHardware_Click_1(object sender, EventArgs e)
  1085. {
  1086. if (m_MsrThreadWrapper.IsSEMConnected())
  1087. {
  1088. m_MsrThreadWrapper.DisconnectSEM();
  1089. }
  1090. this.rbDisconnectHardware.Enabled = false;
  1091. this.rbConnectHardware.Enabled = true;
  1092. log.Warn("SEM Disconnect!");
  1093. }
  1094. private void rbinterrupt_Click(object sender, EventArgs e)
  1095. {
  1096. if (m_MsrThreadWrapper.IsSEMConnected())
  1097. {
  1098. m_MsrThreadWrapper.StopXrayAcquisition();
  1099. }
  1100. log.Warn("StopXrayAcquisition!");
  1101. }
  1102. private void rbAutoBeamOff_Click(object sender, EventArgs e)
  1103. {
  1104. if (m_ProjRstData.GetGenParam().AutoBeamOff)
  1105. {
  1106. m_ProjRstData.GetGenParam().AutoBeamOff = false;
  1107. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1108. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1109. }
  1110. else
  1111. {
  1112. m_ProjRstData.GetGenParam().AutoBeamOff = true;
  1113. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1114. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1115. }
  1116. }
  1117. private void OTSIncAMeasureAppForm_Activated(object sender, EventArgs e)
  1118. {
  1119. }
  1120. }
  1121. }