| | |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Common; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | |
| | | namespace WIDESEAWCS_QuartzJob |
| | |
| | | /// 一般堆垛机实现类,实现堆垛机接口层 |
| | | /// </summary> |
| | | [Description("堆垛机")] |
| | | public class CommonStackerCrane : IStackerCrane |
| | | public class CommonStackerCrane : StackerCraneBase, IStackerCrane |
| | | { |
| | | #region Private Member |
| | | |
| | |
| | | public bool IsConnected => Communicator.IsConnected && _isConnected; |
| | | |
| | | /// <summary> |
| | | /// 堆垛机完成事件是否已订阅 |
| | | /// </summary> |
| | | public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null; |
| | | |
| | | /// <summary> |
| | | /// 堆垛机任务完成事件 |
| | | /// </summary> |
| | | public event EventHandler<StackerCraneTaskCompletedEventArgs> StackerCraneTaskCompletedEventHandler; |
| | |
| | | /// </summary> |
| | | public object StackerCraneTaskCommand { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 堆垛机完成事件是否已订阅 |
| | | /// </summary> |
| | | public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null; |
| | | |
| | | /// <summary> |
| | | /// 上一次任务的类型 |
| | |
| | | { |
| | | return DeviceStatus.Idle; |
| | | } |
| | | else if (StackerCraneWorkStatusValue == StackerCraneWorkStatus.Putting || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PickUp || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PickUpCompleted || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PutCompleted) |
| | | else if (StackerCraneWorkStatusValue == StackerCraneWorkStatus.Putting || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PickUp || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PutMove || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PutCompleted) |
| | | { |
| | | return DeviceStatus.Working; |
| | | } |
| | |
| | | private int GetCurrentTaskNum() |
| | | { |
| | | DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CurrentTaskNum)); |
| | | return devicePro == null ? throw new Exception($"读取当前任务号错误,未获取到协议信息,请检查配置参数名称是否配置,且配置为为{nameof(CurrentTaskNum)}") : (int)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType); |
| | | if (devicePro == null) |
| | | throw new Exception($"读取当前任务号错误,未获取到协议信息,请检查配置参数名称是否配置,且配置为{nameof(CurrentTaskNum)}"); |
| | | |
| | | object value = Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType); |
| | | return Convert.ToInt32(value); // 统一转换为 int |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | return deviceProtocolDetail.ProtocolDetailType; |
| | | } |
| | | return StackerCraneStatus.Unkonw.ToString(); |
| | | return StackerCraneStatus.Unknown.ToString(); |
| | | } |
| | | } |
| | | return StackerCraneStatus.Unkonw.ToString(); |
| | | return StackerCraneStatus.Unknown.ToString(); |
| | | } |
| | | |
| | | private void CheckConnect() |
| | |
| | | _isChecked = true; |
| | | try |
| | | { |
| | | DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneWorkStatus)); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneCompleted)); |
| | | if (devicePro != null) |
| | | { |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePro.DeviceProParamName && x.ProtocolDetailType == StackerCraneWorkStatus.WorkCompleted.ToString()); |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePro.DeviceProParamName && x.ProtocolDetailType == StackerCraneCompleted.Completed.ToString()); |
| | | if (deviceProtocolDetail != null) |
| | | { |
| | | OperateResult<TimeSpan> operateResult = new OperateResult<TimeSpan>(); |