/// <summary> /// Initializes an object for polling data. /// </summary> private void InitModbusPoll() { if (deviceTemplate != null) { // find the required size of the input buffer int inBufSize = 0; foreach (ElemGroup elemGroup in elemGroups) { if (inBufSize < elemGroup.RespAduLen) { inBufSize = elemGroup.RespAduLen; } } foreach (ModbusCmd cmd in deviceTemplate.Cmds) { if (inBufSize < cmd.RespAduLen) { inBufSize = cmd.RespAduLen; } } // create an object for polling data modbusPoll = new ModbusPoll(inBufSize) { Timeout = ReqParams.Timeout, Connection = Connection, WriteToLog = WriteToLog }; } }
/// <summary> /// Initializes an object for polling the device. /// </summary> private void InitModbusPoll() { if (deviceModel != null) { // calculate input buffer size int bufferSize = 0; foreach (ElemGroup elemGroup in deviceModel.ElemGroups) { if (bufferSize < elemGroup.RespAduLen) { bufferSize = elemGroup.RespAduLen; } } foreach (ModbusCmd cmd in deviceModel.Cmds) { if (bufferSize < cmd.RespAduLen) { bufferSize = cmd.RespAduLen; } } // create polling object modbusPoll = new ModbusPoll(transMode, bufferSize) { Timeout = PollingOptions.Timeout, Connection = Connection, Log = Log }; } }
protected ModbusPoll modbusPoll; // implements device polling /// <summary> /// Initializes a new instance of the class. /// </summary> public DevModbusLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig) : base(commContext, lineContext, deviceConfig) { transMode = TransMode.RTU; deviceModel = null; modbusPoll = null; }
private HashSet <int> floatSignals; // множество сигналов, форматируемых как вещественное число /// <summary> /// Конструктор /// </summary> public KpModbusLogic(int number) : base(number) { modbusPoll = new ModbusPoll(); }
private void btnTestAlarm_Click(object sender, EventArgs e) { try { short[] d = new short[] { 0, 0, 0, 0 }; if (flag == 1) { d = new short[] { 0, 0, 0, 0 }; } else { d = new short[] { 1, 1, 1, 1 }; } ModbusPoll mp = new ModbusPoll(); try { mp.StartPoll(this.cbAlarmSerialPort.Text, d); flag = (short)Math.Abs(flag - 1); } catch (Exception ex) { MessageBox.Show("访问报警设备异常:" + ex.Message); } finally { mp.StopPoll(); } } finally { } }