OTSIncAMeasureAppForm.cs 49 KB

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