using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Net;
|
using System.Threading;
|
using System.Windows.Forms;
|
|
namespace SHARP_CLAS_UI
|
{
|
public partial class Form_Vision_Test : Form
|
{
|
#region Filed
|
delegate void UI_Update_Delegate();
|
Thread UI_Update_Th;
|
Form_Frame _Parent;
|
|
Vision_Control vision_control;
|
Form_Vision_Status_Viewer vision_status_viewer;
|
bool update_check;
|
#endregion
|
|
#region Construct
|
public Form_Vision_Test(Form_Frame _Parent)
|
{
|
InitializeComponent();
|
|
this._Parent = _Parent;
|
|
vision_control = new Vision_Control();
|
cbb_Align_SeqType.SelectedIndex = 0;
|
cbb_Align_Recipe_Mode.SelectedIndex = 0;
|
|
cbb_AOI_SeqType.SelectedIndex = 0;
|
cbb_AOI_Recipe_Mode.SelectedIndex = 0;
|
|
UI_Update_Th = new Thread(UI_Update_Th_Set);
|
UI_Update_Th.Start();
|
|
vision_status_viewer = new Form_Vision_Status_Viewer(_Parent);
|
}
|
#endregion
|
|
#region Form Function
|
// Align PC Send
|
private void btn_Recipe_Change_Req_Click(object sender, EventArgs e)
|
{
|
int Recipe_Mode = cbb_Align_Recipe_Mode.SelectedIndex + 1;
|
string Recipe_Name = tb_Align_Recipe_Name.Text;
|
|
_Parent.sm.Set_Bit(Vision_Address.Align_PC_Recipe_Change_Ack, false);
|
_Parent._equip.Align_vision.SendData(vision_control.Send_Recipe_Change_Req(Recipe_Mode, Recipe_Name));
|
}
|
|
private void btn_Grab_Ready_Req_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = cbb_Align_SeqType.SelectedIndex;
|
int Module_Idx = rb_Align_Left.Checked ? 0 : 1;
|
int Grab_Dir = rb_Align_Short.Checked ? 0 : 1;
|
int Pnl_Dir = rb_Align_Short.Checked ? 0 : 1;
|
int Stage_No;
|
int.TryParse(tb_Align_Stage_No.Text, out Stage_No);
|
int Slot_No;
|
int.TryParse(tb_Align_Slot_No.Text, out Slot_No);
|
int Pnl_Idx;
|
int.TryParse(tb_Align_Pnl_Idx.Text, out Pnl_Idx);
|
string Panel_Id = tb_Align_Panel_Id.Text;
|
|
if (Seq_Type == 0)
|
{
|
if(Module_Idx == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_Left_Ack, false);
|
else
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_Right_Ack, false);
|
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_Grab_Ready_Ack, false);
|
}
|
else if (Seq_Type == 1)
|
{
|
if (Module_Idx == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_Left_Ack, false);
|
else
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_Right_Ack, false);
|
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_Grab_Ready_Ack, false);
|
}
|
else if (Seq_Type == 2)
|
{
|
if (Module_Idx == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_Left_Ack, false);
|
else
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_Right_Ack, false);
|
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_Grab_Ready_Ack, false);
|
}
|
|
_Parent._equip.Align_vision.SendData(vision_control.Send_Grab_Ready_Req(Seq_Type, Module_Idx, Grab_Dir, Pnl_Dir, Stage_No, Slot_No, Pnl_Idx, Panel_Id));
|
}
|
|
private void btn_Grab_Start_Req_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = cbb_Align_SeqType.SelectedIndex;
|
int Module_Idx = rb_Align_Left.Checked ? 0 : 1;
|
int Mark_Idx = rb_Align_Mark_1.Checked ? 0 : 1;
|
double Motor_Offset_X;
|
double.TryParse(tb_Align_Motor_Offset_X.Text, out Motor_Offset_X);
|
double Motor_Offset_Y;
|
double.TryParse(tb_Align_Motor_Offset_Y.Text, out Motor_Offset_Y);
|
|
if (Module_Idx == 0)
|
{
|
if (Seq_Type == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_Grab_Start_Left_Ack, false);
|
else if (Seq_Type == 1)
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_Grab_Start_Left_Ack, false);
|
else if (Seq_Type == 2)
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_Grab_Start_Left_Ack, false);
|
}
|
else
|
{
|
if (Seq_Type == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_Grab_Start_Right_Ack, false);
|
else if (Seq_Type == 1)
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_Grab_Start_Right_Ack, false);
|
else if (Seq_Type == 2)
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_Grab_Start_Right_Ack, false);
|
}
|
|
_Parent._equip.Align_vision.SendData(vision_control.Send_Grab_Start_Req(Seq_Type, Module_Idx, Mark_Idx, Motor_Offset_X, Motor_Offset_Y));
|
}
|
|
private void btn_Motor_Pos_Move_Ack_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = cbb_Align_SeqType.SelectedIndex;
|
|
if (Seq_Type == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_Motor_Pos_Ack, false);
|
else if (Seq_Type == 1)
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_Motor_Pos_Ack, false);
|
else if (Seq_Type == 2)
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_Motor_Pos_Ack, false);
|
|
_Parent._equip.Align_vision.SendData(vision_control.Send_Motor_Pos_Move_Ack(0));
|
}
|
|
private void btn_User_Command_Req_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = cbb_Align_SeqType.SelectedIndex;
|
int Module_Idx = rb_Align_Left.Checked ? 0 : 1;
|
int Pnl_Idx;
|
int.TryParse(tb_Align_Pnl_Idx.Text, out Pnl_Idx);
|
string Panel_Id = tb_Align_Panel_Id.Text;
|
int Slot_No;
|
int.TryParse(tb_Align_Slot_No.Text, out Slot_No);
|
|
if (Seq_Type == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Film_Judge_User_Command_Ack, false);
|
else if (Seq_Type == 1)
|
_Parent.sm.Set_Bit(Vision_Address.Pre_Align_User_Command_Ack, false);
|
else if (Seq_Type == 2)
|
_Parent.sm.Set_Bit(Vision_Address.Fine_Align_User_Command_Ack, false);
|
|
_Parent._equip.Align_vision.SendData(vision_control.Send_Command_Req(4, Seq_Type, Module_Idx, Slot_No, Pnl_Idx, Panel_Id));
|
}
|
|
private void btn_System_Time_Sync_Req_Click(object sender, EventArgs e)
|
{
|
_Parent.sm.Set_Bit(Vision_Address.Align_PC_System_Time_Sync_Ack, false);
|
_Parent._equip.Align_vision.SendData(vision_control.Send_System_Time_Sync_Req());
|
}
|
|
// Align PC Recv
|
private void btn_Recipe_Change_Ack_Click(object sender, EventArgs e)
|
{
|
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 Return = 1;
|
|
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, BitConverter.GetBytes((short)210));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Grab_Ready_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = cbb_Align_SeqType.SelectedIndex;
|
int Return = 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)220));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Grab_Start_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = cbb_Align_SeqType.SelectedIndex;
|
int Module_Idx = rb_Align_Left.Checked ? 0 : 1;
|
int Return = 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Module_Idx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)230));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Film_Judge_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = 0;
|
int Module_Idx = rb_Align_Left.Checked ? 0 : 1;
|
int Return = 1; // -1 : 진행중, 0 : Film 無(Fail), 1 : Film 有(Success)
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Module_Idx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
|
if (Module_Idx == 0)
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)241));//Left
|
else
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)242));//Right
|
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Align_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = cbb_Align_SeqType.SelectedIndex;
|
int Module_Idx = rb_Align_Left.Checked ? 0 : 1;
|
int Return = 1; // -1 : 진행중, 0 : Align Fail, 1 : Align Success
|
double dAlignX = 0.001; //Align Offset X
|
double dAlignY = 0.002; //Align Offset Y
|
double dAlign_Angle = 0.003;//Align Angle
|
int nCenterAxis = 1; //제품 중심 좌표 (예비)
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Module_Idx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dAlignX));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dAlignY));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dAlign_Angle));
|
body.InsertRange(body.Count, BitConverter.GetBytes(nCenterAxis));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
|
if (Module_Idx == 0)
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)251));//Left
|
else
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)252));//Right
|
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Motor_Pos_Move_Req_Click(object sender, EventArgs e)
|
{
|
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 SeqType = cbb_Align_SeqType.SelectedIndex;
|
int ModuleIdx = rb_Align_Left.Checked ? 0 : 1;
|
int GrabIdx = 1;
|
|
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(GrabIdx));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)281));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Align_User_Command_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = cbb_Align_SeqType.SelectedIndex;
|
int Return = 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)291));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_System_Time_Sync_Ack_Click(object sender, EventArgs e)
|
{
|
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 Return = 1;
|
|
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, BitConverter.GetBytes((short)292));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_Vision_Alive_Click(object sender, EventArgs e)
|
{
|
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 Controller = 1;
|
int HearBeat = lb_Align_Heart_Beat.Text == "1" ? 0 : 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Controller));
|
body.InsertRange(body.Count, BitConverter.GetBytes(HearBeat));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)100));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Align_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
// AOI PC Send
|
private void btn_AOI_Recipe_Change_Req_Click(object sender, EventArgs e)
|
{
|
int Recipe_Mode = cbb_AOI_Recipe_Mode.SelectedIndex + 1;
|
string Recipe_Name = tb_AOI_Recipe_Name.Text;
|
|
_Parent.sm.Set_Bit(Vision_Address.AOI_PC_Recipe_Change_Ack, false);
|
_Parent._equip.Aoi_vision.SendData(vision_control.Send_Recipe_Change_Req(Recipe_Mode, Recipe_Name));
|
}
|
|
private void btn_AOI_Grab_Ready_Req_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = 3;
|
int Module_Idx = rb_AOI_Left.Checked ? 0 : 1;
|
int Grab_Dir = 1;
|
int Pnl_Dir = rb_AOI_Short.Checked ? 0 : 1;
|
int Stage_No;
|
int.TryParse(tb_AOI_Stage_No.Text, out Stage_No);
|
int Slot_No;
|
int.TryParse(tb_AOI_Slot_No.Text, out Slot_No);
|
int Pnl_Idx;
|
int.TryParse(tb_AOI_Pnl_Idx.Text, out Pnl_Idx);
|
string Panel_Id = tb_AOI_Panel_Id.Text;
|
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_Grab_Ready_Ack, false);
|
|
if (Module_Idx == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_Left_Ack, false);
|
else
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_Right_Ack, false);
|
|
_Parent._equip.Aoi_vision.SendData(vision_control.Send_Grab_Ready_Req(Seq_Type, Module_Idx, Grab_Dir, Pnl_Dir, Stage_No, Slot_No, Pnl_Idx, Panel_Id));
|
}
|
|
private void btn_AOI_Grab_Start_Req_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = 3;
|
int Module_Idx = rb_AOI_Left.Checked ? 0 : 1;
|
int Mark_Idx = rb_AOI_Mark_1.Checked ? 0 : 1;
|
double Motor_Offset_X;
|
double.TryParse(tb_AOI_Motor_Offset_X.Text, out Motor_Offset_X);
|
double Motor_Offset_Y;
|
double.TryParse(tb_AOI_Motor_Offset_Y.Text, out Motor_Offset_Y);
|
|
if(Module_Idx == 0)
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_Grab_Start_Left_Ack, false);
|
else
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_Grab_Start_Right_Ack, false);
|
_Parent._equip.Aoi_vision.SendData(vision_control.Send_Grab_Start_Req(Seq_Type, Module_Idx, Mark_Idx, Motor_Offset_X, Motor_Offset_Y));
|
}
|
|
private void btn_AOI_Measurement_Req_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void btn_AOI_Motor_Pos_Move_Ack_Click(object sender, EventArgs e)
|
{
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_Motor_Pos_Ack, false);
|
_Parent._equip.Aoi_vision.SendData(vision_control.Send_Motor_Pos_Move_Ack(0));
|
}
|
|
private void btn_AOI_User_Command_Req_Click(object sender, EventArgs e)
|
{
|
int Seq_Type = 3;
|
int Module_Idx = rb_AOI_Left.Checked ? 0 : 1;
|
int Pnl_Idx;
|
int.TryParse(tb_AOI_Pnl_Idx.Text, out Pnl_Idx);
|
string Panel_Id = tb_AOI_Panel_Id.Text;
|
int Slot_No;
|
int.TryParse(tb_AOI_Slot_No.Text, out Slot_No);
|
|
_Parent.sm.Set_Bit(Vision_Address.Measurement_User_Command_Ack, false);
|
_Parent._equip.Aoi_vision.SendData(vision_control.Send_Command_Req(4, Seq_Type, Module_Idx, Slot_No, Pnl_Idx, Panel_Id));
|
}
|
|
private void btn_AOI_System_Time_Sync_Req_Click(object sender, EventArgs e)
|
{
|
_Parent.sm.Set_Bit(Vision_Address.AOI_PC_System_Time_Sync_Ack, false);
|
_Parent._equip.Aoi_vision.SendData(vision_control.Send_System_Time_Sync_Req());
|
}
|
|
// AOI PC Recv
|
private void btn_AOI_Recipe_Change_Ack_Click(object sender, EventArgs e)
|
{
|
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 Return = 1;
|
|
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, BitConverter.GetBytes((short)210));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_Grab_Ready_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = 3;
|
int Return = 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)220));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_Grab_Start_Ack_Click(object sender, EventArgs e)
|
{
|
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 SeqType = 3;
|
int Module_Idx = rb_AOI_Left.Checked ? 0 : 1;
|
int Return = 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Module_Idx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)230));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_Measurement_Ack_Click(object sender, EventArgs e)
|
{
|
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 Module_Idx = rb_AOI_Left.Checked ? 0 : 1;
|
int nMeasureResult = 1; // -1 : 진행중, 0 : Fail, 1 : Success
|
double dMark1_Point1 = 0.001;//Mark1의 #1(1/4 Point) to 레이저 가공부 상부 Edge 거리
|
double dMark1_Point2 = 0.002;//Mark1의 #2(2/4 Point) to 레이저 가공부 하부 Edge 거리
|
double dMark2_Point1 = 0.003;//Mark2의 #1(3/4 Point) to 레이저 가공부 상부 Edge 거리
|
double dMark2_Point2 = 0.004;//Mark2의 #2(4/4 Point) to 레이저 가공부 하부 Edge 거리
|
double dMark_Distance = 0.005;//Mark1과 Mark2의 거리
|
int nAlign_Result = 1;//-1 : 진행중, 0 : Align Fail, 1 : Align Success
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Module_Idx));
|
body.InsertRange(body.Count, BitConverter.GetBytes(nMeasureResult));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dMark1_Point1));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dMark1_Point2));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dMark2_Point1));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dMark2_Point2));
|
body.InsertRange(body.Count, BitConverter.GetBytes(dMark_Distance));
|
body.InsertRange(body.Count, BitConverter.GetBytes(nAlign_Result));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
|
if (Module_Idx == 0)
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)261));//Left
|
else
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)262));//Right
|
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_Motor_Pos_Move_Req_Click(object sender, EventArgs e)
|
{
|
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 SeqType = 3;
|
int ModuleIdx = 0;
|
int GrabIdx = 1;
|
|
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(GrabIdx));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)281));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_User_Command_Com_Click(object sender, EventArgs e)
|
{
|
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 SeqType = 3;
|
int Return = 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(SeqType));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Return));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)291));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_System_Time_Sync_Ack_Click(object sender, EventArgs e)
|
{
|
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 Return = 1;
|
|
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, BitConverter.GetBytes((short)292));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
|
private void btn_AOI_Vision_Alive_Click(object sender, EventArgs e)
|
{
|
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 Controller = 2;
|
int HearBeat = lb_AOI_Heart_Beat.Text == "1" ? 0 : 1;
|
|
body.InsertRange(body.Count, BitConverter.GetBytes(MsgIndex));
|
body.InsertRange(body.Count, BitConverter.GetBytes(Controller));
|
body.InsertRange(body.Count, BitConverter.GetBytes(HearBeat));
|
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes(body.Count));
|
senddata.InsertRange(senddata.Count, BitConverter.GetBytes((short)100));
|
senddata.InsertRange(senddata.Count, body.ToArray());
|
|
_Parent._equip.Aoi_vision.commandlist.Enqueue(senddata.ToArray());
|
}
|
#endregion
|
|
#region Function
|
|
public void MessageBoxShow(string msg)
|
{
|
MessageBox.Show(msg);
|
}
|
|
private void UI_Update_Th_Set()
|
{
|
while (!_Parent.IsDisposed)
|
{
|
Thread.Sleep(50);
|
if (!update_check)
|
{
|
update_check = true;
|
UI_Update();
|
}
|
}
|
}
|
|
private void UI_Update()
|
{
|
if (InvokeRequired)
|
{
|
BeginInvoke(new UI_Update_Delegate(UI_Update));
|
return;
|
}
|
else
|
{
|
try
|
{
|
DateTime dt = DateTime.Now;
|
|
lb_Time.Text = $"{dt.Hour:d2}:{dt.Minute:d2}:{dt.Second:d2}.{dt.Millisecond:d3}";
|
|
Align_PC_UI_Update();
|
|
AOI_PC_UI_Update();
|
|
TimeSpan ts = DateTime.Now - dt;
|
}
|
catch (Exception ex)
|
{
|
|
}
|
finally
|
{
|
update_check = false;
|
}
|
}
|
}
|
|
private void Align_PC_UI_Update()
|
{
|
object value;
|
if (_Parent._equip.Align_vision != null)
|
{
|
mtb_Align_Ip_Address.Text = _Parent._equip.Align_vision.Ip;
|
mtb_Align_Port.Text = _Parent._equip.Align_vision.Port.ToString();
|
|
if (_Parent._equip.Align_vision.isConnected)
|
{
|
lb_Align_Connect_Status.Text = "Connect";
|
lb_Align_Connect_Status.BackColor = Color.Lime;
|
}
|
else
|
{
|
lb_Align_Connect_Status.Text = "DisConnect";
|
lb_Align_Connect_Status.BackColor = Color.Green;
|
}
|
}
|
else
|
{
|
lb_Align_Connect_Status.Text = "DisConnect";
|
lb_Align_Connect_Status.BackColor = Color.Green;
|
}
|
|
if(_Parent.sm.Get_Value(Vision_Address.Align_PC_Vision_Alive_Heart_Beat, out value))
|
{
|
lb_Align_Heart_Beat.Text = value.ToString();
|
}
|
|
}
|
|
private void AOI_PC_UI_Update()
|
{
|
object value;
|
if (_Parent._equip.Aoi_vision != null)
|
{
|
mtb_AOI_Ip_Address.Text = _Parent._equip.Aoi_vision.Ip;
|
mtb_AOI_Port.Text = _Parent._equip.Aoi_vision.Port.ToString();
|
|
if (_Parent._equip.Aoi_vision.isConnected)
|
{
|
lb_AOI_Connect_Status.Text = "Connect";
|
lb_AOI_Connect_Status.BackColor = Color.Lime;
|
}
|
else
|
{
|
lb_AOI_Connect_Status.Text = "DisConnect";
|
lb_AOI_Connect_Status.BackColor = Color.Green;
|
}
|
}
|
else
|
{
|
lb_AOI_Connect_Status.Text = "DisConnect";
|
lb_AOI_Connect_Status.BackColor = Color.Green;
|
}
|
|
|
if (_Parent.sm.Get_Value(Vision_Address.AOI_PC_Vision_Alive_Heart_Beat, out value))
|
{
|
lb_AOI_Heart_Beat.Text = value.ToString();
|
}
|
}
|
#endregion
|
|
private void btn_Status_Viewer_Show_Click(object sender, EventArgs e)
|
{
|
vision_status_viewer.Show();
|
vision_status_viewer.TopMost = true;
|
vision_status_viewer.TopMost = false;
|
}
|
|
private void Form_Vision_Test_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
if (!_Parent.IsDisposed)
|
{
|
e.Cancel = true;
|
|
this.Hide();
|
}
|
}
|
}
|
}
|