OTSIncAMeasureAppForm.cs 47 KB

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