7 #include "PlusConfigure.h" 17 static const std::string SERIAL_CMD_NAME =
"SerialCommand";
22 : ResponseExpected(true)
25 this->SetName(SERIAL_CMD_NAME);
36 this->SetName(SERIAL_CMD_NAME);
43 cmdNames.push_back(SERIAL_CMD_NAME);
50 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, SERIAL_CMD_NAME))
52 desc += SERIAL_CMD_NAME;
53 desc +=
": Send text data to the device.";
61 return this->DeviceId;
67 this->DeviceId = deviceId;
73 return this->CommandName;
79 this->CommandName =
text;
85 return this->CommandValue;
91 this->CommandValue =
text;
108 XML_READ_STRING_ATTRIBUTE_OPTIONAL(DeviceId, aConfig);
109 XML_READ_STRING_ATTRIBUTE_OPTIONAL(CommandName, aConfig);
110 XML_READ_STRING_ATTRIBUTE_OPTIONAL(CommandValue, aConfig);
122 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(DeviceId, aConfig);
123 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(CommandName, aConfig);
124 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(CommandValue, aConfig);
131 LOG_DEBUG(
"vtkPlusGenericSerialCommand::Execute: " << (!this->CommandName.empty() ? this->CommandName :
"(undefined)")
132 <<
", device: " << (this->DeviceId.empty() ?
"(undefined)" : this->DeviceId)
133 <<
", value: " << (this->CommandValue.empty() ?
"(undefined)" : this->CommandValue));
136 if (dataCollector == NULL)
143 if (this->DeviceId.empty())
152 + (this->DeviceId.empty() ?
"(undefined)" : this->DeviceId) + std::string(
" is not found."));
158 std::string textToSend;
159 std::string response;
167 response = device->
GetRTS() ?
"True" :
"False";
172 bool onOff = textToSend ==
"True" ? true :
false;
173 status = device->
SetRTS(onOff);
178 status = device->
GetCTS(onOff);
179 response = onOff ?
"True" :
"False";
188 +
" on device " + (this->DeviceId.empty() ?
"(undefined)" : this->DeviceId));
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void PrintSelf(ostream &os, vtkIndent indent)
Abstract interface for tracker and video devices.
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
static const char * SERIAL_COMMAND_GET_CTS
PlusStatus GetDevice(vtkPlusDevice *&aDevice, const std::string &aDeviceId) const
std::string GetCommandName() const
PlusStatus GetCTS(bool &onOff)
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual void SetDeviceId(const std::string &deviceId)
virtual std::string GetDescription(const std::string &commandName)
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
vtkPlusGenericSerialCommand()
virtual ~vtkPlusGenericSerialCommand()
std::string GetCommandValue() const
PhidgetLCD_Font int int const char * text
static const char * SERIAL_COMMAND_GET_RTS
Manages devices that record image or positional data.
virtual PlusStatus Execute()
void SetCommandValue(const std::string &text)
virtual void GetCommandNames(std::list< std::string > &cmdNames)
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual vtkPlusDataCollector * GetDataCollector()
vtkStandardNewMacro(vtkPlusGenericSerialCommand)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
virtual std::string GetDeviceId() const
static const char * SERIAL_COMMAND_SET_RTS
This command is for communicating with vtkPlusGenericSerialDevices.This command is used for communica...
Generic interface for communicating with a serial device.
PlusStatus SetRTS(bool onOff)
void SetCommandName(const std::string &text)