Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
baa991dba0 | |||
b46cd406a7 | |||
6810dbd801 |
23
.gitea/workflows/release_windows.yaml
Normal file
23
.gitea/workflows/release_windows.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
name: Release tag
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [windows11]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- 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/AntiClipSettings.zip
|
@ -248,7 +248,10 @@ 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();
|
||||
@ -258,13 +261,10 @@ void Application::upgradeDevice(const QString &file) {
|
||||
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升级", "设备已离线,请重新连接设备!");
|
||||
}
|
||||
if (device->isConnected()) {
|
||||
device->requestOta(firmware, file);
|
||||
} else {
|
||||
emit newMessage(2, "OTA升级", "设备已离线,请重新连接设备!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(AntiClipSettings VERSION 1.3 LANGUAGES C CXX)
|
||||
project(AntiClipSettings VERSION 1.4 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)
|
||||
@ -29,7 +28,12 @@ else()
|
||||
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_ROOT ${Libraries_ROOT}/ffmpeg-7.0.2-full_build-shared)
|
||||
set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
|
||||
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
|
||||
|
||||
@ -95,8 +99,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://gitea.amass.fun/amass/Kylin.git
|
||||
)
|
||||
set(KYLIN_WITH_FLUENT OFF)
|
||||
FetchContent_MakeAvailable(Kylin)
|
||||
|
||||
target_include_directories(AntiClipSettings
|
||||
PRIVATE ${FFmpeg_INCLUDE_DIR}
|
||||
|
@ -407,18 +407,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);
|
||||
|
@ -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(),
|
||||
|
22
Settings.cpp
22
Settings.cpp
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
106
resources/build.ps1
Normal file
106
resources/build.ps1
Normal file
@ -0,0 +1,106 @@
|
||||
param($type)
|
||||
|
||||
$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"
|
||||
$ffmpegRoot = "$librariesPath\ffmpeg-7.0.2-full_build-shared"
|
||||
|
||||
$projectPath = Get-Location
|
||||
$buildPath = Join-Path -Path $projectPath -ChildPath "build"
|
||||
$deployPath = Join-Path -Path $buildPath -ChildPath "AntiClipSettings"
|
||||
$zipFilePath = Join-Path -Path $buildPath -ChildPath "AntiClipSettings.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\AntiClipSettings.exe
|
||||
& $qtHome\bin\windeployqt.exe $deployPath\AntiClipSettings.exe --qmldir=$qtHome\qml
|
||||
|
||||
|
||||
# $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
|
||||
}
|
||||
|
||||
$ffmpegs = "avcodec-61", "avdevice-61", "avfilter-10", "avformat-61", "avutil-59", "postproc-58", "swresample-5", "swscale-8"
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user