using Newtonsoft.Json; using Prism.Mvvm; using System.Collections.ObjectModel; 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 => JsonConvert.SerializeObject(_InterpolationPoints); // 自动序列化 set { InterpolationPoints = JsonConvert.DeserializeObject>(value); // 自动反序列化 } } 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 } }