Arrays vs DEVCHANs?
vegastech
Posts: 369
How are these different when it comes to using them for button presses? They seem to look almost identical in the declarations:
DEFINE_VARIABLE DEVCHAN dcNums[] = { {dvTP,71}, {dvTP,72}, {dvTP,73}, {dvTP,74}, {dvTP,75}and then
NON_VOLATILE INTEGER nInputSelected[] = {41,42,43,44,45,46,47,48}What is the advantage to using a devchan in this situation, or is there an advantage at all?
0
Comments
The main difference is that the DEVCHAN in your example is a single device while you can combine device arrays with channel arrays for more flexible code.
The core concept behind there use is to help in the abstraction of interfaces (whether that be with a user via the TP, or via IO port to sync sensors etc) from core program logic. On a basic level say you were to have a series of devchans that you had mapped to transport controls for a bluray player via button events. Now say an addition interface device was added. To map these controls to it as well the only thing you, or whoever else may be modifying your code in the future has to do is add an additional entry to the dcPlay devchan array. If all has been written nicely anyone changing the code does need to have any knowledge of what is going on outside of this. The button will function, it's feedback will update etc.
Basically a devchan allow you to explicity list a selection of device and channel pairs you want associated with a particular behavior. On the flip side there are some situations where your code may just need to say right... I want any of these channels on any of these devices to do this, this is when you way want to look into a combination of a device array and button array. Both options are there.