// Poll a single device on the board // Polling typically is reading the temperature(s) from the device; TEC board // also queries current and power. internal void PollNextDeviceBurst() { BoardDevice active = null; // identify the device to next be polled foreach (BoardDevice dev in _pollees) { dev.Poll(); } }
// Poll a single device on the board // Polling typically is reading the temperature(s) from the device; TEC board // also queries current and power. // The idea here is to spread out the queries over time rather than sending every // message at one go (up to twenty-four queries). internal void PollNextDevice() { BoardDevice active = null; // identify the device to next be polled foreach (BoardDevice dev in _pollees) { // Ignore devices that aren't getting polled if (dev.TicksRemaining == 0) { continue; } // Decrement the countdown for each device dev.TicksRemaining -= 1; // Has this one elapsed? if (dev.TicksRemaining == 0) { // First in list to elapse? if (active == null) { active = dev; // reset to poll again after the interval expires dev.TicksRemaining = dev.PollInterval / Tick; } else { // A device earlier in the list will be polled; // need to defer this one until next available tik dev.TicksRemaining += 1; } } } // Have an elapsed one? if (active != null) { // Poll it active.Poll(); // Move device to the end of the list // so that older ones get a chance if this has a short interval _pollees.Remove(active); _pollees.Add(active); } }