33 ui->treeWidget->setColumnCount(4);
34 QTreeWidgetItem* head =
ui->treeWidget->headerItem();
39 head->setToolTip(
idxName,
"The control device's name");
40 head->setToolTip(
idxTags,
"The control device's tags");
41 head->setToolTip(
idxValType,
"The sensor value's' type");
42 head->setToolTip(
idxValue,
"The sensor value");
43 ui->treeWidget->setColumnWidth(
idxName, 150);
44 ui->treeWidget->setColumnWidth(
idxTags, 100);
55 std::unique_lock<std::recursive_timed_mutex> guard {
mutex, std::defer_lock};
56 if (!guard.try_lock_for(std::chrono::microseconds(100)))
60 for (
const auto&
status : allStatus)
62 if (statusUpdates[
status.deviceName].timestampUSec <
status.timestampUSec)
67 QMetaObject::invokeMethod(
this,
"updateContent", Qt::QueuedConnection);
76 statusUpdates.clear();
82 for (
const auto& pair : statusUpdates)
84 if (!entries.count(pair.second.deviceName))
86 add(
robotUnit->getSensorDeviceDescription(pair.second.deviceName));
88 entries.at(pair.second.deviceName)->update(pair.second);
90 statusUpdates.clear();
95 auto temp =
robotUnit->getSensorDeviceDescriptions();
97 std::unique_lock<std::recursive_timed_mutex> guard {
mutex};
98 resetData = std::move(temp);
104 if (resetData.empty())
108 add(resetData.back());
109 resetData.pop_back();
113 void SensorDevicesWidget::add(
const SensorDeviceDescription& desc)
115 std::unique_lock<std::recursive_timed_mutex> guard {
mutex};
116 if (!entries.count(desc.deviceName))
118 entries[desc.deviceName] =
new SensorDevicesWidgetEntry(*
this, *(
ui->treeWidget), desc);
125 header =
new QTreeWidgetItem;
126 treeWidget.addTopLevelItem(header);
130 QCheckBox* boxTags =
new QCheckBox{QString::number(desc.tags.size()) +
" Tags"};
133 boxTags->setChecked(
false);
134 connect(boxTags, SIGNAL(clicked(
bool)),
this, SLOT(hideTagList(
bool)));
135 for (
const auto& tag : desc.tags)
137 QTreeWidgetItem* child =
new QTreeWidgetItem {{QString::fromStdString(tag)}};
138 treeWidget.addTopLevelItem(child);
139 tags.emplace_back(child);
143 value =
new VariantWidget;
144 QTreeWidgetItem* valchild =
new QTreeWidgetItem;
145 header->addChild(valchild);
152 value->layout()->setContentsMargins(0, 0, 0, 0);
162 for (
const auto& tagit : tags)
183 header->setHidden(!vis);
186 void SensorDevicesWidgetEntry::hideTagList(
bool hide)
188 for (QTreeWidgetItem* tag : tags)
190 tag->setHidden(hide);