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