xxyy
2025-02-15 abff6261e5e74ff16a844f4739f84d49b6133000
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine.cs
@@ -174,7 +174,7 @@
        /// <returns>读取到的数据</returns>
        public TRsult GetValue<TEnum, TRsult>(TEnum value, string deviceChildCode) where TEnum : Enum
        {
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【 {DeviceName} 】");
            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == value.ToString() && x.DeviceChildCode == deviceChildCode);
            return devicePro == null ? throw new Exception() : (TRsult)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
        }
@@ -197,7 +197,7 @@
        /// <exception cref="Exception"></exception>
        public bool SendCommand<T>(T command, string deviceChildCode) where T : IDataTransfer, new()
        {
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【{DeviceName}】");
            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
            if (devicePro == null)
            {
@@ -219,7 +219,7 @@
        /// <exception cref="Exception"></exception>
        public T ReadCustomer<T>(string deviceChildCode) where T : IDataTransfer, new()
        {
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【{DeviceName}】");
            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == "ReadDeviceCommand" && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
            if (devicePro == null)
@@ -242,7 +242,7 @@
        /// <exception cref="Exception"></exception>
        public T ReadCustomer<T>(string deviceChildCode, string deviceProParamType) where T : IDataTransfer, new()
        {
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【{DeviceName}】");
            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == deviceProParamType && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
            if (devicePro == null)
@@ -268,13 +268,13 @@
            where TEnum : Enum
            where TValue : notnull
        {
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络");
            if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络【 {DeviceName} 】");
            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == @enum.ToString() && x.DeviceChildCode == deviceChildCode);
            return devicePro == null ? throw new Exception() : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value);
        }
        /// <summary>
        ///
        /// 检测站台是否有货
        /// </summary>
        /// <param name="deviceChildCode"></param>
        /// <returns></returns>
@@ -306,6 +306,31 @@
            return false;
        }
        /// <summary>
        /// 检测站台是否有货
        /// </summary>
        /// <param name="deviceChildCode"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public bool IsOccupiedx(string deviceChildCode)
        {
            if (Communicator.IsConnected)
            {
                var device = _deviceProDTOs.Where(x => x.DeviceChildCode == deviceChildCode && x.DeviceProParamName == "InteractiveSignal").FirstOrDefault();
                object readStatus = Communicator.ReadAsObj(device.DeviceProAddress, device.DeviceDataType);
                //todo 协议明细信息未获取到时抛出异常
                if (readStatus.ToString() != "2")
                {
                    return true;
                }
                return false;
            }
            //todo 通讯未连接时抛出异常
            return false;
        }
        public void Dispose()
        {
            _heartStatr = false;