Extender.cs 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  1. using OINA.Extender;
  2. using OINA.Extender.Acquisition;
  3. using OINA.Extender.Acquisition.Ed;
  4. using OINA.Extender.Acquisition.Image;
  5. using OINA.Extender.Data;
  6. using OINA.Extender.Data.Ed;
  7. using OINA.Extender.Data.Image;
  8. using OINA.Extender.MicroscopeControl;
  9. using OINA.Extender.Processing;
  10. using OINA.Extender.Processing.Ed;
  11. using OINA.Extender.Processing.Quant;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Drawing;
  15. using System.Drawing.Imaging;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading;
  20. //显示弹出信息
  21. using System.Windows.Forms;
  22. namespace Extender
  23. {
  24. enum OxfordControllerState
  25. {
  26. READY = 0,
  27. WORKING = 1,
  28. SUCCEEDED = 2,
  29. FAILED = 3,
  30. ABORT = 4
  31. };
  32. /// <summary>
  33. /// Enum EDSConst definition.
  34. /// </summary>
  35. enum EDSConst
  36. {
  37. MAX_XRAY_BATCH = 1024,
  38. XANA_CHANNELS = 2000,
  39. XANA_CHANNELS_MAX = 4192,
  40. MAX_AMPTIME_CONSTANTS = 10,
  41. MAX_EV_PER_CHANNELS = 5,
  42. MAX_ANALYZERS = 5,
  43. MAX_LEN_ANALYZER_NAME = 16
  44. };
  45. struct OxfordChord
  46. {
  47. public long m_nX;
  48. public long m_nY;
  49. public long m_nLength;
  50. };
  51. enum OxfordCommand
  52. {
  53. //缩放
  54. GetMagnification = 0,
  55. SetMagnification = 1,
  56. //焦距
  57. GetWorkingDistance = 2,
  58. SetWorkingDistance = 3,
  59. //亮度
  60. GetBrightness = 4,
  61. SetBrightness = 5,
  62. //对比度
  63. GetContrast = 6,
  64. SetContrast = 7,
  65. //SEM电压
  66. GetSEMVoltage = 8,
  67. SetSEMVoltage = 9,
  68. //样品台
  69. GetStagePosition = 10,
  70. SetStagePosition = 11,
  71. GetStageAtX = 12,
  72. GetStageAtY = 13,
  73. GetStageAtZ = 14,
  74. GetStageAtT = 15,
  75. GetStageAtR = 16,
  76. SetStageGotoX = 17,
  77. SetStageGotoY = 18,
  78. SetStageGotoZ = 19,
  79. SetStageGotoT = 20,
  80. SetStageGotoR = 21,
  81. MoveStageXY = 22,
  82. //拍图
  83. GrabImage = 23,
  84. //采集参数设置
  85. SetImageAcquistionSetting = 24,
  86. //获取分辨率
  87. GetImageStore = 25,
  88. //设置分辨率
  89. SetImageStore = 26,
  90. //获取bitmap
  91. GetBitmap = 27,
  92. IsAcquiringSpectrum = 28,
  93. //X-ray
  94. //点采集
  95. XrayPointCollectiong = 29,
  96. //面采集
  97. XrayAreaCollectiong = 30,
  98. BeginMultipleAquisition=31,
  99. EndMultipleAquisition=32,
  100. Exit=100,
  101. }
  102. public struct GrabImageParam
  103. {
  104. public GrabImageParam(string filename, short xoff, short yoff, short width, short height, short type)
  105. {
  106. this.filename = filename;
  107. this.xoff = xoff;
  108. this.yoff = yoff;
  109. this.width = width;
  110. this.height = height;
  111. this.type = type;
  112. }
  113. public string filename;
  114. public short xoff;
  115. public short yoff;
  116. public short width;
  117. public short height;
  118. public short type;
  119. }
  120. public class PointXrayParam
  121. {
  122. public PointXrayParam()
  123. {
  124. this.XrayData = new long[2000];
  125. this.listElement=new Dictionary<string, double> ();
  126. }
  127. public double dMilliSecondsTime;
  128. public double x;
  129. public double y;
  130. public long[] XrayData ;
  131. public Dictionary<string, double> listElement;
  132. }
  133. public struct AreaXrayParam
  134. {
  135. public double dMilliSecondsTime;
  136. public List<Segment> a_listChord;
  137. public long[] XrayData;
  138. public Dictionary<string, double> a_listElement;
  139. }
  140. public struct MoveStageParam
  141. {
  142. public float x;
  143. public float y;
  144. }
  145. public class ExtenderWrapper : IExtenderControl
  146. {
  147. struct oxfordCommandData
  148. {
  149. public OxfordCommand commandType;
  150. public bool returnType;
  151. public MoveStageParam moveStagePrm;
  152. public GrabImageParam grabImgParam;
  153. public PointXrayParam pointXrayPrm;
  154. public AreaXrayParam areaXrayPrm;
  155. }
  156. private Thread controlThread;
  157. private oxfordCommandData currentCommand;
  158. private Extender myExtender=null;
  159. AutoResetEvent startEvent= new AutoResetEvent(false);
  160. AutoResetEvent endEvent = new AutoResetEvent(false);
  161. private NLog.Logger log;
  162. public ExtenderWrapper()
  163. {
  164. if (myExtender == null)
  165. {
  166. myExtender = new Extender();
  167. }
  168. log = NLog.LogManager.GetCurrentClassLogger();
  169. controlThread = new Thread(this.ControlerThread);
  170. //controlThread.IsBackground = true;
  171. controlThread.Start();
  172. //Thread.Sleep(100);//wait untill the new thread has been started
  173. }
  174. public void CloseExtender()
  175. {
  176. if (myExtender != null)
  177. {
  178. myExtender.CloseExtender();
  179. currentCommand.commandType = OxfordCommand.Exit;
  180. startEvent.Set();
  181. controlThread.Join();
  182. }
  183. }
  184. ~ExtenderWrapper()
  185. {
  186. this.CloseExtender();
  187. }
  188. private void ControlerThread()
  189. {
  190. log.Info("myExtender has been initialized");
  191. while (true)
  192. {
  193. while (true)
  194. {
  195. if (startEvent.WaitOne(0, true))
  196. {
  197. break;
  198. }
  199. Thread.Sleep(50);
  200. Application.DoEvents();
  201. }
  202. switch (currentCommand.commandType)
  203. {
  204. case OxfordCommand.MoveStageXY:
  205. {
  206. MoveStageParam p = currentCommand.moveStagePrm;
  207. if (myExtender.MoveStageXY(p.x, p.y))
  208. {
  209. currentCommand.returnType = true;
  210. }
  211. else
  212. {
  213. currentCommand.returnType = false;
  214. }
  215. endEvent.Set();
  216. }
  217. break;
  218. case OxfordCommand.GrabImage:
  219. {
  220. GrabImageParam p = currentCommand.grabImgParam;
  221. log.Info("begin:GrabImage:oxford thread 线程ID:" + Thread.CurrentThread.ManagedThreadId.ToString() );
  222. if (myExtender.GrabImage(p.filename, p.xoff, p.yoff, p.width, p.height, p.type))
  223. {
  224. currentCommand.returnType = true;
  225. log.Info("GrabImage:oxford thread return: " + currentCommand.returnType.ToString());
  226. }
  227. else
  228. {
  229. currentCommand.returnType = false;
  230. log.Info("GrabImage:oxford thread return: " + currentCommand.returnType.ToString());
  231. }
  232. endEvent.Set();
  233. }
  234. break;
  235. case OxfordCommand.XrayPointCollectiong:
  236. {
  237. PointXrayParam p = currentCommand.pointXrayPrm;
  238. log.Info("线程:开始采集单点xray");
  239. if (myExtender.XrayPointCollecting(p.dMilliSecondsTime, p.x, p.y, out p.XrayData,out p.listElement))
  240. {
  241. currentCommand.pointXrayPrm = p;
  242. currentCommand.returnType = true;
  243. }
  244. else
  245. {
  246. log.Error("线程:采集单点xray失败");
  247. currentCommand.returnType = false;
  248. }
  249. endEvent.Set();
  250. }
  251. break;
  252. case OxfordCommand.XrayAreaCollectiong:
  253. {
  254. AreaXrayParam p = currentCommand.areaXrayPrm;
  255. log.Info("线程:开始线扫xray");
  256. if (myExtender.XrayAreaCollectiong( p.dMilliSecondsTime, p.a_listChord,out p.XrayData, out p.a_listElement))
  257. {
  258. currentCommand.areaXrayPrm = p;
  259. currentCommand.returnType = true;
  260. }
  261. else
  262. {
  263. log.Error("线程:失败线扫xray");
  264. currentCommand.returnType = false;
  265. }
  266. endEvent.Set();
  267. }
  268. break;
  269. case OxfordCommand.BeginMultipleAquisition:
  270. {
  271. myExtender.BeginMultipleAquisition();
  272. endEvent.Set();
  273. }
  274. break;
  275. case OxfordCommand.EndMultipleAquisition:
  276. {
  277. myExtender.EndMultipleAquisition();
  278. endEvent.Set();
  279. }
  280. break;
  281. case OxfordCommand.Exit:
  282. {
  283. endEvent.Set();
  284. log.Info("receive exit command");
  285. }
  286. break;
  287. }
  288. if (currentCommand.commandType == OxfordCommand.Exit)
  289. {
  290. log.Info("exiting the thread");
  291. break;
  292. }
  293. }
  294. }
  295. public Bitmap GetBitmap()
  296. {
  297. return myExtender.GetBitmap();
  298. }
  299. public float GetBrightness()
  300. {
  301. return myExtender.GetBrightness();
  302. }
  303. public float GetContrast()
  304. {
  305. return myExtender.GetContrast();
  306. }
  307. public int[] GetImageStore()
  308. {
  309. return myExtender.GetImageStore();
  310. }
  311. public float GetMagnification()
  312. {
  313. return myExtender.GetMagnification();
  314. }
  315. public float GetSEMVoltage()
  316. {
  317. return myExtender.GetSEMVoltage();
  318. }
  319. public float GetStageAtR()
  320. {
  321. return myExtender.GetStageAtR();
  322. }
  323. public float GetStageAtT()
  324. {
  325. return myExtender.GetStageAtT();
  326. }
  327. public float GetStageAtX()
  328. {
  329. return myExtender.GetStageAtX();
  330. }
  331. public float GetStageAtY()
  332. {
  333. return myExtender.GetStageAtY();
  334. }
  335. public float GetStageAtZ()
  336. {
  337. return myExtender.GetStageAtZ();
  338. }
  339. public float[] GetStagePosition()
  340. {
  341. return myExtender.GetStagePosition();
  342. }
  343. public float GetWorkingDistance()
  344. {
  345. return myExtender.GetWorkingDistance();
  346. }
  347. public bool GrabImage(string filename, short xoff, short yoff, short width, short height, short type)
  348. {
  349. currentCommand.grabImgParam =new GrabImageParam(filename, xoff, yoff, width, height, type);
  350. currentCommand.commandType = OxfordCommand.GrabImage;
  351. startEvent.Set();
  352. while (true)
  353. {
  354. if (endEvent.WaitOne(0, false))
  355. {
  356. break;
  357. }
  358. Thread.Sleep(100);
  359. Application.DoEvents();
  360. }
  361. log.Info("GrabImage:oxford thread return: " + currentCommand.returnType.ToString());
  362. if (currentCommand.returnType == true)
  363. {
  364. return true;
  365. }
  366. else
  367. {
  368. return false;
  369. }
  370. }
  371. public bool IsAcquiringSpectrum()
  372. {
  373. return myExtender.IsAcquiringSpectrum();
  374. }
  375. public bool MoveStageXY(float x, float y)
  376. {
  377. currentCommand.moveStagePrm = new MoveStageParam();
  378. currentCommand.moveStagePrm.x = x;
  379. currentCommand.moveStagePrm.y = y;
  380. currentCommand.commandType = OxfordCommand.MoveStageXY;
  381. startEvent.Set();
  382. while (true)
  383. {
  384. if (endEvent.WaitOne(0, false))
  385. {
  386. break;
  387. }
  388. }
  389. if (currentCommand.returnType == true)
  390. {
  391. return true;
  392. }
  393. else
  394. {
  395. return false;
  396. }
  397. }
  398. public bool SetBrightness(float set)
  399. {
  400. return myExtender.SetBrightness(set);
  401. }
  402. public bool SetContrast(float set)
  403. {
  404. return myExtender.SetContrast(set);
  405. }
  406. public bool SetImageAcquistionSetting(double a_dDwellTime, int a_nImageType, double a_dImageScanSize)
  407. {
  408. return myExtender.SetImageAcquistionSetting(a_dDwellTime, a_nImageType, a_dImageScanSize);
  409. }
  410. public bool SetImageStore(float set)
  411. {
  412. return myExtender.SetImageStore(set);
  413. }
  414. public bool SetMagnification(float set)
  415. {
  416. return myExtender.SetMagnification(set);
  417. }
  418. public bool SetSEMVoltage(float set)
  419. {
  420. return myExtender.SetSEMVoltage(set);
  421. }
  422. public bool SetStageGotoR(float set)
  423. {
  424. return myExtender.SetStageGotoR(set);
  425. }
  426. public bool SetStageGotoT(float set)
  427. {
  428. return myExtender.SetStageGotoT(set);
  429. }
  430. public bool SetStageGotoX(float set)
  431. {
  432. return myExtender.SetStageGotoX(set);
  433. }
  434. public bool SetStageGotoY(float set)
  435. {
  436. return myExtender.SetStageGotoY(set);
  437. }
  438. public bool SetStageGotoZ(float set)
  439. {
  440. return myExtender.SetStageGotoZ(set);
  441. }
  442. public bool SetStagePosition(float[] set)
  443. {
  444. return myExtender.SetStagePosition(set);
  445. }
  446. public bool SetWorkingDistance(float set)
  447. {
  448. return myExtender.SetWorkingDistance(set);
  449. }
  450. public bool XrayAreaCollectiong( double dMilliSecondsTime, List<Segment> a_listChord, out long[] XrayData, out Dictionary<string, double> a_listElement)
  451. {
  452. var p = new AreaXrayParam();
  453. p = currentCommand.areaXrayPrm;
  454. p.dMilliSecondsTime = dMilliSecondsTime;
  455. p.a_listChord = a_listChord;
  456. currentCommand.areaXrayPrm = p;
  457. currentCommand.commandType = OxfordCommand.XrayAreaCollectiong;
  458. startEvent.Set();
  459. while (true)
  460. {
  461. if (endEvent.WaitOne(0, false))
  462. {
  463. break;
  464. }
  465. }
  466. if (currentCommand.returnType == true)
  467. {
  468. XrayData= currentCommand.areaXrayPrm.XrayData ;
  469. a_listElement= currentCommand.areaXrayPrm.a_listElement ;
  470. return true;
  471. }
  472. else
  473. {
  474. XrayData = p.XrayData;
  475. a_listElement = p.a_listElement;
  476. return false;
  477. }
  478. }
  479. public bool XrayPointCollecting(double dMilliSecondsTime, double x, double y, out long[] XrayData, out Dictionary<string, double> a_listElement)
  480. {
  481. var p = new PointXrayParam();
  482. p.dMilliSecondsTime = dMilliSecondsTime;
  483. p.x = x;
  484. p.y = y;
  485. currentCommand.pointXrayPrm = p;
  486. currentCommand.commandType = OxfordCommand.XrayPointCollectiong;
  487. startEvent.Set();
  488. while (true)
  489. {
  490. if (endEvent.WaitOne(0, false))
  491. {
  492. break;
  493. }
  494. Application.DoEvents();
  495. }
  496. if (currentCommand.returnType == true)
  497. {
  498. XrayData= currentCommand.pointXrayPrm.XrayData ;
  499. a_listElement= currentCommand.pointXrayPrm.listElement ;
  500. return true;
  501. }
  502. else
  503. {
  504. XrayData = p.XrayData;
  505. a_listElement = p.listElement;
  506. return false;
  507. }
  508. }
  509. public void BeginMultipleAquisition()
  510. {
  511. currentCommand.commandType = OxfordCommand.BeginMultipleAquisition;
  512. startEvent.Set();
  513. while (true)
  514. {
  515. if (endEvent.WaitOne(0, false))
  516. {
  517. break;
  518. }
  519. Application.DoEvents();
  520. }
  521. }
  522. public void EndMultipleAquisition()
  523. {
  524. currentCommand.commandType = OxfordCommand.EndMultipleAquisition;
  525. startEvent.Set();
  526. while (true)
  527. {
  528. if (endEvent.WaitOne(0, false))
  529. {
  530. break;
  531. }
  532. Application.DoEvents();
  533. }
  534. }
  535. }
  536. public class Extender : IExtenderControl
  537. {
  538. //构造函数
  539. public Extender()
  540. {
  541. InitMicroscopeController();
  542. InitImageAcquisition();
  543. InitXrayAcquistion();
  544. }
  545. //结束
  546. public void CloseExtender()
  547. {
  548. CloseMicroscopeController();
  549. CloseImageAcquisition();
  550. CloaseXrayAcquistion();
  551. }
  552. #region 电镜控制、样品台
  553. //控制电镜
  554. private IMicroscopeController microscopeController = null;
  555. //电压
  556. private double m_dHighVoltage;
  557. //放大倍数
  558. private double m_dMagnification;
  559. //工作距离
  560. private double m_dWorkingDistance;
  561. //亮度
  562. private double m_dBirghtness;
  563. //对比度
  564. private double m_dContrast;
  565. //BeamOn
  566. private bool m_bBeamOn;
  567. //FilamentOn
  568. private bool m_bFilamentOn;
  569. //样品台位置
  570. private double m_dStageX;
  571. private double m_dStageY;
  572. private double m_dStageZ;
  573. private double m_dStageR;
  574. private double m_dStageT;
  575. private double m_dStageXMax;
  576. public double StageXMax
  577. {
  578. get { return this.m_dStageXMax; }
  579. set { this.m_dStageXMax = value; }
  580. }
  581. private double m_dStageXMin;
  582. public double StageXMin
  583. {
  584. get { return this.m_dStageXMin; }
  585. set { this.m_dStageXMin = value; }
  586. }
  587. private double m_dStageYMax;
  588. public double StageYMax
  589. {
  590. get { return this.m_dStageYMax; }
  591. set { this.m_dStageYMax = value; }
  592. }
  593. private double m_dStageYMin;
  594. public double StageYMin
  595. {
  596. get { return this.m_dStageYMin; }
  597. set { this.m_dStageYMin = value; }
  598. }
  599. private double m_dStageZMax;
  600. public double StageZMax
  601. {
  602. get { return this.m_dStageZMax; }
  603. set { this.m_dStageZMax = value; }
  604. }
  605. private double m_dStageZMin;
  606. public double StageZMin
  607. {
  608. get { return this.m_dStageZMin; }
  609. set { this.m_dStageZMin = value; }
  610. }
  611. private double m_dStageTMax;
  612. public double StageTMax
  613. {
  614. get { return this.m_dStageTMax; }
  615. set { this.m_dStageTMax = value; }
  616. }
  617. private double m_dStageTMin;
  618. public double StageTMin
  619. {
  620. get { return this.m_dStageTMin; }
  621. set { this.m_dStageTMin = value; }
  622. }
  623. private double m_dStageRMax;
  624. public double StageRMax
  625. {
  626. get { return this.m_dStageRMax; }
  627. set { this.m_dStageRMax = value; }
  628. }
  629. private double m_dStageRMin;
  630. public double StageRMin
  631. {
  632. get { return this.m_dStageRMin; }
  633. set { this.m_dStageRMin = value; }
  634. }
  635. //控制电镜初始化
  636. void InitMicroscopeController(float a_fStageXMin = 0, float a_fStageXMax = 130,
  637. float a_fStageYMin = 0, float a_fStageYMax = 130,
  638. float a_fStageZMin = 0, float a_fStageZMax = 40,
  639. float a_fStageTMin = 0, float a_fStageTMax = 90,
  640. float a_fStageRMin = 0, float a_fStageRMax = 360)
  641. {
  642. this.microscopeController = AcquireFactory.CreateMicroscopeControl();
  643. this.microscopeController.ColumnChange += this.OnMicroscopeColumnChange;
  644. this.microscopeController.StageChange += this.OnMicroscopeStageChange;
  645. this.microscopeController.ColumnConnected += this.OnMicroscopeColumnConnected;
  646. this.microscopeController.StageConnected += this.OnMicroscopeStageConnected;
  647. this.microscopeController.ChangeCompleted += this.OnMicroscopeChangeCompleted;
  648. ReadMicroscopeColumn();
  649. ReadStage();
  650. StageXMax = a_fStageXMax;
  651. StageXMin = a_fStageXMin;
  652. StageYMax = a_fStageYMax;
  653. StageYMin = a_fStageYMin;
  654. StageZMax = a_fStageZMax;
  655. StageZMin = a_fStageZMin;
  656. StageTMax = a_fStageTMax;
  657. StageTMin = a_fStageTMin;
  658. StageRMax = a_fStageRMax;
  659. StageRMin = a_fStageRMin;
  660. }
  661. //控制电镜释放
  662. void CloseMicroscopeController()
  663. {
  664. this.microscopeController.ColumnChange -= this.OnMicroscopeColumnChange;
  665. this.microscopeController.StageChange -= this.OnMicroscopeStageChange;
  666. this.microscopeController.ColumnConnected -= this.OnMicroscopeColumnConnected;
  667. this.microscopeController.StageConnected -= this.OnMicroscopeStageConnected;
  668. this.microscopeController.ChangeCompleted -= this.OnMicroscopeChangeCompleted;
  669. }
  670. //读取当前的电镜控制值
  671. private void ReadMicroscopeColumn()
  672. {
  673. var columnCapabilities = this.microscopeController.ColumnCapabilities;
  674. var columnConditions = this.microscopeController.ColumnConditions;
  675. if (columnCapabilities.Magnification.CanRead)
  676. {
  677. m_dMagnification = columnConditions.Magnification;
  678. }
  679. if (columnCapabilities.WorkingDistance.CanRead)
  680. {
  681. m_dWorkingDistance = columnConditions.WorkingDistance;
  682. }
  683. if (columnCapabilities.HighVoltage.CanRead)
  684. {
  685. m_dHighVoltage = columnConditions.HighVoltage;
  686. }
  687. if (columnCapabilities.Brightness.CanRead)
  688. {
  689. m_dBirghtness = columnConditions.Brightness;
  690. }
  691. if (columnCapabilities.Contrast.CanRead)
  692. {
  693. m_dContrast = columnConditions.Contrast;
  694. }
  695. if (columnCapabilities.BeamOn.CanRead)
  696. {
  697. m_bBeamOn = Convert.ToBoolean(columnConditions.BeamOn);
  698. }
  699. if (columnCapabilities.FilamentOn.CanRead)
  700. {
  701. m_bFilamentOn = Convert.ToBoolean(columnConditions.FilamentOn);
  702. }
  703. }
  704. //读取样品台位置
  705. private void ReadStage()
  706. {
  707. var stageCapabilities = this.microscopeController.StageCapabilities;
  708. var stageConditions = this.microscopeController.StageConditions;
  709. if (stageCapabilities.StageX.CanRead)
  710. {
  711. this.m_dStageX = stageConditions.StageX;
  712. }
  713. if (stageCapabilities.StageY.CanRead)
  714. {
  715. this.m_dStageY = stageConditions.StageY;
  716. }
  717. if (stageCapabilities.StageZ.CanRead)
  718. {
  719. this.m_dStageZ = stageConditions.StageZ;
  720. }
  721. if (stageCapabilities.StageT.CanRead)
  722. {
  723. this.m_dStageT = stageConditions.StageT;
  724. }
  725. if (stageCapabilities.StageR.CanRead)
  726. {
  727. this.m_dStageR = stageConditions.StageR;
  728. }
  729. }
  730. //电镜控制改变事件
  731. private void OnMicroscopeColumnChange(object sender, EventArgs e)
  732. {
  733. //MessageBox.Show("电镜控制改变ColumnChange");
  734. ReadMicroscopeColumn();
  735. }
  736. //样品台控制改变事件
  737. private void OnMicroscopeStageChange(object sender, EventArgs e)
  738. {
  739. //MessageBox.Show("样品控制改变StageChange");
  740. ReadStage();
  741. }
  742. //列控制连接或断开时的事件
  743. private void OnMicroscopeColumnConnected(object sender, EventArgs e)
  744. {
  745. //MessageBox.Show("电镜控制连接ColumnConnected");
  746. }
  747. //样品台控制连接或断开时的事件
  748. private void OnMicroscopeStageConnected(object sender, EventArgs e)
  749. {
  750. //MessageBox.Show("样品台连接StageConnected");
  751. ReadStage();
  752. }
  753. //样品台控制、电镜控制、外围控制的事件改变完成
  754. private void OnMicroscopeChangeCompleted(object sender, EventArgs e)
  755. {
  756. //MessageBox.Show("电镜控制完成ChangeCompleted");
  757. ReadMicroscopeColumn();
  758. ReadStage();
  759. }
  760. //电镜控制
  761. //电压
  762. //放大倍数
  763. //工作距离
  764. //亮度
  765. //对比度
  766. //BeamOn
  767. //FilamentOn
  768. //缩放
  769. public float GetMagnification()
  770. {
  771. return (float)m_dMagnification;
  772. }
  773. public Boolean SetMagnification(float set)
  774. {
  775. Dictionary<Column, double> columnDictionary = new Dictionary<Column, double>
  776. {
  777. { Column.Magnification, (double)set }
  778. };
  779. this.microscopeController.SetColumnConditions(columnDictionary);
  780. return true;
  781. }
  782. //焦距
  783. public float GetWorkingDistance()
  784. {
  785. return (float)m_dWorkingDistance;
  786. }
  787. public Boolean SetWorkingDistance(float set)
  788. {
  789. Dictionary<Column, double> columnDictionary = new Dictionary<Column, double>
  790. {
  791. { Column.WorkingDistance, (double)set }
  792. };
  793. this.microscopeController.SetColumnConditions(columnDictionary);
  794. return true;
  795. }
  796. //亮度
  797. public float GetBrightness()
  798. {
  799. return (float)m_dBirghtness;
  800. }
  801. public Boolean SetBrightness(float set)
  802. {
  803. Dictionary<Column, double> columnDictionary = new Dictionary<Column, double>
  804. {
  805. { Column.Brightness, (double)set }
  806. };
  807. this.microscopeController.SetColumnConditions(columnDictionary);
  808. return true;
  809. }
  810. //对比度
  811. public float GetContrast()
  812. {
  813. return (float)m_dContrast;
  814. }
  815. public Boolean SetContrast(float set)
  816. {
  817. Dictionary<Column, double> columnDictionary = new Dictionary<Column, double>
  818. {
  819. { Column.Contrast, (double)set }
  820. };
  821. this.microscopeController.SetColumnConditions(columnDictionary);
  822. return true;
  823. }
  824. //SEM电压
  825. public float GetSEMVoltage()
  826. {
  827. return (float)m_dHighVoltage;
  828. }
  829. public Boolean SetSEMVoltage(float set)
  830. {
  831. Dictionary<Column, double> columnDictionary = new Dictionary<Column, double>
  832. {
  833. { Column.HighVoltage, (double)set }
  834. };
  835. this.microscopeController.SetColumnConditions(columnDictionary);
  836. return true;
  837. }
  838. //样品台
  839. public float[] GetStagePosition()
  840. {
  841. float[] ret = new float[5];
  842. ret[0] = (float)m_dStageX;
  843. ret[1] = (float)m_dStageY;
  844. ret[2] = (float)m_dStageZ;
  845. ret[3] = (float)m_dStageT;
  846. ret[4] = (float)m_dStageR;
  847. return ret;
  848. }
  849. public Boolean SetStagePosition(float[] set)
  850. {
  851. double stageX = (double)set[0];
  852. if (stageX > StageXMax || stageX < StageXMin)
  853. {
  854. return false;
  855. }
  856. double stageY = (double)set[1];
  857. if (stageY > StageYMax || stageY < StageYMin)
  858. {
  859. return false;
  860. }
  861. double stageZ = (double)set[2];
  862. if (stageZ > StageZMax || stageZ < StageZMin)
  863. {
  864. return false;
  865. }
  866. double stageT = (double)set[3];
  867. if (stageT > StageTMax || stageT < StageTMin)
  868. {
  869. return false;
  870. }
  871. double stageR = (double)set[4];
  872. if (stageR > StageRMax || stageR < StageRMin)
  873. {
  874. return false;
  875. }
  876. var stageDictionary = new Dictionary<Stage, double>
  877. {
  878. { Stage.StageX, (double)stageX },
  879. { Stage.StageY, (double)stageY },
  880. { Stage.StageZ, (double)stageZ },
  881. { Stage.StageT, (double)stageT },
  882. { Stage.StageR, (double)stageR }
  883. };
  884. this.microscopeController.SetStageConditions(stageDictionary);
  885. return true;
  886. }
  887. public float GetStageAtX()
  888. {
  889. return (float)m_dStageX;
  890. }
  891. public float GetStageAtY()
  892. {
  893. return (float)m_dStageY;
  894. }
  895. public float GetStageAtZ()
  896. {
  897. return (float)m_dStageZ;
  898. }
  899. public float GetStageAtT()
  900. {
  901. return (float)m_dStageT;
  902. }
  903. public float GetStageAtR()
  904. {
  905. return (float)m_dStageR;
  906. }
  907. public Boolean SetStageGotoX(float set)
  908. {
  909. double stageX = (double)set;
  910. if (stageX > StageXMax || stageX < StageXMin)
  911. {
  912. return false;
  913. }
  914. var stageDictionary = new Dictionary<Stage, double>
  915. {
  916. { Stage.StageX, (double)stageX }
  917. };
  918. this.microscopeController.SetStageConditions(stageDictionary);
  919. return true;
  920. }
  921. public Boolean SetStageGotoY(float set)
  922. {
  923. double stageY = (double)set;
  924. if (stageY > StageYMax || stageY < StageYMin)
  925. {
  926. return false;
  927. }
  928. var stageDictionary = new Dictionary<Stage, double>
  929. {
  930. { Stage.StageY, (double)stageY }
  931. };
  932. this.microscopeController.SetStageConditions(stageDictionary);
  933. return true;
  934. }
  935. public Boolean SetStageGotoZ(float set)
  936. {
  937. double stageZ = (double)set;
  938. if (stageZ > StageZMax || stageZ < StageZMin)
  939. {
  940. return false;
  941. }
  942. var stageDictionary = new Dictionary<Stage, double>
  943. {
  944. { Stage.StageZ, (double)stageZ }
  945. };
  946. this.microscopeController.SetStageConditions(stageDictionary);
  947. return true;
  948. }
  949. public Boolean SetStageGotoT(float set)
  950. {
  951. double stageT = (double)set;
  952. if (stageT > StageTMax || stageT < StageTMin)
  953. {
  954. return false;
  955. }
  956. var stageDictionary = new Dictionary<Stage, double>
  957. {
  958. { Stage.StageT, (double)stageT }
  959. };
  960. this.microscopeController.SetStageConditions(stageDictionary);
  961. return true;
  962. }
  963. public Boolean SetStageGotoR(float set)
  964. {
  965. double stageR = (double)set;
  966. if (stageR > StageRMax || stageR < StageRMin)
  967. {
  968. return false;
  969. }
  970. var stageDictionary = new Dictionary<Stage, double>
  971. {
  972. { Stage.StageR, (double)stageR }
  973. };
  974. this.microscopeController.SetStageConditions(stageDictionary);
  975. return true;
  976. }
  977. public Boolean MoveStageXY(float x, float y)
  978. {
  979. double stageX = (double)x;
  980. if (stageX > StageXMax || stageX < StageXMin)
  981. {
  982. return false;
  983. }
  984. double stageY = (double)y;
  985. if (stageY > StageYMax || stageY < StageYMin)
  986. {
  987. return false;
  988. }
  989. var stageDictionary = new Dictionary<Stage, double>
  990. {
  991. { Stage.StageX, (double)stageX },
  992. { Stage.StageY, (double)stageY }
  993. };
  994. this.microscopeController.SetStageConditions(stageDictionary);
  995. return true;
  996. }
  997. #endregion
  998. #region 拍图
  999. /// <summary>
  1000. /// IImageAcquisitionController object
  1001. /// </summary>
  1002. private IImageAcquisitionController imageAcquisitionController = null;
  1003. /// <summary>
  1004. /// IImageSettings object
  1005. /// </summary>
  1006. private IImageAcquisitionSettings imageAcquisitionSettings = null;
  1007. //图像扫描尺寸
  1008. public double[] ImageScanSize =
  1009. {
  1010. 32,
  1011. 64,
  1012. 128,
  1013. 256,
  1014. 512,
  1015. 1024,
  1016. 4096,
  1017. 8192
  1018. };
  1019. private byte[] m_ImageBit = null;
  1020. private long m_nImageWidth = 0;
  1021. private long m_nImageHeight = 0;
  1022. private double m_dImagePixelsize = 0;//it will be initialized when we get an image from the EDS.
  1023. bool m_bAcquistionDone = false;
  1024. private Bitmap m_Bitmap = null;
  1025. void InitImageAcquisition()
  1026. {
  1027. imageAcquisitionController = AcquireFactory.CreateImageServer();
  1028. imageAcquisitionSettings = AcquireFactory.CreateImageSettings();
  1029. //imageAcquisitionSettings.
  1030. imageAcquisitionController.ExperimentStarted += this.OnImageExperimentStarted;
  1031. imageAcquisitionController.ExperimentFinished += this.OnImageExperimentFinished;
  1032. }
  1033. //控制电镜释放
  1034. void CloseImageAcquisition()
  1035. {
  1036. imageAcquisitionController.ExperimentStarted -= this.OnImageExperimentStarted;
  1037. imageAcquisitionController.ExperimentFinished -= this.OnImageExperimentFinished;
  1038. }
  1039. /// <summary>
  1040. /// OnImageExperimentStarted
  1041. /// </summary>
  1042. private void OnImageExperimentStarted(object sender, AcquisitionStartedEventArgs<IElectronImage[]> e)
  1043. {
  1044. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  1045. log.Info("拍图开始事件!");
  1046. }
  1047. //int m_nState;
  1048. /// <summary>
  1049. /// OnImageExperimentFinished
  1050. /// </summary>
  1051. private void OnImageExperimentFinished(object sender, AcquisitionFinishedEventArgs<IElectronImage[]> e)
  1052. {
  1053. IElectronImage electronImage = e.Value[0];
  1054. if (!ReadImageData(electronImage, out m_ImageBit, out m_nImageWidth, out m_nImageHeight,out m_dImagePixelsize))
  1055. {
  1056. MessageBox.Show("图像采集完成,获取图像像素失败!");
  1057. }
  1058. if (m_ImageBit != null && m_ImageBit.Length == m_nImageWidth * m_nImageHeight)
  1059. {
  1060. m_bAcquistionDone = true;
  1061. }
  1062. }
  1063. bool ReadImageData(IElectronImage a_electronImage, out Byte[] a_pImageBits, out long a_nImageHeight, out long a_nImageWidth,out double a_nPixelSize)
  1064. {
  1065. a_nImageHeight = 0;
  1066. a_nImageWidth = 0;
  1067. a_nPixelSize = 0;
  1068. a_pImageBits = null;
  1069. if (a_electronImage == null)
  1070. {
  1071. return false;
  1072. }
  1073. a_nImageHeight = a_electronImage.Height;
  1074. a_nImageWidth = a_electronImage.Width;
  1075. a_nPixelSize = a_electronImage.PixelSize;
  1076. int nBytesPerPixel = a_electronImage.BytesPerPixel;
  1077. long nImageSize = a_nImageHeight * a_nImageWidth;
  1078. long nBufferSize = nImageSize * nBytesPerPixel;
  1079. Byte[] imageData = new Byte[nBufferSize];
  1080. a_electronImage.GetData(imageData);
  1081. a_pImageBits = new Byte[nImageSize];
  1082. // default, oxford will return short image, we need to convert to byte
  1083. if (nBytesPerPixel == 2)
  1084. {
  1085. int nBSEValue = 0;
  1086. for (int i = 0; i < nImageSize; ++i)
  1087. {
  1088. nBSEValue = imageData[0 + i * nBytesPerPixel] + imageData[1 + i * nBytesPerPixel] * 255;
  1089. a_pImageBits[i] = (Byte)(nBSEValue / 128.0 + 0.5);
  1090. }
  1091. }
  1092. else
  1093. {
  1094. string msg = string.Format("image byte per pixel other than 2({0}), image convert may wrong", nBytesPerPixel);
  1095. MessageBox.Show(msg);
  1096. int nOffset = nBytesPerPixel - 1;
  1097. for (int i = 0; i < nImageSize; ++i)
  1098. {
  1099. a_pImageBits[i] = imageData[nOffset + i * nBytesPerPixel];
  1100. }
  1101. }
  1102. return true;
  1103. }
  1104. void AcquisitionParamInit()
  1105. {
  1106. m_ImageBit = null;
  1107. m_nImageWidth = 0;
  1108. m_nImageHeight = 0;
  1109. m_bAcquistionDone = false;
  1110. Bitmap m_Bitmap = null;
  1111. }
  1112. //a_dDwellTime : 1~100000之间的数
  1113. //a_sImageType : 1: SE, 2: Bse
  1114. //a_dImageScanSize : 图像分辨率,图像的高
  1115. public bool SetImageAcquistionSetting(double a_dDwellTime, int a_nImageType, double a_dImageScanSize)
  1116. {
  1117. IImageSettings imageSettings = imageAcquisitionSettings.ImageSettings;
  1118. IImageCapabilities imageCapabilities = imageAcquisitionSettings.ImageCapabilities;
  1119. IImageScanSettings scanSettings = imageAcquisitionSettings.ScanSettings;
  1120. if (a_dDwellTime > imageCapabilities.MaximumImageDwellMicroseconds)
  1121. {
  1122. imageSettings.DwellTimeMicroSeconds = imageCapabilities.MaximumImageDwellMicroseconds;
  1123. }
  1124. if (a_dDwellTime < imageCapabilities.MinimumImageDwellMicroseconds)
  1125. {
  1126. imageSettings.DwellTimeMicroSeconds = imageCapabilities.MinimumImageDwellMicroseconds;
  1127. }
  1128. else
  1129. {
  1130. imageSettings.DwellTimeMicroSeconds = a_dDwellTime;
  1131. }
  1132. imageSettings.InputSources.ToList().ForEach(i => imageSettings.EnableInputSource(i.Key, false));
  1133. imageSettings.EnableInputSource((ImageInputSources)a_nImageType, true);
  1134. if (!ImageScanSize.Contains(a_dImageScanSize))
  1135. {
  1136. MessageBox.Show("图像尺寸输入无效");
  1137. return false;
  1138. }
  1139. var pixelSize = 1d / a_dImageScanSize;
  1140. scanSettings.AcquisitionRegion.CreateFullFieldRegion(pixelSize);
  1141. return true;
  1142. }
  1143. ////拍图
  1144. public Boolean GrabImage(String filename, short xoff, short yoff, short width, short height, short type)
  1145. {
  1146. SetImageAcquistionSetting(1, 1, 1024);
  1147. AcquisitionParamInit();
  1148. try
  1149. {
  1150. int lastingTime = 0;
  1151. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  1152. //imageAcquisitionController.BeginMultipleAcquisition();
  1153. IEnumerable<IElectronImage> images = imageAcquisitionController.StartAcquisition(imageAcquisitionSettings);
  1154. log.Info("拍图开始 startAcquisition 完成");
  1155. images.ToList().ForEach(i =>
  1156. {
  1157. i.Label = string.Format(@"Code example image - {0:HH:mm:ss} - {1}", DateTime.Now, i.InputSource.ToString());
  1158. });
  1159. while (true)
  1160. {
  1161. if (m_bAcquistionDone)
  1162. {
  1163. // 图像对象
  1164. m_Bitmap = ToGrayBitmap(m_ImageBit, (int)m_nImageHeight, (int)m_nImageWidth);
  1165. switch (Path.GetExtension(filename))
  1166. {
  1167. case ".bmp":
  1168. m_Bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp);
  1169. break;
  1170. case ".jpg":
  1171. m_Bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
  1172. break;
  1173. case ".gif":
  1174. m_Bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Gif);
  1175. break;
  1176. case ".tif":
  1177. m_Bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Tiff);
  1178. break;
  1179. case ".png":
  1180. m_Bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
  1181. break;
  1182. default:
  1183. break;
  1184. }
  1185. break;
  1186. }
  1187. Application.DoEvents();
  1188. Thread.Sleep(100);
  1189. lastingTime += 100;
  1190. if (lastingTime > EDSColletionTimeOut*6)
  1191. {
  1192. return false;
  1193. }
  1194. }
  1195. }
  1196. catch (InvalidSettingsException settingsException)
  1197. {
  1198. var sb = new StringBuilder(@"Invalid settings have been supplied: ");
  1199. sb.AppendLine();
  1200. settingsException.ValidationResults.ValidationErrors.ToList().ForEach(ve => sb.AppendFormat("{0}{1}", Environment.NewLine, ve));
  1201. MessageBox.Show(sb.ToString());
  1202. }
  1203. catch (AcquisitionStartException startException)
  1204. {
  1205. string msg = string.Format(@"AcquisitionStartException: {0}", startException.Message);
  1206. MessageBox.Show(msg);
  1207. }
  1208. return true;
  1209. }
  1210. /// <summary>
  1211. /// 将一个byte的数组转换为8bit灰度位图
  1212. /// </summary>
  1213. /// <param name="data">数组</param>
  1214. /// <param name="width">图像宽度</param>
  1215. /// <param name="height">图像高度</param>
  1216. /// <returns>位图</returns>
  1217. Bitmap ToGrayBitmap(byte[] data, int width, int height)
  1218. {
  1219. // 申请目标位图的变量,并将其内存区域锁定
  1220. Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
  1221. //BitmapData这部分内容 需要 using System.Drawing.Imaging;
  1222. BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height),
  1223. ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
  1224. // 获取图像参数
  1225. // 扫描线的宽度
  1226. int stride = bmpData.Stride;
  1227. // 显示宽度与扫描线宽度的间隙
  1228. int offset = stride - width;
  1229. // 获取bmpData的内存起始位置
  1230. IntPtr iptr = bmpData.Scan0;
  1231. // 用stride宽度,表示这是内存区域的大小
  1232. int scanBytes = stride * height;
  1233. // 下面把原始的显示大小字节数组转换为内存中实际存放的字节数组
  1234. int posScan = 0;
  1235. int posReal = 0;// 分别设置两个位置指针,指向源数组和目标数组
  1236. byte[] pixelValues = new byte[scanBytes]; //为目标数组分配内存
  1237. for (int x = 0; x < height; x++)
  1238. {
  1239. int startIndex = x * width;
  1240. //// 下面的循环节是模拟行扫描
  1241. for (int y = 0; y < width; y++)
  1242. {
  1243. pixelValues[posScan++] = data[posReal++];
  1244. }
  1245. posScan += offset; //行扫描结束,要将目标位置指针移过那段“间隙”
  1246. }
  1247. // 用Marshal的Copy方法,将刚才得到的内存字节数组复制到BitmapData中
  1248. System.Runtime.InteropServices.Marshal.Copy(pixelValues, 0, iptr, scanBytes);
  1249. bmp.UnlockBits(bmpData); // 解锁内存区域
  1250. // 下面的代码是为了修改生成位图的索引表,从伪彩修改为灰度
  1251. ColorPalette tempPalette;
  1252. using (Bitmap tempBmp = new Bitmap(1, 1, PixelFormat.Format8bppIndexed))
  1253. {
  1254. tempPalette = tempBmp.Palette;
  1255. }
  1256. for (int i = 0; i < 256; i++)
  1257. {
  1258. tempPalette.Entries[i] = Color.FromArgb(i, i, i);
  1259. }
  1260. bmp.Palette = tempPalette;
  1261. return bmp;
  1262. }
  1263. //获取分辨率
  1264. public int[] GetImageStore()
  1265. {
  1266. int[] ImageStore = new int[8];
  1267. for (int i = 0; i < 8; i++)
  1268. {
  1269. ImageStore[i] = (int)ImageScanSize[i];
  1270. }
  1271. return ImageStore;
  1272. }
  1273. //设置分辨率
  1274. public Boolean SetImageStore(float set)
  1275. {
  1276. IImageScanSettings scanSettings = imageAcquisitionSettings.ScanSettings;
  1277. if (!ImageScanSize.Contains(set))
  1278. {
  1279. MessageBox.Show("图像尺寸输入无效");
  1280. return false;
  1281. }
  1282. var pixelSize = 1d / (double)set;
  1283. scanSettings.AcquisitionRegion.CreateFullFieldRegion(pixelSize);
  1284. return true;
  1285. }
  1286. public Bitmap GetBitmap()
  1287. {
  1288. return m_Bitmap;
  1289. }
  1290. #endregion
  1291. #region X-ray
  1292. //控制器
  1293. private IEdSpectrumAcquisitionController EdSpectrumAcquisitionController = null;
  1294. private IEdSpectrumSettings EdSpectrumSettings = null;
  1295. private IEdSpectrumProcessing EdSpectrumProcessing = null;
  1296. // Use the autoIdSettings to define elements that are known or elements that you want to exclude. They also list elements that cannot be identified
  1297. private IAutoIdSettings autoIdSettings = null;
  1298. private ISEMQuantSettings quantSettings = null;
  1299. private IEdChordListAcquisitionController _edsChordListController = null;
  1300. private OxfordControllerState m_nState;
  1301. private IEdChordListSettings _edsChordListSetting;
  1302. private int XRayChannelLength = 2000;
  1303. private long[] m_XrayData = null;
  1304. private bool m_bXrayDone = false;
  1305. private int EDSColletionTimeOut=10000;
  1306. private AutoResetEvent m_endControllerEvent;
  1307. //当前feature的pixel数控制
  1308. private long m_nCollectedPixelCounts;
  1309. private long m_nPixelNum;
  1310. private List<Element> m_listElementResult;
  1311. private OxfordXrayData[] m_pXrayDataList;
  1312. const int g_nOxfordControllerProcessTime = 4;
  1313. const int g_nOxfordControllerEnergyRange = 20;
  1314. // feature计数控制
  1315. private long m_nXrayDataCount;
  1316. private long m_nCollectedXrayCounts;
  1317. /// <summary>
  1318. /// List of EdSpectrum objects
  1319. /// </summary>
  1320. private Dictionary<string, double> listElement = null;
  1321. void InitXrayAcquistion()
  1322. {
  1323. EdSpectrumSettings = AcquireFactory.CreateEdSpectrumSettings();
  1324. EdSpectrumAcquisitionController = AcquireFactory.CreateEdSpectrumServer();
  1325. EdSpectrumProcessing = ProcessingFactory.CreateSpectrumProcessing();
  1326. // Use the autoIdSettings to define elements that are known or elements that you want to exclude. They also list elements that cannot be identified
  1327. autoIdSettings = ProcessingFactory.CreateAutoIdSettings();
  1328. quantSettings = ProcessingFactory.CreateSEMQuantSettings();
  1329. EdSpectrumAcquisitionController.ExperimentFinished += this.OnEdSpectrumExperimentFinished;
  1330. //EdSpectrumAcquisitionController.ExperimentStarted += this.OnEdSpectrumExperimentStarted;
  1331. }
  1332. void CloaseXrayAcquistion()
  1333. {
  1334. EdSpectrumAcquisitionController.ExperimentFinished -= this.OnEdSpectrumExperimentFinished;
  1335. //EdSpectrumAcquisitionController.ExperimentStarted -= this.OnEdSpectrumExperimentStarted;
  1336. }
  1337. void SetXrayAcquisitionParam( double a_dMilliSecondsTime)
  1338. {
  1339. EdSpectrumSettings.EdSettings.AcquisitionMode = EdAcquireMode.LiveTime; // RealTime or LiveTime
  1340. if (a_dMilliSecondsTime < 100)
  1341. {
  1342. a_dMilliSecondsTime = 100;
  1343. }
  1344. EdSpectrumSettings.EdSettings.AcquisitionTime = TimeSpan.FromMilliseconds(a_dMilliSecondsTime);
  1345. EdSpectrumSettings.EdSettings.ProcessTime = 4;
  1346. EdSpectrumSettings.EdSettings.EnergyRange = 20;
  1347. EdSpectrumSettings.EdSettings.NumberOfChannels = 4096;
  1348. // EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreateFullFieldRegion(1.0 / 1024.0);
  1349. }
  1350. void SetAreaXrayAcquisitionParam(IEdChordListSettings EdSpectrumSettings, double a_dMilliSecondsTime)
  1351. {
  1352. EdSpectrumSettings.EdSettings.AcquisitionMode = EdAcquireMode.LiveTime; // RealTime or LiveTime
  1353. if (a_dMilliSecondsTime < 100)
  1354. {
  1355. a_dMilliSecondsTime = 100;
  1356. }
  1357. EdSpectrumSettings.EdSettings.AcquisitionTime = TimeSpan.FromMilliseconds(a_dMilliSecondsTime);
  1358. EdSpectrumSettings.EdSettings.ProcessTime = 4;
  1359. EdSpectrumSettings.EdSettings.EnergyRange = 20;
  1360. EdSpectrumSettings.EdSettings.NumberOfChannels = 4096;
  1361. // EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreateFullFieldRegion(1.0 / 1024.0);
  1362. }
  1363. void SetPointAcquistionRegion(double a_nX, double a_nY)
  1364. {
  1365. EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreatePointRegion(new System.Windows.Point(a_nX, a_nY));
  1366. }
  1367. void SetAreaAcquistionRegion(List<Chord> a_nChords)
  1368. {
  1369. ChordList chordsList = null;
  1370. chordsList = new ChordList(a_nChords, m_dImagePixelsize);
  1371. EdSpectrumSettings.ScanSettings.AcquisitionRegion.CreateChordListRegion(chordsList);
  1372. }
  1373. void XrayParamInit()
  1374. {
  1375. m_XrayData = null;
  1376. m_bXrayDone = false;
  1377. }
  1378. /// <summary>
  1379. /// Called when IEdSpectrumAcquisitionController Experiment Starting.
  1380. /// </summary>
  1381. /// <param name="sender">The sender.</param>
  1382. /// <param name="e">The <see cref="AcquisitionFinishedEventArgs{IEdSpectrum}"/> instance containing the event data.</param>
  1383. private void OnEdSpectrumExperimentStarting(object sender, AcquisitionStartingEventArgs<IEdSpectrum> e)
  1384. {
  1385. }
  1386. /// <summary>
  1387. /// Called when IEdSpectrumAcquisitionController Experiment Started.
  1388. /// </summary>
  1389. /// <param name="sender">The sender.</param>
  1390. /// <param name="e">The <see cref="AcquisitionFinishedEventArgs{IEdSpectrum}"/> instance containing the event data.</param>
  1391. private void OnEdSpectrumExperimentStarted(object sender, AcquisitionStartedEventArgs<IEdSpectrum> e)
  1392. {
  1393. }
  1394. private IEdChordListSettings GetChordlistSettings()
  1395. {
  1396. if(_edsChordListSetting == null)
  1397. {
  1398. _edsChordListSetting = AcquireFactory.CreateEdChordListSettings();
  1399. if (_edsChordListSetting!=null)
  1400. {
  1401. _edsChordListSetting.EdSettings.AcquisitionMode = EdAcquireMode.LiveTime;
  1402. _edsChordListSetting.EdSettings.NumberOfChannels = 1024;
  1403. _edsChordListSetting.EdSettings.ProcessTime = g_nOxfordControllerProcessTime;
  1404. _edsChordListSetting.EdSettings.EnergyRange = g_nOxfordControllerEnergyRange;
  1405. _edsChordListSetting.AutoIdSettings.SetKnownElement(79, true);
  1406. _edsChordListSetting.NumberOfProcessingThreads = 1;
  1407. }
  1408. else
  1409. {
  1410. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  1411. log.Error("Create EDS chordlist setting failed.");
  1412. }
  1413. }
  1414. return _edsChordListSetting;
  1415. }
  1416. private IEdChordListAcquisitionController CreateChordlistController()
  1417. {
  1418. if (_edsChordListController==null)
  1419. {
  1420. _edsChordListController = AcquireFactory.CreateEdChordListServer();
  1421. _edsChordListController.PixelProcessed += new EventHandler<OINA.Extender.EventArgs<OINA.Extender.Processing.Quant.IPixelSEMQuantStatus>>(this.OnController_PixelProcessed);
  1422. _edsChordListController.ExperimentFinished += new EventHandler<OINA.Extender.Acquisition.AcquisitionFinishedEventArgs>(this.OnController_ExperimentFinished);
  1423. var edsChordListSettings = GetChordlistSettings();
  1424. while (true)
  1425. {
  1426. if(_edsChordListController.IsEdHardwareReady(edsChordListSettings))
  1427. {
  1428. if(edsChordListSettings.EdCapabilities.HasHardwareConnection)
  1429. {
  1430. break;
  1431. }
  1432. }
  1433. }
  1434. }
  1435. return _edsChordListController;
  1436. }
  1437. struct Element
  1438. {
  1439. public int m_nAotomaticNo;
  1440. public double m_dWeight;
  1441. }
  1442. private struct OxfordXrayData
  1443. {
  1444. public long m_nPosX;
  1445. public long m_nPosY;
  1446. public static readonly long[] m_pXrayData = new long[(int)EDSConst.XANA_CHANNELS];
  1447. public static readonly char[] vs =new char[1024];
  1448. public static readonly OxfordChord[] m_ChordList = new OxfordChord[1024];
  1449. public long m_nChordNum;
  1450. public long m_nPixelNum;
  1451. internal char[] m_strElementResult;
  1452. }
  1453. private void OnController_ExperimentFinished(Object sender,OINA.Extender.Acquisition.AcquisitionFinishedEventArgs e)
  1454. {
  1455. if(m_nCollectedXrayCounts== m_nXrayDataCount)
  1456. {
  1457. m_nState = OxfordControllerState.SUCCEEDED;
  1458. }
  1459. else
  1460. {
  1461. m_nState = OxfordControllerState.FAILED;
  1462. }
  1463. m_endControllerEvent.Set();
  1464. }
  1465. /// <summary>
  1466. ///
  1467. /// </summary>
  1468. /// <param name="sender"></param>
  1469. /// <param name="e"></param>
  1470. private void OnController_PixelProcessed(object sender,EventArgs<IPixelSEMQuantStatus>e)
  1471. {
  1472. m_nCollectedPixelCounts = m_nCollectedPixelCounts++;
  1473. //更新当前feature的元素成分
  1474. //获取单点的元素结果
  1475. var ie = e.Value.QuantStatus.Results.GetEnumerator();
  1476. while(ie.MoveNext())
  1477. {
  1478. ISEMQuantResult result = ie.Current;
  1479. if (result.WeightPercent!=0)
  1480. {
  1481. Element Quant = new Element();
  1482. Quant.m_nAotomaticNo = result.AtomicNumber;
  1483. Quant.m_dWeight = result.WeightPercent;
  1484. if (m_listElementResult==null)
  1485. {
  1486. m_listElementResult = new List<Element>
  1487. {
  1488. Quant
  1489. };
  1490. }
  1491. else
  1492. {
  1493. bool bFind = false;
  1494. for (int i=0;i< m_listElementResult.Count;i++)
  1495. {
  1496. Element element= m_listElementResult[i];
  1497. if (Quant.m_nAotomaticNo== element.m_nAotomaticNo)
  1498. {
  1499. element.m_dWeight += Quant.m_dWeight;
  1500. bFind = true;
  1501. }
  1502. }
  1503. if (!bFind)
  1504. {
  1505. m_listElementResult.Add(Quant);
  1506. }
  1507. }
  1508. }
  1509. }
  1510. //当前的chord数据中pixel没有采集完整
  1511. if(m_nCollectedPixelCounts==m_nPixelNum)
  1512. {
  1513. //形成quant数据
  1514. String Quant = "";
  1515. for (int i = 0; i < m_listElementResult.Count; i++)
  1516. {
  1517. Element result = m_listElementResult[i];
  1518. Quant += "Quant=";
  1519. String strAoto=ElementProperties.GetElementSymbol(result.m_nAotomaticNo);
  1520. Quant += strAoto;
  1521. Quant += ",";
  1522. Quant += "K-serials";
  1523. Quant += ",";
  1524. String strWeight = (result.m_dWeight / Convert.ToDouble(m_nPixelNum)).ToString();
  1525. Quant += strWeight;
  1526. Quant += "\n";
  1527. }
  1528. String msg = Quant;
  1529. char[] dst = m_pXrayDataList[m_nCollectedXrayCounts].m_strElementResult;
  1530. for (int i=0;i<msg.Length;i++)
  1531. {
  1532. dst[i] = (char)msg[i];
  1533. }
  1534. m_nCollectedXrayCounts++;
  1535. if (m_nCollectedXrayCounts<m_nXrayDataCount)
  1536. {
  1537. m_nPixelNum = m_pXrayDataList[m_nCollectedXrayCounts].m_nPixelNum;
  1538. m_nCollectedPixelCounts = 0;
  1539. m_listElementResult.Clear();
  1540. }
  1541. }
  1542. }
  1543. /// <summary>
  1544. /// Called when IEdSpectrumAcquisitionController Experiment Finished
  1545. /// </summary>
  1546. /// <param name="sender">sender object</param>
  1547. /// <param name="e">The instance containing the event data.</param>
  1548. private void OnEdSpectrumExperimentFinished(object sender, AcquisitionFinishedEventArgs<IEdSpectrum> e)
  1549. {
  1550. IEdSpectrumAcquisitionController edSpectrumAcquisitionController = sender as IEdSpectrumAcquisitionController;
  1551. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  1552. IEdSpectrum edSpectrum = e.Value;
  1553. if (!ReadXrayData(edSpectrum, out m_XrayData, XRayChannelLength))
  1554. {
  1555. MessageBox.Show("Xray采集完成,获取xray失败!");
  1556. }
  1557. long nXraycount = 0;
  1558. for (int i = 0; i < 2000; i++)
  1559. {
  1560. nXraycount += m_XrayData[i];
  1561. }
  1562. //Quantify processing
  1563. EdSpectrumProcessing.IdentifyElements(e.Value, autoIdSettings);
  1564. // While it is possible to choose other elements, Oxygen is the only supported element by stoichiometry.
  1565. quantSettings.CombinedElement = 8;
  1566. quantSettings.Normalised = true;
  1567. ISEMQuantStatus quantStatus = EdSpectrumProcessing.SEMQuantifySpectrum(e.Value, quantSettings);//(a_nChannelData, OIHelper::SEMQuantSettings);
  1568. IEnumerable < ISEMQuantResult > Results = quantStatus.Results;
  1569. //Get element result for single point
  1570. //quantStatus.Results.
  1571. var ie = Results.GetEnumerator();
  1572. listElement = new Dictionary<string, double>();
  1573. while (ie.MoveNext())
  1574. {
  1575. ISEMQuantResult result = ie.Current;
  1576. if (result.WeightPercent != 0)
  1577. {
  1578. listElement.Add(ElementProperties.GetElementSymbol(result.AtomicNumber), result.WeightPercent );
  1579. }
  1580. }
  1581. if (m_XrayData != null && m_XrayData.Length == XRayChannelLength)
  1582. {
  1583. log.Info("xray 采集结束事件,采集成功 当前线程" + Thread.CurrentThread.ManagedThreadId.ToString());
  1584. log.Info("计数率为:" + nXraycount.ToString());
  1585. if (nXraycount < 5000)
  1586. {
  1587. log.Warn("计数率低于5000!");
  1588. }
  1589. m_bXrayDone = true;
  1590. }
  1591. }
  1592. bool ReadXrayData(IEdSpectrum a_spectrum, out long[] a_pSpectrumData, int a_nBufferSize)
  1593. {
  1594. a_pSpectrumData = new long[a_nBufferSize];
  1595. int[] xrayData = new int[a_spectrum.NumberOfChannels];
  1596. a_spectrum.GetChannelData(xrayData);
  1597. double dZeroChannelValue = a_spectrum.ZeroChannelValue;
  1598. int nChannelStart = 0;
  1599. if (dZeroChannelValue < 0) // zero channel value should less than zero
  1600. {
  1601. nChannelStart = (int)(-dZeroChannelValue / a_spectrum.ChannelWidth + 0.5);
  1602. }
  1603. int nDataLength = (int)(a_spectrum.EnergyRange * 1000 / a_spectrum.ChannelWidth + 0.5);
  1604. double dStep1 = 1.0 / nDataLength;
  1605. double dStep2 = 1.0 / a_nBufferSize;
  1606. for (int i = 0; i < nDataLength; ++i)
  1607. {
  1608. int nValue = xrayData[i + nChannelStart] > 0 ? xrayData[i + nChannelStart] : 0;
  1609. double dBinPos = i * dStep1;
  1610. long nLeftBin = (long)(dBinPos / dStep2);
  1611. // calculate % into left bin
  1612. double dLeft_Percent = (double)(nLeftBin + 1) - dBinPos / dStep2; // ((nLeftBin + 1)*dStep2 - dBinPos)/dStep2
  1613. // calculate data into the left bin
  1614. long nValueToLeftBin = (long)((double)nValue * dLeft_Percent + 0.5);
  1615. // put data into bins
  1616. a_pSpectrumData[nLeftBin] += nValueToLeftBin;
  1617. if ((nLeftBin + 1) < (long)a_nBufferSize)
  1618. {
  1619. a_pSpectrumData[nLeftBin + 1] += (nValue - nValueToLeftBin);
  1620. }
  1621. }
  1622. return true;
  1623. }
  1624. /// <summary>
  1625. /// Called when IEdSpectrum DataChanged
  1626. /// </summary>
  1627. /// <param name="sender">Event source</param>
  1628. /// <param name="e">Event arguments</param>
  1629. private void OnDataChanged(object sender, EventArgs e)
  1630. {
  1631. }
  1632. public bool IsAcquiringSpectrum()
  1633. {
  1634. return EdSpectrumAcquisitionController.IsAcquiring;
  1635. }
  1636. //点扫描
  1637. //X-ray
  1638. public Boolean XrayPointCollecting(double dMilliSecondsTime, double x, double y, out long[] XrayData, out Dictionary<string, double> a_listElement)
  1639. {
  1640. XrayParamInit();
  1641. XrayData = new long[XRayChannelLength];
  1642. a_listElement = new Dictionary<string, double>();
  1643. SetXrayAcquisitionParam( dMilliSecondsTime);
  1644. SetPointAcquistionRegion(x*m_dImagePixelsize, y*m_dImagePixelsize);
  1645. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  1646. log.Info("开始XrayStartAcquisition:t="+dMilliSecondsTime.ToString()+"pos="+"("+x.ToString()+","+y.ToString()+")");
  1647. if (EdSpectrumAcquisitionController.IsEdHardwareReady(EdSpectrumSettings))
  1648. {
  1649. // Start spectrum acquisition
  1650. try
  1651. {
  1652. m_bXrayDone = false;
  1653. int lastingTime = 0;
  1654. IEdSpectrum edSpectrum = EdSpectrumAcquisitionController.StartAcquisition(EdSpectrumSettings);
  1655. edSpectrum.Label = string.Format(@"Point({0},{1})",x,y);
  1656. while (true)
  1657. {
  1658. if (m_bXrayDone)
  1659. {
  1660. XrayData = m_XrayData;
  1661. a_listElement =listElement;
  1662. break;
  1663. }
  1664. Application.DoEvents();
  1665. Thread.Sleep(100);
  1666. lastingTime += 100;
  1667. if (lastingTime > EDSColletionTimeOut*3)
  1668. {
  1669. //EdSpectrumAcquisitionController.EndMultipleAcquisition();
  1670. log.Warn("XrayStartAcquisition 超时!");
  1671. return false;
  1672. }
  1673. }
  1674. }
  1675. catch (InvalidSettingsException invalidSettingsException)
  1676. {
  1677. string msg = string.Format(@"Invalid Settings Exception:{0}, {1}",
  1678. invalidSettingsException.Message,
  1679. invalidSettingsException.ValidationResults.ValidationErrors);
  1680. MessageBox.Show(msg);
  1681. }
  1682. catch (AcquisitionStartException acquisitionStartException)
  1683. {
  1684. string msg = string.Format(@"Acquisition Start Exception:{0}",acquisitionStartException.Message);
  1685. MessageBox.Show(msg);
  1686. }
  1687. }
  1688. return true;
  1689. }
  1690. //面扫描
  1691. public Boolean XrayAreaCollectiong( double dMilliSecondsTime, List<Segment> a_listChord, out long[] XrayData, out Dictionary<string, double> a_listElement)
  1692. {
  1693. XrayParamInit();
  1694. XrayData = new long[XRayChannelLength];
  1695. a_listElement = new Dictionary<string, double>();
  1696. var edsAreaSpectrumSettings = AcquireFactory.CreateEdChordListSettings();
  1697. SetAreaXrayAcquisitionParam(edsAreaSpectrumSettings, dMilliSecondsTime);
  1698. List<Chord> Chords = new List<Chord>();
  1699. foreach (Segment seg in a_listChord)
  1700. {
  1701. Chord chord = new Chord(seg.X, seg.Y, seg.Length);
  1702. Chords.Add(chord);
  1703. }
  1704. SetAreaAcquistionRegion(Chords);
  1705. var edsSpectrumController = CreateChordlistController();
  1706. // IEdSpectrumSettings.EdCapabilities will validate settings and hardware availability.
  1707. if (edsSpectrumController.IsEdHardwareReady(edsAreaSpectrumSettings))
  1708. {
  1709. // This only used for multiple acquisition:
  1710. // if this is the first acquisition, call BeginMultipleAcquisition
  1711. // on the IEdSpectrumAcquisitionController to suppress external scan switching
  1712. //if (m_bXrayDone)
  1713. // EdSpectrumAcquisitionController.BeginMultipleAcquisition();
  1714. // Start spectrum acquisition
  1715. try
  1716. {
  1717. int lastingTime = 0;
  1718. //IEdSpectrum edSpectrum =
  1719. edsSpectrumController.StartAcquisition(edsAreaSpectrumSettings);
  1720. //edSpectrum.Label = string.Format(@"chord");
  1721. while (true)
  1722. {
  1723. if (m_bXrayDone)
  1724. {
  1725. XrayData = m_XrayData;
  1726. a_listElement = listElement;
  1727. break;
  1728. }
  1729. Thread.Sleep(100);
  1730. Application.DoEvents();
  1731. lastingTime += 100;
  1732. if (lastingTime > EDSColletionTimeOut*8)
  1733. {
  1734. return false;
  1735. }
  1736. }
  1737. }
  1738. catch (InvalidSettingsException invalidSettingsException)
  1739. {
  1740. string msg = string.Format(@"Invalid Settings Exception:{0}, {1}",
  1741. invalidSettingsException.Message,
  1742. invalidSettingsException.ValidationResults.ValidationErrors);
  1743. MessageBox.Show(msg);
  1744. }
  1745. catch (AcquisitionStartException acquisitionStartException)
  1746. {
  1747. string msg = string.Format(@"Acquisition Start Exception:{0}", acquisitionStartException.Message);
  1748. MessageBox.Show(msg);
  1749. }
  1750. }
  1751. return true;
  1752. }
  1753. public void BeginMultipleAquisition()
  1754. {
  1755. EdSpectrumAcquisitionController.BeginMultipleAcquisition();
  1756. }
  1757. public void EndMultipleAquisition()
  1758. {
  1759. EdSpectrumAcquisitionController.EndMultipleAcquisition();
  1760. }
  1761. #endregion
  1762. }
  1763. }