OTSIncAMeasureAppForm.cs 48 KB

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