Home AMX User Forum NetLinx Studio

Specifying M2M system number at run time?

Hello,

I'm trying to make a master-to-master system where I send commands to a virtual device on the remote system. Usually this is a straight-forward process. However, I need to specify the remote system number at run time rather than compile time. *The same code will be deployed into several installations which all report to one RMS server, hence the need for unique system numbers, and my desire to avoid code changes & recompiling for every installation.
*
I'm hoping that I can specify the remote system number in an XML file (or persistent variable) and use that value. *Once the remote system number has been set up I don't expect/need it to change. Obviously I will still need to enter the remote system IP into the URL list for each installation.

I've been trying to figure this out for the last few days but with no success.

Yours,
Roger McLean
Swinburne University*

**

Comments

  • AuserAuser Posts: 506
    Am I missing something here? As far as I'm aware based on your description, what you're trying to do is as simple as...
    // Get system number from file, however you may want to implement it...
    nSystemNumber = SystemNumber_GetFromFile(sFileName)
    
    // Check that the controller has the right system number and update it if not...
    if(nSystemNumber <> get_system_number()
    {
      set_system_number(nSystemNumber)
      reboot(0)
    }
    
    
  • annuelloannuello Posts: 294
    Auser wrote: »
    Am I missing something here? As far as I'm aware based on your description, what you're trying to do is as simple as...
    Thanks for your quick reply. To clarify, I'm not trying to change the system number. I'm trying to avoid specifying in code. Perhap an example would make my idea clearer.
    //Typical M2M setup.  Assume this is running on a system other than 123. 
    define_device
    vdvLocalDevice = 33001:1:0
    vdvRemoteDevice = 33001:1:123. //N.B. The system number is hard coded.
    
    What I want to avoid is the hard-coding (compile time) of the vdvRemoteDevice system number. (123 in the above example.). I want to be able to specify the vdvRemoteDevice system number at run time. That way I can deploy this same code into many installations without having to modify the source for each and every installation.

    I've tried using a dev variable (array with one element) which I can easily "fill out" at run time. However the device on the remote system does not respond when I send_command vdvRemoteDevice. I've tried using set_length_array() and rebuild_event() after setting up my dev variable, but that didn't seem to help. The IP for system 123 is in the URL list for the local system only, and system 123 shows up in the Online Tree when I choose the Show Network option.

    Roger McLean
    Swinburne University
  • AuserAuser Posts: 506
    Aha, with you now. You've tried most of the things I can immediately think of to suggest, but I would suggest taking things back to first principles. Personally, I'd check that you get the expected functionality with vdvRemoteDevice specified in a define_device section and then try specifying vdvRemoteDevice as a non array dev variable. If these work, try using your dev array and targeting your send_command at vdvRemoteDevice[1]. If that works, it would be likely that your set_length_array statement isn't being called or is being called inappropriately.
  • kbeattyAMXkbeattyAMX Posts: 358
    I think that DEFINE_DEVICE is not a runtime event. Try defining a DEV variable. Then you can reassign the variable the system number during runtime device.system = 123. Not sure if device needs to be in DEFINE DEVICE to connected to remote master.
  • Spire_JeffSpire_Jeff Posts: 1,917
    I think the problem you might be having is related to how the processors deal with devices. In order to generate events and track channel/level states, the processor needs to know that the device exists. (I'm not positive on the events, but I know that it won't track channels/levels if the device is not defined.) There might be a way to tell the processor to do this on the fly (I think there is a RELOAD_something command to regenerate event tables or something). I haven't played around much with this, but I have been dabbling with more M2M comms on a larger scale and I have to define shared devices on both processors for things to function.

    I will try to find that reload command if I get a moment, but hopefully someone with more knowledge on the subject will post before then with more specific data.

    Jeff
  • DHawthorneDHawthorne Posts: 4,584
    I would try this:

    1. Create a virtual device for your actual control.
    2. Assign your remote device in a variable ... it could even read a config file at this point.
    3. Combine the variable with the virtual.

    You would have to make sure to also run the various SET_VIRTUAL_ commands if it has more than the default number of devices/levels/etc.
  • annuelloannuello Posts: 294
    Thank you all for your helpful replies. I tried them all, and the one that worked was Dave Hawthorne's solution. Here is an example of how to do it.
    define_device
    vdvLocal = 33001:1:0
    vdvRemote = 33002:1:0  //N.B. This is on our local master
    
    define_variable
    dev vdvVariableRemote  //This variable will get set to vdvLocal on the remote master.
    
    define_function LoadRemoteSystemFromFile(){
     integer iRemoteSystem
     ...
     if(iRemoteSystem != get_system_number()){  //just a saftey check
      vdvVariableRemote = vdvLocal
      vdvVariableRemote.system = iRemoteSystem
      combine_devices(vdvRemote, vdvVariableRemote)
     }
    }
    
    define_event
    button_event[dvTp,someButton]{
     push:{
      send_command vdvRemote,'blah blah blah'  //The vdvLocal on the remote system receives this.
     }
    }
    

    Thanks to all for your suggestions, and a double thanks to Dave. :)

    Roger McLean
    Swinburne University
Sign In or Register to comment.