319 lines
7.7 KiB
C#
319 lines
7.7 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using AuroraLaser.Amplitude.Satsuma;
|
|
using AuroraLaser.Coherent.Arm;
|
|
using Hermes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static AuroraLaser.IPG.YLPN.LaserYLPNSerialConn;
|
|
|
|
namespace AuroraLaser.IPG.YLPN
|
|
{
|
|
public class LaserDeviceYLPN : Device, ILaserDeviceIPG
|
|
{
|
|
protected Logger Log = new Logger("LaserDeviceYLPN");
|
|
|
|
public LaserYLPNConfig Config { get; set; }
|
|
|
|
private LaserYLPNSerialConn _laserYLPNSerialConn;
|
|
|
|
public LaserDeviceYLPN(string deviceId)
|
|
{
|
|
CommType = CommunicationType.Serial;
|
|
DeviceId = deviceId;
|
|
}
|
|
|
|
protected override int DoActivate(IDeviceConfig config)
|
|
{
|
|
Config = config as LaserYLPNConfig;
|
|
return ActivateDevice();
|
|
|
|
//Config = config as LaserYLPNConfig;
|
|
|
|
//if (IsActivated) {
|
|
// return E1.OK;
|
|
//}
|
|
//if (Config.IsSimul) {
|
|
// return E1.OK;
|
|
//}
|
|
|
|
//_laserYLPNSerialConn = new LaserYLPNSerialConn(DeviceId, IsSimul);
|
|
|
|
//if (_laserYLPNSerialConn == null) {
|
|
// Log.E(string.Format("LaserObj is Null"));
|
|
// return E1.ARGUMENT;
|
|
//}
|
|
//return _laserYLPNSerialConn.Open(Config.ConnConfig as SerialConnConfig);
|
|
}
|
|
|
|
protected override int DoDeactivate()
|
|
{
|
|
return DeactivateDevice();
|
|
|
|
//if (IsSimul) {
|
|
// return E1.OK;
|
|
//}
|
|
//if (_laserYLPNSerialConn != null) {
|
|
// _laserYLPNSerialConn.DisConnect();
|
|
//}
|
|
|
|
//return E1.OK;
|
|
}
|
|
|
|
public int ActivateDevice()
|
|
{
|
|
if (IsActivated || IsActivated_InAllLaserDevice) {
|
|
return E1.OK;
|
|
}
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
|
|
_laserYLPNSerialConn = new LaserYLPNSerialConn(DeviceId, IsSimul);
|
|
|
|
if (_laserYLPNSerialConn == null) {
|
|
Log.E(string.Format("LaserObj is Null"));
|
|
return E1.ARGUMENT;
|
|
}
|
|
return _laserYLPNSerialConn.Open(Config.ConnConfig as SerialConnConfig);
|
|
}
|
|
|
|
public int DeactivateDevice()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (_laserYLPNSerialConn != null) {
|
|
_laserYLPNSerialConn.DisConnect();
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// 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;
|
|
}
|
|
if (_laserYLPNSerialConn == null) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int LaserOn()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserYLPNSerialConn.SetEmissionEnable(true);
|
|
}
|
|
|
|
public int LaserOff()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserYLPNSerialConn.SetEmissionEnable(false);
|
|
}
|
|
|
|
public int PilotLaserOn()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
bool result = _laserYLPNSerialConn.SetGuideLaser(true);
|
|
if (result != true) {
|
|
return E1.GENERIC; ;
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
public int PilotLaserOff()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
bool result = _laserYLPNSerialConn.SetGuideLaser(false);
|
|
if (result != true) {
|
|
return E1.GENERIC; ;
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
public bool GetPilotLaserStatus()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
// 업데이트 예정
|
|
return false;
|
|
}
|
|
|
|
public bool GetLaserReady()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
// 업데이트 예정
|
|
return false;
|
|
}
|
|
|
|
public bool GetPilotLaserSetBitStatus()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
// Pilot Laser On 명령.
|
|
// 업데이트 예정
|
|
return false;
|
|
}
|
|
|
|
public bool GetConnected()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
return _laserYLPNSerialConn.IsConnected();
|
|
}
|
|
|
|
public int SetData(int nTarget, int value)
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserYLPNSerialConn.SendCommand((eSetCommand)nTarget, value) ? E1.OK : E2.ABORTED;
|
|
}
|
|
|
|
public int ResetLaser()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
// 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();
|
|
}
|
|
|
|
}
|
|
}
|