PapcoDoc/documents/moduleTutorial
From PapcoWiki
Purpose: a tutorial for creating a module for papco 12
What's new in papco 12
A main focus of PaPCo 12 is to reduce the amount of code needed by modules to provide complex functionality. Many of the modules contained "boiler plate" code that was redundant and made modules harder to understand and correct when bugs appear. The goal is to provide libraries and templates that make developing a module quickly easy, and to have modules that are more science and less overhead.
New facilities include:
- datasets. A convention for storing data and metadata, and codes for producing and operating on them.
- data caching. RAM cache keeps datasets in memory to speed things up and give more control to the end user.
- file caching (also in papco 11). Manages how files are stored, and retrieves data from remote to local file stores.
- papco12 slicers. The slicer interface is extended so that new functionality is provided, such as thumbnail slice series.
- properties sets. Provide widget controls without the burden of having to code them.
- improvements to "make new module."
make new module
Previous versions of papco had a "make new module" script that would take the template module "plot_type" and systematically change the name. This new code would be a working module that would be hacked to provide the desired functionality of the new module.
PaPCo 12 introduces a number of changes to this procedure. First, there have been a number of changes to the plot_type template. It utilizes papco12 facilities to greatly reduce the amount of code. A working file cache is added to encourage automatic data distribution. This file cache gets dummy data from http://www.papco.org. Slicing is included, and the dummy dataset has high dimensionality.
Second, make new module is now accessible from the papco main widget, and a dialog controls how the module is created. Any module can be used as a template, so a developer can have a set of his or her own templates. The script that does the code renaming preserving case and labels, so PLOT_TYPE is converted to MY_MODULE and "Plot Type" is converted to "My Module."
PaPCo 12 can link in a new module without restarting papco, and the new module is linked in after creating it. This introduces a couple of new work modes. Of course, for developing new modules this is convenient. But this also allows the end user to do a quick hack of a working module without affecting the working code.

