| | |
| | | public abstract ResponseMessage MoveToPoint(IOperationConfig opConfig); |
| | | public abstract void ResetAlarm(); |
| | | public abstract ResponseMessage Run(IOperationConfig config); |
| | | /// <summary> |
| | | /// 清除状态 |
| | | /// </summary> |
| | | /// <param name="startAxisIndex">起始轴号</param> |
| | | /// <param name="count">数量</param> |
| | | /// <returns></returns> |
| | | public abstract bool ClearStatus(int startAxisIndex, int count); |
| | | |
| | | /// <summary> |
| | | /// 读取轴状态 |
| | | /// </summary> |
| | | /// <param name="axisNum">轴号</param> |
| | | /// <returns></returns> |
| | | public abstract int GetAxisStatus(int axisNum); |
| | | |
| | | /// <summary> |
| | | /// 位置清零 |
| | | /// </summary> |
| | | /// <param name="startAxisIndex">起始轴号</param> |
| | | /// <param name="count">数量</param> |
| | | /// <returns></returns> |
| | | public abstract bool PositionReset(int startAxisIndex, int count); |
| | | |
| | | public abstract bool AllAxisOn(); |
| | | |
| | | public abstract bool AllAxisOff(); |
| | | |
| | | public abstract Task<bool> AxisOnAsync(int axisNum); |
| | | |
| | | public abstract Task<bool> AxisOffAsync(int axisNum); |
| | | |
| | | /// <summary> |
| | | /// 单个轴 运动(点到点 jog 回零...) |
| | | /// </summary> |
| | | /// <param name="optionPara">运动参数对象</param> |
| | | public abstract Task<bool> SingleAxisMoving(MovingOption optionPara); |
| | | |
| | | /// <summary> |
| | | /// 某个轴运动停止 |
| | | /// </summary> |
| | | /// <param name="axisNum">轴号</param> |
| | | /// <param name="option">0表示平滑停止,1表示紧急停止</param> |
| | | /// <returns></returns> |
| | | public abstract Task<bool> MoveStop(int axisNum, int option); |
| | | |
| | | public virtual void ExcuteMonitorInvoke(DateTime dateTime, string invokeDevice, IDevice device, IMonitorSet monitorSet) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// IO的监听值 |
| | | /// </summary> |
| | | public List<IOItem> MonitorValues { get; set; } = new List<IOItem>(); |
| | | |
| | | public abstract void WriteOutput(short cardNum, short index, IOValue value); |
| | | /// <summary> |
| | | /// 轴的运动状态值 |
| | | /// </summary> |
| | | public List<AxisMovingStatus> AxisMovingOptionValues { get; set; } = new List<AxisMovingStatus>(); |
| | | |
| | | public abstract void WriteOutput(short index, IOValue value); |
| | | } |
| | | |
| | | public class MotionCardInitialConfigBase : InitialConfigBase, IMonitorConfig |
| | |
| | | [Category("板卡操作")] |
| | | [Description("板卡操作配置基类集合,依次执行")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<MotionCardOperationConfigBase>), typeof(UITypeEditor))] |
| | | [Editor(typeof(MotionCardOperationSetEditor), typeof(UITypeEditor))] |
| | | public List<MotionCardOperationSet> OperationCollection { get; set; } = new List<MotionCardOperationSet>(); |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | //OperationCollection.ForEach(o => |
| | | //{ |
| | | // o.MotionCardId = DeviceId; |
| | | //}); |
| | | |
| | | return string.Join(" ", OperationCollection.Select(u => u.GetDisplayText())); |
| | | } |
| | | } |
| | | |
| | | public class MotionCardOperationSetEditor : ComplexCollectionEditor<MotionCardOperationSet> |
| | | { |
| | | public MotionCardOperationSetEditor(Type type) : base(type) { } |
| | | |
| | | IOperationConfig opConfig = null; |
| | | public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) |
| | | { |
| | | if (context.Instance is IOperationConfig config && value is List<MotionCardOperationSet> setList) |
| | | { |
| | | opConfig = config; |
| | | setList.ForEach(set => set.MotionCardId = opConfig.DeviceId); |
| | | } |
| | | |
| | | return base.EditValue(context, provider, value); |
| | | } |
| | | |
| | | protected override object CreateInstance(Type itemType) |
| | | { |
| | | object obj = base.CreateInstance(itemType); |
| | | |
| | | if (obj is MotionCardOperationSet set) |
| | | { |
| | | set.MotionCardId = opConfig?.DeviceId; |
| | | } |
| | | |
| | | return obj; |
| | | } |
| | | |
| | | } |
| | | |
| | | [Device("MotionOperationSet", "运动操作配置基类", EnumHelper.DeviceAttributeType.OperationConfig)] |
| | | public class MotionCardOperationSet : IComplexDisplay |
| | | { |
| | | [Category("IO操作配置")] |
| | |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(IORefrenceItemCollectionEditor), typeof(UITypeEditor))] |
| | | public List<IORefrenceItem> PreCheckIOCollection { get; set; } = new List<IORefrenceItem>(); |
| | | |
| | | [Category("IO操作配置")] |
| | | [Description("超时设置,单位:ms")] |
| | | [DisplayName("IO预检查超时")] |
| | |
| | | [DisplayName("运动配置集合")] |
| | | [Description("MovingOps:运动配置集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<MovingOption>), typeof(UITypeEditor))] |
| | | [Editor(typeof(MovingOpsCollectionEditor), typeof(UITypeEditor))] |
| | | public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>(); |
| | | |
| | | public string MotionCardId = ""; |
| | | |
| | | //[Category("板卡运动配置")] |
| | | //[DisplayName("运动配置集合")] |
| | | //[Description("MovingOps:运动配置集合")] |
| | | //[TypeConverter(typeof(ComplexObjectConvert))] |
| | | //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] |
| | | //public MotionOperationCollection MotionOperationCollection { get; set; } = new MotionOperationCollection(); |
| | | |
| | | |
| | | public string GetDisplayText() |
| | |
| | | { |
| | | moving += i.GetDisplayText() + " "; |
| | | }); |
| | | |
| | | if (moving != "") |
| | | { |
| | | moving = " 运动:" + moving; |
| | | } |
| | | |
| | | return (preCheck + output + confirm + moving).Trim(); |
| | | } |
| | | } |
| | | |
| | | public class MotionOperationCollection : OperationConfigBase, IComplexDisplay |
| | | { |
| | | [Category("运动配置")] |
| | | [DisplayName("运动配置集合")] |
| | | [Description("MovingOps:运动配置集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<MovingOption>), typeof(UITypeEditor))] |
| | | public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>(); |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return $"{string.Join(" ", MovingOps.Select(u => u.GetDisplayText()))}"; |
| | | } |
| | | } |
| | | |
| | |
| | | //} |
| | | } |
| | | |
| | | public class MovingOpsCollectionEditor : ComplexCollectionEditor<MovingOption> |
| | | { |
| | | public MovingOpsCollectionEditor(Type type) : base(type) |
| | | { |
| | | } |
| | | |
| | | MotionCardBase motionCard = null; |
| | | public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) |
| | | { |
| | | if (context.Instance is MotionCardOperationSet set) |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(set.MotionCardId)) |
| | | { |
| | | using (var scope = GlobalVar.Container.BeginLifetimeScope()) |
| | | { |
| | | var deviceList = scope.Resolve<List<IDevice>>(); |
| | | if (deviceList != null) |
| | | { |
| | | motionCard = deviceList.FirstOrDefault(u => u.Id == set.MotionCardId) as MotionCardBase; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (motionCard != null && value is List<MovingOption> ops) |
| | | { |
| | | ops.ForEach(o => o.SetAxisSetting(motionCard.IConfig.AxisSettings)); |
| | | } |
| | | } |
| | | |
| | | return base.EditValue(context, provider, value); |
| | | } |
| | | |
| | | protected override object SetItems(object editValue, object[] value) |
| | | { |
| | | Array.ForEach(value, v => |
| | | { |
| | | if (v is MovingOption op && motionCard != null) |
| | | { |
| | | op.SetAxisSetting(motionCard.IConfig.AxisSettings); |
| | | } |
| | | }); |
| | | |
| | | return base.SetItems(editValue, value); |
| | | } |
| | | ///// <summary> |
| | | ///// 限制一次选一个实例 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //protected override bool CanSelectMultipleInstances() |
| | | //{ |
| | | // return false; |
| | | //} |
| | | ///// <summary> |
| | | ///// 指定创建的对象类型 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //protected override Type CreateCollectionItemType() |
| | | //{ |
| | | // return typeof(MovingOption); |
| | | //} |
| | | } |
| | | |
| | | } |