hutongqing
2024-11-01 2f75b4c0a67ccc3a443e7cc4f2f0f909defd9a92
WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine.cs
@@ -91,19 +91,10 @@
        public string DeviceName => _deviceName;
        /// <summary>
        /// 是否有故障
        /// </summary>
        public bool IsFault => false;
        /// <summary>
        /// 通讯是否已连接
        /// </summary>
        public bool IsConnected => Communicator.IsConnected && _isConnected;
        /// <summary>
        /// 设备状态
        /// </summary>
        public DeviceStatus Status => DeviceStatus.Offline;
        #endregion
        #region Constructor Function
@@ -186,17 +177,24 @@
        /// <exception cref="Exception"></exception>
        public bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new()
        {
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
            if (devicePro == null)
            if(Communicator is SiemensS7)
            {
                if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
                DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                if (devicePro == null)
                {
                    return false;
                }
                if (Communicator.WriteCustomer(devicePro.DeviceProAddress, command))
                {
                    return true;
                }
                return false;
            }
            if (Communicator.WriteCustomer(devicePro.DeviceProAddress, command))
            else
            {
                return true;
                throw new Exception("暂不支持除西门子之外的PLC");
            }
            return false;
        }
        /// <summary>