2026-06-05 13:44:39 +09:00

1526 lines
74 KiB
C#

using Aurora.Api.Devices;
using Opc.Ua;
using Opc.Ua.Client;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace AuroraLaser
{
class LaserTrueDisk : SocketConn, ILaser
{
private Session _session = null;
private Subscription _subscription = null;
public string strServerAddress = "opc.tcp://192.0.2.1:4840";
public string strID = "070";
public string strPW = "070f467";
public bool IsConnect = false;
private bool _IsSimul;
public enum eSeqStep : int
{
SEQ_NONE = 0,
SEQ_LASER_ON_START,
SEQ_LASER_ON_EXT_ACTIVE_CHK,
SEQ_LASER_RESET_ON_CHK,
SEQ_LASER_RESET_ON_DELAY,
SEQ_LASER_RESET_OFF_CHK,
SEQ_LASER_ON_LASER_ON_CHK,
SEQ_LASER_ON_READY_CHK,
SEQ_LASER_ON_DYNAMIC_ON_CHK,
SEQ_LASER_ON_PROG_ACTIVE_CHK,
SEQ_LASER_OFF_START,
SEQ_LASER_OFF_PROG_STOP_ON_CHK,
SEQ_LASER_OFF_PROG_STOP_ON_DELAY,
SEQ_LASER_OFF_PROG_STOP_OFF_CHK,
SEQ_LASER_PILOT_LASER_ON_START,
SEQ_LASER_PILOT_LASER_ON_EXT_ACTIVE_CHK,
SEQ_LASER_PILOT_LASER_ON_RESET_ON_CHK,
SEQ_LASER_PILOT_LASER_ON_RESET_ON_DELAY,
SEQ_LASER_PILOT_LASER_ON_RESET_OFF_CHK,
SEQ_LASER_PILOT_LASER_ON_PILOT_LASER_ON_CHK,
SEQ_LASER_PILOT_LASER_OFF_START,
SEQ_LASER_PILOT_LASER_OFF_CHK,
SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_ON_CHK,
SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_DELAY,
SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_OFF_CHK,
};
private eSeqStep nSequence;
public eLaserStatus nLaserStatus;
public bool AutoProgramStart { get; set; } = false;
Thread m_threadTrueDiskSeq = null;
List<NodeId> readNodeIdList = null;
List<NodeId> writeNodeIdList = null;
// Read/Write node information
public sNodeInfo[] ReadNode = new sNodeInfo[100];
public sNodeInfo[] WriteNode = new sNodeInfo[100];
protected readonly object readNodeLock = new object();
protected readonly object writeNodeLock = new object();
public LaserTrueDisk(string deviceid, bool isSimul, SocketProtocol type, bool isCallBack = false) : base(deviceid, isSimul, type)
{
_IsSimul = isSimul;
nLaserStatus = eLaserStatus.STATUS_NONE;
nSequence = eSeqStep.SEQ_NONE;
for (int i = 0; i < 100; i++) {
ReadNode[i].nExist = 0;
ReadNode[i].IsCallBack = isCallBack ? 1 : 0;
ReadNode[i].nDigit = 1;
ReadNode[i].priority = 1; // 기본값
WriteNode[i].nExist = 0;
WriteNode[i].IsCallBack = isCallBack ? 1 : 0;
WriteNode[i].nDigit = 1;
ReadNode[i].priority = 1; // 기본값
}
string strHead = "ns=2;s=";
//---------- Read NODE
ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.EXT_ACTIVATION_ACTIV";
ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].strDisplayNodeName = "EXT ACTIVATION ACTIVE";
ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].nExist = 1;
ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].strKey = "0";
ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].priority = 0;
ReadNode[csReadNodeNo.LASER_WARNING_LAMP_IS_ON].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.LASER_WARNINGLAMP_IS_ON";
ReadNode[csReadNodeNo.LASER_WARNING_LAMP_IS_ON].strDisplayNodeName = "LASER WARNING LAMP IS ON";
ReadNode[csReadNodeNo.LASER_WARNING_LAMP_IS_ON].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.LASER_WARNING_LAMP_IS_ON].nExist = 1;
ReadNode[csReadNodeNo.LASER_WARNING_LAMP_IS_ON].strKey = "1";
ReadNode[csReadNodeNo.LASER_WARNING_LAMP_IS_ON].priority = 0;
ReadNode[csReadNodeNo.LASER_READY].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.LASER_READY";
ReadNode[csReadNodeNo.LASER_READY].strDisplayNodeName = "LASER READY";
ReadNode[csReadNodeNo.LASER_READY].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.LASER_READY].nExist = 1;
ReadNode[csReadNodeNo.LASER_READY].strKey = "2";
ReadNode[csReadNodeNo.LASER_READY].priority = 0;
ReadNode[csReadNodeNo.LASER_IS_ON].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.LASER_IS_ON";
ReadNode[csReadNodeNo.LASER_IS_ON].strDisplayNodeName = "LASER IS ON";
ReadNode[csReadNodeNo.LASER_IS_ON].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.LASER_IS_ON].nExist = 1;
ReadNode[csReadNodeNo.LASER_IS_ON].strKey = "3";
ReadNode[csReadNodeNo.LASER_IS_ON].priority = 0;
ReadNode[csReadNodeNo.LASER_ASSIGNED].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.LASER_ASSIGNED";
ReadNode[csReadNodeNo.LASER_ASSIGNED].strDisplayNodeName = "LASER ASSIGNED";
ReadNode[csReadNodeNo.LASER_ASSIGNED].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.LASER_ASSIGNED].nExist = 1;
ReadNode[csReadNodeNo.LASER_ASSIGNED].strKey = "4";
ReadNode[csReadNodeNo.LASER_ASSIGNED].priority = 0;
ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.PILOT_LASER_IS_ON";
ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].strDisplayNodeName = "PILOT LASER IS ON";
ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].nExist = 1;
ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].strKey = "5";
ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].priority = 0;
ReadNode[csReadNodeNo.PROG_COMPLETED].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.PROG_COMPLETED";
ReadNode[csReadNodeNo.PROG_COMPLETED].strDisplayNodeName = "PROG COMPLETED";
ReadNode[csReadNodeNo.PROG_COMPLETED].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.PROG_COMPLETED].nExist = 1;
ReadNode[csReadNodeNo.PROG_COMPLETED].strKey = "6";
ReadNode[csReadNodeNo.PROG_COMPLETED].priority = 0;
ReadNode[csReadNodeNo.FAULT_LASER].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.FAULT_LASER";
ReadNode[csReadNodeNo.FAULT_LASER].strDisplayNodeName = "FAULT LASER";
ReadNode[csReadNodeNo.FAULT_LASER].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.FAULT_LASER].nExist = 1;
ReadNode[csReadNodeNo.FAULT_LASER].strKey = "7";
ReadNode[csReadNodeNo.FAULT_LASER].priority = 0;
ReadNode[csReadNodeNo.PROG_ACTIVE].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.PROG_ACTIV";
ReadNode[csReadNodeNo.PROG_ACTIVE].strDisplayNodeName = "PROG ACTIVE";
ReadNode[csReadNodeNo.PROG_ACTIVE].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.PROG_ACTIVE].nExist = 1;
ReadNode[csReadNodeNo.PROG_ACTIVE].strKey = "8";
ReadNode[csReadNodeNo.PROG_ACTIVE].priority = 0;
ReadNode[csReadNodeNo.PROG_CANCELLED].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.PROG_CANCELLED";
ReadNode[csReadNodeNo.PROG_CANCELLED].strDisplayNodeName = "PROG CANCELLED";
ReadNode[csReadNodeNo.PROG_CANCELLED].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.PROG_CANCELLED].nExist = 1;
ReadNode[csReadNodeNo.PROG_CANCELLED].strKey = "9";
ReadNode[csReadNodeNo.PROG_CANCELLED].priority = 0;
ReadNode[csReadNodeNo.PROGRAM_NO].strNodeName = strHead + "ProgramNo";
ReadNode[csReadNodeNo.PROGRAM_NO].strDisplayNodeName = "PROGRAM NO";
ReadNode[csReadNodeNo.PROGRAM_NO].nNodeType = csNodeType.UINT16;
ReadNode[csReadNodeNo.PROGRAM_NO].nExist = 1;
ReadNode[csReadNodeNo.PROGRAM_NO].strKey = "10";
ReadNode[csReadNodeNo.PROGRAM_NO].priority = 0;
ReadNode[csReadNodeNo.PROGRAM_LINE_NO].strNodeName = strHead + "ProgramLineNo";
ReadNode[csReadNodeNo.PROGRAM_LINE_NO].strDisplayNodeName = "PROGRAM LINE NO";
ReadNode[csReadNodeNo.PROGRAM_LINE_NO].nNodeType = csNodeType.UINT16;
ReadNode[csReadNodeNo.PROGRAM_LINE_NO].nExist = 1;
ReadNode[csReadNodeNo.PROGRAM_LINE_NO].strKey = "11";
ReadNode[csReadNodeNo.PROGRAM_LINE_NO].priority = 0;
ReadNode[csReadNodeNo.MAINTENANCE].strNodeName = strHead + "Production.MPI-Slot04.Output.Word03.MAINTENANCE";
ReadNode[csReadNodeNo.MAINTENANCE].strDisplayNodeName = "MAINTENANCE";
ReadNode[csReadNodeNo.MAINTENANCE].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.MAINTENANCE].nExist = 1;
ReadNode[csReadNodeNo.MAINTENANCE].strKey = "16";
ReadNode[csReadNodeNo.MONITORING].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.MONITORING";
ReadNode[csReadNodeNo.MONITORING].strDisplayNodeName = "MONITORING";
ReadNode[csReadNodeNo.MONITORING].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.MONITORING].nExist = 1;
ReadNode[csReadNodeNo.MONITORING].strKey = "17";
ReadNode[csReadNodeNo.MONITORING].priority = 0;
ReadNode[csReadNodeNo.POWER_LIMIT].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.POWER_LIMIT";
ReadNode[csReadNodeNo.POWER_LIMIT].strDisplayNodeName = "POWER LIMIT";
ReadNode[csReadNodeNo.POWER_LIMIT].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.POWER_LIMIT].nExist = 1;
ReadNode[csReadNodeNo.POWER_LIMIT].strKey = "18";
ReadNode[csReadNodeNo.SIK_OPEN].strNodeName = strHead + "Production.MPI-Slot04.Output.Word00.SIK_OPEN";
ReadNode[csReadNodeNo.SIK_OPEN].strDisplayNodeName = "SIK OPEN";
ReadNode[csReadNodeNo.SIK_OPEN].nNodeType = csNodeType.BOOL;
ReadNode[csReadNodeNo.SIK_OPEN].nExist = 1;
ReadNode[csReadNodeNo.SIK_OPEN].strKey = "21";
ReadNode[csReadNodeNo.PULSE_POWER].strNodeName = strHead + "PulseData.PulsePower";
ReadNode[csReadNodeNo.PULSE_POWER].strDisplayNodeName = "PULSE POWER";
ReadNode[csReadNodeNo.PULSE_POWER].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.PULSE_POWER].nExist = 1;
ReadNode[csReadNodeNo.PULSE_POWER].nDigit = 1000;
ReadNode[csReadNodeNo.PULSE_POWER].strKey = "26";
ReadNode[csReadNodeNo.PULSE_POWER_NOMINAL].strNodeName = strHead + "PulseData.PulsePowerNominal";
ReadNode[csReadNodeNo.PULSE_POWER_NOMINAL].strDisplayNodeName = "PULSE POWER NOMINAL";
ReadNode[csReadNodeNo.PULSE_POWER_NOMINAL].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.PULSE_POWER_NOMINAL].nExist = 1;
ReadNode[csReadNodeNo.PULSE_POWER_NOMINAL].nDigit = 1000;
ReadNode[csReadNodeNo.PULSE_POWER_NOMINAL].strKey = "27";
ReadNode[csReadNodeNo.CW_POWER].strNodeName = strHead + "PulseData.CwPower";
ReadNode[csReadNodeNo.CW_POWER].strDisplayNodeName = "CW POWER";
ReadNode[csReadNodeNo.CW_POWER].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.CW_POWER].nExist = 1;
ReadNode[csReadNodeNo.CW_POWER].strKey = "28";
ReadNode[csReadNodeNo.POWER].strNodeName = strHead + "PulseData.Power";
ReadNode[csReadNodeNo.POWER].strDisplayNodeName = "POWER";
ReadNode[csReadNodeNo.POWER].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.POWER].nExist = 1;
ReadNode[csReadNodeNo.POWER].strKey = "29";
ReadNode[csReadNodeNo.ENERGEY].strNodeName = strHead + "PulseData.Energy";
ReadNode[csReadNodeNo.ENERGEY].strDisplayNodeName = "ENERGY";
ReadNode[csReadNodeNo.ENERGEY].nNodeType = csNodeType.UINT64;
ReadNode[csReadNodeNo.ENERGEY].nExist = 1;
ReadNode[csReadNodeNo.ENERGEY].strKey = "30";
ReadNode[csReadNodeNo.FREQUENCY].strNodeName = strHead + "PulseData.Frequency";
ReadNode[csReadNodeNo.FREQUENCY].strDisplayNodeName = "FREQUENCY";
ReadNode[csReadNodeNo.FREQUENCY].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.FREQUENCY].nExist = 1;
ReadNode[csReadNodeNo.FREQUENCY].strKey = "31";
ReadNode[csReadNodeNo.FREQUENCY_NOMINAL].strNodeName = strHead + "PulseData.FrequencyNominal";
ReadNode[csReadNodeNo.FREQUENCY_NOMINAL].strDisplayNodeName = "FREQUENCY NOMINAL";
ReadNode[csReadNodeNo.FREQUENCY_NOMINAL].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.FREQUENCY_NOMINAL].nExist = 1;
ReadNode[csReadNodeNo.FREQUENCY_NOMINAL].strKey = "32";
ReadNode[csReadNodeNo.PULSE_DURATION].strNodeName = strHead + "PulseData.PulseDuration";
ReadNode[csReadNodeNo.PULSE_DURATION].strDisplayNodeName = "PULSE DURATION";
ReadNode[csReadNodeNo.PULSE_DURATION].nNodeType = csNodeType.UINT32;
ReadNode[csReadNodeNo.PULSE_DURATION].nExist = 1;
ReadNode[csReadNodeNo.PULSE_DURATION].strKey = "33";
ReadNode[csReadNodeNo.PULSE_DURATION_NOMINAL].strNodeName = strHead + "PulseData.PulseDurationNominal";
ReadNode[csReadNodeNo.PULSE_DURATION_NOMINAL].strDisplayNodeName = "PULSE DURATION NOMINAL";
ReadNode[csReadNodeNo.PULSE_DURATION_NOMINAL].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.PULSE_DURATION_NOMINAL].nExist = 1;
ReadNode[csReadNodeNo.PULSE_DURATION_NOMINAL].strKey = "34";
ReadNode[csReadNodeNo.PULSE_NUMBER].strNodeName = strHead + "PulseData.PulseNumber";
ReadNode[csReadNodeNo.PULSE_NUMBER].strDisplayNodeName = "PULSE NUMBER";
ReadNode[csReadNodeNo.PULSE_NUMBER].nNodeType = csNodeType.UINT16;
ReadNode[csReadNodeNo.PULSE_NUMBER].nExist = 1;
ReadNode[csReadNodeNo.PULSE_NUMBER].strKey = "35";
ReadNode[csReadNodeNo.PULSE_NUMBER_NOMINAL].strNodeName = strHead + "PulseData.PulseNumberNominal";
ReadNode[csReadNodeNo.PULSE_NUMBER_NOMINAL].strDisplayNodeName = "PULSE NUMBER NOMINAL";
ReadNode[csReadNodeNo.PULSE_NUMBER_NOMINAL].nNodeType = csNodeType.UINT16;
ReadNode[csReadNodeNo.PULSE_NUMBER_NOMINAL].nExist = 1;
ReadNode[csReadNodeNo.PULSE_NUMBER_NOMINAL].strKey = "36";
ReadNode[csReadNodeNo.COOLING_DI_PRESSURE_DIFF].strNodeName = strHead + "Cooling.DIPressureDiff";
ReadNode[csReadNodeNo.COOLING_DI_PRESSURE_DIFF].strDisplayNodeName = "DI PRESSURE DIFF";
ReadNode[csReadNodeNo.COOLING_DI_PRESSURE_DIFF].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_DI_PRESSURE_DIFF].nExist = 1;
ReadNode[csReadNodeNo.COOLING_DI_PRESSURE_DIFF].strKey = "37";
ReadNode[csReadNodeNo.COOLING_DI_RETURN_PRESSURE].strNodeName = strHead + "Cooling.DIReturnPressure";
ReadNode[csReadNodeNo.COOLING_DI_RETURN_PRESSURE].strDisplayNodeName = "DI RETURN PRESSURE";
ReadNode[csReadNodeNo.COOLING_DI_RETURN_PRESSURE].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_DI_RETURN_PRESSURE].nExist = 1;
ReadNode[csReadNodeNo.COOLING_DI_RETURN_PRESSURE].strKey = "38";
//CODE.BY.YIS Laser Cool Parameter Log 추가
strHead = "ns=2;s=[B0/01].";
ReadNode[csReadNodeNo.COOLING_PRESSURE_OUT_EXT].strNodeName = strHead + "Rd_CCB_PressureOut_Ext";
ReadNode[csReadNodeNo.COOLING_PRESSURE_OUT_EXT].strDisplayNodeName = "CCB PRESSURE OUT EXT ";
ReadNode[csReadNodeNo.COOLING_PRESSURE_OUT_EXT].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_PRESSURE_OUT_EXT].nExist = 1;
ReadNode[csReadNodeNo.COOLING_PRESSURE_OUT_EXT].strKey = "39";
ReadNode[csReadNodeNo.COOLING_PRESSURE_IN_EXT].strNodeName = strHead + "Rd_CCB_PressureIn_Ext";
ReadNode[csReadNodeNo.COOLING_PRESSURE_IN_EXT].strDisplayNodeName = "CCB PRESSURE IN EXT ";
ReadNode[csReadNodeNo.COOLING_PRESSURE_IN_EXT].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_PRESSURE_IN_EXT].nExist = 1;
ReadNode[csReadNodeNo.COOLING_PRESSURE_IN_EXT].strKey = "40";
ReadNode[csReadNodeNo.COOLING_TEMP_WATER_IN_EXT].strNodeName = strHead + "Rd_CCB_TempWaterIn_Ext";
ReadNode[csReadNodeNo.COOLING_TEMP_WATER_IN_EXT].strDisplayNodeName = "CCB TEMP WATER IN EXT ";
ReadNode[csReadNodeNo.COOLING_TEMP_WATER_IN_EXT].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_TEMP_WATER_IN_EXT].nExist = 1;
ReadNode[csReadNodeNo.COOLING_TEMP_WATER_IN_EXT].strKey = "41";
ReadNode[csReadNodeNo.COOLING_PWM_X30_MV].strNodeName = strHead + "Rd_CCB_PWM_X30_MV";
ReadNode[csReadNodeNo.COOLING_PWM_X30_MV].strDisplayNodeName = "CCB PWM X30 MV ";
ReadNode[csReadNodeNo.COOLING_PWM_X30_MV].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_PWM_X30_MV].nExist = 1;
ReadNode[csReadNodeNo.COOLING_PWM_X30_MV].strKey = "42";
ReadNode[csReadNodeNo.COOLING_TEMP_TANK_SET_TRACKING].strNodeName = strHead + "Rd_CCB_TempTank_Set_Tracking";
ReadNode[csReadNodeNo.COOLING_TEMP_TANK_SET_TRACKING].strDisplayNodeName = "CCB TEMP TANK SET TRACKING ";
ReadNode[csReadNodeNo.COOLING_TEMP_TANK_SET_TRACKING].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_TEMP_TANK_SET_TRACKING].nExist = 1;
ReadNode[csReadNodeNo.COOLING_TEMP_TANK_SET_TRACKING].strKey = "43";
ReadNode[csReadNodeNo.COOLING_TEMP_COOLING_WATER].strNodeName = strHead + "Rd_CCB_TempCoolingWater";
ReadNode[csReadNodeNo.COOLING_TEMP_COOLING_WATER].strDisplayNodeName = "CCB TEMP COOLING WATER ";
ReadNode[csReadNodeNo.COOLING_TEMP_COOLING_WATER].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_TEMP_COOLING_WATER].nExist = 1;
ReadNode[csReadNodeNo.COOLING_TEMP_COOLING_WATER].strKey = "44";
ReadNode[csReadNodeNo.COOLING_PRESSURE_PUMP].strNodeName = strHead + "Rd_CCB_PressurePump";
ReadNode[csReadNodeNo.COOLING_PRESSURE_PUMP].strDisplayNodeName = "CCG PRESSURE PUMP ";
ReadNode[csReadNodeNo.COOLING_PRESSURE_PUMP].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_PRESSURE_PUMP].nExist = 1;
ReadNode[csReadNodeNo.COOLING_PRESSURE_PUMP].strKey = "45";
ReadNode[csReadNodeNo.COOLING_FC_MAX_FREQUENCY].strNodeName = strHead + "Rd_CCB_FC_MaxFrequency";
ReadNode[csReadNodeNo.COOLING_FC_MAX_FREQUENCY].strDisplayNodeName = "CCG FC MAX FREQUENCY ";
ReadNode[csReadNodeNo.COOLING_FC_MAX_FREQUENCY].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_FC_MAX_FREQUENCY].nExist = 1;
ReadNode[csReadNodeNo.COOLING_FC_MAX_FREQUENCY].strKey = "46";
//ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_CM_ACTUAL].strNodeName = strHead + "Rd_CCB_FC_Frequency_CM_actual";
//ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_CM_ACTUAL].strDisplayNodeName = "CCG FC PREQUENCY CM ACTUAL ";
ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_PUMP].strNodeName = strHead + "Rd_CCB_FC_FrequencyPump";
ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_PUMP].strDisplayNodeName = "CCG FC PREQUENCY PUMP ";
ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_PUMP].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_PUMP].nExist = 1;
ReadNode[csReadNodeNo.COOLING_FC_FREQUENCY_PUMP].strKey = "47";
strHead = "ns=2;s=[CE/01].";
ReadNode[csReadNodeNo.COLLING_TEMP_X80].strNodeName = strHead + "Rd_ILD_Temp_X80";
ReadNode[csReadNodeNo.COLLING_TEMP_X80].strDisplayNodeName = "CCG ILD TEMP X80";
ReadNode[csReadNodeNo.COLLING_TEMP_X80].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COLLING_TEMP_X80].nExist = 1;
ReadNode[csReadNodeNo.COLLING_TEMP_X80].strKey = "48";
ReadNode[csReadNodeNo.COLLING_PRES_X90].strNodeName = strHead + "Rd_ILD_Pres_X90";
ReadNode[csReadNodeNo.COLLING_PRES_X90].strDisplayNodeName = "CCG ILD TEMP X90";
ReadNode[csReadNodeNo.COLLING_PRES_X90].nNodeType = csNodeType.DOUBLE;
ReadNode[csReadNodeNo.COLLING_PRES_X90].nExist = 1;
ReadNode[csReadNodeNo.COLLING_PRES_X90].strKey = "49";
strHead = "ns=2;s=[DC/01].";
ReadNode[csReadNodeNo.COLLING_SPEED_FAN].strNodeName = strHead + "Rd_CMD3_Speed_Fan1";
ReadNode[csReadNodeNo.COLLING_SPEED_FAN].strDisplayNodeName = "CCG SPEED FAN";
ReadNode[csReadNodeNo.COLLING_SPEED_FAN].nNodeType = csNodeType.UINT16;
ReadNode[csReadNodeNo.COLLING_SPEED_FAN].nExist = 1;
ReadNode[csReadNodeNo.COLLING_SPEED_FAN].strKey = "50";
//---------- Write NODE
strHead = "ns=2;s=";
WriteNode[csWriteNodeNo.EXT_ACTIVATION].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.EXT_ACTIVATION";
WriteNode[csWriteNodeNo.EXT_ACTIVATION].strDisplayNodeName = "EXT ACTIVATION";
WriteNode[csWriteNodeNo.EXT_ACTIVATION].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.EXT_ACTIVATION].nExist = 1;
WriteNode[csWriteNodeNo.EXT_ACTIVATION].strKey = "100";
WriteNode[csWriteNodeNo.EXT_ACTIVATION].priority = 0;
WriteNode[csWriteNodeNo.LASER_RESET].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.RESET";
WriteNode[csWriteNodeNo.LASER_RESET].strDisplayNodeName = "LASER RESET";
WriteNode[csWriteNodeNo.LASER_RESET].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.LASER_RESET].nExist = 1;
WriteNode[csWriteNodeNo.LASER_RESET].strKey = "101";
WriteNode[csWriteNodeNo.LASER_RESET].priority = 0;
WriteNode[csWriteNodeNo.LASER_ON].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.LASER_ON";
WriteNode[csWriteNodeNo.LASER_ON].strDisplayNodeName = "LASER ON";
WriteNode[csWriteNodeNo.LASER_ON].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.LASER_ON].nExist = 1;
WriteNode[csWriteNodeNo.LASER_ON].strKey = "102";
WriteNode[csWriteNodeNo.LASER_ON].priority = 0;
WriteNode[csWriteNodeNo.PROG_STOP].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.PROG_STOP";
WriteNode[csWriteNodeNo.PROG_STOP].strDisplayNodeName = "PROG STOP";
WriteNode[csWriteNodeNo.PROG_STOP].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.PROG_STOP].nExist = 1;
WriteNode[csWriteNodeNo.PROG_STOP].strKey = "103";
WriteNode[csWriteNodeNo.PROG_STOP].priority = 0;
WriteNode[csWriteNodeNo.PSTART_DYN].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.PSTART_DYN";
WriteNode[csWriteNodeNo.PSTART_DYN].strDisplayNodeName = "PSTART DYN";
WriteNode[csWriteNodeNo.PSTART_DYN].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.PSTART_DYN].nExist = 1;
WriteNode[csWriteNodeNo.PSTART_DYN].strKey = "104";
WriteNode[csWriteNodeNo.PSTART_DYN].priority = 0;
WriteNode[csWriteNodeNo.REQUEST_LASER].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.REQUEST_LASER";
WriteNode[csWriteNodeNo.REQUEST_LASER].strDisplayNodeName = "REQUEST LASER";
WriteNode[csWriteNodeNo.REQUEST_LASER].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.REQUEST_LASER].nExist = 1;
WriteNode[csWriteNodeNo.REQUEST_LASER].strKey = "105";
WriteNode[csWriteNodeNo.REQUEST_LASER].priority = 0;
WriteNode[csWriteNodeNo.PSTART_STATICAL].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.PSTART_STATICAL";
WriteNode[csWriteNodeNo.PSTART_STATICAL].strDisplayNodeName = "PSTART STATICAL";
WriteNode[csWriteNodeNo.PSTART_STATICAL].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.PSTART_STATICAL].nExist = 1;
WriteNode[csWriteNodeNo.PSTART_STATICAL].strKey = "106";
WriteNode[csWriteNodeNo.INQUIRY_1].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.INQUIRY_1";
WriteNode[csWriteNodeNo.INQUIRY_1].strDisplayNodeName = "INQUIRY 1";
WriteNode[csWriteNodeNo.INQUIRY_1].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.INQUIRY_1].nExist = 1;
WriteNode[csWriteNodeNo.INQUIRY_1].strKey = "107";
WriteNode[csWriteNodeNo.INQUIRY_2].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.INQUIRY_2";
WriteNode[csWriteNodeNo.INQUIRY_2].strDisplayNodeName = "INQUIRY 2";
WriteNode[csWriteNodeNo.INQUIRY_2].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.INQUIRY_2].nExist = 1;
WriteNode[csWriteNodeNo.INQUIRY_2].strKey = "108";
WriteNode[csWriteNodeNo.PILOT_LASER_ON].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.PILOT_LASER_ON";
WriteNode[csWriteNodeNo.PILOT_LASER_ON].strDisplayNodeName = "PILOT LASER ON";
WriteNode[csWriteNodeNo.PILOT_LASER_ON].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.PILOT_LASER_ON].nExist = 1;
WriteNode[csWriteNodeNo.PILOT_LASER_ON].strKey = "109";
WriteNode[csWriteNodeNo.PILOT_LASER_ON].priority = 0;
WriteNode[csWriteNodeNo.FAULT_EXT].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.FAULT_EXT";
WriteNode[csWriteNodeNo.FAULT_EXT].strDisplayNodeName = "FAULT EXT";
WriteNode[csWriteNodeNo.FAULT_EXT].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.FAULT_EXT].nExist = 1;
WriteNode[csWriteNodeNo.FAULT_EXT].strKey = "110";
WriteNode[csWriteNodeNo.FAULT_EXT].priority = 0;
WriteNode[csWriteNodeNo.LOCK_OPERATING_PANEL].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word00.LOCK_OPERATING_PANEL";
WriteNode[csWriteNodeNo.LOCK_OPERATING_PANEL].strDisplayNodeName = "LOCK OPERATING PANEL";
WriteNode[csWriteNodeNo.LOCK_OPERATING_PANEL].nNodeType = csNodeType.BOOL;
WriteNode[csWriteNodeNo.LOCK_OPERATING_PANEL].nExist = 1;
WriteNode[csWriteNodeNo.LOCK_OPERATING_PANEL].strKey = "111";
WriteNode[csWriteNodeNo.PROGRAM_NO].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word01.PROGRAM_No";
WriteNode[csWriteNodeNo.PROGRAM_NO].strDisplayNodeName = "PROGRAM NO";
WriteNode[csWriteNodeNo.PROGRAM_NO].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.PROGRAM_NO].nExist = 1;
WriteNode[csWriteNodeNo.PROGRAM_NO].strKey = "112";
WriteNode[csWriteNodeNo.PROGRAM_NO].priority = 0;
WriteNode[csWriteNodeNo.IW03].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word03";
WriteNode[csWriteNodeNo.IW03].strDisplayNodeName = "IW03";
WriteNode[csWriteNodeNo.IW03].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.IW03].nExist = 1;
WriteNode[csWriteNodeNo.IW03].strKey = "113";
WriteNode[csWriteNodeNo.IW03].priority = 0;
WriteNode[csWriteNodeNo.IW04].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word04";
WriteNode[csWriteNodeNo.IW04].strDisplayNodeName = "IW04";
WriteNode[csWriteNodeNo.IW04].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.IW04].nExist = 1;
WriteNode[csWriteNodeNo.IW04].strKey = "114";
WriteNode[csWriteNodeNo.IW04].priority = 0;
WriteNode[csWriteNodeNo.IW05].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word05";
WriteNode[csWriteNodeNo.IW05].strDisplayNodeName = "IW05";
WriteNode[csWriteNodeNo.IW05].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.IW05].nExist = 1;
WriteNode[csWriteNodeNo.IW05].strKey = "115";
WriteNode[csWriteNodeNo.IW05].priority = 0;
WriteNode[csWriteNodeNo.IW06].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word06";
WriteNode[csWriteNodeNo.IW06].strDisplayNodeName = "IW06";
WriteNode[csWriteNodeNo.IW06].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.IW06].nExist = 1;
WriteNode[csWriteNodeNo.IW06].strKey = "116";
WriteNode[csWriteNodeNo.IW06].priority = 0;
WriteNode[csWriteNodeNo.IW07].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word07";
WriteNode[csWriteNodeNo.IW07].strDisplayNodeName = "IW07";
WriteNode[csWriteNodeNo.IW07].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.IW07].nExist = 1;
WriteNode[csWriteNodeNo.IW07].strKey = "117";
WriteNode[csWriteNodeNo.IW07].priority = 0;
WriteNode[csWriteNodeNo.IW08].strNodeName = strHead + "Activation.MPI-Slot04.Input.Word08";
WriteNode[csWriteNodeNo.IW08].strDisplayNodeName = "IW08";
WriteNode[csWriteNodeNo.IW08].nNodeType = csNodeType.UINT16;
WriteNode[csWriteNodeNo.IW08].nExist = 1;
WriteNode[csWriteNodeNo.IW08].strKey = "118";
WriteNode[csWriteNodeNo.IW08].priority = 0;
#region 읽어올 Node ID를 배열에 미리 넣어둔다(ReadNodeData 함수에서 사용)
if (isCallBack) {
readNodeIdList = null;
writeNodeIdList = null;
} else {
readNodeIdList = new List<NodeId>();
for (int nTarget = 0; nTarget < 100; nTarget++) {
if (ReadNode[nTarget].nExist != 1) continue;
else if (ReadNode[nTarget].IsCallBack == 1) continue;
NodeId nodeId = new NodeId(ReadNode[nTarget].strNodeName);
readNodeIdList.Add(nodeId);
}
writeNodeIdList = new List<NodeId>();
for (int nTarget = 0; nTarget < 100; nTarget++) {
if (WriteNode[nTarget].nExist != 1) continue;
else if (WriteNode[nTarget].IsCallBack == 1) continue;
NodeId nodeId = new NodeId(WriteNode[nTarget].strNodeName);
writeNodeIdList.Add(nodeId);
}
}
#endregion
}
public int Open(LaserConfig Config)
{
if (ConnectServer() == 1) {
m_threadTrueDiskSeq = new Thread(new ThreadStart(TrueDiskThread_Seq));
m_threadTrueDiskSeq.Start();
return 1;
} else return 0;
}
public void DisConnect()
{
try {
if (IsConnect == true) {
SetData(csWriteNodeNo.PROG_STOP, 1);
Thread.Sleep(500);
SetData(csWriteNodeNo.PROG_STOP, 0);
SetData(csWriteNodeNo.PSTART_STATICAL, 0);
SetData(csWriteNodeNo.PSTART_DYN, 0);
SetData(csWriteNodeNo.REQUEST_LASER, 0);
SetData(csWriteNodeNo.LASER_ON, 0);
SetData(csWriteNodeNo.EXT_ACTIVATION, 0);
}
if (m_threadTrueDiskSeq != null) {
m_threadTrueDiskSeq.Join(500);
m_threadTrueDiskSeq.Abort();
}
try {
if (IsConnect) {
_session.RemoveSubscription(_subscription);
StatusCode result = _session.Close();
IsConnect = false;
}
} catch (Exception ex) {
throw ex;
}
} catch {
}
IsConnect = false;
return;
}
public bool GetConnected()
{
return IsConnect;
}
public int SetData(int nTarget, int value)
{
if (!IsConnect) return 0;
try {
NodeId nodeId = new NodeId(WriteNode[nTarget].strNodeName);
WriteNodeValue(nodeId, (object)value);
return 1;
} catch (Exception ex) {
throw ex;
}
}
public string GetData(int nTarget)
{
string strRet = "Not Exist";
int nArrayNo;
try {
if (nTarget >= 0 && nTarget < 100) {
lock (readNodeLock) {
nArrayNo = nTarget;
if (ReadNode[nArrayNo].nExist != 1) return strRet;
switch (ReadNode[nArrayNo].nNodeType) {
case csNodeType.INT:
strRet = string.Format("{0:D0}", ReadNode[nArrayNo].nRet);
break;
case csNodeType.DOUBLE:
strRet = string.Format("{0:F2}", ReadNode[nArrayNo].dRet);
break;
case csNodeType.STRING:
strRet = ReadNode[nArrayNo].strRet;
break;
case csNodeType.UINT16:
strRet = string.Format("{0:D0}", (int)ReadNode[nArrayNo].n16Ret);
break;
case csNodeType.UINT32:
strRet = string.Format("{0:D0}", (int)ReadNode[nArrayNo].n32Ret);
break;
case csNodeType.UINT64:
strRet = string.Format("{0:D0}", (int)ReadNode[nArrayNo].n64Ret);
break;
case csNodeType.BOOL:
strRet = ReadNode[nArrayNo].nRet == 1 ? "1" : "0";
break;
case csNodeType.BYTE:
strRet = string.Format("{0:D0}", (int)ReadNode[nArrayNo].nRet);
break;
default:
break;
}
}
} else {
lock (writeNodeLock) {
nArrayNo = nTarget - 100;
if (WriteNode[nArrayNo].nExist != 1) return strRet;
switch (WriteNode[nArrayNo].nNodeType) {
case csNodeType.INT:
strRet = string.Format("{0:D0}", WriteNode[nArrayNo].nRet);
break;
case csNodeType.DOUBLE:
strRet = string.Format("{0:F2}", WriteNode[nArrayNo].dRet);
break;
case csNodeType.STRING:
strRet = WriteNode[nArrayNo].strRet;
break;
case csNodeType.UINT16:
strRet = string.Format("{0:D0}", (int)WriteNode[nArrayNo].n16Ret);
break;
case csNodeType.UINT32:
strRet = string.Format("{0:D0}", (int)WriteNode[nArrayNo].n32Ret);
break;
case csNodeType.UINT64:
strRet = string.Format("{0:D0}", (int)WriteNode[nArrayNo].n64Ret);
break;
case csNodeType.BOOL:
strRet = WriteNode[nArrayNo].nRet == 1 ? "1" : "0";
break;
case csNodeType.BYTE:
strRet = string.Format("{0:D0}", (int)WriteNode[nArrayNo].nRet);
break;
default:
break;
}
}
}
} catch (Exception ex) {
throw ex;
}
return strRet;
}
public int LaserOn()
{
SetLaserOn(true);
return 1;
}
public int LaserOff()
{
SetLaserOn(false);
return 1;
}
public int PilotLaserOn()
{
// thread 가 있는것 같은데, node를 바로 write 하면 되는게 맞는가?
return SetData(csWriteNodeNo.PILOT_LASER_ON, 1);
}
public int PilotLaserOff()
{
// thread 가 있는것 같은데, node를 바로 write 하면 되는게 맞는가?
return SetData(csWriteNodeNo.PILOT_LASER_ON, 0);
}
public bool GetInitCommunication()
{
// 업데이트 예정
return false;
}
public bool GetEmissionStatus()
{
// 업데이트 예정
return false;
}
public bool GetWariningStatus()
{
// 업데이트 예정
return false;
}
// MAINS_STATUS, ERROR_STATUS 는 위에 있음
public bool GetPilotLaserStatus()
{
// 업데이트 예정
return false;
}
public string GetControlMode()
{
// 업데이트 예정
return "";
}
public string GetPowerCenter()
{
// 업데이트 예정
return "";
}
public string GetPowerRing()
{
// 업데이트 예정
return "";
}
#region Set 명령 나간 bit 를 모니터링
public bool GetStartLaserSetBitStatus()
{
// Laser Start 명령
// 업데이트 예정
return false;
}
public bool GetLaserStartSetBitStatus()
{
// Laser On 명령. Laser Emission Ready 를 위한 bit
// 업데이트 예정
return false;
}
public bool GetPilotLaserSetBitStatus()
{
// Pilot Laser On 명령.
// 업데이트 예정
return false;
}
public bool GetLaserResetSetBitStatus()
{
// Laser Reset 명령.
// 업데이트 예정
return false;
}
public bool GetControlModeSetStatus()
{
// Control mode Local(false) Remote(true)
// 업데이트 예정
return false;
}
#endregion
public int ConnectServer() // Connect OPC UA Server, Resist Read Nodes.
{
if (_session != null && _session.Connected) return 2;
#region Opc Ua 새로운 API 사용
try {
ApplicationConfiguration config = new Opc.Ua.ApplicationConfiguration() {
ApplicationName = "OPCClientTest",
ApplicationType = ApplicationType.Client,
SecurityConfiguration = new SecurityConfiguration {
ApplicationCertificate = new CertificateIdentifier(),
AutoAcceptUntrustedCertificates = true,
},
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 },
};
config.Validate(ApplicationType.Client);
if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates) {
config.CertificateValidator.CertificateValidation += (s, ex) => {
ex.Accept = (ex.Error.StatusCode == StatusCodes.BadCertificateUntrusted);
};
}
// 연결 Url 설정
string endpointUrl = strServerAddress;
// 연결 시작(Session 연결)
var userIdentity = new UserIdentity(strID, strPW);
//var selectedEndPoint = CoreClientUtils.SelectEndpoint(endpointUrl, useSecurity: false);
//var endconf = new ConfiguredEndpoint(null, selectedEndPoint, EndpointConfiguration.Create(config)); // version 1
var endconf = new ConfiguredEndpoint(null, new EndpointDescription(endpointUrl)); // version 2
_session = Session.Create(config, endconf, true, "session", 60000, userIdentity, null).GetAwaiter().GetResult();
IsConnect = _session.Connected;
} catch (Exception ex) {
IsConnect = false;
Debug.WriteLine("TruDisk.ConnectServer() - Exception : " + ex.Message);
}
#endregion
if (IsConnect == false) return 0;
System.Threading.Thread.Sleep(500);
RegistReadNodes();
return 1;
}
public int RegistReadNodes()
{
try {
if (_session == null || !_session.Connected) return 0;
if (_subscription != null) {
_session.RemoveSubscription(_subscription);
_subscription = null;
}
// 모니터링 설정
_subscription = new Subscription(_session.DefaultSubscription) {
PublishingEnabled = true,
PublishingInterval = 50, // TruDisk 2021 최소값은 50ms
};
// 모니터링 할 Item List
var listRead = new List<MonitoredItem> { };
var listWrite = new List<MonitoredItem> { };
// List 추가
for (int i = 0; i < 100; i++) {
if (ReadNode[i].nExist == 0) continue;
if (ReadNode[i].IsCallBack != 1) continue;
listRead.Add(new MonitoredItem() {
DisplayName = ReadNode[i].strDisplayNodeName,
StartNodeId = ReadNode[i].strNodeName,
// 단위는 ms, 100ms씩 증가, 0은 Server에서 가능한 가장 빠른 Interval(100ms)로 Sampling
SamplingInterval = ReadNode[i].priority == 0 ? 100 : 1000,
});
}
for (int i = 0; i < 100; i++) {
if (WriteNode[i].nExist == 0) continue;
if (WriteNode[i].IsCallBack != 1) continue;
listWrite.Add(new MonitoredItem() {
DisplayName = WriteNode[i].strDisplayNodeName,
StartNodeId = WriteNode[i].strNodeName,
// 단위는 ms, 100ms씩 증가, 0은 Server에서 가능한 가장 빠른 Interval(100ms)로 Sampling
SamplingInterval = WriteNode[i].priority == 0 ? 100 : 1000,
});
}
// 각각의 Item에 Event 추가
listRead.ForEach(i => i.Notification += new MonitoredItemNotificationEventHandler(OnNotificationRead));
listWrite.ForEach(i => i.Notification += new MonitoredItemNotificationEventHandler(OnNotificationWrite));
// Subscription에 List 추가
_subscription.AddItems(listRead);
_subscription.AddItems(listWrite);
// Session에 Subscription 추가
_session.AddSubscription(_subscription);
// Subscription 생성
_subscription.Create();
} catch (Exception ex) {
throw ex;
}
return 1;
}
private Variant WriteNodeValue(NodeId nodeId, object value)
{
try {
// cast the value to a string.
//object value = TypeInfo.Cast(ValueTB.Text, TypeInfo.Scalars.String, m_sourceType.BuiltInType);
// build list of attributes to read.
WriteValueCollection nodesToWrite = new WriteValueCollection();
WriteValue nodeToWrite = new WriteValue();
nodeToWrite.NodeId = nodeId;
nodeToWrite.AttributeId = Attributes.Value;
// using the WrappedValue instead of the Value property because we know the TypeInfo.
// this makes the assignment more efficient by avoiding reflection to determine type.
//nodeToWrite.Value.WrappedValue = new Variant(value, m_sourceType);
nodeToWrite.Value.WrappedValue = new Variant(value);
nodesToWrite.Add(nodeToWrite);
// override the diagnostic masks (other parameters are set to defaults).
RequestHeader requestHeader = new RequestHeader();
requestHeader.ReturnDiagnostics = (uint)DiagnosticsMasks.All;
// read the attributes.
StatusCodeCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;
ResponseHeader responseHeader = _session.Write(requestHeader, nodesToWrite, out results, out diagnosticInfos);
ClientBase.ValidateResponse(results, nodesToWrite);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToWrite);
// check status.
if (StatusCode.IsBad(results[0])) {
// embed the diagnostic information in a exception.
throw ServiceResultException.Create(results[0], 0, diagnosticInfos, responseHeader.StringTable);
}
// return valid value.
return nodeToWrite.Value.WrappedValue;
} catch (Exception ex) {
throw ex;
}
}
private void OnNotificationRead(MonitoredItem item, MonitoredItemNotificationEventArgs e)
{
try {
MonitoredItemNotification notification = e.NotificationValue as MonitoredItemNotification;
foreach (var value in item.DequeueValues()) {
// 상태가 정상일 경우
if (StatusCode.IsGood(value.StatusCode)) {
lock (readNodeLock) {
int nArrayNo = -1;
for (int i = 0; i < 100; i++) {
if (ReadNode[i].nExist == 1 && ReadNode[i].strDisplayNodeName == item.DisplayName) {
nArrayNo = i;
break;
}
}
if (0 <= nArrayNo && nArrayNo < 100) {
string strReturnData = value.Value.ToString();
switch (ReadNode[nArrayNo].nNodeType) {
case csNodeType.INT:
ReadNode[nArrayNo].nRet = int.Parse(strReturnData) * ReadNode[nArrayNo].nDigit;
break;
case csNodeType.DOUBLE:
ReadNode[nArrayNo].dRet = (double.Parse(strReturnData) * ReadNode[nArrayNo].nDigit);
break;
case csNodeType.STRING:
ReadNode[nArrayNo].strRet = strReturnData;
break;
case csNodeType.UINT16:
ReadNode[nArrayNo].n16Ret = (ushort)(int.Parse(strReturnData) * ReadNode[nArrayNo].nDigit);
break;
case csNodeType.UINT32:
ReadNode[nArrayNo].n32Ret = (uint)(uint.Parse(strReturnData) * ReadNode[nArrayNo].nDigit);
break;
case csNodeType.UINT64:
ReadNode[nArrayNo].n64Ret = ulong.Parse(strReturnData) * (ulong)ReadNode[nArrayNo].nDigit;
break;
case csNodeType.BOOL:
if (strReturnData == "True") ReadNode[nArrayNo].nRet = 1;
else ReadNode[nArrayNo].nRet = 0;
break;
case csNodeType.BYTE:
ReadNode[nArrayNo].nRet = byte.Parse(strReturnData) * ReadNode[nArrayNo].nDigit;
break;
default:
break;
}
}
}
}
}
} catch (Exception ex) {
throw ex;
}
}
private void OnNotificationWrite(MonitoredItem item, MonitoredItemNotificationEventArgs e)
{
try {
MonitoredItemNotification notification = e.NotificationValue as MonitoredItemNotification;
foreach (var value in item.DequeueValues()) {
// 상태가 정상일 경우
if (StatusCode.IsGood(value.StatusCode)) {
lock (writeNodeLock) {
int nArrayNo = -1;
for (int i = 0; i < 100; i++) {
if (WriteNode[i].nExist == 1 && WriteNode[i].strDisplayNodeName == item.DisplayName) {
nArrayNo = i;
break;
}
}
if (0 <= nArrayNo && nArrayNo < 100) {
string strReturnData = value.Value.ToString();
switch (WriteNode[nArrayNo].nNodeType) {
case csNodeType.INT:
WriteNode[nArrayNo].nRet = int.Parse(strReturnData) * WriteNode[nArrayNo].nDigit;
break;
case csNodeType.DOUBLE:
WriteNode[nArrayNo].dRet = (double.Parse(strReturnData) * WriteNode[nArrayNo].nDigit);
break;
case csNodeType.STRING:
WriteNode[nArrayNo].strRet = strReturnData;
break;
case csNodeType.UINT16:
WriteNode[nArrayNo].n16Ret = (ushort)(int.Parse(strReturnData) * ReadNode[nArrayNo].nDigit);
break;
case csNodeType.UINT32:
WriteNode[nArrayNo].n32Ret = (uint)(uint.Parse(strReturnData) * ReadNode[nArrayNo].nDigit);
break;
case csNodeType.UINT64:
WriteNode[nArrayNo].n64Ret = ulong.Parse(strReturnData) * (ulong)ReadNode[nArrayNo].nDigit;
break;
case csNodeType.BOOL:
if (strReturnData == "True") WriteNode[nArrayNo].nRet = 1;
else WriteNode[nArrayNo].nRet = 0;
break;
case csNodeType.BYTE:
WriteNode[nArrayNo].nRet = byte.Parse(strReturnData) * WriteNode[nArrayNo].nDigit;
break;
default:
break;
}
}
}
}
}
} catch (Exception ex) {
throw ex;
}
}
public void TrueDiskThread_Seq()
{
int timeOut = 10;
DateTime startTime = DateTime.Now;
while (true) {
Thread.Sleep(20);
try {
if (nSequence == eSeqStep.SEQ_NONE) {
if (ReadNode[csReadNodeNo.FAULT_LASER].nRet == 1 || ReadNode[csReadNodeNo.LIGHTPATH_BLOCKED].nRet == 1) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
}
}
switch (nSequence) {
case eSeqStep.SEQ_NONE:
break;
#region Laser On 시퀀스
case eSeqStep.SEQ_LASER_ON_START:
nLaserStatus = eLaserStatus.STATUS_LASER_ON_STEP;
SetData(csWriteNodeNo.EXT_ACTIVATION, 1);
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_ON_EXT_ACTIVE_CHK;
break;
case eSeqStep.SEQ_LASER_ON_EXT_ACTIVE_CHK:
if (ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].nRet == 1) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.PROGRAM_NO, 0);
SetData(csWriteNodeNo.PILOT_LASER_ON, 0);
SetData(csWriteNodeNo.LASER_RESET, 1);
nSequence = eSeqStep.SEQ_LASER_RESET_ON_CHK;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_RESET_ON_CHK:
if (WriteNode[csWriteNodeNo.LASER_RESET].nRet == 1) {
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_RESET_ON_DELAY;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_RESET_ON_DELAY:
if (ReadNode[csReadNodeNo.FAULT_LASER].nRet == 0 || 0.5 < DateTime.Now.Subtract(startTime).TotalSeconds) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.LASER_RESET, 0);
nSequence = eSeqStep.SEQ_LASER_RESET_OFF_CHK;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_RESET_OFF_CHK:
if (WriteNode[csWriteNodeNo.LASER_RESET].nRet == 0) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.LASER_ON, 1);
nSequence = eSeqStep.SEQ_LASER_ON_LASER_ON_CHK;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_ON_LASER_ON_CHK:
if (ReadNode[csReadNodeNo.LASER_IS_ON].nRet == 1) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.REQUEST_LASER, 1);
nSequence = eSeqStep.SEQ_LASER_ON_READY_CHK;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_ON_READY_CHK:
if (ReadNode[csReadNodeNo.LASER_READY].nRet == 1) {
if (AutoProgramStart) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.PSTART_DYN, 1);
nSequence = eSeqStep.SEQ_LASER_ON_DYNAMIC_ON_CHK;
} else {
nLaserStatus = eLaserStatus.STATUS_LASER_READY;
nSequence = eSeqStep.SEQ_NONE;
}
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_ON_DYNAMIC_ON_CHK:
if (WriteNode[csWriteNodeNo.PSTART_DYN].nRet == 1) {
SetData(csWriteNodeNo.PSTART_DYN, 0);
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_ON_PROG_ACTIVE_CHK;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_ON_PROG_ACTIVE_CHK:
if (ReadNode[csReadNodeNo.PROG_ACTIVE].nRet == 1) {
nLaserStatus = eLaserStatus.STATUS_LASER_READY;
nSequence = eSeqStep.SEQ_NONE;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
#endregion Laser On 시퀀스
#region Laser Off 시퀀스
case eSeqStep.SEQ_LASER_OFF_START:
nLaserStatus = eLaserStatus.STATUS_LASER_OFF_STEP;
SetData(csWriteNodeNo.PROG_STOP, 1);
SetData(csWriteNodeNo.PILOT_LASER_ON, 0);
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_OFF_PROG_STOP_ON_CHK;
break;
case eSeqStep.SEQ_LASER_OFF_PROG_STOP_ON_CHK:
if (WriteNode[csWriteNodeNo.PROG_STOP].nRet == 1) {
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_OFF_PROG_STOP_ON_DELAY;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_OFF_PROG_STOP_ON_DELAY:
if (ReadNode[csReadNodeNo.PROG_ACTIVE].nRet == 0 || 0.5 < DateTime.Now.Subtract(startTime).TotalSeconds) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.PROG_STOP, 0);
nSequence = eSeqStep.SEQ_LASER_OFF_PROG_STOP_OFF_CHK;
}
break;
case eSeqStep.SEQ_LASER_OFF_PROG_STOP_OFF_CHK:
if (WriteNode[csWriteNodeNo.PROG_STOP].nRet == 0) {
SetData(csWriteNodeNo.REQUEST_LASER, 0);
SetData(csWriteNodeNo.LASER_ON, 0);
SetData(csWriteNodeNo.EXT_ACTIVATION, 0);
nSequence = eSeqStep.SEQ_NONE;
} else if (timeOut < DateTime.Now.Subtract(startTime).TotalSeconds) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
#endregion Laser Off 시퀀스
#region Pilot Laser On 시퀀스
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_START:
nLaserStatus = eLaserStatus.STATUS_LASER_ON_STEP;
SetData(csWriteNodeNo.EXT_ACTIVATION, 1);
SetData(csWriteNodeNo.LASER_ON, 0);
SetData(csWriteNodeNo.PROGRAM_NO, 1); // Laser Program 1번 광경로가 Absorber로 되어 있어야 함
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_EXT_ACTIVE_CHK;
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_EXT_ACTIVE_CHK:
if (ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].nRet == 1) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.LASER_RESET, 1);
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_RESET_ON_CHK;
} else if (DateTime.Now.Subtract(startTime).TotalMilliseconds > (timeOut * 1000)) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_RESET_ON_CHK:
if (WriteNode[csWriteNodeNo.LASER_RESET].nRet == 1) {
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_RESET_ON_DELAY;
} else if (DateTime.Now.Subtract(startTime).TotalMilliseconds > (timeOut * 1000 * 2)) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_RESET_ON_DELAY:
if (DateTime.Now.Subtract(startTime).TotalMilliseconds > 500) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.LASER_RESET, 0);
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_RESET_OFF_CHK;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_RESET_OFF_CHK:
if (WriteNode[csWriteNodeNo.LASER_RESET].nRet == 0) {
startTime = DateTime.Now;
SetData(csWriteNodeNo.REQUEST_LASER, 1);
SetData(csWriteNodeNo.PILOT_LASER_ON, 1);
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_PILOT_LASER_ON_CHK;
} else if (DateTime.Now.Subtract(startTime).TotalMilliseconds > (timeOut * 1000 * 2)) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_PILOT_LASER_ON_CHK:
if (ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].nRet == 1) {
nLaserStatus = eLaserStatus.STATUS_NONE;
nSequence = eSeqStep.SEQ_NONE;
} else if (DateTime.Now.Subtract(startTime).TotalMilliseconds > (timeOut * 1000)) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
#endregion Pilot Laser On 시퀀스
#region Pilot Laser Off 시퀀스
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_START:
nLaserStatus = eLaserStatus.STATUS_LASER_ON_STEP;
SetData(csWriteNodeNo.LASER_ON, 0);
SetData(csWriteNodeNo.PROGRAM_NO, 0);
SetData(csWriteNodeNo.REQUEST_LASER, 0);
SetData(csWriteNodeNo.PILOT_LASER_ON, 0);
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_OFF_CHK;
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_CHK:
if (ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].nRet == 0) {
SetData(csWriteNodeNo.REQUEST_LASER, 1);
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_ON_CHK;
} else if (DateTime.Now.Subtract(startTime).TotalMilliseconds > (timeOut * 1000)) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_ON_CHK:
if (WriteNode[csWriteNodeNo.REQUEST_LASER].nRet == 1) {
startTime = DateTime.Now;
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_DELAY;
} else if (DateTime.Now.Subtract(startTime).TotalMilliseconds > (timeOut * 1000)) {
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
nSequence = eSeqStep.SEQ_NONE;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_DELAY:
if (DateTime.Now.Subtract(startTime).TotalMilliseconds > 500) {
SetData(csWriteNodeNo.REQUEST_LASER, 0);
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_OFF_CHK;
}
break;
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_REQUEST_LASER_OFF_CHK:
SetData(csWriteNodeNo.EXT_ACTIVATION, 0);
nSequence = eSeqStep.SEQ_NONE;
break;
#endregion Pilot Laser Off 시퀀스
default:
break;
}
} catch {
}
}
}
public DataValue ReadNodeValue(NodeId nodeId)
{
try {
ReadValueIdCollection itemsToRead = new ReadValueIdCollection();
ReadValueId itemToRead = new ReadValueId() {
NodeId = nodeId,
AttributeId = Attributes.Value,
};
itemsToRead.Add(itemToRead);
// read from server.
DataValueCollection values = null;
DiagnosticInfoCollection diagnosticInfos = null;
ResponseHeader responseHeader = _session.Read(null, 0, TimestampsToReturn.Both, itemsToRead, out values, out diagnosticInfos);
ClientBase.ValidateResponse(values, itemsToRead);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, itemsToRead);
if (StatusCode.IsBad(values[0].StatusCode)) {
ServiceResult result = ClientBase.GetResult(values[0].StatusCode, 0, diagnosticInfos, responseHeader);
throw new ServiceResultException(result);
}
return values[0];
} catch (Exception ex) {
throw ex;
}
}
public List<DataValue> ReadNodeListValue(List<NodeId> nodeIdList)
{
try {
ReadValueIdCollection itemsToRead = new ReadValueIdCollection();
foreach (NodeId id in nodeIdList) {
ReadValueId itemToRead = new ReadValueId() {
NodeId = id,
AttributeId = Attributes.Value,
};
itemsToRead.Add(itemToRead);
}
// read from server.
DataValueCollection values = null;
DiagnosticInfoCollection diagnosticInfos = null;
ResponseHeader responseHeader = _session.Read(null, 0, TimestampsToReturn.Both, itemsToRead, out values, out diagnosticInfos);
ClientBase.ValidateResponse(values, itemsToRead);
ClientBase.ValidateDiagnosticInfos(diagnosticInfos, itemsToRead);
foreach (DataValue value in values) {
if (StatusCode.IsBad(value.StatusCode)) {
ServiceResult result = ClientBase.GetResult(value.StatusCode, 0, diagnosticInfos, responseHeader);
throw new ServiceResultException(result);
}
}
return values;
} catch (Exception ex) {
throw ex;
}
}
#region Read/Write Node 호출 함수
public bool GetLaserEmissionEnable()
{
if (AutoProgramStart) {
return ReadNode[csReadNodeNo.PROG_ACTIVE].nRet == 1 ? true : false;
} else {
return ReadNode[csReadNodeNo.LASER_READY].nRet == 1 ? true : false;
}
}
public bool GetPilotLaserOn()
{
return ReadNode[csReadNodeNo.PILOT_LASER_IS_ON].nRet == 1 ? true : false;
}
public bool GetLaserError()
{
int ret = 0;
ret += (ReadNode[csReadNodeNo.FAULT_LASER].nRet == 1 ? 1 : 0);
ret += ReadNode[csReadNodeNo.SIK_OPEN].nRet == 1 ? 2 : 0;
return ret == 0 ? false : true;
}
public bool GetExternalActivation()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.EXT_ACTIVATION_ACTIVE].nRet == 1 ? true : false;
}
}
public bool GetLaserIsOn()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.LASER_IS_ON].nRet == 1 ? true : false;
}
}
public bool GetLaserAssigned()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.LASER_ASSIGNED].nRet == 1 ? true : false;
}
}
public bool GetLaserReady()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.LASER_READY].nRet == 1 ? true : false;
}
}
public bool GetProgramActive()
{
lock (readNodeLock) {
//return ReadNode[csReadNodeNo.PROG_ACTIVE].nRet == 1 ? true : false;
NodeId id = new NodeId(ReadNode[csReadNodeNo.PROG_ACTIVE].strNodeName);
return Convert.ToBoolean(ReadNodeValue(id).Value) ? true : false;
}
}
public bool GetProgramCompleted()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.PROG_COMPLETED].nRet == 1 ? true : false;
}
}
public bool GetProgramCancelled()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.PROG_CANCELLED].nRet == 1 ? true : false;
}
}
public int GetProgramNo()
{
lock (readNodeLock) {
return ReadNode[csReadNodeNo.PROGRAM_NO].n16Ret;
}
}
public int GetProgramLineNo()
{
lock (readNodeLock) {
//return ReadNode[csReadNodeNo.PROGRAM_LINE_NO].n16Ret;
NodeId id = new NodeId(ReadNode[csReadNodeNo.PROGRAM_LINE_NO].strNodeName);
return Convert.ToInt32(ReadNodeValue(id).Value);
}
}
public int SetExternalActivation(bool bOn)
{
return SetData(csWriteNodeNo.EXT_ACTIVATION, bOn ? 1 : 0);
}
public int SetLaserReset(bool bOn)
{
return SetData(csWriteNodeNo.LASER_RESET, bOn ? 1 : 0);
}
public int SetLaserOn(bool bOn)
{
return SetData(csWriteNodeNo.LASER_ON, bOn ? 1 : 0);
}
public int SetRequestLaser(bool bOn)
{
return SetData(csWriteNodeNo.REQUEST_LASER, bOn ? 1 : 0);
}
public int SetProgramStartDynamic(bool bOn)
{
return SetData(csWriteNodeNo.PSTART_DYN, bOn ? 1 : 0);
}
public int SetProgramStop(bool bOn)
{
return SetData(csWriteNodeNo.PROG_STOP, bOn ? 1 : 0);
}
public int SetProgramNo(int no)
{
return SetData(csWriteNodeNo.PROGRAM_NO, no);
}
#endregion
}
}