123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- using FEIApiControl;
- using OTSModelSharp.ServiceCenter;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using NSDLL_CLR;
- using System.Reflection;
- namespace OTSMeasureApp.ServiceCenter.Coxm
- {
- class CoxmSemController : ISemController
- {
- public static NSRestClient m_api;
- private int imageWidth = 640;
- private int imageHeight = 480;
- double dwelltime = 10;
- int port = 7321;
- string ip = "127.0.0.1";
- /// <summary>
- /// //se 0;bse 1;se_bse 2;
- /// </summary>
- int scan_chanel = 1;
- /// <summary>
- /// //red 0; fast 1; slow 2; slow2 3
- /// </summary>
- int scan_speed = 1;
- public CoxmSemController()
- {
- m_api = NSDLL_CLR.NSRestClient.GetControllerInstance();
- }
- public static NSRestClient GetApiClassInstance()
- {
- if (m_api == null)
- {
- m_api = NSDLL_CLR.NSRestClient.GetControllerInstance();
- }
- return m_api;
- }
- public bool Connect()
- {
- string FEIIP = FileHelper.GetXMLInformations("FEIIP");
- string FEIPORT = FileHelper.GetXMLInformations("FEIPORT");
- if (FEIIP == "" || FEIPORT == "")
- {
- NLog.LogManager.GetCurrentClassLogger().Error("FEI电镜端口配置为空!");
- return false;
- }
- if (m_api.IsServerConnectStatus())
- {
- return true;
- }
- if (m_api.ServerConnect())
- {
- return true;
- }
- return false;
- }
- public bool DisConnect()
- {
- if (m_api.ServerDisConnect())
- {
- return true;
- }
- return false;
- }
- public bool GetMagnification(ref double a_dMagnification)
- {
- int mag = 0;
- if (m_api.GetMagnification(ref mag))
- {
- a_dMagnification=(double)mag;
- return true;
- }
- return false;
- }
- public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY)
- {
- if (!m_api.IsServerConnectStatus())
- {
- return false;
- }
- else
- {
- dScanFieldSizeX = imageWidth;
- dScanFieldSizeY = imageHeight;
- return true;
- }
-
- }
- public bool GetSemBeamBlank(ref bool a_nBeamBlank)
- {
- return m_api.PostBeamBlank(a_nBeamBlank);
- }
- public bool GetSemBrightness(ref double a_dBrightness)
- {
- int brightness = 0;
- bool get = m_api.GetBrightness(ref brightness);
- if(get)
- a_dBrightness=(double)brightness;
- return get;
- }
- public bool GetSemContrast(ref double a_dContrast)
- {
- int contrast = 0;
- bool get=m_api.GetContrast(ref contrast);
- if(get)
- {
- a_dContrast=(double)contrast;
- }
- return get;
- }
- public bool GetSemHighTension(ref double a_dKV)
- {
- int kv = 0;
- if(m_api.GetAccVoltage(ref kv))
- {
- a_dKV=(double)kv;
- }
- return false;
- }
- public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR)
- {
- double t = 0;
- return m_api.GetStageALL(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR, ref a_dPositionR, ref t);
-
- }
- public bool GetWorkingDistance(ref double a_distance)
- {
- return m_api.GetWD(ref a_distance);
- }
- public bool IsConnected()
- {
-
- return m_api.IsServerConnectStatus();
- }
- public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double rotation)
- {
- return false;
-
- }
- public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY)
- {
- return true;//test when no stage
- //return m_api.MoveStageX_YAndConform(a_dPositionX, a_dPositionY);
- }
- public bool SetMagnification(double a_dMagnification)
- {
- int mag =(int) a_dMagnification;
- return m_api.PostMagnification(mag);
- }
- public bool SetScanExternal(bool b)
- {
- return m_api.PostExternalOn(b);
- }
- public bool SetSemBeamBlank(bool value)
- {
- return m_api.PostBeamBlank(value);
- }
- public bool SetSemBeamCurrentOff(bool value)
- {
-
- return false;
- }
- public bool SetSemBrightness(double a_dBrightness)
- {
- int brightness=(int) a_dBrightness;
- return m_api.PostBrightness(brightness);
- }
- public bool SetSemContrast(double a_dContrast)
- {
- int contast=(int) a_dContrast;
- return m_api.PostContrast(contast);
- }
- public bool SetSemHighTension(double a_dKV)
- {
- int KV = (int)a_dKV;
- return m_api.PostAccVoltage(KV);
- }
- public bool SetSemHTOff(bool value)
- {
- if(value)
- {
- return m_api.PostEGunOFF();
- }
- else
- {
- return false;
- }
- }
- public bool SetWorkingDistance(double a_distance)
- {
- return m_api.PostWD(a_distance);
- }
- public bool StopXrayAcquisition()
- {
- return false;
- }
- bool ISemController.GetSemBeamBlank(ref int a_nBeamBlank)
- {
- if(a_nBeamBlank==1)
- {
- m_api.PostBeamBlank(true);
- }
- else if(a_nBeamBlank==0)
- {
- m_api.PostBeamBlank(false);
- }
- return false;
- }
- bool ISemController.RunHIGH_VACUUM()
- {
- return true;
- }
- bool ISemController.SetFullFrame()
- {
- return true;
- }
- bool ISemController.SetReducedArea()
- {
- return true;
- }
- bool ISemController.StopImageAcquisition()
- {
- return true;
- }
- }
- }
|