Skip to content
Snippets Groups Projects
Commit 39fb4a5b authored by phanikiran1169's avatar phanikiran1169 Committed by Florent Lamiraux
Browse files

Methods to check whether queue received data

parent 6148edfd
No related branches found
No related tags found
No related merge requests found
......@@ -24,5 +24,11 @@ BOOST_PYTHON_MODULE(wrap) {
"Return the queue size of a given signal", bp::args("signal_name"))
.def("readQueue", &dg::RosQueuedSubscribe::readQueue,
"Whether signals should read values from the queues, and when.",
bp::args("start_time"));
bp::args("start_time"))
.def("queueReceivedData", &dg::RosQueuedSubscribe::queueReceivedData,
"Check whether the queue of a given signal has received atleast one data point",
bp::args("signal_name"))
.def("setQueueReceivedData", &dg::RosQueuedSubscribe::setQueueReceivedData,
"Set the data reception status of the queue corresponding to a given signal",
bp::args("signal_name","signal_data_acq_status"));
}
......@@ -147,4 +147,21 @@ void RosQueuedSubscribe::readQueue(int beginReadingAt) {
}
std::string RosQueuedSubscribe::getDocString() const { return docstring_; }
} // end of namespace dynamicgraph.
bool RosQueuedSubscribe::queueReceivedData(const std::string& signal) const{
std::map<std::string, bindedSignal_t>::const_iterator _bs = bindedSignal_.find(signal);
if (_bs != bindedSignal_.end()) {
return _bs->second->receivedData();
}
return false;
}
void RosQueuedSubscribe::setQueueReceivedData(const std::string& signal, bool status) {
std::map<std::string, bindedSignal_t>::const_iterator _bs = bindedSignal_.find(signal);
if (_bs != bindedSignal_.end()) {
_bs->second->receivedData(status);
}
}
} // end of namespace dynamicgraph.
\ No newline at end of file
......@@ -57,6 +57,9 @@ struct BindedSignalBase {
virtual void clear() = 0;
virtual std::size_t size() const = 0;
virtual bool receivedData() const = 0;
virtual void receivedData(bool) = 0;
Subscriber_t subscriber;
RosQueuedSubscribe* entity;
};
......@@ -73,7 +76,8 @@ struct BindedSignal : BindedSignalBase {
frontIdx(0),
backIdx(0),
buffer(BufferSize),
init(false) {}
init(false),
receivedData_(false) {}
~BindedSignal() {
signal.reset();
clear();
......@@ -107,6 +111,15 @@ struct BindedSignal : BindedSignalBase {
return backIdx + BufferSize - frontIdx;
}
/// @brief Returns the value stored in receivedData_ i.e.
/// whether the signal has received atleast one data point
/// or not
bool receivedData() const {return receivedData_;}
/// @brief Set the value of data acquisition status of the signal
/// @param status
void receivedData(bool status) {receivedData_ = status;}
SignalPtr_t signal;
/// Index of the next value to be read.
size_type frontIdx;
......@@ -120,6 +133,10 @@ struct BindedSignal : BindedSignalBase {
template <typename R>
void writer(const R& data);
T& reader(T& val, int time);
private:
/// Indicates whether the signal has received atleast one data point
bool receivedData_;
};
} // namespace internal
......@@ -144,6 +161,8 @@ class RosQueuedSubscribe : public dynamicgraph::Entity {
void clearQueue(const std::string& signal);
void readQueue(int beginReadingAt);
std::size_t queueSize(const std::string& signal) const;
bool queueReceivedData(const std::string& signal) const;
void setQueueReceivedData(const std::string& signal, bool status);
template <typename T>
void add(const std::string& type, const std::string& signal,
......
......@@ -82,6 +82,12 @@ void BindedSignal<T, N>::writer(const R& data) {
last = buffer[backIdx];
init = true;
}
// Updating the status flag to indicate that the signal
// has received atleast one data point.
if (!receivedData_) {
receivedData_ = true;
}
backIdx = (backIdx + 1) % N;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment