11 Commits
v1.3 ... v1.5

Author SHA1 Message Date
d0966cfcc7 修正ci拉取代码步骤。
All checks were successful
Release tag / build (push) Successful in 2m53s
2024-11-14 12:15:48 +08:00
d6a36c0450 完善CI构建。
Some checks failed
Release tag / build (push) Failing after 49s
2024-11-14 12:11:59 +08:00
27e5db45d6 减小打包体积。 2024-11-14 11:20:32 +08:00
51f9a2af52 打包时显示版本号。 2024-11-13 14:54:14 +08:00
0b3198c90e 修正编译条件。 2024-11-13 14:40:10 +08:00
f55d3aa9df 实现视频旋转及翻转指令控制。 2024-11-13 14:25:22 +08:00
bf3ad2be2f 修改升级文件校验。 2024-10-21 19:35:49 +08:00
f230e4cc8b update ffmpeg ver. 2024-10-21 17:00:48 +08:00
baa991dba0 fix build env.
All checks were successful
Release tag / build (push) Successful in 3m2s
2024-10-15 18:58:02 +08:00
b46cd406a7 支持CI构建。
Some checks failed
Release tag / build (push) Failing after 17s
2024-10-15 18:14:21 +08:00
6810dbd801 增加设备发现过滤配置,以灵活支持T013以及后续型号。 2024-10-15 17:48:51 +08:00
12 changed files with 433 additions and 54 deletions

View File

@ -0,0 +1,33 @@
name: Release tag
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: [windows11]
steps:
- name: Clone repository
run: |
$ref = "${{ github.ref }}"
if ($ref -like 'refs/heads/*') {
$branch = $ref -replace '^refs/heads/', ''
} elseif ($ref -like 'refs/tags/*') {
$branch = $ref -replace '^refs/tags/', ''
} else {
$branch = $ref
}
git clone --depth 1 --branch=$branch https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_PASSWORD }}@amass.fun/gitea/${{ gitea.repository }}.git .
git checkout ${{ github.sha }}
- name: Build and deploy
run: |
resources/build.ps1 build
resources/build.ps1 deploy
resources/build.ps1 changelog
- name: Upload Gitea Release
uses: akkuman/gitea-release-action@v1
with:
body_path: build/CHANGELOG.txt
files: |-
build/视觉防夹设备上位机工具*.zip

View File

