DATA_EVENT ONLINE: and DEV Arrays
TurnipTruck
Posts: 1,485
Greetings,
I have a system with ten of the same serial devices connected to ten serial ports in a Netlinx based system. All of the devices are in a DEV array. Is there a way to do a DATA_EVENT ONLINE: for all ten devices in a single online event for the DEV? I need to SET_BAUD for all ten ports and I like my code short.
Thanks!
I have a system with ten of the same serial devices connected to ten serial ports in a Netlinx based system. All of the devices are in a DEV array. Is there a way to do a DATA_EVENT ONLINE: for all ten devices in a single online event for the DEV? I need to SET_BAUD for all ten ports and I like my code short.
Thanks!
0
Comments
Dave is absolutely correct with respect to GET_LAST() use in events with device arrays with one exception. Do not use GET_LAST() on DEV or DEVLEV arrays in a LEVEL_EVENT - it will not work correctly. You can use GET_LAST() on only the integer LEVEL in a LEVEL_EVENT but GET_LAST() does not work correctly on the DEV or combined DEVLEV components. This has been a problem for a long time and does not appear to be likely to be fixed anytime soon.
From there, all your individual device references will be dvDevArray[iDevIdx], and your button press channels iButnArray[iButnIdx] (though I usually leave my references relative, except for feeback, and just work with iButnIdx directly).
Dave,
I generally do the same thing - separate arrays for the DEVs and for the Channels, Levels, etc. Occasionally I will use a DEVCHAN or DEVLEV array but generally only for relays or contacts. The wierd thing about the LEVEL_EVENT bug is that it affects the DEV component of the event regardless of whether a DEV array is used in conjunction with explicit levels or an array of levels or a DEVLEV array is used instead. Avoiding the use of the DEVLEV does not solve the problem.
At first, when I experienced the problem, I was using a DEVLEV array and thought separating the devices and levels into their own arrays would solve the problem. The GET_LAST() on the level works fine but the GET_LAST() on the DEV or DEVLEV component will almost always yield the wrong device. I say almost since GET_LAST() will sometimes return a non-zero value but it will be the last DEV that triggered a Button, Channel, or Data event for that same DEV array. Before I tracked this down, a couple of programs had some very interesting results to say the least. Tech Note 486 has all of the details for anyone that is interested.
Reese
In a program that I just finished, I have ten serial devices in a DEV array. I am using GET_LAST from their DEV array to determine which device a string came from and then place it in the correct message array location. It seems to work fine.
Thanks!
The GET_LAST() problem on DEV and DEVLEV arrays only occurs with LEVEL_EVENTs. See AMX Tech Note 486 for more information. Use of DEV or DEVCHAN arrays with other event types works fine.