1165 lines
52 KiB
C#
1165 lines
52 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Net.Sockets;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
|
|
namespace AuroraLaser
|
|
{
|
|
class LaserArm : SocketConn, ILaser
|
|
{
|
|
// SocketConn 을 상속받았기 때문에 바로 연결함수를 쓸수는 있다.
|
|
// 그러나 기존에 감시하는 함수들을 그대로 쓰기 위해서 하위 변수로 client 를 추가해서 쓰도록하자
|
|
#region Properties
|
|
LaserConfig _Config;
|
|
private UdpClient udp = null; // 레이저 통신 컴.
|
|
IAsyncResult ar_ = null; // 콜백.
|
|
public bool IsConnect = false;
|
|
private bool _IsSimul;
|
|
|
|
public enum eLaserStatus { STATUS_NONE = 0, STATUS_LASER_ON_STEP, STATUS_LASER_READY, STATUS_LASER_OFF_STEP, STATUS_LASER_OFF, STATUS_LASER_ERROR };
|
|
|
|
public int TestData;
|
|
public int nLaserType = 0; // TRUMPF (0), Coherent (1);
|
|
|
|
protected readonly object readNodeLock = new object();
|
|
protected readonly object writeNodeLock = new object();
|
|
|
|
// Read/Write node information
|
|
public sNodeInfo[] ReadNode = new sNodeInfo[100];
|
|
public sNodeInfo[] WriteNode = new sNodeInfo[100];
|
|
|
|
public string strSendMsg = ""; // 보낼 데이터.
|
|
public string strReceiveMsgTotal = ""; // 수신 완료시 받은 데이터.
|
|
public string strReceiveMsg = ""; // 완료시까지 받은 데이터.
|
|
public string CRLF = "\r\n";
|
|
public int RetryCnt = 0; // ERR_LASER_READ_ERROR retry count
|
|
|
|
public enum eSeqStep : int
|
|
{
|
|
SEQ_NONE = 0,
|
|
SEQ_LASER_ON_START,
|
|
SEQ_LASER_ON_REMOTE_ON,
|
|
SEQ_LASER_ON_REMOTE_ON_CHK,
|
|
SEQ_LASER_ON_MAINS,
|
|
SEQ_LASER_ON_MAINS_CHK,
|
|
SEQ_LASER_ON_READY_BEFORE_DELAY,
|
|
SEQ_LASER_ON_READY,
|
|
SEQ_LASER_ON_READY_CHK,
|
|
|
|
SEQ_LASER_OFF_START,
|
|
SEQ_LASER_OFF_EMISSION_OFF_CHK,
|
|
|
|
SEQ_LASER_PILOT_LASER_ON_START,
|
|
SEQ_LASER_PILOT_LASER_ON_EMISSION_OFF_CHK,
|
|
SEQ_LASER_PILOT_LASER_ON_LOCAL_MODE_ON_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,
|
|
|
|
};
|
|
public eSeqStep nSequence;
|
|
|
|
public eLaserStatus nLaserStatus; //
|
|
Thread m_threadCoherent = null;
|
|
Thread m_threadCoherentSeq = null;
|
|
|
|
public int nTargetCommand;
|
|
public int nSettingValue;
|
|
public int nReturnType;
|
|
public int nWriteCmd = 0;
|
|
|
|
public enum eCommStatus : int { COMM_STATUS_NONE = 0, COMM_STATUS_WAIT_RECEIVE_DATA, COMM_STATUS_WAIT_RESET_START, COMM_STATUS_WAIT_RESET_FINISH, COMM_STATUS_TIME_OUT }; // 읽거나 쓸때 리턴값에 타겟이 안나온다. 결과만 오기 때문에 리턴 받은 후 다음 명령 써야 한다.
|
|
public eCommStatus nCommStatus;
|
|
|
|
#endregion
|
|
|
|
public LaserArm(string deviceid, bool isSimul, SocketProtocol type) : base(deviceid, isSimul, type)
|
|
{
|
|
_IsSimul = isSimul;
|
|
nLaserStatus = eLaserStatus.STATUS_NONE;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
nCommStatus = eCommStatus.COMM_STATUS_NONE;
|
|
nTargetCommand = 0;
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
ReadNode[i].nExist = 0;
|
|
ReadNode[i].IsCallBack = 0;
|
|
ReadNode[i].nDigit = 1;
|
|
ReadNode[i].priority = 1;
|
|
WriteNode[i].nExist = 0;
|
|
WriteNode[i].IsCallBack = 0;
|
|
WriteNode[i].nDigit = 1;
|
|
ReadNode[i].priority = 1;
|
|
}
|
|
|
|
//---------- Read NODE
|
|
ReadNode[csReadCOH.INIT_COMMUNICATION].strNodeName = "?init" + CRLF;
|
|
ReadNode[csReadCOH.INIT_COMMUNICATION].strDisplayNodeName = "INIT COMMUNICATION";
|
|
ReadNode[csReadCOH.INIT_COMMUNICATION].nNodeType = csNodeType.BOOL;
|
|
ReadNode[csReadCOH.INIT_COMMUNICATION].nExist = 1;
|
|
ReadNode[csReadCOH.INIT_COMMUNICATION].strKey = "0";
|
|
|
|
ReadNode[csReadCOH.EMS_STATUS].strNodeName = "?ems" + CRLF;
|
|
ReadNode[csReadCOH.EMS_STATUS].strDisplayNodeName = "EMISSION ON STATE";
|
|
ReadNode[csReadCOH.EMS_STATUS].nNodeType = csNodeType.BOOL;
|
|
ReadNode[csReadCOH.EMS_STATUS].nExist = 1;
|
|
ReadNode[csReadCOH.EMS_STATUS].strKey = "1";
|
|
|
|
ReadNode[csReadCOH.MAINS_STATUS].strNodeName = "?mains" + CRLF;
|
|
ReadNode[csReadCOH.MAINS_STATUS].strDisplayNodeName = "CARD MAIN SUPPLY STATE";
|
|
ReadNode[csReadCOH.MAINS_STATUS].nNodeType = csNodeType.BOOL;
|
|
ReadNode[csReadCOH.MAINS_STATUS].nExist = 1;
|
|
ReadNode[csReadCOH.MAINS_STATUS].strKey = "2";
|
|
|
|
ReadNode[csReadCOH.WARNING_STATUS].strNodeName = "?alert" + CRLF;
|
|
ReadNode[csReadCOH.WARNING_STATUS].strDisplayNodeName = "WARNING STATE";
|
|
ReadNode[csReadCOH.WARNING_STATUS].nNodeType = csNodeType.BOOL;
|
|
ReadNode[csReadCOH.WARNING_STATUS].nExist = 1;
|
|
ReadNode[csReadCOH.WARNING_STATUS].strKey = "3";
|
|
|
|
ReadNode[csReadCOH.ERROR_STATUS].strNodeName = "?error" + CRLF;
|
|
ReadNode[csReadCOH.ERROR_STATUS].strDisplayNodeName = "ERROR STATE";
|
|
ReadNode[csReadCOH.ERROR_STATUS].nNodeType = csNodeType.BOOL;
|
|
ReadNode[csReadCOH.ERROR_STATUS].nExist = 1;
|
|
ReadNode[csReadCOH.ERROR_STATUS].strKey = "4";
|
|
|
|
ReadNode[csReadCOH.PILOT_LASER_STATE].strNodeName = "?abo" + CRLF;
|
|
ReadNode[csReadCOH.PILOT_LASER_STATE].strDisplayNodeName = "PILOT LASER STATE";
|
|
ReadNode[csReadCOH.PILOT_LASER_STATE].nNodeType = csNodeType.BOOL;
|
|
ReadNode[csReadCOH.PILOT_LASER_STATE].nExist = 1;
|
|
ReadNode[csReadCOH.PILOT_LASER_STATE].strKey = "5";
|
|
|
|
ReadNode[csReadCOH.CONTROL_MODE].strNodeName = "?spm" + CRLF;
|
|
ReadNode[csReadCOH.CONTROL_MODE].strDisplayNodeName = "CONTROL MODE";
|
|
ReadNode[csReadCOH.CONTROL_MODE].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.CONTROL_MODE].nExist = 1;
|
|
ReadNode[csReadCOH.CONTROL_MODE].strKey = "6";
|
|
|
|
ReadNode[csReadCOH.WATER_FLOW_MAIN].strNodeName = "?wf" + CRLF;
|
|
ReadNode[csReadCOH.WATER_FLOW_MAIN].strDisplayNodeName = "WATER FLOW MAIN L/M";
|
|
ReadNode[csReadCOH.WATER_FLOW_MAIN].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.WATER_FLOW_MAIN].nExist = 1;
|
|
ReadNode[csReadCOH.WATER_FLOW_MAIN].strKey = "7";
|
|
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_1].strNodeName = "";
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_1].strDisplayNodeName = "WATER FLOW MODULE 1 L/M";
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_1].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_1].nExist = 1;
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_1].strKey = "8";
|
|
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_2].strNodeName = "";
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_2].strDisplayNodeName = "WATER FLOW MODULE 2 L/M";
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_2].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_2].nExist = 1;
|
|
ReadNode[csReadCOH.WATER_FLOW_MODULE_2].strKey = "9";
|
|
|
|
ReadNode[csReadCOH.WATER_TEMP_MAIN].strNodeName = "?wt" + CRLF;
|
|
ReadNode[csReadCOH.WATER_TEMP_MAIN].strDisplayNodeName = "WATER TEMP MAIN ℃"; // ℃";
|
|
ReadNode[csReadCOH.WATER_TEMP_MAIN].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.WATER_TEMP_MAIN].nExist = 1;
|
|
ReadNode[csReadCOH.WATER_TEMP_MAIN].strKey = "10";
|
|
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_1].strNodeName = "";
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_1].strDisplayNodeName = "WATER TEMP MODULE 1";
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_1].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_1].nExist = 1;
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_1].strKey = "11";
|
|
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_2].strNodeName = "";
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_2].strDisplayNodeName = "WATER TEMP MODULE 2";
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_2].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_2].nExist = 1;
|
|
ReadNode[csReadCOH.WATER_TEMP_MODULE_2].strKey = "12";
|
|
|
|
ReadNode[csReadCOH.HUMIDITY_MAIN].strNodeName = "?eh" + CRLF;
|
|
ReadNode[csReadCOH.HUMIDITY_MAIN].strDisplayNodeName = "HUMIDITY MAIN";
|
|
ReadNode[csReadCOH.HUMIDITY_MAIN].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.HUMIDITY_MAIN].nExist = 1;
|
|
ReadNode[csReadCOH.HUMIDITY_MAIN].strKey = "13";
|
|
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_1].strNodeName = "";
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_1].strDisplayNodeName = "HUMIDITY MODULE 1";
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_1].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_1].nExist = 1;
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_1].strKey = "14";
|
|
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_2].strNodeName = "";
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_2].strDisplayNodeName = "HUMIDITY MODULE 2";
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_2].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_2].nExist = 1;
|
|
ReadNode[csReadCOH.HUMIDITY_MODULE_2].strKey = "15";
|
|
|
|
ReadNode[csReadCOH.ERROR_MESSAGE].strNodeName = "?cerr" + CRLF;
|
|
ReadNode[csReadCOH.ERROR_MESSAGE].strDisplayNodeName = "ERROR MESSAGE";
|
|
ReadNode[csReadCOH.ERROR_MESSAGE].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.ERROR_MESSAGE].nExist = 1;
|
|
ReadNode[csReadCOH.ERROR_MESSAGE].strKey = "16";
|
|
|
|
ReadNode[csReadCOH.LASER_POWER_CENTER].strNodeName = "?hw" + CRLF;
|
|
ReadNode[csReadCOH.LASER_POWER_CENTER].strDisplayNodeName = "LASER POWER CENTER";
|
|
ReadNode[csReadCOH.LASER_POWER_CENTER].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.LASER_POWER_CENTER].nExist = 1;
|
|
ReadNode[csReadCOH.LASER_POWER_CENTER].strKey = "17";
|
|
|
|
ReadNode[csReadCOH.LASER_POWER_RING].strNodeName = "";
|
|
ReadNode[csReadCOH.LASER_POWER_RING].strDisplayNodeName = "LASER POWER RING";
|
|
ReadNode[csReadCOH.LASER_POWER_RING].nNodeType = csNodeType.STRING;
|
|
ReadNode[csReadCOH.LASER_POWER_RING].nExist = 1;
|
|
ReadNode[csReadCOH.LASER_POWER_RING].strKey = "18";
|
|
|
|
//---------- Write NODE
|
|
WriteNode[csWriteCOH.SYSTEM_START].strNodeName = "!start" + CRLF; // 현재 상태 mains
|
|
WriteNode[csWriteCOH.SYSTEM_START].strDisplayNodeName = "START LASER";
|
|
WriteNode[csWriteCOH.SYSTEM_START].nNodeType = csNodeType.BOOL;
|
|
WriteNode[csWriteCOH.SYSTEM_START].nExist = 1;
|
|
WriteNode[csWriteCOH.SYSTEM_START].strKey = "100";
|
|
WriteNode[csWriteCOH.SYSTEM_START].nKey = 100;
|
|
|
|
WriteNode[csWriteCOH.LASER_START].strNodeName = "!spo ";
|
|
WriteNode[csWriteCOH.LASER_START].strDisplayNodeName = "EMISSION ENABLE";
|
|
WriteNode[csWriteCOH.LASER_START].nNodeType = csNodeType.BOOL;
|
|
WriteNode[csWriteCOH.LASER_START].nExist = 1;
|
|
WriteNode[csWriteCOH.LASER_START].strKey = "101";
|
|
WriteNode[csWriteCOH.LASER_START].nKey = 101;
|
|
|
|
WriteNode[csWriteCOH.PILOT_LASER].strNodeName = "!abo ";
|
|
WriteNode[csWriteCOH.PILOT_LASER].strDisplayNodeName = "PILOT LASER ON";
|
|
WriteNode[csWriteCOH.PILOT_LASER].nNodeType = csNodeType.BOOL;
|
|
WriteNode[csWriteCOH.PILOT_LASER].nExist = 1;
|
|
WriteNode[csWriteCOH.PILOT_LASER].strKey = "102";
|
|
WriteNode[csWriteCOH.PILOT_LASER].nKey = 102;
|
|
|
|
WriteNode[csWriteCOH.LASER_RESET].strNodeName = "!reset" + CRLF; // max 30sec disconnect comm.
|
|
WriteNode[csWriteCOH.LASER_RESET].strDisplayNodeName = "RESET";
|
|
WriteNode[csWriteCOH.LASER_RESET].nNodeType = csNodeType.BOOL;
|
|
WriteNode[csWriteCOH.LASER_RESET].nExist = 1;
|
|
WriteNode[csWriteCOH.LASER_RESET].strKey = "103";
|
|
WriteNode[csWriteCOH.LASER_RESET].nKey = 103;
|
|
|
|
WriteNode[csWriteCOH.CONTROL_MODE].strNodeName = "!spm "; // Control mode Local(1) Remote(2)
|
|
WriteNode[csWriteCOH.CONTROL_MODE].strDisplayNodeName = "CONTROL MODE";
|
|
WriteNode[csWriteCOH.CONTROL_MODE].nNodeType = csNodeType.BOOL;
|
|
WriteNode[csWriteCOH.CONTROL_MODE].nExist = 1;
|
|
WriteNode[csWriteCOH.CONTROL_MODE].strKey = "104";
|
|
WriteNode[csWriteCOH.CONTROL_MODE].nKey = 104;
|
|
|
|
|
|
}
|
|
|
|
private void StartListening()
|
|
{
|
|
try {
|
|
ar_ = udp.BeginReceive(CoherentReceive, new object());
|
|
} catch {
|
|
|
|
}
|
|
}
|
|
|
|
private void CoherentReceive(IAsyncResult ar)
|
|
{
|
|
IPEndPoint ip = new IPEndPoint(IPAddress.Any, 0);
|
|
try {
|
|
byte[] bytes = udp.EndReceive(ar, ref ip);
|
|
string message = Encoding.Default.GetString(bytes);
|
|
string strmsg = "";
|
|
string strFind = ";";
|
|
string strEnd = "\r\n";
|
|
int nIndex;
|
|
bool bReceiveFinish;
|
|
double dData;
|
|
|
|
nIndex = message.IndexOf(strFind, 0); // 항상 "1;"가 따라온다.
|
|
strmsg = message.Substring(nIndex + 1);
|
|
bReceiveFinish = strmsg.Contains(strEnd);
|
|
|
|
strReceiveMsg += strmsg;
|
|
|
|
if (bReceiveFinish) {
|
|
strReceiveMsgTotal = strReceiveMsg;
|
|
switch (nTargetCommand) {
|
|
case csReadCOH.INIT_COMMUNICATION:
|
|
case csReadCOH.EMS_STATUS:
|
|
case csReadCOH.MAINS_STATUS:
|
|
ReadNode[nTargetCommand].nRet = strReceiveMsgTotal.Contains("1") == true ? 1 : 0;
|
|
break;
|
|
//case csReadCOH.SPO:
|
|
// nIndex = strReceiveMsgTotal.IndexOf("[1]", 0); // [1] [2] 센터와 링을 동일하게 사용.
|
|
// strmsg = strReceiveMsgTotal.Substring(nIndex + 4, 1);
|
|
// ReadNode[nTargetCommand].nRet = strmsg == "1" ? 1 : 0;
|
|
// break;
|
|
case csReadCOH.WARNING_STATUS:
|
|
case csReadCOH.ERROR_STATUS:
|
|
case csReadCOH.PILOT_LASER_STATE:
|
|
ReadNode[nTargetCommand].nRet = strReceiveMsgTotal.Contains("1") == true ? 1 : 0;
|
|
break;
|
|
case csReadCOH.CONTROL_MODE:
|
|
ReadNode[nTargetCommand].strRet = strReceiveMsgTotal.Contains("1") == true ? "LOCAL" : (strReceiveMsgTotal.Contains("2") == true ? "REMOTE" : "INVALID MODE");
|
|
break;
|
|
case csReadCOH.WATER_FLOW_MAIN:
|
|
case csReadCOH.WATER_FLOW_MODULE_1:
|
|
case csReadCOH.WATER_FLOW_MODULE_2:
|
|
nIndex = strReceiveMsgTotal.IndexOf("[0]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand].strRet = string.Format("{0:F1} l/m", (dData * 0.1));
|
|
|
|
nIndex = strReceiveMsgTotal.IndexOf("[1]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 1].strRet = string.Format("{0:F1} l/m", (dData * 0.1));
|
|
|
|
nIndex = strReceiveMsgTotal.IndexOf("[2]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 2].strRet = string.Format("{0:F1} l/m", (dData * 0.1));
|
|
break;
|
|
|
|
case csReadCOH.WATER_TEMP_MAIN:
|
|
case csReadCOH.WATER_TEMP_MODULE_1:
|
|
case csReadCOH.WATER_TEMP_MODULE_2:
|
|
nIndex = strReceiveMsgTotal.IndexOf("[0]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand].strRet = string.Format("{0:F1}", (dData * 0.1));
|
|
|
|
nIndex = strReceiveMsgTotal.IndexOf("[1]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 1].strRet = string.Format("{0:F1} ℃", (dData * 0.1));
|
|
|
|
nIndex = strReceiveMsgTotal.IndexOf("[2]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 2].strRet = string.Format("{0:F1} ℃", (dData * 0.1));
|
|
break;
|
|
case csReadCOH.HUMIDITY_MAIN:
|
|
case csReadCOH.HUMIDITY_MODULE_1:
|
|
case csReadCOH.HUMIDITY_MODULE_2:
|
|
nIndex = strReceiveMsgTotal.IndexOf("[0]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand].strRet = string.Format("{0:F1} %", (dData * 0.1));
|
|
|
|
nIndex = strReceiveMsgTotal.IndexOf("[1]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 1].strRet = string.Format("{0:F1} %", (dData * 0.1));
|
|
|
|
nIndex = strReceiveMsgTotal.IndexOf("[2]", 0); // [1] 264 170 300 [2] 257 170 300
|
|
strmsg = strReceiveMsgTotal.Substring(nIndex + 4);
|
|
nIndex = strmsg.IndexOf(" ", 0);
|
|
strmsg = strmsg.Substring(0, nIndex);
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 2].strRet = string.Format("{0:F1} %", (dData * 0.1));
|
|
break;
|
|
case csReadCOH.ERROR_MESSAGE: // ERROR_MESSAGE
|
|
ReadNode[nTargetCommand].strRet = strReceiveMsgTotal;
|
|
break;
|
|
case csReadCOH.LASER_POWER_CENTER:
|
|
case csReadCOH.LASER_POWER_RING:
|
|
string[] strData = strReceiveMsgTotal.Split(' ');
|
|
if (strData.Length > 3) {
|
|
strmsg = strData[strData.Length - 3];
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand].strRet = string.Format("{0:F3} V", (dData * 0.001));
|
|
ReadNode[nTargetCommand].dRet = dData * 0.15;
|
|
|
|
strmsg = strData[strData.Length - 2];
|
|
dData = Convert.ToDouble(strmsg);
|
|
ReadNode[nTargetCommand + 1].strRet = string.Format("{0:F3} V", (dData * 0.001));
|
|
ReadNode[nTargetCommand + 1].dRet = dData * 0.25;
|
|
} else {
|
|
//To Do : AlarmLog 수정할 것
|
|
Logger.E("LASER_POWER Invalid Data received " + strReceiveMsgTotal);
|
|
|
|
//UtilUnit.logUnit.SetLog(LogUnit.eLogType.DEBUG, MethodBase.GetCurrentMethod().Name, "LASER_POWER Invalid Data received " + strReceiveMsgTotal);
|
|
}
|
|
break;
|
|
case 100: // SYSTEM_START // 현재 값은 ?mains로 확인.
|
|
nWriteCmd = 0;
|
|
break;
|
|
case 101: // LASER_START // ?spo로 확인.
|
|
nWriteCmd = 0;
|
|
break;
|
|
case 102: // PILOT_LASER // ?abo로 확인.
|
|
nWriteCmd = 0;
|
|
break;
|
|
case 103: // LASER_RESET
|
|
nWriteCmd = 0;
|
|
break;
|
|
case 104:
|
|
nWriteCmd = 0;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
strReceiveMsgTotal = "";
|
|
if (nTargetCommand == 103) nCommStatus = eCommStatus.COMM_STATUS_WAIT_RESET_START;
|
|
else {
|
|
nCommStatus = eCommStatus.COMM_STATUS_NONE;
|
|
RetryCnt = 0;
|
|
}
|
|
}
|
|
} catch {
|
|
|
|
}
|
|
|
|
StartListening();
|
|
}
|
|
|
|
public int Send(string message, int nTargetCmd)
|
|
{
|
|
strSendMsg = message;
|
|
strReceiveMsg = "";
|
|
nTargetCommand = nTargetCmd;
|
|
|
|
var connConfig = _Config.ConnConfig as SocketConnConfig;
|
|
|
|
IPEndPoint ip = new IPEndPoint(IPAddress.Parse(connConfig.Address.IpAddress), connConfig.Address.PortNumber);
|
|
byte[] bytes = Encoding.Default.GetBytes(message);
|
|
udp.Send(bytes, bytes.Length, ip);
|
|
|
|
nCommStatus = eCommStatus.COMM_STATUS_WAIT_RECEIVE_DATA;
|
|
|
|
return 1;
|
|
}
|
|
|
|
public int Initialize(LaserConfig Config)
|
|
{
|
|
_Config = Config;
|
|
var connConfig = Config.ConnConfig as SocketConnConfig;
|
|
udp = new UdpClient(connConfig.Address.PortNumber);
|
|
return 0;
|
|
}
|
|
|
|
public int Open(LaserConfig Config)
|
|
{
|
|
if (udp == null)
|
|
Initialize(Config);
|
|
|
|
StartListening();
|
|
|
|
Thread.Sleep(100);
|
|
|
|
m_threadCoherent = new Thread(new ThreadStart(ThreadCoherent));
|
|
m_threadCoherent.Start();
|
|
|
|
m_threadCoherentSeq = new Thread(new ThreadStart(ThreadCoherent_Seq));
|
|
m_threadCoherentSeq.Start();
|
|
IsConnect = true;
|
|
return 0;
|
|
}
|
|
public new void DisConnect()
|
|
{
|
|
TimeSpan spanTime;
|
|
DateTime startTime = DateTime.Now;
|
|
bool bRet = true;
|
|
int timeOut = 7;
|
|
|
|
try {
|
|
SetData(csWriteCOH.LASER_START, 0);
|
|
|
|
while (bRet) {
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000) ||
|
|
nCommStatus == eCommStatus.COMM_STATUS_NONE) bRet = false;
|
|
|
|
Thread.Sleep(10);
|
|
}
|
|
|
|
if (m_threadCoherent != null) {
|
|
m_threadCoherent.Join(500);
|
|
m_threadCoherent.Abort();
|
|
}
|
|
|
|
if (m_threadCoherentSeq != null) {
|
|
m_threadCoherentSeq.Join(500);
|
|
m_threadCoherentSeq.Abort();
|
|
}
|
|
|
|
udp.Close();
|
|
} catch {
|
|
|
|
}
|
|
|
|
IsConnect = false;
|
|
}
|
|
public void ThreadCoherent()
|
|
{
|
|
int nIndex = 0;
|
|
int timeOut = 5; // 3sec
|
|
int nWriteNo = 0;
|
|
TimeSpan spanTime;
|
|
DateTime startTime = DateTime.Now;
|
|
|
|
while (true) {
|
|
try {
|
|
switch (nCommStatus) {
|
|
case eCommStatus.COMM_STATUS_NONE:
|
|
nWriteNo = IsExistWriteNode();
|
|
if (nWriteNo != 0) {
|
|
if (Send(GetWriteCommand(nWriteNo - 100), nWriteNo) == 1) {
|
|
startTime = DateTime.Now;
|
|
}
|
|
} else {
|
|
if (ReadNode[nIndex].nExist == 1) {
|
|
if (ReadNode[nIndex].strNodeName != "") {
|
|
if (Send(ReadNode[nIndex].strNodeName, nIndex) == 1) {
|
|
nIndex++;
|
|
startTime = DateTime.Now;
|
|
}
|
|
} else {
|
|
nIndex++;
|
|
}
|
|
} else {
|
|
nIndex = 0;
|
|
}
|
|
}
|
|
break;
|
|
case eCommStatus.COMM_STATUS_WAIT_RECEIVE_DATA:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
//To Do : AlarmLog 수정할 것
|
|
Logger.E(MethodBase.GetCurrentMethod().Name, "eCommStatus.COMM_STATUS_WAIT_RECEIVE_DATA TimeOut");
|
|
|
|
//UtilUnit.logUnit.SetLog(LogUnit.eLogType.DEBUG, MethodBase.GetCurrentMethod().Name, "eCommStatus.COMM_STATUS_WAIT_RECEIVE_DATA TimeOut");
|
|
nCommStatus = eCommStatus.COMM_STATUS_TIME_OUT;
|
|
}
|
|
break;
|
|
case eCommStatus.COMM_STATUS_WAIT_RESET_START:
|
|
startTime = DateTime.Now;
|
|
RetryCnt = 0;
|
|
nCommStatus = eCommStatus.COMM_STATUS_WAIT_RESET_FINISH;
|
|
break;
|
|
case eCommStatus.COMM_STATUS_WAIT_RESET_FINISH:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (60 * 1000)) {
|
|
//To Do : AlarmLog 수정할 것
|
|
Logger.E(MethodBase.GetCurrentMethod().Name, "eCommStatus.COMM_STATUS_WAIT_RESET_FINISH TimeOut");
|
|
|
|
//UtilUnit.logUnit.SetLog(LogUnit.eLogType.DEBUG, MethodBase.GetCurrentMethod().Name, "eCommStatus.COMM_STATUS_WAIT_RESET_FINISH TimeOut");
|
|
nCommStatus = eCommStatus.COMM_STATUS_TIME_OUT;
|
|
}
|
|
break;
|
|
case eCommStatus.COMM_STATUS_TIME_OUT:
|
|
if (RetryCnt++ > 5) {
|
|
//To Do : AlarmLog 수정할 것
|
|
Logger.E(MethodBase.GetCurrentMethod().Name, "ERR_LASER_READ_ERROR");
|
|
|
|
//UtilUnit.logUnit.SetLog(LogUnit.eLogType.ERROR, MethodBase.GetCurrentMethod().Name, "ERR_LASER_READ_ERROR");
|
|
}
|
|
nCommStatus = eCommStatus.COMM_STATUS_NONE;
|
|
break;
|
|
|
|
}
|
|
|
|
Thread.Sleep(50);
|
|
} catch {
|
|
}
|
|
}
|
|
}
|
|
public void ThreadCoherent_Seq()
|
|
{
|
|
int timeOut = 5; // 3sec
|
|
int nRetryCnt = 0;
|
|
TimeSpan spanTime;
|
|
DateTime startTime = DateTime.Now;
|
|
|
|
while (true) {
|
|
Thread.Sleep(100);
|
|
|
|
try {
|
|
switch (nSequence) {
|
|
case eSeqStep.SEQ_NONE:
|
|
break;
|
|
// Error status check.
|
|
case eSeqStep.SEQ_LASER_ON_START:
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ON_STEP;
|
|
SetData(csWriteCOH.PILOT_LASER, 0);
|
|
if (ReadNode[csReadCOH.ERROR_STATUS].nRet == 0) {
|
|
nSequence = eSeqStep.SEQ_LASER_ON_REMOTE_ON;
|
|
} else {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
break;
|
|
// REMOTE Mode
|
|
case eSeqStep.SEQ_LASER_ON_REMOTE_ON:
|
|
if (ReadNode[csReadCOH.CONTROL_MODE].strRet == "REMOTE") {
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_REMOTE_ON_CHK;
|
|
} else {
|
|
SetData(csWriteCOH.CONTROL_MODE, 1);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_REMOTE_ON_CHK;
|
|
}
|
|
break;
|
|
// REMOTE Mode check
|
|
case eSeqStep.SEQ_LASER_ON_REMOTE_ON_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
|
|
if (ReadNode[csReadCOH.CONTROL_MODE].strRet == "REMOTE") {
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_MAINS;
|
|
}
|
|
break;
|
|
// MAIN SUPPLY ON
|
|
case eSeqStep.SEQ_LASER_ON_MAINS:
|
|
if (ReadNode[csReadCOH.MAINS_STATUS].nRet == 1) {
|
|
startTime = DateTime.Now;
|
|
nRetryCnt = 0;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_READY;
|
|
} else {
|
|
SetData(csWriteCOH.SYSTEM_START, 1);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_MAINS_CHK;
|
|
}
|
|
break;
|
|
// MAIN SUPPLY ON check
|
|
case eSeqStep.SEQ_LASER_ON_MAINS_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
if (ReadNode[csReadCOH.MAINS_STATUS].nRet == 1) {
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_READY_BEFORE_DELAY;
|
|
}
|
|
break;
|
|
// BEFORE LASER ON DELAY
|
|
case eSeqStep.SEQ_LASER_ON_READY_BEFORE_DELAY:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (3 * 1000)) {
|
|
startTime = DateTime.Now;
|
|
nRetryCnt = 0;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_READY;
|
|
}
|
|
break;
|
|
// EMISSION ON
|
|
case eSeqStep.SEQ_LASER_ON_READY:
|
|
SetData(csWriteCOH.LASER_START, 1);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_READY_CHK;
|
|
break;
|
|
// EMISSION ON check
|
|
case eSeqStep.SEQ_LASER_ON_READY_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 5 * 1000)) {
|
|
if (nRetryCnt++ < 2) {
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_ON_READY;
|
|
} else {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
}
|
|
if (ReadNode[csReadCOH.EMS_STATUS].nRet == 1) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_READY;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
break;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Laser Off sequence
|
|
case eSeqStep.SEQ_LASER_OFF_START:
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_OFF_STEP;
|
|
if (ReadNode[csReadCOH.ERROR_STATUS].nRet == 0) {
|
|
SetData(csWriteCOH.LASER_START, 0);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_OFF_EMISSION_OFF_CHK;
|
|
} else {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
break;
|
|
case eSeqStep.SEQ_LASER_OFF_EMISSION_OFF_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
if (ReadNode[csReadCOH.EMS_STATUS].nRet == 0) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_OFF;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
break;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Pilot Laser On sequence
|
|
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_START:
|
|
SetData(csWriteCOH.LASER_START, 0);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_EMISSION_OFF_CHK;
|
|
break;
|
|
|
|
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_EMISSION_OFF_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
if (ReadNode[csReadCOH.EMS_STATUS].nRet == 0) {
|
|
SetData(csWriteCOH.CONTROL_MODE, 0);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_LOCAL_MODE_ON_CHK;
|
|
}
|
|
break;
|
|
|
|
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_LOCAL_MODE_ON_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
|
|
if (ReadNode[csReadCOH.CONTROL_MODE].strRet == "LOCAL") {
|
|
SetData(csWriteCOH.PILOT_LASER, 1);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_PILOT_LASER_ON_CHK;
|
|
}
|
|
break;
|
|
|
|
case eSeqStep.SEQ_LASER_PILOT_LASER_ON_PILOT_LASER_ON_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
|
|
if (ReadNode[csReadCOH.PILOT_LASER_STATE].nRet == 1) {
|
|
nLaserStatus = eLaserStatus.STATUS_NONE;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
break;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Pilot Laser Off sequence
|
|
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_START:
|
|
SetData(csWriteCOH.PILOT_LASER, 0);
|
|
startTime = DateTime.Now;
|
|
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_OFF_CHK;
|
|
break;
|
|
|
|
case eSeqStep.SEQ_LASER_PILOT_LASER_OFF_CHK:
|
|
spanTime = DateTime.Now.Subtract(startTime);
|
|
if (spanTime.TotalMilliseconds > (timeOut * 1000)) {
|
|
nLaserStatus = eLaserStatus.STATUS_LASER_ERROR;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
|
|
if (ReadNode[csReadCOH.PILOT_LASER_STATE].nRet == 0) {
|
|
nLaserStatus = eLaserStatus.STATUS_NONE;
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
nSequence = eSeqStep.SEQ_NONE;
|
|
break;
|
|
|
|
}
|
|
|
|
} catch {
|
|
}
|
|
}
|
|
}
|
|
public bool GetConnected()
|
|
{
|
|
return IsConnect;
|
|
}
|
|
|
|
public int IsExistWriteNode()
|
|
{
|
|
if (nWriteCmd != 0) {
|
|
if (WriteNode[nWriteCmd - 100].nExist == 1) {
|
|
return nWriteCmd;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
public string GetWriteCommand(int nNodeNo)
|
|
{
|
|
string strCommand = "";
|
|
|
|
switch (nNodeNo) {
|
|
case csWriteCOH.SYSTEM_START:
|
|
strCommand = WriteNode[csWriteCOH.SYSTEM_START].strNodeName;
|
|
break;
|
|
case csWriteCOH.LASER_START:
|
|
strCommand = WriteNode[csWriteCOH.LASER_START].strNodeName + ((WriteNode[csWriteCOH.LASER_START].nSettingValue == 1) ? "1" : "0") + CRLF;
|
|
break;
|
|
case csWriteCOH.PILOT_LASER:
|
|
strCommand = WriteNode[csWriteCOH.PILOT_LASER].strNodeName + ((WriteNode[csWriteCOH.PILOT_LASER].nSettingValue == 1) ? "1" : "0") + CRLF;
|
|
break;
|
|
case csWriteCOH.LASER_RESET:
|
|
strCommand = WriteNode[csWriteCOH.LASER_RESET].strNodeName;
|
|
break;
|
|
case csWriteCOH.CONTROL_MODE:
|
|
strCommand = WriteNode[csWriteCOH.CONTROL_MODE].strNodeName + ((WriteNode[csWriteCOH.CONTROL_MODE].nSettingValue == 1) ? "2" : "1") + CRLF;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return strCommand;
|
|
}
|
|
public int LaserOn()
|
|
{
|
|
if (nSequence != (int)eSeqStep.SEQ_NONE) return 0;
|
|
|
|
nSequence = eSeqStep.SEQ_LASER_ON_START;
|
|
|
|
return 1;
|
|
}
|
|
|
|
public int LaserOff()
|
|
{
|
|
if (nSequence != (int)eSeqStep.SEQ_NONE) return 0;
|
|
|
|
nSequence = eSeqStep.SEQ_LASER_OFF_START;
|
|
|
|
return 1;
|
|
}
|
|
public int PilotLaserOn()
|
|
{
|
|
// 이 기능은 어떤 기능인지가 확인 필요. 함수는 유지해둔다.
|
|
if (nSequence != (int)eSeqStep.SEQ_NONE) return 0;
|
|
|
|
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_ON_START;
|
|
|
|
return 1;
|
|
}
|
|
|
|
public int PilotLaserOff()
|
|
{
|
|
// 이 기능은 어떤 기능인지가 확인 필요. 함수는 유지해둔다.
|
|
if (nSequence != (int)eSeqStep.SEQ_NONE) return 0;
|
|
|
|
nSequence = eSeqStep.SEQ_LASER_PILOT_LASER_OFF_START;
|
|
|
|
return 1;
|
|
}
|
|
|
|
public eLaserStatus GetLaserStatus()
|
|
{
|
|
// 추상함수를 추가할지 검토하자. 다른 레이저에도 이런 함수는 있을거같은데
|
|
// Thread 로 계속 업데이트를 하고 변수만 꺼내오는듯하다.
|
|
return nLaserStatus;
|
|
}
|
|
|
|
public void GetLaserPower(out List<double> lsPower)
|
|
{
|
|
// ArmLaser 는 Power 종류가 2가지임.
|
|
lsPower = new List<double>();
|
|
lsPower.Add(ReadNode[csReadCOH.LASER_POWER_CENTER].dRet);
|
|
lsPower.Add(ReadNode[csReadCOH.LASER_POWER_RING].dRet);
|
|
return;
|
|
}
|
|
|
|
public bool ResetFault()
|
|
{
|
|
// 원래 class의 return 은 void type 이므로 true 로 return 고정함.
|
|
nLaserStatus = eLaserStatus.STATUS_NONE;
|
|
return true;
|
|
}
|
|
|
|
public int SetData(int nTarget, int value)
|
|
{
|
|
if (WriteNode[nTarget].nExist != 1) return 2;
|
|
if (nWriteCmd != 0) return 3;
|
|
try {
|
|
nWriteCmd = WriteNode[nTarget].nKey;
|
|
WriteNode[nTarget].nSettingValue = value;
|
|
} catch (Exception ex) {
|
|
//To Do : AlarmLog 수정할 것
|
|
Logger.E("Coherent Laser", string.Format("[Laser] Coherent Laser Communication SetData Fail;{0}", ex.Message));
|
|
//UtilUnit.logUnit.SetLog(LogUnit.eLogType.ALARM, "Coherent Laser", string.Format("[Laser] Coherent Laser Communication SetData Fail;{0}", ex.Message), LogUnit.eLogLevel.HIGH);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
public string GetData(int nTarget)
|
|
{
|
|
string strRet = "Not Exist";
|
|
int nArrayNo;
|
|
|
|
try {
|
|
if (nTarget >= 0 && nTarget < 100) {
|
|
nArrayNo = nTarget;
|
|
|
|
if (ReadNode[nArrayNo].nExist != 1) return strRet;
|
|
|
|
switch (ReadNode[nArrayNo].nNodeType) {
|
|
case csNodeType.BOOL:
|
|
strRet = (ReadNode[nArrayNo].nRet == 1 ? "1" : "0");
|
|
break;
|
|
case csNodeType.STRING:
|
|
strRet = ReadNode[nArrayNo].strRet;
|
|
break;
|
|
default:
|
|
strRet = ReadNode[nArrayNo].strRet;
|
|
break;
|
|
}
|
|
} else {
|
|
nArrayNo = nTarget - 100;
|
|
|
|
if (WriteNode[nArrayNo].nExist != 1) return strRet;
|
|
|
|
if (nArrayNo == csWriteCOH.SYSTEM_START) strRet = (ReadNode[csReadCOH.MAINS_STATUS].nRet == 1 ? "1" : "0");
|
|
else if (nArrayNo == csWriteCOH.LASER_START) strRet = (ReadNode[csReadCOH.EMS_STATUS].nRet == 1 ? "1" : "0");
|
|
else if (nArrayNo == csWriteCOH.PILOT_LASER) strRet = (ReadNode[csReadCOH.PILOT_LASER_STATE].nRet == 1 ? "1" : "0");
|
|
else if (nArrayNo == csWriteCOH.CONTROL_MODE) strRet = (ReadNode[csReadCOH.CONTROL_MODE].strRet == "REMOTE" ? "1" : "0");
|
|
else strRet = "0";
|
|
}
|
|
} catch (Exception) {
|
|
}
|
|
|
|
return strRet;
|
|
}
|
|
|
|
public void ResetLaserStatus()
|
|
{
|
|
nLaserStatus = eLaserStatus.STATUS_NONE;
|
|
}
|
|
|
|
public void GetLaserPower(out double power1, out double power2)
|
|
{
|
|
power1 = ReadNode[csReadCOH.LASER_POWER_CENTER].dRet;
|
|
power2 = ReadNode[csReadCOH.LASER_POWER_RING].dRet;
|
|
return;
|
|
}
|
|
|
|
public void GetLaserCoolingStatus(
|
|
out double PressureDiff,
|
|
out double ReturnPressure,
|
|
out double CCB_PressureOut_Ext,
|
|
out double CCB_PressureIn_Ext,
|
|
out double CCB_TempWaterIn_Ext,
|
|
out double CCB_PWM_X30_MV,
|
|
out double CCB_TempTank_Set_Tracking,
|
|
out double CCB_TempCoolingWater,
|
|
out double CCB_PressurePump,
|
|
out double CCB_FC_MaxFrequency,
|
|
out double CCB_FC_FrequencyPump,
|
|
out double TEMP_X80,
|
|
out double PRES_X90,
|
|
out UInt16 SPEED_PAN)
|
|
{
|
|
PressureDiff = ReturnPressure = CCB_PressureOut_Ext = CCB_PressureIn_Ext = CCB_TempWaterIn_Ext = CCB_PWM_X30_MV = CCB_TempTank_Set_Tracking = CCB_TempCoolingWater = 0;
|
|
CCB_PressurePump = CCB_FC_MaxFrequency = CCB_FC_FrequencyPump = TEMP_X80 = PRES_X90 = 0;
|
|
SPEED_PAN = 0;
|
|
|
|
return;
|
|
}
|
|
|
|
// CoherentReceive 에서 강제로 처리해주는듯. BOOL type 도 string 을 받아서 nRet 에 넣어준다.
|
|
// write 는 CoherentReceive 에서 처리 안해주는듯
|
|
// nRet==1 이면 true 다.
|
|
public bool GetLaserError()
|
|
{
|
|
return ReadNode[csReadCOH.ERROR_STATUS].nRet == 1 ? true : false;
|
|
}
|
|
|
|
#region Read/Write Node 호출 함수
|
|
public bool GetExternalActivation()
|
|
{
|
|
lock (readNodeLock) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool GetLaserIsOn()
|
|
{
|
|
// Laser On Set bit on인지
|
|
lock (readNodeLock) {
|
|
return WriteNode[csWriteCOH.LASER_START].nRet == 1 ? true : false;
|
|
}
|
|
}
|
|
|
|
public bool GetLaserAssigned()
|
|
{
|
|
lock (readNodeLock) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool GetLaserReady()
|
|
{
|
|
// Laser On 후 Ready 인지
|
|
lock (readNodeLock) {
|
|
return ReadNode[csReadCOH.MAINS_STATUS].nRet == 1 ? true : false;
|
|
}
|
|
}
|
|
|
|
public bool GetProgramActive()
|
|
{
|
|
lock (readNodeLock) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool GetProgramCompleted()
|
|
{
|
|
lock (readNodeLock) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool GetProgramCancelled()
|
|
{
|
|
lock (readNodeLock) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public int GetProgramNo()
|
|
{
|
|
lock (readNodeLock) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
public int GetProgramLineNo()
|
|
{
|
|
lock (readNodeLock) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
public int SetExternalActivation(bool bOn)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public int SetLaserReset(bool bOn)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public int SetLaserOn(bool bOn)
|
|
{
|
|
if (bOn) LaserOn();
|
|
else LaserOff();
|
|
return 0;
|
|
}
|
|
|
|
public int SetRequestLaser(bool bOn)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public int SetProgramStartDynamic(bool bOn)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public int SetProgramStop(bool bOn)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public int SetProgramNo(int no)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// 여기서부터 새로 추가
|
|
public bool GetInitCommunication()
|
|
{
|
|
return ReadNode[csReadCOH.INIT_COMMUNICATION].nRet == 1 ? true : false;
|
|
}
|
|
public bool GetEmissionStatus()
|
|
{
|
|
return ReadNode[csReadCOH.EMS_STATUS].nRet == 1 ? true : false;
|
|
}
|
|
public bool GetWariningStatus()
|
|
{
|
|
return ReadNode[csReadCOH.WARNING_STATUS].nRet == 1 ? true : false;
|
|
}
|
|
// MAINS_STATUS, ERROR_STATUS 는 위에 있음
|
|
public bool GetPilotLaserStatus()
|
|
{
|
|
return ReadNode[csReadCOH.PILOT_LASER_STATE].nRet == 1 ? true : false;
|
|
}
|
|
public string GetControlMode()
|
|
{
|
|
return ReadNode[csReadCOH.CONTROL_MODE].strRet;
|
|
}
|
|
public string GetPowerCenter()
|
|
{
|
|
return ReadNode[csReadCOH.LASER_POWER_CENTER].strRet;
|
|
}
|
|
public string GetPowerRing()
|
|
{
|
|
return ReadNode[csReadCOH.LASER_POWER_RING].strRet;
|
|
}
|
|
#region Set 명령 나간 bit 를 모니터링
|
|
public bool GetStartLaserSetBitStatus()
|
|
{
|
|
|
|
// Laser Start 명령
|
|
return WriteNode[csWriteCOH.SYSTEM_START].nSettingValue == 1 ? true : false;
|
|
}
|
|
public bool GetLaserStartSetBitStatus()
|
|
{
|
|
// Laser On 명령. Laser Emission Ready 를 위한 bit
|
|
return WriteNode[csWriteCOH.LASER_START].nSettingValue == 1 ? true : false;
|
|
}
|
|
public bool GetPilotLaserSetBitStatus()
|
|
{
|
|
// Pilot Laser On 명령.
|
|
return WriteNode[csWriteCOH.PILOT_LASER].nSettingValue == 1 ? true : false;
|
|
}
|
|
public bool GetLaserResetSetBitStatus()
|
|
{
|
|
// Laser Reset 명령.
|
|
return WriteNode[csWriteCOH.LASER_RESET].nSettingValue == 1 ? true : false;
|
|
}
|
|
public bool GetControlModeSetStatus()
|
|
{
|
|
// Control mode Local(false) Remote(true)
|
|
return WriteNode[csWriteCOH.CONTROL_MODE].nSettingValue == 1 ? true : false;
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|