Home AMX User Forum NetLinx Studio
Options

AXI or AXS

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.

Comments

  • Options
    champchamp Posts: 261
    axi is the lazier, messier and quicker one off solution.
    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.
  • Options
    PhreaKPhreaK Posts: 966
    It all depends on what your are trying to modularize / separate and the type of interaction you need with that.

    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.
  • Options
    DHawthorneDHawthorne Posts: 4,584
    I try not to put working code in AXI files. I use them strictly for variables, constants, etc., that are specific to the project. That way, the working code that resides in the modules can be stored in a global directory, and updates will propagate to any project that uses them, while the AXI files reside int he project directory itself.

    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.
Sign In or Register to comment.