|
|
|
|
using Rs.Controls;
|
|
|
|
|
using Rs.Framework;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Rs.MotionPlat.Commom
|
|
|
|
|
{
|
|
|
|
|
public class TrayPosition
|
|
|
|
|
{
|
|
|
|
|
private int m_row = 26;
|
|
|
|
|
private int m_column = 10;
|
|
|
|
|
private TrayPosition()
|
|
|
|
|
{
|
|
|
|
|
//for (int i = 0; i < m_row; i++)
|
|
|
|
|
//{
|
|
|
|
|
// for(int j=0;j<m_column;j++)
|
|
|
|
|
// {
|
|
|
|
|
// TraySlot ts = new TraySlot();
|
|
|
|
|
// ts.Row = i + 1;
|
|
|
|
|
// ts.Column= j + 1;
|
|
|
|
|
// ts.Position = new PointF(0, 0);
|
|
|
|
|
// SlotPoints.Add(ts);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
public TrayPosition(int row,int column,string trayName) {
|
|
|
|
|
m_row= row;
|
|
|
|
|
m_column= column;
|
|
|
|
|
TrayName= trayName;
|
|
|
|
|
}
|
|
|
|
|
public string TrayName { get; set; } = "料盘1";
|
|
|
|
|
|
|
|
|
|
public PointF LeftTop { get; set; } = new PointF(0, 0);
|
|
|
|
|
public PointF LeftBottom { get; set; } = new PointF(0, 0);
|
|
|
|
|
public PointF RightBottom { get; set; } = new PointF(0, 0);
|
|
|
|
|
|
|
|
|
|
public BindingList<TraySlot> SlotPoints { get; set; } = new BindingList<TraySlot>();
|
|
|
|
|
|
|
|
|
|
public bool Save()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
float offsetX = Math.Abs(LeftTop.X - RightBottom.X)/(m_column-1);
|
|
|
|
|
float offsetY = Math.Abs(LeftTop.Y - LeftBottom.Y)/(m_row-1);
|
|
|
|
|
int index = 0;
|
|
|
|
|
SlotPoints.Clear();
|
|
|
|
|
for (int i = 0; i < m_column; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < m_row; j++)
|
|
|
|
|
{
|
|
|
|
|
index++;
|
|
|
|
|
TraySlot ts = new TraySlot();
|
|
|
|
|
ts.Index = index;
|
|
|
|
|
ts.Row = i + 1;
|
|
|
|
|
ts.Column = j + 1;
|
|
|
|
|
ts.Position = new PointF(LeftTop.X + (i * offsetX), LeftTop.Y + (j * offsetY));
|
|
|
|
|
SlotPoints.Add(ts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
XmlSerializerHelper.Instance.Serialize($"Recipe/{TrayName}.xml", this);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TrayPosition Load(string trayName)
|
|
|
|
|
{
|
|
|
|
|
XmlSerializerHelper.Instance.Deserialize($"Recipe/{trayName}.xml",out TrayPosition entity);
|
|
|
|
|
if (entity == null)
|
|
|
|
|
return new TrayPosition(26,10, trayName);
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|