OTSIncAMeasureAppForm.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  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_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. m_ProjParam.InitWorkingSampleData(0);
  643. this.InitCurrentSampleState();
  644. m_MeasureResultWindow.SetInit();
  645. m_SamplepaceWindow. PrepareMeasureField(m_SamplepaceWindow.GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  646. }
  647. private void rbSaveFile_Click(object sender, EventArgs e)
  648. {
  649. bool iRev = m_ProjRstData.Save();
  650. if (!iRev)
  651. {
  652. return;
  653. }
  654. }
  655. private void rbCheckParam_Click(object sender, EventArgs e)
  656. {
  657. //检查样品测量参数
  658. if (m_ProjParam.CheckSampleParam(true))
  659. {
  660. string message = table["message7"].ToString();
  661. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  662. }
  663. }
  664. private void ribReset_Click(object sender, EventArgs e)
  665. {
  666. //调用样品台窗口中的复位方法
  667. m_SamplepaceWindow.ResetWorkSampleMeasure();
  668. }
  669. //绘制圆形测量区域
  670. private void ribCircle_Click(object sender, EventArgs e)
  671. {
  672. //修改工作样品的测量区域为圆形
  673. m_SamplepaceWindow.DrawCircleMeasure();
  674. }
  675. private void rbThreePoints_Click(object sender, EventArgs e)
  676. {
  677. //修改工作样品的测量区域为圆形
  678. m_SamplepaceWindow.DrawCircleMeasureByThreePoints();
  679. }
  680. private void rbRingShape_Click(object sender, EventArgs e)
  681. {
  682. //修改工作样品的测量区域为圆形
  683. m_SamplepaceWindow.DrawRingShapeArea();
  684. }
  685. //绘制矩形测量区域
  686. private void ribRectangle_Click(object sender, EventArgs e)
  687. {
  688. //修改工作样品的测量区域为矩形
  689. m_SamplepaceWindow.DrawRectangleMeasure();
  690. }
  691. private void rbExitApp_Click(object sender, EventArgs e)
  692. {
  693. this.Close();
  694. }
  695. private void rbStart_Click(object sender, EventArgs e)
  696. {
  697. if (!m_ProjParam.CheckSampleParam(false))
  698. {
  699. return;
  700. }
  701. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning() && !m_MsrThreadWrapper.BgWorkIsPaused())
  702. {
  703. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  704. m_MsrThreadWrapper.StartBGWorkThread();
  705. m_RibbonFun.SetMeasureRibbonButnStatu();
  706. }
  707. else //thread is in pausing state
  708. {
  709. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  710. m_MsrThreadWrapper.SetMeasureThreadStatus(OTS_MSR_THREAD_STATUS.INPROCESS);
  711. m_RibbonFun.SetMeasureRibbonButnStatu();
  712. }
  713. }
  714. public void SetStartMeasureRibbonStatus()
  715. {
  716. ribView.Enabled = false;
  717. m_RibbonFun.SetToolButnStatu(false);
  718. //false: 将其他ribbon按钮设置为灰色
  719. rbPanelFile.Enabled = false;
  720. rbPanelSample.Enabled = false;
  721. m_SolutionWindows.Enabled = false;
  722. m_SPropertyWindows.Enabled = false;
  723. rbStart.Enabled = false;
  724. //rbPause.Enabled = true;
  725. rbStop.Enabled = true;
  726. rbCheckParam.Enabled = false;
  727. }
  728. private void rbStop_Click(object sender, EventArgs e)
  729. {
  730. //如果当前正在测量,则停止测量线程
  731. if (MeasureThreadRunFlag)
  732. {
  733. //停止测量线程
  734. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  735. }
  736. else if (m_MsrThreadWrapper.m_measure.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
  737. {
  738. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  739. foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_measure.mapSmplMsr)
  740. {
  741. if (smpl.Value.GetSample().GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
  742. {
  743. smpl.Value.TheLastWorkOfSampleMeasure();
  744. SetStopMeasureRibbonStatus();
  745. return;
  746. }
  747. }
  748. }
  749. }
  750. private void rbPause_Click(object sender, EventArgs e)
  751. {
  752. //如果当前正在测量,则停止测量线程
  753. if (MeasureThreadRunFlag)
  754. {
  755. //停止测量线程
  756. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.PAUSED);
  757. }
  758. }
  759. private void rbRuler_Click(object sender, EventArgs e)
  760. {
  761. m_SamplepaceWindow.ShowRulerLocation();
  762. }
  763. private void rbSmapleName_Click(object sender, EventArgs e)
  764. {
  765. //m_SamplepaceWindow.ChangeSampleHoleFont();
  766. }
  767. private void rbSmaplePhoto_Click(object sender, EventArgs e)
  768. {
  769. m_SamplepaceWindow.ChangeSampleHoleImage();
  770. }
  771. //当点击Ribbon停止按钮时,设置Ribbon状态
  772. public void SetStopMeasureRibbonStatus()
  773. {
  774. ribView.Enabled = true;
  775. m_RibbonFun.SetToolButnStatu(true);
  776. rbPanelFile.Enabled = true;
  777. rbPanelSample.Enabled = true;
  778. m_RibbonFun.SetMeasureRibbonButnStatu();
  779. m_SolutionWindows.Enabled = true;
  780. m_SPropertyWindows.Enabled = true;
  781. rbStart.Enabled = true;
  782. rbPause.Enabled = false;
  783. rbStop.Enabled = false;
  784. rbCheckParam.Enabled = true;
  785. //激活跳转至报告程序按钮
  786. rbPReport.Enabled = true;
  787. rbReport.Enabled = true;
  788. }
  789. public void SetPauseMeasureRibbonStatus()
  790. {
  791. ribView.Enabled = true;
  792. m_RibbonFun.SetToolButnStatu(true);
  793. rbPanelFile.Enabled = true;
  794. rbPanelSample.Enabled = true;
  795. m_RibbonFun.SetMeasureRibbonButnStatu();
  796. m_SolutionWindows.Enabled = true;
  797. m_SPropertyWindows.Enabled = true;
  798. rbStart.Enabled = true;
  799. rbPause.Enabled = false;
  800. rbStop.Enabled = true;
  801. rbCheckParam.Enabled = false;
  802. //激活跳转至报告程序按钮
  803. rbPReport.Enabled = true;
  804. rbReport.Enabled = true;
  805. }
  806. public bool SwitchDisplayMeasureSample(string sMsrSampleName)
  807. {
  808. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  809. m_SolutionWindows.SwitchSample(sMsrSampleName);
  810. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  811. return true;
  812. }
  813. #region 开始获取样品孔中的照片
  814. /// <summary>
  815. /// 开始获取样品孔中的照片
  816. /// </summary>
  817. /// <param name="doRunType"></param>
  818. /// <param name="HoleID"></param>
  819. /// <param name="c_DomainMessure"></param>
  820. public void StartSampleHoleBSEImage()
  821. {
  822. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  823. {
  824. m_MsrThreadWrapper.StartBGWorkThread();
  825. m_RibbonFun.SetMeasureRibbonButnStatu();
  826. }
  827. }
  828. #endregion
  829. private void rbRecover_Click(object sender, EventArgs e)
  830. {
  831. //关闭所有内容
  832. CloseAllContents();
  833. //显示样品属性窗口与树结构窗口
  834. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  835. m_SPropertyWindows.Show(dockPanel);
  836. //显示样品台窗口 测量状态与测量结果窗口
  837. m_SamplepaceWindow.Show(dockPanel);
  838. m_MessureStatuWindow.Show(dockPanel);
  839. m_MeasureResultWindow.Show(dockPanel);
  840. //此处将在父窗体选项卡上显示
  841. foreach (Form child in this.MdiChildren)
  842. {
  843. if (child.Name == "OTSSamplespaceWindow")
  844. {
  845. child.Activate();
  846. break;
  847. }
  848. }
  849. }
  850. private void CloseAllContents()
  851. {
  852. m_SolutionWindows.DockPanel = null;
  853. m_SPropertyWindows.DockPanel = null;
  854. m_SamplepaceWindow.DockPanel = null;
  855. m_MessureStatuWindow.DockPanel = null;
  856. m_MeasureResultWindow.DockPanel = null;
  857. CloseAllDocuments();
  858. }
  859. private void CloseAllDocuments()
  860. {
  861. if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
  862. {
  863. foreach (Form form in MdiChildren)
  864. form.Close();
  865. }
  866. else
  867. {
  868. IDockContent[] documents = dockPanel.DocumentsToArray();
  869. foreach (IDockContent content in documents)
  870. content.DockHandler.Close();
  871. }
  872. }
  873. private void rbMeasureCircle_Click(object sender, EventArgs e)
  874. {
  875. m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCUL);
  876. //修改工作样品的测量区域为圆形
  877. m_SamplepaceWindow.changeShape(ShapeType.CIRCUL);
  878. }
  879. private void rbMeasureRectangle_Click(object sender, EventArgs e)
  880. {
  881. m_ProjParam.SetMeasureAreaShape(ShapeType.RECTANGLE);
  882. //修改工作样品的测量区域为矩形
  883. m_SamplepaceWindow.changeShape(ShapeType.RECTANGLE);
  884. }
  885. //ctrl+s组合键进行保存
  886. private void OTSIncAMeasureAppForm_KeyDown(object sender, KeyEventArgs e)
  887. {
  888. if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
  889. {
  890. bool iRev = m_ProjRstData.Save();
  891. if (!iRev)
  892. {
  893. log.Error("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  894. return;
  895. }
  896. log.Error("(OTSIncAMeasureAppForm.rbSaveAs_Click) m_DataMgrFun.SaveFile() Success !");
  897. }
  898. }
  899. private void rbSTDEdit_Click_1(object sender, EventArgs e)
  900. {
  901. OpenFileDialog openFileDialog = new OpenFileDialog();
  902. openFileDialog.Filter = "(*.db)|*.db";
  903. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  904. openFileDialog.RestoreDirectory = true;
  905. openFileDialog.FilterIndex = 1;
  906. if (openFileDialog.ShowDialog() == DialogResult.OK)
  907. {
  908. try
  909. {
  910. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", "\""+openFileDialog.FileName+ "\"");
  911. p.WaitForExit();
  912. }
  913. catch (Exception ex)
  914. {
  915. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  916. }
  917. }
  918. //reload the setup data just now
  919. foreach (var s in this.m_ProjRstData.GetSampleList())
  920. {
  921. var stdname= s.GetMsrParams().GetSTDName();
  922. if (stdname != "NoSTDDB")
  923. {
  924. if (!stdname.Contains(".db"))
  925. {
  926. stdname += ".db";
  927. }
  928. var m_classifyEngine = new COTSClassifyEngineClr(EngineType.ExpressionClassifyEng, stdname);
  929. m_classifyEngine.ReloadEngineDB();
  930. }
  931. }
  932. }
  933. private void rbSysMgrApp_Click(object sender, EventArgs e)
  934. {
  935. try
  936. {
  937. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSSysMgrApp.exe");
  938. p.WaitForExit();
  939. }
  940. catch (Exception ex)
  941. {
  942. log.Error("OTSSysMgrApp:" + ex.ToString());
  943. }
  944. }
  945. private void ribPolygon_Click(object sender, EventArgs e)
  946. {
  947. //修改工作样品的测量区域为矩形
  948. m_SamplepaceWindow.DrawPolygonMeasure();
  949. }
  950. private void rbReClassify_Click(object sender, EventArgs e)
  951. {
  952. this.Cursor = Cursors.WaitCursor;
  953. if (m_ProjRstData.Reclassify())
  954. {
  955. m_ProjRstData.Save();
  956. MessageBox.Show("reclassification success");
  957. }
  958. else
  959. {
  960. MessageBox.Show("reclassification failed");
  961. }
  962. this.Cursor = Cursors.Default;
  963. }
  964. /// <summary>
  965. /// 打开测量项目文件
  966. /// </summary>
  967. private void OpenMeasureProjectFile()
  968. {
  969. bool bOpenFlag=false;
  970. COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
  971. string strPathName;
  972. // file open dialog
  973. OpenFileDialog openFileDialog = new OpenFileDialog();
  974. openFileDialog.Filter = "Probject Files (*.prj)|*.prj";
  975. if (openFileDialog.ShowDialog() != DialogResult.OK)
  976. {
  977. return ;
  978. }
  979. strPathName = openFileDialog.FileName;
  980. this.Cursor = Cursors.WaitCursor;
  981. if (ProjDataMgr.Load(strPathName))
  982. {
  983. m_ProjRstData = ProjDataMgr;
  984. m_ProjParam.SetResultData(m_ProjRstData);
  985. m_ProjParam.InitResultData();
  986. bOpenFlag = true;
  987. }
  988. this.Cursor = Cursors.Default;
  989. if (bOpenFlag)
  990. {
  991. if (!DisplayExistSampleFile())
  992. {
  993. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) OpenExistSampleFile() = false Failed !");
  994. return;
  995. }
  996. m_RibbonFun.SetAllRibbonButnStatus(true);
  997. }
  998. else
  999. {
  1000. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) m_DataMgrFun.OpenExistSampleFile() Failed !");
  1001. }
  1002. }
  1003. private void OTSIncAMeasureAppForm_FormClosed(object sender, FormClosedEventArgs e)
  1004. {
  1005. }
  1006. private void rbAbout_Click(object sender, EventArgs e)
  1007. {
  1008. if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.IncA)
  1009. {
  1010. OTSSplashScreen_IncA m_about = new OTSSplashScreen_IncA();
  1011. m_about.TopMost = false;
  1012. m_about.ShowInTaskbar = true;
  1013. m_about.Show();
  1014. }
  1015. else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
  1016. {
  1017. OTSSplashScreen_Cleanness m_about = new OTSSplashScreen_Cleanness();
  1018. m_about.TopMost = false;
  1019. m_about.ShowInTaskbar = true;
  1020. m_about.Show();
  1021. }
  1022. }
  1023. protected override void DefWndProc(ref Message m)
  1024. {
  1025. switch (m.Msg)
  1026. {
  1027. case MsgID:
  1028. break;
  1029. case LogMsgID:
  1030. m_LogMsg = new PostLogMsg();
  1031. m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
  1032. var log = NLog.LogManager.GetCurrentClassLogger();
  1033. string s = GetString(m_LogMsg.logMessage);
  1034. switch (m_LogMsg.logLevel)
  1035. {
  1036. case 1:
  1037. log.Trace(s);
  1038. break;
  1039. case 2:
  1040. log.Debug(s);
  1041. break;
  1042. case 3:
  1043. log.Info(s);
  1044. break;
  1045. case 4:
  1046. log.Warn(s);
  1047. break;
  1048. case 5:
  1049. log.Error(s);
  1050. break;
  1051. case 6:
  1052. log.Fatal(s);
  1053. break;
  1054. }
  1055. break;
  1056. default:
  1057. base.DefWndProc(ref m);
  1058. break;
  1059. }
  1060. }
  1061. private string GetString(char[] csStr)
  1062. {
  1063. int ilen = csStr.Length;
  1064. string csName = new string(csStr); //MSTMsg.STMSampleStu.cSName
  1065. csName.IndexOf('\0');
  1066. csName = csName.Substring(0, csName.IndexOf('\0'));
  1067. return csName;
  1068. }
  1069. private void PrepareIpcServer()
  1070. {
  1071. //Instantiate our server channel.
  1072. IpcServerChannel channel = new IpcServerChannel("ServerChannel");
  1073. //Register the server channel.
  1074. ChannelServices.RegisterChannel(channel, false);
  1075. //Register this service type.
  1076. RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcSEMController), "RemoteObject", WellKnownObjectMode.Singleton);
  1077. }
  1078. private void rbConnectHardware_Click_1(object sender, EventArgs e)
  1079. {
  1080. if (!m_MsrThreadWrapper.IsSEMConnected())
  1081. {
  1082. if (!m_MsrThreadWrapper.ConnectSEM())
  1083. {
  1084. MessageBox.Show("Connect failed!");
  1085. return;
  1086. }
  1087. }
  1088. this.rbConnectHardware.Enabled = false;
  1089. this.rbDisconnectHardware.Enabled = true;
  1090. log.Warn("SEM connect success!");
  1091. }
  1092. private void rbDisconnectHardware_Click_1(object sender, EventArgs e)
  1093. {
  1094. if (m_MsrThreadWrapper.IsSEMConnected())
  1095. {
  1096. m_MsrThreadWrapper.DisconnectSEM();
  1097. }
  1098. this.rbDisconnectHardware.Enabled = false;
  1099. this.rbConnectHardware.Enabled = true;
  1100. log.Warn("SEM Disconnect!");
  1101. }
  1102. private void rbinterrupt_Click(object sender, EventArgs e)
  1103. {
  1104. if (m_MsrThreadWrapper.IsSEMConnected())
  1105. {
  1106. m_MsrThreadWrapper.StopXrayAcquisition();
  1107. }
  1108. log.Warn("StopXrayAcquisition!");
  1109. }
  1110. private void rbAutoBeamOff_Click(object sender, EventArgs e)
  1111. {
  1112. if (m_ProjRstData.GetGenParam().AutoBeamOff)
  1113. {
  1114. m_ProjRstData.GetGenParam().AutoBeamOff = false;
  1115. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1116. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1117. }
  1118. else
  1119. {
  1120. m_ProjRstData.GetGenParam().AutoBeamOff = true;
  1121. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1122. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1123. }
  1124. }
  1125. private void OTSIncAMeasureAppForm_Activated(object sender, EventArgs e)
  1126. {
  1127. }
  1128. }
  1129. }