7 #include "PlusConfigure.h" 18 static const std::string GET_FRAME_RATE_CMD =
"GetFrameRate";
23 : ResponseExpected(true)
26 this->SetName(GET_FRAME_RATE_CMD);
37 this->SetName(GET_FRAME_RATE_CMD);
44 cmdNames.push_back(GET_FRAME_RATE_CMD);
51 if (commandName.empty() || igsioCommon::IsEqualInsensitive(commandName, GET_FRAME_RATE_CMD))
53 desc += GET_FRAME_RATE_CMD;
54 desc +=
": Get frame rate from a data channel.";
62 return this->ChannelId;
68 this->ChannelId = channelId;
84 XML_READ_STRING_ATTRIBUTE_OPTIONAL(ChannelId, aConfig);
95 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(ChannelId, aConfig);
102 LOG_DEBUG(
"vtkPlusGetFrameRateCommand::Execute: " << (!this->
Name.empty() ? this->
Name :
"(undefined)")
103 <<
", channel: " << (this->ChannelId.empty() ?
"(undefined)" : this->ChannelId));
106 if (dataCollector == NULL)
113 if (this->ChannelId.empty())
122 + (this->ChannelId.empty() ?
"(undefined)" : this->ChannelId) + std::string(
" is not found."));
128 channel->GetVideoSource(dataSource);
130 double framerate = dataSource->
GetFrameRate(
false, &stddev);
132 std::map < std::string, std::pair<IANA_ENCODING_TYPE, std::string> > metaData;
134 std::stringstream response;
135 std::string error =
"";
137 metaData[
"FrameRate"] = std::make_pair(IANA_TYPE_US_ASCII,
std::to_string(framerate));
138 metaData[
"FrameRateStdDev"] = std::make_pair(IANA_TYPE_US_ASCII,
std::to_string(stddev));
140 vtkSmartPointer<vtkPlusCommandRTSCommandResponse> commandResponse = vtkSmartPointer<vtkPlusCommandRTSCommandResponse>::New();
141 commandResponse->UseDefaultFormatOff();
142 commandResponse->SetClientId(this->
ClientId);
143 commandResponse->SetOriginalId(this->
Id);
144 commandResponse->SetCommandName(this->GetName());
147 commandResponse->SetErrorString(error);
148 commandResponse->SetResultString(response.str());
149 commandResponse->SetParameters(metaData);
virtual ~vtkPlusGetFrameRateCommand()
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
virtual void PrintSelf(ostream &os, vtkIndent indent)
This command returns the current frame rate from a vtkPlusChannel's DataSource.This command is used f...
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual PlusStatus Execute()
std::string to_string(ClariusAvailability avail)
virtual void SetChannelId(const std::string &channelId)
virtual std::string GetDescription(const std::string &commandName)
virtual std::string GetChannelId() const
vtkStandardNewMacro(vtkPlusGetFrameRateCommand)
virtual void GetCommandNames(std::list< std::string > &cmdNames)
Manages devices that record image or positional data.
bool RespondWithCommandMessage
void SetNameToGetFrameRate()
virtual double GetFrameRate(bool ideal=false, double *framePeriodStdevSecPtr=NULL)
void QueueCommandResponse(PlusStatus status, const std::string &message, const std::string &error="", const igtl::MessageBase::MetaDataMap *metaData=nullptr)
virtual vtkPlusDataCollector * GetDataCollector()
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
PlusCommandResponseList CommandResponseQueue
PlusStatus GetChannel(vtkPlusChannel *&aChannel, const std::string &aChannelId) const
vtkPlusGetFrameRateCommand()
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *aConfig)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *aConfig)
Interface to a 3D positioning tool, video source, or generalized data stream.