Extracts the first available data value from the input port. Used for Scripted Element.
For INTERCONNECT 6.5+, this script command supports for both Sample Mode and Block Mode data.
Syntax |
Description |
---|---|
signalIn = popportframe(port); |
For a scripted element, this command returns a frame structure containing the input signal for a given input ‘port’ (data) and its properties (header). |
Implementation Details
Digital signal frame:
The data contains the current time instant and the value of the signal, as well as the bandwidth struct which contains the signal bitrate and time window. The header is a struct that contains the signal type and subtype. The type for a digital signal is ‘3’. The subtype for sample and block modes digital signal are '1' and '2', respectively.
#digital signal frame data=struct data.bandwidth=struct data.bandwidth.bitrate data.bandwidth.time_window data.time data.value header=struct header.subtype header.type valid
Electrical signal frame:
The data contains the current time instant and the value of the signal, as well as the bandwidth struct which contains the signal frequency, sample rate and time window. The header is a struct that contains the signal type and subtype. The type for an electrical signal is ‘2’. The subtype for sample and block modes electrical signal are '1' and '2', respectively.
#electrical signal frame data=struct data.bandwidth=struct data.bandwidth.frequency data.bandwidth.sample_rate data.bandwidth.time_window data.time data.value header=struct header.subtype header.type valid
Optical signal frame:
The data signal is a cell which contains the channel and mode information. The signal channel is a cell that contains the bandwidth struct, and the bandwidth struct contains the signal frequency, sample rate and time window. The mode is a struct which contains the mode label, orthogonal indentifier and the mode ID. The header is a struct that contains the signal type and subtype. The type for an optical signal is ‘1’. The subtype for sample and block modes optical signal are '1' and '2', respectively.
#optical signal frame data=struct data.signal=cell data.signal.channel=cell data.signal.channel.bandwidth=struct data.signal.channel.bandwidth.frequency data.signal.channel.bandwidth.sample_rate data.signal.channel.bandwidth.time_window data.signal.channel.time data.signal.channel.value data.signal.mode=struct data.signal.mode.label data.signal.mode.orthogonal_identifier data.signal.mode.uid header=struct header.subtype header.type valid
Example
Sample Mode
Implements of a ‘go’ function of a scripted element with one digital input and one digital output port. It calculates the complementary output:
signalIn = popportframe( "input" ); if( signalIn.valid ) { logmessage( toscript( signalIn ) ); bitrate = signalIn.data.bandwidth.bitrate; mxX( nCount ) = signalIn.data.time; mxY( nCount ) = signalIn.data.value; if( signalIn.data.value 0 ) { signalIn.data.value = 0; } else { signalIn.data.value = 1; } nCount = nCount + 1; } pushportframe( "output", signalIn );
The digital signal frame at time instant ‘6.4e-10’ seconds
SignalIn=struct; SignalIn.data=struct; SignalIn.data.bandwidth=struct; SignalIn.data.bandwidth.bitrate=2.5e+009; SignalIn.data.bandwidth.time_window=6.4e-009; SignalIn.data.time=5.6e-009; SignalIn.data.value=0; SignalIn.header=struct; SignalIn.header.subtype=1; SignalIn.header.type=3 SignalIn.valid=1
Implements of a ‘go’ function of a scripted element with one electrical input and one electrical output port. It calculates applies a gain of ‘10’ to the input signal:
signalIn = popportframe( "input" ); if( signalIn.valid ) { logmessage(toscript(signalIn)); for( i=1:length( signalIn.data.value ) ) { signalIn.data.value( i ) = 10 * signalIn.data.value( i ); } } pushportframe( "output", signalIn );
The electrical signal frame at time instant ‘3.19375e-009’ seconds
signalIn=struct; signalIn.data.bandwidth=struct; signalIn.data.bandwidth.frequency=0; signalIn.data.bandwidth.sample_rate=1.6e+011; signalIn.data.bandwidth.time_window=3.2e-009; signalIn.data.time=3.19375e-009; signalIn.data.value=3.19375e-009; signalIn.header=struct; signalIn.header.subtype=1; signalIn.header.type=2; signalIn.valid=1;
Implements of a ‘go’ function of a scripted element with one optical input and one optical output port. It calculates applies a gain of ‘10’ to the input signal for each mode and channel:
signalIn = popportframe( "input" ); if( signalIn.valid ) { logmessage( toscript( signalIn ) ); for( i = 1:length( signalIn.data.signal ) ) { nChannels = length( signalIn.data.signal{i}.channel ); for( j = 1:nChannels ) { for(k=1:length(signalIn.data.signal{i}.channel{j}.value)) { signalIn.data.signal{i}.channel{j}.value(k) = 10.0 * signalIn.data.signal{i}.channel{j}.value(k); } } } } pushportframe( "output", signalIn );
The optical signal frame at time instant ‘7.01562e-010’ seconds
Scripted Element: signalIn=struct; signalIn.data=struct; signalIn.data.signal=cell(1); signalIn.data.signal{1}=struct; signalIn.data.signal{1}.channel=cell(1); signalIn.data.signal{1}.channel{1}=struct; signalIn.data.signal{1}.channel{1}.bandwidth=struct; signalIn.data.signal{1}.channel{1}.bandwidth.frequency=1.931e+014; signalIn.data.signal{1}.channel{1}.bandwidth.sample_rate=1.6e+011; signalIn.data.signal{1}.channel{1}.bandwidth.time_window=3.2e-009; signalIn.data.signal{1}.channel{1}.time=3.18125e-009; signalIn.data.signal{1}.channel{1}.value=0.0316228+0i; signalIn.data.signal{1}.mode=struct; signalIn.data.signal{1}.mode.label='X'; signalIn.data.signal{1}.mode.orthogonal_identifier=1; signalIn.data.signal{1}.mode.uid='#1'; signalIn.header=struct; signalIn.header.subtype=1; signalIn.header.type=1; signalIn.valid=1;
Block Mode
Implements of a ‘go’ function of a scripted element with one digital input and one digital output port for Block Mode. It calculates the complementary output, achieves the same purpose as in the first example:
signalIn = popportframe( "input" ); if( signalIn.valid ) { logmessage( toscript( signalIn ) ); bitrate = signalIn.data.bandwidth.bitrate; mxX = signalIn.data.time; mxY = signalIn.data.value; for (nCount = 1:16) { if( signalIn.data.value(nCount) 0 ) { signalIn.data.value(nCount) = 0; } else { signalIn.data.value(nCount) = 1; } } } pushportframe( "output", signalIn );
The digital signal block frame at time instant ‘6.4e-10’ seconds
signalIn=struct; signalIn.data=struct; signalIn.data.bandwidth=struct; signalIn.data.bandwidth.bitrate=2.5e+010; signalIn.data.bandwidth.time_window=6.4e-010; signalIn.data.time=0; signalIn.data.value=matrix(16); signalIn.data.value(1)=0; signalIn.data.value(2)=1; signalIn.data.value(3)=1; signalIn.data.value(4)=0; signalIn.data.value(5)=1; signalIn.data.value(6)=1; signalIn.data.value(7)=1; signalIn.data.value(8)=0; signalIn.data.value(9)=0; signalIn.data.value(10)=1; signalIn.data.value(11)=0; signalIn.data.value(12)=0; signalIn.data.value(13)=0; signalIn.data.value(14)=0; signalIn.data.value(15)=0; signalIn.data.value(16)=1; signalIn.header=struct; signalIn.header.subtype=2; signalIn.header.type=3; signalIn.valid=1;
See Also
pushportdata , cloneportdata , portdatasize , pushportframe , getmonitorframe , getmonitorwaveform