| | |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << 版 本 注 释 >> |
| | | |
| | | using Autofac.Core; |
| | | using AutoMapper; |
| | | using Microsoft.AspNetCore.Routing; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Quartz; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.Log; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.Helper; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_Core.Caches; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_Model.Models.System; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class CommonConveyorLineJob : IJob |
| | | public class CommonConveyorLineJob : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IPlatformStationService _PlatformStationService; |
| | | |
| | | private readonly IRouterRepository _routerRepository; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IMapper _mapper; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly List<Dt_WarehouseDevice> warehouseDevices; |
| | | |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, IPlatformStationService platformStation) |
| | | public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, ITaskRepository taskRepository, ICacheService cacheService, IMapper mapper) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _routerService = routerService; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _taskRepository = taskRepository; |
| | | _routerRepository = routerRepository; |
| | | _cacheService = cacheService; |
| | | _mapper = mapper; |
| | | _PlatformStationService = platformStation; |
| | | } |
| | | |
| | | string? warehouseDevicesStr = _cacheService.Get<string>(nameof(Dt_WarehouseDevice)); |
| | | if (!string.IsNullOrEmpty(warehouseDevicesStr)) |
| | | { |
| | | warehouseDevices = JsonConvert.DeserializeObject<List<Dt_WarehouseDevice>>(warehouseDevicesStr) ?? new List<Dt_WarehouseDevice>(); |
| | | } |
| | | else |
| | | { |
| | | warehouseDevices = new List<Dt_WarehouseDevice>(); |
| | | } |
| | | |
| | | } |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | |
| | | if (conveyorLine != null) |
| | | { |
| | | //读取输送线入库申请 |
| | | RequestInbound(conveyorLine); |
| | | //读取堆垛机入库站台信号 |
| | | RequestInSCLine(conveyorLine); |
| | | List<string> deviceStations = conveyorLine.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == conveyorLine.DeviceCode); |
| | | foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) |
| | | { |
| | | try |
| | | { |
| | | DeviceProDTO? deviceProRead = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | //堆垛机站台进行下发输送线任务 |
| | | RequestOutSCLine(conveyorLine); |
| | | //读取Rgv出库口任务 |
| | | RequestOutbound(conveyorLine); |
| | | //读取出库站台,获取出库口更新出库任务 |
| | | RequestOutAdd(conveyorLine); |
| | | |
| | | DeviceProDTO? deviceProWrite = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineDBName)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | if (deviceProRead != null && deviceProWrite != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead = conveyorLine.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | W_ConveyorLineInfo conveyorLineInfoWrite = conveyorLine.Communicator.ReadCustomer<W_ConveyorLineInfo>(deviceProWrite.DeviceProAddress); |
| | | if (conveyorLineInfoRead == null || conveyorLineInfoWrite == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | R_ConveyorLineStatus conveyorLineStatus = conveyorLineInfoRead.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | |
| | | ConveyorLineSignal conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | |
| | | bool ACK = conveyorLine.GetValue<W_ConveyorLineDBName, bool>(W_ConveyorLineDBName.W_ConveyorLine_ACK, item.StationCode); |
| | | |
| | | bool STB = conveyorLine.GetValue<W_ConveyorLineDBName, bool>(W_ConveyorLineDBName.W_ConveyorLine_STB, item.StationCode); |
| | | |
| | | //bool Return = conveyorLine.GetValue<W_ConveyorLineDB, bool>(W_ConveyorLineDB.Return, item.StationCode); |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) |
| | | { |
| | | |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !ACK) |
| | | { |
| | | if (conveyorLineInfoRead.TaskNo == 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.Barcode))//采购入库 |
| | | { |
| | | WebResponseContent webResponse = _taskService.ApplyLocation(conveyorLineInfoRead.Barcode); |
| | | if (webResponse.Status) |
| | | { |
| | | List<Dt_WarehouseDevice> warehouseDevicesList = warehouseDevices.Where(x => x.WarehouseId == webResponse.Data.ObjToInt()).ToList(); |
| | | |
| | | foreach (var list in warehouseDevicesList) |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == item.StationCode && x.ChildPosiDeviceCode == list.DeviceCode); |
| | | #region 先找允许入库的输送线入口 |
| | | deviceProRead = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == routers.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.NextAddress == routers.NextPosi); |
| | | if (dt_Task != null) { continue; } |
| | | if (deviceProRead != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead1 = conveyorLine.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | R_ConveyorLineStatus conveyorLineStatus1 = conveyorLineInfoRead1.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | if (conveyorLineInfoRead1.Status == 6 && conveyorLineStatus1.Free && conveyorLineStatus1.Online && !conveyorLineStatus1.Goods) |
| | | { |
| | | |
| | | #region 请求WMS生成任务后给输送线启动信号 |
| | | WebResponseContent content = _taskService.CPRequestWMSTaskSimple(conveyorLineInfoRead.Barcode, routers.NextPosi, conveyorLineInfoRead.Spare2, item.StationCode); |
| | | if (content.Status) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.Barcode && x.CurrentAddress == item.StationCode && x.DeviceCode == conveyorLine.DeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, true, item.StationCode); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_NEW, sourceAddress: item.StationCode, RGVCode: item.AGVStationCode); |
| | | //WebResponseContent responseContent = _taskService.LedShowTask(item.StationCode, task.PalletCode, task.TaskType); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt()) |
| | | { |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !ACK) |
| | | { |
| | | if (conveyorLineInfoRead.TaskNo == 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.Barcode))//采购入库 |
| | | { |
| | | WebResponseContent webResponse = _taskService.ApplyLocation(conveyorLineInfoRead.Barcode); |
| | | if (webResponse.Status) |
| | | { |
| | | List<Dt_WarehouseDevice> warehouseDevicesList = warehouseDevices.Where(x => x.WarehouseId == webResponse.Data.ObjToInt()).ToList(); |
| | | |
| | | foreach (var list in warehouseDevicesList) |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == item.StationCode && x.ChildPosiDeviceCode == list.DeviceCode); |
| | | #region 先找允许入库的输送线入口 |
| | | deviceProRead = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == routers.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.NextAddress == routers.NextPosi); |
| | | if (dt_Task != null) { continue; } |
| | | if (deviceProRead != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead1 = conveyorLine.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | R_ConveyorLineStatus conveyorLineStatus1 = conveyorLineInfoRead1.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | if (conveyorLineInfoRead1.Status == 6 && conveyorLineStatus1.Free && conveyorLineStatus1.Online && !conveyorLineStatus1.Goods) |
| | | { |
| | | |
| | | #region 请求WMS生成任务后给输送线启动信号 |
| | | WebResponseContent content = _taskService.CPRequestWMSTaskSimple(conveyorLineInfoRead.Barcode, routers.NextPosi, conveyorLineInfoRead.Spare2, item.StationCode); |
| | | if (content.Status) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.Barcode && x.CurrentAddress == item.StationCode && x.DeviceCode == conveyorLine.DeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, true, item.StationCode); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_NEW, sourceAddress: item.StationCode, RGVCode: item.AGVStationCode); |
| | | |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | //出库站台 |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | |
| | | } |
| | | if (item.StationType == StationTypeEnum.SC_In.ObjToInt()) |
| | | { |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !ACK) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.RGV_Finish.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.Roadway, currentAddress: task.NextAddress); |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, true, item.StationCode); |
| | | } |
| | | } |
| | | } |
| | | if (item.StationType == StationTypeEnum.SC_Out.ObjToInt()) |
| | | { |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB && !ACK) |
| | | { |
| | | Dt_Task _Task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt()); |
| | | if (_Task != null) |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == _Task.CurrentAddress); |
| | | if (routers != null) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_TaskNo, _Task.TaskNum, item.StationCode); |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_EndPos, routers.NextPosi, item.StationCode); |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_STB, true, item.StationCode); |
| | | _taskService.UpdateTask(_Task, TaskStatusEnum.Line_Executing, nextAddress: routers.NextPosi); |
| | | WriteDebug($"堆垛机出库口{item.StationCode}", $"堆垛机出库口任务更新,任务号{_Task.TaskId},目标出口位置{_Task.TargetAddress},托盘号:{_Task.PalletCode}"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //堆垛机出库口外面一段出库站台 |
| | | if (conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB && !ACK) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && x.DeviceCode == conveyorLine.DeviceCode && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | List<Dt_Router> routers = _routerRepository.QueryData(x => x.StartPosi == item.StationCode).ToList(); |
| | | foreach (var items in routers) |
| | | { |
| | | deviceProRead = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == items.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (deviceProRead != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead3 = conveyorLine.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | R_ConveyorLineStatus conveyorLineStatus3 = conveyorLineInfoRead3.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | |
| | | ConveyorLineSignal conveyorLineSignalRead3 = conveyorLineInfoRead3.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | if (!conveyorLineSignalRead3.STB && !conveyorLineSignalRead3.ACK && conveyorLineStatus3.Online && conveyorLineStatus3.Free && !conveyorLineStatus3.Goods && !conveyorLineStatus3.Alarm && !STB && !ACK)//判断出库口是否空闲 |
| | | { |
| | | Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.TargetAddress == items.NextPosi); |
| | | if (dt_Task == null) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, true, item.StationCode); |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_Execute, currentAddress: item.StationCode, targetAddress: items.NextPosi, nextAddress: items.NextPosi, RGVCode: item.AGVStationCode); |
| | | Thread.Sleep(500); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (!conveyorLineSignalRead.STB && conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && STB && !ACK) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_STB, false, item.StationCode); |
| | | } |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB && ACK) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, false, item.StationCode); |
| | | } |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && !conveyorLineStatus.Alarm && !STB && ACK) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, false, item.StationCode); |
| | | } |
| | | //if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && !conveyorLineStatus.Alarm && !STB && !ACK && Return) |
| | | //{ |
| | | // conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_Return, false, item.StationCode); |
| | | //} |
| | | if (conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && ACK) |
| | | { |
| | | conveyorLine.SetValue(W_ConveyorLineDBName.W_ConveyorLine_ACK, false, item.StationCode); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(nameof(CommonConveyorLine), ex.Message, ex); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); |
| | | WriteError(nameof(CommonConveyorLine), ex.Message, ex); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | |
| | | /// 输送线请求入库 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | public void RequestInbound(CommonConveyorLine conveyorLine) |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | |
| | | List<PlatformStation> platformsList = _PlatformStationService.GetPlatformList(conveyorLine.DeviceCode); |
| | | foreach (var RGVStationitem in platformsList) |
| | | { |
| | | ConveyorLineCommand command = lineCommand(conveyorLine,RGVStationitem.Station_code); |
| | | if (command != null) |
| | | { |
| | | if (command.Online) |
| | | { |
| | | if (command.STB) |
| | | { |
| | | WebResponseContent content = _taskService.RequestWMSTask(command.BarCode, RGVStationitem.Station_code.ToString(), command.GoodsType); |
| | | if (content.Status) |
| | | { |
| | | DeviceProDTO? deviceProDTO6 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == RGVStationitem.Station_code.ToString() && x.DeviceProParamName == "ACK" && x.DeviceProParamType == "DeviceCommand"); |
| | | if (deviceProDTO6 != null) |
| | | { |
| | | conveyorLine.Communicator.Write(deviceProDTO6.DeviceProAddress, (bool)true); |
| | | wcsWriteLog(RGVStationitem.Station_code.ToString(), "正常日志", $"{RGVStationitem.Station_code}写入输送线信号,模块{deviceProDTO6.DeviceProAddress}:true"); |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog(RGVStationitem.Station_code.ToString(), "错误日志", $"未找到对于的读取模块{RGVStationitem.Station_code}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog(RGVStationitem.Station_code.ToString(), "错误日志", $"入库站台:{RGVStationitem.Station_code},错误信息:{content.Message}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | DeviceProDTO? deviceProDTO6 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == RGVStationitem.Station_code.ToString() && x.DeviceProParamName == "ACK" && x.DeviceProParamType == "DeviceCommand"); |
| | | if (deviceProDTO6 != null) |
| | | { |
| | | |
| | | conveyorLine.Communicator.Write(deviceProDTO6.DeviceProAddress, (bool)false); |
| | | wcsWriteLog(RGVStationitem.Station_code.ToString(), "正常日志", $"{RGVStationitem.Station_code}写入输送线信号,模块{deviceProDTO6.DeviceProAddress}:false"); |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog(RGVStationitem.Station_code.ToString(), "错误日志", $"未找到对于的读取模块{RGVStationitem.Station_code}"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog(RGVStationitem.Station_code.ToString(), "错误日志", $"该站台{RGVStationitem.Station_code}不处于联机状态"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取堆垛机入库站台信息,进行任务完成 |
| | | /// 输送线请求入库下一地址 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | public void RequestInSCLine(CommonConveyorLine conveyorLine) |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | List<string> platformsList = _PlatformStationService.GetPlatIn(conveyorLine.DeviceCode); //读取站台信息 |
| | | foreach (var RGVStationitem in platformsList) |
| | | { |
| | | ConveyorLineCommand command = lineCommand(conveyorLine, RGVStationitem); |
| | | if (command != null) |
| | | { |
| | | if (command.Online && command.STB && command.TaskNo != 0) |
| | | { |
| | | //写入反馈 |
| | | DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == RGVStationitem && x.DeviceProParamName == "ACK" && x.DeviceProParamType == "DeviceCommand"); |
| | | |
| | | if (conveyorLine.Communicator.Write(deviceProDTO.DeviceProAddress, (bool)true)) |
| | | { |
| | | DeviceProDTO? deviceProDTO2 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == RGVStationitem && x.DeviceProParamName == "STB" && x.DeviceProParamType == "ReadDeviceCommand"); |
| | | if (conveyorLine.Communicator.Read<bool>(deviceProDTO2.DeviceProAddress)) |
| | | { |
| | | conveyorLine.Communicator.Write(deviceProDTO.DeviceProAddress, (bool)false); |
| | | _taskService.UpdateTaskStatusToNext2(command.TaskNo); |
| | | |
| | | wcsWriteLog5(RGVStationitem, "正常信息", $"清除站台:{RGVStationitem}的交互信号写入:false,地址:{deviceProDTO.DeviceProAddress}"); |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog5(RGVStationitem, "错误信息", $"未读取到站台:{RGVStationitem}的交互信号:true,地址:{deviceProDTO.DeviceProAddress}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | conveyorLine.Communicator.Write(deviceProDTO.DeviceProAddress, (bool)false); |
| | | wcsWriteLog5(RGVStationitem, "错误信息", $"{RGVStationitem}的交互信号写入:true ==》 false,地址:{deviceProDTO.DeviceProAddress}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog5(RGVStationitem, "错误信息", $"未读取到站台:{RGVStationitem}的申请信号,目前信号状态为。Online:{command.Online},STB:{command.STB},TaskNo:{command.TaskNo},"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// RGV输送线请求出站 |
| | | /// 输送线入库完成 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine) |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | |
| | | List<string> platformsList = _PlatformStationService.GetPlatform2(conveyorLine.DeviceCode); |
| | | foreach (var RGVStationitem in platformsList) |
| | | { |
| | | ConveyorLineCommand command = lineCommand(conveyorLine, RGVStationitem); |
| | | if (command != null) |
| | | { |
| | | if(command.Online) |
| | | { |
| | | if (command.STB) |
| | | { |
| | | if (_taskService.UpdateTaskStatusToNext(command.TaskNo).Status) |
| | | { |
| | | DeviceProDTO? deviceProDTO6 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == RGVStationitem && x.DeviceProParamName == "ACK" && x.DeviceProParamType == "DeviceCommand"); |
| | | if (deviceProDTO6 != null) |
| | | { |
| | | conveyorLine.Communicator.Write(deviceProDTO6.DeviceProAddress, (bool)true); |
| | | wcsWriteLog2(RGVStationitem, "正常日志", $"{RGVStationitem}写入输送线信号,模块{deviceProDTO6.DeviceProAddress}:true"); |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog2(RGVStationitem, "错误日志", $"未找到对于的读取模块{RGVStationitem}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog2(RGVStationitem, "错误日志", $"任务信息更改失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | DeviceProDTO? deviceProDTO6 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == RGVStationitem && x.DeviceProParamName == "ACK" && x.DeviceProParamType == "DeviceCommand"); |
| | | if (deviceProDTO6 != null) |
| | | { |
| | | |
| | | conveyorLine.Communicator.Write(deviceProDTO6.DeviceProAddress, (bool)false); |
| | | wcsWriteLog2(RGVStationitem, "正常日志", $"{RGVStationitem}写入输送线信号,模块{deviceProDTO6.DeviceProAddress}:false"); |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog2(RGVStationitem, "错误日志", $"未找到对于的读取模块{RGVStationitem}"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog2(RGVStationitem, "错误日志", $"该站台{RGVStationitem}不处于联机状态"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取出库站台,更新出库任务 |
| | | /// 输送线请求出信息 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | public void RequestOutAdd(CommonConveyorLine conveyorLine) |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | List<PlatformStation> platformsList = _PlatformStationService.GetPlatformOutList(conveyorLine.DeviceCode); |
| | | foreach (var RGVStationitem in platformsList) |
| | | { |
| | | ConveyorLineCommand command = lineCommand(conveyorLine, RGVStationitem.Station_code); |
| | | if (command != null) |
| | | { |
| | | if(command.Online) |
| | | { |
| | | if (command.Free) |
| | | { |
| | | if (_taskService.OutConveyorLineTask(RGVStationitem)) //查找是否被占用 |
| | | { |
| | | wcsWriteLog3(RGVStationitem.Station_code.ToString(), "更新成功", $"任务信息更新成功"); |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog3(RGVStationitem.Station_code.ToString(), "错误信息", $"已有该站台的出库任务或任务更新失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog3(RGVStationitem.Station_code.ToString(), "错误信息", $"该出库站台不可放货"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog3(RGVStationitem.Station_code.ToString(), "是否联机", $"该站台{RGVStationitem.Station_code}不处于联机状态"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 堆垛机出库站台,根据任务进行下发至输送线 |
| | | /// 输送线请求出库下一地址 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | public void RequestOutSCLine(CommonConveyorLine conveyorLine) |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | List<Dt_Task> StationData = _taskService.StackerCraneOutTask(); |
| | | |
| | | foreach (var LinSCStationitem in StationData) |
| | | { |
| | | string platformsList = _PlatformStationService.GetOutSCName(LinSCStationitem.Roadway, LinSCStationitem.Station_storey); |
| | | DeviceProDTO? deviceProDTO6 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == platformsList && x.DeviceProParamName == "STB" && x.DeviceProParamType == "DeviceCommand"); |
| | | DeviceProDTO? deviceProDTO7 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == platformsList && x.DeviceProParamName == "TaskNo" && x.DeviceProParamType == "DeviceCommand"); |
| | | if (deviceProDTO6 != null && deviceProDTO7 != null) |
| | | { |
| | | conveyorLine.Communicator.Write(deviceProDTO7.DeviceProAddress, (int)LinSCStationitem.TaskNum); |
| | | if (conveyorLine.Communicator.Write(deviceProDTO6.DeviceProAddress, (bool)true)) |
| | | { |
| | | DeviceProDTO? deviceProDTO8 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == platformsList && x.DeviceProParamName == "ACK" && x.DeviceProParamType == "ReadDeviceCommand"); |
| | | if (deviceProDTO8 != null) |
| | | { |
| | | if (conveyorLine.Communicator.Read<bool>(deviceProDTO8.DeviceProAddress)) |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(LinSCStationitem.TaskNum); |
| | | conveyorLine.Communicator.Write(deviceProDTO6.DeviceProAddress, (bool)false); |
| | | conveyorLine.Communicator.Write(deviceProDTO8.DeviceProAddress, (int)0); |
| | | //写入输送线回应信号与 |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog4(LinSCStationitem.TargetAddress, "申请出库堆垛机站台错误信息", $"未读取到输送线回应信号:ACK,{LinSCStationitem}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog4(LinSCStationitem.TargetAddress, "申请出库堆垛机站台错误信息", $"未找到对于的读取模块{LinSCStationitem}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog4(LinSCStationitem.TargetAddress, "申请出库堆垛机站台失败", $"写入输送线信号,模块{deviceProDTO6.DeviceProAddress}:失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | wcsWriteLog4(LinSCStationitem.TargetAddress, "申请出库堆垛机站台错误信息", $"未找到对于的写入模块{LinSCStationitem}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取信息记录 |
| | | /// 输送线出库完成 |
| | | /// </summary> |
| | | /// <param name="SCLLinStack"></param> |
| | | /// <param name="Logtype"></param> |
| | | /// <param name="Magessadd"></param> |
| | | public void wcsWriteLog(string SCLLinStack, string Logtype, string Magessadd) |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | { |
| | | WriteLog.Write_Log("入库口", SCLLinStack + "站台", Logtype, new { 信息 = Magessadd }); |
| | | } |
| | | |
| | | public void wcsWriteLog2(string SCLLinStack, string Logtype, string Magessadd) |
| | | { |
| | | WriteLog.Write_Log("RGV站台", SCLLinStack + "站台", Logtype, new { 信息 = Magessadd }); |
| | | } |
| | | |
| | | public void wcsWriteLog3(string SCLLinStack, string Logtype, string Magessadd) |
| | | { |
| | | WriteLog.Write_Log("出库口", SCLLinStack + "站台", Logtype, new { 信息 = Magessadd }); |
| | | } |
| | | |
| | | public void wcsWriteLog4(string SCLLinStack, string Logtype, string Magessadd) |
| | | { |
| | | WriteLog.Write_Log("堆垛机站台", SCLLinStack + "站台", Logtype, new { 信息 = Magessadd }); |
| | | } |
| | | |
| | | public void wcsWriteLog5(string SCLLinStack, string Logtype, string Magessadd) |
| | | { |
| | | WriteLog.Write_Log("堆垛机入库站台", SCLLinStack + "站台", Logtype, new { 信息 = Magessadd }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public ConveyorLineCommand lineCommand(CommonConveyorLine conveyorLine,string Station_code) |
| | | { |
| | | ConveyorLineCommand conveyorLineCommand = new ConveyorLineCommand(); |
| | | List<DeviceProDTO> deviceProDTO6 = conveyorLine.DeviceProDTOs |
| | | .Where(x => x.DeviceChildCode == Station_code |
| | | && DBLine.ListDBdata.Contains(x.DeviceProParamName) |
| | | && x.DeviceProParamType == "ReadDeviceCommand") |
| | | .ToList(); |
| | | foreach (var item in deviceProDTO6) |
| | | { |
| | | var paramName = item.DeviceProParamName; |
| | | var propertyInfo = typeof(ConveyorLineCommand).GetProperty(paramName); |
| | | |
| | | if (propertyInfo != null) |
| | | { |
| | | if (item.DeviceDataType == "bool") |
| | | { |
| | | var value = conveyorLine.Communicator.Read<bool>(item.DeviceProAddress); |
| | | propertyInfo.SetValue(conveyorLineCommand, value); |
| | | }else if(item.DeviceDataType == "int") |
| | | { |
| | | var value = conveyorLine.Communicator.Read<int>(item.DeviceProAddress); |
| | | propertyInfo.SetValue(conveyorLineCommand, value); |
| | | }else if(item.DeviceDataType == "string") |
| | | { |
| | | var value = conveyorLine.Communicator.Read<string>(item.DeviceProAddress); |
| | | propertyInfo.SetValue(conveyorLineCommand, value); |
| | | } |
| | | } |
| | | } |
| | | return conveyorLineCommand; |
| | | } |
| | | } |
| | | } |