using Newtonsoft.Json;
using Prism.Mvvm;
using SKMC.Api.Recipe.Model;
namespace SKMC.Api.Product.Material.Tray
{
///
/// 矩阵物料盘的物料/穴位模型
///
[JsonObject(MemberSerialization.OptIn)]
public class TraySlot : BindableBase
{
[JsonProperty]
public int Index { get; set; }
[JsonProperty]
public int ColX { get; set; }
[JsonProperty]
public int RowY { get; set; }
// 是否可用
public bool IsEnable { get; set; } = true;
public int TrayCols { get; set; }
// X方向电机步距
public double PosX { get; set; }
// Y方向电机步距
public double PosY { get; set; }
// X方向间距 mm
public double IntervalX { get; set; }
// Y方向间距 mm
public double IntervalY { get; set; }
// X方向实际距离 mm
public double DistX { get; set; }
// Y方向实际距离 mm
public double DistY { get; set; }
private double _fixsetX;
// X方向的偏移量 mm(视觉辅助)
public double FixsetX
{
get { return _fixsetX; }
set { _fixsetX = value; }
}
private double _fixsetY;
// Y方向的偏移量 mm(视觉辅助)
public double FixsetY
{
get { return _fixsetY; }
set { _fixsetY = value; }
}
// R方向的偏移量 度(视觉辅助)
public double FixsetR { get; set; }
// 是否定位成功 (0:未定位 1:定位成功 2:定位失败)
public byte Located { get; set; }
private string _code;
// 物料二维码
public string Code
{
get { return _code; }
set { _code = value; RaisePropertyChanged(); }
}
private byte _result = (byte)MatterStatus.UNKNOWN;
[JsonProperty]
public byte Result
{
get { return _result; }
set { _result = value; RaisePropertyChanged(); }
}
// 详细结果
public string ResultMsg { get; set; }
// 重试次数
public int RetryTimes { get; set; }
public RecipePoint ProcessPoint { get; set; }
public void Set(int index)
{
Index = index;
RowY = index / TrayCols;
ColX = index % TrayCols;
}
///
/// 获取产品或穴位定位的偏移量
///
///
public void InjectFixset(TraySlot processTrayMatter)
{
FixsetX = processTrayMatter.FixsetX;
FixsetY = processTrayMatter.FixsetY;
if (ProcessPoint != null)
{
ProcessPoint.RecipePointPositions[0].FixsetVal = processTrayMatter.FixsetX;
ProcessPoint.RecipePointPositions[1].FixsetVal = processTrayMatter.FixsetY;
}
}
public override string ToString()
{
return $"index: {Index}, code: {Code}, result: {Result}, located: {Located}";
}
}
public enum TrayType : byte
{
Main = 0,
NG = 1,
OK = 2
}
public enum MatterStatus : byte
{
UNKNOWN = 0,
OK = 1,
NG = 2,
NGL = 3,
TODO = 4,
EXIST = 5,
NULL = 6,
ERROR = 9
}
public enum LocateStatus : byte
{
TODO = 0,
OK = 1,
FAIL = 2
}
}