//------------------------------------------------------------------------------------------------------------ // periodic timer to handle network reads (ugly, but functional, and with simple to read code) private void TimerEventProcessor(Object myObject, EventArgs myEventArgs) { timer1.Stop(); // read a packet of data from the gate // if (sock != null && sock.Available > 0) { byte[] rxBuf = new byte[256]; int numBytes = sock.Receive(rxBuf); if (numBytes > 0) { laprf.processBytes(rxBuf, numBytes); } } // update the progress bars with RSSI values // for (int idx = 1; idx <= 8; ++idx) { ProgressBar ctn = (ProgressBar)this.Controls["progressBar" + idx]; ctn.Value = (int)laprf.getRssiPerSlot(idx).lastRssi; } // captured any passing records? // if (laprf.getPassingRecordCount() > 0) { PassingRecord nextRecord = laprf.getNextPassingRecord(); passingRecordText.Text = String.Format("Passing: {0} {1} {2}", nextRecord.passingNumber, nextRecord.pilotId, nextRecord.rtcTime); } timer1.Enabled = true; }
//----------------------------------------------------------------------------------- public LapRFProtocol() { crcCalc = new CRCCalc(); passingRecords = new Queue <PassingRecord>(); inDecode = false; currentRssiSlot = 0; currentSetupSlot = 0; currentPassingRecord = new PassingRecord(); currentPassingRecord.bValid = false; // initialize the last status date, assume that we got at least one good status lastStatusDate = DateTime.Now; // create the Rx stream rxStream = new MemoryStream(); rxStreamWriter = new BinaryWriter(rxStream); unitTests(); }