@ -40,7 +40,7 @@ Application::Application(int &argc, char **argv)
font.setFamily("微软雅黑");
m_app->setFont(font);
m_app->setApplicationName(APPLICATION_NAME);
m_app->setApplicationVersion(QString("V%1").arg(APP_VERSION));
m_app->setApplicationVersion(QString("v%1").arg(APP_VERSION));
m_player->open();
}
@ -164,6 +164,35 @@ void Application::updateShieldedAreaPoints(const QList<QPointF> &points) {
}
}
bool Application::currentDeviceFlip() const {
return m_currentDeviceFlip;
}
void Application::setCurrentDeviceFlip(bool flip) {
if (m_currentDeviceFlip != flip) {
m_currentDeviceFlip = flip;
emit currentDeviceFlipChanged();
if (!m_device.expired()) {
auto device = m_device.lock();
device->updateFlip(flip);
}
}
}
int Application::currentDeviceRotation() const {
return m_currentDeviceRotation;
}
void Application::setCurrentDeviceRotation(int rotation) {
if (m_currentDeviceRotation != rotation) {
m_currentDeviceRotation = rotation;
emit currentDeviceRotationChanged();
if (!m_device.expired()) {
auto device = m_device.lock();
device->updateRotation(rotation);
}
}
}
void Application::updateNetworkInfomation(bool dhcp, const QString &ip, const QString &netmask, const QString &gateway,
const QString &dns) {
if (!m_device.expired()) {
@ -180,6 +209,8 @@ void Application::updateNetworkInfomation(bool dhcp, const QString &ip, const QS
void Application::connectToDevice(int index) {
if (!m_device.expired()) {
auto device = m_device.lock();
disconnect(device.get(), &DeviceConnection::rotationChanged, this, &Application::onDeviceRotationChanged);
disconnect(device.get(), &DeviceConnection::flipChanged, this, &Application::onDeviceFlipChanged);
disconnect(device.get(), &DeviceConnection::openDoorAreaChanged, this, &Application::onDeviceOpenDoorArea);
disconnect(device.get(), &DeviceConnection::shieldedAreaChanged, this, &Application::onDeviceShieldedArea);
disconnect(device.get(), &DeviceConnection::antiClipAreaChanged, this, &Application::onDeviceAntiClipArea);
@ -202,6 +233,8 @@ void Application::connectToDevice(int index) {
auto device = m_devices->device(index);
m_device = device;
connect(device.get(), &DeviceConnection::rotationChanged, this, &Application::onDeviceRotationChanged);
connect(device.get(), &DeviceConnection::flipChanged, this, &Application::onDeviceFlipChanged);
connect(device.get(), &DeviceConnection::openDoorAreaChanged, this, &Application::onDeviceOpenDoorArea);
connect(device.get(), &DeviceConnection::shieldedAreaChanged, this, &Application::onDeviceShieldedArea);
connect(device.get(), &DeviceConnection::antiClipAreaChanged, this, &Application::onDeviceAntiClipArea);
@ -220,16 +253,20 @@ void Application::connectToDevice(int index) {
}
});
device->setLiveStreamEnabled(true);
auto area = device->area();
m_currentOpenDoorAreaWay = area.openDoorAreaWay;
m_currentOpenDoorAreaPoints = area.openDoorArea;
m_currentShieldedAreaEnabled = area.shieldedAreaEnabled;
m_currentShieldedAreaPoints = area.shieldedArea;
m_currentAntiClipAreaEnabled = area.antiClipAreaEnabled;
m_currentAntiClipAreaPoints = area.antiClipArea;
auto info = device->infomation();
m_currentOpenDoorAreaWay = info.openDoorAreaWay;
m_currentOpenDoorAreaPoints = info.openDoorArea;
m_currentShieldedAreaEnabled = info.shieldedAreaEnabled;
m_currentShieldedAreaPoints = info.shieldedArea;
m_currentAntiClipAreaEnabled = info.antiClipAreaEnabled;
m_currentAntiClipAreaPoints = info.antiClipArea;
m_currentNetworkInfomation = device->networkInfomation();
m_currentFirmware = device->infomation().firmwareVersion;
m_currentDeviceConnected = device->isConnected();
m_currentDeviceFlip = info.flip;
m_currentDeviceRotation = info.rotation;
emit currentDeviceRotationChanged();
emit currentDeviceFlipChanged();
emit currentOpenDoorAreaPointsChanged();
emit currentShieldedAreaPointsChanged();
emit currentAntiClipAreaPointsChanged();
@ -248,23 +285,24 @@ void Application::startSearchDevice() {
}
void Application::upgradeDevice(const QString &file) {
constexpr auto versionPrefix = "RD_T009";
if (m_device.expired()) return;
auto device = m_device.lock();
auto infomation = device->infomation();
auto versionPrefix = infomation.softwareVersion.left(7);
constexpr auto version = "RD_T009_V21R003B013";
QFileInfo fileInfo(file);
QString baseName = fileInfo.baseName();
int position = baseName.indexOf(versionPrefix);
if (position < 0 || ((baseName.length() - position) < std::strlen(version))) {
emit newMessage(2, "OTA升级", "文件名格式不合法!");
LOG(error) << "baseName: " << baseName.toStdString() << ", position: " << position;
return;
}
QString firmware = baseName.mid(position, std::strlen(version));
if (!m_device.expired()) {
auto device = m_device.lock();
if (device->isConnected()) {
device->requestOta(firmware, file);
} else {
emit newMessage(2, "OTA升级", "设备已离线,请重新连接设备!");
}
QString firmware = baseName.mid(position);
if (device->isConnected()) {
device->requestOta(firmware, file);
} else {
emit newMessage(2, "OTA升级", "设备已离线,请重新连接设备!");
}
}
@ -273,6 +311,13 @@ void Application::onDeviceOpenDoorArea(DeviceConnection::AreaWay way, const QLis
setCurrentOpenDoorAreaPoints(points);
}
void Application::onDeviceRotationChanged(int rotation) {
setCurrentDeviceRotation(rotation);
}
void Application::onDeviceFlipChanged(bool flip) {
setCurrentDeviceFlip(flip);
}
void Application::onDeviceShieldedArea(bool enabled, const QList<QPointF> &points) {
setCurrentShieldedAreaEnabled(enabled);
setCurrentShieldedAreaPoints(points);

View File

@ -40,6 +40,10 @@ class Application : public QObject {
NetworkInfomation currentNetworkInfomation READ currentNetworkInfomation NOTIFY currentNetworkInfomationChanged)
Q_PROPERTY(QString currentFirmware MEMBER m_currentFirmware NOTIFY currentFirmwareChanged)
Q_PROPERTY(bool currentDeviceConnected MEMBER m_currentDeviceConnected NOTIFY currentDeviceConnectedChanged)
Q_PROPERTY(bool currentDeviceFlip READ currentDeviceFlip WRITE setCurrentDeviceFlip NOTIFY currentDeviceFlipChanged)
Q_PROPERTY(int currentDeviceRotation READ currentDeviceRotation WRITE setCurrentDeviceRotation NOTIFY
currentDeviceRotationChanged)
friend class Amass::Singleton<Application>;
public:
@ -64,6 +68,12 @@ public:
QList<QPointF> currentAntiClipAreaPoints() const;
void setCurrentAntiClipAreaPoints(const QList<QPointF> &points);
bool currentDeviceFlip() const;
void setCurrentDeviceFlip(bool flip);
int currentDeviceRotation() const;
void setCurrentDeviceRotation(int rotation);
Q_INVOKABLE void updateOpenDoorAreaPoints(const QList<QPointF> &points);
Q_INVOKABLE void updateAntiClipAreaPoints(const QList<QPointF> &points);
Q_INVOKABLE void updateShieldedAreaPoints(const QList<QPointF> &points);
@ -88,10 +98,14 @@ signals:
void currentFirmwareChanged();
void currentDeviceConnectedChanged();
void currentDeviceOtaProgressChanged(bool status, int progress, const QString &message);
void currentDeviceFlipChanged();
void currentDeviceRotationChanged();
void newMessage(int type, const QString &title, const QString &message);
protected:
Application(int &argc, char **argv);
void onDeviceRotationChanged(int rotation);
void onDeviceFlipChanged(bool flip);
void onDeviceOpenDoorArea(DeviceConnection::AreaWay way, const QList<QPointF> &points);
void onDeviceShieldedArea(bool enabled, const QList<QPointF> &points);
void onDeviceAntiClipArea(bool enabled, const QList<QPointF> &points);
@ -118,6 +132,8 @@ private:
NetworkInfomation m_currentNetworkInfomation;
QString m_currentFirmware;
bool m_currentDeviceConnected = false;
bool m_currentDeviceFlip = false;
int m_currentDeviceRotation = 0;
};
#endif // APPLICATION_H

View File

@ -1,13 +1,12 @@
cmake_minimum_required(VERSION 3.16)
project(AntiClipSettings VERSION 1.3 LANGUAGES C CXX)
project(AntiClipSettings VERSION 1.5 LANGUAGES C CXX)
set(APPLICATION_NAME "视觉防夹设备上位机工具")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(Projects_ROOT E:/Projects)
set(Libraries_ROOT ${Projects_ROOT}/Libraries)
set(Libraries_ROOT E:/Projects/Libraries CACHE STRING "Libraries directory.")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick Network QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick Network QuickControls2)
@ -19,6 +18,7 @@ if (Qt6_FOUND)
add_compile_definitions(
BOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN10
)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.2-full_build-shared)
else()
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
@ -26,18 +26,29 @@ else()
set(CMAKE_AUTORCC ON)
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_83_0_msvc2022_64bit)
set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_83)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-6.1.1-full_build-shared)
endif()
option(Boost_USE_STATIC_LIBS OFF)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-6.1.1-full_build-shared)
set(OpenSSL_ROOT D:/Qt/Tools/OpenSSLv3/Win_x64)
set(OPENSSL_INCLUDE_DIR ${OpenSSL_ROOT}/include)
set(OpenSSL_LIBRARY_DIRS ${OpenSSL_ROOT}/lib)
set(OpenSSL_LIBRARIES libssl libcrypto)
set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_debug)
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_debug)
else()
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_release)
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_release)
endif()
set(MBEDTLS_INCLUDE_DIR ${MBEDTLS_ROOT}/include)
set(MBEDTLS_LIBRARY_DIRS ${MBEDTLS_ROOT}/lib)
set(JPEGTURBO_INCLUDE_DIR ${JPEGTURBO_ROOT}/include)
set(JPEGTURBO_LIB_DIR ${JPEGTURBO_ROOT}/lib)
@ -95,8 +106,13 @@ set_target_properties(AntiClipSettings PROPERTIES
WIN32_EXECUTABLE TRUE
)
add_subdirectory(${Projects_ROOT}/Kylin/Universal Universal)
add_subdirectory(${Projects_ROOT}/Kylin/Encrypt Encrypt)
include(CPack)
include(FetchContent)
FetchContent_Declare(Kylin
GIT_REPOSITORY https://amass.fun/gitea/amass/Kylin.git
)
set(KYLIN_WITH_FLUENT OFF)
FetchContent_MakeAvailable(Kylin)
target_include_directories(AntiClipSettings
PRIVATE ${FFmpeg_INCLUDE_DIR}

View File

@ -73,10 +73,6 @@ void DeviceConnection::connect(const Infomation &infomation) {
m_h264Socket->connectToHost(infomation.ip, 8000);
}
DeviceConnection::Area DeviceConnection::area() const {
return m_area;
}
NetworkInfomation DeviceConnection::networkInfomation() const {
return m_networkInfomation;
}
@ -262,6 +258,44 @@ void DeviceConnection::requestResolution(Resolution resolution) {
m_requests.push(task);
}
void DeviceConnection::updateRotation(int rotation) {
Task task;
task.command = "a23imagerotate_setdata";
task.task = [this, rotation]() {
boost::json::object request;
request["func"] = "a23imagerotate_setdata";
request["deviceid"] = "0";
boost::json::object data;
data["value"] = std::to_string(rotation);
request["data"] = std::move(data);
auto text = boost::json::serialize(request);
m_commandSocket->write(text.data(), text.size());
LOG(info) << "updateRotation: " << text;
};
if (m_requests.empty()) {
task.task();
}
m_requests.push(task);
}
void DeviceConnection::updateFlip(bool flip) {
Task task;
task.command = "a04imageflipping_setdata";
task.task = [this, flip]() {
boost::json::object request;
request["func"] = "a04imageflipping_setdata";
request["deviceid"] = "0";
boost::json::object data;
data["value"] = flip ? "2" : "1";
request["data"] = std::move(data);
auto text = boost::json::serialize(request);
m_commandSocket->write(text.data(), text.size());
};
if (m_requests.empty()) {
task.task();
}
m_requests.push(task);
}
void DeviceConnection::requestVersion() {
Task task;
task.command = "a15devicedetail_getdata";
@ -281,6 +315,27 @@ void DeviceConnection::requestVersion() {
m_requests.push(task);
}
void DeviceConnection::requestVideoInformation() {
constexpr const char *commands[] = {"a23imagerotate_getdata", "a04imageflipping_getdata"};
for (auto command : commands) {
Task task;
task.command = command;
task.task = [this, command]() {
boost::json::object request;
request["func"] = command;
request["deviceid"] = "0";
boost::json::object data;
request["data"] = std::move(data);
auto text = boost::json::serialize(request);
m_commandSocket->write(text.data(), text.size());
};
if (m_requests.empty()) {
task.task();
}
m_requests.push(task);
}
}
void DeviceConnection::requestNetworkInfomation() {
Task task;
task.command = "netconfig_getdata";
@ -407,18 +462,6 @@ void DeviceConnection::transferBinContent() {
} else if (m_sendedSize >= m_uploadBuffer.size()) {
LOG(info) << "transfer ota file finished, wait " << WaitMd5CheckTime
<< " ms for send check, total sended size: " << m_sendedSize;
// QTimer::singleShot(WaitMd5CheckTime, this, [this]() {
// boost::json::object request;
// request["func"] = "a22devicefirmware_setdata";
// request["deviceid"] = "0";
// boost::json::object data;
// data["target_linux04_firmware"] = "RD_T009_V21R003B001";
// request["data"] = std::move(data);
// auto text = boost::json::serialize(request);
// m_commandSocket->write(text.data(), text.size());
// LOG(info) << "request md5 check result: " << text;
// });
if (m_otaTimer == nullptr) {
m_otaTimer = new QTimer(this);
m_otaTimer->setSingleShot(true);
@ -469,8 +512,8 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const
} else if (value == "2") {
way = Quadrangle;
}
m_area.openDoorAreaWay = way;
m_area.openDoorArea = points;
m_infomation.openDoorAreaWay = way;
m_infomation.openDoorArea = points;
emit openDoorAreaChanged(way, points);
} else if (function == "a03opendoor4_getdata") {
auto &data = reply.at("data").as_object();
@ -484,8 +527,8 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const
point.setY(obj.at("y").as_double());
points.push_back(point);
}
m_area.shieldedAreaEnabled = value == "1";
m_area.shieldedArea = points;
m_infomation.shieldedAreaEnabled = value == "1";
m_infomation.shieldedArea = points;
emit shieldedAreaChanged(value == "1", points);
} else if (function == "a03opendoor5_getdata") {
auto &data = reply.at("data").as_object();
@ -499,8 +542,8 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const
point.setY(obj.at("y").as_double());
points.push_back(point);
}
m_area.antiClipAreaEnabled = value == "1";
m_area.antiClipArea = points;
m_infomation.antiClipAreaEnabled = value == "1";
m_infomation.antiClipArea = points;
emit antiClipAreaChanged(value == "1", points);
} else if (function == "netconfig_getdata") {
auto &data = reply.at("data").as_object();
@ -591,6 +634,40 @@ QString DeviceConnection::handleCommand(const std::string_view &replyText, const
}
emit otaProgressChanged(false, m_otaProgress, tip);
}
} else if (function == "a23imagerotate_getdata") {
// {"data":{"value":"2"},"deviceid":"0","flag":"ok","func":"a23imagerotate_getdata"}
auto &data = reply.at("data").as_object();
auto &value = data.at("value").as_string();
m_infomation.rotation = std::stoi(static_cast<std::string>(value));
emit rotationChanged(m_infomation.rotation);
} else if (function == "a04imageflipping_getdata") {
// {"data":{"value":"1"},"deviceid":"0","flag":"ok","func":"a04imageflipping_getdata"}
auto &data = reply.at("data").as_object();
auto &value = data.at("value").as_string();
m_infomation.flip = value == "2";
emit flipChanged(m_infomation.flip);
} else if (function == "a04imageflipping_setdata") {
if ((task != nullptr) && (task->command.toStdString() == function)) {
if (task->timeoutTimer) {
task->timeoutTimer->stop();
}
bool status = true;
if (task->future) {
task->future->reportFinished(&status);
}
}
requestVideoInformation();
} else if (function == "a23imagerotate_setdata") {
if ((task != nullptr) && (task->command.toStdString() == function)) {
if (task->timeoutTimer) {
task->timeoutTimer->stop();
}
bool status = true;
if (task->future) {
task->future->reportFinished(&status);
}
}
requestVideoInformation();
} else {
LOG(warning) << "unknown reply: " << replyText;
}
@ -605,6 +682,7 @@ void DeviceConnection::onConnected() {
requestShieldedArea();
requestAntiClipArea();
requestNetworkInfomation();
requestVideoInformation();
emit connected();
m_timerId = startTimer(2500);
if (m_otaProgress == 99) {

View File

@ -34,11 +34,10 @@ public:
QString softwareVersion;
QString firmwareVersion;
QString ip;
};
Q_ENUM(AreaWay)
class Area {
public:
int rotation = 0;
bool flip = false;
QList<QPointF> openDoorArea;
AreaWay openDoorAreaWay;
@ -48,6 +47,7 @@ public:
QList<QPointF> antiClipArea;
bool antiClipAreaEnabled;
};
Q_ENUM(AreaWay)
using H264FrameCallback = std::function<void(const char *data, uint32_t size)>;
DeviceConnection(QObject *parent = nullptr);
@ -60,7 +60,6 @@ public:
void setLiveStreamEnabled(bool enabled);
NetworkInfomation networkInfomation() const;
Area area() const;
void requestOpenDoorArea();
QFuture<bool> updateOpenDoorAreaPoints(AreaWay way, const QList<QPointF> &points);
@ -73,6 +72,9 @@ public:
QFuture<bool> updateNetworkInfomation(bool dhcp, const QString &ip, const QString &netmask, const QString &gateway,
const QString &dns);
void requestVersion();
void requestVideoInformation();
void updateRotation(int rotation);
void updateFlip(bool flip);
/**
* @brief 对设备升级OTA,主要有几个步骤
@ -91,6 +93,8 @@ signals:
void openDoorAreaChanged(AreaWay way, const QList<QPointF> &points);
void shieldedAreaChanged(bool enabled, const QList<QPointF> &points);
void antiClipAreaChanged(bool enabled, const QList<QPointF> &points);
void rotationChanged(int rotation);
void flipChanged(bool flip);
void networkInfomationChanged(const NetworkInfomation &info);
void firmwareChanged(const QString &firmware);
void otaProgressChanged(bool status, int progress, const QString &message);
@ -133,7 +137,6 @@ private:
std::queue<Task> m_requests;
int m_timerId = -1;
int heartbeats = 0;
Area m_area;
NetworkInfomation m_networkInfomation;
QString m_firmware;
};

View File

@ -1,6 +1,7 @@
#include "DeviceListModel.h"
#include "BoostLog.h"
#include "DeviceConnection.h"
#include "Settings.h"
#include <QNetworkDatagram>
#include <QNetworkInterface>
#include <QTimer>
@ -186,6 +187,7 @@ void DeviceListModel::onDeviceDisconnected() {
}
void DeviceListModel::onDeviceReplyReadyRead() {
using namespace Amass;
auto udp = dynamic_cast<QUdpSocket *>(sender());
while (udp->hasPendingDatagrams()) {
QNetworkDatagram datagram = udp->receiveDatagram();
@ -202,7 +204,12 @@ void DeviceListModel::onDeviceReplyReadyRead() {
if (reply.contains("sw_ver")) {
device.softwareVersion = QString::fromStdString(std::string(reply.at("sw_ver").as_string()));
}
if (!device.softwareVersion.startsWith("RD_T009")) continue; // 其它设备不予显示
auto settings = Singleton<Settings>::instance();
auto supportedDevices = settings->supportedDevices();
auto item = std::find_if(supportedDevices.cbegin(), supportedDevices.cend(), [&device](const std::string &model) {
return device.softwareVersion.startsWith(QString::fromStdString(model));
});
if (item == supportedDevices.cend()) continue; // 其它设备不予显示
device.ip = datagram.senderAddress().toString();
auto iterator = std::find_if(m_devices.cbegin(), m_devices.cend(),

View File

@ -25,20 +25,36 @@ void Settings::save() {
ptree.put("Application.DataCollection.ImageQuality", m_imageQuality);
ptree.put("Application.DataCollection.ImageQuality.<xmlcomment>", "0-100,仅对jpg有效");
for (auto &device : m_supportedDevices) {
ptree.add("Application.SupportedDevices.Model", device);
}
boost::property_tree::xml_writer_settings<std::string> settings('\t', 1);
boost::property_tree::write_xml(SettingsFilePath, ptree, std::locale(), settings);
}
void Settings::load() {
boost::property_tree::ptree ptree;
m_supportedDevices.clear();
try {
boost::property_tree::read_xml(SettingsFilePath, ptree);
m_imageFormat = static_cast<ImageFormat>(ptree.get<int>("Application.DataCollection.ImageFormat"));
m_imageQuality = ptree.get<int>("Application.DataCollection.ImageQuality");
for (auto &child : ptree.get_child("Application.SupportedDevices")) {
if (child.first != "Model") continue;
m_supportedDevices.push_back(child.second.get<std::string>(""));
}
} catch (...) {
LOG(error) << "parse " << SettingsFilePath << " failed.";
}
LOG(info) << "image format: " << m_imageFormat << ", quality: " << m_imageQuality;
std::ostringstream oss;
oss << "[";
for (auto &device : m_supportedDevices) {
oss << device << ", ";
}
oss << "]";
LOG(info) << "image format: " << m_imageFormat << ", quality: " << m_imageQuality
<< ", supported devices: " << oss.str();
}
ImageFormat Settings::imageFormat() const {
@ -48,3 +64,7 @@ ImageFormat Settings::imageFormat() const {
int Settings::imageQuality() const {
return m_imageQuality;
}
std::list<std::string> Settings::supportedDevices() const {
return m_supportedDevices;
}

View File

@ -12,6 +12,7 @@ public:
void load();
ImageFormat imageFormat() const;
int imageQuality() const;
std::list<std::string> supportedDevices() const;
protected:
Settings();
@ -19,6 +20,7 @@ protected:
private:
ImageFormat m_imageFormat = ImageFormat::Jpeg; // 0: jpg 1: yuv
int m_imageQuality = 100;
std::list<std::string> m_supportedDevices{"RD_T009", "RD_T013"};
};
#endif // SETTINGS_H

View File

@ -16,6 +16,9 @@ Item {
property color antiClipAreaColor: "blue"
property var antiClipAreaPoints: []
property bool antiClipAreaEnabled: false
property alias flip: flipSwitch.checked
property alias videoRotation: rotateComboBox.currentIndex
Item {
anchors.left: parent.left
anchors.right: parent.right
@ -246,6 +249,35 @@ Item {
columns: 2
spacing: 10
verticalItemAlignment: Qt.AlignVCenter
Label { text: qsTr("图像: ") }
Row {
enabled: root.enabled
Label {
anchors.verticalCenter: parent.verticalCenter
text: qsTr("旋转")
}
Item {width: 10; height:10}
ComboBox {
id: rotateComboBox
model: ["0°","90°","180°","270°"]
onCurrentIndexChanged: {
App.currentDeviceRotation = rotateComboBox.currentIndex
}
}
Item {width: 70; height:10}
Label {
anchors.verticalCenter: parent.verticalCenter
text: qsTr("翻转")
}
Item {width: 10; height:10}
Switch {
id: flipSwitch
onToggled: App.currentDeviceFlip=flipSwitch.checked
}
}
Label {
text: qsTr("开门区域: ")
}

View File

@ -80,7 +80,7 @@ ApplicationWindow {
deviceList.currentIndex = index
}
onDoubleClicked: {
if (!softwareVersion.includes("R003")) {
if (softwareVersion.includes("T009") && !softwareVersion.includes("R003")) {
showMessageDialog(2, "网络设置", "当前设备不支持有线网络设置!")
} else if (onlineStatus) {
networkPopup.open()
@ -119,6 +119,8 @@ ApplicationWindow {
shieldedAreaPoints: App.currentShieldedAreaPoints
antiClipAreaEnabled: App.currentAntiClipAreaEnabled
antiClipAreaPoints: App.currentAntiClipAreaPoints
flip: App.currentDeviceFlip
videoRotation: App.currentDeviceRotation
}
NetworkSettingPopup {

125
resources/build.ps1 Normal file
View File

@ -0,0 +1,125 @@
param($type)
# 该脚本设置为 UTF8-bom 编码即可支持中文
$MsvcScript = 'D:\Program Files\Microsoft Visual Studio\2022\\Community\Common7\Tools\Launch-VsDevShell.ps1'
if (!(Test-Path $MsvcScript)) { $MsvcScript = 'D:\Program Files\Microsoft Visual Studio\2022\\Professional\Common7\Tools\Launch-VsDevShell.ps1' }
. $MsvcScript -SkipAutomaticLocation -Arch amd64
$qtHome = "D:\Qt\5.15.2\msvc2019_64"
$openSSLRoot = "D:\Qt\Tools\OpenSSLv3\Win_x64"
$librariesPath = "E:\Projects\Libraries"
if (!(Test-Path $librariesPath)) { $librariesPath = "D:\Projects\Libraries" }
$boostRoot = "$librariesPath\boost_1_83_0_msvc2022_64bit"
# 6.1.1 版本支持 windows7
$ffmpegRoot = "$librariesPath\ffmpeg-6.1.1-full_build-shared"
$projectPath = Get-Location
$buildPath = Join-Path -Path $projectPath -ChildPath "build"
$fileContent = (Get-Content -Path "CMakeLists.txt") -join " "
if ($fileContent -match 'project\([^\)]+VERSION\s+([0-9]+\.[0-9]+)') {
$version = $Matches[1]
} else {
Write-Output "未找到版本号"
}
$deployPath = Join-Path -Path $buildPath -ChildPath "视觉防夹设备上位机工具v$version"
$zipFilePath = Join-Path -Path $buildPath -ChildPath "视觉防夹设备上位机工具v$version.zip"
$changelogPath = Join-Path -Path $buildPath -ChildPath "CHANGELOG.txt"
function Build() {
if (!(Test-Path $buildPath\CMakeCache.txt)) {
cmake.exe -G Ninja -S . -B build `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_PREFIX_PATH=$qtHome `
-DQT_DIR="$qtHome\lib\cmake\Qt5" `
-DQt5_DIR="$qtHome\lib\cmake\Qt5" `
-DLibraries_ROOT="$librariesPath"
}
cmake.exe --build $buildPath --target all
}
function Deploy() {
if (Test-Path $deployPath) {
Remove-Item $deployPath -Recurse -Force
}
New-Item $deployPath -ItemType Directory
Copy-Item $buildPath\AntiClipSettings.exe $deployPath\视觉防夹设备上位机工具v$version.exe
& $qtHome\bin\windeployqt.exe $deployPath\视觉防夹设备上位机工具v$version.exe --qmldir=$qtHome\qml
Remove-Item -Path $deployPath\d3dcompiler_47.dll -Force
Remove-Item -Path $deployPath\Qt5RemoteObjects.dll -Force
Remove-Item -Path $deployPath\Qt5QuickTest.dll -Force
Remove-Item -Path $deployPath\translations -Recurse -Force # 暂时不需要翻译文件
Remove-Item -Path $deployPath\qmltooling -Recurse -Force
Remove-Item -Path $deployPath\QtTest -Recurse -Force
Remove-Item -Path $deployPath\QtGraphicalEffects -Recurse -Force
# $modules = "QmlCore"
# foreach ($module in $modules) {
# Copy-Item -Path $qtHome\bin\Qt6$module.dll -Destination $deployPath
# }
# if (-Not (Test-Path -Path $deployPath\qml\QtCore)) {
# New-Item $deployPath\qml\QtCore -ItemType Directory
# $plugins = "qtqmlcoreplugin.dll", "qmldir", "plugins.qmltypes"
# foreach ($plugin in $plugins) {
# Copy-Item -Path $QtHome\qml\QtCore\$plugin -Destination $deployPath\qml\QtCore
# }
# }
Copy-Item $openSSLRoot\bin\libssl-3-x64.dll $deployPath
Copy-Item $openSSLRoot\bin\libcrypto-3-x64.dll $deployPath
$boosts = "atomic", "thread", "filesystem", "log", "json"
foreach ($boost in $boosts) {
Copy-Item -Path $boostRoot\lib\boost_$boost-vc143-mt-x64-1_83.dll -Destination $deployPath
}
# 暂时不需要 avfilter-9、avformat-60
$ffmpegs = "avcodec-60", "avdevice-60", "avutil-58", "postproc-57", "swresample-4", "swscale-7"
foreach ($ffmpeg in $ffmpegs) {
Copy-Item -Path $ffmpegRoot\bin\$ffmpeg.dll -Destination $deployPath
}
Compress-Archive -Path $deployPath -DestinationPath $zipFilePath -Force
}
function Clean() {
if (Test-Path $buildPath) {
Remove-Item $buildPath -Recurse -Force
}
}
function Changelog() {
$commit_message = git log -1 --pretty=format:"%B"
Write-Output "Latest commit message:"
Write-Output $commit_message
$commit_message | Out-File -FilePath $changelogPath -Encoding utf8
Write-Output "Commit message has been written to $changelogPath"
}
switch ($type) {
"build" {
Build
}
"deploy" {
Deploy
}
"clean" {
Clean
}
"installer" {
Installer
}
"changelog" {
Changelog
}
"update" {
UpdateServer
}
}