Ok, so I have a little project with heating elements, and based on a temperature differential the netduino will ask for a certain number to be on.
I am trying to create a little object which uses a Queue to equalize the loading on all of them so I don't manually have to swap them out to ensure even wearing over time.
Problem is the Queue initialization seems to be returning null, but its just the standard Queue from System.Collections. Does the .NET MF not actually implement Queue?
Code:
public class Balancer{ public Balancer(Cpu.Pin[] relayPins) { _avail = new RelayList(false); foreach (Cpu.Pin relaypin in relayPins) _avail.Enqueue(new Heater(relaypin)); }}public class RelayList{ protected bool _isActive; protected Queue _list; public RelayList(bool isActive) { _isActive = isActive; _list = new Queue(); } public virtual object Dequeue() { if (_list != null) return _list.Dequeue(); return new object(); } public virtual void Enqueue(object toAdd) { if (_list != null) _list.Enqueue(toAdd); }}
As you can see, _list is a Queue. I was concerned because the _avail.Enqueue was not putting the Heater objects into the Queue.
When I started my debug, basically the if(_list != null) in Enqueue was failing, so I walked through the constructor and, after the _list = new Queue() line, _list is still null. Am I doing something wrong? Is their a limit on call stack depth (this code is called about 4 deep during intialization, Main -> Balancer -> RelayList -> Queue)? Would that cause an error like this or would it throw an exception?