Home AMX User Forum NetLinx Studio

Module Instance

Is there any thing that can be done to make known a particular instance of a module in code?
This would be for debugging pusposes. I use the same variable names for a lot of things in all my modules and I would like to know which module was sending info to the console without putting in a bunch of specific code. Something like send_string 0, "INSTANCE.NAME" would be great.

Comments

  • Nothing built in that I can think of, but wouldn't it be easy enough to include a string variable in a module, add some code that lets you assign it from the hosting program via SEND_COMMAND at initialization time, then just include that variable with your debug messages?

    - Chip
  • Is there any thing that can be done to make known a particular instance of a module in code?
    This would be for debugging pusposes. I use the same variable names for a lot of things in all my modules and I would like to know which module was sending info to the console without putting in a bunch of specific code. Something like send_string 0, "INSTANCE.NAME" would be great.

    Pass each module a name through its header; include in each module a function called Debug which prepends that name to your string to send.
  • Thanks all. I was looking for a one keyword solution, but these will do.
  • DHawthorneDHawthorne Posts: 4,584
    Unfortunately, the built-in debugger's watch list doesn't work properly with multiple instances of a module. It asks you which instance you want to track the variable in (often giving you choice that don't make any sense), and if you want to track the same variable in two instances, you only get one of them. I've done tow things to overcome this: (1) as mentioned, use SEND_STRING 0 and identify the module instance in that, or (2) temporarily comment one module declaration out, troubleshoot it, then enable the other when it's all straight.
  • DarksideDarkside Posts: 345
    This 'issue' came up for me a while ago when coding for 8 projectors in one training area. I tricked up my module up to include a parameter called 'vp_loc' (vp_location).

    This allowed me to insert a room number into each module instance therefore each one effectively becomes discrete in the way it reported using send_string 0.

    This is all obviously a 'no brainer' if the module is your own as you can modify it at will, but for modules by others, it's a bit more difficult.

    My two bobs worth
  • Joe HebertJoe Hebert Posts: 2,159
    One keyword solution
    Something like send_string 0, "INSTANCE.NAME" would be great.
    If you had something like this:
    MODULE_NAME='RuncoComm' (DEV vdvDisplay, DEV dvDisplay)

    You could do something like this:
    SEND_STRING 0, "'Hello From: ',ITOA(vdvDisplay.NUMBER)"

    Or if you want to deal with a real device with multiple systems you have these at your disposal also:
    dvDisplay.PORT
    dvDisplay.SYSTEM

    I?ve used this approach in the past and I think it?s as close to an INSTANCE_NAME that you can get without having to add code.
  • This is perfect.
  • yuriyuri Posts: 861
    lol, nice reply :D
    ontopic, the DEVICE.PORT doesnt really work well if you define your virtuals like i do:
    vdvProjector = 33001:1:1 ;)
  • Joe HebertJoe Hebert Posts: 2,159
    yuri wrote:
    the DEVICE.PORT doesnt really work well if you define your virtuals like i do:
    vdvProjector = 33001:1:1 ;)
    That?s why I used DEVICE.NUMBER in my example for a virtual device. DEVICE.PORT would be useful if you wanted to track an NI based real device
  • DHawthorneDHawthorne Posts: 4,584
    Joe Hebert wrote:
    That?s why I used DEVICE.NUMBER in my example for a virtual device. DEVICE.PORT would be useful if you wanted to track an NI based real device

    I take it a step further and put the whole D:P:S in. I made a quick function to make it a string:
    DEFINE_FUNCTION CHAR[20] sDevToString (DEV dvDev)
    {
        RETURN "ITOA(dvDev.NUMBER), ':', ITOA(dvDev.PORT), ':', ITOA(dvDev.SYSTEM)" ;
    }
    
    When communicating between masters on a multi-master system, I like to make my virtual devices the same on all the masters, so I need to have the system number to tell them apart.
Sign In or Register to comment.