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 = new Thread(new ThreadStart(DoSplash));
  41. public static string m_SamplespaceWindowName = "样品台";
  42. public static string m_MeasureStauWindowName = "测量状态";
  43. public static string m_MeasureRetWindowName = "测量结果";
  44. public static string m_NoWindowName = "未知工作窗口";
  45. //国际化
  46. OTSCommon.Language lan;
  47. Hashtable table;
  48. public OTSRibbonFun m_RibbonFun = null;
  49. // 初始化日志类
  50. NLog.Logger log ;
  51. private PostLogMsg m_LogMsg;
  52. public const int MsgID = 0x0464;
  53. public const int LogMsgID = 0x0465;
  54. // Control m_ControlWindow = null;
  55. public OTSMeasureResultWindow m_MeasureResultWindow = null;
  56. public OTSMeasureStatusWindow m_MessureStatuWindow = null;
  57. public OTSSamplespaceWindow m_SamplepaceWindow = null;
  58. public OTSMeasureOutputNlog m_OTSMeasureOutputNlog = null;
  59. public COTSMeasureParam m_ProjParam = null;
  60. public COTSMsrPrjResultData m_ProjRstData;
  61. public OTSSolutionWindow m_SolutionWindows = null;
  62. public OTSPropertyWindow m_SPropertyWindows = null;
  63. //测量线程对象
  64. public CMeasureThreadWrapper m_MsrThreadWrapper = null;
  65. // 测量线程当前状态 True: 正在测量; False: 测量结束
  66. public bool MeasureThreadRunFlag { get => m_MsrThreadWrapper.BGWorkThreadIsRunning(); }
  67. public MSR_RUN_TYPE GetRunType()
  68. {
  69. return m_MsrThreadWrapper.GetDoRunType();
  70. }
  71. public void SetRunType(MSR_RUN_TYPE value)
  72. {
  73. m_MsrThreadWrapper.SetDoRunType(value);
  74. }
  75. public FileSystemWatcher fileWatcher = new FileSystemWatcher(Application.StartupPath+ @"\Config\SysData");
  76. public OTSIncAMeasureAppForm()
  77. {
  78. th.Start();
  79. InitializeComponent();
  80. //国际化
  81. lan = new OTSCommon.Language(this);
  82. table = lan.GetNameTable(this.Name);
  83. m_SamplespaceWindowName = table["m_samplespacewindowname"].ToString();
  84. m_MeasureStauWindowName = table["m_measurestauwindowname"].ToString();
  85. m_MeasureRetWindowName = table["m_measureretwindowname"].ToString();
  86. m_NoWindowName = table["m_nowindowname"].ToString();
  87. m_OTSMeasureOutputNlog = new OTSMeasureOutputNlog();
  88. m_OTSMeasureOutputNlog.Show();
  89. // 初始化Docpanle
  90. m_SolutionWindows = new OTSSolutionWindow(this);
  91. m_SPropertyWindows = new OTSPropertyWindow(this);
  92. m_MeasureResultWindow = new OTSMeasureResultWindow(this);
  93. m_MeasureResultWindow.Text = m_MeasureRetWindowName;
  94. m_MessureStatuWindow = new OTSMeasureStatusWindow(this);
  95. m_MessureStatuWindow.Text = m_MeasureStauWindowName;
  96. m_SamplepaceWindow = new OTSSamplespaceWindow(this);
  97. m_SamplepaceWindow.Text = m_SamplespaceWindowName;
  98. m_ProjParam = new COTSMeasureParam(this);
  99. m_ProjRstData = m_ProjParam.GetResultData();
  100. //初始化Ribbon类,操作Ribbon按钮的可用或者不可用
  101. m_RibbonFun = new OTSRibbonFun(this);
  102. //初始化测量线程
  103. m_MsrThreadWrapper = new CMeasureThreadWrapper(this);//must be the last sentence of this procedure.
  104. fileWatcher.Changed += FileWatcher_Changed;
  105. fileWatcher.EnableRaisingEvents=true;
  106. }
  107. private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
  108. {
  109. if (e.Name == "SpecialGrayConfig.xml")
  110. {
  111. m_ProjParam.SpecialRanges.IsInited = false;
  112. foreach (var s in this.m_ProjRstData.GetSampleList())
  113. {
  114. s.GetMsrParams().GetSpecialGrayRangeParam().IsInited = false;
  115. }
  116. }
  117. }
  118. private void OTSIncAMeasureAppForm_Load(object sender, EventArgs e)
  119. {
  120. try
  121. {
  122. ArrangWorkspaceWindow();
  123. log = NLog.LogManager.GetCurrentClassLogger();
  124. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  125. {
  126. m_ProjParam.LoadSpecialGrayRangeParamFile();
  127. if (m_ProjParam.InitResultData())
  128. {
  129. m_RibbonFun.SetAllRibbonButnStatus(true);
  130. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(),m_ProjRstData.GetSEMStageData());
  131. //添加启动系统界面显示
  132. if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.IncA)
  133. {
  134. this.Text += "(Inclusion)";
  135. }
  136. else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
  137. {
  138. this.Text += "(Cleanness)";
  139. }
  140. }
  141. else
  142. {
  143. log.Error(" InitResultData() failed");
  144. }
  145. }
  146. else
  147. {
  148. log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) (LoadParamFile() && LoadStageParamFile()) failed");
  149. }
  150. if (!m_MsrThreadWrapper.ConnectSEM())
  151. {
  152. MessageBox.Show("Connect SEM failed!Please goto the SysMgrApp.exe to setup the proper parameter or check other parameter of the EDS software");
  153. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  154. process.FileName = "OTSSysMgrApp.exe";//打开app的路径
  155. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  156. System.Diagnostics.Process.Start(process);
  157. this.rbConnectHardware.Enabled = true;
  158. this.rbDisconnectHardware.Enabled = false;
  159. }
  160. this.rbConnectHardware.Enabled = false;
  161. this.rbDisconnectHardware.Enabled = true;
  162. log.Warn("SEM connect success!");
  163. PrepareIpcServer();
  164. log.Info("Ipc server start success!");
  165. //----------------------Test Code, Don't delete
  166. //var f = new BaseFunctionTest();
  167. //f.ShowDialog();
  168. //----------------------
  169. }
  170. catch (Exception ex)
  171. {
  172. log.Error(" OTSIncAMeasureAppForm_Load:" + ex.ToString());
  173. }
  174. th.Abort();
  175. this.Activate();
  176. }
  177. public void ArrangWorkspaceWindow()
  178. {
  179. //Show 样品台窗口
  180. m_SamplepaceWindow.Show(dockPanel);
  181. //Show 测量状态窗口
  182. m_MessureStatuWindow.Show(dockPanel);
  183. //Show 测量结果窗口
  184. m_MeasureResultWindow.Show(dockPanel);
  185. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  186. //Show 测量过程中Log显示窗口
  187. //m_OTSMeasureOutputNlog.Show();
  188. m_OTSMeasureOutputNlog.Show(dockPanel, DockState.DockRight);
  189. dockPanel.DockRightPortion = 365;
  190. m_SPropertyWindows.Show(dockPanel);
  191. m_SamplepaceWindow.Activate();
  192. }
  193. static private void DoSplash()
  194. {
  195. try
  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. OTSSplashScreen_IncA sp = new OTSSplashScreen_IncA();
  206. sp.ShowDialog();
  207. }
  208. else if (str == "CleannessA")
  209. {
  210. OTSSplashScreen_Cleanness sp = new OTSSplashScreen_Cleanness();
  211. sp.ShowDialog();
  212. }
  213. }
  214. catch
  215. {
  216. }
  217. }
  218. private void rbReport_Click(object sender, EventArgs e)
  219. {
  220. //测量结果文件路径列表
  221. List<string> mrFilePathList = new List<string>();
  222. //获取测量结果文件路径列表
  223. bool result = m_ProjParam.GetCompletedMeasureFileName(ref mrFilePathList);
  224. if (result)
  225. {
  226. for (int i = 0; i < mrFilePathList.Count; i++)
  227. {
  228. mrFilePathList[i] = mrFilePathList[i].Replace(" ", "^");
  229. }
  230. //转换为数组
  231. string[] resultFilePath = mrFilePathList.ToArray();
  232. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  233. process.FileName = "OTSIncAReportApp.exe";//打开app的路径
  234. string FilePath = string.Join(" ", resultFilePath);
  235. process.Arguments = FilePath;//多个参数用空格隔开
  236. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  237. System.Diagnostics.Process.Start(process);
  238. }
  239. }
  240. // sNewWorkSampleName: 新工作样品名
  241. public void SwitchWSample(string sNewWorkSampleName)
  242. {
  243. m_ProjParam.SetWorkSample(sNewWorkSampleName);
  244. m_SolutionWindows.SwitchSample(sNewWorkSampleName);
  245. //获取新工作样品属性值
  246. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  247. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  248. //发送想你的样品名给Sample
  249. m_SamplepaceWindow.SwitchWorkSample(sNewWorkSampleName);
  250. }
  251. public void SoluWindowCheckBoxStatuChange(string sSampleName, bool bCheckBoxStatu)
  252. {
  253. string sWSampleName = m_ProjParam.GetWorkSampleName();
  254. if ("" == sWSampleName)
  255. {
  256. //不修改Tteeview 的工作样品属性值
  257. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  258. return;
  259. }
  260. //Treeview更改的工作样品数的CHECKBOX 状态
  261. if (!m_ProjParam.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH, OTS_ITEM_TYPES.BOOL, bCheckBoxStatu))
  262. {
  263. //不修改Tteeview 的工作样品属性值
  264. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  265. return;
  266. }
  267. // 设置 开始 ,停止 和检查参数 按钮状态
  268. m_RibbonFun.SetMeasureRibbonButnStatu();
  269. //修改Grid工作样品的SWITCH值
  270. OTSSampleVisualPropertyInfo SMeasurenfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  271. m_SPropertyWindows.DisplaySampleMeasureInfo(SMeasurenfo);
  272. }
  273. public bool EditWorkSampleName(string sSampleOldName, string sSampleNewName)
  274. {
  275. if (!m_ProjParam.ChangeWorkSampleName(sSampleNewName))
  276. {
  277. return false;
  278. }
  279. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  280. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  281. m_SamplepaceWindow.ChangeWorkSampleName(sSampleNewName);
  282. return true;
  283. }
  284. public void SoluwindowReqAddSample()
  285. {
  286. //Treeview右键点击添加新样品
  287. this.AddNewSampleMeasure();
  288. }
  289. private void OTSIncAMeasureAppForm_FormClosing(object sender, FormClosingEventArgs e)
  290. {
  291. try
  292. {
  293. if (m_MsrThreadWrapper.BGWorkThreadIsRunning ()) //当前正在测量
  294. {
  295. e.Cancel = true;
  296. return;
  297. }
  298. if (m_MsrThreadWrapper.IsHavingNotCompleteSamples()) //当前正在测量
  299. {
  300. e.Cancel = true;
  301. MessageBox.Show("There is one sample is still in pausing state,please stop it!");
  302. return;
  303. }
  304. //判断测量结果文件修改后是否保存
  305. if (m_ProjRstData.IsModified())
  306. {
  307. string message = table["message2"].ToString();
  308. DialogResult lsdr = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
  309. if (lsdr == DialogResult.Yes)
  310. {
  311. //保存,退出
  312. m_ProjRstData.Save();
  313. //保存,直接退出
  314. Application.ExitThread();
  315. }
  316. else if (lsdr == DialogResult.No)
  317. {
  318. //不保存,直接退出
  319. Application.ExitThread();
  320. }
  321. else if (lsdr == DialogResult.Cancel)
  322. {
  323. //取消
  324. e.Cancel = true;
  325. return;
  326. }
  327. }
  328. log.Info("Disconnect SEM!");
  329. m_MsrThreadWrapper.DisconnectSEM();
  330. m_MsrThreadWrapper.SetWorkThreadPending();
  331. }
  332. catch (Exception ex)
  333. {
  334. string message = table["message3"].ToString();
  335. log.Error("OTSIncAMeasureAppForm_FormClosing-"+ message + ":" + ex.ToString());
  336. }
  337. Process.GetCurrentProcess().Kill();
  338. }
  339. //打开指定路径的文件
  340. private void ribbonOrbMenuItem1_OpenWorkspace_Click(object sender, EventArgs e)
  341. {
  342. OpenMeasureProjectFile();
  343. //UpdatePropertyVal();
  344. }
  345. //新建样品工作文件
  346. private void ribbonOrbMenuItem3_CreateWorkspace_Click(object sender, EventArgs e)
  347. {
  348. int iCreateNewFileResult = m_ProjParam.CreateNewFile();
  349. if (iCreateNewFileResult == 0)
  350. {
  351. log.Error("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Failed !");
  352. return;
  353. }
  354. else if(iCreateNewFileResult == 2)
  355. {
  356. log.Info("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Cancel !");
  357. return;
  358. }
  359. m_RibbonFun.SetAllRibbonButnStatus(true);
  360. //清除TREEVIEW和GRID上的显示的已经保存的样品信息
  361. m_SolutionWindows.m_TreeViewBase.DeleteAllTreeNode();
  362. m_SPropertyWindows.m_SampleGrid.HideGrid();
  363. //设置报告按钮
  364. rbPReport.Enabled = false;
  365. rbReport.Enabled = false;
  366. rbReClassify.Enabled = true;
  367. //新建项目时,设置属性窗体中的两个按钮也为不可用状态
  368. m_SPropertyWindows.TSLoad.Enabled = false;
  369. m_SPropertyWindows.TSSaveAs.Enabled = false;
  370. //绘制样品台
  371. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  372. //隐藏XrayTable控件
  373. m_MessureStatuWindow.HideXRayTable();
  374. //新建时重新初始化结果窗体结果
  375. m_MeasureResultWindow.SetInit();
  376. }
  377. // 新建样品时提示保存样品信息Messagebox
  378. public int ShowSaveInfoMsgBox()
  379. {
  380. string message = table["message4"].ToString();
  381. DialogResult dResult = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
  382. if (dResult == DialogResult.Yes)
  383. {
  384. return (int)MessageBoxRev.DIALOG_YES;
  385. }
  386. else if (dResult == DialogResult.No)
  387. {
  388. return (int)MessageBoxRev.DIALOG_NO;
  389. }
  390. else
  391. {
  392. return (int)MessageBoxRev.DIALOG_CANCEL;
  393. }
  394. }
  395. //打开已经保存的工作文件
  396. private bool DisplayExistSampleFile()
  397. {
  398. List<CTreeSampleParam> TSampleParamList = new List<CTreeSampleParam>();
  399. List<SampleMeasurePara> SampleMeasureParaList = new List<SampleMeasurePara>();
  400. int iSampleCount = m_ProjRstData.GetSampleList().Count;
  401. if (0 == iSampleCount)
  402. {
  403. return false;
  404. }
  405. for (int i = 0; i < iSampleCount; i++)
  406. {
  407. CTreeSampleParam CTSampleParam = new CTreeSampleParam();
  408. COTSSample SampleClr = (m_ProjRstData.GetSampleList())[i];
  409. CTSampleParam.sSampleTitleName = m_ProjRstData.GetFileName();
  410. CTSampleParam.sWorkSampleName = SampleClr.GetName();
  411. CTSampleParam.bSwitch = SampleClr.GetSwitch();
  412. TSampleParamList.Add(CTSampleParam);
  413. }
  414. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  415. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  416. m_SolutionWindows.DisplayExistSampleFile(TSampleParamList, SMInfo.TSampleParam);
  417. if (!InitExistSampleMeasureParam(ref SampleMeasureParaList))
  418. {
  419. log.Error(" OpenExistSampleMeasureArea(ref SampleMeasureAreaList) Failed !");
  420. return false;
  421. }
  422. string sWSampleName = m_ProjParam.GetWorkSampleName();
  423. if ("" == sWSampleName)
  424. {
  425. log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile) m_DataMgrFun.GetWorkSampleName() = null !");
  426. return false;
  427. }
  428. m_SamplepaceWindow.DisplayVisualStage(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  429. m_SamplepaceWindow.DisplayExistSamples( SampleMeasureParaList);
  430. m_MeasureResultWindow.UpdateResultInfoBySampleName(sWSampleName);
  431. return true;
  432. }
  433. public bool InitExistSampleMeasureParam(ref List<SampleMeasurePara> SampleMeasureParaList)
  434. {
  435. int iSListCount = m_ProjRstData.GetSampleList().Count;
  436. if (0 == iSListCount)
  437. {
  438. return false;
  439. }
  440. for (int i = 0; i < iSListCount; i++)
  441. {
  442. SampleMeasurePara SampleMeasureParam =new SampleMeasurePara(m_ProjRstData.GetSampleList()[i]);
  443. SampleMeasureParaList.Add(SampleMeasureParam);
  444. }
  445. return true;
  446. }
  447. //打开指定路径的文件
  448. private void rbOpen_Click(object sender, EventArgs e)
  449. {
  450. OpenMeasureProjectFile();
  451. }
  452. private void rbDeleteSample_Click(object sender, EventArgs e)
  453. {
  454. //删除样品(样品必须先选中)
  455. string sWSampleName = m_ProjParam.GetWorkSampleName();
  456. if ("" == sWSampleName)
  457. {
  458. log.Error("(OTSIncAMeasureAppForm.rbDeleteSample_Click) m_DataMgrFun.GetWorkSampleName() = null Failed");
  459. return;
  460. }
  461. string message = table["message5"].ToString();
  462. string message6 = table["message6"].ToString();
  463. string sDeleteSampleName = message;
  464. sDeleteSampleName += sWSampleName;
  465. sDeleteSampleName += message6;
  466. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Tip", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  467. {
  468. //删除样品成功
  469. DeleteSample(sWSampleName);
  470. sWSampleName = m_ProjParam.GetWorkSampleName();
  471. if ("" != sWSampleName)
  472. {
  473. m_SolutionWindows.m_TreeViewBase.GetTreeWorkSampleNode(sWSampleName);
  474. m_SolutionWindows.treeView1.Focus();
  475. }
  476. }
  477. }
  478. //返回删除的工作样品名
  479. public void DeleteSample(string sDeleteWSampleName = "")
  480. {
  481. if (m_MsrThreadWrapper.m_measure.mapSmplMsr.ContainsKey(sDeleteWSampleName))
  482. {
  483. m_MsrThreadWrapper.m_measure.mapSmplMsr.Remove(sDeleteWSampleName);
  484. }
  485. m_ProjParam.DeleteWorkSample(sDeleteWSampleName);
  486. // 设置 开始 ,停止 和检查参数 按钮状态
  487. m_RibbonFun.SetMeasureRibbonButnStatu();
  488. //设置 删除,复位,圆形,矩形 按钮状态
  489. m_RibbonFun.SetSampleRibbonButnStatus();
  490. // 更新报告ribbon按钮状态
  491. m_RibbonFun.SetAllRibbonButnStatus(true);
  492. int iSampleCount = m_ProjParam.GetSampleCount();
  493. if (0 == iSampleCount)
  494. {
  495. //给工作样品台发送删除样品和新的工作样品名称
  496. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  497. m_SPropertyWindows.PropGrid.Hide();
  498. m_SolutionWindows.treeView1.Nodes.Clear();
  499. m_MessureStatuWindow.HideXRayTable();
  500. m_MeasureResultWindow.SetInit();
  501. return ;
  502. }
  503. else
  504. {
  505. string sNewWSName = m_ProjParam.GetWorkSampleName();
  506. if ("" == sNewWSName)
  507. {
  508. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetWorkSampleName() = null Failed");
  509. return ;
  510. }
  511. m_SolutionWindows.DeletCurrentSampleNode();
  512. m_SolutionWindows.DisplaySample(sNewWSName);
  513. //将测量状态初始化
  514. m_MessureStatuWindow.SetMeasureStatusInit();
  515. //给工作样品台发送删除样品和新的工作样品名称
  516. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  517. //设置工作样品
  518. SwitchWSample(sNewWSName);
  519. }
  520. return ;
  521. }
  522. private void rbAddSample_Click(object sender, EventArgs e)
  523. {
  524. this.AddNewSampleMeasure();//the system will choose the empty hole one by one according to the holeNo sequence.
  525. }
  526. public void AddNewSampleMeasure(string sSampleHoleName = "")
  527. {
  528. OTSSampleVisualPropertyInfo SMInfo = m_ProjParam.AddNewSampleMeasure(sSampleHoleName);
  529. if (null == SMInfo)
  530. {
  531. // 设置 开始 ,停止 和检查参数 按钮状态
  532. m_RibbonFun.SetMeasureRibbonButnStatu();
  533. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  534. return;
  535. }
  536. m_SPropertyWindows.TSSaveAs.Enabled = true;
  537. m_SPropertyWindows.TSLoad.Enabled = true;
  538. m_SPropertyWindows.TSEdit.Enabled = false;
  539. m_SPropertyWindows.TSEdit.Visible = false;
  540. //给SampleWindow 发送样品信息
  541. m_SamplepaceWindow.AddSampleArea(SMInfo.SMeasurePara);
  542. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  543. //给PropWindow 发送工作样品属性信息
  544. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  545. //给SoluWindow 发送样品显示信息
  546. m_SolutionWindows.AddSampleMeasure(SMInfo.TSampleParam);
  547. // 设置 开始 ,停止 和检查参数 按钮状态
  548. m_RibbonFun.SetMeasureRibbonButnStatu();
  549. //设置 删除,复位,圆形,矩形 按钮状态
  550. m_RibbonFun.SetSampleRibbonButnStatus();
  551. //清空帧图信息
  552. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  553. }
  554. public void InitCurrentSampleState()
  555. {
  556. OTSSampleVisualPropertyInfo SMInfo = m_ProjParam.GetWorkingSampleVisualPropertyInfo();
  557. if (null == SMInfo)
  558. {
  559. // 设置 开始 ,停止 和检查参数 按钮状态
  560. m_RibbonFun.SetMeasureRibbonButnStatu();
  561. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  562. return;
  563. }
  564. m_SPropertyWindows.TSSaveAs.Enabled = true;
  565. m_SPropertyWindows.TSLoad.Enabled = true;
  566. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  567. //给PropWindow 发送工作样品属性信息
  568. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  569. // 设置 开始 ,停止 和检查参数 按钮状态
  570. m_RibbonFun.SetMeasureRibbonButnStatu();
  571. //设置 删除,复位,圆形,矩形 按钮状态
  572. m_RibbonFun.SetSampleRibbonButnStatus();
  573. //清空帧图信息
  574. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  575. }
  576. private void rbSelectDlg_Click(object sender, EventArgs e)
  577. {
  578. //判断样品台是否有样品,如果有样品则不能设置默认参数
  579. if (m_ProjParam.GetSampleCount() > 0)
  580. {
  581. MessageBox.Show("Cann't setup preference parameter,for you have added some samples!");
  582. return;
  583. }
  584. ProgMgrInfoForm ProgMgrForm = new ProgMgrInfoForm();
  585. if (DialogResult.OK == ProgMgrForm.ShowDialog())
  586. {
  587. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  588. {
  589. if (m_ProjParam.InitResultData())
  590. {
  591. m_RibbonFun.SetAllRibbonButnStatus(true);
  592. //当样品台上有样品,则不更新样品台数据
  593. if (0 == m_ProjParam.GetSampleCount())
  594. {
  595. m_SamplepaceWindow.InitStageDisplay(m_ProjRstData.GetStage(), m_ProjRstData.GetSEMStageData());
  596. }
  597. }
  598. else
  599. {
  600. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) this.CheckMeasureSysFileExist() = false");
  601. }
  602. }
  603. else
  604. {
  605. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
  606. }
  607. }
  608. }
  609. // 主Windows框右下角显示鼠标点的SEM坐标(样品台)
  610. public void ShowSemCoordvAL(string sSemCoord)
  611. {
  612. STSemCoordinate.Text = sSemCoord;
  613. statusStrip1.Refresh();
  614. }
  615. //// 主Windows框右下角显示鼠标点的灰度值(测量图)
  616. public void ShowGrayVal(string sGrayVal)
  617. {
  618. TSGrayVal.Text = sGrayVal;
  619. statusStrip1.Refresh();
  620. }
  621. //获取工作样品测量锁
  622. public bool GetWorkSampleParamLock(ref CTreeSampleParam TSParamLock)
  623. {
  624. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  625. TSParamLock = SMInfo.TSampleParam;
  626. return true;
  627. }
  628. /// <summary>
  629. /// 更新属性窗口
  630. /// </summary>
  631. public void UpdatePropertyVal()
  632. {
  633. //获取新的工作样品属性值
  634. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(m_ProjParam.GetWorkSample(),m_ProjParam.GetDefaultParam().GetSysType());
  635. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  636. }
  637. private void ribbonOrbMenuItemSaveAs_Click(object sender, EventArgs e)
  638. {
  639. bool iRev = m_ProjRstData.SaveAs();
  640. if (!iRev)
  641. {
  642. return;
  643. }
  644. m_ProjParam.InitWorkingSampleData(0);
  645. this.InitCurrentSampleState();
  646. m_MeasureResultWindow.SetInit();
  647. m_SamplepaceWindow. PrepareMeasureField(m_SamplepaceWindow.GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
  648. }
  649. private void rbSaveFile_Click(object sender, EventArgs e)
  650. {
  651. bool iRev = m_ProjRstData.Save();
  652. if (!iRev)
  653. {
  654. return;
  655. }
  656. }
  657. private void rbCheckParam_Click(object sender, EventArgs e)
  658. {
  659. //检查样品测量参数
  660. if (m_ProjParam.CheckSampleParam(true))
  661. {
  662. string message = table["message7"].ToString();
  663. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  664. }
  665. }
  666. private void ribReset_Click(object sender, EventArgs e)
  667. {
  668. //调用样品台窗口中的复位方法
  669. m_SamplepaceWindow.ResetWorkSampleMeasure();
  670. }
  671. //绘制圆形测量区域
  672. private void ribCircle_Click(object sender, EventArgs e)
  673. {
  674. //修改工作样品的测量区域为圆形
  675. m_SamplepaceWindow.DrawCircleMeasure();
  676. }
  677. private void rbThreePoints_Click(object sender, EventArgs e)
  678. {
  679. //修改工作样品的测量区域为圆形
  680. m_SamplepaceWindow.DrawCircleMeasureByThreePoints();
  681. }
  682. private void rbRingShape_Click(object sender, EventArgs e)
  683. {
  684. //修改工作样品的测量区域为圆形
  685. m_SamplepaceWindow.DrawRingShapeArea();
  686. }
  687. //绘制矩形测量区域
  688. private void ribRectangle_Click(object sender, EventArgs e)
  689. {
  690. //修改工作样品的测量区域为矩形
  691. m_SamplepaceWindow.DrawRectangleMeasure();
  692. }
  693. private void rbExitApp_Click(object sender, EventArgs e)
  694. {
  695. this.Close();
  696. }
  697. private void rbStart_Click(object sender, EventArgs e)
  698. {
  699. if (!m_ProjParam.CheckSampleParam(false))
  700. {
  701. return;
  702. }
  703. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning() && !m_MsrThreadWrapper.BgWorkIsPaused())
  704. {
  705. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  706. m_MsrThreadWrapper.StartBGWorkThread();
  707. m_RibbonFun.SetMeasureRibbonButnStatu();
  708. }
  709. else //thread is in pausing state
  710. {
  711. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  712. m_MsrThreadWrapper.SetMeasureThreadStatus(OTS_MSR_THREAD_STATUS.INPROCESS);
  713. m_RibbonFun.SetMeasureRibbonButnStatu();
  714. }
  715. }
  716. public void SetStartMeasureRibbonStatus()
  717. {
  718. ribView.Enabled = false;
  719. m_RibbonFun.SetToolButnStatu(false);
  720. //false: 将其他ribbon按钮设置为灰色
  721. rbPanelFile.Enabled = false;
  722. rbPanelSample.Enabled = false;
  723. m_SolutionWindows.Enabled = false;
  724. m_SPropertyWindows.Enabled = false;
  725. rbStart.Enabled = false;
  726. //rbPause.Enabled = true;
  727. rbStop.Enabled = true;
  728. rbCheckParam.Enabled = false;
  729. }
  730. private void rbStop_Click(object sender, EventArgs e)
  731. {
  732. //如果当前正在测量,则停止测量线程
  733. if (MeasureThreadRunFlag)
  734. {
  735. //停止测量线程
  736. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  737. }
  738. else if (m_MsrThreadWrapper.m_measure.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
  739. {
  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. 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. }