Пример #1
0
        private void OnResponseToReadRequestReceived(ModbusRequest request, ModbusMessage message)
        {
            if (message.Function == ReadFunctionCode)
            {
                string readValue = new UTF8Encoding().GetString(message.Data);

                if (DataReadEvent != null)
                    DataReadEvent(this, new ModbusDataReadEventArgs(request.SlaveAddress, request.RegisterNumber, readValue));
            }
        }
Пример #2
0
 private void OnResponseToWriteRequestReceived(ModbusRequest request, ModbusMessage message)
 {
 }
Пример #3
0
 private ModbusRequest AddSentRequest(byte slaveAddress, short register, ModbusMessage message, Action<ModbusRequest, ModbusMessage> ResponseHandler)
 {
     ModbusRequest request = new ModbusRequest(message, slaveAddress, register, NumberOfAttempts, RequestTimeout);
     request.TimeoutEvent += new EventHandler(OnRequestTimeout);
     request.ResponseHandler = ResponseHandler;
     _sentRequests.Add(slaveAddress, request);
     return request;
 }