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

Resources usage


  • Please log in to reply
2 replies to this topic

#1 Novice Alex

Novice Alex

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts

Posted 12 August 2012 - 11:34 PM

Hi Guys, I am in a project to monitor some flow meters at the same time doing some remote monitoring. In my project, I have a class object for flow meters which is controlled and monitored by the main program loop that will send back current flow meters pulse counters on every 5 seconds. The question is which of the following method require more resource from N+? 1. On timer (5 seconds) interrupt in the each of flow meter object, I will raise a NewData event (passing back the current flow meter pulse counter) for my main program to handle them separately. 2. On timer (5 seconds) interrupt in my main program, i will called the public property in each flow meter to get the current flow meter pulse counter. Then handle them accordingly. Generally, just wonder is it better to use raise event method or pull method? Thanks in advance. Regards, Novice Alex

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 August 2012 - 04:33 PM

Hi Alex,

The question is which of the following method require more resource from N+?
1. On timer (5 seconds) interrupt in the each of flow meter object, I will raise a NewData event (passing back the current flow meter pulse counter) for my main program to handle them separately.
2. On timer (5 seconds) interrupt in my main program, i will called the public property in each flow meter to get the current flow meter pulse counter. Then handle them accordingly.

Generally, just wonder is it better to use raise event method or pull method?

They're both valid approaches and consume roughly the same number of MCU cycles. Threads are lightweight so I would go with option #1 purely because it simplifies your code. In effect, you just become a consumer of NewData...and as the way that that data is gathered changes your main code can stay the same.

If there's additional logic to your operation (such as needing to always read flow measurements in a certain order) then #2 becomes a good option.

Chris

#3 Novice Alex

Novice Alex

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts

Posted 13 August 2012 - 11:52 PM

Hi Alex,


They're both valid approaches and consume roughly the same number of MCU cycles. Threads are lightweight so I would go with option #1 purely because it simplifies your code. In effect, you just become a consumer of NewData...and as the way that that data is gathered changes your main code can stay the same.

If there's additional logic to your operation (such as needing to always read flow measurements in a certain order) then #2 becomes a good option.

Chris


Hi Chris,

Well noted.




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.