| | |
| | | using HslCommunication; |
| | | using Autofac.Core; |
| | | using HslCommunication; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | |
| | | WriteError("CommonConveyorLineJob", "test", ex); |
| | | //Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString()); |
| | | } |
| | | WriteDebug("CommonConveyorLineJob", "test"); |
| | | //WriteDebug("CommonConveyorLineJob", "test"); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | { |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) |
| | | { |
| | | Console.Out.WriteLine("TaskCompleted" + e.TaskNum); |
| | | //Console.Out.WriteLine("TaskCompleted" + e.TaskNum); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务完成,任务号:【{e.TaskNum}】", ConsoleColor.Blue); |
| | | _taskService.StackCraneTaskCompleted(e.TaskNum); |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | } |
| | |
| | | /// <returns>如果未被占用,返回传入的任务信息,否则,返回null</returns> |
| | | private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) |
| | | { |
| | | if (task.Roadway.Contains("GW")) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015"); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; |
| | | if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (router != null) |
| | | if (task.Roadway.Contains("GW") || task.Roadway.Contains("CW")) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | if (router != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用 |
| | | |
| | | IDevice? device = null; |
| | | if (task.Roadway.Contains("CW")) |
| | | { |
| | | return task; |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | } |
| | | |
| | | else |
| | | { |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015"); |
| | | } |
| | | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | //Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (router != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2; |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); |
| | | } |
| | |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(endCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(endCodes[2]); |
| | | string[] sourceCodes = task.SourceAddress.Split("-"); |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2; |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); |
| | | } |
| | |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2; |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); |
| | | } |
| | |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2; |
| | | stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); |
| | | stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); |
| | | } |
| | |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | | if (sourceCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); |
| | | stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2; |
| | | stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); |
| | | stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); |
| | | } |
| | |
| | | /// 设备心跳 |
| | | /// </summary> |
| | | /// <param name="commonStackerCrane"></param> |
| | | public async void EqptAlive(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | if (commonStackerCrane.StackerOnline) |
| | | { |
| | | BasicDto dto = new BasicDto |
| | | { |
| | | EmployeeNo = "T00001", |
| | | EquipmentCode = commonStackerCrane.DeviceCode, |
| | | RequestTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | Software = commonStackerCrane.DeviceName, |
| | | }; |
| | | var respone = await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptAlive", dto.ToJsonString()); |
| | | if (respone != null) |
| | | { |
| | | var result = JsonConvert.DeserializeObject<ResponseEqptAliveDto>(respone); |
| | | if (result != null && result.Success) |
| | | { |
| | | if (result.KeyFlag == "99") |
| | | commonStackerCrane.StackerOnline = true; |
| | | else if (result.KeyFlag == "98") |
| | | commonStackerCrane.StackerOnline = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //public async void EqptAlive(CommonStackerCrane commonStackerCrane) |
| | | //{ |
| | | // if (commonStackerCrane.StackerOnline) |
| | | // { |
| | | // BasicDto dto = new BasicDto |
| | | // { |
| | | // EmployeeNo = "T00001", |
| | | // EquipmentCode = commonStackerCrane.DeviceCode, |
| | | // RequestTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | // SessionId = Guid.NewGuid().ToString(), |
| | | // Software = commonStackerCrane.DeviceName, |
| | | // }; |
| | | // var respone = await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptAlive", dto.ToJsonString()); |
| | | // if (respone != null) |
| | | // { |
| | | // var result = JsonConvert.DeserializeObject<ResponseEqptAliveDto>(respone); |
| | | // if (result != null && result.Success) |
| | | // { |
| | | // if (result.KeyFlag == "99") |
| | | // commonStackerCrane.StackerOnline = true; |
| | | // else if (result.KeyFlag == "98") |
| | | // commonStackerCrane.StackerOnline = false; |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | } |
| | | } |