| | |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AngleSharp.Dom; |
| | | using Autofac.Core; |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Microsoft.CodeAnalysis.CSharp.Syntax; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Quartz; |
| | | using System.Reflection; |
| | |
| | | #endregion è°ç¨äºä»¶æ»çº¿éç¥å端 |
| | | |
| | | // å°äº¤äºä¿¡å·è½¬æ¢ä¸ºå¸å°æ°ç» |
| | | var writeInteractiveSignal = command.InteractiveSignal; |
| | | var structs = BitConverter.GetBytes(writeInteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | // è·å设å¤å议详æ
|
| | | List<DeviceProtocolDetailDTO>? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.Where(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal)).ToList(); |
| | | |
| | |
| | | MethodInfo? method = GetType().GetMethod(item.ProtocolDetailType); |
| | | if (method != null) |
| | | { |
| | | method.Invoke(this, new object[] { conveyorLine, station.stationName }); |
| | | method.Invoke(this, new object[] { conveyorLine, station }); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="command">读åç请æ±ä¿¡æ¯</param>Request outbound |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public async Task RequestInbound(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | public async Task RequestInbound(CommonConveyorLine conveyorLine, Dt_StationManager station) |
| | | { |
| | | try |
| | | { |
| | | // è¾åºä¿¡æ¯ï¼è¡¨ç¤ºç«å°è¯·æ±åè´§ |
| | | var log = $"ã{conveyorLine._deviceName}ãç«å°ã{childDeviceCode}ã请æ±åè´§"; |
| | | ConsoleHelper.WriteWarningLine(log); |
| | | // æ¨ééç¥å°å端SignIR |
| | | await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "Red" }); |
| | | WriteInfo(conveyorLine.DeviceName, log); |
| | | var log = $"ã{conveyorLine._deviceName}ãç«å°ã{station.stationName}ã请æ±åè´§"; |
| | | await LogAndWarn(conveyorLine.DeviceName, log); |
| | | |
| | | // è·åææä»»å¡æºå°å |
| | | List<string> task = _taskService.QueryConveyorLineTaskSourceAddress(); |
| | | List<string> taskSourceAddress = _taskService.QueryConveyorLineTask(); |
| | | if (_taskService.QueryConveyorLineTask(station.stationName) != null) |
| | | { |
| | | ConveyorLineSendFinish(conveyorLine, station.stationName); |
| | | await LogAndWarn(conveyorLine.DeviceName, $"ã{conveyorLine._deviceName}ãç«å°ã{station.stationName}ãåå¨ä»»å¡"); |
| | | return; |
| | | } |
| | | |
| | | // æ ¹æ®è®¾å¤ç¼å·å任塿ºå°åæ¥è¯¢æææªæ§è¡çä»»å¡ |
| | | List<Dt_StationManager> childDeviceCodes = _stationManagerService.QuerypLatform(conveyorLine.DeviceCode, task); //å¯¹åºæ¯ä¸ªipæ¾å
¨é¨ç䏿ç«ç¹ä¸å«æ¿åæ¶ç¹ç«å°ç¹ |
| | | List<Dt_StationManager> childDeviceCodes = _stationManagerService.QueryPlatform(station, taskSourceAddress); //å¯¹åºæ¯ä¸ªipæ¾å
¨é¨ç䏿ç«ç¹ä¸å«æ¿åæ¶ç¹ç«å°ç¹ |
| | | |
| | | if(childDeviceCodes.Count()==0|| childDeviceCodes == null) |
| | | { |
| | | ConveyorLineSendFinish(conveyorLine, station.stationName); |
| | | await LogAndWarn(conveyorLine.DeviceName, $"ã{conveyorLine._deviceName}ãç«å°ã{station.stationName}ãæªæ¾å°å¯åå¾ç«å°"); |
| | | return; |
| | | } |
| | | |
| | | foreach (var item in childDeviceCodes) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); |
| | | if (command != null) |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == item.DeviceCode); |
| | | if (device != null) |
| | | { |
| | | var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | if (structs[1]) |
| | | { |
| | | if (item.stationMaterial == (int)AgvStationEnum.PadRecycle) |
| | | { |
| | | RequestHcdbst(conveyorLine, item.stationArea, item.stationName, item.stationRemark); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | Dt_Task taskDTO = new Dt_Task() |
| | | { |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Grade = 1, |
| | | Roadway = item.stationArea.ToString(), |
| | | SourceAddress = childDeviceCode, |
| | | TargetAddress = item.stationName, |
| | | TaskState = (int)AGVTaskStatusEnum.AGVNew, |
| | | TaskType = item.stationMaterial, |
| | | }; |
| | | _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, $"ç«å°{item.stationName}ç¶æä¸å¯ç¨{structs[2]}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, $"éè®¯è¿æ¥é误ï¼{item.stationName}æªæ¾å°è¯»å模åå°å"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®agv䏿任å¡ï¼æææ¾è³ä¸æå£æç¼åä½ |
| | | /// </summary> |
| | | /// <param name="conveyorLine">è¾é线å®ä¾å¯¹è±¡</param> |
| | | /// <param name="childDeviceCode">å设å¤ç¼å·</param> |
| | | public void RequestOutbound(CommonConveyorLine conveyorLine, string childDeviceCode) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_StationManager> station = _stationManagerService.QuerypLatformarer(conveyorLine.DeviceCode); |
| | | foreach (var item in station) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | ConveyorLineTaskCommand command = commonConveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); |
| | | if (command != null) |
| | | { |
| | | var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | if (structs[2]) |
| | | { |
| | | if (item.stationMaterial == (int)AgvStationEnum.BoardLoad) |
| | | Dt_Task taskDTO = new Dt_Task() |
| | | { |
| | | //Dt_Task agvstack= _taskService.QueryConveyorLineTaskRoadway(AGVStationitem.stationArea); |
| | | //if(agvstack != null) |
| | | //{ |
| | | // _taskService.UpdateTargetAddress(agvstack.TaskId, AGVStationitem.stationName); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //廿¾ç¼ååºåºå |
| | | // RequestHcst(conveyorLine, AGVStationitem.stationArea, AGVStationitem.stationName, AGVStationitem.stationRemark); |
| | | //} |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Grade = 1, |
| | | Roadway = item.stationArea.ToString(), |
| | | SourceAddress = station.stationName, |
| | | CurrentAddress= station.stationName, |
| | | TargetAddress = item.stationName, |
| | | NextAddress = item.stationName, |
| | | TaskState = (int)AGVTaskStatusEnum.AGVNew, |
| | | TaskType = (int)AGVTaskTypeEnum.AGVCarry, |
| | | AGVName = item.stationArea switch |
| | | { |
| | | 1 => "AGV01", |
| | | 4 => "AGV03", |
| | | _ => "AGV02", |
| | | } |
| | | }; |
| | | _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); |
| | | ConveyorLineSendFinish(conveyorLine,station.stationName); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | await LogAndWarn(conveyorLine.DeviceName, $"ç«å°{item.stationName}ç¶æä¸å¯ç¨{structs[2]}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, $"ç«å°{item.stationName}ç¶æä¸å¯ç¨{structs[2]}"); |
| | | WriteInfo(conveyorLine.DeviceName, $"éè®¯è¿æ¥é误ï¼{item.stationName}æªæ¾å°è¯»å模åå°å"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var logerror = $"ã{conveyorLine.DeviceName}ãç«å°ï¼ã{item.stationName}ãæªé
置设å¤è¡¨å¤´"; |
| | | await LogAndWarn(conveyorLine.DeviceName, logerror); |
| | | } |
| | | } |
| | | } |
| | |
| | | WriteInfo(conveyorLine.DeviceName, ex.Message); |
| | | } |
| | | } |
| | | |
| | | public void RequestHcst(CommonConveyorLine conveyorLine,int Station_Area,string Station_names,string Station_remark) |
| | | { |
| | | List<Dt_StationManager> AGVStationListdata = _stationManagerService.QuerypLatformmaterial(Station_Area); //æ¥åºç¼åä½ |
| | | if (Station_remark != null) //æ¾å¯»å¯¹åºçæ¾è´§ç«å° |
| | | { |
| | | AGVStationListdata = _stationManagerService.QuerypStation_Area2(Station_remark); |
| | | } |
| | | foreach (var item in AGVStationListdata) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); |
| | | if (command != null) |
| | | { |
| | | var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | if (structs[1]) |
| | | { |
| | | if (_taskService.QueryConveyorLinetaeersuadd(item.stationName)) |
| | | { |
| | | Dt_Task taskDTO = new Dt_Task() |
| | | { |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Grade = 1, |
| | | Roadway = item.stationArea.ToString(), |
| | | SourceAddress = item.stationName, |
| | | CurrentAddress = item.stationName, |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | TaskType = (int)item.stationMaterial, |
| | | TargetAddress = Station_names, |
| | | NextAddress = Station_names, |
| | | }; |
| | | _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, $"éè®¯è¿æ¥é误ï¼{item.stationName}æªæ¾å°è¯»å模åå°å"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void RequestHcdbst(CommonConveyorLine conveyorLine, int Station_Area, string Station_names,string Station_remark) |
| | | { |
| | | List<Dt_StationManager> AGVStationListdata = _stationManagerService.QuerypStation_Area(Station_Area); //æ¥åºç¼åä½ |
| | | if(Station_remark !=null) //æ¾å¯»å¯¹åºçæ¾è´§ç«å° |
| | | { |
| | | AGVStationListdata= _stationManagerService.QuerypStation_Area2(Station_remark); |
| | | } |
| | | |
| | | foreach (var item in AGVStationListdata) |
| | | { |
| | | ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item.stationName); |
| | | if (command != null) |
| | | { |
| | | var structs = BitConverter.GetBytes(command.InteractiveSignal).Reverse().ToArray().ToBoolArray(); |
| | | if (structs[1]) |
| | | { |
| | | if (_taskService.QueryConveyorLinetaeersuadd(item.stationName)) |
| | | { |
| | | Dt_Task taskDTO = new Dt_Task() |
| | | { |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Grade = 1, |
| | | Roadway = item.stationArea.ToString(), |
| | | SourceAddress = Station_names, |
| | | CurrentAddress = Station_names, |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | TaskType = (int)item.stationMaterial, |
| | | TargetAddress = item.stationName, |
| | | NextAddress = item.stationName, |
| | | }; |
| | | _taskService.ReceiveWMSTask(new List<Dt_Task> { taskDTO }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, $"è¯»åæ¾è´§ä¿¡å·ä¸ºï¼{structs[2]}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¾é线交äºå®æ |
| | | /// </summary> |
| | |
| | | |
| | | conveyorLine.Communicator.Write(devicePro.DeviceProAddress, true); |
| | | } |
| | | |
| | | public async Task LogAndWarn(string deviceName, string log, string color = "red") |
| | | { |
| | | ConsoleHelper.WriteWarningLine(log); |
| | | await _noticeService.Logs(userTokenIds, new { deviceName, log = log, time = DateTime.Now.ToString("G"), color = color }); |
| | | WriteInfo(deviceName, log); |
| | | } |
| | | } |
| | | } |