2026-01-26 18:56:53 +09:00

643 lines
15 KiB
C#

using Aurora.Api;
using AuroraLaser.Amplitude.Satsuma;
using AuroraLaser.Ekspla.NL202;
using Hermes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using static AuroraPowerMeter.Coherent.PowerMeterPowerMax;
namespace AuroraLaser.Ekspla
{
public enum eLaserEksplaDeviceType
{
UNKNOWN = -1,
NL202 = 0
}
public class LaserDeviceEkspla : Device, ILaserDeviceEkspla
{
protected string LOG_TAG = "LaserEkspla";
protected readonly Logger LOG = new Logger("LaserEkspla");
public const int MAX_SLAVES = 5;
// Status
protected bool _isConnected = false;
// Laser Config
protected eLaserEksplaDeviceType _laserType { get; set; }
public LaserEksplaConfig Config { get; set; }
protected LaserEksplaObject _laserObj;
private string GetFuncName()
{
System.Diagnostics.StackFrame stackFrameForFunc = new System.Diagnostics.StackFrame(1);
return stackFrameForFunc.GetMethod().Name;
}
public LaserDeviceEkspla(string deviceId, eLaserEksplaDeviceType type)
{
DeviceId = deviceId;
Type = DeviceType.Etc;
CommType = CommunicationType.Serial;
_laserType = type;
}
protected override int DoActivate(IDeviceConfig config)
{
Config = config as LaserEksplaConfig;
return ActivateDevice();
//LOG.I(GetFuncName() + " enter");
//_config = config as LaserEksplaConfig;
//_laserObj = new LaserNL202(DeviceId, config as LaserEksplaConfig);
//_laserObj.Connect();
//return _laserObj.GetConnected() ? E1.OK : E2.NOT_CONNECTED;
}
protected override int DoDeactivate()
{
return DeactivateDevice();
//LOG.I(GetFuncName() + " enter");
//_laserObj.Disconnect();
//IsSimul = false;
//return E1.OK;
}
public int ActivateDevice()
{
LOG.I(GetFuncName() + " enter");
_laserObj = new LaserNL202(DeviceId, Config, IsSimul);
_laserObj.Connect();
return _laserObj.GetConnected() ? E1.OK : E2.NOT_CONNECTED;
}
public int DeactivateDevice()
{
LOG.I(GetFuncName() + " enter");
_laserObj.Disconnect();
IsSimul = false;
return E1.OK;
}
public double GetTemperature(int diode)
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return _laserObj.GetTemperature(diode);
} else {
return -1;
}
}
public bool GetLastError(ref int errorCode, ref string errorMsg)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.GetLastError(ref errorCode, ref errorMsg);
} else {
return false;
}
}
public void SetError(int errorCode, string errorMsg)
{
if (!IsActivated) {
return;
}
if (_laserObj is LaserNL202) {
_laserObj.SetError(errorCode, errorMsg);
} else {
return;
}
}
public bool RunLaser()
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.RunLaser();
} else {
return false;
}
}
public bool StartBurstShot()
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.StartBurstShot();
} else {
return false;
}
}
public bool StopLaser() // Laser 상태를 Stop
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.StopLaser();
} else {
return false;
}
}
public bool StopShot() // 쏘고있는 Laser를 Stop
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.StopShot();
} else {
return false;
}
}
public bool ResetFault()
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.ResetFault();
} else {
return false;
}
}
public bool SetPumpLevel(double dValue)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetPumpLevel(dValue);
} else {
return false;
}
}
public bool SetBurstCount(int nBurst)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetBurstCount(nBurst);
} else {
return false;
}
}
public bool SetBurstMode(int nFireMode)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetBurstMode(nFireMode);
} else {
return false;
}
}
public bool SetRepetitionRate(int nRepetition)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetRepetitionRate(nRepetition);
} else {
return false;
}
}
public bool SetEnergyLevel(int nMod)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetEnergyLevel(nMod);
} else {
return false;
}
}
public bool SetWaveLength(int nWaveLength)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetWaveLength(nWaveLength);
} else {
return false;
}
}
public bool SetAttenuator(double dValue)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetAttenuator(dValue);
} else {
return false;
}
}
public bool SetSyncMode(int nMode)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetSyncMode(nMode);
} else {
return false;
}
}
//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;
}
if (_laserObj is LaserNL202) {
return _laserObj.SetLaserParam(nIndex, dValue);
} else {
return false;
}
}
public bool GetLaserParam(int nIndex)
{
if (!IsActivated) {
return false;
}
if (_laserObj is LaserNL202) {
return _laserObj.GetLaserParam(nIndex);
} else {
return false;
}
}
public void CheckLaserParmeter(int nSynMode, int nBurstMode, int nBurstCount, int nWaveLength, int nRepetitionRate, double dAtt)
{
if (!IsActivated) {
return;
}
if (_laserObj is LaserNL202) {
_laserObj.CheckLaserParmeter(nSynMode, nBurstMode, nBurstCount, nWaveLength, nRepetitionRate, dAtt);
} else {
return;
}
}
public int GetState()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetState();
} else {
return -1;
}
}
public double GetPumpLevel()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetPumpLevel();
} else {
return 0;
}
}
public int GetBurstMode()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetBurstMode();
} else {
return -1;
}
}
public int GetBurstCount()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetBurstCount();
} else {
return -1;
}
}
public double GetAttTrans()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetAttTrans();
} else {
return 0;
}
}
public int GetRepetitionRate()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetRepetitionRate();
} else {
return -1;
}
}
public int GetWaveLength()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetWaveLength();
} else {
return -1;
}
}
public int GetEnergyLevel()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetEnergyLevel();
} else {
return -1;
}
}
public int GetSyncMode()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetSyncMode();
} else {
return -1;
}
}
public int GetQSWadjDelay()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetQSWadjDelay();
} else {
return -1;
}
}
public int GetShotCnt()
{
if (!IsActivated) {
return -1;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetShotCnt();
} else {
return -1;
}
}
///////////////////////////////////////////////////////////
// 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;
}
if (_laserObj is LaserNL202) {
return (_laserObj as LaserNL202).GetConnected();
} else {
return false;
}
}
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();
}
}
}