Resources usage
#1
Posted 12 August 2012 - 11:34 PM
#2
Posted 13 August 2012 - 04:33 PM
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.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?
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
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