| | |
| | | using Bro.Common.Helper; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Drawing.Design; |
| | | using System.Globalization; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | |
| | | //[Description("IsUseWarning:是否启用报警")] |
| | | //public bool IsUseWarning { get; set; } = false; |
| | | |
| | | [Category("原点配置")] |
| | | [DisplayName("回原点参数")] |
| | | [Description("回原点参数")] |
| | | [TypeConverter(typeof(ComplexObjectConvert))] |
| | | [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] |
| | | public GoHomePara GoHomePara { get; set; } = new GoHomePara(); |
| | | |
| | | [Category("暂停配置")] |
| | | [DisplayName("是否启用立即暂停")] |
| | | [Description("IsImmediatePause:是否启用立即暂停")] |
| | |
| | | [Category("速度配置")] |
| | | [DisplayName("加速度")] |
| | | [Description("Acc:加速度,为0时表示不修改当前设置")] |
| | | public double Acc { get; set; } = 1; |
| | | public double Acc { get; set; } = 0; |
| | | |
| | | [Category("速度配置")] |
| | | [DisplayName("减速度")] |
| | | [Description("减速度,为0时表示不修改当前设置")] |
| | | public double Dec { get; set; } = 1; |
| | | public double Dec { get; set; } = 0; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | [Category("回原点参数")] |
| | | [DisplayName("回原点方式")] |
| | | [Description("HomeMode:回原点方式 (HOME_MODE_LIMIT = 10; HOME_MODE_LIMIT_HOME = 11; HOME_MODE_LIMIT_INDEX = 12; HOME_MODE_LIMIT_HOME_INDEX = 13;HOME_MODE_HOME = 20;HOME_MODE_HOME_INDEX = 22;HOME_MODE_INDEX = 30;")] |
| | | public short HomeMode { get; set; } = 11; |
| | | public short HomeMode { get; set; } = 11; |
| | | |
| | | [Category("回原点参数")] |
| | | [DisplayName("回原点方向")] |
| | | [Description("HomeDir:1 正向,-1 负向")] |
| | | public short HomeDir { get; set; } = 1; |
| | | |
| | | [Category("回原点参数")] |
| | | [DisplayName("回原点方向")] |
| | | [Description("HomeDir:1 正向,-1 负向")] |
| | | [DisplayName("边缘")] |
| | | [Description("edge:边缘")] |
| | | public short Edge { get; set; } = 0; |
| | | |
| | | [Category("回原点参数")] |
| | | [Category("回原点速度")] |
| | | [DisplayName("回原点最低速度")] |
| | | [Description("LowVelocity:速度,为0时表示不修改当前设置")] |
| | | public double LowVelocity { get; set; } = 50; |
| | | |
| | | |
| | | [Category("回原点参数")] |
| | | [Category("回原点速度")] |
| | | [DisplayName("回原点最高速度")] |
| | | [Description("HighVelocity:速度,为0时表示不修改当前设置")] |
| | | public double HighVelocity { get; set; } = 50; |
| | | |
| | | [Category("回原点参数")] |
| | | [DisplayName("搜搜距离")] |
| | | [Description("SearchHomeDistance:搜搜距离")] |
| | | public int SearchHomeDistance { get; set; } = 9999999; |
| | | //[Category("回原点参数")] |
| | | //[DisplayName("搜索距离")] |
| | | //[Description("SearchHomeDistance:搜索距离")] |
| | | //public int SearchHomeDistance { get; set; } = 9999999; |
| | | |
| | | [Category("回原点参数")] |
| | | [Category("回原点偏移")] |
| | | [DisplayName("偏移距离")] |
| | | [Description("HomeOffset:偏移距离")] |
| | | public int HomeOffset { get; set; } = 0; |
| | | |
| | | [Category("回原点参数")] |
| | | [Category("回原点偏移")] |
| | | [DisplayName("跳过步长")] |
| | | [Description("EscapeStep:跳过步长")] |
| | | public int EscapeStep { get; set; } = 1000; |
| | | |
| | | [Category("回原点方向")] |
| | | [DisplayName("起始运动方向")] |
| | | [Description("回原点时,轴的初始运动方向:true 正向,false 负向")] |
| | | public bool IsHomeDirPositive { get; set; } = true; |
| | | |
| | | [Category("回原点方向")] |
| | | [DisplayName("原点捕捉方向")] |
| | | [Description("捕捉原点时,轴的运动方向:true 正向,false 负向")] |
| | | public bool IsCaptureDirPositive { get; set; } = true; |
| | | |
| | | [Category("回原点超时")] |
| | | [DisplayName("回原点超时")] |
| | | [Description("回原点超时,单位秒")] |
| | | public int GoHomeTimeOut { get; set; } = 60; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return $"轴{AxisIndex}:{AxisName}-当前:{CurPosition}-规划:{Destination}"; |
| | | return $"轴{AxisIndex}:{AxisName}-当前状态:{AxisStatus}-当前位置:{CurPosition}-规划位置:{Destination}"; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 运动对象 |
| | | /// </summary> |
| | | public class MovingOption : INotifyPropertyChanged, IComplexDisplay |
| | | public class MovingOption : IComplexDisplay |
| | | { |
| | | private int axisIndex = 0; |
| | | [Category("运动配置")] |
| | | [DisplayName("运动轴索引")] |
| | | [Description("AxisIndex:运动轴索引")] |
| | | [TypeConverter(typeof(AxisIndexConvert))] |
| | | public string AxisIndexStr { get; set; } = "1"; |
| | | |
| | | [Browsable(false)] |
| | | [JsonIgnore] |
| | | public int AxisIndex |
| | | { |
| | | get => axisIndex; |
| | | set |
| | | { |
| | | if (axisIndex != value) |
| | | { |
| | | axisIndex = value; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex")); |
| | | } |
| | | axisIndex = value; |
| | | } |
| | | get => int.Parse(AxisIndexStr); |
| | | set => AxisIndexStr = value.ToString(); |
| | | } |
| | | |
| | | private MotionMode moveMode = MotionMode.Normal; |
| | | //private int axisIndex = 0; |
| | | //[Category("运动配置")] |
| | | //[DisplayName("运动轴索引")] |
| | | //[Description("AxisIndex:运动轴索引")] |
| | | //[TypeConverter(typeof(AxisIndexConvert))] |
| | | //public int AxisIndex { get; set; } |
| | | //{ |
| | | // get => axisIndex; |
| | | // set |
| | | // { |
| | | // if (axisIndex != value) |
| | | // { |
| | | // axisIndex = value; |
| | | // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex")); |
| | | // } |
| | | // axisIndex = value; |
| | | // } |
| | | //} |
| | | |
| | | //private MotionMode moveMode = MotionMode.Normal; |
| | | [Category("运动配置")] |
| | | [DisplayName("运动模式")] |
| | | [Description("MoveMode:运动模式")] |
| | | public MotionMode MoveMode |
| | | { |
| | | get => moveMode; |
| | | set |
| | | { |
| | | if (moveMode != value) |
| | | { |
| | | moveMode = value; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode")); |
| | | } |
| | | public MotionMode MoveMode { get; set; } = MotionMode.Normal; |
| | | //{ |
| | | // get => moveMode; |
| | | // set |
| | | // { |
| | | // if (moveMode != value) |
| | | // { |
| | | // moveMode = value; |
| | | // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode")); |
| | | // } |
| | | |
| | | moveMode = value; |
| | | } |
| | | } |
| | | // moveMode = value; |
| | | // } |
| | | //} |
| | | |
| | | private bool isAbsolute = true; |
| | | //private bool isAbsolute = true; |
| | | [Category("运动配置")] |
| | | [DisplayName("是否绝对运动")] |
| | | [Description("IsAbsolute:是否绝对运动")] |
| | | public bool IsAbsolute |
| | | { |
| | | get => isAbsolute; |
| | | set |
| | | { |
| | | if (isAbsolute != value) |
| | | { |
| | | isAbsolute = value; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsAbsolute")); |
| | | } |
| | | public bool IsAbsolute { get; set; } = true; |
| | | //{ |
| | | // get => isAbsolute; |
| | | // set |
| | | // { |
| | | // if (isAbsolute != value) |
| | | // { |
| | | // isAbsolute = value; |
| | | // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsAbsolute")); |
| | | // } |
| | | |
| | | isAbsolute = value; |
| | | } |
| | | } |
| | | // isAbsolute = value; |
| | | // } |
| | | //} |
| | | |
| | | private int destination = 0; |
| | | //private int destination = 0; |
| | | [Category("运动配置")] |
| | | [DisplayName("目的地")] |
| | | [Description("Destination:目的地")] |
| | | public int Destination |
| | | { |
| | | get => destination; |
| | | set |
| | | { |
| | | if (destination != value) |
| | | { |
| | | destination = value; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Destination")); |
| | | } |
| | | public int Destination { get; set; } |
| | | //{ |
| | | // get => destination; |
| | | // set |
| | | // { |
| | | // if (destination != value) |
| | | // { |
| | | // destination = value; |
| | | // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Destination")); |
| | | // } |
| | | |
| | | destination = value; |
| | | } |
| | | } |
| | | // destination = value; |
| | | // } |
| | | //} |
| | | |
| | | private VelocityPara velocityPara = new VelocityPara(); |
| | | //private VelocityPara velocityPara = new VelocityPara(); |
| | | [Category("运动配置")] |
| | | [DisplayName("速度参数")] |
| | | [Description("VelocityPara:速度参数")] |
| | | [TypeConverter(typeof(ComplexObjectConvert))] |
| | | [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] |
| | | public VelocityPara VelocityPara |
| | | { |
| | | get => velocityPara; |
| | | set |
| | | { |
| | | velocityPara = value; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VelocityPara")); |
| | | } |
| | | } |
| | | public VelocityPara VelocityPara { get; set; } = new VelocityPara(); |
| | | //{ |
| | | // get => velocityPara; |
| | | // set |
| | | // { |
| | | // velocityPara = value; |
| | | // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VelocityPara")); |
| | | // } |
| | | //} |
| | | |
| | | private GoHomePara goHomePara = new GoHomePara(); |
| | | [Category("运动配置")] |
| | | [DisplayName("回原点参数")] |
| | | [Description("GoHomePara:速度参数")] |
| | | [TypeConverter(typeof(ComplexObjectConvert))] |
| | | [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] |
| | | public GoHomePara GoHomePara |
| | | { |
| | | get => goHomePara; |
| | | set |
| | | { |
| | | goHomePara = value; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara")); |
| | | } |
| | | } |
| | | //private GoHomePara goHomePara = new GoHomePara(); |
| | | //[Category("运动配置")] |
| | | //[DisplayName("回原点参数")] |
| | | //[Description("GoHomePara:速度参数")] |
| | | //[TypeConverter(typeof(ComplexObjectConvert))] |
| | | //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] |
| | | //public GoHomePara GoHomePara { get; set; } = new GoHomePara(); |
| | | //{ |
| | | // get => goHomePara; |
| | | // set |
| | | // { |
| | | // goHomePara = value; |
| | | // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara")); |
| | | // } |
| | | //} |
| | | |
| | | [Category("板卡运动配置")] |
| | | [Description("超时设置,单位:ms")] |
| | |
| | | public int MovingTimeout { get; set; } = 0; |
| | | |
| | | internal List<AxisSetting> _axisSettingList = new List<AxisSetting>(); |
| | | |
| | | public void SetAxisSetting(List<AxisSetting> settings) |
| | | { |
| | | if (settings != null) |
| | |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | string axisName = AxisIndex.ToString(); |
| | | string axisName = AxisIndexStr; |
| | | var axisSet = _axisSettingList.FirstOrDefault(a => a.AxisIndex == AxisIndex); |
| | | if (axisSet != null) |
| | | { |
| | |
| | | } |
| | | return axisName + "," + MoveMode.ToString() + "," + (IsAbsolute ? "Abs" : "Rel") + "," + Destination; |
| | | } |
| | | public event PropertyChangedEventHandler PropertyChanged; |
| | | //public event PropertyChangedEventHandler PropertyChanged; |
| | | } |
| | | |
| | | public class AxisIndexConvert : TypeConverter |
| | | public class AxisIndexConvert : ComboBoxItemTypeConvert |
| | | { |
| | | Dictionary<int, string> _indexNameDict = new Dictionary<int, string>(); |
| | | |
| | | public override bool GetStandardValuesSupported(ITypeDescriptorContext context) |
| | | public override Hashtable GetConvertHash(ITypeDescriptorContext context) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) |
| | | { |
| | | MovingOption mo = context.Instance as MovingOption; |
| | | |
| | | _indexNameDict = mo._axisSettingList.ToDictionary(a => a.AxisIndex, a => a.AxisIndex + "-" + a.AxisName); |
| | | |
| | | return new StandardValuesCollection(_indexNameDict.Keys); |
| | | } |
| | | |
| | | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
| | | { |
| | | if (sourceType == typeof(string)) |
| | | Hashtable table = new Hashtable(); |
| | | if (context.Instance is MovingOption op) |
| | | { |
| | | return true; |
| | | } |
| | | return base.CanConvertFrom(context, sourceType); |
| | | } |
| | | |
| | | public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v) |
| | | { |
| | | if (v is string) |
| | | { |
| | | foreach (var indexName in _indexNameDict) |
| | | op._axisSettingList.ForEach(a => |
| | | { |
| | | if (indexName.Value == v.ToString()) |
| | | { |
| | | return indexName.Key; |
| | | } |
| | | } |
| | | return Convert.ToInt32(v); |
| | | table[a.AxisIndex.ToString()] = a.AxisName; |
| | | }); |
| | | } |
| | | return base.ConvertFrom(context, culture, v); |
| | | |
| | | return table; |
| | | } |
| | | |
| | | public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v, Type destinationType) |
| | | { |
| | | if (destinationType == typeof(string)) |
| | | { |
| | | if (_indexNameDict.ContainsKey(Convert.ToInt32(v))) |
| | | { |
| | | return _indexNameDict[Convert.ToInt32(v)]; |
| | | } |
| | | } |
| | | return base.ConvertTo(context, culture, v, destinationType); |
| | | } |
| | | //public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
| | | //{ |
| | | // bool flag = base.CanConvertFrom(context, sourceType); |
| | | // return flag; |
| | | //} |
| | | |
| | | public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) |
| | | { |
| | | return false; |
| | | } |
| | | //public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) |
| | | //{ |
| | | // return base.CanConvertTo(context, destinationType); |
| | | //} |
| | | |
| | | //public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object v) |
| | | //{ |
| | | // //if (string.IsNullOrWhiteSpace(v.ToString())) |
| | | // //{ |
| | | // // return 0; |
| | | // //} |
| | | |
| | | // return base.ConvertFrom(context, culture, Convert.ToInt32(v)); |
| | | //} |
| | | |
| | | //public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object v, Type destinationType) |
| | | //{ |
| | | // return base.ConvertTo(context, culture, v, destinationType); |
| | | //} |
| | | } |
| | | |
| | | //public class AxisIndexConvert : TypeConverter |
| | | //{ |
| | | // Dictionary<int, string> _indexNameDict = new Dictionary<int, string>(); |
| | | |
| | | // public override bool GetStandardValuesSupported(ITypeDescriptorContext context) |
| | | // { |
| | | // return true; |
| | | // } |
| | | |
| | | // public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) |
| | | // { |
| | | // MovingOption mo = context.Instance as MovingOption; |
| | | |
| | | // _indexNameDict = mo._axisSettingList.ToDictionary(a => a.AxisIndex, a => a.AxisIndex + "-" + a.AxisName); |
| | | |
| | | // return new StandardValuesCollection(_indexNameDict.Keys); |
| | | // } |
| | | |
| | | // public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
| | | // { |
| | | // if (sourceType == typeof(string)) |
| | | // { |
| | | // return true; |
| | | // } |
| | | // return base.CanConvertFrom(context, sourceType); |
| | | // } |
| | | |
| | | // public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v) |
| | | // { |
| | | // if (v is string) |
| | | // { |
| | | // foreach (var indexName in _indexNameDict) |
| | | // { |
| | | // if (indexName.Value == v.ToString()) |
| | | // { |
| | | // return indexName.Key; |
| | | // } |
| | | // } |
| | | // return Convert.ToInt32(v); |
| | | // } |
| | | // return base.ConvertFrom(context, culture, v); |
| | | // } |
| | | |
| | | // public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v, Type destinationType) |
| | | // { |
| | | // if (destinationType == typeof(string)) |
| | | // { |
| | | // if (_indexNameDict.ContainsKey(Convert.ToInt32(v))) |
| | | // { |
| | | // return _indexNameDict[Convert.ToInt32(v)]; |
| | | // } |
| | | // } |
| | | // return base.ConvertTo(context, culture, v, destinationType); |
| | | // } |
| | | |
| | | // public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) |
| | | // { |
| | | // return false; |
| | | // } |
| | | //} |
| | | |
| | | public class AxisConflictSet : IComplexDisplay |
| | | { |
| | | [Category("1.轴冲突条件")] |