| 133 | | |
| 134 | | |
| | 132 | On the OEF toolbar, select OSSIE : Generate Component. This generates all of the files for the component in the local eclipse workspace directory. |
| | 133 | |
| | 134 | Generating the component will produce multiple files along with the source code. |
| | 135 | \begin{enumerate} |
| | 136 | \item {\tt configure.ac}: This is the script that autoconf uses to generate the configure file. It checks for dependencies such as which compiler to use, as well as the presence of OSSIE libraries. |
| | 137 | \item {\tt Makefile.am}: This is the script that automake uses to generate the Makefile. It includes all the source files for the component. |
| | 138 | \item {\tt reconf}: This is a script to run the automake tools. |
| | 139 | \item {\tt component\_name.h}: Component class header file. |
| | 140 | \item {\tt component\_name.cpp}: Component class implementation definition. |
| | 141 | \item {\tt main.cpp}: Contains the mandatory {\tt int main()} definition. |
| | 142 | \item {\tt component\_name.prf.xml}: Component property file. |
| | 143 | \item {\tt component\_name.scd.xml}: Software component descriptor. |
| | 144 | \item {\tt component\_name.spd.xml}: Software package descriptor. |
| | 145 | \item {\tt documentation.txt}: File for documenting your component. |
| | 146 | \item {\tt Doxyfile}: Doxygen file for generating documentation. |
| | 147 | \end{enumerate} |
| | 148 | Additional files are generated when using the {\tt pyi\_comp} option: |
| | 149 | \begin{enumerate} |
| | 150 | \item {\tt component\_name.py}: Python file with port implementations. |
| | 151 | \item {\tt WorkModule.py}: Python file where processing is done. |
| | 152 | \item {\tt setup.py}: Install script used to copy Python and XML files into the appropriate subdirectories under {\tt /sdr} once the component is edited to provide functionality. This is executed by typing {\tt python setup.py install}. |
| | 153 | \end{enumerate} |
| | 154 | |
| | 155 | At this point the signal processing or logical function of the component must be defined. The process for doing so is different depending on whether the component is written in C++ or python. |
| | 156 | |
| | 157 | \subsubsection{Editing C++ Components} |
| | 158 | \label{section:oef:editingccomponent} |
| | 159 | In this example, by selecting {\tt basic\_ports} the component was generated as a C++ component. To edit the component, open {\tt component\_name.cpp} and find the {\tt ProcessData} function. |
| | 160 | \begin{lstlisting}[] |
| | 161 | $ cd /path/to/OEF/workspace/component_name/ |
| | 162 | $ vim component_name.cpp |
| | 163 | \end{lstlisting} |
| | 164 | |
| | 165 | Within the function, there will be a {\tt while} loop and inside of it will be a line: |
| | 166 | \begin{lstlisting}[] |
| | 167 | /*insert code here to do work*/ |
| | 168 | \end{lstlisting} |
| | 169 | This is where the signal processing function should be implemented. The property that was generated, {\tt gain} will be availble in the source code initially as {\tt simplei\_0\_value}. Reassign this to a new variable named {\tt gain} in the {\tt configure} function in the same file. |
| | 170 | |
| | 171 | \subsubsection{Editing Python Components} |
| | 172 | \label{section:oef:editpythoncomponents} |
| | 173 | Generated component template code must be modified to |
| | 174 | process data. The instructions here apply to a very basic Python component with |
| | 175 | one {\it uses} and one {\it provides} port and no properties. Property values |
| | 176 | can be used in the processing operations, but this will be the subject of a |
| | 177 | future excercise. |
| | 178 | |
| | 179 | All data coming into a {\it provides} port will be loaded into the |
| | 180 | WorkModule buffer. The data going into this buffer will be loaded |
| | 181 | into variables called I and Q. See the generated WorkModule.py and |
| | 182 | look for: |
| | 183 | \begin{lstlisting}[] |
| | 184 | I = new_data[0] |
| | 185 | Q = new_data[1] |
| | 186 | \end{lstlisting} |
| | 187 | This implies that if you try to run a component that is getting real |
| | 188 | data only, Q should be empty, and this may even cause an error. There are |
| | 189 | comments in various parts of the python files describing how to adjust your code |
| | 190 | appropriately. |
| | 191 | |
| | 192 | The next two lines initialize two arrays to store your new data: |
| | 193 | \begin{lstlisting}[] |
| | 194 | newI = [0 for x in range(len(I)))] |
| | 195 | newQ = [0 for x in range(len(Q)))] |
| | 196 | \end{lstlisting} |
| | 197 | %TODO: Make listings highlighted |
| | 198 | Following these lines are comments with an example of how to |
| | 199 | process data. If you uncomment the 3-line example, your |
| | 200 | component will pass the data received by the {\it provides} (input) port to the |
| | 201 | {\it uses} (output) port, assuming you have one {\it uses} port of type {\tt |
| | 202 | complexShort} and one {\it provides} port, also of type {\tt complexShort}. |
| | 203 | Code can be added to process the data. |
| | 204 | |
| | 205 | The next set of lines following the comment ``{\tt \# Output the new data},'' |
| | 206 | will send the {\tt newI} and {\tt newQ} vectors to all of your output ports. |
| | 207 | |
| | 208 | \subsubsection{Editing the SPD File} |
| | 209 | |
| | 210 | You will need to edit {\tt MyComponent.spd.xml} before your Python |
| | 211 | component will work properly. Find the XML tag below the tag {\tt <code |
| | 212 | type="'Executable"'>}. By default the next tag is: |
| | 213 | \begin{lstlisting}[] |
| | 214 | <localfile name="'bin/MyComponent"'/>} |
| | 215 | \end{lstlisting} |
| | 216 | This needs to be changed to: |
| | 217 | \begin{lstlisting}[] |
| | 218 | <localfile name="'bin/MyComponent/MyComponent.py"'/> |
| | 219 | \end{lstlisting} |
| | 220 | |
| | 221 | \subsubsection{Making Sure Files are Executable} |
| | 222 | |
| | 223 | After you have installed the component (see below), you will need to make sure |
| | 224 | that you have permission to execute the Python files. To do this, navigate to |
| | 225 | {\tt /sdr/bin/MyComponent} and type: |
| | 226 | \begin{lstlisting}[] |
| | 227 | $ chmod +x *.py |
| | 228 | \end{lstlisting} |
| | 229 | |
| | 230 | \subsubsection{Installing a Component} |
| | 231 | \label{section:oef:installcomponent} |
| | 232 | After the component has been edited, it must be compiled and installed to {\tt /sdr}. To do this, move into the component's workspace directory and run the automake tools. |
| | 233 | \begin{lstlisting}[] |
| | 234 | $ cd /path/to/eclipse/workspace/component_name/ |
| | 235 | $ ./reconf |
| | 236 | $ ./configure |
| | 237 | $ make |
| | 238 | $ make install |
| | 239 | \end{lstlisting} |
| | 240 | |
| | 241 | If the commands execute successfully, the component will be installed to {\tt /sdr} and it will be possible to use the component in a waveform. Start a new waveform in OEF to verify that the component has been installed correctly. |