OTSIncAMeasureAppForm.cs 49 KB

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