next up previous contents
Next: 5.2.6 Editing the SPD Up: 5.2 Creating a New Previous: 5.2.4 Generating the Source   Contents

5.2.5 Building a Working Python Component

Generated component template code must be modified to process data. The instructions here apply to a very basic Python component with one uses and one provides port and no properties. Property values can be used in the processing operations, but this will be the subject of a future excercise.

All data coming into a provides port will be loaded into the WorkModule buffer. The data going into this buffer will be loaded into variables called I and Q. See the generated WorkModule.py and look for:

    I = new_data[0]
    Q = new_data[1]
This implies that if you try to run a component that is getting real data only, Q should be empty, and this may even cause an error. There are comments in various parts of the python files describing how to adjust your code appropriately.

The next two lines initialize two arrays to store your new data:

    newI = [0 for x in range(len(I)))]
    newQ = [0 for x in range(len(Q)))]
Following these lines are comments with an example of how to process data. If you uncomment the 3-line example, your component will pass the data received by the provides (input) port to the uses (output) port, assuming you have one uses port of type complexShort and one provides port, also of type complexShort. Code can be added to process the data.

The next set of lines following the comment ``# Output the new data,'' will send the newI and newQ vectors to all of your output ports.


next up previous contents
Next: 5.2.6 Editing the SPD Up: 5.2 Creating a New Previous: 5.2.4 Generating the Source   Contents
2008-04-25