AXI or AXS
John Paul
Posts: 143
I usually divide each device into an include file or 'AXI' file so my workspace will have multiple include files . I was wondering if this is common practice or do you create netlinx modules (AXS) per device.
0
Comments
axs requires more coding discipline but pays off in the long run if you reuse the module a few times.
I usually start with axi and when I get to a point I turn it into an axs.
That being said I have sometimes turned axs into axi because I want to use functions and variables from the main section of code and don't want to waste too much time writing code to parse data through a virtual device or add lots of parameters to the module definition.
I have many axi files I plan on turning into axs "when I get some spare time" but there is always something better to do like watching footy or shooting imaginary baddies on a computer.
When you separate out code into an include (*.axi) this does not provide you with and data hiding or privacy. Basically external code still has full access to everything in that include, no local scope is created.
When placed within a module (*.axs) everything declared within is scoped to that module and hidden / protected from the outside world, this then also provides it with the ability to be instantiated multiple times. Common practice is to then utilize a virtual device to provide an interface for communication with external code. It is also important to remember that a module does not necessarily have to be used for device communication alone. For example, if you had the a requirement to say restart an NI once per week you could have a module that has no parameters and a couple of lines of code to perform this task. It could then be used by any system that had this requirement.
Another thing to consider is that includes can be used within modules to separate and modularize functionality further. Download RMS Enterprise SDK and have a look at the open source device monitor modules for a great example of this. They all use a set of core functionality thats handled by an include, each module then wraps this and extends it as necessary showing both the code-reuse provided by includes and encapsulation of modules.
Both includes and modules have their place and are both incredibly powerful core tools of the NetLinx language. Its just important to be aware of their differences and use the two appropriately.
Of course, there are always exceptions, especially when integrating someone else's code in a project, but that's my practice. It's more an organizational thing than functional.