From 799808db1ace43141760a1fe74b2cbf28ddb2e39 Mon Sep 17 00:00:00 2001 From: wells <123> Date: 星期五, 10 七月 2020 18:41:25 +0800 Subject: [PATCH] 合并 --- src/Bro.Common.Model/Model/MotionCardRelated.cs | 455 +++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 283 insertions(+), 172 deletions(-) diff --git a/src/Bro.Common.Model/Model/MotionCardRelated.cs b/src/Bro.Common.Model/Model/MotionCardRelated.cs index 5b4f5ac..7010262 100644 --- a/src/Bro.Common.Model/Model/MotionCardRelated.cs +++ b/src/Bro.Common.Model/Model/MotionCardRelated.cs @@ -1,9 +1,11 @@ 锘縰sing 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; @@ -35,66 +37,66 @@ [Category("鎹㈢畻閰嶇疆")] [DisplayName("鑴夊啿鏁版崲绠楁瘮渚�")] [Description("鑴夊啿鏁板拰鍏朵粬璁¢噺鍗曚綅鐨勬崲绠楁瘮渚嬶紝渚嬪璁剧疆涓�1000锛岃〃绀�1000涓剦鍐茬瓑浜�1uint")] - public int PulseRatio { get; set; } = 1; + public int AxisRatio { get; set; } = 1; - [Category("閫熷害閰嶇疆")] - [DisplayName("榛樿閫熷害鍙傛暟")] - [Description("VelocityPara锛氶粯璁ら�熷害鍙傛暟")] - [TypeConverter(typeof(ComplexObjectConvert))] - [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] - public VelocityPara VelocityPara { get; set; } = new VelocityPara(); + //[Category("閫熷害閰嶇疆")] + //[DisplayName("榛樿閫熷害鍙傛暟")] + //[Description("VelocityPara锛氶粯璁ら�熷害鍙傛暟")] + //[TypeConverter(typeof(ComplexObjectConvert))] + //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] + //public VelocityPara VelocityPara { get; set; } = new VelocityPara(); - [Category("鍥炲師鐐硅缃�")] - [DisplayName("鍥炲師鐐规ā寮�")] - [Description("HomeMode锛氬洖鍘熺偣妯″紡銆�0锛氫竴鑸ā寮� 1锛氭瀬闄愰檺浣嶆ā寮� 2锛氬閮ㄨЕ鍙戞ā寮�")] - public int HomeMode { get; set; } = 0; + //[Category("鍥炲師鐐硅缃�")] + //[DisplayName("鍥炲師鐐规ā寮�")] + //[Description("HomeMode锛氬洖鍘熺偣妯″紡銆�0锛氫竴鑸ā寮� 1锛氭瀬闄愰檺浣嶆ā寮� 2锛氬閮ㄨЕ鍙戞ā寮�")] + //public int HomeMode { get; set; } = 0; - [Category("鍥炲師鐐硅缃�")] - [DisplayName("鍥炲師鐐规柟鍚�")] - [Description("IsHomePositive锛氬洖鍘熺偣鏂瑰悜銆� true锛氭鏂瑰悜寮�濮� false锛氳礋鏂瑰悜寮�濮�")] - public bool IsHomePositive { get; set; } = true; + //[Category("鍥炲師鐐硅缃�")] + //[DisplayName("鍥炲師鐐规柟鍚�")] + //[Description("IsHomePositive锛氬洖鍘熺偣鏂瑰悜銆� true锛氭鏂瑰悜寮�濮� false锛氳礋鏂瑰悜寮�濮�")] + //public bool IsHomePositive { get; set; } = true; - [Category("鍥炲師鐐硅缃�")] - [DisplayName("鏄惁鑷姩鍥炲師鐐�")] - [Description("IsAutoGoHome锛氭槸鍚﹁嚜鍔ㄥ洖鍘熺偣銆� true锛氭槸 false锛氬惁")] - public bool IsAutoGoHome { get; set; } = false; + //[Category("鍥炲師鐐硅缃�")] + //[DisplayName("鏄惁鑷姩鍥炲師鐐�")] + //[Description("IsAutoGoHome锛氭槸鍚﹁嚜鍔ㄥ洖鍘熺偣銆� true锛氭槸 false锛氬惁")] + //public bool IsAutoGoHome { get; set; } = false; - [Category("瓒呮椂璁剧疆")] - [DisplayName("鍥炲師鐐硅秴鏃�")] - [Description("TimeOutHome锛氬洖鍘熺偣瓒呮椂锛屽崟浣嶆绉�")] - public int TimeOutHome { get; set; } = 30000; + //[Category("瓒呮椂璁剧疆")] + //[DisplayName("鍥炲師鐐硅秴鏃�")] + //[Description("TimeOutHome锛氬洖鍘熺偣瓒呮椂锛屽崟浣嶆绉�")] + //public int TimeOutHome { get; set; } = 30000; - [Category("瓒呮椂璁剧疆")] - [DisplayName("杩愬姩瓒呮椂")] - [Description("TimeOutMove锛氳繍鍔ㄨ秴鏃讹紝鍗曚綅姣")] - public int TimeOutMove { get; set; } = 10000; + //[Category("瓒呮椂璁剧疆")] + //[DisplayName("杩愬姩瓒呮椂")] + //[Description("TimeOutMove锛氳繍鍔ㄨ秴鏃讹紝鍗曚綅姣")] + //public int TimeOutMove { get; set; } = 10000; - [Category("寮�闂幆璁剧疆")] - [DisplayName("鏄惁浣跨敤Cmmd鍥為")] - [Description("IsUseCmmdPosition锛氭槸鍚︿娇鐢–mmd鍥為")] - public bool IsUseCmmdPosition { get; set; } = false; + //[Category("寮�闂幆璁剧疆")] + //[DisplayName("鏄惁浣跨敤Cmmd鍥為")] + //[Description("IsUseCmmdPosition锛氭槸鍚︿娇鐢–mmd鍥為")] + //public bool IsUseCmmdPosition { get; set; } = false; - [Category("寮�闂幆璁剧疆")] - [DisplayName("鏄惁浣跨敤鏉垮崱鍙嶉鍋滄淇″彿")] - [Description("IsUseMDNStopSignal锛氭槸鍚︿娇鐢ㄦ澘鍗″弽棣堝仠姝俊鍙�")] - public bool IsUseMDNStopSignal { get; set; } = false; + //[Category("寮�闂幆璁剧疆")] + //[DisplayName("鏄惁浣跨敤鏉垮崱鍙嶉鍋滄淇″彿")] + //[Description("IsUseMDNStopSignal锛氭槸鍚︿娇鐢ㄦ澘鍗″弽棣堝仠姝俊鍙�")] + //public bool IsUseMDNStopSignal { get; set; } = false; - [Category("寮�闂幆璁剧疆")] - [DisplayName("鏄惁鍚敤鎶ヨ")] - [Description("IsUseWarning锛氭槸鍚﹀惎鐢ㄦ姤璀�")] - public bool IsUseWarning { get; set; } = false; + //[Category("寮�闂幆璁剧疆")] + //[DisplayName("鏄惁鍚敤鎶ヨ")] + //[Description("IsUseWarning锛氭槸鍚﹀惎鐢ㄦ姤璀�")] + //public bool IsUseWarning { get; set; } = false; [Category("鏆傚仠閰嶇疆")] [DisplayName("鏄惁鍚敤绔嬪嵆鏆傚仠")] [Description("IsImmediatePause锛氭槸鍚﹀惎鐢ㄧ珛鍗虫殏鍋�")] public bool IsImmediatePause { get; set; } = false; - [Category("鏆傚仠閰嶇疆")] - [DisplayName("杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] - [Description("ImmediatePauseSections锛氬綋杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] - [TypeConverter(typeof(CollectionCountConvert))] - [Editor(typeof(ComplexCollectionEditor<Section>), typeof(UITypeEditor))] - public List<Section> ImmediatePauseSections { get; set; } = new List<Section>(); + //[Category("鏆傚仠閰嶇疆")] + //[DisplayName("杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] + //[Description("ImmediatePauseSections锛氬綋杞翠綅缃浜庡尯闂村唴鏃堕�傜敤鐨勬殏鍋滄搷浣�")] + //[TypeConverter(typeof(CollectionCountConvert))] + //[Editor(typeof(ComplexCollectionEditor<Section>), typeof(UITypeEditor))] + //public List<Section> ImmediatePauseSections { get; set; } = new List<Section>(); public string GetDisplayText() { @@ -193,119 +195,185 @@ } /// <summary> + /// 鏉垮崱杩愬姩鐘舵�佸璞� + /// </summary> + public class AxisMovingStatus : IComplexDisplay + { + /// <summary> + /// 杞寸储寮� + /// </summary> + public int AxisIndex { get; set; } + + /// <summary> + /// 杞村悕绉� + /// </summary> + public string AxisName { get; set; } + + /// <summary> + /// 褰撳墠浣嶇疆 + /// </summary> + public int CurPosition { get; set; } + + /// <summary> + /// 鐩殑鍦� + /// </summary> + public int Destination { get; set; } + + /// <summary> + /// 褰撳墠閫熷害鍙傛暟 + /// </summary> + public double CurVelocity { get; set; } + + /// <summary> + /// 瑙勫垝閫熷害鍙傛暟 + /// </summary> + public double PrfVelocity { get; set; } + + /// <summary> + /// 杞寸姸鎬� + /// </summary> + public int AxisStatus { get; set; } + + public string GetDisplayText() + { + 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; } = "0"; + + [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 MotorMoveMode moveMode = MotorMoveMode.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 MotorMoveMode 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(); + //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")); - } - } + public GoHomePara GoHomePara { get; set; } = new GoHomePara(); + //{ + // get => goHomePara; + // set + // { + // goHomePara = value; + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara")); + // } + //} + + [Category("鏉垮崱杩愬姩閰嶇疆")] + [Description("瓒呮椂璁剧疆锛屽崟浣嶏細ms")] + [DisplayName("杩愬姩瓒呮椂")] + public int MovingTimeout { get; set; } = 0; internal List<AxisSetting> _axisSettingList = new List<AxisSetting>(); + public void SetAxisSetting(List<AxisSetting> settings) { if (settings != null) @@ -314,7 +382,7 @@ public string GetDisplayText() { - string axisName = AxisIndex.ToString(); + string axisName = AxisIndexStr; var axisSet = _axisSettingList.FirstOrDefault(a => a.AxisIndex == AxisIndex); if (axisSet != null) { @@ -322,70 +390,113 @@ } 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.杞村啿绐佹潯浠�")] -- Gitblit v1.8.0