/// <summary> /// Write a byte of data to the controller. Note that data may be /// pre-processed through filters before being sent to the output device. /// </summary> /// <param name="Data">A byte of data to send through the controller</param> private void WriteByte(byte Data) { this.TotalUnfilteredBytesSent++; if (outputFilter != null) { // Write data to the first filter. The filters are daisy-chained, so this value // is passed all the way down to the end of the chain and back up again. outputFilter.Write(Data); while (outputFilter.DataReady) { byte b = outputFilter.Read(); this.TotalBytesSent++; lock (this.dataToSend) { this.dataToSend.Enqueue(b); } } } else { // If there are no output filters, just store the value in the send queue. lock (this.dataToSend) { this.dataToSend.Enqueue(Data); } } }
/// <summary> /// Function that gets called from descendents to register data received from /// a device with the controller - which may include pre-processing filters. /// </summary> /// <param name="Data">A byte of incoming data to register with the controller</param> protected void ReceiveFromDevice(byte Data) { this.TotalUnfilteredBytesReceived++; try { if (inputFilter != null) { // Write data to the first filter. The filters are daisy-chained, so this value // is passed all the way down to the end of the chain and back up again. inputFilter.Write(Data); while (inputFilter.DataReady) { byte b = inputFilter.Read(); this.TotalBytesReceived++; lock (this.dataReceived) { this.dataReceived.Enqueue(b); } } } else { // If there are no input filters, just store the value in the receipt queue. lock (this.dataReceived) { this.dataReceived.Enqueue(Data); } } } catch (Exception ex) { BroadcastError(ex.Message); } }