define a device as a variable
[Deleted User]
Posts: 0
Is it possible? if so how?, I have perused the manuals etc and dont find a good reference and help appreciated
0
Comments
Works just as well as putting it in DEFINE_DEVICE.
If you have TP1 and TP2 declared in the normal way, you can reference them both through a single variable by doing this:
- Chip
I was trying to just use one page to operate all the Ir devices I had as they all used the same button interface.
I worked it round by creating a variable called 'IRdeck' then allowing the push_channel to assign the value
finally sending command [IRDECK,play] ect where play is a constant.
it seems to work but if there is a better way to do please let me know let me know.
Caution!
If you define a device as a variable and it is not an array of actual devices a Data_Event will not occur.
Assuming you mistyped and meant this: ..the code will indeed run assuming you have a TP addressed at 10001.
If it is not a real device, the code won't run.
I think I'm a little tired and just missing something here. Help?
- Chip
Never mind, Chip.
DEFINE_VARIABLE
DEV TPVar = 10001:1:0
and this appears to work fine for data events (i do prefix it with 'volatile') .
it fact, what i've been working on is this..
DEFINE_CONSTANT
integer MAXPANELS = 32
DEFINE_VARIABLE
volatile DEV AllPanels[MAXPANELS]
then, i can add/remove panels/devices to the array.
here's an example
if(length_array(AllPanels)<MAXPANELS)
{
set_length_array(AllPanels,length_array(AllPanels)+1)
AllPanels[length_array(AllPanels)].device = 150
AllPanels[length_array(AllPanels)].port = 1
AllPanels[length_array(AllPanels)].system = 0
rebuild_event()
}
once the rebuild_event() has run, the panel with create an online event and away you go.
i know there are other ways to do this. i've described this as an example. there is a method to my madness here. it's to create a 'soft' type of system, that doesn't know/care what gets connected to it. i actually begin with one huge array containing all possible device addresses (well, most of the expected ones). when a device comes online from my main array list, depending on the type, it will get shuffled over to an appropriate array (panels/dms/controllers).
I assume the issue Brian mentioned with virtual device arrays in DATA_EVENTS holds for other event types (i.e. LEVEL_EVENTS) like the following:
<code>
DEFINE_DEVICE
vdvDEV1 = 34000:1:0
vdvDEV2 = 34001:1:0
DEFINE_VARIABLE
DEV vdvARRAY[] = {vdvDEV1,vdvDEV2}
LEVEL_EVENT[vdvARRAY,1]
{
// Nothing here executes
}
</code>
This would explain some 'problems' I had just today
Pat
What I believe the difference to be is that devices in DEFINE_DEVICE are run through an internal constructor, and those in DEFINE_VARIABLE are not - in Java or C++ parlance, the difference is between using the "new" keyword (DEFINE_DEVICE) and simply allocating memory space (DEFINE_VARIABLE). That would be the reason there even is a DEFINE_DEVICE section rather than simply tossing it all into DEFINE_VARIABLE.
Hmm... my array of virtual devices in the LEVEL_EVENT seems to work today. Sometimes it's better just not to ask questions...
Pat