using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace SHARP_CLAS_UI
|
{
|
public class Vision_Control
|
{
|
#region Property
|
|
// =========================== 제어 -> Align ===============================
|
readonly byte[] RecipeChangeReq = BitConverter.GetBytes((short)110);
|
|
readonly byte[] GrabReadyReq = BitConverter.GetBytes((short)120);
|
|
readonly byte[] GrabStartReq = BitConverter.GetBytes((short)130);
|
|
readonly byte[] MotorPosMoveAck = BitConverter.GetBytes((short)181);
|
|
readonly byte[] UserCommandReq = BitConverter.GetBytes((short)191);
|
|
readonly byte[] SystemTimeSyncReq = BitConverter.GetBytes((short)192);
|
|
// ============================ Align -> 제어 =================================
|
readonly byte[] RecipeChangeAck = BitConverter.GetBytes((short)210);
|
|
readonly byte[] GrabReadyAck = BitConverter.GetBytes((short)220);
|
|
readonly byte[] GrabStartAck = BitConverter.GetBytes((short)230);
|
|
readonly byte[] FilmJudgeResult1 = BitConverter.GetBytes((short)241);
|
|
readonly byte[] FilmJudgeResult2 = BitConverter.GetBytes((short)242);
|
|
readonly byte[] AlignResult1 = BitConverter.GetBytes((short)251);
|
|
readonly byte[] AlignResult2 = BitConverter.GetBytes((short)252);
|
|
readonly byte[] MeasurementResult1 = BitConverter.GetBytes((short)261);
|
|
readonly byte[] MeasurementResult2 = BitConverter.GetBytes((short)262);
|
|
readonly byte[] MotorPosMoveReq = BitConverter.GetBytes((short)281);
|
|
readonly byte[] UserCommandCom = BitConverter.GetBytes((short)291);
|
|
readonly byte[] SystemTimeSyncAck = BitConverter.GetBytes((short)292);
|
|
readonly byte[] VisionAlive = BitConverter.GetBytes((short)100);
|
#endregion
|
|
#region Construct
|
public Vision_Control()
|
{
|
|
}
|
#endregion
|
|
#region Function
|
// =========================== 제어 -> Align ===============================
|
/// <summary>
|
/// Send Recipe Change Req
|
/// </summary>
|
/// <param name="RecipeMode">Recipe Move, 1 : 추가 , 2 : 변경(default), 3 : 삭제 => 현재 변경 고정 사용</param>
|
/// <param name="RecipeName">제품 구분 정보(레시피 명)</param>
|
public byte[] Send_Recipe_Change_Req(int RecipeMode, string RecipeName)
|
{
|
List<byte> senddata = new List<byte>();
|
List<byte> body = new List<byte>();
|
byte[] send_recipe_name = new byte[20];
|
byte[] recipe_name = Encoding.ASCII.GetBytes(RecipeName);
|
Array.Copy(recipe_name, send_recipe_name, recipe_name.Length);
|
DateTime dt = DateTime.Now;
|
int msgindex = int.Parse($"{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}{dt.Millisecond:d3}");
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(msgindex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(RecipeMode));
|
body.InsertRange(body.Count, send_recipe_name);
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, RecipeChangeReq);
|
senddata.InsertRange(senddata.Count, body);
|
|
return senddata.ToArray();
|
}
|
|
/// <summary>
|
/// Send Grab Ready Req
|
/// </summary>
|
/// <param name="SeqType">물류 Sequence Type</param>
|
/// <param name="ModuleIdx">카메라 Module Idx (0: Left, 1: Right)</param>
|
/// <param name="GrabDir">단축 Grab(Default), 1: 단축 Grab</param>
|
/// <param name="PnlDir">0: 단면 물류 흐름 방향, 1: 장면 물류 흐름 방향</param>
|
/// <param name="StageNo">현재 검사를 위한 Panel이 로딩된 Stage 번호</param>
|
/// <param name="SlotNo">Tray Slot 번호</param>
|
/// <param name="PnlIdx">Tray 내 Panel이 위치한 Idx 번호</param>
|
/// <param name="PanelID">Panel을 식별하기위한 ID (*없는 경우 NULL)</param>
|
public byte[] Send_Grab_Ready_Req(int SeqType, int ModuleIdx, int GrabDir, int PnlDir, int StageNo, int SlotNo, int PnlIdx, string PanelID)
|
{
|
List<byte> senddata = new List<byte>();
|
List<byte> body = new List<byte>();
|
|
byte[] send_panel_id = new byte[20];
|
byte[] panel_id = Encoding.ASCII.GetBytes(PanelID);
|
Array.Copy(panel_id, send_panel_id, panel_id.Length);
|
|
DateTime dt = DateTime.Now;
|
int msgindex = int.Parse($"{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}{dt.Millisecond:d3}");
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(msgindex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(ModuleIdx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(GrabDir));
|
body.InsertRange(body.Count, BitConverter.GetBytes(PnlDir));
|
body.InsertRange(body.Count, BitConverter.GetBytes(StageNo));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SlotNo));
|
body.InsertRange(body.Count, BitConverter.GetBytes(PnlIdx));
|
body.InsertRange(body.Count, send_panel_id);
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, GrabReadyReq);
|
senddata.InsertRange(senddata.Count, body);
|
|
return senddata.ToArray();
|
}
|
|
/// <summary>
|
/// Send Grab Start Req
|
/// </summary>
|
/// <param name="SeqType">물류 Sequence Type</param>
|
/// <param name="ModelIndx">카메라 Module Idx (0: Left, 1: Right)</param>
|
/// <param name="MotorOffsetX">현재 Motor Position X</param>
|
/// <param name="MotorOffsetY">현재 Motor Position Y</param>
|
public byte[] Send_Grab_Start_Req(int SeqType, int ModelIndx, int MarkIdx, double MotorOffsetX, double MotorOffsetY)
|
{
|
List<byte> senddata = new List<byte>();
|
List<byte> body = new List<byte>();
|
|
DateTime dt = DateTime.Now;
|
int msgindex = int.Parse($"{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}{dt.Millisecond:d3}");
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(msgindex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(ModelIndx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(MarkIdx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(MotorOffsetX));
|
body.InsertRange(body.Count, BitConverter.GetBytes(MotorOffsetY));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, GrabStartReq);
|
senddata.InsertRange(senddata.Count, body);
|
|
return senddata.ToArray();
|
}
|
|
/// <summary>
|
/// Send Motor Pos Move Ack
|
/// </summary>
|
/// <param name="Return"> 0 : 위치 이동 완료 (Success), n : 기타 에러(Fail) 제어 정의.</param>
|
public byte[] Send_Motor_Pos_Move_Ack(int Return)
|
{
|
List<byte> senddata = new List<byte>();
|
List<byte> body = new List<byte>();
|
|
DateTime dt = DateTime.Now;
|
int msgindex = int.Parse($"{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}{dt.Millisecond:d3}");
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(msgindex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, MotorPosMoveAck);
|
senddata.InsertRange(senddata.Count, body);
|
|
return senddata.ToArray();
|
}
|
|
/// <summary>
|
/// Send Command Req
|
/// </summary>
|
/// <param name="CmdType">0: Scrap(제거, 1: Retry(재시도), 3: Skip(NG), 4: Pass(OK), 5: User(수동선택)</param>
|
/// <param name="SeqType">물류 Sequence Type</param>
|
/// <param name="ModuleIdx">카메라 Module Idx (0: Left, 1: Right)</param>
|
/// <param name="PnlIdx">Tray 내 Panel이 위치한 Idx 번호</param>
|
/// <param name="PanelID">Panel을 식별하기위한 ID (*없는 경우 NULL)</param>
|
public byte[] Send_Command_Req(int CmdType, int SeqType, int ModuleIdx, int SlotNo, int PnlIdx, string PanelID)
|
{
|
List<byte> senddata = new List<byte>();
|
List<byte> body = new List<byte>();
|
|
byte[] send_panel_id = new byte[20];
|
byte[] panel_id = Encoding.ASCII.GetBytes(PanelID);
|
Array.Copy(panel_id, send_panel_id, panel_id.Length);
|
|
DateTime dt = DateTime.Now;
|
int msgindex = int.Parse($"{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}{dt.Millisecond:d3}");
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(msgindex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(CmdType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(ModuleIdx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SlotNo));
|
body.InsertRange(body.Count, BitConverter.GetBytes(PnlIdx));
|
body.InsertRange(body.Count, send_panel_id);
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, UserCommandReq);
|
senddata.InsertRange(senddata.Count, body);
|
|
return senddata.ToArray();
|
}
|
|
/// <summary>
|
/// Send System Time Sync Req
|
/// </summary>
|
public byte[] Send_System_Time_Sync_Req()
|
{
|
List<byte> senddata = new List<byte>();
|
List<byte> body = new List<byte>();
|
|
DateTime dt = DateTime.Now;
|
int msgindex = int.Parse($"{dt.Hour:d2}{dt.Minute:d2}{dt.Second:d2}{dt.Millisecond:d3}");
|
int year = dt.Year;
|
int month = dt.Month;
|
int day = dt.Day;
|
int hour = dt.Hour;
|
int minutes = dt.Minute;
|
int second = dt.Second;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(msgindex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(year));
|
body.InsertRange(body.Count, BitConverter.GetBytes(month));
|
body.InsertRange(body.Count, BitConverter.GetBytes(day));
|
body.InsertRange(body.Count, BitConverter.GetBytes(hour));
|
body.InsertRange(body.Count, BitConverter.GetBytes(minutes));
|
body.InsertRange(body.Count, BitConverter.GetBytes(second));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, SystemTimeSyncReq);
|
senddata.InsertRange(senddata.Count, body);
|
|
return senddata.ToArray();
|
}
|
|
// ============================ Align -> 제어 =================================
|
/// <summary>
|
/// Recv Recipe Change Ack
|
/// </summary>
|
/// <param name="Recvdata"></param>
|
public void Recv_Recipe_Change_Ack(byte[] Recvdata, out RecipeChangeAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] Return = new byte[4]; //0 : Fail , 1: Success
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, Return, 0, Return.Length);
|
copylength += Return.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_Return = BitConverter.ToInt32(Return, 0);
|
|
Ack = new RecipeChangeAck(Result_MsgIndex, Result_Return);
|
}
|
|
public void Recv_Grab_Read_Ack(byte[] Recvdata, out GrabReadyAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] SeqType = new byte[4]; //물류 Sequence Type
|
byte[] Return = new byte[4]; //0 : Fail, 1 : Success
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, SeqType, 0, SeqType.Length);
|
copylength += SeqType.Length;
|
Array.Copy(Recvdata, copylength, Return, 0, Return.Length);
|
copylength += Return.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_SeqType = BitConverter.ToInt32(SeqType, 0);
|
int Result_Return = BitConverter.ToInt32(Return, 0);
|
|
Ack = new GrabReadyAck(Result_MsgIndex, Result_SeqType, Result_Return);
|
}
|
|
public void Recv_Grab_Start_Ack(byte[] Recvdata, out GrabStartAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] SeqType = new byte[4]; //물류 Sequence Type
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] Return = new byte[4]; //0 : Fail, 1 : Success
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, SeqType, 0, SeqType.Length);
|
copylength += SeqType.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, Return, 0, Return.Length);
|
copylength += Return.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_SeqType = BitConverter.ToInt32(SeqType, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_Return = BitConverter.ToInt32(Return, 0);
|
|
Ack = new GrabStartAck(Result_MsgIndex, Result_SeqType, Result_ModuleIdx, Result_Return);
|
}
|
|
public void Recv_Film_Judge_Result(byte[] Recvdata, out FilmJudgeResultAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] SeqType = new byte[4]; //물류 Sequence Type
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] FilmResult = new byte[4]; //0 : Film 無(Fail), 1 : Film 有(Success)
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, SeqType, 0, SeqType.Length);
|
copylength += SeqType.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, FilmResult, 0, FilmResult.Length);
|
copylength += FilmResult.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Reuslt_SeqType = BitConverter.ToInt32(SeqType, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_FilmResult = BitConverter.ToInt32(FilmResult, 0);
|
|
Ack = new FilmJudgeResultAck(Result_MsgIndex, Reuslt_SeqType, Result_ModuleIdx, Result_FilmResult);
|
}
|
|
public void Recv_Align_Result(byte[] Recvdata, out AlignResultAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] SeqType = new byte[4]; //물류 Sequence Type
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] AlignResult = new byte[4]; //0 : Align Fail, 1 : Align Success
|
byte[] AlignX = new byte[8]; //Align Offset X
|
byte[] AlignY = new byte[8]; //Align Offset Y
|
byte[] AlignAngle = new byte[8]; //Align Angle
|
byte[] CenterAxis = new byte[4]; //제품 중심 좌표 (예비)
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, SeqType, 0, SeqType.Length);
|
copylength += SeqType.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, AlignResult, 0, AlignResult.Length);
|
copylength += AlignResult.Length;
|
Array.Copy(Recvdata, copylength, AlignX, 0, AlignX.Length);
|
copylength += AlignX.Length;
|
Array.Copy(Recvdata, copylength, AlignY, 0, AlignY.Length);
|
copylength += AlignY.Length;
|
Array.Copy(Recvdata, copylength, AlignAngle, 0, AlignAngle.Length);
|
copylength += AlignAngle.Length;
|
Array.Copy(Recvdata, copylength, CenterAxis, 0, CenterAxis.Length);
|
copylength += CenterAxis.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_SeqType = BitConverter.ToInt32(SeqType, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_AlignResult = BitConverter.ToInt32(AlignResult, 0);
|
double Result_AlignX = BitConverter.ToDouble(AlignX, 0);
|
double Result_AlignY = BitConverter.ToDouble(AlignY, 0);
|
double Result_AlignAngle = BitConverter.ToDouble(AlignAngle, 0);
|
int Result_CenterAxis = BitConverter.ToInt32(CenterAxis, 0);
|
|
Ack = new AlignResultAck(Result_MsgIndex, Result_SeqType, Result_ModuleIdx, Result_AlignResult, Result_AlignX, Result_AlignY, Result_AlignAngle, Result_CenterAxis);
|
}
|
|
public void Recv_Measurement_Result(byte[] Recvdata, out MeasurementResultAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] MeasureResult = new byte[4]; //0 : Fail, 1 : Success
|
byte[] Mark1Point1 = new byte[8]; //Mark1의 #1(1/4 Point) to 레이저 가공부 상부 Edge 거리
|
byte[] Mark1Point2 = new byte[8]; //Mark1의 #2(2/4 Point) to 레이저 가공부 하부 Edge 거리
|
byte[] Mark2Point1 = new byte[8]; //Mark2의 #1(3/4 Point) to 레이저 가공부 상부 Edge 거리
|
byte[] Mark2Point2 = new byte[8]; //Mark2의 #2(4/4 Point) to 레이저 가공부 하부 Edge 거리
|
byte[] Mark3Point1 = new byte[8]; //Mark3의 #1(3/4 Point) to 레이저 가공부 상부 Edge 거리
|
byte[] Mark3Point2 = new byte[8]; //Mark3의 #2(4/4 Point) to 레이저 가공부 하부 Edge 거리
|
byte[] Mark4Point1 = new byte[8]; //Mark4의 #1(3/4 Point) to 레이저 가공부 상부 Edge 거리
|
byte[] Mark4Point2 = new byte[8]; //Mark4의 #2(4/4 Point) to 레이저 가공부 하부 Edge 거리
|
byte[] MarkDistance = new byte[8]; //Mark1과 Mark2의 거리
|
byte[] AlignResult = new byte[4]; //0 : Align Fail, 1 : Align Success
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, MeasureResult, 0, MeasureResult.Length);
|
copylength += MeasureResult.Length;
|
Array.Copy(Recvdata, copylength, Mark1Point1, 0, Mark1Point1.Length);
|
copylength += Mark1Point1.Length;
|
Array.Copy(Recvdata, copylength, Mark1Point2, 0, Mark1Point2.Length);
|
copylength += Mark1Point2.Length;
|
Array.Copy(Recvdata, copylength, Mark2Point1, 0, Mark2Point1.Length);
|
copylength += Mark2Point1.Length;
|
Array.Copy(Recvdata, copylength, Mark2Point2, 0, Mark2Point2.Length);
|
copylength += Mark2Point2.Length;
|
Array.Copy(Recvdata, copylength, Mark3Point1, 0, Mark3Point1.Length);
|
copylength += Mark3Point1.Length;
|
Array.Copy(Recvdata, copylength, Mark3Point2, 0, Mark3Point2.Length);
|
copylength += Mark3Point2.Length;
|
Array.Copy(Recvdata, copylength, Mark4Point1, 0, Mark4Point1.Length);
|
copylength += Mark4Point1.Length;
|
Array.Copy(Recvdata, copylength, Mark4Point2, 0, Mark4Point2.Length);
|
copylength += Mark4Point2.Length;
|
Array.Copy(Recvdata, copylength, MarkDistance, 0, MarkDistance.Length);
|
copylength += MarkDistance.Length;
|
Array.Copy(Recvdata, copylength, AlignResult, 0, AlignResult.Length);
|
copylength += AlignResult.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_MeasureResult = BitConverter.ToInt32(MeasureResult, 0);
|
double Result_Mark1Point1 = BitConverter.ToDouble(Mark1Point1, 0);
|
double Result_Mark1Point2 = BitConverter.ToDouble(Mark1Point2, 0);
|
double Result_Mark2Point1 = BitConverter.ToDouble(Mark2Point1, 0);
|
double Result_Mark2Point2 = BitConverter.ToDouble(Mark2Point2, 0);
|
double Result_Mark3Point1 = BitConverter.ToDouble(Mark3Point1, 0);
|
double Result_Mark3Point2 = BitConverter.ToDouble(Mark3Point2, 0);
|
double Result_Mark4Point1 = BitConverter.ToDouble(Mark4Point1, 0);
|
double Result_Mark4Point2 = BitConverter.ToDouble(Mark4Point2, 0);
|
double Result_MarkDistance = BitConverter.ToDouble(MarkDistance, 0);
|
int Result_AlignResult = BitConverter.ToInt32(AlignResult, 0);
|
|
Ack = new MeasurementResultAck(Result_MsgIndex, Result_ModuleIdx, Result_MeasureResult, Result_Mark1Point1, Result_Mark1Point2, Result_Mark2Point1, Result_Mark2Point2, Result_Mark3Point1, Result_Mark3Point2, Result_Mark4Point1, Result_Mark4Point2, Result_MarkDistance, Result_AlignResult);
|
}
|
|
public void Recv_WidthMeasurement_Result(byte[] Recvdata, out WidthMeasurementResultAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] MeasureResult = new byte[4]; //0 : Fail, 1 : Success
|
byte[] Mark1Width = new byte[8]; //Mark1의 넓이
|
byte[] Mark2Width = new byte[8]; //Mark2의 넓이
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, MeasureResult, 0, MeasureResult.Length);
|
copylength += MeasureResult.Length;
|
Array.Copy(Recvdata, copylength, Mark1Width, 0, Mark1Width.Length);
|
copylength += Mark1Width.Length;
|
Array.Copy(Recvdata, copylength, Mark2Width, 0, Mark2Width.Length);
|
copylength += Mark2Width.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_MeasureResult = BitConverter.ToInt32(MeasureResult, 0);
|
double Result_Mark1Width = BitConverter.ToDouble(Mark1Width, 0);
|
double Result_Mark2Width = BitConverter.ToDouble(Mark2Width, 0);
|
|
Ack = new WidthMeasurementResultAck(Result_MsgIndex, Result_ModuleIdx, Result_MeasureResult, Result_Mark1Width, Result_Mark2Width);
|
}
|
|
public void Recv_Fine_Align_Result(byte[] Recvdata, out FineAlignResultAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] SeqType = new byte[4]; //물류 Sequence Type
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] AlignResult = new byte[4]; //0 : Align Fail, 1 : Align Success
|
byte[] AlignX = new byte[8]; //Align Offset X
|
byte[] AlignY = new byte[8]; //Align Offset Y
|
byte[] AlignAngle = new byte[8]; //Align Angle
|
byte[] CenterAxis = new byte[4]; //제품 중심 좌표 (예비)
|
byte[] Mark_Distance = new byte[8]; //Mark간 거리
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, SeqType, 0, SeqType.Length);
|
copylength += SeqType.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, AlignResult, 0, AlignResult.Length);
|
copylength += AlignResult.Length;
|
Array.Copy(Recvdata, copylength, AlignX, 0, AlignX.Length);
|
copylength += AlignX.Length;
|
Array.Copy(Recvdata, copylength, AlignY, 0, AlignY.Length);
|
copylength += AlignY.Length;
|
Array.Copy(Recvdata, copylength, AlignAngle, 0, AlignAngle.Length);
|
copylength += AlignAngle.Length;
|
Array.Copy(Recvdata, copylength, CenterAxis, 0, CenterAxis.Length);
|
copylength += CenterAxis.Length;
|
Array.Copy(Recvdata, copylength, Mark_Distance, 0, Mark_Distance.Length);
|
copylength += Mark_Distance.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_SeqType = BitConverter.ToInt32(SeqType, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_AlignResult = BitConverter.ToInt32(AlignResult, 0);
|
double Result_AlignX = BitConverter.ToDouble(AlignX, 0);
|
double Result_AlignY = BitConverter.ToDouble(AlignY, 0);
|
double Result_AlignAngle = BitConverter.ToDouble(AlignAngle, 0);
|
int Result_CenterAxis = BitConverter.ToInt32(CenterAxis, 0);
|
double Result_Mark_Distance = BitConverter.ToDouble(Mark_Distance, 0);
|
|
Ack = new FineAlignResultAck(Result_MsgIndex, Result_SeqType, Result_ModuleIdx, Result_AlignResult, Result_AlignX, Result_AlignY, Result_AlignAngle, Result_CenterAxis, Result_Mark_Distance);
|
}
|
public void Recv_Motor_Pos_Move_Req(byte[] Recvdata, out MotorPosMoveReq Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] SeqType = new byte[4]; //물류 Sequence Type
|
byte[] ModuleIdx = new byte[4]; //카메라 Module Idx (0: Left, 1: Right)
|
byte[] GrabIdx = new byte[4]; //영상 취득 Idx (0: Mark1, 1: Mark2)
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, SeqType, 0, SeqType.Length);
|
copylength += SeqType.Length;
|
Array.Copy(Recvdata, copylength, ModuleIdx, 0, ModuleIdx.Length);
|
copylength += ModuleIdx.Length;
|
Array.Copy(Recvdata, copylength, GrabIdx, 0, GrabIdx.Length);
|
copylength += GrabIdx.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Reuslt_SeqType = BitConverter.ToInt32(SeqType, 0);
|
int Result_ModuleIdx = BitConverter.ToInt32(ModuleIdx, 0);
|
int Result_GrabIdx = BitConverter.ToInt32(GrabIdx, 0);
|
|
Ack = new MotorPosMoveReq(Result_MsgIndex, Reuslt_SeqType, Result_ModuleIdx, Result_GrabIdx);
|
}
|
|
public void Recv_User_Command_Ack(byte[] Recvdata, out UserCommandAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] Return = new byte[4]; //0: 실패, 1: 성공
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, Return, 0, Return.Length);
|
copylength += Return.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_Return = BitConverter.ToInt32(Return, 0);
|
|
Ack = new UserCommandAck(Result_MsgIndex, Result_Return);
|
}
|
|
public void Recv_System_Time_Sync_Ack(byte[] Recvdata, out SystemTimeSyncAck Ack)
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] Return = new byte[4]; //0: 실패, 1: 성공
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, Return, 0, Return.Length);
|
copylength += Return.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_Return = BitConverter.ToInt32(Return, 0);
|
|
Ack = new SystemTimeSyncAck(Result_MsgIndex, Result_Return);
|
}
|
|
public void Recv_Vision_Alive(byte[] Recvdata, out VisionAliveAck Ack )
|
{
|
byte[] size = new byte[4];
|
byte[] command = new byte[2];
|
byte[] MsgIndex = new byte[4]; //TimeStamp (HHMMSSmsmsms)
|
byte[] Controller = new byte[4]; //PC구분 ( 1: Align, 2: AOI )
|
byte[] HeartBeat = new byte[4]; //Toggle ( 0 -> 1 -> 0 …)
|
|
int copylength = 0;
|
Array.Copy(Recvdata, size, size.Length);
|
copylength += size.Length;
|
Array.Copy(Recvdata, copylength, command, 0, command.Length);
|
copylength += command.Length;
|
Array.Copy(Recvdata, copylength, MsgIndex, 0, MsgIndex.Length);
|
copylength += MsgIndex.Length;
|
Array.Copy(Recvdata, copylength, Controller, 0, Controller.Length);
|
copylength += Controller.Length;
|
Array.Copy(Recvdata, copylength, HeartBeat, 0, HeartBeat.Length);
|
copylength += HeartBeat.Length;
|
|
int Result_MsgIndex = BitConverter.ToInt32(MsgIndex, 0);
|
int Result_Controller = BitConverter.ToInt32(Controller, 0);
|
int Result_HeartBeat = BitConverter.ToInt32(HeartBeat, 0);
|
|
Ack = new VisionAliveAck(Result_MsgIndex, Result_Controller, Result_HeartBeat);
|
}
|
#endregion
|
}
|
}
|