using Newtonsoft.Json;
using Prism.Mvvm;
using System.ComponentModel.DataAnnotations.Schema;
namespace PLCSharp.VVMs.Robots
{
///
/// 机器人点位
///
public class RobotPoint : BindableBase
{
#region 属性
///
/// 唯一标识
///
public Guid ID { get; set; } = Guid.NewGuid();
///
/// 配方标识
///
public Guid RecipeID { get; set; }
///
/// 机器人ID
///
public Guid RobotID { get; set; }
///
/// 点位类型
///
public int PointType { get; set; }
private string _Name;
///
/// 点名称
///
public string Name
{
get { return _Name; }
set { SetProperty(ref _Name, value); }
}
private double _X;
///
/// X坐标
///
public double X
{
get { return _X; }
set
{
value = Math.Round(value, 4);
SetProperty(ref _X, value);
}
}
private double _Y;
///
/// Y坐标
///
public double Y
{
get { return _Y; }
set
{
value = Math.Round(value, 4);
SetProperty(ref _Y, value);
}
}
private double _Z;
///
/// Z坐标
///
public double Z
{
get { return _Z; }
set
{
value = Math.Round(value, 4);
SetProperty(ref _Z, value);
}
}
private double _U;
///
/// U坐标 (Rx)
///
public double U
{
get { return _U; }
set
{
value = Math.Round(value, 4);
SetProperty(ref _U, value);
}
}
private double _V;
///
/// V
///
public double V
{
get { return _V; }
set
{
value = Math.Round(value, 4);
SetProperty(ref _V, value);
}
}
private double _W;
///
/// W
///
public double W
{
get { return _W; }
set
{
value = Math.Round(value, 4);
SetProperty(ref _W, value);
}
}
private double _Rate = 100;
///
/// 速率 1-100
///
public double Rate
{
get { return _Rate; }
set
{
if (value > 100)
value = 100;
else if (value < 1)
value = 1;
SetProperty(ref _Rate, value);
}
}
#region 左右手
private HandType _Hand = HandType.R;
///
/// 左右手 0-L 1-R
///
public HandType Hand
{
get { return _Hand; }
set { SetProperty(ref _Hand, value); }
}
#endregion
#region 工具坐标系
private int _ToolNum = 0;
///
/// 工具坐标系编号
///
public int ToolNum
{
get { return _ToolNum; }
set { SetProperty(ref _ToolNum, value); }
}
#endregion
#region 用户坐标系
private short _UF = 0;
///
/// 用户坐标系
///
public short UF
{
get { return _UF; }
set { SetProperty(ref _UF, value); }
}
#endregion
///
/// Safe
///
[NotMapped]
///
/// 是否安全可运行
///
public bool Safe { get; set; } = true;
///
/// 序列化Params
///
[Column("Params")]
public string SerializedParams
{
get => JsonConvert.SerializeObject(Params);
set => Params = JsonConvert.DeserializeObject(value);
}
private PointParams _Params;
///
/// 参数集合
///
[NotMapped]
public PointParams Params
{
get
{
_Params ??= new PointParams();
return _Params;
}
set
{
SetProperty(ref _Params, value);
}
}
///
/// Command
///
[NotMapped]
public string Command { get; set; }
///
/// 点位Params
///
public class PointParams : BindableBase
{
}
#endregion
}
}