| | |
| | | using DocumentFormat.OpenXml.Drawing; |
| | | using Furion.Logging; |
| | | using Microsoft.AspNetCore.SignalR; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using System; |
| | | //using WCS.Application.Util; |
| | | |
| | | namespace WCS.Application; |
| | | public static class PLCTaskAction |
| | |
| | | /// </summary> |
| | | public static void Init() |
| | | { |
| | | // var strMsg = new HttpService().RequestPackWcs("LN000001"); |
| | | cts.Cancel(); |
| | | listPlc = _db.Queryable<WcsPlc>() |
| | | .Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine || s.Type == PLCTypeEnum.BoxConveyorLine) |
| | |
| | | } |
| | | if (!modPlcUtil.Connected) |
| | | { |
| | | Thread.Sleep(10000); |
| | | Thread.Sleep(1000); |
| | | modPlcUtil.Open(); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | //Console.WriteLine($"{modPlc.IP}读取{modDevice.DbNumber}.{modDevice.PlcPos}的值为:{value}"); |
| | | //无流程跳出 |
| | | if (value == 0 )// && modPlc.Type!= PLCTypeEnum.BoxConveyorLine |
| | | if (value == 0)// && modPlc.Type!= PLCTypeEnum.BoxConveyorLine |
| | | continue; |
| | | var dto = modDevice.Adapt<WcsDeviceDto>(); |
| | | dto.Value = value; |
| | |
| | | HubUtil.PublicPlcConn(modPlc); |
| | | } |
| | | } |
| | | Thread.Sleep(1000); |
| | | Thread.Sleep(10000); |
| | | } |
| | | } |
| | | catch (OperationCanceledException) |
| | |
| | | listPulish.Add(modAlarm); |
| | | } |
| | | //取消报警 |
| | | else if (value && modAlarm.Status == YesNoEnum.Y) |
| | | else if (!value && modAlarm.Status == YesNoEnum.Y) |
| | | { |
| | | modAlarm.AlarmTime = null; |
| | | modAlarm.Status = YesNoEnum.N; |
| | |
| | | modLog.Id = 0; |
| | | listLog.Add(modLog); |
| | | } |
| | | _db.Insertable(listLog).ExecuteCommand(); |
| | | if (listLog.Count >= 0) |
| | | _db.Insertable(listLog).ExecuteCommand(); |
| | | HubUtil.PublicAlarm(listPulish); |
| | | } |
| | | } |
| | |
| | | if (modPlcUtil == null) |
| | | continue; |
| | | var plcIp = modPlcUtil.PlcIP; |
| | | var listDevice = listPlcDevice.Where(s => s.PlcId == modPlcUtil.PlcId && s.DeviceType == DeviceTypeEnum.Show).ToList(); |
| | | var modPlc = listPlc.FirstOrDefault(s => s.Id == modPlcUtil.PlcId); |
| | | var listDevice = listPlcDevice.Where(s => s.PlcId == modPlcUtil.PlcId && s.DeviceType == DeviceTypeEnum.Show).ToList(); |
| | | var modPlc = listPlc.FirstOrDefault(s => s.Id == modPlcUtil.PlcId); |
| | | var listaddress = new Dictionary<string, PLCDataTypeEnum>(); |
| | | foreach (var modDevice in listDevice) |
| | | { |
| | |
| | | { |
| | | var bl = false; |
| | | int value = Convert.ToInt32(item.Value); |
| | | if (value == 0) |
| | | if (value <= 30) |
| | | { |
| | | bl = false; |
| | | } |
| | | else |
| | | else |
| | | { |
| | | bl = true; |
| | | } |
| | |
| | | HubUtil.PublicPosition(modInfo); |
| | | UpdatePosition(modInfo); |
| | | } |
| | | // liudl 注释:和电气工程师确认页面展示交互字后启用。 |
| | | //var value = Convert.ToBoolean(item.Value); |
| | | //if (!value == modDevice.BoHaveItem) |
| | | //{ |
| | | // modDevice.BoHaveItem = value; |
| | | // //下发状态 |
| | | // var modInfo = new PlcPositionInfo() { Type = modPlc.Type, StationNum = modDevice.StationNum.PadLeft(3,'0'), BoHaveItem = value }; |
| | | // HubUtil.PublicPosition(modInfo); |
| | | // UpdatePosition(modInfo); |
| | | //} |
| | | } |
| | | break; |
| | | default: |