Virtual device ports in module.
Danny Campbell
Posts: 311
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?
0
Comments
From NetLinx Keyword Help
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.
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!
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.
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.
This is how I did it (in a module):
(vdvDevice is the virtual that's passed into the module)
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.
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: