Virtual device (Newbie question)
Denis
Posts: 163
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
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
0
Comments
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