using PLCSharp.Core.Tools;
using Prism.Mvvm;
using System.Collections.ObjectModel;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace PLCSharp.VVMs.MotionController
{
///
/// 插补
///
public class Interpolation : BindableBase
{
#region 属性
private string _Name;
///
/// 点名称
///
public string Name
{
get { return _Name; }
set { SetProperty(ref _Name, value); }
}
private InterpolationType _Type;
///
/// 类型
///
public InterpolationType Type
{
get { return _Type; }
set { SetProperty(ref _Type, value); }
}
///
/// 序列化Interpolations
///
public string SerializedInterpolations
{
get => JsonSerializer.Serialize(_InterpolationPoints, JsonOptions.Default); // 自动序列化
set
{
InterpolationPoints = JsonSerializer.Deserialize>(value, JsonOptions.Default); // 自动反序列化
}
}
private ObservableCollection _InterpolationPoints = [];
///
/// 插补Points
///
[JsonIgnore]
public ObservableCollection InterpolationPoints
{
get { return _InterpolationPoints; }
set { SetProperty(ref _InterpolationPoints, value); }
}
private InterpolationParams _Params;
///
/// 配置项
///
public InterpolationParams Params
{
get
{
_Params ??= new InterpolationParams();
return _Params;
}
set
{
SetProperty(ref _Params, value);
}
}
///
/// 插补Params
///
public class InterpolationParams : BindableBase
{
private string _Prompt;
///
/// 提示
///
[JsonIgnore]
public string Prompt
{
get { return _Prompt; }
set { SetProperty(ref _Prompt, value); }
}
private ushort _Dir;
///
/// Dir
///
public ushort Dir
{
get { return _Dir; }
set { SetProperty(ref _Dir, value); }
}
private ushort _PositionMode;
///
/// 位置Mode
///
public ushort PositionMode
{
get { return _PositionMode; }
set { SetProperty(ref _PositionMode, value); }
}
}
#endregion 属性
}
public enum InterpolationType
{
Line直线 = 0,
Arc圆弧 = 1
}
}