OTSIncAMeasureAppForm.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  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 CefSharp;
  9. using OTSDataType;
  10. using OTSModelSharp;
  11. using OTSModelSharp.ResourceManage;
  12. using static OTSDataType.otsdataconst;
  13. using System.Diagnostics;
  14. using OTSModelSharp.ServiceInterface;
  15. using OTSMeasureApp._0_OTSModel.Measure.ParamData;
  16. using OTSCLRINTERFACE;
  17. using System.IO;
  18. using System.Management;
  19. using System.Xml;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Runtime.Remoting.Channels.Ipc;
  23. using System.Runtime.Remoting.Channels;
  24. using System.Runtime.Remoting;
  25. using OTSMeasureApp.ServiceCenter;
  26. namespace OTSMeasureApp
  27. {
  28. public enum ShapeType
  29. {
  30. CIRCUL = 0, //圆形
  31. RECTANGLE = 1 //矩形
  32. };
  33. enum MessageBoxRev
  34. {
  35. DIALOG_YES = 0,
  36. DIALOG_NO = 1,
  37. DIALOG_CANCEL = 2
  38. }
  39. public partial class OTSIncAMeasureAppForm : Form
  40. {
  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_MeasureRetWindow = 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_ProjData;
  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. InitializeComponent();
  79. //国际化
  80. lan = new OTSCommon.Language(this);
  81. table = lan.GetNameTable(this.Name);
  82. m_SamplespaceWindowName = table["m_samplespacewindowname"].ToString();
  83. m_MeasureStauWindowName = table["m_measurestauwindowname"].ToString();
  84. m_MeasureRetWindowName = table["m_measureretwindowname"].ToString();
  85. m_NoWindowName = table["m_nowindowname"].ToString();
  86. m_OTSMeasureOutputNlog = new OTSMeasureOutputNlog();
  87. m_OTSMeasureOutputNlog.Show();
  88. // 初始化Docpanle
  89. m_SolutionWindows = new OTSSolutionWindow(this);
  90. m_SPropertyWindows = new OTSPropertyWindow(this);
  91. m_MeasureRetWindow = new OTSMeasureResultWindow(this);
  92. m_MeasureRetWindow.Text = m_MeasureRetWindowName;
  93. m_MessureStatuWindow = new OTSMeasureStatusWindow(this);
  94. m_MessureStatuWindow.Text = m_MeasureStauWindowName;
  95. m_SamplepaceWindow = new OTSSamplespaceWindow(this);
  96. m_SamplepaceWindow.Text = m_SamplespaceWindowName;
  97. //和DataMgr进行数据交互类
  98. m_ProjParam = new COTSMeasureParam(this);
  99. m_ProjData = 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_ProjData.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_ProjData.GetStage(),m_ProjData.GetSEMStageData());
  131. //添加启动系统界面显示
  132. if (m_ProjParam.GetDefaultParam().m_nPackId == OTS_SysType_ID.IncA)
  133. {
  134. this.Text += "(Inclusion)";
  135. }
  136. else if (m_ProjParam.GetDefaultParam().m_nPackId == 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. }
  175. public void ArrangWorkspaceWindow()
  176. {
  177. //Show 样品台窗口
  178. m_SamplepaceWindow.Show(dockPanel);
  179. //Show 测量状态窗口
  180. m_MessureStatuWindow.Show(dockPanel);
  181. //Show 测量结果窗口
  182. m_MeasureRetWindow.Show(dockPanel);
  183. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  184. //Show 测量过程中Log显示窗口
  185. m_OTSMeasureOutputNlog.Show(dockPanel, DockState.DockRight);
  186. dockPanel.DockRightPortion = 365;
  187. m_SPropertyWindows.Show(dockPanel);
  188. m_SamplepaceWindow.Activate();
  189. }
  190. private void rbReport_Click(object sender, EventArgs e)
  191. {
  192. //测量结果文件路径列表
  193. List<string> mrFilePathList = new List<string>();
  194. //获取测量结果文件路径列表
  195. bool result = m_ProjParam.GetCompletedMeasureFileName(ref mrFilePathList);
  196. if (result)
  197. {
  198. for (int i = 0; i < mrFilePathList.Count; i++)
  199. {
  200. mrFilePathList[i] = mrFilePathList[i].Replace(" ", "^");
  201. }
  202. //转换为数组
  203. string[] resultFilePath = mrFilePathList.ToArray();
  204. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  205. process.FileName = "OTSIncAReportApp.exe";//打开app的路径
  206. string FilePath = string.Join(" ", resultFilePath);
  207. process.Arguments = FilePath;//多个参数用空格隔开
  208. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  209. System.Diagnostics.Process.Start(process);
  210. }
  211. }
  212. // sNewWorkSampleName: 新工作样品名
  213. public void SwitchWSample(string sNewWorkSampleName)
  214. {
  215. m_ProjParam.SetWorkSample(sNewWorkSampleName);
  216. m_SolutionWindows.SwitchSample(m_ProjParam.GetWorkSampleName());
  217. //获取新工作样品属性值
  218. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  219. m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo);
  220. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  221. //发送新的样品名给Treeview
  222. m_SolutionWindows.SwitchSample(sNewWorkSampleName);
  223. //发送想你的样品名给Sample
  224. m_SamplepaceWindow.SwitchWorkSample(sNewWorkSampleName);
  225. //根据节点设置样品台窗口中所选择的样品名称
  226. }
  227. public void Rev_SoluWindowReqCheckBosStatuChange_Event(string sSampleName, bool bCheckBoxStatu)
  228. {
  229. string sWSampleName = m_ProjParam.GetWorkSampleName();
  230. if ("" == sWSampleName)
  231. {
  232. //不修改Tteeview 的工作样品属性值
  233. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  234. return;
  235. }
  236. //Treeview更改的工作样品数的CHECKBOX 状态
  237. if (!m_ProjParam.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH, OTS_ITEM_TYPES.BOOL, bCheckBoxStatu))
  238. {
  239. //不修改Tteeview 的工作样品属性值
  240. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  241. return;
  242. }
  243. // 设置 开始 ,停止 和检查参数 按钮状态
  244. m_RibbonFun.SetMeasureRibbonButnStatu();
  245. //修改Grid工作样品的SWITCH值
  246. OTSSamplePropertyInfo SMeasurenfo = new OTSSamplePropertyInfo();
  247. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMeasurenfo))
  248. {
  249. return;
  250. }
  251. m_SPropertyWindows.DisplaySampleMeasureInfo(SMeasurenfo);
  252. }
  253. public bool EditWorkSampleName(string sSampleOldName, string sSampleNewName)
  254. {
  255. if (!m_ProjParam.ChangeWorkSampleName(sSampleNewName))
  256. {
  257. return false;
  258. }
  259. // 获取修改名称后的工作样品属性值
  260. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  261. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  262. {
  263. return false;
  264. }
  265. //获取修改名称后的工作样品属性值发送给Grid显示
  266. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  267. //给样品台发送新的工作样品名称
  268. m_SamplepaceWindow.ChangeWorkSampleName(sSampleNewName);
  269. return true;
  270. }
  271. public void SoluwindowReqAddSample()
  272. {
  273. //Treeview右键点击添加新样品
  274. this.AddNewSampleMeasure();
  275. }
  276. private void OTSIncAMeasureAppForm_FormClosing(object sender, FormClosingEventArgs e)
  277. {
  278. try
  279. {
  280. if (m_MsrThreadWrapper.BGWorkThreadIsRunning ()) //当前正在测量
  281. {
  282. e.Cancel = true;
  283. return;
  284. }
  285. if (m_MsrThreadWrapper.IsHavingNotCompleteSamples()) //当前正在测量
  286. {
  287. e.Cancel = true;
  288. MessageBox.Show("There is one sample is still in pausing state,please stop it!");
  289. return;
  290. }
  291. //判断测量结果文件修改后是否保存
  292. if (m_ProjData.IsModified())
  293. {
  294. string message = table["message2"].ToString();
  295. DialogResult lsdr = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
  296. if (lsdr == DialogResult.Yes)
  297. {
  298. //保存,退出
  299. m_ProjData.Save();
  300. //保存,直接退出
  301. Application.ExitThread();
  302. }
  303. else if (lsdr == DialogResult.No)
  304. {
  305. //不保存,直接退出
  306. Application.ExitThread();
  307. }
  308. else if (lsdr == DialogResult.Cancel)
  309. {
  310. //取消
  311. e.Cancel = true;
  312. return;
  313. }
  314. }
  315. log.Info("Disconnect SEM!");
  316. m_MsrThreadWrapper.DisconnectSEM();
  317. m_MsrThreadWrapper.SetWorkThreadPending();
  318. }
  319. catch (Exception ex)
  320. {
  321. string message = table["message3"].ToString();
  322. log.Error("OTSIncAMeasureAppForm_FormClosing-"+ message + ":" + ex.ToString());
  323. }
  324. Process.GetCurrentProcess().Kill();
  325. }
  326. //打开指定路径的文件
  327. private void ribbonOrbMenuItem1_OpenWorkspace_Click(object sender, EventArgs e)
  328. {
  329. OpenMeasureProjectFile();
  330. //UpdatePropertyVal();
  331. }
  332. //新建样品工作文件
  333. private void ribbonOrbMenuItem3_CreateWorkspace_Click(object sender, EventArgs e)
  334. {
  335. int iCreateNewFileResult = m_ProjParam.CreateNewFile();
  336. if (iCreateNewFileResult == 0)
  337. {
  338. log.Error("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Failed !");
  339. return;
  340. }
  341. else if(iCreateNewFileResult == 2)
  342. {
  343. log.Info("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Cancel !");
  344. return;
  345. }
  346. m_RibbonFun.SetAllRibbonButnStatus(true);
  347. //清除TREEVIEW和GRID上的显示的已经保存的样品信息
  348. m_SolutionWindows.m_TreeViewBase.DeleteAllTreeNode();
  349. m_SPropertyWindows.m_SampleGrid.HideGrid();
  350. //设置报告按钮
  351. rbPReport.Enabled = false;
  352. rbReport.Enabled = false;
  353. rbReClassify.Enabled = true;
  354. //新建项目时,设置属性窗体中的两个按钮也为不可用状态
  355. m_SPropertyWindows.TSLoad.Enabled = false;
  356. m_SPropertyWindows.TSSaveAs.Enabled = false;
  357. //绘制样品台
  358. m_SamplepaceWindow.InitStageDisplay(m_ProjData.GetStage(), m_ProjData.GetSEMStageData());
  359. //隐藏XrayTable控件
  360. m_MessureStatuWindow.HideXRayTable();
  361. //新建时重新初始化结果窗体结果
  362. m_MeasureRetWindow.SetInit();
  363. }
  364. // 新建样品时提示保存样品信息Messagebox
  365. public int ShowSaveInfoMsgBox()
  366. {
  367. string message = table["message4"].ToString();
  368. DialogResult dResult = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
  369. if (dResult == DialogResult.Yes)
  370. {
  371. return (int)MessageBoxRev.DIALOG_YES;
  372. }
  373. else if (dResult == DialogResult.No)
  374. {
  375. return (int)MessageBoxRev.DIALOG_NO;
  376. }
  377. else
  378. {
  379. return (int)MessageBoxRev.DIALOG_CANCEL;
  380. }
  381. }
  382. //打开已经保存的工作文件
  383. private bool DisplayExistSampleFile()
  384. {
  385. List<CTreeSampleParam> TSampleParamList = new List<CTreeSampleParam>();
  386. List<SampleMeasurePara> SampleMeasureAreaList = new List<SampleMeasurePara>();
  387. int iSampleCount = m_ProjData.GetSampleList().Count;
  388. if (0 == iSampleCount)
  389. {
  390. return false;
  391. }
  392. for (int i = 0; i < iSampleCount; i++)
  393. {
  394. CTreeSampleParam CTSampleParam = new CTreeSampleParam();
  395. COTSSample SampleClr = (m_ProjData.GetSampleList())[i];
  396. CTSampleParam.sSampleTitleName = m_ProjData.GetFileName();
  397. CTSampleParam.sWorkSampleName = SampleClr.GetName();
  398. CTSampleParam.bSwitch = SampleClr.GetSwitch();
  399. CTSampleParam.bParamLock = SampleClr.GetParamLock();
  400. TSampleParamList.Add(CTSampleParam);
  401. }
  402. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  403. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetResultData().GetWorkingSample(), ref SMInfo))
  404. {
  405. log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(), ref SMInfo) = false Failed !");
  406. return false;
  407. }
  408. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  409. m_SolutionWindows.OpenExistSampleFile(TSampleParamList, SMInfo.TSampleParam);
  410. if (!OpenExistSampleMeasureArea(ref SampleMeasureAreaList))
  411. {
  412. log.Error(" OpenExistSampleMeasureArea(ref SampleMeasureAreaList) Failed !");
  413. return false;
  414. }
  415. string sWSampleName = m_ProjParam.GetWorkSampleName();
  416. if ("" == sWSampleName)
  417. {
  418. log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile) m_DataMgrFun.GetWorkSampleName() = null !");
  419. return false;
  420. }
  421. m_SamplepaceWindow.OpenExistSampleFile(m_ProjData.GetStage(), m_ProjData.GetSEMStageData(), SampleMeasureAreaList);
  422. return true;
  423. }
  424. public bool OpenExistSampleMeasureArea(ref List<SampleMeasurePara> SampleMeasureParaList)
  425. {
  426. int iSListCount = m_ProjData.GetSampleList().Count;
  427. if (0 == iSListCount)
  428. {
  429. return false;
  430. }
  431. for (int i = 0; i < iSListCount; i++)
  432. {
  433. SampleMeasurePara SampleMeasureArea = new SampleMeasurePara();
  434. //获取样品的测量区域信息
  435. //获取样品名称
  436. SampleMeasureArea.sSampleName = (m_ProjData.GetSampleList())[i].GetName();
  437. // 获取测量区域形状
  438. SampleMeasureArea.iShape = (ShapeType)m_ProjData.GetSampleList()[i].GetMsrDomain().GetShape();
  439. //获取样品孔名称
  440. SampleMeasureArea.sampleHoleName = (m_ProjData.GetSampleList())[i].GetSampleHoleName();
  441. //样品测量区域
  442. SampleMeasureArea.MeasureRect =(m_ProjData.GetSampleList())[i].GetMsrDomain().GetRectDomain();
  443. //多边形点集合
  444. List<PointF> PointRegionF = new List<PointF>();
  445. List<Point> PolygonPoint = m_ProjData.GetSampleList()[i].GetMsrDomain().GetPolygonPoint();
  446. if (PolygonPoint != null)
  447. {
  448. foreach (var item in m_ProjData.GetSampleList()[i].GetMsrDomain().GetPolygonPoint())
  449. {
  450. PointRegionF.Add(new PointF(item.X, item.Y));
  451. }
  452. }
  453. SampleMeasureArea.DrawPolygonPointList = PointRegionF;
  454. SampleMeasureParaList.Add(SampleMeasureArea);
  455. }
  456. return true;
  457. }
  458. //打开指定路径的文件
  459. private void rbOpen_Click(object sender, EventArgs e)
  460. {
  461. OpenMeasureProjectFile();
  462. }
  463. private void rbDeleteSample_Click(object sender, EventArgs e)
  464. {
  465. //删除样品(样品必须先选中)
  466. string sWSampleName = m_ProjParam.GetWorkSampleName();
  467. if ("" == sWSampleName)
  468. {
  469. log.Error("(OTSIncAMeasureAppForm.rbDeleteSample_Click) m_DataMgrFun.GetWorkSampleName() = null Failed");
  470. return;
  471. }
  472. string message = table["message5"].ToString();
  473. string message6 = table["message6"].ToString();
  474. string sDeleteSampleName = message;
  475. sDeleteSampleName += sWSampleName;
  476. sDeleteSampleName += message6;
  477. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Tip", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  478. {
  479. //删除样品成功
  480. DeleteSample(sWSampleName);
  481. sWSampleName = m_ProjParam.GetWorkSampleName();
  482. if ("" != sWSampleName)
  483. {
  484. m_SolutionWindows.m_TreeViewBase.GetTreeWorkSampleNode(sWSampleName);
  485. m_SolutionWindows.treeView1.Focus();
  486. }
  487. }
  488. }
  489. //返回删除的工作样品名
  490. public void DeleteSample(string sDeleteWSampleName = "")
  491. {
  492. if (m_MsrThreadWrapper.m_measure.mapSmplMsr.ContainsKey(sDeleteWSampleName))
  493. {
  494. m_MsrThreadWrapper.m_measure.mapSmplMsr.Remove(sDeleteWSampleName);
  495. }
  496. if (!m_ProjParam.DeleteWorkSample(sDeleteWSampleName))
  497. {
  498. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.DeleteWorkSample(sDeleteWSampleName) Failed, sDeleteWSampleName = " + sDeleteWSampleName);
  499. }
  500. // 设置 开始 ,停止 和检查参数 按钮状态
  501. m_RibbonFun.SetMeasureRibbonButnStatu();
  502. //设置 删除,复位,圆形,矩形 按钮状态
  503. m_RibbonFun.SetSampleRibbonButnStatus();
  504. // 更新报告ribbon按钮状态
  505. m_RibbonFun.SetAllRibbonButnStatus(true);
  506. int iSampleCount = m_ProjParam.GetSampleCount();
  507. if (0 == iSampleCount)
  508. {
  509. //给工作样品台发送删除样品和新的工作样品名称
  510. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  511. m_SPropertyWindows.PropGrid.Hide();
  512. m_SolutionWindows.treeView1.Nodes.Clear();
  513. m_MessureStatuWindow.HideXRayTable();
  514. m_MeasureRetWindow.SetInit();
  515. return ;
  516. }
  517. else
  518. {
  519. string sNewWSName = m_ProjParam.GetWorkSampleName();
  520. if ("" == sNewWSName)
  521. {
  522. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetWorkSampleName() = null Failed");
  523. return ;
  524. }
  525. m_SolutionWindows.DeletCurrentSampleNode();
  526. m_SolutionWindows.DisplaySample(sNewWSName);
  527. //将测量状态初始化
  528. m_MessureStatuWindow.SetMeasureStatusInit();
  529. //给工作样品台发送删除样品和新的工作样品名称
  530. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  531. //设置工作样品
  532. SwitchWSample(sNewWSName);
  533. }
  534. return ;
  535. }
  536. private void rbAddSample_Click(object sender, EventArgs e)
  537. {
  538. this.AddNewSampleMeasure();//the system will choose the empty hole one by one according to the holeNo sequence.
  539. }
  540. public void AddNewSampleMeasure(string sSampleHoleName = "")
  541. {
  542. //样品的属性值
  543. OTSSamplePropertyInfo SMInfo = m_ProjParam.AddNewSampleMeasure(sSampleHoleName);
  544. if (null == SMInfo)
  545. {
  546. // 设置 开始 ,停止 和检查参数 按钮状态
  547. m_RibbonFun.SetMeasureRibbonButnStatu();
  548. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  549. return;
  550. }
  551. m_SPropertyWindows.TSSaveAs.Enabled = true;
  552. m_SPropertyWindows.TSLoad.Enabled = true;
  553. //给SampleWindow 发送样品信息
  554. m_SamplepaceWindow.AddSampleArea(SMInfo.SMeasurePara);
  555. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  556. //给PropWindow 发送工作样品属性信息
  557. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  558. //给SoluWindow 发送样品显示信息
  559. m_SolutionWindows.AddSampleMeasure(SMInfo.TSampleParam);
  560. // 设置 开始 ,停止 和检查参数 按钮状态
  561. m_RibbonFun.SetMeasureRibbonButnStatu();
  562. //设置 删除,复位,圆形,矩形 按钮状态
  563. m_RibbonFun.SetSampleRibbonButnStatus();
  564. //清空帧图信息
  565. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  566. }
  567. private void rbSelectDlg_Click(object sender, EventArgs e)
  568. {
  569. //判断样品台是否有样品,如果有样品则不能设置默认参数
  570. if (m_ProjParam.GetSampleCount() > 0)
  571. {
  572. MessageBox.Show("Cann't setup preference parameter,for you have added some samples!");
  573. return;
  574. }
  575. ProgMgrInfoForm ProgMgrForm = new ProgMgrInfoForm();
  576. if (DialogResult.OK == ProgMgrForm.ShowDialog())
  577. {
  578. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  579. {
  580. if (m_ProjParam.InitResultData())
  581. {
  582. m_RibbonFun.SetAllRibbonButnStatus(true);
  583. //当样品台上有样品,则不更新样品台数据
  584. if (0 == m_ProjParam.GetSampleCount())
  585. {
  586. m_SamplepaceWindow.InitStageDisplay(m_ProjData.GetStage(), m_ProjData.GetSEMStageData());
  587. }
  588. }
  589. else
  590. {
  591. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) this.CheckMeasureSysFileExist() = false");
  592. }
  593. }
  594. else
  595. {
  596. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
  597. }
  598. }
  599. }
  600. // 主Windows框右下角显示鼠标点的SEM坐标(样品台)
  601. public void ShowSemCoordvAL(string sSemCoord)
  602. {
  603. STSemCoordinate.Text = sSemCoord;
  604. statusStrip1.Refresh();
  605. }
  606. //// 主Windows框右下角显示鼠标点的灰度值(测量图)
  607. public void ShowGrayVal(string sGrayVal)
  608. {
  609. TSGrayVal.Text = sGrayVal;
  610. statusStrip1.Refresh();
  611. }
  612. //获取工作样品测量锁
  613. public bool GetWorkSampleParamLock(ref CTreeSampleParam TSParamLock)
  614. {
  615. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  616. if (!m_ProjParam.GetWSampleParaLock(ref SMInfo))
  617. {
  618. return false;
  619. }
  620. TSParamLock = SMInfo.TSampleParam;
  621. return true;
  622. }
  623. /// <summary>
  624. /// 更新属性窗口
  625. /// </summary>
  626. public void UpdatePropertyVal()
  627. {
  628. //获取新的工作样品属性值
  629. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  630. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  631. {
  632. log.Error("(OTSIncAMeasureAppForm.SetSEMData) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(),ref SMInfo) = false Failed");
  633. }
  634. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  635. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  636. }
  637. private void ribbonOrbMenuItemSaveAs_Click(object sender, EventArgs e)
  638. {
  639. bool iRev = m_ProjData.SaveAs();
  640. if (!iRev)
  641. {
  642. return;
  643. }
  644. }
  645. private void rbSaveFile_Click(object sender, EventArgs e)
  646. {
  647. bool iRev = m_ProjData.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.SetDoRunType(MSR_RUN_TYPE.RUNMEASURE);
  703. m_MsrThreadWrapper.StartBGWorkThread();
  704. m_RibbonFun.SetMeasureRibbonButnStatu();
  705. }
  706. else //thread is in pausing state
  707. {
  708. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  709. //m_MsrThreadWrapper.SetDoRunType(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. foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_measure.mapSmplMsr)
  739. {
  740. if (smpl.Value.GetSample().GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
  741. {
  742. smpl.Value.TheLastWorkOfSampleMeasure();
  743. return;
  744. }
  745. }
  746. }
  747. }
  748. private void rbPause_Click(object sender, EventArgs e)
  749. {
  750. //如果当前正在测量,则停止测量线程
  751. if (MeasureThreadRunFlag)
  752. {
  753. //停止测量线程
  754. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.PAUSED);
  755. }
  756. }
  757. private void rbRuler_Click(object sender, EventArgs e)
  758. {
  759. m_SamplepaceWindow.ShowRulerLocation();
  760. }
  761. private void rbSmapleName_Click(object sender, EventArgs e)
  762. {
  763. //m_SamplepaceWindow.ChangeSampleHoleFont();
  764. }
  765. private void rbSmaplePhoto_Click(object sender, EventArgs e)
  766. {
  767. m_SamplepaceWindow.ChangeSampleHoleImage();
  768. }
  769. //当点击Ribbon停止按钮时,设置Ribbon状态
  770. public void SetStopMeasureRibbonStatus()
  771. {
  772. ribView.Enabled = true;
  773. m_RibbonFun.SetToolButnStatu(true);
  774. rbPanelFile.Enabled = true;
  775. rbPanelSample.Enabled = true;
  776. m_RibbonFun.SetMeasureRibbonButnStatu();
  777. m_SolutionWindows.Enabled = true;
  778. m_SPropertyWindows.Enabled = true;
  779. rbStart.Enabled = true;
  780. rbPause.Enabled = false;
  781. rbStop.Enabled = false;
  782. rbCheckParam.Enabled = true;
  783. }
  784. public void SetPauseMeasureRibbonStatus()
  785. {
  786. ribView.Enabled = true;
  787. m_RibbonFun.SetToolButnStatu(true);
  788. rbPanelFile.Enabled = true;
  789. rbPanelSample.Enabled = true;
  790. m_RibbonFun.SetMeasureRibbonButnStatu();
  791. m_SolutionWindows.Enabled = true;
  792. m_SPropertyWindows.Enabled = true;
  793. rbStart.Enabled = true;
  794. rbPause.Enabled = false;
  795. rbStop.Enabled = true;
  796. rbCheckParam.Enabled = false;
  797. }
  798. public bool SwitchMeasureSample(string sMsrSampleName)
  799. {
  800. if (!m_ProjParam.SetWorkSample(sMsrSampleName))
  801. {
  802. log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample) SetWorkSample(sMsrSampleName =" + sMsrSampleName + ") Failed !");
  803. return false;
  804. }
  805. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  806. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  807. {
  808. log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(), ref SMInfo) = false Failed !");
  809. return false;
  810. }
  811. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  812. m_SolutionWindows.SwitchSample(sMsrSampleName);
  813. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  814. return true;
  815. }
  816. #region 开始获取样品孔中的照片
  817. /// <summary>
  818. /// 开始获取样品孔中的照片
  819. /// </summary>
  820. /// <param name="doRunType"></param>
  821. /// <param name="HoleID"></param>
  822. /// <param name="c_DomainMessure"></param>
  823. public void StartSampleHoleBSEImage(int HoleID)
  824. {
  825. //设置获取样品孔中照片所需的参数
  826. m_MsrThreadWrapper.SetHoleImagePreview(HoleID);
  827. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  828. {
  829. m_MsrThreadWrapper.StartBGWorkThread();
  830. m_RibbonFun.SetMeasureRibbonButnStatu();
  831. }
  832. }
  833. #endregion
  834. private void rbRecover_Click(object sender, EventArgs e)
  835. {
  836. //关闭所有内容
  837. CloseAllContents();
  838. //显示样品属性窗口与树结构窗口
  839. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  840. m_SPropertyWindows.Show(dockPanel);
  841. //显示样品台窗口 测量状态与测量结果窗口
  842. m_SamplepaceWindow.Show(dockPanel);
  843. m_MessureStatuWindow.Show(dockPanel);
  844. m_MeasureRetWindow.Show(dockPanel);
  845. //此处将在父窗体选项卡上显示
  846. foreach (Form child in this.MdiChildren)
  847. {
  848. if (child.Name == "OTSSamplespaceWindow")
  849. {
  850. child.Activate();
  851. break;
  852. }
  853. }
  854. }
  855. private void CloseAllContents()
  856. {
  857. m_SolutionWindows.DockPanel = null;
  858. m_SPropertyWindows.DockPanel = null;
  859. m_SamplepaceWindow.DockPanel = null;
  860. m_MessureStatuWindow.DockPanel = null;
  861. m_MeasureRetWindow.DockPanel = null;
  862. CloseAllDocuments();
  863. }
  864. private void CloseAllDocuments()
  865. {
  866. if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
  867. {
  868. foreach (Form form in MdiChildren)
  869. form.Close();
  870. }
  871. else
  872. {
  873. IDockContent[] documents = dockPanel.DocumentsToArray();
  874. foreach (IDockContent content in documents)
  875. content.DockHandler.Close();
  876. }
  877. }
  878. private void rbMeasureCircle_Click(object sender, EventArgs e)
  879. {
  880. m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCUL);
  881. //修改工作样品的测量区域为圆形
  882. m_SamplepaceWindow.changeShape(ShapeType.CIRCUL);
  883. }
  884. private void rbMeasureRectangle_Click(object sender, EventArgs e)
  885. {
  886. m_ProjParam.SetMeasureAreaShape(ShapeType.RECTANGLE);
  887. //修改工作样品的测量区域为矩形
  888. m_SamplepaceWindow.changeShape(ShapeType.RECTANGLE);
  889. }
  890. //ctrl+s组合键进行保存
  891. private void OTSIncAMeasureAppForm_KeyDown(object sender, KeyEventArgs e)
  892. {
  893. if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
  894. {
  895. bool iRev = m_ProjData.Save();
  896. if (!iRev)
  897. {
  898. log.Error("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  899. return;
  900. }
  901. log.Error("(OTSIncAMeasureAppForm.rbSaveAs_Click) m_DataMgrFun.SaveFile() Success !");
  902. }
  903. }
  904. private void rbSTDEdit_Click_1(object sender, EventArgs e)
  905. {
  906. OpenFileDialog openFileDialog = new OpenFileDialog();
  907. openFileDialog.Filter = "(*.db)|*.db";
  908. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  909. openFileDialog.RestoreDirectory = true;
  910. openFileDialog.FilterIndex = 1;
  911. if (openFileDialog.ShowDialog() == DialogResult.OK)
  912. {
  913. try
  914. {
  915. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", openFileDialog.FileName);
  916. p.WaitForExit();
  917. }
  918. catch (Exception ex)
  919. {
  920. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  921. }
  922. }
  923. //reload the setup data just now
  924. foreach (var s in this.m_ProjData.GetSampleList())
  925. {
  926. var stdname= s.GetMsrParams().GetSTDName();
  927. if (stdname != "NoSTD")
  928. {
  929. if (!stdname.Contains(".db"))
  930. {
  931. stdname += ".db";
  932. }
  933. var m_classifyEngine = new COTSClassifyEngineClr(EngineType.ParticleClassifyEng, stdname);
  934. m_classifyEngine.ReloadEngineDB();
  935. }
  936. }
  937. }
  938. private void rbSysMgrApp_Click(object sender, EventArgs e)
  939. {
  940. try
  941. {
  942. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSSysMgrApp.exe");
  943. p.WaitForExit();
  944. }
  945. catch (Exception ex)
  946. {
  947. log.Error("OTSSysMgrApp:" + ex.ToString());
  948. }
  949. }
  950. private void ribPolygon_Click(object sender, EventArgs e)
  951. {
  952. //修改工作样品的测量区域为矩形
  953. m_SamplepaceWindow.DrawPolygonMeasure();
  954. }
  955. private void rbReClassify_Click(object sender, EventArgs e)
  956. {
  957. this.Cursor = Cursors.WaitCursor;
  958. if (m_ProjData.Reclassify())
  959. {
  960. m_ProjData.Save();
  961. MessageBox.Show("reclassification success");
  962. }
  963. else
  964. {
  965. MessageBox.Show("reclassification failed");
  966. }
  967. this.Cursor = Cursors.Default;
  968. }
  969. /// <summary>
  970. /// 打开测量项目文件
  971. /// </summary>
  972. private void OpenMeasureProjectFile()
  973. {
  974. bool bOpenFlag=false;
  975. COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
  976. string strPathName;
  977. // file open dialog
  978. OpenFileDialog openFileDialog = new OpenFileDialog();
  979. openFileDialog.Filter = "Probject Files (*.prj)|*.prj";
  980. if (openFileDialog.ShowDialog() != DialogResult.OK)
  981. {
  982. return ;
  983. }
  984. strPathName = openFileDialog.FileName;
  985. this.Cursor = Cursors.WaitCursor;
  986. if (ProjDataMgr.Load(strPathName))
  987. {
  988. m_ProjData = ProjDataMgr;
  989. m_ProjParam.SetResultData(m_ProjData);
  990. m_ProjParam.InitResultData();
  991. bOpenFlag = true;
  992. }
  993. this.Cursor = Cursors.Default;
  994. if (bOpenFlag)
  995. {
  996. if (!DisplayExistSampleFile())
  997. {
  998. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) OpenExistSampleFile() = false Failed !");
  999. return;
  1000. }
  1001. m_RibbonFun.SetAllRibbonButnStatus(true);
  1002. }
  1003. else
  1004. {
  1005. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) m_DataMgrFun.OpenExistSampleFile() Failed !");
  1006. }
  1007. }
  1008. private void OTSIncAMeasureAppForm_FormClosed(object sender, FormClosedEventArgs e)
  1009. {
  1010. }
  1011. private void rbAbout_Click(object sender, EventArgs e)
  1012. {
  1013. About m_about = new About();
  1014. m_about.ShowDialog();
  1015. }
  1016. protected override void DefWndProc(ref Message m)
  1017. {
  1018. switch (m.Msg)
  1019. {
  1020. case MsgID:
  1021. break;
  1022. case LogMsgID:
  1023. m_LogMsg = new PostLogMsg();
  1024. m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
  1025. var log = NLog.LogManager.GetCurrentClassLogger();
  1026. string s = GetString(m_LogMsg.logMessage);
  1027. switch (m_LogMsg.logLevel)
  1028. {
  1029. case 1:
  1030. log.Trace(s);
  1031. break;
  1032. case 2:
  1033. log.Debug(s);
  1034. break;
  1035. case 3:
  1036. log.Info(s);
  1037. break;
  1038. case 4:
  1039. log.Warn(s);
  1040. break;
  1041. case 5:
  1042. log.Error(s);
  1043. break;
  1044. case 6:
  1045. log.Fatal(s);
  1046. break;
  1047. }
  1048. break;
  1049. default:
  1050. base.DefWndProc(ref m);
  1051. break;
  1052. }
  1053. }
  1054. private string GetString(char[] csStr)
  1055. {
  1056. int ilen = csStr.Length;
  1057. string csName = new string(csStr); //MSTMsg.STMSampleStu.cSName
  1058. csName.IndexOf('\0');
  1059. csName = csName.Substring(0, csName.IndexOf('\0'));
  1060. return csName;
  1061. }
  1062. private void PrepareIpcServer()
  1063. {
  1064. //Instantiate our server channel.
  1065. IpcServerChannel channel = new IpcServerChannel("ServerChannel");
  1066. //Register the server channel.
  1067. ChannelServices.RegisterChannel(channel, false);
  1068. //Register this service type.
  1069. RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcSEMController), "RemoteObject", WellKnownObjectMode.Singleton);
  1070. }
  1071. private void rbConnectHardware_Click_1(object sender, EventArgs e)
  1072. {
  1073. if (!m_MsrThreadWrapper.IsSEMConnected())
  1074. {
  1075. if (!m_MsrThreadWrapper.ConnectSEM())
  1076. {
  1077. MessageBox.Show("Connect failed!");
  1078. return;
  1079. }
  1080. }
  1081. this.rbConnectHardware.Enabled = false;
  1082. this.rbDisconnectHardware.Enabled = true;
  1083. log.Warn("SEM connect success!");
  1084. }
  1085. private void rbDisconnectHardware_Click_1(object sender, EventArgs e)
  1086. {
  1087. if (m_MsrThreadWrapper.IsSEMConnected())
  1088. {
  1089. m_MsrThreadWrapper.DisconnectSEM();
  1090. }
  1091. this.rbDisconnectHardware.Enabled = false;
  1092. this.rbConnectHardware.Enabled = true;
  1093. log.Warn("SEM Disconnect!");
  1094. }
  1095. private void rbinterrupt_Click(object sender, EventArgs e)
  1096. {
  1097. if (m_MsrThreadWrapper.IsSEMConnected())
  1098. {
  1099. m_MsrThreadWrapper.StopXrayAcquisition();
  1100. }
  1101. log.Warn("StopXrayAcquisition!");
  1102. }
  1103. private void rbAutoBeamOff_Click(object sender, EventArgs e)
  1104. {
  1105. if (m_ProjData.GetGenParam().AutoBeamOff)
  1106. {
  1107. m_ProjData.GetGenParam().AutoBeamOff = false;
  1108. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1109. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1110. }
  1111. else
  1112. {
  1113. m_ProjData.GetGenParam().AutoBeamOff = true;
  1114. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1115. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1116. }
  1117. }
  1118. }
  1119. }