OTSIncAMeasureAppForm.cs 49 KB

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