HE/TX_transmit.m

124 lines
5.3 KiB
Mathematica
Raw Normal View History

2024-03-30 16:35:40 +08:00
%*********************************lql03.21*********************************
function [paraCal,tx_data,cfgUI,errorMessage] = TX_transmit(numPkt,SEED,cfgUI,feedback_data,txPSDUfile)
% try
if strcmp(cfgUI.DataType,'photo')
pktLength = cfgUI.user1.APEPlength;
% zjd3.26
if numPkt*pktLength >= length(txPSDUfile(:,1)) % 5
for pktNum = 1:numPkt %
if pktNum*pktLength >= length(txPSDUfile(:,1))
numPkt = pktNum;
break
end
end
else % 5
if numPkt*7007 >= length(txPSDUfile(:,1))
for pktNum = 1:numPkt %
if pktNum*7007 >= length(txPSDUfile(:,1))
numPkt = pktNum;
pktLength = 7007;
break
end
end
else
for pktNum = 1:numPkt %
if pktNum*12012 >= length(txPSDUfile(:,1))
numPkt = pktNum;
pktLength = 12012;
break
end
end
end
end
%
cfgUI.user1.APEPlength = pktLength;
cfgUI.user2.APEPlength = pktLength;
cfgUI.user1.t = ones(1,numPkt);
cfgUI.user2.t = ones(1,numPkt);
end
if strcmp(cfgUI.FeedbackMode,'feedback')
[cfgHE,RU_index,cfgUI] = parameter_fromAlgorithm(cfgUI,feedback_data);% RU
else
[cfgHE,RU_index,cfgUI] = parameter_fromUI(cfgUI); % RU
end
%*********************************lql03.21*********************************
showResourceMatrix(cfgHE,cfgUI,RU_index); %
txPSDU = DataGenerate(cfgUI,numPkt,SEED,cfgHE,txPSDUfile);
% for i = 1:length(txPSDU)
% txPSDU{i} = HESU_gen(txPSDU,cfgUI.ChannelBandwidth,cfgHE.User{1}.MCS);
% end
tx_data = [];
% HE-SU
if strcmp(cfgUI.UserMode,'SU')
txPSDU = txPSDU{1};
% --------------------------------zjd0323-----------------------
for pnum = 1 : numPkt
[txPad,cfgHE]=TX_SU(cfgHE,txPSDU(:,pnum));
tx_awgn = wgn(600,cfgHE.NumTransmitAntennas,-20,'complex');
tx_data = [tx_data;txPad;tx_awgn]; %
end
tx_data = [tx_awgn(1:50,:);tx_data]; %
elseif strcmp(cfgUI.UserMode,'MU')
% HE-MU
if strcmp(cfgUI.FeedbackMode,'feedback')
%*********************************lql03.21*********************************
% feedback_data
for nuser = 1 : length(cfgHE.User)
STAID = cfgHE.User{nuser}.STAID;
if STAID == 0
eval(['Feedback_data.user' num2str(nuser) '= feedback_data.user2']);
else
eval(['Feedback_data.user' num2str(nuser) '= feedback_data.user' num2str(STAID)]);
end
end
staFeedback = cell(1,length(cfgHE.User));
for userIdx = 1:length(cfgHE.User)
eval(['staFeedback{userIdx} = Feedback_data.user' num2str(userIdx) '.staFeedback;']);
end
%*********************************lql03.21*********************************
cfgNDP = wlanHESUConfig('APEPLength',0,'GuardInterval',0.8); % No data in an NDP
cfgNDP.NumTransmitAntennas = cfgHE.NumTransmitAntennas;%??
cfgNDP.NumSpaceTimeStreams = 1;%??
% For each RU calculate the steering matrix to apply
for ruIdx = 1:numel(cfgHE.RU)
% Calculate the steering matrix to apply to the RU given the feedback
steeringMatrix = heMUCalculateSteeringMatrix(staFeedback,cfgHE,cfgNDP,ruIdx);
% Apply the steering matrix to each RU
cfgHE.RU{ruIdx}.SpatialMapping = 'Custom';
cfgHE.RU{ruIdx}.SpatialMappingMatrix = steeringMatrix;
end
elseif strcmp(cfgUI.FeedbackMode,'openloop')
for ruIdx = 1:numel(cfgHE.RU)
% Apply the steering matrix to each RU
% cfgHE.RU{ruIdx}.SpatialMapping = cfgUI.user1.SpatialMapping;%% --???
cfgHE.RU{ruIdx}.SpatialMapping = 'Hadamard';
end
end
% Generate waveform with idle period
for pnum = 1 : numPkt
userString = '{';
for nuser = 1 : length(cfgHE.User)
userString = [userString 'txPSDU{' num2str(nuser) '}(:,pnum),'];
end
txPSDUtmp = eval([userString(1:(end-1)) '}']); %%------------CRC
tx = wlanWaveformGenerator(txPSDUtmp,cfgHE);
tx_awgn = wgn(600,cfgHE.NumTransmitAntennas,-20,'complex');
% awgn(zeros(600,cfgHE.NumTransmitAntennas),20,'linear',1,'all');
tx_data = [tx_data;tx;tx_awgn]; %
end
tx_data = [tx_awgn(1:50,:);tx_data]; %
% tx_data = awgn(tx_data,30,mean(abs(tx_data(1:1000)).^2)); %
end
paraCal = calculate_PAPR(tx_data(1500:2500,:));
errorMessage = '';
% catch ErrorInfo
% paraCal = 0;
% tx_data = [];
% cfgUI = struct();
% errorMessage = ErrorInfo.message;
% end
end