| | |
| | | using Microsoft.AspNetCore.Components.Routing; |
| | | using HslCommunication.WebSocket; |
| | | using Microsoft.AspNetCore.Components.Routing; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using SqlSugar.Extensions; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics.CodeAnalysis; |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using SqlSugar.Extensions; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | using WIDESEAWCS_Tasks.åæåº; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | private readonly IRouterService _routerService; |
| | | private readonly IRouterRepository _routerRepository; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | private readonly WebSocketServer _webSocketServer; |
| | | |
| | | public StackerCraneJob_CP(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository,IRouterRepository routerRepository) |
| | | public StackerCraneJob_CP(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository,IRouterRepository routerRepository, WebSocketServer webSocketServer) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | _routerService = routerService; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _routerRepository = routerRepository; |
| | | _webSocketServer = webSocketServer; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | |
| | | { |
| | | commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订é
ä»»å¡å®æäºä»¶ |
| | | } |
| | | commonStackerCrane.CheckStackerCraneTaskCompleted();//鲿¢ä»»å¡å®æäºä»¶çæµè¶
æ¶ï¼åæå¨è§¦å䏿¬¡ |
| | | if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) |
| | | //commonStackerCrane.CheckStackerCraneTaskCompleted();//鲿¢ä»»å¡å®æäºä»¶çæµè¶
æ¶ï¼åæå¨è§¦å䏿¬¡ |
| | | if (commonStackerCrane.CurrentTaskNum > 0 && (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted || commonStackerCrane.Communicator.Read<short>("DB1000.40.0") == 3)) |
| | | { |
| | | StackerCraneTaskCompletedEventArgs e = new StackerCraneTaskCompletedEventArgs(commonStackerCrane.CurrentTaskNum); |
| | | CommonStackerCrane_StackerCraneTaskCompletedEventHandler(commonStackerCrane, e); |
| | | } |
| | | else if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) |
| | | { |
| | | short stackerError = commonStackerCrane.Communicator.Read<short>("DB1000.54.0"); |
| | | if (stackerError == 0) |
| | |
| | | } |
| | | } |
| | | } |
| | | // 设置设å¤ç¼å·ï¼å端ç¨äºè¯å«å åæº |
| | | YL_DB yL_DB = new YL_DB(); |
| | | yL_DB.R_PP_Status = commonStackerCrane.DeviceCode; |
| | | // 设置å åæºç¶æ |
| | | yL_DB.YL_Status = commonStackerCrane.StackerCraneStatusValue switch |
| | | { |
| | | StackerCraneStatus.Fault => 0, |
| | | StackerCraneStatus.Normal => 1, |
| | | StackerCraneStatus.EmergencyStop => 2, |
| | | StackerCraneStatus.Unkonw => 3, |
| | | }; |
| | | yL_DB.YL_AutoStatus = commonStackerCrane.StackerCraneAutoStatusValue switch |
| | | { |
| | | StackerCraneAutoStatus.SemiAutomatic => 1, |
| | | StackerCraneAutoStatus.Maintenance => 2, |
| | | StackerCraneAutoStatus.Automatic => 3, |
| | | StackerCraneAutoStatus.Manual => 4, |
| | | StackerCraneAutoStatus.Unkonw => 5, |
| | | }; |
| | | yL_DB.YL_WorkStatus = commonStackerCrane.StackerCraneWorkStatusValue switch |
| | | { |
| | | StackerCraneWorkStatus.Standby => 1, |
| | | StackerCraneWorkStatus.PickUpCompleted => 2, |
| | | StackerCraneWorkStatus.PickUp => 3, |
| | | StackerCraneWorkStatus.Putting => 5, |
| | | StackerCraneWorkStatus.WorkCompleted => 9, |
| | | }; |
| | | yL_DB.YL_TaskNum = commonStackerCrane.CurrentTaskNum; |
| | | yL_DB.YL_WorkType = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType); |
| | | yL_DB.YL_Row = commonStackerCrane.Communicator.Read<short>("DB1000.46"); |
| | | yL_DB.YL_Column = commonStackerCrane.Communicator.Read<short>("DB1000.48.0"); |
| | | yL_DB.YL_Layer = commonStackerCrane.Communicator.Read<short>("DB1000.50.0"); |
| | | // è¯»åæ¥è¦ä¿¡æ¯ |
| | | short stackerError2 = commonStackerCrane.Communicator.Read<short>("DB1000.54.0"); |
| | | yL_DB.StackerAlarm = stackerError2 == 0 ? "æ " : $"æ¥è¦ä»£ç : {stackerError2}"; |
| | | // åºååå¹¶åéæ°æ® |
| | | string ylDB = JsonConvert.SerializeObject(yL_DB); |
| | | _webSocketServer.PublishAllClientPayload(ylDB); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StackerCraneStationCode == task.NextAddress && x.StackerCraneCode==deviceCode); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode==deviceCode); |
| | | if (stationManger == null) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"è¾é线åºåºç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | |
| | | /// <returns></returns> |
| | | private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | //夿æ¯å¦ææ£æ§è¡çä»»å¡ï¼å¦ææåä¸ä¸å |
| | | Dt_Task? taskOld = _taskRepository.QueryFirst(x => x.DeviceCode == commonStackerCrane.DeviceCode && x.Roadway == commonStackerCrane.DeviceCode && x.TaskState == TaskStatusEnum.SC_Executing.ObjToInt()); |
| | | if (taskOld!=null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | Dt_Task task; |
| | | if (commonStackerCrane.LastTaskType == null) |
| | | { |
| | |
| | | short command = client.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode); |
| | | if (command==3)//åºåºç«å°æªè¢«å ç¨ |
| | | { |
| | | task.NextAddress = stationManger.StackerCraneStationCode; |
| | | _taskRepository.UpdateData(task); |
| | | //task.NextAddress = stationManger.StackerCraneStationCode; |
| | | //_taskRepository.UpdateData(task); |
| | | return task; |
| | | } |
| | | else |
| | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//夿æ¯å¦æ¯åºåºä»»å¡ |
| | | { |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode); |
| | | string[] targetCodes = stationManger.StackerCraneStationCode.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); |