实现安全帽阈值下发控制。
This commit is contained in:
parent
559867bd31
commit
dbe7c1a64e
@ -240,7 +240,7 @@ void DeviceConnection::updateAntiClipAreaPoints(bool enabled, const QList<QPoint
|
||||
m_requests.push(task);
|
||||
}
|
||||
|
||||
void DeviceConnection::updateHelmetThreshold(int threshold) {
|
||||
QFuture<bool> DeviceConnection::updateHelmetThreshold(int threshold) {
|
||||
constexpr auto command = "thresholdwithhat_setdata";
|
||||
Task task;
|
||||
task.command = command;
|
||||
@ -254,10 +254,13 @@ void DeviceConnection::updateHelmetThreshold(int threshold) {
|
||||
auto text = boost::json::serialize(request);
|
||||
m_commandSocket->write(text.data(), text.size());
|
||||
};
|
||||
task.future = std::make_shared<QFutureInterface<bool>>();
|
||||
if (m_requests.empty()) {
|
||||
task.task();
|
||||
}
|
||||
auto ret = task.future->future();
|
||||
m_requests.push(task);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DeviceConnection::requestHelmetThreshold() {
|
||||
@ -741,6 +744,16 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const
|
||||
auto &value = data.at("value").as_int64();
|
||||
m_infomation.helmetThreshold = value;
|
||||
emit helmetThresholdChanged(m_infomation.helmetThreshold);
|
||||
} else if (function == "thresholdwithhat_setdata") {
|
||||
if ((task != nullptr) && (task->command.toStdString() == function)) {
|
||||
if (task->timeoutTimer) {
|
||||
task->timeoutTimer->stop();
|
||||
}
|
||||
bool status = true;
|
||||
if (task->future) {
|
||||
task->future->reportFinished(&status);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG(warning) << "unknown reply: " << replyText;
|
||||
}
|
||||
@ -756,6 +769,7 @@ void DeviceConnection::onConnected() {
|
||||
requestAntiClipArea();
|
||||
requestNetworkInfomation();
|
||||
requestVideoInformation();
|
||||
requestHelmetThreshold();
|
||||
emit connected();
|
||||
m_heartbeatTimerId = startTimer(2500);
|
||||
if (m_otaProgress == 99) {
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
void updateAntiClipAreaPoints(bool enabled, const QList<QPointF> &points, int sensitivity);
|
||||
void requestResolution(Resolution resolution);
|
||||
void requestNetworkInfomation();
|
||||
void updateHelmetThreshold(int threshold);
|
||||
QFuture<bool> updateHelmetThreshold(int threshold);
|
||||
void requestHelmetThreshold();
|
||||
QFuture<bool> updateNetworkInfomation(bool dhcp, const QString &ip, const QString &netmask, const QString &gateway,
|
||||
const QString &dns);
|
||||
|
@ -17,6 +17,7 @@ Item {
|
||||
property var antiClipAreaPoints: []
|
||||
property bool antiClipAreaEnabled: false
|
||||
property int antiClipSensitivity: 1
|
||||
property alias helmetThreshold: helmetInput.text
|
||||
property alias flip: flipSwitch.checked
|
||||
property alias videoRotation: rotateComboBox.currentIndex
|
||||
|
||||
@ -335,6 +336,7 @@ Item {
|
||||
ComboBox {
|
||||
id: antiClipSensitivityComboBox
|
||||
enabled: root.enabled
|
||||
implicitWidth: 60
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
model: [1,2,3,4,5]
|
||||
currentIndex: root.antiClipSensitivity-1
|
||||
@ -343,12 +345,24 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Label { text: qsTr("安全帽灵敏度: ")
|
||||
Label { text: qsTr("安全帽阈值: ")
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
TextField {
|
||||
id: helmetInput
|
||||
enabled: root.enabled
|
||||
implicitWidth: 60
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
validator: IntValidator {
|
||||
bottom: 0
|
||||
top: 300
|
||||
}
|
||||
onAccepted: {
|
||||
if(App.currentHelmetThreshold !== parseInt(helmetInput.text)){
|
||||
App.currentHelmetThreshold= parseInt(helmetInput.text)
|
||||
window.showSuccess("设置成功",2500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {text: qsTr("屏蔽区域: ")}
|
||||
|
@ -48,7 +48,8 @@ ApplicationWindow {
|
||||
id: emptyHint
|
||||
visible: false
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("未搜索到设备")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("未搜索到设备\n请尝试关闭Windows防火墙后再重试")
|
||||
}
|
||||
delegate: Rectangle {
|
||||
width: deviceList.width
|
||||
@ -120,6 +121,7 @@ ApplicationWindow {
|
||||
antiClipAreaEnabled: App.currentAntiClipAreaEnabled
|
||||
antiClipSensitivity: App.currentAntiClipSensitivity
|
||||
antiClipAreaPoints: App.currentAntiClipAreaPoints
|
||||
helmetThreshold: App.currentHelmetThreshold
|
||||
flip: App.currentDeviceFlip
|
||||
videoRotation: App.currentDeviceRotation
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user