7 #include "PlusConfigure.h" 8 #include "igtl_header.h" 21 static const std::string REQUEST_CHANNEL_IDS_CMD =
"RequestChannelIds";
22 static const std::string REQUEST_DEVICE_CHANNEL_IDS_CMD =
"RequestDeviceChannelIds";
23 static const std::string REQUEST_DEVICE_IDS_CMD =
"RequestDeviceIds";
24 static const std::string REQUEST_INPUT_DEVICE_IDS_CMD =
"RequestInputDeviceIds";
40 SetName(REQUEST_CHANNEL_IDS_CMD);
44 SetName(REQUEST_DEVICE_IDS_CMD);
48 SetName(REQUEST_INPUT_DEVICE_IDS_CMD);
52 SetName(REQUEST_DEVICE_CHANNEL_IDS_CMD);
59 cmdNames.push_back(REQUEST_CHANNEL_IDS_CMD);
60 cmdNames.push_back(REQUEST_DEVICE_IDS_CMD);
61 cmdNames.push_back(REQUEST_INPUT_DEVICE_IDS_CMD);
62 cmdNames.push_back(REQUEST_DEVICE_CHANNEL_IDS_CMD);
69 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, REQUEST_CHANNEL_IDS_CMD))
71 desc += REQUEST_CHANNEL_IDS_CMD;
72 desc +=
": Request the list of channels for all devices.";
74 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, REQUEST_DEVICE_IDS_CMD))
76 desc += REQUEST_DEVICE_IDS_CMD;
77 desc +=
": Request the list of devices. Attributes: DeviceType: restrict the returned list of devices to a specific type (VirtualCapture, VirtualVolumeReconstructor, etc.)";
79 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, REQUEST_INPUT_DEVICE_IDS_CMD))
81 desc += REQUEST_INPUT_DEVICE_IDS_CMD;
82 desc +=
": Request the list of devices that are used as input to the requested device. Attributes: DeviceId: the id of the device to query.";
84 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, REQUEST_DEVICE_CHANNEL_IDS_CMD))
86 desc += REQUEST_DEVICE_CHANNEL_IDS_CMD;
87 desc +=
": Request the list of channels for a given device. Attributes: DeviceId: the id of the device to query.";
105 XML_READ_CSTRING_ATTRIBUTE_OPTIONAL(
DeviceType, aConfig);
106 XML_READ_CSTRING_ATTRIBUTE_OPTIONAL(
DeviceId, aConfig);
117 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(
DeviceId, aConfig);
118 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(
DeviceType, aConfig);
125 if (this->
Name.empty())
132 if (dataCollector == NULL)
147 for (
auto it = aCollection.begin(); it != aCollection.end(); ++it)
149 if (this->
DeviceId == (*it)->GetDeviceId())
157 if (igsioCommon::IsEqualInsensitive(this->
Name, REQUEST_CHANNEL_IDS_CMD))
159 std::string responseMessage;
160 bool addSeparator =
false;
161 igtl::MessageBase::MetaDataMap keyValuePairs;
172 responseMessage +=
",";
174 responseMessage += (*it)->GetChannelId();
176 keyValuePairs[(*it)->GetChannelId()] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, (*it)->GetChannelId());
180 std::ostringstream oss;
184 LOG_WARNING(
"Unable to locate client data for client id: " << this->
GetClientId());
188 oss << responseMessage;
192 oss <<
"Found: " << keyValuePairs.size() <<
" parameter" << (keyValuePairs.size() > 1 ?
"s." :
".");
198 else if (igsioCommon::IsEqualInsensitive(this->
Name, REQUEST_DEVICE_IDS_CMD))
200 std::string responseMessage;
201 bool addSeparator =
false;
202 igtl::MessageBase::MetaDataMap keyValuePairs;
215 vtkSmartPointer<vtkPlusDeviceFactory> factory = vtkSmartPointer<vtkPlusDeviceFactory>::New();
226 responseMessage +=
",";
231 keyValuePairs[aDevice->
GetDeviceId()] = std::pair<IANA_ENCODING_TYPE, std::string>(IANA_TYPE_US_ASCII, aDevice->
GetDeviceId());
234 std::ostringstream oss;
238 LOG_WARNING(
"Unable to locate client data for client id: " << this->
GetClientId());
242 oss << responseMessage;
246 oss <<
"Found: " << keyValuePairs.size() <<
" parameter" << (keyValuePairs.size() > 1 ?
"s." :
".");
251 else if (igsioCommon::IsEqualInsensitive(this->
Name, REQUEST_INPUT_DEVICE_IDS_CMD))
259 std::vector<vtkPlusDevice*> list;
260 auto device = _FindDevice(aCollection);
261 if (device ==
nullptr)
267 if (device->GetInputDevicesRecursive(list) ==
PLUS_FAIL)
272 list.insert(list.begin(), device);
274 std::ostringstream oss;
275 for (
auto it = list.begin(); it != list.end(); ++it)
277 oss << (*it)->GetDeviceId();
284 else if (igsioCommon::IsEqualInsensitive(this->
Name, REQUEST_DEVICE_CHANNEL_IDS_CMD))
286 auto device = _FindDevice(aCollection);
287 if (device ==
nullptr)
293 std::ostringstream oss;
294 for (
auto chanIter = device->GetOutputChannelsStart(); chanIter != device->GetOutputChannelsEnd(); ++chanIter)
296 oss << (*chanIter)->GetChannelId();
PlusStatus GetDevices(DeviceCollection &OutVector) const
virtual PlusStatus Execute()
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual int GetClientId()
Abstract interface for tracker and video devices.
std::vector< vtkPlusDevice * >::const_iterator DeviceCollectionConstIterator
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
virtual ~vtkPlusRequestIdsCommand()
vtkPlusRequestIdsCommand()
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual std::string GetDeviceId() const
std::vector< vtkPlusDevice * > DeviceCollection
virtual const char * GetClassName()
virtual vtkPlusOpenIGTLinkServer * GetPlusServer()
vtkPlusCommandProcessor * CommandProcessor
void SetNameToRequestChannelIds()
ChannelContainerConstIterator GetOutputChannelsEnd() const
Manages devices that record image or positional data.
virtual PlusStatus GetClientInfo(unsigned int clientId, PlusIgtlClientInfo &outClientInfo) const
virtual std::string GetDescription(const std::string &commandName)
ChannelContainerConstIterator GetOutputChannelsStart() const
ChannelContainer::const_iterator ChannelContainerConstIterator
void SetNameToRequestInputDeviceIds()
int GetClientHeaderVersion() const
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual vtkPlusDataCollector * GetDataCollector()
vtkStandardNewMacro(vtkPlusRequestIdsCommand)
virtual void PrintSelf(ostream &os, vtkIndent indent)
void SetNameToRequestDeviceChannelIds()
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
This class provides client information for vtkPlusOpenIGTLinkServer.
virtual int OutputChannelCount() const
virtual void GetCommandNames(std::list< std::string > &cmdNames)
const char ** deviceClassName
void SetNameToRequestDeviceIds()