public static PLCCommandQueue GetInstance(PLCSerialPortInterface serialPortInterface) { if (pLCCommandQueue == null) { pLCCommandQueue = new PLCCommandQueue(serialPortInterface); } return(pLCCommandQueue); }
public PLCCommandQueue(PLCSerialPortInterface serialPortInterface) { this.serialPortInterface = serialPortInterface; IsStart = false; HasRead = true; queue = new ConcurrentQueue <string>(); priority1Queue = new ConcurrentQueue <CCDSendData>(); priority2Queue = new ConcurrentQueue <CCDSendData>(); timer = new DispatcherTimer(); }
public static PLCSerialPortUtils GetInstance(PLCSerialPortInterface serialPortInterface) { if (serialPortUtils == null) { serialPortUtils = new PLCSerialPortUtils(); mSerialPortInterface = serialPortInterface; // 读取配置,并给串口通讯类做配置 InitSerialPort(); } return(serialPortUtils); }
/// <summary> /// /// </summary> /// <param name="serialPortInterface">PLC</param> /// <param name="frequent">发送监听时间间隔(单位毫秒)</param> /// <param name="data">发送内容</param> public PLCReader(PLCSerialPortInterface serialPortInterface, int frequent, string data) { plcUtils = PLCSerialPortUtils.GetInstance(serialPortInterface); Frequent = frequent; this.data = data; }