OTSIncAMeasureAppForm.cs 47 KB

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