OTSIncAMeasureAppForm.cs 50 KB

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