113 lines
3.2 KiB
C#
113 lines
3.2 KiB
C#
using Aurora;
|
|
using Aurora.Api;
|
|
using AuroraDeviceCommon.Utils;
|
|
using AuroraIO;
|
|
using AuroraLaser;
|
|
using Hermes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static AuroraIO.AJINEXTEK.AjinIO.IOModuleInfo;
|
|
using static WeldingCommon.Devices.Laser.PAIX_PrismaticScanner;
|
|
|
|
namespace WeldingCommon.Devices.Laser
|
|
{
|
|
public class PAIX_PrismaticScanner : IODevice
|
|
{
|
|
public PAIX_PrismaticScanner(IAuroraEnvironment auroraEnv, string deviceId, bool isSimul) : base(auroraEnv, deviceId, isSimul)
|
|
{
|
|
|
|
}
|
|
public int WriteDoBit(ePrismaticDOAddress index, bool bit) => _iOUnit.WriteDoBit((int)index, bit);
|
|
public bool ReadDiBit(ePrismaticDIAddress index) => _iOUnit.ReadDiBit((int)index);
|
|
|
|
public enum ePrismaticDIAddress
|
|
{
|
|
CoreLaser_Laser_Ready = 9,
|
|
CoreLaser_Error_State,
|
|
CoreLaser_Laser_Output_State,
|
|
CoreLaser_Control_Status,
|
|
RingLaser_Laser_Ready,
|
|
RingLaser_Error_State,
|
|
RingLaser_Laser_Output_State,
|
|
RingLaser_Control_Status = 23,
|
|
}
|
|
public enum ePrismaticDOAddress
|
|
{
|
|
CoreLaser_Control = 9,
|
|
CoreLaser_ErrorClearing,
|
|
RingLaser_Control = 13,
|
|
RingLaser_ErrorClearing,
|
|
EX_Red_Control = 17,
|
|
}
|
|
}
|
|
public class LaserIOControl : Device
|
|
{
|
|
PAIX_PrismaticScanner _ioBoard;
|
|
public IODevice _IOLaser;
|
|
public IOUnit _iOUnit;
|
|
|
|
public LaserIOControl(PAIX_PrismaticScanner io)
|
|
{
|
|
_IOLaser = io;
|
|
_ioBoard = io;
|
|
_iOUnit = io._iOUnit;
|
|
}
|
|
protected override int DoActivate(IDeviceConfig config)
|
|
{
|
|
if (_ioBoard.IsActivated)
|
|
return E1.OK;
|
|
|
|
return E2.NOT_CONNECTED;
|
|
}
|
|
|
|
protected override int DoDeactivate()
|
|
{
|
|
return E1.OK;
|
|
}
|
|
|
|
public int SetEmmision(bool on)
|
|
{
|
|
_ioBoard.WriteDO(1, on);
|
|
return E1.OK;
|
|
}
|
|
|
|
public bool GetLaserReady()
|
|
{
|
|
bool coreReady = false;
|
|
bool ringReady = false;
|
|
GetLaserDIStatus(ePrismaticDIAddress.CoreLaser_Laser_Ready, out coreReady);
|
|
GetLaserDIStatus(ePrismaticDIAddress.RingLaser_Laser_Ready, out ringReady);
|
|
|
|
return coreReady && ringReady;
|
|
}
|
|
public int GetLaserDevice(ref IODevice _IOLaser)
|
|
{
|
|
if (IsActivated == false || _ioBoard == null)
|
|
{
|
|
return E1.GENERIC;
|
|
}
|
|
_IOLaser = _ioBoard;
|
|
return E1.OK;
|
|
}
|
|
private bool GetLaserDIStatus(ePrismaticDIAddress addr, out bool bValue)
|
|
{
|
|
|
|
bool[] arrDI = new bool[Convert.ToInt32(_IOLaser._iOUnit.GetDICount())];
|
|
int nRet = _IOLaser._iOUnit.GetDiArray(ref arrDI);
|
|
if (nRet == E1.OK && arrDI.Length != 0)
|
|
{
|
|
bValue = arrDI[Convert.ToInt32(addr)];
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
bValue = false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|