Skip to content
Snippets Groups Projects
Commit 7a01369f authored by Mirko Wächter's avatar Mirko Wächter
Browse files

plotter supports observers history now

parent 51e0984f
No related branches found
No related tags found
No related merge requests found
...@@ -274,7 +274,7 @@ namespace armarx ...@@ -274,7 +274,7 @@ namespace armarx
{ {
logstream << "Timestamp"; logstream << "Timestamp";
for (auto & channel : selectedChannels) for (auto& channel : selectedChannels)
{ {
logstream << "," << channel.toStdString(); logstream << "," << channel.toStdString();
} }
...@@ -334,7 +334,7 @@ namespace armarx ...@@ -334,7 +334,7 @@ namespace armarx
ScopedLock lock(dataMutex); ScopedLock lock(dataMutex);
IceUtil::Time curTime = TimeUtil::GetTime(); IceUtil::Time curTime = TimeUtil::GetTime();
// erase old markers // erase old markers
for (auto & markerChannel : markers) for (auto& markerChannel : markers)
{ {
for (auto it = markerChannel.second.begin(); it != markerChannel.second.end();) for (auto it = markerChannel.second.begin(); it != markerChannel.second.end();)
{ {
...@@ -383,7 +383,7 @@ namespace armarx ...@@ -383,7 +383,7 @@ namespace armarx
marker->setLineStyle(QwtPlotMarker::VLine); marker->setLineStyle(QwtPlotMarker::VLine);
marker->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft); marker->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft);
int i = 0; int i = 0;
for (auto & markerSubMap : markers) for (auto& markerSubMap : markers)
{ {
if (markerSubMap.first == datafieldId) if (markerSubMap.first == datafieldId)
{ {
...@@ -623,7 +623,8 @@ namespace armarx ...@@ -623,7 +623,8 @@ namespace armarx
{ {
ScopedLock lock(dataMutex); ScopedLock lock(dataMutex);
auto now = TimeUtil::GetTime();
std::map<std::string, ChannelHistory> histories;
markers.clear(); markers.clear();
for (int i = 0; i < selectedChannels.size(); i++) for (int i = 0; i < selectedChannels.size(); i++)
{ {
...@@ -633,6 +634,22 @@ namespace armarx ...@@ -633,6 +634,22 @@ namespace armarx
DataFieldIdentifierPtr identifier = new DataFieldIdentifier(selectedChannels.at(i).toStdString()); DataFieldIdentifierPtr identifier = new DataFieldIdentifier(selectedChannels.at(i).toStdString());
auto prx = getProxy<ObserverInterfacePrx>(identifier->observerName); auto prx = getProxy<ObserverInterfacePrx>(identifier->observerName);
// get past data of that datafield
auto id = identifier->getIdentifierStr();
auto historiesIt = histories.find(identifier->channelName);
if (historiesIt == histories.end())
{
auto start = IceUtil::Time::now();
histories[identifier->channelName] = prx->getPartialChannelHistory(identifier->channelName,
(now - IceUtil::Time::seconds(shownInterval)).toMicroSeconds(), now.toMicroSeconds());
ARMARX_DEBUG << "history data polling took : " << (IceUtil::Time::now() - start).toMilliSecondsDouble() << " got " << histories[identifier->channelName].size() << " entries";
historiesIt = histories.find(identifier->channelName);
}
long lastTimestamp = 0;
VariantPtr var = VariantPtr::dynamicCast(prx->getDataField(identifier)); VariantPtr var = VariantPtr::dynamicCast(prx->getDataField(identifier));
auto type = var->getType(); auto type = var->getType();
if (type == VariantType::String) if (type == VariantType::String)
...@@ -646,6 +663,15 @@ namespace armarx ...@@ -646,6 +663,15 @@ namespace armarx
QwtThermo* bar = createBar(selectedChannels.at(i)); QwtThermo* bar = createBar(selectedChannels.at(i));
bars[selectedChannels.at(i).toStdString()] = bar; bars[selectedChannels.at(i).toStdString()] = bar;
for (auto& entry : historiesIt->second)
{
if (lastTimestamp + pollingInterval < entry.first)
{
dataMap[id].push_back(TimeData(IceUtil::Time::microSeconds(entry.first), VariantPtr::dynamicCast(entry.second[identifier->datafieldName].value)));
lastTimestamp = entry.first;
}
}
} }
else else
{ {
...@@ -674,7 +700,42 @@ namespace armarx ...@@ -674,7 +700,42 @@ namespace armarx
bars[key] = bar; bars[key] = bar;
} }
} }
for (auto& entry : historiesIt->second)
{
if (lastTimestamp + pollingInterval < entry.first)
{
auto dict = JSONObject::ConvertToBasicVariantMap(json, entry.second[identifier->datafieldName].value);
for (const auto& e : dict)
{
if (e.first == "timestamp") // TimedVariants always contain a timestamp field which is irrelevant
{
continue;
}
std::string key = id + "." + e.first;
// ARMARX_INFO << key << ": " << *VariantPtr::dynamicCast(e.second);
VariantPtr var = VariantPtr::dynamicCast(e.second);
auto type = var->getType();
if (type == VariantType::String)
{
// complex contain additional strings often, which cannot be selected right now -> disable strings from complex types
// if (dataMap[id].size() == 0 || dataMap[id].rbegin()->data->getString() != var->getString())
// {
// // only insert if changed
// dataMap[id].push_back(TimeData(time, var));
// newData[key] = var;
// }
}
else
{
dataMap[key].push_back(TimeData(IceUtil::Time::microSeconds(entry.first), var));
}
}
}
}
} }
} }
catch (...) catch (...)
{ {
...@@ -822,7 +883,7 @@ namespace armarx ...@@ -822,7 +883,7 @@ namespace armarx
{ {
auto dict = JSONObject::ConvertToBasicVariantMap(json, var); auto dict = JSONObject::ConvertToBasicVariantMap(json, var);
for (const auto & e : dict) for (const auto& e : dict)
{ {
if (e.first == "timestamp") // TimedVariants always contain a timestamp field which is irrelevant if (e.first == "timestamp") // TimedVariants always contain a timestamp field which is irrelevant
{ {
...@@ -885,7 +946,7 @@ namespace armarx ...@@ -885,7 +946,7 @@ namespace armarx
{ {
logstream << (time - logStartTime).toMilliSecondsDouble() << ","; logstream << (time - logStartTime).toMilliSecondsDouble() << ",";
for (auto & channel : selectedChannels) for (auto& channel : selectedChannels)
{ {
logstream << dataMaptoAppend.at(channel.toStdString())->Variant::getOutputValueOnly(); logstream << dataMaptoAppend.at(channel.toStdString())->Variant::getOutputValueOnly();
if (!selectedChannels.endsWith(channel)) if (!selectedChannels.endsWith(channel))
......
...@@ -49,11 +49,11 @@ namespace armarx ...@@ -49,11 +49,11 @@ namespace armarx
* RobotStatePropertyDefinition Property Definitions * RobotStatePropertyDefinition Property Definitions
*/ */
class RobotStateObserverPropertyDefinitions: class RobotStateObserverPropertyDefinitions:
public ComponentPropertyDefinitions public ObserverPropertyDefinitions
{ {
public: public:
RobotStateObserverPropertyDefinitions(std::string prefix): RobotStateObserverPropertyDefinitions(std::string prefix):
ComponentPropertyDefinitions(prefix) ObserverPropertyDefinitions(prefix)
{ {
defineOptionalProperty<std::string>("TCPsToReport", "", "comma seperated list of nodesets' endeffectors, which poses and velocities that should be reported. * for all, empty for none"); defineOptionalProperty<std::string>("TCPsToReport", "", "comma seperated list of nodesets' endeffectors, which poses and velocities that should be reported. * for all, empty for none");
} }
......
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