Skip to content

Commit

Permalink
Store server command response messages in attributes, instead of betw…
Browse files Browse the repository at this point in the history
…een tags (#341)

It was already handled this way for old (V1/V2) OpenIGTLink commands.
This changes the current current V3 commands to use the a similar message format.
Also adds command name and status attributes to response.
  • Loading branch information
Sunderlandkyl committed Jul 30, 2018
1 parent d3024ea commit 63ba551
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/PlusServer/vtkPlusOpenIGTLinkServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1296,13 +1296,15 @@ igtl::MessageBase::Pointer vtkPlusOpenIGTLinkServer::CreateIgtlMessageFromComman

// Send command result details both in XML and in metadata, slowly phase towards metadata
std::ostringstream replyStr;
replyStr << "<Command><Result>" << (commandResponse->GetStatus() ? "true" : "false") << "</Result>";
replyStr << "<CommandReply";
replyStr << " Name=\"" << commandResponse->GetCommandName() << "\"";
replyStr << " Status=\"" << (commandResponse->GetStatus() ? "SUCCESS" : "FAIL") << "\"";
if (commandResponse->GetStatus() == PLUS_FAIL)
{
replyStr << "<Error>" << commandResponse->GetErrorString() << "</Error>";
replyStr << " Error=\"" << commandResponse->GetErrorString() << "\"";
igtlMessage->SetMetaDataElement("Error", IANA_TYPE_US_ASCII, commandResponse->GetErrorString());
}
replyStr << "<Message>" << commandResponse->GetResultString() << "</Message></Command>";
replyStr << " Message=\"" << commandResponse->GetResultString() << "\"></CommandReply>";
igtlMessage->SetMetaDataElement("Message", IANA_TYPE_US_ASCII, commandResponse->GetResultString());

igtlMessage->SetMetaDataElement("Result", IANA_TYPE_US_ASCII, (commandResponse->GetStatus() ? "true" : "false"));
Expand Down

0 comments on commit 63ba551

Please sign in to comment.