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.
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.
That's pretty much how I do it as a matter of course for simple IR devices, and I have been doing it since Axcess days: create a device variable, assign whatever you are controlling to it, then send all your IR pulse references to the variable rather than the actual device. This makes it possible to share button channels across devices (handy for G3 panels with limited channels), and makes it easier to use that panel to control multiple rooms (make your device variable an array, and use the room number for an index, then you can reference the controlled device per room and the panel won't lose track when you change rooms).
If you define a device as a variable and it is not an array of actual devices a Data_Event will not occur.
DEFINE_VARIABLE
DEV TPVar = 10001:1:0
DEFINE_EVENT[TPVar]
{
ONLINE:
{
// any code put here will not run
}
}
Assuming you mistyped and meant this:
DEFINE_VARIABLE
DEV TPVar = 10001:1:0
DEFINE_EVENT
DATA_EVENT[TPVar]
{
ONLINE:
{
// any code put here [b]will[/b] run here
WAIT 300 SEND_STRING 0, 'hello'
}
}
..the code will indeed run assuming you have a TP addressed at 10001.
i've being using a similiar bit of coding as the example..
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).
No, the issue Brain mentioned only applies to devices that were only defined as DEV variables in the DEFINE_VARIABLE section. Those defined in DEFINE_DEVICE are not affected. I just slapped a quick load on my test master to verify this, and I do in fact get level events from a virtual defined in DEFINE_DEVICE. You have a different problem, I'm afraid, Pat. Even when two virts are stacked in an array, I get LEVEL_EVENTS from the array event table.
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.
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