OTSIncAMeasureAppForm.cs 50 KB

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