Home AMX User Forum NetLinx Studio

Virtual device (Newbie question)

Hi

I would like to know when is preferable to use virtual device. All the time or just when we use a third party unit

Tanks in advance

Comments

  • annuelloannuello Posts: 294
    Virtual devices

    Hello Denis,

    I tend to use virtual devices when I want either of the following:
    1. Interchangable hardware of different makes & models (e.g. data projectors)
    2. Easier modelling of code.

    I often use virtual devices hand-in-hand with modules, creating the behavior of the virtual device inside the module.

    When writing modules to control data projectors, my mainline code simply sends strings to the virtual_device using easy-to-read commands. E.g. "On", "Input 1", "Blank", etc. My virtual_device then acts on that string to send the appropriate string to the projector, taking into account the warmup times, etc of the projector. If a projector dies, I can replace it with a different type, recompile with a module for the new type, and away we go. The mainline is still sending the same strings to the virtual device. The new virtual device understands them and interprets the action as appropriatly.

    Virtual devices can also be useful for state tracking of equipment. You can set channels ON & OFF for the virtual device, which your mainline can then act on.

    Depending on your situation, a third party device may not be required to justify a virtual_device. An example would be an small neural network. A neural network models behavior, not necessarily something physical. A virtual device could be used to model the whole AI part of your code. I guess that would make it easy to disable if it got out of control! :)

    Yours,
    Roger McLean
  • DHawthorneDHawthorne Posts: 4,584
    I've adopted the paradigm AMX uses with their modules: a comm module for the actual device, a UI module for the interface, and a virtual device for talking between the two. Since NetLinx modules don't allow access to internal functions from the outside the module, passing messages with the virtual is the cleanest way to accomplish the same thing without breaking the modularity of it.
Sign In or Register to comment.