using Aurora.Api; using AuroraLaser.Amplitude.Satsuma; using AuroraLaser.Coherent; using Hermes; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AuroraLaser.Ekspla.NL202 { public class LaserDeviceNL202 : Device, ILaserDeviceEkspla { protected string LOG_TAG = "LaserDeviceNL202"; protected readonly Logger LOG = new Logger("LaserDeviceNL202"); public const int MAX_SLAVES = 5; // Status protected bool _isConnected = false; public LaserEksplaConfig Config { get; set; } protected LaserNL202 _laserNL202; private string GetFuncName() { System.Diagnostics.StackFrame stackFrameForFunc = new System.Diagnostics.StackFrame(1); return stackFrameForFunc.GetMethod().Name; } public LaserDeviceNL202(string deviceId) { DeviceId = deviceId; Type = DeviceType.Etc; CommType = CommunicationType.Serial; } protected override int DoActivate(IDeviceConfig config) { Config = config as LaserEksplaConfig; return ActivateDevice(); //LOG.I(GetFuncName() + " enter"); //_config = config as LaserEksplaConfig; //_laserNL202 = new LaserNL202(DeviceId, config as LaserEksplaConfig, (_isSimulBySetting || _config.IsSimul)); //_laserNL202.Connect(); //IsSimul = _isSimulBySetting || _config.IsSimul; //return _laserNL202.GetConnected() ? E1.OK : E2.NOT_CONNECTED; } protected override int DoDeactivate() { return DeactivateDevice(); //LOG.I(GetFuncName() + " enter"); //_laserNL202.Disconnect(); //IsSimul = false; //return E1.OK; } public int ActivateDevice() { LOG.I(GetFuncName() + " enter"); _laserNL202 = new LaserNL202(DeviceId, Config, IsSimul); _laserNL202.Connect(); return _laserNL202.GetConnected() ? E1.OK : E2.NOT_CONNECTED; } public int DeactivateDevice() { LOG.I(GetFuncName() + " enter"); _laserNL202.Disconnect(); IsSimul = false; return E1.OK; } public double GetTemperature(int diode) { if (!IsActivated) { return -1; } return _laserNL202.GetTemperature(diode); } public bool GetLastError(ref int errorCode, ref string errorMsg) { if (!IsActivated) { return false; } return _laserNL202.GetLastError(ref errorCode, ref errorMsg); } public void SetError(int errorCode, string errorMsg) { if (!IsActivated) { return; } _laserNL202.SetError(errorCode, errorMsg); } public bool RunLaser() { if (!IsActivated) { return false; } return _laserNL202.RunLaser(); } public bool StartBurstShot() { if (!IsActivated) { return false; } return _laserNL202.StartBurstShot(); } public bool StopLaser() // Laser 상태를 Stop { if (!IsActivated) { return false; } return _laserNL202.StopLaser(); } public bool StopShot() // 쏘고있는 Laser를 Stop { if (!IsActivated) { return false; } return _laserNL202.StopShot(); } public bool ResetFault() { if (!IsActivated) { return false; } return _laserNL202.ResetFault(); } public bool SetPumpLevel(double dValue) { if (!IsActivated) { return false; } return _laserNL202.SetPumpLevel(dValue); } public bool SetBurstCount(int nBurst) { if (!IsActivated) { return false; } return _laserNL202.SetBurstCount(nBurst); } public bool SetBurstMode(int nFireMode) { if (!IsActivated) { return false; } return _laserNL202.SetBurstMode(nFireMode); } public bool SetRepetitionRate(int nRepetition) { if (!IsActivated) { return false; } return _laserNL202.SetRepetitionRate(nRepetition); } public bool SetEnergyLevel(int nMod) { if (!IsActivated) { return false; } return _laserNL202.SetEnergyLevel(nMod); } public bool SetWaveLength(int nWaveLength) { if (!IsActivated) { return false; } return _laserNL202.SetWaveLength(nWaveLength); } public bool SetAttenuator(double dValue) { if (!IsActivated) { return false; } return _laserNL202.SetAttenuator(dValue); } public bool SetSyncMode(int nMode) { if (!IsActivated) { return false; } return _laserNL202.SetSyncMode(nMode); } //public bool SetOutputControl(int nValue) // SetEnergyLevel과 중복. 삭제 //{ // if (!IsActivated) return false; // return (_laserObj is LaserDeviceNL202) ? (_laserObj as LaserDeviceNL202).SetOutputControl(nValue) : false; //} public bool SetLaserParam(int nIndex, double dValue) { if (!IsActivated) { return false; } return _laserNL202.SetLaserParam(nIndex, dValue); } public bool GetLaserParam(int nIndex) { if (!IsActivated) { return false; } return _laserNL202.GetLaserParam(nIndex); } public void CheckLaserParmeter(int nSynMode, int nBurstMode, int nBurstCount, int nWaveLength, int nRepetitionRate, double dAtt) { if (!IsActivated) { return; } _laserNL202.CheckLaserParmeter(nSynMode, nBurstMode, nBurstCount, nWaveLength, nRepetitionRate, dAtt); } public int GetState() { if (!IsActivated) { return -1; } return _laserNL202.GetState(); } public double GetPumpLevel() { if (!IsActivated) { return -1; } return _laserNL202.GetPumpLevel(); } public int GetBurstMode() { if (!IsActivated) { return -1; } return _laserNL202.GetBurstMode(); } public int GetBurstCount() { if (!IsActivated) { return -1; } return _laserNL202.GetBurstCount(); } public double GetAttTrans() { if (!IsActivated) { return -1; } return _laserNL202.GetAttTrans(); } public int GetRepetitionRate() { if (!IsActivated) { return -1; } return _laserNL202.GetRepetitionRate(); } public int GetWaveLength() { if (!IsActivated) { return -1; } return _laserNL202.GetWaveLength(); } public int GetEnergyLevel() { if (!IsActivated) { return -1; } return _laserNL202.GetEnergyLevel(); } public int GetSyncMode() { if (!IsActivated) { return -1; } return _laserNL202.GetSyncMode(); } public int GetQSWadjDelay() { if (!IsActivated) { return -1; } return _laserNL202.GetQSWadjDelay(); } public int GetShotCnt() { if (!IsActivated) { return -1; } return _laserNL202.GetShotCnt(); } /////////////////////////////////////////////////////////// // Laser Interface 추가 // All LaserDevice 에서 선택하여 Device 가 생성될 때 사용되며, All LaserDevice 가 Activated 일 때만 true 가 됨. public bool IsActivated_InAllLaserDevice = false; private bool CanCallLaserFunction() { if (IsActivated_InAllLaserDevice == false && IsActivated == false) { return false; } return true; } public int LaserOn() { // TODO: 구현 필요 return 1; } public int LaserOff() { // TODO: 구현 필요 return 1; } public int PilotLaserOn() { // TODO: 구현 필요 return 1; } public int PilotLaserOff() { // TODO: 구현 필요 return 1; } public bool GetPilotLaserStatus() { // TODO: 구현 필요 return true; } public bool GetLaserReady() { // TODO: 구현 필요 return true; } public bool GetPilotLaserSetBitStatus() { // TODO: 구현 필요 return true; } public bool GetConnected() { if (!IsActivated) { return false; } return _laserNL202.GetConnected(); } public int SetData(int nTarget, int value) { // TODO: 구현 필요 return 1; } public int ResetLaser() { // TODO: 구현 필요 return E1.OK; } public string GetControlMode() { throw new NotImplementedException(); } public bool GetControlModeSetStatus() { throw new NotImplementedException(); } public bool GetEmissionStatus() { throw new NotImplementedException(); } public bool GetEStop() { throw new NotImplementedException(); } public bool GetInitCommunication() { throw new NotImplementedException(); } public bool GetLaserError() { throw new NotImplementedException(); } public bool GetLaserResetSetBitStatus() { throw new NotImplementedException(); } public bool GetLaserStartSetBitStatus() { throw new NotImplementedException(); } public string GetPowerCenter() { throw new NotImplementedException(); } public string GetPowerRing() { throw new NotImplementedException(); } public bool GetStartLaserSetBitStatus() { throw new NotImplementedException(); } public bool GetWarningStatus() { throw new NotImplementedException(); } public bool GetLaserInterlock() { throw new NotImplementedException(); } } }