Home AMX User Forum NetLinx Studio

SET_VIRTUAL_PORT_COUNT ??

Hello everyone,

I just inherited a program that might have a potential bug lurking in it somewhere. As I've been going over it, I found in the DEFINE_EVENT section of the main program:
data_event[33001:1:0]
{
  online:
	{
	  set_virtual_port_count(data.device,15)
	}
}

I've never used SET_VIRTUAL_PORT_COUNT, and it isn't in the NetLinx documentation either it seems. I'm guessing by the name that it sets a port count for a virtual device, but I'm wondering why that is even needed really. Has anybody else ever used this function? Is there any benefit?

Many thanks for the help!

Comments

  • jjamesjjames Posts: 2,908
    By default I believe virtuals use up to 256 channels. If you ever needed to go above that, you would use SET_VIRTUAL_PORT_COUNT. There's been cases to where setting it was needed for the R4 - but I forget the details.

    I'm confused as to why one would set it to 15 when 256 it should work out of the box.
  • KielLKielL Posts: 34
    I'm probably going to remove it from this program since it (likely) has no benefit. Just one less thing to look at when I have to go on-site to troubleshoot.

    Thank you for the help, jjames!
  • Spire_JeffSpire_Jeff Posts: 1,917
    SET_VIRTUAL_PORT_COUNT is necessary for the processor to track channel/level states for port above 1 (According to the help file). If you remove this, it is possible that feedback and or functionality will be adversely affected.

    Here is the section the NetLinx Keywords Help file:
    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).
    
    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
    
    See Also
    
    SET_DNS_LIST
    
    SET_IP_ADDRESS
    
    SET_LENGTH_ARRAY
    
    SET_LENGTH_STRING
    SET_OUTDOOR_TEMPERATURE
    SET_PULSE_TIME
    SET_SYSTEM_NUMBER
    SET_TIMER
    
    SET_VIRTUAL_CHANNEL_COUNT
    SET_VIRTUAL_LEVEL_COUNT
    

    As you can see, there is also a SET_VIRTUAL_CHANNEL_COUNT and SET_VIRTUAL_LEVEL_COUNT. Channels default to 255 and levels to 8. I would recommend NOT removing it unless you are sure you don't need it.

    Jeff
  • jjamesjjames Posts: 2,908
    Jeff - thanks for the clarification of my bad information. I obviously got SET_VIRTUAL_CHANNEL_COUNT and SET_VIRTUAL_PORT_COUNT mixed up.

    *oops!*
  • AMXJeffAMXJeff Posts: 450
    jjames wrote: »
    Jeff - thanks for the clarification of my bad information. I obviously got SET_VIRTUAL_CHANNEL_COUNT and SET_VIRTUAL_PORT_COUNT mixed up.

    *oops!*

    I was going to say... It is not wise to remove code from a program on the grounds that you do not understand why it was there. Surfice it to say, programmers tend not to add code just to add code...
  • jjamesjjames Posts: 2,908
    AMXJeff wrote: »
    I was going to say... It is not wise to remove code from a program on the grounds that you do not understand why it was there. Surfice it to say, programmers tend not to add code just to add code...
    Agreed! Like I said, obviously got the CHANNEL & PORT mixed up and was confused why one would set it lower than the default.

    I never advised him to remove it.
  • KielLKielL Posts: 34
    Thanks for the clarification, guys!
  • viningvining Posts: 4,368
    SET_VIRTUAL_PORT_COUNT is your friend and I use it all the time. Of course using multiple ports on a single virtual number opens up other problems but if you are going above one port on the same vDev.number it's a must use item.
  • mushmush Posts: 287
    KielL wrote: »
    data_event[33001:1:0]
    {
      online:
    	{
    	  set_virtual_port_count(data.device,15)
    	}
    }
    

    Should there also be a REBUILD_EVENT() in there?
Sign In or Register to comment.