Virtual device ports in module.
I was writing a Netlinx module the other day and wanted to be able to use multiple ports on the virtual device that is passed to the module. Like the Duet modules use where they pulse a channel on different ports. I know that I can pass a device array, but I'd rather not. Am I just having a brain fart or is this not possible?
Comments
-
I believe the command is something like "Set_Virtual_Port_Count" . The virtual device you are using it on needs to be online. It can be fiddly, especially if you are using "translate_device" in conjunction.
-
From NetLinx Keyword Help
SET_VIRTUAL_PORT_COUNT
Lets the programmer override the default number of ports that a virtual device maintains.By default every virtual device maintains the state of a single port (port 1).
Syntax:
SET_VIRTUAL_PORT_COUNT(DEV Device, INTEGER Count)
Parameters:
Device - the virtual device to modify.
Count - the number of ports that the specified virtual device should maintain.
Returns: None
Example:
SET_VIRTUAL_PORT_COUNT (dvVirtual,2) // 2 ports
With regards to TRANSLATE_DEVICE, set_virtual_port_count needs to be applied to the dynamic virtual device and then translate_device applied to each port on the virtual device pair.
-
By fiddly I mean timing for when you apply translate_device to the device pairs. Then you may also need to do rebuild_events depending on how you code your events. I wrote a module that could dynamically add devices based on some configuration commands to the module. I got it to work with a lot of tweaking. This was one of those "I wonder if I can get this to work" experiments. Although it was a production module that I used regularly I felt it was really edge of the envelope for what Netlinx is reasonally capable of. I will stop now before I get upset thinking about Cafe Duet support and what could have been.
-
Edge of the envelope is writing NetLinx programs with no defined devices and populating device arrays from configuration file data...
Yup - that's a thing :-)
-
Thanks guys!
-
@HARMAN_icraigie said:
Edge of the envelope is writing NetLinx programs with no defined devices and populating device arrays from configuration file data...Yup - that's a thing :-)
Yep, it's the basis of CineTouch. Same for UI, Rooms, Users, features. All defined in data... the program is the same in every system, and the panels are the same for every room in every system... data rules.
-
... the program is the same in every system, and the panels are the same for every room in every system... data rules.
I was headed that way at one point in time, but then I kinda got my enthusiasm beat out of me, and now it seems like a waste of time to work on. The time to have developed an abstract Netlinx program system was 10+ years ago. I think John and a few others rode the wave. I just drowned.
-
Depending how or where its used you might have to also rebuild_event() after the SVPC. Normally its done in define start but not always. My memories of such things are very faded.
-
rebuild_event() can be called anywhere - the key is that it only takes effect on the elements that have been manipulated within that same scope.
I settled on f-ing with the length array as that's what worked for me.
{ stack_var integer iLen; iLen = length_array(dvDevArray); set_length_array(dvDevArray, MAX_DEVS); // MAX_DEVS is theoretical max + 1 dvDevArray[iLen + 1] = 10003:1:0; iLen++; set_length_array(dvDevArray, iLen); rebuild_event(); } -
This is how I did it (in a module):
(vdvDevice is the virtual that's passed into the module)
DEFINE_DEVICE vdvCam = DYNAMIC_VIRTUAL_DEVICE DEFINE_FUNCTION fnBuildDeviceArray() { STACK_VAR INTEGER nCount SET_VIRTUAL_PORT_COUNT(vdvDevice,PORT_COUNT) SET_VIRTUAL_PORT_COUNT(vdvCam,PORT_COUNT) FOR(nCount = 1; nCount <= PORT_COUNT; nCount++) { vdvCamArray[nCount] = vdvCam.NUMBER:nCount:vdvCam.SYSTEM TRANSLATE_DEVICE(vdvDevice.NUMBER:nCount:vdvDevice.SYSTEM,vdvCam.NUMBER:nCount:vdvCam.SYSTEM) } SET_LENGTH_ARRAY(vdvCamArray,PORT_COUNT) REBUILD_EVENT() }As '@JasonS' noted, using TRANSLATE_DEVICE can be a bit tricky. Still hoping for some explanation about this, like some internal AMX document that magically appears. Hint... it's all a bit trail and error now.
-
I believe if you do your SVPC in define_start or in a function called by define start with out any wait delays you don't need to rebuild the event table because the event tables aren't yet built but if you do it anywhere else in code after the event tables are built that's when you have to use rebuilt_event() otherwise you won't get what you want.
-
@vining said:
I believe if you do your SVPC in define_start or in a function called by define start with out any wait delays you don't need to rebuild the event table because the event tables aren't yet built but if you do it anywhere else in code after the event tables are built that's when you have to use rebuilt_event() otherwise you won't get what you want.If any named element (device, channel, level, etc) referenced in an event trigger is not defined (DEFINE_DEVICE, DEFINE_CONSTANT, DEFINE_VARIABLE) the event table will not be built and REBUILD_EVENT is required.
-
Right but if you set your values in define start even though they’re not initialized with a value in define device, variable or constant you don’t need rebuild event. At least that’s my recollection but if your dynamically building arrays based on various conditions or events that are used in event tables then you do need to rebuild them each time values are changed. Most event tables for most people are static so the use of rebuild event isn’t necassary but there are times when they need to be dynamically modified during runtime in which case it is needed.
-
This channel event never happens:
(***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE volatile dev vdvTEST_3; (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START vdvTEST_3 = 33003:1:0; (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT channel_event[vdvTEST_3,0] { on: { amx_log(AMX_ERROR,"'channel_event[',itoa(channel.device.number),',',itoa(channel.channel),']'"); } }
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

