431 lines
11 KiB
C#
431 lines
11 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using AuroraLaser.Amplitude.Satsuma;
|
|
using AuroraLaser.Coherent.RapidLX;
|
|
using AuroraLaser.Ekspla.NL202;
|
|
using Hermes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Documents;
|
|
|
|
namespace AuroraLaser.Coherent.Arm
|
|
{
|
|
public class LaserDeviceArm : Device, ILaserDeviceCoherent
|
|
{
|
|
protected Logger Log = new Logger("LaserDeviceArm");
|
|
|
|
public LaserArmConfig Config { get; set; }
|
|
private LaserArmSocketConn _laserArmSocktConn;
|
|
|
|
public LaserDeviceArm(string deviceId)
|
|
{
|
|
CommType = CommunicationType.Socket;
|
|
DeviceId = deviceId;
|
|
}
|
|
|
|
protected override int DoActivate(IDeviceConfig config)
|
|
{
|
|
Config = config as LaserArmConfig;
|
|
return ActivateDevice();
|
|
|
|
//Config = config as LaserArmConfig;
|
|
|
|
//if (IsActivated) {
|
|
// return E1.OK;
|
|
//}
|
|
//if (Config.IsSimul) {
|
|
// return E1.OK;
|
|
//}
|
|
|
|
//_laserArmSocktConn = new LaserArmSocketConn(DeviceId, IsSimul, SocketProtocol.UDP);
|
|
|
|
//if (_laserArmSocktConn == null) {
|
|
// Log.E(string.Format("LaserObj is Null"));
|
|
// return E1.ARGUMENT;
|
|
//}
|
|
//return _laserArmSocktConn.Open(Config);
|
|
}
|
|
|
|
protected override int DoDeactivate()
|
|
{
|
|
return DeactivateDevice();
|
|
|
|
//if (IsSimul) {
|
|
// return E1.OK;
|
|
//}
|
|
//if (_laserArmSocktConn != null) {
|
|
// _laserArmSocktConn.DisConnect();
|
|
//}
|
|
|
|
//return E1.OK;
|
|
}
|
|
|
|
public int ActivateDevice()
|
|
{
|
|
if (IsActivated || IsActivated_InAllLaserDevice) {
|
|
return E1.OK;
|
|
}
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
|
|
_laserArmSocktConn = new LaserArmSocketConn(DeviceId, IsSimul, SocketProtocol.UDP);
|
|
|
|
if (_laserArmSocktConn == null)
|
|
{
|
|
Log.E(string.Format("LaserObj is Null"));
|
|
return E1.ARGUMENT;
|
|
}
|
|
|
|
return _laserArmSocktConn.Open(Config);
|
|
}
|
|
|
|
public int DeactivateDevice()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return E1.OK;
|
|
}
|
|
if (_laserArmSocktConn != null)
|
|
{
|
|
_laserArmSocktConn.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 (_laserArmSocktConn == null) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int LaserOn()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserArmSocktConn.LaserOn();
|
|
}
|
|
|
|
public int LaserOff()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserArmSocktConn.LaserOff();
|
|
}
|
|
|
|
public int PilotLaserOn()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserArmSocktConn.PilotLaserOn();
|
|
}
|
|
|
|
public int PilotLaserOff()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserArmSocktConn.PilotLaserOff();
|
|
}
|
|
|
|
public bool GetPilotLaserStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
return _laserArmSocktConn.GetPilotLaserStatus();
|
|
}
|
|
|
|
public bool GetLaserReady()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
return _laserArmSocktConn.GetLaserReady();
|
|
}
|
|
|
|
public bool GetPilotLaserSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
return _laserArmSocktConn.GetPilotLaserSetBitStatus();
|
|
}
|
|
|
|
public bool GetConnected()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return false;
|
|
}
|
|
|
|
return _laserArmSocktConn.GetConnected();
|
|
}
|
|
public string GetControlMode()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return "";
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return "";
|
|
//}
|
|
|
|
return _laserArmSocktConn.GetControlMode();
|
|
}
|
|
public bool GetControlModeSetStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
|
|
return _laserArmSocktConn.GetControlModeSetStatus();
|
|
}
|
|
|
|
public bool GetEmissionStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
|
|
return _laserArmSocktConn.GetEmissionStatus();
|
|
}
|
|
|
|
public bool GetEStop()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetEStop();
|
|
}
|
|
|
|
public bool GetInitCommunication()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetInitCommunication();
|
|
}
|
|
public bool GetLaserError()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return false;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetLaserError();
|
|
}
|
|
|
|
public bool GetLaserResetSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return false;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetLaserResetSetBitStatus();
|
|
}
|
|
|
|
public bool GetLaserStartSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return false;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetLaserStartSetBitStatus();
|
|
}
|
|
|
|
public string GetPowerCenter()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return "";
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return "";
|
|
//}
|
|
|
|
return _laserArmSocktConn.GetPowerCenter();
|
|
}
|
|
public string GetPowerRing()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return "";
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return "";
|
|
//}
|
|
|
|
return _laserArmSocktConn.GetPowerRing();
|
|
}
|
|
|
|
public bool GetStartLaserSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return false;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetStartLaserSetBitStatus();
|
|
}
|
|
|
|
public bool GetWarningStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return false;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null)
|
|
//{
|
|
// return false;
|
|
//}
|
|
return _laserArmSocktConn.GetWarningStatus();
|
|
}
|
|
|
|
public int SetData(int nTarget, int value)
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserArmSocktConn.SetData(nTarget, value);
|
|
}
|
|
|
|
public int ResetLaser()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _laserArmSocktConn.ResetLaser();
|
|
}
|
|
|
|
|
|
public string GetErrorMessage()
|
|
{
|
|
if (IsSimul) {
|
|
return "";
|
|
}
|
|
if (CanCallLaserFunction() == false) {
|
|
return "";
|
|
}
|
|
|
|
return _laserArmSocktConn.GetErrorMessage();
|
|
}
|
|
public List<string> GetErrorMessages()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return null;
|
|
}
|
|
//if (IsActivated == false || _laserArmSocktConn == null) {
|
|
// return "";
|
|
//}
|
|
|
|
return _laserArmSocktConn.GetErrorMessages();
|
|
}
|
|
public bool GetLaserInterlock()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|