0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 1 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 2 As of Version 2.4, LTPDA now supports extension modules. This should allow
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 3 users to extend LTPDA to provide more specific functionalities for their own
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 4 context.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 5 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 6 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 7 <ul>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 8 <li><a href="#whatis">What is an Extension Module?</a></li>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 9 <li><a href="#building">Building your own Extension Module</a></li>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 10 <li><a href="#installing">Installing Extension Modules</a></li>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 11 <li><a href="#newmethods">Adding New Methods</a></li>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 12 <li><a href="#userclasses">New User Classes</a></li>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 13 <li><a href="#unittests">Unit Tests</a></li>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 14 </ul>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 15 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 16 <br><br>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 17 <h2><a name="whatis">What is an Extension Module?</a></h2>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 18 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 19 Extension modules are a collection of class methods, new user classes, built-in models,
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 20 utility functions, examples, source files, and unit tests. All extension modules have the
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 21 following structure on disk:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 22 <pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 23 My_Module/
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 24 |-- README.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 25 |-- classes
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 26 | |-- README_classes.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 27 |-- examples
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 28 |-- functions
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 29 | |-- README_functions.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 30 |-- jar
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 31 | |-- README_jar.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 32 |-- models
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 33 | |-- README_models.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 34 |-- moduleinfo.xml
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 35 |-- pipelines
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 36 | |-- README_pipelines.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 37 |-- tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 38 |-- README_tests.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 39 |-- classes
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 40 | |-- README_class_tests.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 41 |-- models
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 42 |-- README_model_tests.txt
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 43 </pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 44 The file <tt>moduleinfo.xml</tt> contains the name and version of the module. It is
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 45 not necessary that the module name and the containing directory are the same, though
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 46 they may be. To build an extension module, see Section <a href="#building">Building your own Extension Module</a>. The various
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 47 directories and their uses are described in the following sections.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 48 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 49
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 50 <h3>classes</h3>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 51 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 52 The <tt>classes</tt> directory can contain either new LTPDA user classes (see Section <a href="#userclasses">New User Classes</a>)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 53 or by adding methods to existing LTPDA user classes (see Section <a href="#newmethods">Adding New Methods</a>).
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 54 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 55
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 56 <h3>examples</h3>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 57 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 58 The <tt>examples</tt> directory is meant to contain useful examples for users.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 59 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 60
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 61 <h3>jar</h3>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 62 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 63 Since MATLAB is built on top of java, one useful way to extend the functionalities is to create java classes and methods, or even
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 64 graphical user interfaces. The LTPDA startup script (<tt>ltpda_startup</tt>) will take care of properly installing any jar files (java archive files)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 65 contained within this directory.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 66 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 67
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 68 <h3>models</h3>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 69 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 70 Here you should place any built-in models, either for existing LTPDA user classes, or for new user classes defined in this module. The LTPDA
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 71 built-in model framework looks in this directory (and any sub-directories) for built-in models.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 72 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 73
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 74 <h3>pipelines</h3>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 75 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 76 This directory is meant to hold any LTPDA pipelines or analysis workflows which you want to distribute to users.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 77 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 78
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 79 <h3>tests</h3>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 80 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 81 The <tt>tests</tt> directory should contain unit-tests for all new class methods, user classes and built-in models in this module. For help in writing
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 82 unit tests see Section <a href="#unittests">Unit Tests</a>.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 83 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 84
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 85
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 86 <br><br>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 87 <h2><a name="building">Building your own Extension Module</a></h2>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 88
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 89 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 90 Building your own extension modules starts by preparing the directory structure on disk. For this
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 91 we have a convenient utility method:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 92 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 93 <div class="fragment"><pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 94 >> utils.modules.buildModule(<span class="string">'/some/path/'</span>, <span class="string">'My_Module'</span>)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 95 </pre></div>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 96
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 97 <br><br>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 98 <h2><a name="installing">Installing Extension Modules</a></h2>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 99 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 100 Installing an LTPDA Extension Module is straightforward. Start the LTPDA Preferences:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 101 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 102 <div class="fragment"><pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 103 >> LTPDAprefs
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 104 </pre></div>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 105 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 106 Select the 'Extensions' tab. Click the 'Browse' button to locate the module directory on disk, or directly type the path to the module in the input text field.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 107 Click the 'plus' button to add this extension to the list. You should see some activity on the MATLAB terminal as LTPDA will start installing any
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 108 extension methods for existing user classes. Removing an extension module is just a case of selecting the module in the list and clicking the 'minus'
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 109 button.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 110 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 111 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 112 <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 113 <tr width="90%">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 114 <td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 115 Note: after installing an extension module, in order to make new methods available to the workbench, you need to rebuild the
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 116 library from the workbench menu: "Tools -> Rebuild LTPDA Library". This will take a couple of minutes, but afterwards
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 117 the new methods from the extension module should be available on the workbench.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 118 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 119 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 120 </table>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 121 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 122
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 123 <br><br>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 124 <h2><a name="newmethods">Adding New Methods</a></h2>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 125 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 126 New methods can be added to existing LTPDA user classes. For example, you can add a new method to the Analysis Object class (<tt>ao</tt>)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 127 by creating a sub-directory of the <tt>classes</tt> directory called <tt>ao</tt> then put your new method in there. For example, suppose
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 128 we want to create a new AO method called <tt>myCalibration</tt>. We create a directory <tt>ao</tt> in <tt>My_Module/classes</tt> then add
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 129 the new file <tt>myCalibration.m</tt> to that directory. In order for the new method to work, the LTPDA startup function <tt>ltpda_startup</tt>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 130 copies all methods for core LTPDA user classes in to their correct class directories. In order to write a correct LTPDA user-class method, it
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 131 is recommended to look at some examples, such as <tt>ao/abs</tt>, <tt>ao/average</tt>, or <tt>ao/psd</tt>. You can also extend other existing user
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 132 classes in the same way. Just make a directory of the correct class name (remember to leave off the <tt>@</tt> from the directory name; this is not supposed to
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 133 be a 'normal' MATLAB class directory) and put your new methods in there.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 134 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 135
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 136 <br><br>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 137 <h2><a name="userclasses">New User Classes</a></h2>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 138 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 139 This is an advanced topic, and it is assumed that you are familiary with
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 140 creating MATLAB classes already. To get familiar, read the MATLAB documentation on Object-Oriented Programming in the user manual.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 141 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 142 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 143 You can create new user classes in the <tt>classes</tt> directory. These follow MATLAB rules for classes, i.e., the directory name begins with a <tt>@</tt>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 144 and contains a constructor file with the same name. For example, suppose we want to create a new user class which stores trigger events from some experiment.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 145 Each trigger event has the following properties: a trigger time, an amplitude, and a frequency. We would create a new directory under <tt>classes</tt> called
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 146 <tt>@Trigger</tt> and an associated constructor file like this:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 147
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 148 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 149 <div class="fragment"><pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 150 >> cd <span class="string">'My_Module/classes'</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 151 >> mkdir <span class="string">@Trigger</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 152 >> edit <span class="string">@Trigger/Trigger.m</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 153 </pre></div>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 154 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 155 The constructor file should declare that this new Trigger class is a subclass of the LTPDA user-object base class <tt>ltpda_uoh</tt>.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 156 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 157 <div class="fragment"><pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 158 <span class="comment">% TRIGGER constructor for Trigger class.</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 159 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 160 <span class="comment">%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 161 <span class="comment">% DESCRIPTION: TRIGGER constructor for Trigger class.</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 162 <span class="comment">%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 163 <span class="comment">% CONSTRUCTOR:</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 164 <span class="comment">%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 165 <span class="comment">% t = Trigger() - creates an empty trigger object</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 166 <span class="comment">%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 167 <span class="comment">% <a href="matlab:utils.helper.displayMethodInfo('Trigger', 'Trigger')">Parameter Sets</a></span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 168 <span class="comment">%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 169 <span class="comment">% VERSION: $Id: extensions_intro_content.html,v 1.2 2011/04/29 07:23:31 hewitson Exp $</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 170 <span class="comment">%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 171 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 172
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 173 classdef Trigger < ltpda_uoh
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 174
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 175 %---------- Public (read/write) Properties ----------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 176 properties
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 177 time = time();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 178 amplitude = [];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 179 frequency = [];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 180 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 181
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 182 methods
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 183 function obj = Trigger(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 184
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 185 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 186 utils.helper.msg(msg.PROC3, <span class="string">'running %s/%s'</span>, mfilename(<span class="string">'class'</span>), mfilename);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 187
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 188 <span class="comment">% do some initialisation of the object</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 189
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 190 end <span class="comment">% End constructor</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 191
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 192 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 193
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 194 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 195 </pre></div>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 196 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 197 Various methods need to be defined by any new user class, in particular, the following abstract methods need to be created:
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 198 <table cellspacing="0" class="body" cellpadding="4" border="2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 199 <colgroup>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 200 <col width="20%">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 201 <col width="80%">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 202 </colgroup>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 203 <thead>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 204 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 205 <th bgcolor="#B2B2B2">Method name</th>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 206 <th bgcolor="#B2B2B2">Description</th>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 207 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 208 </thead>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 209 <tbody>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 210 <!-- attachToDom -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 211 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 212 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 213 <p>attachToDom</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 214 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 215 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 216 <p>Defines how the object is serialized to an XML DOM.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 217 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 218 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 219 <!-- char -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 220 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 221 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 222 <p>char</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 223 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 224 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 225 <p>Creates a character representation of the object, typically for use in display.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 226 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 227 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 228 <!-- copy -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 229 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 230 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 231 <p>copy</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 232 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 233 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 234 <p>Makes a deep or shallow copy of the object, depending on the passed argument.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 235 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 236 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 237 <!-- display -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 238 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 239 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 240 <p>display</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 241 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 242 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 243 <p>Defines how the object is displayed on the MATLAB terminal.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 244 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 245 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 246 <!-- fromDom -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 247 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 248 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 249 <p>fromDom</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 250 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 251 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 252 <p>Constructs an object from an XML DOM.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 253 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 254 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 255 <!-- loadobj -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 256 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 257 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 258 <p>loadobj</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 259 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 260 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 261 <p>This function is called is MATLAB is unable to load an object from a MAT file, for example if the class structure changes between versions. This gives an opportunity to update the loaded structure before trying to create an object from it. For more details, see MATLAB's help topic <tt>>>help loadobj</tt></p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 262 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 263 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 264 <!-- update_struct -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 265 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 266 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 267 <p>update_struct</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 268 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 269 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 270 <p>Define rules how to update structure representation of an object between versions.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 271 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 272 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 273 <!-- generateConstructorPlist -->
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 274 <tr valign="top">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 275 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 276 <p>generateConstructorPlist</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 277 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 278 <td bgcolor="#F2F2F2">
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 279 <p>Given an instance of the user object, this method generates a plist which can be used to construct an object with the same properties.</p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 280 </td>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 281 </tr>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 282 </tbody>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 283 </table>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 284 In most cases, copying these methods from an existing LTPDA user class, for example, <tt>ao</tt>, is a good start.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 285 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 286 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 287 In addition to defining these abstract methods, you typically need to overload some static methods (which we usually place inside the class constructor file). The following
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 288 code fragment shows the necessary methods needed to complete our Trigger example.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 289 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 290
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 291 <div class="fragment"><pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 292 methods (Static)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 293
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 294 <span class="comment">% This provides the hook for the command <tt><class>.getBuiltInModels</tt>. </span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 295 function mdls = getBuiltInModels(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 296 mdls = ltpda_uo.getBuiltInModels(<span class="string">'Trigger'</span>);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 297 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 298
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 299 <span class="comment">% Here we typically return the CVS version or some other version string </span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 300 function out = VEROUT()
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 301 out = <span class="string">'$Id: extensions_intro_content.html,v 1.2 2011/04/29 07:23:31 hewitson Exp $'</span>;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 302 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 303
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 304 <span class="comment">% This provides the hook for the command <tt><class>.getInfo</tt>. </span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 305 function ii = getInfo(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 306 ii = utils.helper.generic_getInfo(varargin{:}, <span class="string">'Trigger'</span>);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 307 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 308
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 309 <span class="comment">% Here we return a list of parameter sets that this constructor can handle. </span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 310 function out = SETS()
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 311 out = [SETS@ltpda_uoh, ...
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 312 {'<span class="string">Default'</span>} ...
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 313 ];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 314 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 315
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 316
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 317 <span class="comment">% This returns a parameter list for a given parameter set. </span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 318 <span class="comment">% The use of the MATLAB 'persistent' keyword means we don't repeatedly build the same plist.</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 319 function plout = getDefaultPlist(set)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 320 persistent pl;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 321 persistent lastset;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 322 if exist(<span class="string">'pl'</span>, <span class="string">'var'</span>)==0 || isempty(pl) || ~strcmp(lastset, set)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 323 pl = Trigger.buildplist(set);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 324 lastset = set;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 325 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 326 plout = pl;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 327 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 328
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 329 <span class="comment">% This builds a parameter list for the given set name. </span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 330 function out = buildplist(set)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 331
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 332 if ~utils.helper.ismember(lower(Trigger.SETS), lower(set))
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 333 error(<span class="string">'### Unknown set [%s]'</span>, set);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 334 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 335
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 336 out = plist();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 337 out = Trigger.addGlobalKeys(out);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 338 out = buildplist@ltpda_uoh(out, set);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 339
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 340 <span class="comment">% Build the requested parameter list.</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 341 switch lower(set)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 342 case <span class="string">'Default'</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 343 % time
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 344 p = param({<span class="string">'time'</span>,<span class="string">'The time of the trigger. Give either a string representation or a time object.'</span>}, paramValue.EMPTY_STRING);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 345 out.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 346
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 347 % amplitude
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 348 p = param({<span class="string">'amplitude'</span>,<span class="string">'The trigger amplitude.'</span>}, paramValue.EMPTY_DOUBLE);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 349 out.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 350
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 351 % frequency
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 352 p = param({<span class="string">'frequency'</span>,<span class="string">'The trigger frequency.'</span>}, paramValue.EMPTY_DOUBLE);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 353 out.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 354
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 355 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 356 end % function out = getDefaultPlist(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 357
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 358 <span class="comment">% This creates arrays of the given size containing empty Trigger objects.</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 359 function obj = initObjectWithSize(n,m)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 360 obj = Trigger.newarray([n m]);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 361 for ii = 1:numel(obj)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 362 obj(ii).UUID = char(java.util.UUID.randomUUID);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 363 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 364 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 365
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 366 end <span class="comment">% End static methods</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 367
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 368 methods (Static, Access=protected)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 369
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 370 <span class="comment">% Global keys are added to all parameter lists so that properties common to all</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 371 <span class="comment">% user objects can be set.</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 372 function pl = removeGlobalKeys(pl)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 373 pl.remove(<span class="string">'name'</span>);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 374 pl.remove(<span class="string">'description'</span>);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 375 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 376
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 377 function pl = addGlobalKeys(pl)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 378 % Name
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 379 p = param({<span class="string">'Name'</span>,<span class="string">'The name of the constructed trigger object.'</span>}, paramValue.STRING_VALUE(<span class="string">'None'</span>));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 380 pl.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 381
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 382 % Description
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 383 p = param({<span class="string">'Description'</span>,<span class="string">'The description of the constructed trigger object.'</span>}, paramValue.EMPTY_STRING);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 384 pl.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 385 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 386
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 387 end <span class="comment">% End static, private methods</span>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 388
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 389 methods (Static = true, Hidden = true)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 390 varargout = loadobj(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 391 varargout = update_struct(varargin);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 392 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 393
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 394 methods
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 395 varargout = char(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 396 varargout = display(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 397 varargout = copy(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 398 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 399
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 400 methods (Hidden = true)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 401 varargout = attachToDom(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 402 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 403
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 404 methods (Access = protected)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 405 obj = fromStruct(obj, a_struct)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 406 varargout = fromDom(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 407 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 408 </pre></div>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 409
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 410
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 411 <br><br>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 412 <h2><a name="unittests">Unit Tests</a></h2>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 413
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 414 <p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 415 LTPDA provides a unit test framework that aims to make it easy to test your new methods, classes and built-in models. Unit tests are methods of a
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 416 unit test class. These unit test classes should inherit from one of the base classes <tt>ltpda_utp</tt> or <tt>ltpda_builtin_model_utp</tt>. The
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 417 directory <tt>ltpda_toolbox/ltpda/classes/tests/</tt> contains these test classes and examples for testing classes and built-in models. To run
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 418 the unit tests you can use the unit test runner class <tt>ltpda_test_runner</tt>. For example,
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 419 </p>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 420 <div class="fragment"><pre>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 421 >> ltpda_test_runner.RUN_ALL_TESTS
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 422 >> ltpda_test_runner.RUN_TESTS(<span class="string">'@my_class_tests'</span>)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 423 >> ltpda_test_runner.RUN_TESTS(<span class="string">'@my_class_tests'</span>, <span class="string">'test_a_particular_method_feature'</span>)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 424 </pre></div>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 425
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 426
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 427