You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.6 KiB
C#

2 years ago
using Rs.Camera;
using Rs.Controls;
using Rs.Framework;
using Rs.Motion;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Flow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Rs.MotionPlat
{
public partial class TrayRecipe : BaseForm
{
ButtonEx m_button;
TrayPosition trayPosition;
public TrayRecipe()
{
InitializeComponent();
}
public TrayRecipe(ButtonEx button)
{
InitializeComponent();
m_button = button;
}
private void TrayRecipe_Load(object sender, EventArgs e)
{
dataGridView1.AutoGenerateColumns = false;
rsTray1.HeadText = m_button.ShowText;
trayPosition = TrayPosition.Load(m_button.ShowText,10,5);
2 years ago
slot_lefttop.Position = trayPosition.LeftTop;
slot_leftbottom.Position = trayPosition.LeftBottom;
slot_rightbottom.Position = trayPosition.RightBottom;
//trayPosition.SlotPoints.Select(new Func<TraySlot, TResult> { })
dataGridView1.DataSource = trayPosition.SlotPoints.Select(sp =>new { Index=sp.Index,X=sp.Position.X,Y=sp.Position.Y } ).ToList();
timer1.Interval = 1000;
timer1.Enabled = true;
}
int val = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (val == 0) val = 1;
else if (val == 1) val = 0;
rsTray1.ChangeStatus(1, val);
rsTray1.ChangeStatus(10, val);
rsTray1.ChangeStatus(50, val);
2 years ago
}
protected void SavePosEvent(object sender, EventArgs e)
{
//获取当前上料XY坐标
//ErrorCode errCode = AxisControl.LoadX.GetEncoderPosition(out double dEncPosX);
//if(errCode> ErrorCode.Ok)
//{
// Msg.ShowError(errCode.ToString());
// return;
//}
//AxisControl.LoadY.GetEncoderPosition(out double dEncPosY);
//if (errCode > ErrorCode.Ok)
//{
// Msg.ShowError(errCode.ToString());
// return;
//}
TrayLocation trayLocation=(TrayLocation)sender;
if (trayLocation == slot_lefttop)
trayPosition.LeftTop = new PointF(slot_lefttop.PosX, slot_lefttop.PosY);
if (trayLocation == slot_leftbottom)
trayPosition.LeftBottom = new PointF(slot_leftbottom.PosX, slot_leftbottom.PosY);
if (trayLocation == slot_rightbottom)
trayPosition.RightBottom = new PointF(slot_rightbottom.PosX, slot_rightbottom.PosY);
trayPosition.Save();
2 years ago
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
if (e.ColumnIndex == 3)
{
int slot = e.RowIndex + 1;
DialogResult dr = MessageBox.Show($"确定移动到{slot}号槽位吗?","Tips",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
}
}
}
private void rsTray1_SlotClickEvent(TraySlot obj, MouseEventArgs e)
{
contextMenuStrip1.Show(rsTray1, new Point(e.Location.X+15,e.Location.Y+40));
}
private void tsmi_go_Click(object sender, EventArgs e)
{
MessageBox.Show(rsTray1.SelectSlot.Index.ToString());
}
}
}