140 lines
5.2 KiB
C#
140 lines
5.2 KiB
C#
using Aurora.Api.Devices;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AuroraLBAD.Services
|
|
{
|
|
public class StreamLBADClient : StreamClient
|
|
{
|
|
public enum eJudgeFlag
|
|
{
|
|
NO_RESPONSE = -1,
|
|
OK = 0,
|
|
NG,
|
|
NA,
|
|
FAILED,
|
|
ERROR
|
|
}
|
|
|
|
//LBAD
|
|
public const string MESSAGE_PC_LBAD_READY_STATUS = "PcLBADReadyStatus";
|
|
public const string MESSAGE_PC_LBAD_WELDING_TRIGGER = "PcLBADWeldingTrigger";
|
|
public const string MESSAGE_PC_LBAD_WELDING_STOP = "PcLBADWeldingStop";
|
|
public const string MESSAGE_PC_LBAD_JUDGEMENT_COMPLETE = "PcLBADJudgementComplete";
|
|
public const string MESSAGE_PC_LBAD_CELL_ID = "PcLBADCellID";
|
|
public const string MESSAGE_PC_LBAD_LOT_ID = "PcLBADLotID";
|
|
|
|
public StreamLBADClient(string serviceName) : base(serviceName)
|
|
{
|
|
AddParser(MESSAGE_PC_LBAD_READY_STATUS, new StreamNumberParser<int>(), new StreamNumberParser<int>());
|
|
AddParser(MESSAGE_PC_LBAD_WELDING_TRIGGER, new StreamNumberParser<int>(), new StreamNumberParser<int>());
|
|
AddParser(MESSAGE_PC_LBAD_WELDING_STOP, new StreamNumberParser<int>(), new StreamNumberParser<int>());
|
|
//용접 완료 후 LBAD측에 JudgeComplete를 요청한뒤 JudgeFlag를 회신 받는다
|
|
AddParser(MESSAGE_PC_LBAD_JUDGEMENT_COMPLETE, new StreamNumberParser<int>(), new StreamNumberParser<int>());
|
|
AddParser(MESSAGE_PC_LBAD_CELL_ID, new StreamStringParser(), new StreamNumberParser<int>());
|
|
AddParser(MESSAGE_PC_LBAD_LOT_ID, new StreamStringParser(), new StreamNumberParser<int>());
|
|
}
|
|
|
|
public bool CheckReadyStatus()
|
|
{
|
|
int requestData = 1;
|
|
var reply = RequestNReply(requestData, MESSAGE_PC_LBAD_READY_STATUS);
|
|
if (reply != null) {
|
|
var replyParsed = (int)reply;
|
|
_Log.I($"Stream {MESSAGE_PC_LBAD_READY_STATUS} Reply Result : {replyParsed}");
|
|
return true;
|
|
} else {
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_READY_STATUS} reply is null!");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool SendCellID(int cellId)
|
|
{
|
|
string cellID = $"CELL_ID_{cellId}";
|
|
var reply = RequestNReply(cellID, MESSAGE_PC_LBAD_CELL_ID);
|
|
if (reply != null) {
|
|
var replyParsed = (int)reply;
|
|
_Log.I($"Stream {MESSAGE_PC_LBAD_CELL_ID} Reply Result : {replyParsed}");
|
|
return true;
|
|
} else {
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_CELL_ID} reply is null!");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool SendLotID(int lotId)
|
|
{
|
|
string lotID = $"LOT_ID_{lotId}";
|
|
var reply = RequestNReply(lotID, MESSAGE_PC_LBAD_LOT_ID);
|
|
if (reply != null) {
|
|
var replyParsed = (int)reply;
|
|
_Log.I($"Stream {MESSAGE_PC_LBAD_LOT_ID} Reply Result : {replyParsed}");
|
|
} else {
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_LOT_ID} reply is null!");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool SetWeldTriggerOn()
|
|
{
|
|
int requestData = 1;
|
|
var reply = RequestNReply(requestData, MESSAGE_PC_LBAD_WELDING_TRIGGER);
|
|
if (reply != null) {
|
|
var replyParsed = (int)reply;
|
|
_Log.I($"Stream {MESSAGE_PC_LBAD_WELDING_TRIGGER} Reply Result : {replyParsed}");
|
|
|
|
return true;
|
|
} else {
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_WELDING_TRIGGER} reply is null!");
|
|
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool SendWeldingStop()
|
|
{
|
|
//Welding Stop On
|
|
int requestData = 1;
|
|
var reply = RequestNReply(requestData, MESSAGE_PC_LBAD_WELDING_STOP);
|
|
|
|
if (reply != null) {
|
|
var replyParsed = (int)reply;
|
|
_Log.I($"Stream {MESSAGE_PC_LBAD_WELDING_STOP} Reply Result : {replyParsed}");
|
|
return true;
|
|
} else {
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_WELDING_STOP} reply is null!");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public eJudgeFlag CheckJudgeComplete()
|
|
{
|
|
int requestData = 1;
|
|
var reply = RequestNReply(requestData, MESSAGE_PC_LBAD_JUDGEMENT_COMPLETE);
|
|
if (reply != null) {
|
|
var replyParsed = (int)reply;
|
|
_Log.I($"Stream {MESSAGE_PC_LBAD_JUDGEMENT_COMPLETE} Reply Result : {replyParsed}");
|
|
//JudgeFlag에 따라서 시퀀스 결정
|
|
//(OK = 0, NG = 1, NA = 2, FAILED = 3, ERROR = 4)
|
|
if (Enum.IsDefined(typeof(eJudgeFlag), replyParsed)) {
|
|
return (eJudgeFlag)replyParsed;
|
|
}
|
|
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_JUDGEMENT_COMPLETE} reply is abnormal value : {replyParsed}!");
|
|
} else {
|
|
_Log.E($"Stream {MESSAGE_PC_LBAD_JUDGEMENT_COMPLETE} reply is null!");
|
|
}
|
|
|
|
return eJudgeFlag.NO_RESPONSE;
|
|
}
|
|
}
|
|
}
|