DEVLEV & LEVEL_EVENT
hodeyp
Posts: 104
Hi,
I am struggling to get a LEVEL_EVENT to work for an array of levels.
Code:
DEFINE_VARIABLES
DEVLEV Scenes[]
DEFINE_START
Scenes[1] = {dvLights,1}
Scenes[2] = {dvLights,2}
Scenes[3] = {dvLights,3}
Scenes[4] = {dvLights,4}
Scenes[5] = {dvLights,5}
Scenes[6] = {dvLights,6}
DEFINE_EVENTS
LEVEL_EVENT[Scenes]
{
!!Do Something!!
}
When looking at the diagnostics I am seeing the levels change but it is not triggering the level event. Am I using this correctly?
TIA, Phil
I am struggling to get a LEVEL_EVENT to work for an array of levels.
Code:
DEFINE_VARIABLES
DEVLEV Scenes[]
DEFINE_START
Scenes[1] = {dvLights,1}
Scenes[2] = {dvLights,2}
Scenes[3] = {dvLights,3}
Scenes[4] = {dvLights,4}
Scenes[5] = {dvLights,5}
Scenes[6] = {dvLights,6}
DEFINE_EVENTS
LEVEL_EVENT[Scenes]
{
!!Do Something!!
}
When looking at the diagnostics I am seeing the levels change but it is not triggering the level event. Am I using this correctly?
TIA, Phil
0
Comments
HTH
Fred
Thanks, you were right that this was an edited cut'n'paste - I do actually have the array size set to 6.
Any other thoughts?
regs, Phil
Phil,
While Fred is correct about the length of the array being 0 unless explicitly being set to the desired length using SET_LENGTH_ARRAY(), this is not the only problem with the code segment.
You are building an event trigger table in runtime and this requires that you inform Netlinx that an event trigger list for a declared handler has been modified. In this case, once the DEVLEV array is built and the SET_LENGTH_ARRAY() command has been issued to establish the correct size of the array, you would include the REBUILD_EVENT() runtime command following them to force Netlinx to rebuild the event handler tables which would take into account the initialized DEVLEV values in your array.
In your case, since the device component is always the same, you could have used a single device specification and an integer array for your level event.
where nLightLevels is an array of integer values from 1 to 6. If you initialized the array in the DEFINE_VARIABLE section with the values 1 to 6, then REBUILD_EVENT() would not be needed. Otherwise, if initialized in DEFINE_START, you would need to rebuild the event table.
The reason I point out the latter alternative is that there are some known issues with DEVLEV and DEV array handling in level events. In particular, using arrays of DEVs or arrays of DEVLEVs in an event handler where GET_LAST() is used to determine the device/level causing the event does not work (see TechNote 486). There are workarounds -- see the TechNote for more information. Note that the problems are limited to LEVEL_EVENTS and the use of the GET_LAST() command to determine the device generating the event.
Reese
..or almost!
Got a very frustrating one here, I have combined the levels on the lighting system with levels on the touchpanel.
I have read all of the combine level notes both here and on the amx website and am certain I am doing thins as per example code. However, I am not getting levels sync'd even though they are combined...
I ahve checked on the master using show_combine and get back the follwoing...
Combines
Combined Level([33005:1:1,1],[10001:1:1,3],[5001:1:1,1])
Combined Level([33005:1:1,2],[10001:1:1,4],[5001:1:1,3])
Combined Level([33005:1:1,3],[10001:1:1,5],[5001:1:1,2])
I created the combines in the define_start section of the code as follows...
COMBINE_LEVEL(vdvLevelControl,1,tpDrawingRoom,3,dvLUTRON,1)
COMBINE_LEVEL(vdvLevelControl,2,tpDrawingRoom,4,dvLUTRON,3)
COMBINE_LEVEL(vdvLevelControl,3,tpDrawingRoom,5,dvLUTRON,2)
I have a single LEVEL_EVENT as per the below post.
Now for the funny bit, if I select a level on the touchpanel all works as expected, lights change to reflect selected scene.
I have also built a DATA_EVENT that receives status from the rs232 unit and parses it into current levels (for when lights are switched on from the light switch instead of the touchpanel)
The DATA_EVENT has a SEND_LEVEL to the dvLUTRON [5001:1:1] and when I check the device status I can see that the correct level has been set in this device. However, this is not then passed back to the touchpanel.
Am I using levels correctly??
Regards
Phil
Am I missing the point here? I thought by combining levels they would 'act as one' and a level change on any of them would cause the level to change on the others and any corresponding LEVEL_EVENTS to be called...
In practice, the direction is important. Real device levels are synced on all devices in the COMBINE_LEVEL statement, but the programmers way to send a level is to send it to the virtual level.
In many cases, real and virtual devices are handled differently by Netlinx, and this is one of the cases.
Fred