7 #include "PlusConfigure.h" 8 #include "igtl_header.h" 9 #include "vtkImageData.h" 10 #include "vtkMatrix4x4.h" 13 #include "vtkVersion.h" 20 : CommandProcessor(NULL)
23 , RespondWithCommandMessage(true)
35 this->Superclass::PrintSelf(os, indent);
43 LOG_ERROR(
"vtkPlusCommand::ReadConfiguration failed, input is NULL");
46 SetName(aConfig->GetAttribute(
"Name"));
59 LOG_ERROR(
"vtkPlusCommand::WriteConfiguration failed, input is NULL");
62 aConfig->SetName(
"Command");
63 if (!this->
Name.empty())
65 aConfig->SetAttribute(
"Name", this->
Name.c_str());
70 std::list<std::string> cmdNames;
72 if (!cmdNames.empty())
74 aConfig->SetAttribute(
"Name", cmdNames.front().c_str());
97 LOG_ERROR(
"CommandProcessor is invalid");
104 LOG_ERROR(
"CommandProcessor::PlusServer is invalid");
109 if (dataCollector == NULL)
111 LOG_ERROR(
"CommandProcessor::PlusServer::DataCollector is invalid");
114 return dataCollector;
122 LOG_ERROR(
"CommandProcessor is invalid");
129 LOG_ERROR(
"CommandProcessor::PlusServer is invalid");
133 vtkIGSIOTransformRepository* aRepository =
server->GetTransformRepository();
134 if (aRepository == NULL)
136 LOG_ERROR(
"CommandProcessor::PlusServer::TransformRepository is invalid");
145 if (this->
Name.empty())
147 LOG_ERROR(
"Command name is not specified");
150 std::list<std::string> cmdNames;
152 for (std::list<std::string>::iterator it = cmdNames.begin(); it != cmdNames.end(); ++it)
154 if (igsioCommon::IsEqualInsensitive(*it, this->
Name))
160 LOG_ERROR(
"Command name " << this->
Name <<
" is not recognized");
167 std::ostringstream ss;
211 if (!igsioCommon::IsEqualInsensitive(uidInDeviceName, uid))
224 std::size_t separatorPos =
deviceName.find(
"_");
225 if (separatorPos != std::string::npos)
236 std::size_t separatorPos =
deviceName.find(
"_");
237 if (separatorPos != std::string::npos)
257 vtkSmartPointer<vtkPlusCommandRTSCommandResponse> commandResponse = vtkSmartPointer<vtkPlusCommandRTSCommandResponse>::New();
258 commandResponse->SetClientId(this->
ClientId);
259 commandResponse->SetOriginalId(this->
Id);
260 commandResponse->SetDeviceName(this->
DeviceName);
261 commandResponse->SetCommandName(this->GetName());
262 commandResponse->SetStatus(status);
264 commandResponse->SetErrorString(error);
265 commandResponse->SetResultString(
message);
266 if (replyMetaData != NULL)
268 commandResponse->SetParameters(*replyMetaData);
static std::string GenerateReplyDeviceName(uint32_t uid)
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
static const std::string DEVICE_NAME_COMMAND
virtual void SetCommandProcessor(vtkPlusCommandProcessor *processor)
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual vtkIGSIOTransformRepository * GetTransformRepository()
Creates a PlusCommand from a string. If the commands are to be executed on the main thread then call ...
virtual vtkPlusOpenIGTLinkServer * GetPlusServer()
void PopCommandResponses(PlusCommandResponseList &responses)
PlusStatus ValidateName()
vtkPlusCommandProcessor * CommandProcessor
void SetMetaData(const igtl::MessageBase::MetaDataMap &metaData)
virtual void GetCommandNames(std::list< std::string > &cmdNames)=0
Manages devices that record image or positional data.
bool RespondWithCommandMessage
igtl::MessageBase::MetaDataMap MetaData
virtual ~vtkPlusCommand()
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual vtkPlusDataCollector * GetDataCollector()
static std::string GetPrefixFromCommandDeviceName(const std::string &deviceName)
static bool IsCommandDeviceName(const std::string &deviceName)
static std::string GetUidFromCommandDeviceName(const std::string &deviceName)
This class provides a network interface for data acquired by Plus as an OpenIGTLink server.
std::list< vtkSmartPointer< vtkPlusCommandResponse > > PlusCommandResponseList
PlusCommandResponseList CommandResponseQueue
static PlusStatus GenerateCommandDeviceName(const std::string &uid, std::string &outDeviceName)
static bool IsReplyDeviceName(const std::string &deviceName, const std::string &uid=std::string(""))
static const std::string DEVICE_NAME_REPLY
vtkNew< vtkPlusOpenIGTLinkServer > server