using OxfordExtenderWrapper; using OTSModelSharp.ServiceCenter; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.Remoting.Channels.Ipc; using System.Runtime.Remoting.Channels; using OTSMeasureApp.ServiceCenter.OxfordExtender; using System.Threading; namespace OTSMeasureApp.ServiceCenter { class OxfordSemController : ISemController { ExtenderIpcUI iExtender; public OxfordSemController() { iExtender = ExtenderWrapperIpc.GetExtenderWrapper(); } public bool Connect() { try { iExtender = ExtenderWrapperIpc.GetExtenderWrapper(); } catch (Exception e) { NLog.LogManager.GetCurrentClassLogger().Warn(e.Message); } return true; } public bool DisConnect() { try { iExtender.CloseExtender(); //ExtenderWrapperIpc.KillExtenderWrapperProcess(); } catch (Exception e) { NLog.LogManager.GetCurrentClassLogger().Warn(e.Message); } return true; } public bool GetMagnification(ref double a_dMagnification) { a_dMagnification= iExtender.GetMagnification(); return true; } public bool GetSemBeamBlank(ref int a_nBeamBlank) { a_nBeamBlank = 1; return true; } public bool GetSemBrightness(ref double a_dBrightness) { a_dBrightness = iExtender.GetBrightness(); return true; } public bool GetSemContrast(ref double a_dContrast) { a_dContrast = iExtender.GetContrast(); return true; } public bool GetSemHighTension(ref double a_dKV) { a_dKV = iExtender.GetSEMVoltage() / 1000; return true; } public bool GetSemPositionXY(ref double a_dPositionX, ref double a_dPositionY, ref double a_dPositionR) { a_dPositionX = iExtender.GetStageAtX(); a_dPositionY = iExtender.GetStageAtY(); a_dPositionR = iExtender.GetStageAtR(); return true; } public bool GetWorkingDistance(ref double a_distance) { a_distance= iExtender.GetWorkingDistance(); return true; } public bool IsConnected() { if (Connect()) { return true; } else { return false; } } public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY, double rotation) { var b1= iExtender.MoveStageXY((float)a_dPositionX, (float)a_dPositionY); var b2=iExtender.SetStageGotoR((float)rotation); return b1&b2; } public bool MoveSEMToPoint(double a_dPositionX, double a_dPositionY) { var b= iExtender.MoveStageXY((float)a_dPositionX, (float)a_dPositionY); return b; } public bool SetMagnification(double a_dMagnification) { return iExtender.SetMagnification((float)a_dMagnification); } public bool SetScanExternal(bool b) { return iExtender.SetSemScanExternal(b); } public bool SetSemBeamOn(bool val) { return true; } public bool GetSemBeamOn() { return iExtender.GetSemBeamOn(); } public bool SetSemBrightness(double a_dBrightness) { return iExtender.SetBrightness((float)a_dBrightness); } public bool SetSemContrast(double a_dContrast) { return iExtender.SetContrast((float)a_dContrast); } public bool SetSemHighTension(double a_dKV) { return iExtender.SetSEMVoltage((float)a_dKV); } public bool SetWorkingDistance(double a_distance) { return iExtender.SetWorkingDistance((float)a_distance); } public void StopXrayAcquisition() { iExtender.StopXrayAquisition(); } public bool GetScanFieldSize(ref double dScanFieldSizeX, ref double dScanFieldSizeY) { throw new NotImplementedException(); } public bool SetSemBeamCurrentOff(bool a_dKV) { throw new NotImplementedException(); } public bool SetSemBeamBlank(bool a_dKV) { throw new NotImplementedException(); } bool ISemController.StopXrayAcquisition() { throw new NotImplementedException(); } public bool SetSemHTOff(bool value) { return true; } public bool RunHIGH_VACUUM() { return true; } public bool StopImageAcquisition() { return true; } public bool SetReducedArea() { return true; } public bool SetFullFrame() { return true; } } }