| | |
| | | { |
| | | public event Action<DateTime, string, IDevice, IMonitorSet> OnMonitorInvoke; |
| | | public event Action<DateTime, IDevice, IWarningSet> OnMonitorAlarm; |
| | | public event Action<int, string> OnAxisAlarmRaised; |
| | | public event Action<int, int, int> OnAxisStatusChanged; |
| | | |
| | | public void AxisAlarmRaised(int axisIndex, string msg) |
| | | { |
| | | OnAxisAlarmRaised?.Invoke(axisIndex, msg); |
| | | } |
| | | |
| | | public void AxisStatusChanged(int axisIndex, int preStatus, int curStatus) |
| | | { |
| | | OnAxisStatusChanged?.Invoke(axisIndex, preStatus, curStatus); |
| | | } |
| | | |
| | | protected override void Start() |
| | | { |
| | | Task.Run(() => |
| | | { |
| | | Monitor(); |
| | | }); |
| | | } |
| | | public abstract List<AxisInfo> GetCurrentAxisInfo(params string[] axisName); |
| | | public abstract void Monitor(); |
| | | public abstract ResponseMessage MoveToPoint(IOperationConfig opConfig); |
| | |
| | | /// <summary> |
| | | /// 轴的运动状态值 |
| | | /// </summary> |
| | | public List<AxisMovingStatus> AxisMovingOptionValues { get; set; } = new List<AxisMovingStatus>(); |
| | | public List<AxisMovingStatus> AxisStatusList { get; set; } = new List<AxisMovingStatus>(); |
| | | |
| | | public abstract void WriteOutput(short index, IOValue value); |
| | | |
| | | #region ImmediatePause |
| | | /// <summary> |
| | | /// 启动立即暂停 |
| | | /// </summary> |
| | | public abstract void SetImmediatePause(); |
| | | |
| | | /// <summary> |
| | | /// 恢复立即暂停 |
| | | /// </summary> |
| | | public abstract void ResetImmediatePause(bool isResumeMoving); |
| | | #endregion |
| | | } |
| | | |
| | | public class MotionCardInitialConfigBase : InitialConfigBase, IMonitorConfig |
| | |
| | | [Category("板卡配置")] |
| | | [DisplayName("卡号")] |
| | | [Description("CardNum:卡号")] |
| | | public int CardNum { get; set; } |
| | | public int CardNum { get; set; } = 1; |
| | | |
| | | [Category("板卡配置")] |
| | | [DisplayName("初始配置文件路径")] |
| | |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<IODefinition>), typeof(UITypeEditor))] |
| | | public List<IODefinition> IODefinitionCollection { get; set; } = new List<IODefinition>(); |
| | | |
| | | [Category("IO配置")] |
| | | [Description("true:输出取反 false:输出不取反")] |
| | | public bool IsOutputReversed { get; set; } = true; |
| | | |
| | | #region IMonitorConfig |
| | | [Category("监听设置")] |
| | |
| | | [Device("MotionOperationSet", "运动操作配置基类", EnumHelper.DeviceAttributeType.OperationConfig)] |
| | | public class MotionCardOperationSet : IComplexDisplay |
| | | { |
| | | [Category("IO操作配置")] |
| | | [DisplayName("IO预检查定义集合")] |
| | | [Category("1.IO操作配置")] |
| | | [DisplayName("1.IO预检查")] |
| | | [Description("IO预检查定义集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(IORefrenceItemCollectionEditor), typeof(UITypeEditor))] |
| | | public List<IORefrenceItem> PreCheckIOCollection { get; set; } = new List<IORefrenceItem>(); |
| | | |
| | | [Category("IO操作配置")] |
| | | [Category("1.IO操作配置")] |
| | | [Description("超时设置,单位:ms")] |
| | | [DisplayName("IO预检查超时")] |
| | | [DisplayName("2.IO预检查超时")] |
| | | public int PreCheckIOTimeout { get; set; } = 0; |
| | | |
| | | [Category("IO操作配置")] |
| | | [DisplayName("IO输出定义集合")] |
| | | [Category("1.IO操作配置")] |
| | | [DisplayName("3.IO输出")] |
| | | [Description("IO输出定义集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(IORefrenceItemCollectionEditor), typeof(UITypeEditor))] |
| | | public List<IORefrenceItem> IOOutputCollection { get; set; } = new List<IORefrenceItem>(); |
| | | |
| | | [Category("IO操作配置")] |
| | | [DisplayName("IO确认定义集合")] |
| | | [Category("1.IO操作配置")] |
| | | [DisplayName("4.IO输出确认")] |
| | | [Description("IO确认定义集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(IORefrenceItemCollectionEditor), typeof(UITypeEditor))] |
| | | public List<IORefrenceItem> IOConfirmCollection { get; set; } = new List<IORefrenceItem>(); |
| | | [Category("IO操作配置")] |
| | | |
| | | [Category("1.IO操作配置")] |
| | | [Description("超时设置,单位:ms")] |
| | | [DisplayName("IO确认超时")] |
| | | [DisplayName("5.IO输出确认超时")] |
| | | public int IOConfirmTimeout { get; set; } = 0; |
| | | |
| | | [Category("板卡运动配置")] |
| | | [Category("2.板卡运动配置")] |
| | | [DisplayName("运动配置集合")] |
| | | [Description("MovingOps:运动配置集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(MovingOpsCollectionEditor), typeof(UITypeEditor))] |
| | | public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>(); |
| | | |
| | | [Category("3.运动延时")] |
| | | [Description("操作前延时,单位ms")] |
| | | public int DelayBefore { get; set; } = 0; |
| | | |
| | | [Category("3.运动延时")] |
| | | [Description("操作后延时,单位ms")] |
| | | public int DelayAfter { get; set; } = 0; |
| | | |
| | | public string MotionCardId = ""; |
| | | |
| | |
| | | if (itemType == typeof(IORefrenceItem)) |
| | | { |
| | | IORefrenceItem item = new IORefrenceItem(); |
| | | if ((this.Context.Instance is IOperationConfig opConfig) && !string.IsNullOrWhiteSpace(opConfig.DeviceId)) |
| | | if (this.Context.Instance is MotionCardOperationSet set) |
| | | { |
| | | using (var scope = GlobalVar.Container.BeginLifetimeScope()) |
| | | { |
| | | List<IDevice> deviceList = scope.Resolve<List<IDevice>>(); |
| | | |
| | | var device = deviceList.FirstOrDefault(u => u.Id == opConfig.DeviceId); |
| | | var device = deviceList.FirstOrDefault(u => u.Id == set.MotionCardId); |
| | | |
| | | if (device != null && (device is MotionCardBase motionCard)) |
| | | { |
| | |
| | | |
| | | public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) |
| | | { |
| | | if (context.Instance is IOperationConfig opConfig) |
| | | if (context.Instance is MotionCardOperationSet set) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(opConfig.DeviceId)) |
| | | if (string.IsNullOrWhiteSpace(set.MotionCardId)) |
| | | { |
| | | return base.EditValue(context, provider, value); |
| | | } |
| | |
| | | { |
| | | List<IDevice> deviceList = scope.Resolve<List<IDevice>>(); |
| | | |
| | | var device = deviceList.FirstOrDefault(u => u.Id == opConfig.DeviceId); |
| | | var device = deviceList.FirstOrDefault(u => u.Id == set.MotionCardId); |
| | | |
| | | if (device == null) |
| | | { |