Robochameleon  v1.0
Public Member Functions | Public Attributes | Private Attributes | List of all members
unit Class Reference

Superclass: basic building block to hold functions. More...

Inherits handle.

Inherited by AdaptiveEqualizer_MMA_RDE_v1, BalancedPair_v1, BaseBandFilter_v1, BC_Nx1_v1, BERT_v1, BranchSignal_v1, BS_1xN_v1, CDCompensation_v1, ChannelCombiner_v1, ClassTemplate_v1, Combiner_v1, Crop_v1, DCblock_v1, DDPLL_v1, Decimate_v1, Delay_v1, DigitalPreFilter_v1, DSO_v1, EDFA_v1, ElectricalFilter_v1, Gain_v1, IntensityModulator_v1, IQModulator_v1, Laser_v1, LinChBulk_v1, Mapper_v1, module, Negator_v1, NonlinearChannel_v1, OpticalHybrid_v1, OrthogonalCodeGenerator_v1, OSNR_v1, PatternGenerator_v1, PBC_Nx1_v1, PBS_1xN_v1, PD_v1, Polarizer_v1, PPG_v1, PulseShaper_v1, PulseTrainGenerator_v1, QuadratureImbalanceCompensation_v1, Quantizer_v1, Resample_v1, ResampleSkewJitter_v1, sink, SNR_v1, Splitter_v1, TestCh2x2_v1, TestSink_v1, and TestSource_v1.

Public Member Functions

virtual traverse (in obj, in varargin)
 Main function call.
 
function traverseNode (in obj)
 Set unique ID when creating a unit. More...
 
function connectOutput (in obj, in uobj, in unitOutput, in nextUnitInput)
 Specify where signal should go next. More...
 
function connectOutputs (in obj, in units, in destInputs)
 Specify where signal should go next. More...
 
function writeInputBuffer (in obj, in sig, in inputId)
 write input buffer
 
function horzcat (in varargin)
 horizontal concatenation
 
function vertcat (in varargin)
 vertical concatenation
 
function setparams (in obj, in params, in REQUIRED_PARAMS, in QUIET_PARAMS)
 set parameters More...
 
function view (in obj)
 Show interactive GUI through unit_view-class.
 

Public Attributes

Property inputBuffer
 Buffer for storing inputs as we traverse the graph.
 
Property nextNodes
 Children nodes.
 
Property destInputs
 Destination inputs in children.
 
Property results
 For storing results.
 
Property label
 
Property draw
 enable/disable plotting
 
Property nInputs
 Number of signals traverse expects.
 
Property nOutputs
 Number of outputs traverse expects.
 

Private Attributes

Property ID
 

Detailed Description

Superclass: basic building block to hold functions.

Everything that operates on a signal_interface object should be defined as a class that inherits certain properties from unit. For example:

classdef MyClass_v1 < unit
...
end

All units must have the following properties:

Author
Robert Borkowski
Version
1

Definition at line 27 of file unit.m.

Member Function Documentation

function unit::connectOutput ( in  obj,
in  uobj,
in  unitOutput,
in  nextUnitInput 
)

Specify where signal should go next.

Connects one output of one unit to the inputs of the next For use in modules

Complicated example:

%% Construct some units (a 90 degree hybrid and two balanced pairs)
hyb1 = OpticalHybrid_v1(param.hyb);
bpd1 = BalancedPair_v1(param.bpd);
bpd2 = BalancedPair_v1(param.bpd);
%% attach the hybrid outputs to the BPDs
hyb1.connectOutput(bpd1, 1, 1);
hyb1.connectOutput(bpd1, 2, 2);
hyb1.connectOutput(bpd2, 3, 1);
hyb1.connectOutput(bpd2, 4, 2);

This will have the following connection diagram

BlockDiagUnitExplanation.jpg
Parameters
uobjwhich unit to connect to
unitOutputwhich unit output to connect
nextUnitInputwhich input to connect to
See also
module
function unit::connectOutputs ( in  obj,
in  units,
in  destInputs 
)

Specify where signal should go next.

Connects all the outputs of one unit to the inputs of the next. For use in modules

Connects all the outputs of one unit to the inputs of the next set of units.

Complicated example:

%% Construct some units (a 90 degree hybrid and two balanced pairs)
hyb1 = OpticalHybrid_v1(param.hyb);
bpd1 = BalancedPair_v1(param.bpd);
bpd2 = BalancedPair_v1(param.bpd);
%% attach the hybrid outputs to the BPDs
hyb1.connectOutputs({bpd1 bpd1 bpd2 bpd2}, [1 2 1 2]);

This will have the following connection diagram

BlockDiagUnitExplanation.jpg

Note the implied order of unit outputs is 1,2,3,...

Notes on syntax:

  1. The set of destinations should be passed as a cell array. If they are passed as a regular array, this function will attempt to convert to cell array, but this is not ideal.
  2. The destination inputs can be omitted if:

    (a) There is one destination unit and all source outputs connect sequentially to all destination outputs OR

    (b) There is exactly one destination unit for each source output.

Parameters
unitsobject, or cell array of objects, to connect to
destInputswhich input to connect to
See also
module
function unit::setparams ( in  obj,
in  params,
in  REQUIRED_PARAMS,
in  QUIET_PARAMS 
)

set parameters

Compare user-specified parameters to class properties. Assign as many as possible, warn the user when default is being used and when they have specified properties the class does not have.

For example, using Delay_v1, if the constructor is

function obj = Delay_v1(param)
setparams(obj, param);
end

Then the following code:

goodparam = struct('delay', 100, 'mode', 'symbols');
delay = Delay_v1(goodparam);

returns no warnings, errors, etc. This code,

weirdparam = struct('delay', 100, 'mode', 'symbols', 'puppies', 1e6);
delay = Delay_v1(weirdparam);

will warn the user that ther is no puppies property in the delay class. If instead the constructor had been written

function obj = Delay_v1(param)
setparams(obj, param, {}, {'draw'});
end

then

delay = Delay_v1(goodparam);

would warn the user that nInputs, nOutputs, results, and label are set to the default values. A better constructor would be

function obj = Delay_v1(param)
setparams(obj, param, {'delay'});
end

because it will return an error if the user tries to build a delay without actually specifying the delay. It will also warn the user if any other class-specific properties (mode, in this case) are set to default.

Parameters
paramsparameter structure to evaluate
REQUIRED_PARAMScell array of required parameter names (default empty)
QUIET_PARAMScell array of parameter names not to warn user about (default nInputs, nOutputs, results, label, draw)
function unit::traverseNode ( in  obj)

Set unique ID when creating a unit.

Apply function contained in unit to signal

Displays name of node and executes function contained in each unit on input signal(s).


The documentation for this class was generated from the following file: