OTSIncAMeasureAppForm.cs 51 KB

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