OTSIncAMeasureAppForm.cs 48 KB

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