Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Queue's available for Netduino?


  • Please log in to reply
2 replies to this topic

#1 Gauss

Gauss

    Member

  • Members
  • PipPip
  • 14 posts

Posted 11 October 2013 - 05:15 PM

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?



#2 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 12 October 2013 - 01:40 PM

Hi Gauss,

 

I have written some code to use a queue, but have yet to try it out properly.

Your post triggered me to run it up.

 

I am using a Netduino plus v1 with .netmf v4.2.

 

I put a break point on the line:

messageQueue = new Queue();

Before the line executes, I confirmed that the messageQueue variable appears as "null" when the mouse hovers over it.

After stepping over the line, the variable appears as "Count = 0" instead, and I can click a "+" to see more internal data.

 

The queue is a private member of a class that is created by the main program.

It is new'd when the class constructor runs.

 

What hardware and framework combination do you have?

 

Hope this is of some help - Paul



#3 Gauss

Gauss

    Member

  • Members
  • PipPip
  • 14 posts

Posted 14 October 2013 - 07:39 PM

Hi Gauss,

 

I have written some code to use a queue, but have yet to try it out properly.

Your post triggered me to run it up.

 

I am using a Netduino plus v1 with .netmf v4.2.

 

I put a break point on the line:

messageQueue = new Queue();

Before the line executes, I confirmed that the messageQueue variable appears as "null" when the mouse hovers over it.

After stepping over the line, the variable appears as "Count = 0" instead, and I can click a "+" to see more internal data.

 

The queue is a private member of a class that is created by the main program.

It is new'd when the class constructor runs.

 

What hardware and framework combination do you have?

 

Hope this is of some help - Paul

 

I have a Netduino Plus v1 with .NET MF v4.2

 

I found out that its actually putting the Queue in there, but apparently some of the functions are timing out during debug... Very weird.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.