Home AMX User Forum NetLinx Studio

Connection of levels

Hello all, i have another pair of questions about programming in NetLinx :)
I'm trying to use DEFINE_CONNECT_LEVEL to connect bargraph in the panel, which has level number 8, and dimmer 6 of lighting system. So, i write in my program something like this:
(*begin cut*)
dvLTS   = 2:1:0 //Radia Lighting system
char bright_current //current level of brightness

CREATE_LEVEL dvLTS,6,bright_current
//                              ^^^^^^^^^
CREATE_LEVEL TP,8,bright_current
//                         ^^^^^^^^^
//                          is this correct?
(*end cut*)
In this example i can regulate light with help of bargraph, but light level changes do not affect bargraph level (i.e., when i do SEND_LEVEL to a lighting system, what changes brightness of light, nothing happens to bargraph position). Do i need to add code like this (as i did to make light changes visible at bargraph):
SEND_LEVEL TP,8,bright_current
Btw, syntax of DEFINE_CONNECT_LEVEL is described differently in different documents - i.e., should i use "virtual" device-level structure as the first argument, or not? And how?
Sorry for my english.


  • Options
    Connection of levels

    If the devices and levels you wish to connect are static and do not change during the course of your program, then DEFINE_CONNECT_LEVEL will work fine. You need to define a virtual device and then use that device and a level on it as the first argument to the connect. You can choose whatever level on the virtual device you want to use and in fact you can create level connections on numerous levels on a virtual device (see caveat below). Netlinx requires a virtual device as the device used to connect all of the physical devices and even other virtual device levels.

    If the devices and levels you wish to connect are subject to change during the course of the program and hence dynamic, you can use COMBINE_LEVELS and UNCOMBINE_LEVELS to create and destroy connections. This is only needed if the devices and/or levels that are connected need to change at runtime. These runtime directives also require a virtual device as the first argument since that is the device used to connect all of the devices and levels that follow.

    On a side note, virtual devices have by default 8 levels. If you define a virtual device and intend to use it for a number of level connects, if you exceed the use of 8 levels on the device, be sure to specify the highest level you intend to use with SET_VIRTUAL_LEVEL_COUNT.

    Lastly, the LEVEL_EVENT you specified in your code sample (to make your sample work) is not needed once you have connected the levels successfully. A change to the lighting control level will automatically update the level on the touchpanel which is precisely what you want to happen. The level event is not needed at that point.

  • Options
    Can you, please, post a little example? Or where can i get it?
  • Options
    Connection of levels [Example]

    Here is an example using level connects between a touchpanel level (display only) and a level on an NXC-VOL4 volume control card. The VOL4 card is a 4-channel volume control card (4 mono channels or 2 stereo channel pairs) and is a 2-port device. Each port has 2 levels - one for each of the mono channels. In my example, I deal with channel pairs since I use them for stereo volume control and hence I only monitor one of the levels on each device/port combination as the volume on the VOL4 is always ramped in such a way that the channels maintain the same volume value within a stereo channel pair. I do not use an active bargraph in this example since only a mono channel would be ramped as a result. This is really for example only.

    Note, I defined a virtual device to be used specifically for connecting the levels. I have 24 audio zones in the example so I need 24 levels on the virtual device. Since each VOL4 card can handle 2 stereo zones, 12 VOL4 cards are needed to handle all of the audio zones. The DEFINE_DEVICE section has declarations for these 24 device/port combinations.
    (* Virtual device used for level connects *)
    vdvVolume = 33001:1:0
    (* NXC-VOL4 devices used for volume control *)
    dvVol4_1   = 301:1:0
    dvVol4_2   = 301:2:0
    dvVol4_3   = 302:1:0
    dvVol4_4   = 302:2:0
    dvVol4_5   = 303:1:0
    dvVol4_6   = 303:2:0
    dvVol4_7   = 304:1:0
    dvVol4_8   = 304:2:0
    dvVol4_9   = 305:1:0
    dvVol4_10  = 305:2:0
    dvVol4_11  = 306:1:0
    dvVol4_12  = 306:2:0
    dvVol4_13  = 307:1:0
    dvVol4_14  = 307:2:0
    dvVol4_15  = 308:1:0
    dvVol4_16  = 308:2:0
    dvVol4_17  = 309:1:0
    dvVol4_18  = 309:2:0
    dvVol4_19  = 310:1:0
    dvVol4_20  = 310:2:0
    dvVol4_21  = 311:1:0
    dvVol4_22  = 311:2:0
    dvVol4_23  = 312:1:0
    dvVol4_24  = 312:2:0
    (* Touchpanel used for volume control *)
    dvTP_Volume = 10001:5:0
    (* Loop index for DEFINE_START *)
     * Array of device/levels for the VOL4 cards to create the level
     * connections to the touchpanel and the virtual level device.
    VOLATILE DEVLEV dvlVolume[] =
      { dvVol4_1, 1 },  { dvVol4_2, 1 },   { dvVol4_3, 1 },
      { dvVol4_4, 1 },  { dvVol4_5, 1 },   { dvVol4_6, 1 },
      { dvVol4_7, 1 },  { dvVol4_8, 1 },   { dvVol4_9, 1 },
      { dvVol4_10, 1 }, { dvVol4_11, 1 }, { dvVol4_12, 1 },
      { dvVol4_13, 1 }, { dvVol4_14, 1 }, { dvVol4_15, 1 },
      { dvVol4_16, 1 }, { dvVol4_17, 1 }, { dvVol4_18, 1 },
      { dvVol4_19, 1 }, { dvVol4_20, 1 }, { dvVol4_21, 1 },
      { dvVol4_22, 1 }, { dvVol4_23, 1 }, { dvVol4_24, 1 }
    (* Set virtual device level count since more than 8 levels required *)
    SET_VIRTUAL_LEVEL_COUNT(vdvVolume, 24)
    (* Connect the touchpanel and VOL4 audio zone levels *)
    FOR(nZone=1; nZone <= LENGTH_ARRAY(dvlVolume); nZone++)
      (* Combine levels - vdvVolume,1,TP,1,Vol4,1 ...... *)
      COMBINE_LEVELS(vdvVolume,nZone,      // virtual device/level
                     dvTP_Volume,nZone,   // touchpanel level
                     dvlVolume[nZone])    // VOL4 audio zone level
    The VOL4 device/level combinations are then placed into an array of DEVLEVs merely as a convenience for doing the level combines in DEFINE_START. The virtual device level count is set to 24 since that is the number of levels needed - one for each of the audio zones. Remember that by default a virtual device only has 8 levels defined for it. The COMBINE_LEVELS is then used inside a FOR loop to create the connects. The loop is executed 24 times and on each iteration creates the next virtual device level connect between the touchpanel (levels 1-24) and the corresponding VOL4 volume level.

    Whenever a VOL4 volume level changes, the corresponding level on the touchpanel will automatically change. Since the bargraph is display only in my example, you would not be able to use the touchpanel bargraph to raise/lower the volume and watch the VOL4 track the changes. However, the code example could be easily modified to support an active bargraph such that when the bargraph is manipulated, the resulting level change would cause the volume for the corresponding audio zone to also change. This would actually require code in the VOL4 volume handling module to ensure that volume changes to one of the channels in a stereo pair is automatically reflected to the other channel as well (easily handled in a LEVEL_EVENT for the VOL4 channel level that is connected to the touchpanel level). Note however that no events are required in this example to have the touchpanel level follow the audio zone level which was your objective in your original post (granted it was lighting versus audio levels).

    Hope this helps --

Sign In or Register to comment.