added parallel message receiving for previously implemented messaging where necessary
This commit is contained in:
@@ -145,7 +145,7 @@
|
|||||||
</Artifacts>
|
</Artifacts>
|
||||||
<BuildFolder type="coderapp.internal.util.mfz.FileSpec"/>
|
<BuildFolder type="coderapp.internal.util.mfz.FileSpec"/>
|
||||||
<Success>true</Success>
|
<Success>true</Success>
|
||||||
<Timestamp>2026-01-30T17:33:44</Timestamp>
|
<Timestamp>2026-01-30T18:21:40</Timestamp>
|
||||||
</MainBuildResult>
|
</MainBuildResult>
|
||||||
</coderapp.internal.mlc.mfz.MatlabCoderProjectState>
|
</coderapp.internal.mlc.mfz.MatlabCoderProjectState>
|
||||||
</MF0>
|
</MF0>
|
||||||
|
|||||||
@@ -56,37 +56,20 @@ for i = 1:numClients
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Receive TARGET acknowledgments
|
% Wait for TARGET acknowledgments from all clients (simultaneously using select())
|
||||||
targetAcks = zeros(1, numClients, 'int32');
|
|
||||||
for i = 1:numClients
|
|
||||||
if coder.target('MATLAB')
|
if coder.target('MATLAB')
|
||||||
disp(['Waiting for ACK:TARGET from client ', num2str(i)]);
|
disp('Waiting for ACK:TARGET from all clients...');
|
||||||
targetAcks(i) = 1; % Simulate successful ACK
|
disp('All TARGET acknowledgments received.');
|
||||||
else
|
else
|
||||||
targetAcks(i) = coder.ceval('receiveTargetAck', int32(i));
|
coder.ceval('waitForAllTargetAck', int32(numClients));
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
% Check all ACKs received
|
% Wait for READY signals from all clients (simultaneously using select())
|
||||||
if coder.target('MATLAB')
|
if coder.target('MATLAB')
|
||||||
disp(['Target ACKs received: ', num2str(targetAcks)]);
|
disp('Waiting for READY from all clients...');
|
||||||
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('All UAVs at target positions.');
|
disp('All UAVs at target positions.');
|
||||||
|
else
|
||||||
|
coder.ceval('waitForAllReady', int32(numClients));
|
||||||
end
|
end
|
||||||
|
|
||||||
% Wait for user input before closing experiment
|
% Wait for user input before closing experiment
|
||||||
|
|||||||
@@ -229,6 +229,18 @@ static int waitForAllMessage(int numClients, const char* expectedMessage) {
|
|||||||
return 1;
|
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
|
// Wait for RTL_COMPLETE from ALL clients simultaneously
|
||||||
// Returns 1 if all clients completed RTL, 0 otherwise
|
// Returns 1 if all clients completed RTL, 0 otherwise
|
||||||
int waitForAllRTLComplete(int numClients) {
|
int waitForAllRTLComplete(int numClients) {
|
||||||
|
|||||||
@@ -18,11 +18,15 @@ int receiveTargetAck(int clientId);
|
|||||||
int waitForReady(int clientId);
|
int waitForReady(int clientId);
|
||||||
void sendFinished(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
|
// RTL and LAND protocol functions
|
||||||
void sendRTL(int clientId);
|
void sendRTL(int clientId);
|
||||||
void sendLAND(int clientId);
|
void sendLAND(int clientId);
|
||||||
int waitForAllRTLComplete(int numClients);
|
|
||||||
int waitForAllLANDComplete(int numClients);
|
|
||||||
void waitForUserInput();
|
void waitForUserInput();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user