OTSIncAMeasureAppForm.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430
  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 ;
  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. Form sp;
  77. public OTSIncAMeasureAppForm()
  78. {
  79. th = new Thread(new ThreadStart(DoSplash));
  80. th.Start();
  81. InitializeComponent();
  82. //国际化
  83. lan = new OTSCommon.Language(this);
  84. table = lan.GetNameTable(this.Name);
  85. m_SamplespaceWindowName = table["m_samplespacewindowname"].ToString();
  86. m_MeasureStauWindowName = table["m_measurestauwindowname"].ToString();
  87. m_MeasureRetWindowName = table["m_measureretwindowname"].ToString();
  88. m_NoWindowName = table["m_nowindowname"].ToString();
  89. m_OTSMeasureOutputNlog = new OTSMeasureOutputNlog();
  90. m_OTSMeasureOutputNlog.Show();
  91. // 初始化Docpanle
  92. m_SolutionWindows = new OTSSolutionWindow(this);
  93. m_SPropertyWindows = new OTSPropertyWindow(this);
  94. m_MeasureResultWindow = new OTSMeasureResultWindow(this);
  95. m_MeasureResultWindow.Text = m_MeasureRetWindowName;
  96. m_MessureStatuWindow = new OTSMeasureStatusWindow(this);
  97. m_MessureStatuWindow.Text = m_MeasureStauWindowName;
  98. m_SamplepaceWindow = new OTSSamplespaceWindow(this);
  99. m_SamplepaceWindow.Text = m_SamplespaceWindowName;
  100. m_ProjParam = new COTSMeasureParam(this);
  101. m_ProjRstData = m_ProjParam.GetResultData();
  102. //初始化Ribbon类,操作Ribbon按钮的可用或者不可用
  103. m_RibbonFun = new OTSRibbonFun(this);
  104. //初始化测量线程
  105. m_MsrThreadWrapper = new CMeasureThreadWrapper(this);//must be the last sentence of this procedure.
  106. fileWatcher.Changed += FileWatcher_Changed;
  107. fileWatcher.EnableRaisingEvents=true;
  108. }
  109. private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
  110. {
  111. if (e.Name == "SpecialGrayConfig.xml")
  112. {
  113. m_ProjParam.SpecialRanges.IsInited = false;
  114. foreach (var s in this.m_ProjRstData.GetSampleList())
  115. {
  116. s.GetMsrParams().GetSpecialGrayRangeParam().IsInited = false;
  117. }
  118. }
  119. }
  120. private void OTSIncAMeasureAppForm_Load(object sender, EventArgs e)
  121. {
  122. try
  123. {
  124. ArrangWorkspaceWindow();
  125. log = NLog.LogManager.GetCurrentClassLogger();
  126. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  127. {
  128. m_ProjParam.LoadSpecialGrayRangeParamFile();
  129. if (m_ProjParam.InitResultData())
  130. {
  131. m_RibbonFun.SetAllRibbonButnStatus(true);
  132. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(),m_ProjRstData.GetSEMStageData());
  133. //添加启动系统界面显示
  134. if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.IncA)
  135. {
  136. this.Text += "(Inclusion)";
  137. }
  138. else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
  139. {
  140. this.Text += "(Cleanness)";
  141. }
  142. }
  143. else
  144. {
  145. log.Error(" InitResultData() failed");
  146. }
  147. }
  148. else
  149. {
  150. log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) (LoadParamFile() && LoadStageParamFile()) failed");
  151. }
  152. if (!m_MsrThreadWrapper.ConnectSEM())
  153. {
  154. MessageBox.Show("Connect SEM failed!Please goto the SysMgrApp.exe to setup the proper parameter or check other parameter of the EDS software");
  155. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  156. process.FileName = "OTSSysMgrApp.exe";//打开app的路径
  157. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  158. System.Diagnostics.Process.Start(process);
  159. this.rbConnectHardware.Enabled = true;
  160. this.rbDisconnectHardware.Enabled = false;
  161. }
  162. this.rbConnectHardware.Enabled = false;
  163. this.rbDisconnectHardware.Enabled = true;
  164. log.Warn("SEM connect success!");
  165. PrepareIpcServer();
  166. log.Info("Ipc server start success!");
  167. //----------------------Test Code, Don't delete
  168. //var f = new BaseFunctionTest();
  169. //f.ShowDialog();
  170. //----------------------
  171. }
  172. catch (Exception ex)
  173. {
  174. log.Error(" OTSIncAMeasureAppForm_Load:" + ex.ToString());
  175. }
  176. sp.Close();
  177. this.Activate();
  178. }
  179. public void ArrangWorkspaceWindow()
  180. {
  181. //Show 样品台窗口
  182. m_SamplepaceWindow.Show(dockPanel);
  183. //Show 测量状态窗口
  184. m_MessureStatuWindow.Show(dockPanel);
  185. //Show 测量结果窗口
  186. m_MeasureResultWindow.Show(dockPanel);
  187. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  188. //Show 测量过程中Log显示窗口
  189. //m_OTSMeasureOutputNlog.Show();
  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 == "CleannessA")
  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_SolutionWindows.treeView1.Nodes.Clear();
  495. m_MessureStatuWindow.HideXRayTable();
  496. m_MeasureResultWindow.SetInit();
  497. return ;
  498. }
  499. else
  500. {
  501. string sNewWSName = m_ProjParam.GetWorkSampleName();
  502. if ("" == sNewWSName)
  503. {
  504. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetWorkSampleName() = null Failed");
  505. return ;
  506. }
  507. m_SolutionWindows.DeletCurrentSampleNode();
  508. m_SolutionWindows.DisplaySample(sNewWSName);
  509. //将测量状态初始化
  510. m_MessureStatuWindow.SetMeasureStatusInit();
  511. //给工作样品台发送删除样品和新的工作样品名称
  512. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  513. //设置工作样品
  514. SwitchWSample(sNewWSName);
  515. }
  516. return ;
  517. }
  518. private void rbAddSample_Click(object sender, EventArgs e)
  519. {
  520. this.AddNewSampleMeasure();//the system will choose the empty hole one by one according to the holeNo sequence.
  521. }
  522. public void AddNewSampleMeasure(string sSampleHoleName = "")
  523. {
  524. OTSSampleVisualPropertyInfo SMInfo = m_ProjParam.AddNewSampleMeasure(sSampleHoleName);
  525. if (null == SMInfo)
  526. {
  527. // 设置 开始 ,停止 和检查参数 按钮状态
  528. m_RibbonFun.SetMeasureRibbonButnStatu();
  529. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  530. return;
  531. }
  532. m_SPropertyWindows.TSSaveAs.Enabled = true;
  533. m_SPropertyWindows.TSLoad.Enabled = true;
  534. m_SPropertyWindows.TSEdit.Enabled = false;
  535. m_SPropertyWindows.TSEdit.Visible = false;
  536. //给SampleWindow 发送样品信息
  537. m_SamplepaceWindow.AddSampleArea(SMInfo.SMeasurePara);
  538. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  539. //给PropWindow 发送工作样品属性信息
  540. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  541. //给SoluWindow 发送样品显示信息
  542. m_SolutionWindows.AddSampleMeasure(SMInfo.TSampleParam);
  543. // 设置 开始 ,停止 和检查参数 按钮状态
  544. m_RibbonFun.SetMeasureRibbonButnStatu();
  545. //设置 删除,复位,圆形,矩形 按钮状态
  546. m_RibbonFun.SetSampleRibbonButnStatus();
  547. //清空帧图信息
  548. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  549. }
  550. public void InitCurrentSampleState()
  551. {
  552. OTSSampleVisualPropertyInfo SMInfo = m_ProjParam.GetWorkingSampleVisualPropertyInfo();
  553. if (null == SMInfo)
  554. {
  555. // 设置 开始 ,停止 和检查参数 按钮状态
  556. m_RibbonFun.SetMeasureRibbonButnStatu();
  557. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  558. return;
  559. }
  560. m_SPropertyWindows.TSSaveAs.Enabled = true;
  561. m_SPropertyWindows.TSLoad.Enabled = true;
  562. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  563. //给PropWindow 发送工作样品属性信息
  564. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  565. // 设置 开始 ,停止 和检查参数 按钮状态
  566. m_RibbonFun.SetMeasureRibbonButnStatu();
  567. //设置 删除,复位,圆形,矩形 按钮状态
  568. m_RibbonFun.SetSampleRibbonButnStatus();
  569. //清空帧图信息
  570. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  571. }
  572. private void rbSelectDlg_Click(object sender, EventArgs e)
  573. {
  574. //判断样品台是否有样品,如果有样品则不能设置默认参数
  575. if (m_ProjParam.GetSampleCount() > 0)
  576. {
  577. MessageBox.Show("Cann't setup preference parameter,for you have added some samples!");
  578. return;
  579. }
  580. ProgMgrInfoForm ProgMgrForm = new ProgMgrInfoForm();
  581. if (DialogResult.OK == ProgMgrForm.ShowDialog())
  582. {
  583. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  584. {
  585. if (m_ProjParam.InitResultData())
  586. {
  587. m_RibbonFun.SetAllRibbonButnStatus(true);
  588. //当样品台上有样品,则不更新样品台数据
  589. if (0 == m_ProjParam.GetSampleCount())
  590. {
  591. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  592. }
  593. }
  594. else
  595. {
  596. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) this.CheckMeasureSysFileExist() = false");
  597. }
  598. }
  599. else
  600. {
  601. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
  602. }
  603. }
  604. }
  605. // 主Windows框右下角显示鼠标点的SEM坐标(样品台)
  606. public void ShowSemCoordvAL(string sSemCoord)
  607. {
  608. STSemCoordinate.Text = sSemCoord;
  609. statusStrip1.Refresh();
  610. }
  611. //// 主Windows框右下角显示鼠标点的灰度值(测量图)
  612. public void ShowGrayVal(string sGrayVal)
  613. {
  614. TSGrayVal.Text = sGrayVal;
  615. statusStrip1.Refresh();
  616. }
  617. //获取工作样品测量锁
  618. public bool GetWorkSampleParamLock(ref CTreeSampleParam TSParamLock)
  619. {
  620. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  621. TSParamLock = SMInfo.TSampleParam;
  622. return true;
  623. }
  624. /// <summary>
  625. /// 更新属性窗口
  626. /// </summary>
  627. public void UpdatePropertyVal()
  628. {
  629. //获取新的工作样品属性值
  630. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  631. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  632. }
  633. private void ribbonOrbMenuItemSaveAs_Click(object sender, EventArgs e)
  634. {
  635. bool iRev = m_ProjRstData.SaveAs();
  636. if (!iRev)
  637. {
  638. return;
  639. }
  640. m_ProjParam.InitWorkingSampleData(0);
  641. this.InitCurrentSampleState();
  642. m_MeasureResultWindow.SetInit();
  643. m_SamplepaceWindow. PrepareMeasureField(m_SamplepaceWindow.GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  644. }
  645. private void rbSaveFile_Click(object sender, EventArgs e)
  646. {
  647. bool iRev = m_ProjRstData.Save();
  648. if (!iRev)
  649. {
  650. return;
  651. }
  652. }
  653. private void rbCheckParam_Click(object sender, EventArgs e)
  654. {
  655. //检查样品测量参数
  656. if (m_ProjParam.CheckSampleParam(true))
  657. {
  658. string message = table["message7"].ToString();
  659. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  660. }
  661. }
  662. private void ribReset_Click(object sender, EventArgs e)
  663. {
  664. //调用样品台窗口中的复位方法
  665. m_SamplepaceWindow.ResetWorkSampleMeasure();
  666. }
  667. //绘制圆形测量区域
  668. private void ribCircle_Click(object sender, EventArgs e)
  669. {
  670. //修改工作样品的测量区域为圆形
  671. m_SamplepaceWindow.DrawCircleMeasure();
  672. }
  673. private void rbThreePoints_Click(object sender, EventArgs e)
  674. {
  675. //修改工作样品的测量区域为圆形
  676. m_SamplepaceWindow.DrawCircleMeasureByThreePoints();
  677. }
  678. private void rbRingShape_Click(object sender, EventArgs e)
  679. {
  680. //修改工作样品的测量区域为圆形
  681. m_SamplepaceWindow.DrawRingShapeArea();
  682. }
  683. //绘制矩形测量区域
  684. private void ribRectangle_Click(object sender, EventArgs e)
  685. {
  686. //修改工作样品的测量区域为矩形
  687. m_SamplepaceWindow.DrawRectangleMeasure();
  688. }
  689. private void rbExitApp_Click(object sender, EventArgs e)
  690. {
  691. this.Close();
  692. }
  693. private void rbStart_Click(object sender, EventArgs e)
  694. {
  695. if (!m_ProjParam.CheckSampleParam(false))
  696. {
  697. return;
  698. }
  699. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning() && !m_MsrThreadWrapper.BgWorkIsPaused())
  700. {
  701. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  702. m_MsrThreadWrapper.StartBGWorkThread();
  703. m_RibbonFun.SetMeasureRibbonButnStatu();
  704. }
  705. else //thread is in pausing state
  706. {
  707. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  708. m_MsrThreadWrapper.SetMeasureThreadStatus(OTS_MSR_THREAD_STATUS.INPROCESS);
  709. m_RibbonFun.SetMeasureRibbonButnStatu();
  710. }
  711. }
  712. public void SetStartMeasureRibbonStatus()
  713. {
  714. ribView.Enabled = false;
  715. m_RibbonFun.SetToolButnStatu(false);
  716. //false: 将其他ribbon按钮设置为灰色
  717. rbPanelFile.Enabled = false;
  718. rbPanelSample.Enabled = false;
  719. m_SolutionWindows.Enabled = false;
  720. m_SPropertyWindows.Enabled = false;
  721. rbStart.Enabled = false;
  722. //rbPause.Enabled = true;
  723. rbStop.Enabled = true;
  724. rbCheckParam.Enabled = false;
  725. }
  726. private void rbStop_Click(object sender, EventArgs e)
  727. {
  728. //如果当前正在测量,则停止测量线程
  729. if (MeasureThreadRunFlag)
  730. {
  731. //停止测量线程
  732. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  733. }
  734. else if (m_MsrThreadWrapper.m_measure.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
  735. {
  736. foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_measure.mapSmplMsr)
  737. {
  738. if (smpl.Value.GetSample().GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
  739. {
  740. smpl.Value.TheLastWorkOfSampleMeasure();
  741. SetStopMeasureRibbonStatus();
  742. return;
  743. }
  744. }
  745. }
  746. }
  747. private void rbPause_Click(object sender, EventArgs e)
  748. {
  749. //如果当前正在测量,则停止测量线程
  750. if (MeasureThreadRunFlag)
  751. {
  752. //停止测量线程
  753. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.PAUSED);
  754. }
  755. }
  756. private void rbRuler_Click(object sender, EventArgs e)
  757. {
  758. m_SamplepaceWindow.ShowRulerLocation();
  759. }
  760. private void rbSmapleName_Click(object sender, EventArgs e)
  761. {
  762. //m_SamplepaceWindow.ChangeSampleHoleFont();
  763. }
  764. private void rbSmaplePhoto_Click(object sender, EventArgs e)
  765. {
  766. m_SamplepaceWindow.ChangeSampleHoleImage();
  767. }
  768. //当点击Ribbon停止按钮时,设置Ribbon状态
  769. public void SetStopMeasureRibbonStatus()
  770. {
  771. ribView.Enabled = true;
  772. m_RibbonFun.SetToolButnStatu(true);
  773. rbPanelFile.Enabled = true;
  774. rbPanelSample.Enabled = true;
  775. m_RibbonFun.SetMeasureRibbonButnStatu();
  776. m_SolutionWindows.Enabled = true;
  777. m_SPropertyWindows.Enabled = true;
  778. rbStart.Enabled = true;
  779. rbPause.Enabled = false;
  780. rbStop.Enabled = false;
  781. rbCheckParam.Enabled = true;
  782. //激活跳转至报告程序按钮
  783. rbPReport.Enabled = true;
  784. rbReport.Enabled = true;
  785. }
  786. public void SetPauseMeasureRibbonStatus()
  787. {
  788. ribView.Enabled = true;
  789. m_RibbonFun.SetToolButnStatu(true);
  790. rbPanelFile.Enabled = true;
  791. rbPanelSample.Enabled = true;
  792. m_RibbonFun.SetMeasureRibbonButnStatu();
  793. m_SolutionWindows.Enabled = true;
  794. m_SPropertyWindows.Enabled = true;
  795. rbStart.Enabled = true;
  796. rbPause.Enabled = false;
  797. rbStop.Enabled = true;
  798. rbCheckParam.Enabled = false;
  799. //激活跳转至报告程序按钮
  800. rbPReport.Enabled = true;
  801. rbReport.Enabled = true;
  802. }
  803. public bool SwitchDisplayMeasureSample(string sMsrSampleName)
  804. {
  805. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  806. m_SolutionWindows.SwitchSample(sMsrSampleName);
  807. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  808. return true;
  809. }
  810. #region 开始获取样品孔中的照片
  811. /// <summary>
  812. /// 开始获取样品孔中的照片
  813. /// </summary>
  814. /// <param name="doRunType"></param>
  815. /// <param name="HoleID"></param>
  816. /// <param name="c_DomainMessure"></param>
  817. public void StartSampleHoleBSEImage()
  818. {
  819. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  820. {
  821. m_MsrThreadWrapper.StartBGWorkThread();
  822. m_RibbonFun.SetMeasureRibbonButnStatu();
  823. }
  824. }
  825. #endregion
  826. private void rbRecover_Click(object sender, EventArgs e)
  827. {
  828. //关闭所有内容
  829. CloseAllContents();
  830. //显示样品属性窗口与树结构窗口
  831. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  832. m_SPropertyWindows.Show(dockPanel);
  833. //显示样品台窗口 测量状态与测量结果窗口
  834. m_SamplepaceWindow.Show(dockPanel);
  835. m_MessureStatuWindow.Show(dockPanel);
  836. m_MeasureResultWindow.Show(dockPanel);
  837. //此处将在父窗体选项卡上显示
  838. foreach (Form child in this.MdiChildren)
  839. {
  840. if (child.Name == "OTSSamplespaceWindow")
  841. {
  842. child.Activate();
  843. break;
  844. }
  845. }
  846. }
  847. private void CloseAllContents()
  848. {
  849. m_SolutionWindows.DockPanel = null;
  850. m_SPropertyWindows.DockPanel = null;
  851. m_SamplepaceWindow.DockPanel = null;
  852. m_MessureStatuWindow.DockPanel = null;
  853. m_MeasureResultWindow.DockPanel = null;
  854. CloseAllDocuments();
  855. }
  856. private void CloseAllDocuments()
  857. {
  858. if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
  859. {
  860. foreach (Form form in MdiChildren)
  861. form.Close();
  862. }
  863. else
  864. {
  865. IDockContent[] documents = dockPanel.DocumentsToArray();
  866. foreach (IDockContent content in documents)
  867. content.DockHandler.Close();
  868. }
  869. }
  870. private void rbMeasureCircle_Click(object sender, EventArgs e)
  871. {
  872. m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCUL);
  873. //修改工作样品的测量区域为圆形
  874. m_SamplepaceWindow.changeShape(ShapeType.CIRCUL);
  875. }
  876. private void rbMeasureRectangle_Click(object sender, EventArgs e)
  877. {
  878. m_ProjParam.SetMeasureAreaShape(ShapeType.RECTANGLE);
  879. //修改工作样品的测量区域为矩形
  880. m_SamplepaceWindow.changeShape(ShapeType.RECTANGLE);
  881. }
  882. //ctrl+s组合键进行保存
  883. private void OTSIncAMeasureAppForm_KeyDown(object sender, KeyEventArgs e)
  884. {
  885. if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
  886. {
  887. bool iRev = m_ProjRstData.Save();
  888. if (!iRev)
  889. {
  890. log.Error("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  891. return;
  892. }
  893. log.Error("(OTSIncAMeasureAppForm.rbSaveAs_Click) m_DataMgrFun.SaveFile() Success !");
  894. }
  895. }
  896. private void rbSTDEdit_Click_1(object sender, EventArgs e)
  897. {
  898. OpenFileDialog openFileDialog = new OpenFileDialog();
  899. openFileDialog.Filter = "(*.db)|*.db";
  900. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  901. openFileDialog.RestoreDirectory = true;
  902. openFileDialog.FilterIndex = 1;
  903. if (openFileDialog.ShowDialog() == DialogResult.OK)
  904. {
  905. try
  906. {
  907. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", "\""+openFileDialog.FileName+ "\"");
  908. p.WaitForExit();
  909. }
  910. catch (Exception ex)
  911. {
  912. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  913. }
  914. }
  915. //reload the setup data just now
  916. foreach (var s in this.m_ProjRstData.GetSampleList())
  917. {
  918. var stdname= s.GetMsrParams().GetSTDName();
  919. if (stdname != "NoSTDDB")
  920. {
  921. if (!stdname.Contains(".db"))
  922. {
  923. stdname += ".db";
  924. }
  925. var m_classifyEngine = new COTSClassifyEngineClr(EngineType.ExpressionClassifyEng, stdname);
  926. m_classifyEngine.ReloadEngineDB();
  927. }
  928. }
  929. }
  930. private void rbSysMgrApp_Click(object sender, EventArgs e)
  931. {
  932. try
  933. {
  934. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSSysMgrApp.exe");
  935. p.WaitForExit();
  936. }
  937. catch (Exception ex)
  938. {
  939. log.Error("OTSSysMgrApp:" + ex.ToString());
  940. }
  941. }
  942. private void ribPolygon_Click(object sender, EventArgs e)
  943. {
  944. //修改工作样品的测量区域为矩形
  945. m_SamplepaceWindow.DrawPolygonMeasure();
  946. }
  947. private void rbReClassify_Click(object sender, EventArgs e)
  948. {
  949. this.Cursor = Cursors.WaitCursor;
  950. if (m_ProjRstData.Reclassify())
  951. {
  952. m_ProjRstData.Save();
  953. MessageBox.Show("reclassification success");
  954. }
  955. else
  956. {
  957. MessageBox.Show("reclassification failed");
  958. }
  959. this.Cursor = Cursors.Default;
  960. }
  961. /// <summary>
  962. /// 打开测量项目文件
  963. /// </summary>
  964. private void OpenMeasureProjectFile()
  965. {
  966. bool bOpenFlag=false;
  967. COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
  968. string strPathName;
  969. // file open dialog
  970. OpenFileDialog openFileDialog = new OpenFileDialog();
  971. openFileDialog.Filter = "Probject Files (*.prj)|*.prj";
  972. if (openFileDialog.ShowDialog() != DialogResult.OK)
  973. {
  974. return ;
  975. }
  976. strPathName = openFileDialog.FileName;
  977. this.Cursor = Cursors.WaitCursor;
  978. if (ProjDataMgr.Load(strPathName))
  979. {
  980. m_ProjRstData = ProjDataMgr;
  981. m_ProjParam.SetResultData(m_ProjRstData);
  982. m_ProjParam.InitResultData();
  983. bOpenFlag = true;
  984. }
  985. this.Cursor = Cursors.Default;
  986. if (bOpenFlag)
  987. {
  988. if (!DisplayExistSampleFile())
  989. {
  990. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) OpenExistSampleFile() = false Failed !");
  991. return;
  992. }
  993. m_RibbonFun.SetAllRibbonButnStatus(true);
  994. }
  995. else
  996. {
  997. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) m_DataMgrFun.OpenExistSampleFile() Failed !");
  998. }
  999. }
  1000. private void OTSIncAMeasureAppForm_FormClosed(object sender, FormClosedEventArgs e)
  1001. {
  1002. }
  1003. private void rbAbout_Click(object sender, EventArgs e)
  1004. {
  1005. if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.IncA)
  1006. {
  1007. OTSSplashScreen_IncA m_about = new OTSSplashScreen_IncA();
  1008. m_about.TopMost = false;
  1009. m_about.ShowInTaskbar = true;
  1010. m_about.Show();
  1011. }
  1012. else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
  1013. {
  1014. OTSSplashScreen_Cleanness m_about = new OTSSplashScreen_Cleanness();
  1015. m_about.TopMost = false;
  1016. m_about.ShowInTaskbar = true;
  1017. m_about.Show();
  1018. }
  1019. }
  1020. protected override void DefWndProc(ref Message m)
  1021. {
  1022. switch (m.Msg)
  1023. {
  1024. case MsgID:
  1025. break;
  1026. case LogMsgID:
  1027. m_LogMsg = new PostLogMsg();
  1028. m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
  1029. var log = NLog.LogManager.GetCurrentClassLogger();
  1030. string s = GetString(m_LogMsg.logMessage);
  1031. switch (m_LogMsg.logLevel)
  1032. {
  1033. case 1:
  1034. log.Trace(s);
  1035. break;
  1036. case 2:
  1037. log.Debug(s);
  1038. break;
  1039. case 3:
  1040. log.Info(s);
  1041. break;
  1042. case 4:
  1043. log.Warn(s);
  1044. break;
  1045. case 5:
  1046. log.Error(s);
  1047. break;
  1048. case 6:
  1049. log.Fatal(s);
  1050. break;
  1051. }
  1052. break;
  1053. default:
  1054. base.DefWndProc(ref m);
  1055. break;
  1056. }
  1057. }
  1058. private string GetString(char[] csStr)
  1059. {
  1060. int ilen = csStr.Length;
  1061. string csName = new string(csStr); //MSTMsg.STMSampleStu.cSName
  1062. csName.IndexOf('\0');
  1063. csName = csName.Substring(0, csName.IndexOf('\0'));
  1064. return csName;
  1065. }
  1066. private void PrepareIpcServer()
  1067. {
  1068. //Instantiate our server channel.
  1069. IpcServerChannel channel = new IpcServerChannel("ServerChannel");
  1070. //Register the server channel.
  1071. ChannelServices.RegisterChannel(channel, false);
  1072. //Register this service type.
  1073. RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcSEMController), "RemoteObject", WellKnownObjectMode.Singleton);
  1074. }
  1075. private void rbConnectHardware_Click_1(object sender, EventArgs e)
  1076. {
  1077. if (!m_MsrThreadWrapper.IsSEMConnected())
  1078. {
  1079. if (!m_MsrThreadWrapper.ConnectSEM())
  1080. {
  1081. MessageBox.Show("Connect failed!");
  1082. return;
  1083. }
  1084. }
  1085. this.rbConnectHardware.Enabled = false;
  1086. this.rbDisconnectHardware.Enabled = true;
  1087. log.Warn("SEM connect success!");
  1088. }
  1089. private void rbDisconnectHardware_Click_1(object sender, EventArgs e)
  1090. {
  1091. if (m_MsrThreadWrapper.IsSEMConnected())
  1092. {
  1093. m_MsrThreadWrapper.DisconnectSEM();
  1094. }
  1095. this.rbDisconnectHardware.Enabled = false;
  1096. this.rbConnectHardware.Enabled = true;
  1097. log.Warn("SEM Disconnect!");
  1098. }
  1099. private void rbinterrupt_Click(object sender, EventArgs e)
  1100. {
  1101. if (m_MsrThreadWrapper.IsSEMConnected())
  1102. {
  1103. m_MsrThreadWrapper.StopXrayAcquisition();
  1104. }
  1105. log.Warn("StopXrayAcquisition!");
  1106. }
  1107. private void rbAutoBeamOff_Click(object sender, EventArgs e)
  1108. {
  1109. if (m_ProjRstData.GetGenParam().AutoBeamOff)
  1110. {
  1111. m_ProjRstData.GetGenParam().AutoBeamOff = false;
  1112. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1113. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1114. }
  1115. else
  1116. {
  1117. m_ProjRstData.GetGenParam().AutoBeamOff = true;
  1118. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1119. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1120. }
  1121. }
  1122. private void OTSIncAMeasureAppForm_Activated(object sender, EventArgs e)
  1123. {
  1124. }
  1125. }
  1126. }