Constant to Module
jabramson
Posts: 106
Is it possible to send a constant in a module (directly in the define_module line). ]
This is what I have:
define_module 'ClearOneModule' Mic1 (dvClearOne, vdvClearOne_Mic1, nMutes[1], nGain[1], nInstance[1], cInstance[1])
This is what I would like:
define_module 'ClearOneModule' Mic1 (dvClearOne, vdvClearOne_Mic1, nMutes[1], nGain[1], 1, "'I'")
I tried this but it throws an error about constants. I'm not sure if it isn't possible or if I'm doing it wrong. Seems silly to define a variable for a module that never changes
This is what I have:
define_module 'ClearOneModule' Mic1 (dvClearOne, vdvClearOne_Mic1, nMutes[1], nGain[1], nInstance[1], cInstance[1])
This is what I would like:
define_module 'ClearOneModule' Mic1 (dvClearOne, vdvClearOne_Mic1, nMutes[1], nGain[1], 1, "'I'")
I tried this but it throws an error about constants. I'm not sure if it isn't possible or if I'm doing it wrong. Seems silly to define a variable for a module that never changes
0
Comments
I used to do this but all my modules now only pass in the real device for whatever's being controlled and a virtual device for control and messages back to the main program.
What are you wanting to pass in that has to be a constant?
I'm trying to build the module to tracj each type of fader with one set of commands. The gains and mutes are the only variable that is changed.
Defining A Module
entry on the first line of the file.
Syntax:
MODULE_NAME = '<module name>' [(<parameter list>)]
The MODULE_NAME entry identifies the file as containing a NetLinx module, as opposed to a standard NetLinx source code file. The module name is any valid string literal not to exceed 64 characters. A file can contain only one module and the file name must be the same as the module name with the addition of the ".AXS" extension.
Module parameters behave exactly like subroutine parameters; the parameter list is optional. The value for each parameter is set either by the main program or another module. If the value of a parameter is changed, both the main program and the module see the change.
Constants and expressions cannot be used as arguments in the parameter list.
Persistent variables do not work in Modules.
All parameters to a module must be on of the intrinsic types: CHAR, INTEGER, SINTEGER, LONG, SLONG, FLOAT, DOUBLE, DEV, DEVCHAN or DEVLEV. Also, any array of any of the intrinsic types can be used.
How do you get the IP address and port in there?
Send_commands to the virtual. This can go in the virtual online event, or elsewhere.
As said in the previous post: I create a command routine and send in all the vitals with commands. My commands might look like send_command vdvVirtual, 'IP_ADRESS:192.168.1.25'
I've already developed a set of routines for handling commands and just copy/paste them into any new modules I write complete with buffering and so forth.
Why do this instead of just passing values in via the module declaration?
1). There's a bit of under-the-hood overhead that gets eaten up when you pass values through that are not really necessary.
2). Values passed through at startup are not as easily changeable on the fly.
3). Passing what are essentially operating values and setup vial module declaration tends to make the modules less changeable over their lifetime. Example your old module was an rs232 only module but the new one does IP. It is much more difficult to pop the newer IP based module in your old RS232 a system without a serious rewrite. You either need to put a baud rate variable on the IP module that doesn't need to be there and/or and IP Address sting on an RS232 module that doesn't need to be there. In the command-based setup you can even put in some programming to say, " if I get an IP Adress then run the module th IP way, if a baud rate command then run the module the RS232 way. To the main program it's all the same.
I created a variable that is essentially a constant and assigned that.
Works for my needs, thanks everyone.
All valuable points, but the tradeoff is:
I can't think of a way to send all that config on startup that isn't way more code than passing in the IP.
my module section looks like
define_module 'pjMod'mldPJ1(dv1,vdv1,...ip1)
define_module 'pjMod'mldPJ1(dv2,vdv2,...ip2)
... snip ...
define_module 'pjMod'mldPJ50(dv50,vdv50,...ip50)
I'm curious how you go about defining then looking up all the values you need and sending them off to the proper module instance
Shoot, maybe I could have the list of IPs/Ports/etc in a text file that get's parsed...
Module
Main code
I was onsite today for an R3 issue and the module works fine.
Even works with multiple instances:
Our TV presets module passes variable arrays for the favorite channels (and icons), so we can use those directly in the code and the UI, but it is a separate module from the control for any particular device. That way we can do presets on every device that tunes "0123456789-." in their stations without writing that specifically into any control module. Just include a "TUNE-" command in the control module.
For this specific case, we have an "IP connector" module (as long as the protocol is the same) which will control all the needed setup for any kind of IP link, and you can chain the serial module(s) into it. (Warning to programmers who do not know about it, a module like needs to use the TRANSLATE_DEVICE() netlinx function to make the virtual act more like a normal port rather than the broadcasting/reflection normally seen with virtuals - it's a semi-undocumented voodoo command).
Then we can just do something like this first line to switch a serial module over to IP: