| | |
| | | #region << 版 本 注 释 >> |
| | | |
| | | /*---------------------------------------------------------------- |
| | | * 命名空间:WIDESEAWCS_QuartzJob |
| | | * 创建者:胡童庆 |
| | |
| | | * 修改说明: |
| | | * |
| | | *----------------------------------------------------------------*/ |
| | | |
| | | #endregion << 版 本 注 释 >> |
| | | |
| | | using HslCommunication; |
| | |
| | | public class CommonConveyorLine : IConveyorLine |
| | | { |
| | | #region Private Member |
| | | |
| | | /// <summary> |
| | | /// 堆垛机通讯对象 |
| | | /// </summary> |
| | |
| | | private bool _heartStatr = true; |
| | | |
| | | private bool _isConnected = true; |
| | | |
| | | #endregion |
| | | |
| | | #region Public Member |
| | | |
| | | /// <summary> |
| | | /// 输送线通讯对象 |
| | | /// </summary> |
| | |
| | | /// 设备状态 |
| | | /// </summary> |
| | | public DeviceStatus Status => DeviceStatus.Offline; |
| | | |
| | | #endregion |
| | | |
| | | #region Constructor Function |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | |
| | | _deviceName = deviceName; |
| | | CheckConnect(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Private Method |
| | | |
| | | private void CheckConnect() |
| | | { |
| | | Task.Run(() => |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Public Method |
| | | |
| | | /// <summary> |
| | | /// 读取PLC协议地址的数据 |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取PLC数据,返回自定义对象 |
| | | /// </summary> |
| | | /// <typeparam name="T">泛型</typeparam> |
| | | /// <param name="deviceChildCode">子设备编号</param> |
| | | /// <param name="deviceProParamType">参数类型</param> |
| | | /// <returns>返回自定义对象或抛出异常</returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public T ReadCustomer<T>(string deviceChildCode, string deviceProParamType) where T : IDataTransfer, new() |
| | | { |
| | | if (!IsConnected) throw new Exception($"通讯连接错误,请检查网络"); |
| | | DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == deviceProParamType && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | if (devicePro == null) |
| | | { |
| | | throw new Exception("未找到协议信息"); |
| | | } |
| | | else |
| | | { |
| | | return Communicator.ReadCustomer<T>(devicePro.DeviceProAddress); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据参数名称、设备子编号写入对应的数据。 |
| | | /// </summary> |
| | | /// <typeparam name="TEnum">参数名称枚举类型。</typeparam> |
| | |
| | | _communicator.Dispose(); |
| | | GC.SuppressFinalize(this); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |