added parallel message receiving for previously implemented messaging where necessary

This commit is contained in:
2026-01-30 18:28:19 -08:00
parent 448db1e0e3
commit a965dff4ca
4 changed files with 28 additions and 29 deletions

View File

@@ -145,7 +145,7 @@
</Artifacts>
<BuildFolder type="coderapp.internal.util.mfz.FileSpec"/>
<Success>true</Success>
<Timestamp>2026-01-30T17:33:44</Timestamp>
<Timestamp>2026-01-30T18:21:40</Timestamp>
</MainBuildResult>
</coderapp.internal.mlc.mfz.MatlabCoderProjectState>
</MF0>

View File

@@ -56,37 +56,20 @@ for i = 1:numClients
end
end
% Receive TARGET acknowledgments
targetAcks = zeros(1, numClients, 'int32');
for i = 1:numClients
% Wait for TARGET acknowledgments from all clients (simultaneously using select())
if coder.target('MATLAB')
disp(['Waiting for ACK:TARGET from client ', num2str(i)]);
targetAcks(i) = 1; % Simulate successful ACK
disp('Waiting for ACK:TARGET from all clients...');
disp('All TARGET acknowledgments received.');
else
targetAcks(i) = coder.ceval('receiveTargetAck', int32(i));
end
coder.ceval('waitForAllTargetAck', int32(numClients));
end
% Check all ACKs received
% Wait for READY signals from all clients (simultaneously using select())
if coder.target('MATLAB')
disp(['Target ACKs received: ', num2str(targetAcks)]);
end
% Wait for READY signals (UAVs have reached their targets)
readySignals = zeros(1, numClients, 'int32');
for i = 1:numClients
if coder.target('MATLAB')
disp(['Waiting for READY from client ', num2str(i)]);
readySignals(i) = 1; % Simulate READY
else
readySignals(i) = coder.ceval('waitForReady', int32(i));
end
end
% Check all READY signals received
if coder.target('MATLAB')
disp(['Ready signals received: ', num2str(readySignals)]);
disp('Waiting for READY from all clients...');
disp('All UAVs at target positions.');
else
coder.ceval('waitForAllReady', int32(numClients));
end
% Wait for user input before closing experiment

View File

@@ -229,6 +229,18 @@ static int waitForAllMessage(int numClients, const char* expectedMessage) {
return 1;
}
// Wait for ACK:TARGET from ALL clients simultaneously
// Returns 1 if all clients acknowledged, 0 otherwise
int waitForAllTargetAck(int numClients) {
return waitForAllMessage(numClients, "ACK:TARGET");
}
// Wait for READY from ALL clients simultaneously
// Returns 1 if all clients are ready, 0 otherwise
int waitForAllReady(int numClients) {
return waitForAllMessage(numClients, "READY");
}
// Wait for RTL_COMPLETE from ALL clients simultaneously
// Returns 1 if all clients completed RTL, 0 otherwise
int waitForAllRTLComplete(int numClients) {

View File

@@ -18,11 +18,15 @@ int receiveTargetAck(int clientId);
int waitForReady(int clientId);
void sendFinished(int clientId);
// Parallel wait functions (using select() for simultaneous processing)
int waitForAllTargetAck(int numClients);
int waitForAllReady(int numClients);
int waitForAllRTLComplete(int numClients);
int waitForAllLANDComplete(int numClients);
// RTL and LAND protocol functions
void sendRTL(int clientId);
void sendLAND(int clientId);
int waitForAllRTLComplete(int numClients);
int waitForAllLANDComplete(int numClients);
void waitForUserInput();
#ifdef __cplusplus