define a device as a variable
nastables
Junior Member
Is it possible? if so how?, I have perused the manuals etc and dont find a good reference and help appreciated
Comments
-
It would help to know what you're trying to accomplish, but...
DEFINE_VARIABLE DEV TPVar = 10001:1:0
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:DEV TP[] = {TP1,TP2}
- Chip -
thanks! I think i get the gist
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).nastables wrote: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. -
Be careful.
Caution!Chip Moody wrote:It would help to know what you're trying to accomplish, but...DEFINE_VARIABLE DEV TPVar = 10001:1:0
Works just as well as putting it in DEFINE_DEVICE.
- Chip
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 DATA_EVENT[TPVar] { ONLINE: { // any code put here will not run } } -
B_Clements wrote:Caution!
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. -
Sorry for the typo.
If it is not a real device, the code won't run. -
I must have misunderstood what you meant when you said it had to be an array. I assumed these were real devices that were in question. Nevermind...
-
If you define a device as a device, and never connect it to the system, you won't get a DATA_EVENT either.

I think I'm a little tired and just missing something here. Help?
- Chip -
Chip Moody wrote:If you define a device as a device, and never connect it to the system, you won't get a DATA_EVENT either.

I think I'm a little tired and just missing something here. Help?
- Chip
Never mind, Chip. -
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 virtual arrays in events
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 -
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. -
Spirits...
Hmm... my array of virtual devices in the LEVEL_EVENT seems to work today. Sometimes it's better just not to ask questions...
Pat
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums