hwh
2024-09-03 c56d28d684cee010f291295dbe851bab64c1b6a6
Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
@@ -21,7 +21,7 @@
    private static List<WcsPosition> listPlcStation;
    private static List<PLCUtil> listPlcUtil = new List<PLCUtil>();
    private static CancellationTokenSource cts;//取消线程标识
    private static CancellationTokenSource cts = new CancellationTokenSource();//取消线程标识
    //对外公布连接状态
    public static List<PLCUtil> listPlcConn
    {
@@ -64,6 +64,7 @@
        cts = new CancellationTokenSource();
        boRunningState = true;
        StartRead();
        ConnectionStatus();
    }
    /// <summary>
    /// 开启读取plc线程
@@ -82,8 +83,10 @@
                    {
                        foreach (var modPlcUtil in listPlcUtil)
                        {
                            modPlcUtil.Close();
                            if (modPlcUtil != null && modPlcUtil.Connected)
                                modPlcUtil.Close();
                        }
                        break;
                        throw new OperationCanceledException();
                    }
                    try
@@ -94,7 +97,7 @@
                            modPlcUtil = new PLCUtil(modPlc);
                            listPlcUtil.Add(modPlcUtil);
                        }
                        var listDevice = listPlcDevice.Where(s => s.PlcId == _modplc.Id).ToList();
                        var listDevice = listPlcDevice.Where(s => s.PlcId == _modplc.Id && s.DeviceType == DeviceTypeEnum.Business).ToList();
                        //循环读设备
                        foreach (var modDevice in listDevice.Where(s => s.Level == DeviceLevelEnum.DB))
                        {
@@ -109,9 +112,9 @@
                                dto.Type = _modplc.Type;
                                dto.PLCUtil = modPlcUtil;
                                dto.listStation = listPlcStation.Where(s => s.DeviceId == modDevice.Id).ToList();
                                dto.listDevice = listDevice.Where(s => s.StationNum == modDevice.StationNum).ToList();
                                dto.listDevice = listDevice.Where(s => s.StationNum == modDevice.StationNum && s.Level == DeviceLevelEnum.Station).ToList();
                                //这里触发值变更事件
                                DeviceValueChangeEvent?.Invoke(dto, EventArgs.Empty);
                                //DeviceValueChangeEvent?.Invoke(dto, EventArgs.Empty);
                            }
                            else
                            {