From 0d97500a3aac13b642fc93fae2e5dd01e1086b21 Mon Sep 17 00:00:00 2001 From: wells.liu <wells.liu@broconcentric.com> Date: 星期一, 29 六月 2020 12:31:12 +0800 Subject: [PATCH] 暂存 固高板卡 --- src/Bro.Device.GTSCard/GTSCardConfig.cs | 854 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 641 insertions(+), 213 deletions(-) diff --git a/src/Bro.Device.GTSCard/GTSCardConfig.cs b/src/Bro.Device.GTSCard/GTSCardConfig.cs index 49d9c60..de7aad9 100644 --- a/src/Bro.Device.GTSCard/GTSCardConfig.cs +++ b/src/Bro.Device.GTSCard/GTSCardConfig.cs @@ -1,247 +1,675 @@ 锘縰sing Bro.Common.Base; using Bro.Common.Helper; using Bro.Common.Interface; +using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Configuration; using System.Drawing.Design; +using System.Linq; +using System.Threading; +using static Bro.Common.Helper.EnumHelper; namespace Bro.Device.GTSCard { - public abstract class GTSCardOperationConfigBase : OperationConfigBase + + [Device("GTSCard", "鍥洪珮鏉垮崱", EnumHelper.DeviceAttributeType.OperationConfig)] + public class GTSCardOperationConfig : OperationConfigBase, IComplexDisplay { - ///// <summary> - ///// 闇�瑕佹搷浣滅殑PLC椤� - ///// </summary> - //public List<PLCItem> Items { get; set; } = new List<PLCItem>(); + [Category("鏉垮崱杩愬姩閰嶇疆")] + [DisplayName("杩愬姩閰嶇疆闆嗗悎")] + [Description("MovingOps锛氳繍鍔ㄩ厤缃泦鍚�")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<MovingOption>), typeof(UITypeEditor))] + public ObservableCollection<MovingOption> MovingOps { get; set; } = new ObservableCollection<MovingOption>(); + + public string GetDisplayText() + { + return MovingOps.Count() == 0 ? "--" : string.Join(";", MovingOps.Select(m => m.GetDisplayText())); + } } - //public class GTSCardInitialConfigBase : InitialConfigBase, IMonitorConfig - //{ - // [Category("椹卞姩绫诲瀷")] - // [Description("椹卞姩绫诲瀷")] - // [DisplayName("椹卞姩绫诲瀷")] - // [TypeConverter(typeof(PLCTypeConverter))] - // public override string DriverType { get; set; } + [Device("GTSCard", "鍥洪珮鏉垮崱", EnumHelper.DeviceAttributeType.OperationConfig)] + public class GTSCardInitialConfig : InitialConfigBase, IMonitorConfig + { + [Category("鏉垮崱閰嶇疆")] + [DisplayName("鍗″彿")] + [Description("CardNum锛氬崱鍙�")] + public int CardNum { get; set; } - // [Category("璀︽姤閰嶇疆")] - // [Description("璀︽姤閰嶇疆鍒楄〃")] - // [DisplayName("璀︽姤閰嶇疆")] - // [TypeConverter(typeof(CollectionCountConvert))] - // [Editor(typeof(WarningSetsEditor), typeof(UITypeEditor))] - // public List<WarningSet> WarningSetCollection { get; set; } = new List<WarningSet>(); + //[Category("鏉垮崱閰嶇疆")] + //[Description("IO鍗″彿")] + //public int IOCardNum { get; set; } - // #region IMonitorConfig - // [Category("鐩戝惉璁剧疆")] - // [Description("鐩戝惉鎿嶄綔閰嶇疆闆嗗悎")] - // [DisplayName("鐩戝惉閰嶇疆")] - // [TypeConverter(typeof(CollectionCountConvert))] - // [Editor(typeof(ComplexCollectionEditor<MonitorSet>), typeof(UITypeEditor))] - // public List<IMonitorSet> MonitorSetCollection { get; set; } = new List<IMonitorSet>(); + [Category("鏉垮崱閰嶇疆")] + [DisplayName("鍒濆閰嶇疆鏂囦欢璺緞")] + [Description("InitialConfigFilePath锛氬垵濮嬮厤缃枃浠惰矾寰�")] + [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))] + public string InitialConfigFilePath { get; set; } - // [Category("鐩戝惉璁剧疆")] - // [Description("true锛氬惎鍔ㄧ洃鍚� false锛氬叧闂洃鍚�")] - // [DisplayName("鐩戝惉鍚敤")] - // public bool IsEnableMonitor { get; set; } = true; + [Category("IO鎵弿閰嶇疆")] + [DisplayName("鎵弿闂撮殧")] + [Description("ScanInterval锛氭壂鎻忛棿闅旓紝浠ユ绉掍负鍗曚綅")] + public int ScanInterval { get; set; } = 100; - // [Category("鐩戝惉璁剧疆")] - // [Description("鎵弿闂撮殧鏃堕棿锛屽崟浣嶏細ms")] - // [DisplayName("鎵弿闂撮殧")] - // public int MonitorInterval { get; set; } = 100; + [Category("杞撮厤缃�")] + [DisplayName("杞存暟閲�")] + [Description("AxisNum锛氳酱鏁伴噺")] + public int AxisNum { get; set; } = 2; - // [Category("鐩戝惉璁剧疆")] - // [Description("瓒呮椂璁剧疆锛屽崟浣嶏細ms")] - // [DisplayName("鐩戝惉瓒呮椂")] - // public int MonitorTimeout { get; set; } = 500; + [Category("杞撮厤缃�")] + [DisplayName("杞撮厤缃俊鎭泦鍚�")] + [Description("AxisSettings锛氳酱閰嶇疆淇℃伅闆嗗悎")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<AxisSetting>), typeof(UITypeEditor))] + public List<AxisSetting> AxisSettings { get; set; } = new List<AxisSetting>(); - // [Category("浜嬩欢鍦板潃璁剧疆")] - // [Description("浜嬩欢寮�濮嬪湴鍧�锛孭LC鐨勫疄闄呭瘎瀛樺櫒鍦板潃銆傚崄杩涘埗锛屼笉鍖呭惈鍔熻兘鐮併��")] - // [DisplayName("鐩戝惉寮�濮嬪湴鍧�")] - // public int EventStartAddress { get; set; } = 8000; + [Category("杞撮厤缃�")] + [DisplayName("杞撮�熷害姣旂巼")] + [Description("AxisVelocityRatio锛氳酱閫熷害姣旂巼")] + public double AxisVelocityRatio { get; set; } = 1; - // [Category("浜嬩欢鍦板潃璁剧疆")] - // [Description("浜嬩欢鍦板潃闀垮害锛屾渶澶ч暱搴�128")] - // [DisplayName("鐩戝惉闀垮害")] - // public int EventLength { get; set; } = 120; + [Category("寤舵椂閰嶇疆")] + [DisplayName("鍔ㄤ綔瀹屾垚鍚庡欢杩�")] + [Description("ActionAfterDelay锛氬姩浣滃畬鎴愬悗寤惰繜")] + public int ActionAfterDelay { get; set; } = 100; - // public List<IMonitorSet> GetAllMonitorSet() - // { - // WarningSetCollection.ForEach(m => m.Source = this.Name); + public bool IsEnableMonitor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public int MonitorInterval { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public int MonitorTimeout { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public List<IMonitorSet> MonitorSetCollection { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - // MonitorSetCollection.ForEach(m => m.SourceDevice = this.Id); - // return MonitorSetCollection; - // } - // #endregion - - // #region IMotion Related - // [Category("杩愬姩閰嶇疆")] - // [Description("杩愬姩杞寸姸鎬侀泦鍚�")] - // [DisplayName("杩愬姩杞寸姸鎬侀泦鍚�")] - // [TypeConverter(typeof(CollectionCountConvert))] - // [Editor(typeof(ComplexCollectionEditor<PLCMotionDefinition_State>), typeof(UITypeEditor))] - // public List<PLCMotionDefinition_State> MotionStateCollection { get; set; } = new List<PLCMotionDefinition_State>(); - // #endregion - //} + public List<IMonitorSet> GetAllMonitorSet() + { + throw new NotImplementedException(); + } + } /// <summary> - /// 鐐逛綅绫诲瀷 + /// 杞撮厤缃� /// </summary> - public enum PosType + public class AxisSetting : IComplexDisplay { - /// <summary> - /// 鐩寸嚎鎻掕ˉ - /// </summary> - Line = 1, - /// <summary> - /// 鍦嗗姬鎻掕ˉ(鍗婂緞) - /// </summary> - CircleRadius, - /// <summary> - /// 鍦嗗姬鎻掕ˉ(鍦嗗績) - /// </summary> - CircleCenter + [Category("杞撮厤缃�")] + [DisplayName("杞村彿绱㈠紩")] + [Description("AxisIndex锛氳酱鍙风储寮�")] + public int AxisIndex { get; set; } + + [Category("杞撮厤缃�")] + [DisplayName("杞村悕绉�")] + [Description("AxisName锛氳酱鍚嶇О")] + public string AxisName { get; set; } + + [Category("杞撮厤缃�")] + [DisplayName("杞存槸鍚﹀惎鐢�")] + [Description("IsAxisEnabled锛氳酱鏄惁鍚敤")] + public bool IsAxisEnabled { get; set; } = false; + + [Category("鎹㈢畻閰嶇疆")] + [DisplayName("鑴夊啿鏁版崲绠楁瘮渚�")] + [Description("鑴夊啿鏁板拰鍏朵粬璁¢噺鍗曚綅鐨勬崲绠楁瘮渚嬶紝渚嬪璁剧疆涓�1000锛岃〃绀�1000涓剦鍐茬瓑浜�1uint")] + public int PulseRatio { 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("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("IsAutoGoHome锛氭槸鍚﹁嚜鍔ㄥ洖鍘熺偣銆� true锛氭槸 false锛氬惁")] + public bool IsAutoGoHome { get; set; } = false; + + [Category("瓒呮椂璁剧疆")] + [DisplayName("鍥炲師鐐硅秴鏃�")] + [Description("TimeOutHome锛氬洖鍘熺偣瓒呮椂锛屽崟浣嶆绉�")] + public int TimeOutHome { get; set; } = 30000; + + [Category("瓒呮椂璁剧疆")] + [DisplayName("杩愬姩瓒呮椂")] + [Description("TimeOutMove锛氳繍鍔ㄨ秴鏃讹紝鍗曚綅姣")] + public int TimeOutMove { get; set; } = 10000; + + [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("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>(); + + public string GetDisplayText() + { + return AxisIndex + "-" + AxisName + "-" + (IsAxisEnabled ? "鍚敤" : "绂佺敤"); + } } - public static class GTSCardParameter + /// <summary> + /// 浣嶇疆瀵硅薄 + /// </summary> + public class Section : IComplexDisplay { - #region 杩愬姩鍙傛暟 - public static int Dangliang = 1; - public static int AxisCount = 2;//杩愬姩杞存暟閲� - public static short CardNum = Convert.ToInt16(ConfigurationManager.AppSettings["cardNum"]); - public static short fifo = Convert.ToInt16(ConfigurationManager.AppSettings["fifo"]); - public static int FlySpeed = Convert.ToInt32(ConfigurationManager.AppSettings["flySpeed"]); - public static double FlyAcc = Convert.ToDouble(ConfigurationManager.AppSettings["flyAcc"]); - public static int P2PSpeed = Convert.ToInt32(ConfigurationManager.AppSettings["p2pSpeed"]); - public static double P2PAcc = Convert.ToDouble(ConfigurationManager.AppSettings["p2pAcc"]); - public static double P2PDec = Convert.ToDouble(ConfigurationManager.AppSettings["p2pDec"]); - public static int FreeSpeed = Convert.ToInt32(ConfigurationManager.AppSettings["freeSpeed"]); - public static int VelEnd = Convert.ToInt32(ConfigurationManager.AppSettings["velEnd"]);//椋炴媿缁撴潫閫熷害 - public static int HomeSpeed = Convert.ToInt32(ConfigurationManager.AppSettings["homeSpeed"]); - public static int Loading = Convert.ToInt32(ConfigurationManager.AppSettings["loading"]); - //public const short cardn = 0;//杩愬姩鎺у埗鍣ㄥ崱鍙� 榛樿涓猴細0 - //public const short crdn = 1;//鍧愭爣绯诲彿 鍙栧�艰寖鍥达細[1, 2] - //public const short fifo = 0;//鎻掕ˉ缂撳瓨鍖哄彿 鍙栧�艰寖鍥达細[0, 1]锛岄粯璁ゅ�间负锛�0 - //public const int flySpeed = 250;//椋炴媿閫熷害 - //public const double flyAcc = 0.5;//椋炴媿鍔犻�熷害 - //public const int gocatorSpeed = 150;//3D妫�娴嬭酱杩愬姩閫熷害 - //public const int p2pSpeed = 250;//P2P閫熷害 - //public const double p2pAcc = 1;//P2P鍔犻�熷害 - //public const double p2pDec = 1;//P2P鍑忛�熷害 - //public const int calibrationSpeed = 10;//鏍囧畾閫熷害 - //public const int calibrationZ = 19336;//鏍囧畾Z杞撮珮搴� - //public const int barcodeSpeed = 250;//鏉$爜妫�娴嬭酱杩愬姩閫熷害 - //public const int freeSpeed = 250;//闈炴娴嬫椂杞磋繍鍔ㄩ�熷害 - //public const int velEnd = 0;//椋炴媿缁撴潫閫熷害 - //public const int homeSpeed = 50;//鍥為浂閫熷害 - //public const int loading = 80000;//涓婃枡浣嶇疆 - #endregion + [Category("鏆傚仠鍖洪棿")] + [DisplayName("璧峰浣嶇疆")] + [Description("StartPosition锛氳捣濮嬩綅缃�")] + public int StartPosition { get; set; } - #region IO - /// <summary> - /// 杈撳叆IO榛樿鍊� - /// </summary> - public const int InDefaultValue = 0xFFDA; - /// <summary> - /// 澶圭揣姘旂几 - /// </summary> - public const short EXO_1 = 100;//澶圭揣姘旂几 - /// <summary> - /// 鏃ュ厜鐏� - /// </summary> - public const short EXO_2 = 101;//鏃ュ厜鐏� - /// <summary> - /// 鍏夋簮鍒囨崲 - /// </summary> - public const short EXO_3 = 102;//鍏夋簮鍒囨崲 - /// <summary> - /// 绾㈢伅 - /// </summary> - public const short EXO_4 = 103;//绾㈢伅 - /// <summary> - /// 榛勭伅 - /// </summary> - public const short EXO_5 = 104;//榛勭伅 - /// <summary> - /// 缁跨伅 - /// </summary> - public const short EXO_6 = 105;//缁跨伅 - /// <summary> - /// 铚傞福鍣� - /// </summary> - public const short EXO_7 = 106;//铚傞福鍣� - /// <summary> - /// Gocator X - /// </summary> - public const short EXO_8 = 107;//Gocator X + [Category("鏆傚仠鍖洪棿")] + [DisplayName("缁撴潫浣嶇疆")] + [Description("EndPosition锛氱粨鏉熶綅缃�")] + public int EndPosition { get; set; } - /// <summary> - /// 姝i潰鍏�(宸�) - /// </summary> - public const short EXO_9 = 108;//姝i潰鍏�(宸�) - - /// <summary> - /// 姝i潰鍏�(鍚�) - /// </summary> - public const short EXO_10 = 109;//姝i潰鍏�(鍚�) - - /// <summary> - /// 姝i潰鍏�(鍙�) - /// </summary> - public const short EXO_11 = 110;//姝i潰鍏�(鍙�) - - /// <summary> - /// 姝i潰鍏�(鍓�) - /// </summary> - public const short EXO_12 = 111;//姝i潰鍏�(鍓�) - - /// <summary> - /// Gocator Y - /// </summary> - public const short EXO_16 = 115;//Gocator Y - - /// <summary> - /// 杈撳嚭IO榛樿鍊� - /// </summary> - public const int OutDefaultValue = 0xFFF; - /// <summary> - /// 宸﹀惎鍔� - /// </summary> - public const short EXI0 = 0;//宸﹁捣鍔� - /// <summary> - /// 鍙冲惎鍔� - /// </summary> - public const short EXI1 = 1;//鍙宠捣鍔� - /// <summary> - /// 鍋滄 - /// </summary> - public const short EXI2 = 2;//鍋滄 - /// <summary> - /// 澶嶄綅 - /// </summary> - public const short EXI3 = 3;//澶嶄綅 - /// <summary> - /// 鎬ュ仠 - /// </summary> - public const short EXI4 = 4;//鎬ュ仠 - /// <summary> - /// 闂ㄥ紑鍏� - /// </summary> - public const short EXI5 = 5;//闂ㄥ紑鍏� - /// <summary> - /// 瀹夊叏鍏夊箷 - /// </summary> - public const short EXI6 = 6;//瀹夊叏鍏夊箷 - - public const short EXI7 = 7;// - /// <summary> - /// 澶圭揣姘旂几鍘熶綅 - /// </summary> - public const short EXI8 = 8;//澶圭揣姘旂几鍘熶綅 - /// <summary> - /// 澶圭揣姘旂几鍒颁綅 - /// </summary> - public const short EXI9 = 9;//澶圭揣姘旂几鍒颁綅 - #endregion + public string GetDisplayText() + { + return $"{StartPosition}--{EndPosition}"; + } } + + /// <summary> + /// 閫熷害鍙傛暟瀵硅薄 + /// </summary> + public class VelocityPara + { + [Category("閫熷害閰嶇疆")] + [DisplayName("閫熷害")] + [Description("Velocity锛氶�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] + public double Velocity { get; set; } = 0; + + [Category("閫熷害閰嶇疆")] + [DisplayName("鍔犻�熷害")] + [Description("Acc锛氬姞閫熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆")] + public double Acc { get; set; } = 0; + + [Category("閫熷害閰嶇疆")] + [DisplayName("鍑忛�熷害")] + [Description("鍑忛�熷害,涓�0鏃惰〃绀轰笉淇敼褰撳墠璁剧疆銆傚洖鍘熺偣妯″紡鏃惰缃负鏇茬嚎鍙傛暟")] + public double Dec { get; set; } = 0; + } + + /// <summary> + /// 杩愬姩瀵硅薄 + /// </summary> + public class MovingOption : INotifyPropertyChanged, IComplexDisplay + { + private int axisIndex = 0; + [Category("杩愬姩閰嶇疆")] + [DisplayName("杩愬姩杞寸储寮�")] + [Description("AxisIndex锛氳繍鍔ㄨ酱绱㈠紩")] + [TypeConverter(typeof(AxisIndexConvert))] + public int AxisIndex + { + get => axisIndex; + set + { + if (axisIndex != value) + { + axisIndex = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex")); + } + axisIndex = value; + } + } + + private MotorMoveMode moveMode = MotorMoveMode.Normal; + [Category("杩愬姩閰嶇疆")] + [DisplayName("杩愬姩妯″紡")] + [Description("MoveMode锛氳繍鍔ㄦā寮�")] + public MotorMoveMode MoveMode + { + get => moveMode; + set + { + if (moveMode != value) + { + moveMode = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode")); + } + + moveMode = value; + } + } + + 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")); + } + + isAbsolute = value; + } + } + + 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")); + } + + destination = value; + } + } + + 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")); + } + } + + internal List<AxisSetting> _axisSettingList = new List<AxisSetting>(); + public void SetAxisSetting(List<AxisSetting> settings) + { + if (settings != null) + _axisSettingList = settings; + } + + public string GetDisplayText() + { + string axisName = AxisIndex.ToString(); + var axisSet = _axisSettingList.FirstOrDefault(a => a.AxisIndex == AxisIndex); + if (axisSet != null) + { + axisName += ("-" + axisSet.AxisName); + } + return axisName + "," + MoveMode.ToString() + "," + (IsAbsolute ? "Abs" : "Rel") + "," + Destination; + } + public event PropertyChangedEventHandler PropertyChanged; + } + + 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.杞村啿绐佹潯浠�")] + [Description("杞村啿绐佹潯浠讹紝婊¤冻鍏ㄩ儴鏉′欢鏃惰酱杩愬姩闇�瑕佹鏌ュ啿绐�")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<AxisLimit>), typeof(UITypeEditor))] + public List<AxisLimit> AxisOptions { get; set; } = new List<AxisLimit>(); + + [Category("1.杞村啿绐佹潯浠�")] + [Description("IO鍐茬獊鏉′欢锛屾弧瓒冲叏閮ㄦ潯浠舵椂杞磋繍鍔ㄩ渶瑕佹鏌ュ啿绐�")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<IOLimit>), typeof(UITypeEditor))] + public List<IOLimit> IOOptions { get; set; } = new List<IOLimit>(); + + [Category("2.杞村啿绐侀檺鍒�")] + [Description("杞村啿绐侀檺鍒讹紝杞磋繍鍔ㄥ厑璁稿尯闂�")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<AxisLimit>), typeof(UITypeEditor))] + public List<AxisLimit> AxisLimits { get; set; } = new List<AxisLimit>(); + + [Category("2.杞村啿绐侀檺鍒�")] + [Description("IO鍏佽鏉′欢锛屽厑璁歌緭鍑虹殑IO")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<IOLimit>), typeof(UITypeEditor))] + public List<IOLimit> IOOutputs { get; set; } = new List<IOLimit>(); + + [Category("3.杞村啿绐佸惎鐢�")] + [Description("true锛氬惎鐢ㄨ酱鍐茬獊闄愬埗 false锛氫笉鍚敤杞村啿绐侀檺鍒�")] + public bool IsEnabled { get; set; } = true; + + public string GetDisplayText() + { + string optionStr = "Options:" + String.Join(";", AxisOptions.Select(a => a.GetDisplayText())); + string limitStr = "Limits:" + String.Join(";", AxisLimits.Select(a => a.GetDisplayText())); + + return optionStr + "|" + limitStr; + } + } + + public class AxisLimit : IComplexDisplay + { + [Category("1.杞村彿")] + [Description("1.杞村彿")] + public int AxisIndex { get; set; } + + [Category("2.杞存渶灏忛檺鍒�")] + [Description("2.杞存渶灏忛檺鍒�")] + public int LimitMin { get; set; } + + [Category("3.杞存渶澶ч檺鍒�")] + [Description("3.杞存渶澶ч檺鍒�")] + public int LimitMax { get; set; } + + private int currentPosition = 0; + [Browsable(false)] + [JsonIgnore] + public int CurrentPosition + { + get => currentPosition; + set + { + if (currentPosition != value) + { + if (value >= LimitMin && value <= LimitMax) + { + IsInLimit = true; + } + else + { + IsInLimit = false; + } + } + + currentPosition = value; + } + } + + [Browsable(false)] + [JsonIgnore] + public bool IsInLimit { get; set; } + + public string GetDisplayText() + { + return String.Format("Index:{0},{1}->{2}", AxisIndex, LimitMin, LimitMax); + } + } + + public class IOLimit : IComplexDisplay + { + [Category("1.IO闄愬埗")] + [Description("IO绱㈠紩")] + public int IOIndex { get; set; } + + [Category("1.IO闄愬埗")] + [Description("IO闄愬埗鍊笺�傝緭鍏ュ垽鏂椂璇ュ�间綔涓哄惎鐢ㄥ垽鏂�硷紝杈撳嚭鍒ゆ柇鏃惰鍊间綔涓哄厑璁歌緭鍑哄��")] + public bool IOSignal { get; set; } + + public string GetDisplayText() + { + return IOIndex + "--" + IOSignal.ToString(); + } + } + + public class AxisMovingStay + { + public int Position { get; set; } + + public int Velocity { get; set; } + + public AutoResetEvent MoveHandle { get; set; } = new AutoResetEvent(false); + + public AutoResetEvent MoveSendHandle { get; set; } = new AutoResetEvent(false); + } + + ///// <summary> + ///// 鐐逛綅绫诲瀷 + ///// </summary> + //public enum PosType + //{ + // /// <summary> + // /// 鐩寸嚎鎻掕ˉ + // /// </summary> + // Line = 1, + // /// <summary> + // /// 鍦嗗姬鎻掕ˉ(鍗婂緞) + // /// </summary> + // CircleRadius, + // /// <summary> + // /// 鍦嗗姬鎻掕ˉ(鍦嗗績) + // /// </summary> + // CircleCenter + //} + + + //public static class GTSCardParameter + //{ + // #region 杩愬姩鍙傛暟 + // public static int Dangliang = 1; + // public static int AxisCount = 2;//杩愬姩杞存暟閲� + // public static short CardNum = Convert.ToInt16(ConfigurationManager.AppSettings["cardNum"]); + // public static short fifo = Convert.ToInt16(ConfigurationManager.AppSettings["fifo"]); + // public static int FlySpeed = Convert.ToInt32(ConfigurationManager.AppSettings["flySpeed"]); + // public static double FlyAcc = Convert.ToDouble(ConfigurationManager.AppSettings["flyAcc"]); + // public static int P2PSpeed = Convert.ToInt32(ConfigurationManager.AppSettings["p2pSpeed"]); + // public static double P2PAcc = Convert.ToDouble(ConfigurationManager.AppSettings["p2pAcc"]); + // public static double P2PDec = Convert.ToDouble(ConfigurationManager.AppSettings["p2pDec"]); + // public static int FreeSpeed = Convert.ToInt32(ConfigurationManager.AppSettings["freeSpeed"]); + // public static int VelEnd = Convert.ToInt32(ConfigurationManager.AppSettings["velEnd"]);//椋炴媿缁撴潫閫熷害 + // public static int HomeSpeed = Convert.ToInt32(ConfigurationManager.AppSettings["homeSpeed"]); + // public static int Loading = Convert.ToInt32(ConfigurationManager.AppSettings["loading"]); + // //public const short cardn = 0;//杩愬姩鎺у埗鍣ㄥ崱鍙� 榛樿涓猴細0 + // //public const short crdn = 1;//鍧愭爣绯诲彿 鍙栧�艰寖鍥达細[1, 2] + // //public const short fifo = 0;//鎻掕ˉ缂撳瓨鍖哄彿 鍙栧�艰寖鍥达細[0, 1]锛岄粯璁ゅ�间负锛�0 + // //public const int flySpeed = 250;//椋炴媿閫熷害 + // //public const double flyAcc = 0.5;//椋炴媿鍔犻�熷害 + // //public const int gocatorSpeed = 150;//3D妫�娴嬭酱杩愬姩閫熷害 + // //public const int p2pSpeed = 250;//P2P閫熷害 + // //public const double p2pAcc = 1;//P2P鍔犻�熷害 + // //public const double p2pDec = 1;//P2P鍑忛�熷害 + // //public const int calibrationSpeed = 10;//鏍囧畾閫熷害 + // //public const int calibrationZ = 19336;//鏍囧畾Z杞撮珮搴� + // //public const int barcodeSpeed = 250;//鏉$爜妫�娴嬭酱杩愬姩閫熷害 + // //public const int freeSpeed = 250;//闈炴娴嬫椂杞磋繍鍔ㄩ�熷害 + // //public const int velEnd = 0;//椋炴媿缁撴潫閫熷害 + // //public const int homeSpeed = 50;//鍥為浂閫熷害 + // //public const int loading = 80000;//涓婃枡浣嶇疆 + // #endregion + + // #region IO + // /// <summary> + // /// 杈撳叆IO榛樿鍊� + // /// </summary> + // public const int InDefaultValue = 0xFFDA; + // /// <summary> + // /// 澶圭揣姘旂几 + // /// </summary> + // public const short EXO_1 = 100;//澶圭揣姘旂几 + // /// <summary> + // /// 鏃ュ厜鐏� + // /// </summary> + // public const short EXO_2 = 101;//鏃ュ厜鐏� + // /// <summary> + // /// 鍏夋簮鍒囨崲 + // /// </summary> + // public const short EXO_3 = 102;//鍏夋簮鍒囨崲 + // /// <summary> + // /// 绾㈢伅 + // /// </summary> + // public const short EXO_4 = 103;//绾㈢伅 + // /// <summary> + // /// 榛勭伅 + // /// </summary> + // public const short EXO_5 = 104;//榛勭伅 + // /// <summary> + // /// 缁跨伅 + // /// </summary> + // public const short EXO_6 = 105;//缁跨伅 + // /// <summary> + // /// 铚傞福鍣� + // /// </summary> + // public const short EXO_7 = 106;//铚傞福鍣� + // /// <summary> + // /// Gocator X + // /// </summary> + // public const short EXO_8 = 107;//Gocator X + + // /// <summary> + // /// 姝i潰鍏�(宸�) + // /// </summary> + // public const short EXO_9 = 108;//姝i潰鍏�(宸�) + + // /// <summary> + // /// 姝i潰鍏�(鍚�) + // /// </summary> + // public const short EXO_10 = 109;//姝i潰鍏�(鍚�) + + // /// <summary> + // /// 姝i潰鍏�(鍙�) + // /// </summary> + // public const short EXO_11 = 110;//姝i潰鍏�(鍙�) + + // /// <summary> + // /// 姝i潰鍏�(鍓�) + // /// </summary> + // public const short EXO_12 = 111;//姝i潰鍏�(鍓�) + + // /// <summary> + // /// Gocator Y + // /// </summary> + // public const short EXO_16 = 115;//Gocator Y + + // /// <summary> + // /// 杈撳嚭IO榛樿鍊� + // /// </summary> + // public const int OutDefaultValue = 0xFFF; + // /// <summary> + // /// 宸﹀惎鍔� + // /// </summary> + // public const short EXI0 = 0;//宸﹁捣鍔� + // /// <summary> + // /// 鍙冲惎鍔� + // /// </summary> + // public const short EXI1 = 1;//鍙宠捣鍔� + // /// <summary> + // /// 鍋滄 + // /// </summary> + // public const short EXI2 = 2;//鍋滄 + // /// <summary> + // /// 澶嶄綅 + // /// </summary> + // public const short EXI3 = 3;//澶嶄綅 + // /// <summary> + // /// 鎬ュ仠 + // /// </summary> + // public const short EXI4 = 4;//鎬ュ仠 + // /// <summary> + // /// 闂ㄥ紑鍏� + // /// </summary> + // public const short EXI5 = 5;//闂ㄥ紑鍏� + // /// <summary> + // /// 瀹夊叏鍏夊箷 + // /// </summary> + // public const short EXI6 = 6;//瀹夊叏鍏夊箷 + + // public const short EXI7 = 7;// + // /// <summary> + // /// 澶圭揣姘旂几鍘熶綅 + // /// </summary> + // public const short EXI8 = 8;//澶圭揣姘旂几鍘熶綅 + // /// <summary> + // /// 澶圭揣姘旂几鍒颁綅 + // /// </summary> + // public const short EXI9 = 9;//澶圭揣姘旂几鍒颁綅 + // #endregion + //} } -- Gitblit v1.8.0