Compare commits
80 Commits
master
...
self_dev_t
| Author | SHA1 | Date | |
|---|---|---|---|
| c067cd4eb4 | |||
| dec66e5e7a | |||
| 4f299f2fdd | |||
| f83cbfc753 | |||
| 6c908697bf | |||
| 71cc0c4f1a | |||
| 340f9316ee | |||
| 648b8b0f70 | |||
| 1f780ef25b | |||
| c96ed16d09 | |||
| fe33514c40 | |||
| 3af645f080 | |||
| 87549b312f | |||
| b1a776bfda | |||
| ec2d25398c | |||
| 27d45de8a1 | |||
| 97b5924079 | |||
| 16450402a1 | |||
| a1d2b53084 | |||
| 8e2df6d291 | |||
| 889803339e | |||
| 2f2ee5b6c5 | |||
| f984fd14a2 | |||
| 0df5b3bf51 | |||
| 9ea836be8c | |||
| 6b8fa0685e | |||
| f7d5ba4bf9 | |||
| fe60964e28 | |||
| 7f4db7efdb | |||
| 1bd94f5f77 | |||
| 74784e2e40 | |||
| 020e7fb47e | |||
| ee2d142182 | |||
| 43a6bfff3c | |||
| e71d0abfe8 | |||
| ac2f1ee8ec | |||
| 166b62af1b | |||
| baf5ae0a37 | |||
| 55c9f8e435 | |||
| 46a0a87da9 | |||
| 2c42a9eaa7 | |||
| 0da25401ac | |||
| 9f3b468afc | |||
| c5a57c9678 | |||
| 16bad754f0 | |||
| 3ec608686f | |||
| 3461aa9e4a | |||
| 37cd43791e | |||
| 8f75f5672c | |||
| 4b28af5a4e | |||
| 64f60fe3af | |||
| ac94c60151 | |||
| 69eecc6824 | |||
| 0eb563da4e | |||
| c1f45d3524 | |||
| ae6c9fdd25 | |||
| fcae5b8236 | |||
| d167660911 | |||
| 64bd8799fb | |||
| b03cf0c257 | |||
| e952ec06a5 | |||
| 70d34a54a2 | |||
| 44c0daefe8 | |||
| 4c8d546c84 | |||
| 7575aa4aa9 | |||
| 4a0e1a44c5 | |||
| eaed2efaa5 | |||
| 576fe1ffd1 | |||
| 50901aefed | |||
| 653d994f9c | |||
| 6c6acfea62 | |||
| 3dd25ff15b | |||
| 385d30613c | |||
| 0c217eea58 | |||
| 306db57a47 | |||
| f7cf832d9a | |||
| e1541a5da5 | |||
| dedc7d3bfa | |||
| 28e8e6779c | |||
| 21ea1b3f8b |
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"memory": "cpp"
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,8 @@ MyTcpClient::MyTcpClient(QObject *parent) : QObject(parent), shouldReconnect(tru
|
||||
// 连接失败后,定时尝试重连
|
||||
connect(&reconnectTimer, &QTimer::timeout, this, &MyTcpClient::onReconnect);
|
||||
reconnectTimer.setInterval(5000); // 5秒重连一次
|
||||
memset(header,0,sizeof(header));
|
||||
int packge_len = 0;
|
||||
}
|
||||
|
||||
MyTcpClient::~MyTcpClient() {
|
||||
@ -70,8 +72,59 @@ void MyTcpClient::onConnected() {
|
||||
}
|
||||
|
||||
void MyTcpClient::onReadyRead() {
|
||||
QByteArray data = socket->readAll();
|
||||
emit dataReceived(data);
|
||||
m_buffer.append(socket->readAll());
|
||||
|
||||
while (true) {
|
||||
if (m_buffer.size() < sizeof(BaseHeader)) return;
|
||||
|
||||
const BaseHeader *base = reinterpret_cast<const BaseHeader *>(m_buffer.constData());
|
||||
if (!(base->head[0] == 0xAA && base->head[1] == 0x55 && base->head[2] == 0xAA)) {
|
||||
m_buffer.remove(0, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8_t cmd = base->cmd;
|
||||
|
||||
if (cmd == kDownloadConfigFile) {
|
||||
if (m_buffer.size() < sizeof(BaseHeader) + sizeof(LargeHeaderExtra))
|
||||
return; // 等待更多数据
|
||||
|
||||
const LargeHeaderExtra *extra = reinterpret_cast<const LargeHeaderExtra *>(
|
||||
m_buffer.constData() + sizeof(BaseHeader));
|
||||
int payloadLen = extra->len;
|
||||
if (payloadLen <= 0 || payloadLen > 10 * 1024 * 1024) {
|
||||
qWarning() << "Detected abnormal payload length:" << payloadLen;
|
||||
m_buffer.remove(0, sizeof(BaseHeader)); // 丢弃当前包头
|
||||
continue;
|
||||
}
|
||||
int totalLen = sizeof(BaseHeader) + sizeof(LargeHeaderExtra) + extra->len;
|
||||
if (m_buffer.size() < totalLen)
|
||||
return; // 等待完整数据到达
|
||||
emit dataReceived( m_buffer);
|
||||
m_buffer.remove(0, totalLen);
|
||||
}else if(cmd == kGetLogInfo){
|
||||
if (m_buffer.size() < sizeof(GetSubCardLogRsp))
|
||||
return; // 等待更多数据
|
||||
|
||||
const GetSubCardLogRsp *extra = reinterpret_cast<const GetSubCardLogRsp *>(m_buffer.constData());
|
||||
int payloadLen = extra->len;
|
||||
if (payloadLen <= 0 || payloadLen > 10 * 1024 * 1024) {
|
||||
qWarning() << "Detected abnormal payload length:" << payloadLen;
|
||||
m_buffer.remove(0, sizeof(BaseHeader)); // 丢弃当前包头
|
||||
continue;
|
||||
}
|
||||
int totalLen = sizeof(GetSubCardLogRsp) + extra->len;
|
||||
if (m_buffer.size() < totalLen)
|
||||
return; // 等待完整数据到达
|
||||
emit dataReceived( m_buffer);
|
||||
m_buffer.remove(0, totalLen);
|
||||
} else {
|
||||
QByteArray fullData = m_buffer;
|
||||
emit dataReceived(fullData);
|
||||
m_buffer.clear();
|
||||
return; // 等待下一批数据
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyTcpClient::onDisconnected() {
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
#include "data_config.h"
|
||||
|
||||
class MyTcpClient : public QObject {
|
||||
Q_OBJECT
|
||||
@ -39,6 +40,12 @@ private:
|
||||
quint16 serverPort;
|
||||
bool shouldReconnect; // 标记是否需要重连
|
||||
static MyTcpClient* m_instance;
|
||||
|
||||
QByteArray m_buffer; // 存储当前正在接收的数据
|
||||
bool m_waitingForHeader = true; // 是否在等待头部
|
||||
|
||||
uint8_t header[4];
|
||||
int packge_len ;
|
||||
};
|
||||
|
||||
#endif // MYTCPCLIENT_H
|
||||
|
||||
1
TSI_Config.git/HEAD
Normal file
1
TSI_Config.git/HEAD
Normal file
@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
10
TSI_Config.git/config
Normal file
10
TSI_Config.git/config
Normal file
@ -0,0 +1,10 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = false
|
||||
bare = true
|
||||
symlinks = false
|
||||
ignorecase = true
|
||||
[remote "origin"]
|
||||
url = http://192.168.0.10:3000/pandx/TSI_Config.git
|
||||
fetch = +refs/*:refs/*
|
||||
mirror = true
|
||||
1
TSI_Config.git/description
Normal file
1
TSI_Config.git/description
Normal file
@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
15
TSI_Config.git/hooks/applypatch-msg.sample
Normal file
15
TSI_Config.git/hooks/applypatch-msg.sample
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message taken by
|
||||
# applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit. The hook is
|
||||
# allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
:
|
||||
24
TSI_Config.git/hooks/commit-msg.sample
Normal file
24
TSI_Config.git/hooks/commit-msg.sample
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
174
TSI_Config.git/hooks/fsmonitor-watchman.sample
Normal file
174
TSI_Config.git/hooks/fsmonitor-watchman.sample
Normal file
@ -0,0 +1,174 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IPC::Open2;
|
||||
|
||||
# An example hook script to integrate Watchman
|
||||
# (https://facebook.github.io/watchman/) with git to speed up detecting
|
||||
# new and modified files.
|
||||
#
|
||||
# The hook is passed a version (currently 2) and last update token
|
||||
# formatted as a string and outputs to stdout a new update token and
|
||||
# all files that have been modified since the update token. Paths must
|
||||
# be relative to the root of the working tree and separated by a single NUL.
|
||||
#
|
||||
# To enable this hook, rename this file to "query-watchman" and set
|
||||
# 'git config core.fsmonitor .git/hooks/query-watchman'
|
||||
#
|
||||
my ($version, $last_update_token) = @ARGV;
|
||||
|
||||
# Uncomment for debugging
|
||||
# print STDERR "$0 $version $last_update_token\n";
|
||||
|
||||
# Check the hook interface version
|
||||
if ($version ne 2) {
|
||||
die "Unsupported query-fsmonitor hook version '$version'.\n" .
|
||||
"Falling back to scanning...\n";
|
||||
}
|
||||
|
||||
my $git_work_tree = get_working_dir();
|
||||
|
||||
my $retry = 1;
|
||||
|
||||
my $json_pkg;
|
||||
eval {
|
||||
require JSON::XS;
|
||||
$json_pkg = "JSON::XS";
|
||||
1;
|
||||
} or do {
|
||||
require JSON::PP;
|
||||
$json_pkg = "JSON::PP";
|
||||
};
|
||||
|
||||
launch_watchman();
|
||||
|
||||
sub launch_watchman {
|
||||
my $o = watchman_query();
|
||||
if (is_work_tree_watched($o)) {
|
||||
output_result($o->{clock}, @{$o->{files}});
|
||||
}
|
||||
}
|
||||
|
||||
sub output_result {
|
||||
my ($clockid, @files) = @_;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# binmode $fh, ":utf8";
|
||||
# print $fh "$clockid\n@files\n";
|
||||
# close $fh;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
print $clockid;
|
||||
print "\0";
|
||||
local $, = "\0";
|
||||
print @files;
|
||||
}
|
||||
|
||||
sub watchman_clock {
|
||||
my $response = qx/watchman clock "$git_work_tree"/;
|
||||
die "Failed to get clock id on '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub watchman_query {
|
||||
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
|
||||
or die "open2() failed: $!\n" .
|
||||
"Falling back to scanning...\n";
|
||||
|
||||
# In the query expression below we're asking for names of files that
|
||||
# changed since $last_update_token but not from the .git folder.
|
||||
#
|
||||
# To accomplish this, we're using the "since" generator to use the
|
||||
# recency index to select candidate nodes and "fields" to limit the
|
||||
# output to file names only. Then we're using the "expression" term to
|
||||
# further constrain the results.
|
||||
my $last_update_line = "";
|
||||
if (substr($last_update_token, 0, 1) eq "c") {
|
||||
$last_update_token = "\"$last_update_token\"";
|
||||
$last_update_line = qq[\n"since": $last_update_token,];
|
||||
}
|
||||
my $query = <<" END";
|
||||
["query", "$git_work_tree", {$last_update_line
|
||||
"fields": ["name"],
|
||||
"expression": ["not", ["dirname", ".git"]]
|
||||
}]
|
||||
END
|
||||
|
||||
# Uncomment for debugging the watchman query
|
||||
# open (my $fh, ">", ".git/watchman-query.json");
|
||||
# print $fh $query;
|
||||
# close $fh;
|
||||
|
||||
print CHLD_IN $query;
|
||||
close CHLD_IN;
|
||||
my $response = do {local $/; <CHLD_OUT>};
|
||||
|
||||
# Uncomment for debugging the watch response
|
||||
# open ($fh, ">", ".git/watchman-response.json");
|
||||
# print $fh $response;
|
||||
# close $fh;
|
||||
|
||||
die "Watchman: command returned no output.\n" .
|
||||
"Falling back to scanning...\n" if $response eq "";
|
||||
die "Watchman: command returned invalid output: $response\n" .
|
||||
"Falling back to scanning...\n" unless $response =~ /^\{/;
|
||||
|
||||
return $json_pkg->new->utf8->decode($response);
|
||||
}
|
||||
|
||||
sub is_work_tree_watched {
|
||||
my ($output) = @_;
|
||||
my $error = $output->{error};
|
||||
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
|
||||
$retry--;
|
||||
my $response = qx/watchman watch "$git_work_tree"/;
|
||||
die "Failed to make watchman watch '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
$output = $json_pkg->new->utf8->decode($response);
|
||||
$error = $output->{error};
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
# Uncomment for debugging watchman output
|
||||
# open (my $fh, ">", ".git/watchman-output.out");
|
||||
# close $fh;
|
||||
|
||||
# Watchman will always return all files on the first query so
|
||||
# return the fast "everything is dirty" flag to git and do the
|
||||
# Watchman query just to get it over with now so we won't pay
|
||||
# the cost in git to look up each individual file.
|
||||
my $o = watchman_clock();
|
||||
$error = $output->{error};
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
output_result($o->{clock}, ("/"));
|
||||
$last_update_token = $o->{clock};
|
||||
|
||||
eval { launch_watchman() };
|
||||
return 0;
|
||||
}
|
||||
|
||||
die "Watchman: $error.\n" .
|
||||
"Falling back to scanning...\n" if $error;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub get_working_dir {
|
||||
my $working_dir;
|
||||
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
|
||||
$working_dir = Win32::GetCwd();
|
||||
$working_dir =~ tr/\\/\//;
|
||||
} else {
|
||||
require Cwd;
|
||||
$working_dir = Cwd::cwd();
|
||||
}
|
||||
|
||||
return $working_dir;
|
||||
}
|
||||
8
TSI_Config.git/hooks/post-update.sample
Normal file
8
TSI_Config.git/hooks/post-update.sample
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare a packed repository for use over
|
||||
# dumb transports.
|
||||
#
|
||||
# To enable this hook, rename this file to "post-update".
|
||||
|
||||
exec git update-server-info
|
||||
14
TSI_Config.git/hooks/pre-applypatch.sample
Normal file
14
TSI_Config.git/hooks/pre-applypatch.sample
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed
|
||||
# by applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
:
|
||||
49
TSI_Config.git/hooks/pre-commit.sample
Normal file
49
TSI_Config.git/hooks/pre-commit.sample
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --type=bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
||||
13
TSI_Config.git/hooks/pre-merge-commit.sample
Normal file
13
TSI_Config.git/hooks/pre-merge-commit.sample
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git merge" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message to
|
||||
# stderr if it wants to stop the merge commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-merge-commit".
|
||||
|
||||
. git-sh-setup
|
||||
test -x "$GIT_DIR/hooks/pre-commit" &&
|
||||
exec "$GIT_DIR/hooks/pre-commit"
|
||||
:
|
||||
53
TSI_Config.git/hooks/pre-push.sample
Normal file
53
TSI_Config.git/hooks/pre-push.sample
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
#
|
||||
# Information about the commits which are being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
#
|
||||
# <local ref> <local oid> <remote ref> <remote oid>
|
||||
#
|
||||
# This sample shows how to prevent push of commits where the log message starts
|
||||
# with "WIP" (work in progress).
|
||||
|
||||
remote="$1"
|
||||
url="$2"
|
||||
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
|
||||
while read local_ref local_oid remote_ref remote_oid
|
||||
do
|
||||
if test "$local_oid" = "$zero"
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if test "$remote_oid" = "$zero"
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_oid"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_oid..$local_oid"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
|
||||
if test -n "$commit"
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
169
TSI_Config.git/hooks/pre-rebase.sample
Normal file
169
TSI_Config.git/hooks/pre-rebase.sample
Normal file
@ -0,0 +1,169 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||
#
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||
# its job, and can prevent the command from running by exiting with
|
||||
# non-zero status.
|
||||
#
|
||||
# The hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- the upstream the series was forked from.
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||
#
|
||||
# This sample shows how to prevent topic branches that are already
|
||||
# merged to 'next' branch from getting rebased, because allowing it
|
||||
# would result in rebasing already published history.
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
# on top of master. Is it OK to rebase it?
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
/^([0-9a-f]+) /;
|
||||
($1 => 1);
|
||||
} split(/\n/, $ARGV[1]);
|
||||
for my $elem (map {
|
||||
/^([0-9a-f]+) (.*)$/;
|
||||
[$1 => $2];
|
||||
} split(/\n/, $ARGV[2])) {
|
||||
if (!exists $not_in_next{$elem->[0]}) {
|
||||
if ($msg) {
|
||||
print STDERR $msg;
|
||||
undef $msg;
|
||||
}
|
||||
print STDERR " $elem->[1]\n";
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
This sample hook safeguards topic branches that have been
|
||||
published from being rewound.
|
||||
|
||||
The workflow assumed here is:
|
||||
|
||||
* Once a topic branch forks from "master", "master" is never
|
||||
merged into it again (either directly or indirectly).
|
||||
|
||||
* Once a topic branch is fully cooked and merged into "master",
|
||||
it is deleted. If you need to build on top of it to correct
|
||||
earlier mistakes, a new topic branch is created by forking at
|
||||
the tip of the "master". This is not strictly necessary, but
|
||||
it makes it easier to keep your history simple.
|
||||
|
||||
* Whenever you need to test or publish your changes to topic
|
||||
branches, merge them into "next" branch.
|
||||
|
||||
The script, being an example, hardcodes the publish branch name
|
||||
to be "next", but it is trivial to make it configurable via
|
||||
$GIT_DIR/config mechanism.
|
||||
|
||||
With this workflow, you would want to know:
|
||||
|
||||
(1) ... if a topic branch has ever been merged to "next". Young
|
||||
topic branches can have stupid mistakes you would rather
|
||||
clean up before publishing, and things that have not been
|
||||
merged into other branches can be easily rebased without
|
||||
affecting other people. But once it is published, you would
|
||||
not want to rewind it.
|
||||
|
||||
(2) ... if a topic branch has been fully merged to "master".
|
||||
Then you can delete it. More importantly, you should not
|
||||
build on top of it -- other people may already want to
|
||||
change things related to the topic as patches against your
|
||||
"master", so if you need further changes, it is better to
|
||||
fork the topic (perhaps with the same name) afresh from the
|
||||
tip of "master".
|
||||
|
||||
Let's look at this example:
|
||||
|
||||
o---o---o---o---o---o---o---o---o---o "next"
|
||||
/ / / /
|
||||
/ a---a---b A / /
|
||||
/ / / /
|
||||
/ / c---c---c---c B /
|
||||
/ / / \ /
|
||||
/ / / b---b C \ /
|
||||
/ / / / \ /
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||
|
||||
|
||||
A, B and C are topic branches.
|
||||
|
||||
* A has one fix since it was merged up to "next".
|
||||
|
||||
* B has finished. It has been fully merged up to "master" and "next",
|
||||
and is ready to be deleted.
|
||||
|
||||
* C has not merged to "next" at all.
|
||||
|
||||
We would want to allow C to be rebased, refuse A, and encourage
|
||||
B to be deleted.
|
||||
|
||||
To compute (1):
|
||||
|
||||
git rev-list ^master ^topic next
|
||||
git rev-list ^master next
|
||||
|
||||
if these match, topic has not merged in next at all.
|
||||
|
||||
To compute (2):
|
||||
|
||||
git rev-list master..topic
|
||||
|
||||
if this is empty, it is fully merged to "master".
|
||||
|
||||
DOC_END
|
||||
24
TSI_Config.git/hooks/pre-receive.sample
Normal file
24
TSI_Config.git/hooks/pre-receive.sample
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to make use of push options.
|
||||
# The example simply echoes all push options that start with 'echoback='
|
||||
# and rejects all pushes when the "reject" push option is used.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
42
TSI_Config.git/hooks/prepare-commit-msg.sample
Normal file
42
TSI_Config.git/hooks/prepare-commit-msg.sample
Normal file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare the commit log message.
|
||||
# Called by "git commit" with the name of the file that has the
|
||||
# commit message, followed by the description of the commit
|
||||
# message's source. The hook's purpose is to edit the commit
|
||||
# message file. If the hook fails with a non-zero status,
|
||||
# the commit is aborted.
|
||||
#
|
||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||
|
||||
# This hook includes three examples. The first one removes the
|
||||
# "# Please enter the commit message..." help message.
|
||||
#
|
||||
# The second includes the output of "git diff --name-status -r"
|
||||
# into the message, just before the "git status" output. It is
|
||||
# commented because it doesn't cope with --amend or with squashed
|
||||
# commits.
|
||||
#
|
||||
# The third example adds a Signed-off-by line to the message, that can
|
||||
# still be edited. This is rarely a good idea.
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_SOURCE=$2
|
||||
SHA1=$3
|
||||
|
||||
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
||||
|
||||
# case "$COMMIT_SOURCE,$SHA1" in
|
||||
# ,|template,)
|
||||
# /usr/bin/perl -i.bak -pe '
|
||||
# print "\n" . `git diff --cached --name-status -r`
|
||||
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
||||
# *) ;;
|
||||
# esac
|
||||
|
||||
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
||||
# if test -z "$COMMIT_SOURCE"
|
||||
# then
|
||||
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
||||
# fi
|
||||
78
TSI_Config.git/hooks/push-to-checkout.sample
Normal file
78
TSI_Config.git/hooks/push-to-checkout.sample
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to update a checked-out tree on a git push.
|
||||
#
|
||||
# This hook is invoked by git-receive-pack(1) when it reacts to git
|
||||
# push and updates reference(s) in its repository, and when the push
|
||||
# tries to update the branch that is currently checked out and the
|
||||
# receive.denyCurrentBranch configuration variable is set to
|
||||
# updateInstead.
|
||||
#
|
||||
# By default, such a push is refused if the working tree and the index
|
||||
# of the remote repository has any difference from the currently
|
||||
# checked out commit; when both the working tree and the index match
|
||||
# the current commit, they are updated to match the newly pushed tip
|
||||
# of the branch. This hook is to be used to override the default
|
||||
# behaviour; however the code below reimplements the default behaviour
|
||||
# as a starting point for convenient modification.
|
||||
#
|
||||
# The hook receives the commit with which the tip of the current
|
||||
# branch is going to be updated:
|
||||
commit=$1
|
||||
|
||||
# It can exit with a non-zero status to refuse the push (when it does
|
||||
# so, it must not modify the index or the working tree).
|
||||
die () {
|
||||
echo >&2 "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Or it can make any necessary changes to the working tree and to the
|
||||
# index to bring them to the desired state when the tip of the current
|
||||
# branch is updated to the new commit, and exit with a zero status.
|
||||
#
|
||||
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
|
||||
# in order to emulate git fetch that is run in the reverse direction
|
||||
# with git push, as the two-tree form of git read-tree -u -m is
|
||||
# essentially the same as git switch or git checkout that switches
|
||||
# branches while keeping the local changes in the working tree that do
|
||||
# not interfere with the difference between the branches.
|
||||
|
||||
# The below is a more-or-less exact translation to shell of the C code
|
||||
# for the default behaviour for git's push-to-checkout hook defined in
|
||||
# the push_to_deploy() function in builtin/receive-pack.c.
|
||||
#
|
||||
# Note that the hook will be executed from the repository directory,
|
||||
# not from the working tree, so if you want to perform operations on
|
||||
# the working tree, you will have to adapt your code accordingly, e.g.
|
||||
# by adding "cd .." or using relative paths.
|
||||
|
||||
if ! git update-index -q --ignore-submodules --refresh
|
||||
then
|
||||
die "Up-to-date check failed"
|
||||
fi
|
||||
|
||||
if ! git diff-files --quiet --ignore-submodules --
|
||||
then
|
||||
die "Working directory has unstaged changes"
|
||||
fi
|
||||
|
||||
# This is a rough translation of:
|
||||
#
|
||||
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
|
||||
if git cat-file -e HEAD 2>/dev/null
|
||||
then
|
||||
head=HEAD
|
||||
else
|
||||
head=$(git hash-object -t tree --stdin </dev/null)
|
||||
fi
|
||||
|
||||
if ! git diff-index --quiet --cached --ignore-submodules $head --
|
||||
then
|
||||
die "Working directory has staged changes"
|
||||
fi
|
||||
|
||||
if ! git read-tree -u -m "$commit"
|
||||
then
|
||||
die "Could not update working tree to new HEAD"
|
||||
fi
|
||||
77
TSI_Config.git/hooks/sendemail-validate.sample
Normal file
77
TSI_Config.git/hooks/sendemail-validate.sample
Normal file
@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to validate a patch (and/or patch series) before
|
||||
# sending it via email.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an appropriate
|
||||
# message if it wants to prevent the email(s) from being sent.
|
||||
#
|
||||
# To enable this hook, rename this file to "sendemail-validate".
|
||||
#
|
||||
# By default, it will only check that the patch(es) can be applied on top of
|
||||
# the default upstream branch without conflicts in a secondary worktree. After
|
||||
# validation (successful or not) of the last patch of a series, the worktree
|
||||
# will be deleted.
|
||||
#
|
||||
# The following config variables can be set to change the default remote and
|
||||
# remote ref that are used to apply the patches against:
|
||||
#
|
||||
# sendemail.validateRemote (default: origin)
|
||||
# sendemail.validateRemoteRef (default: HEAD)
|
||||
#
|
||||
# Replace the TODO placeholders with appropriate checks according to your
|
||||
# needs.
|
||||
|
||||
validate_cover_letter () {
|
||||
file="$1"
|
||||
# TODO: Replace with appropriate checks (e.g. spell checking).
|
||||
true
|
||||
}
|
||||
|
||||
validate_patch () {
|
||||
file="$1"
|
||||
# Ensure that the patch applies without conflicts.
|
||||
git am -3 "$file" || return
|
||||
# TODO: Replace with appropriate checks for this patch
|
||||
# (e.g. checkpatch.pl).
|
||||
true
|
||||
}
|
||||
|
||||
validate_series () {
|
||||
# TODO: Replace with appropriate checks for the whole series
|
||||
# (e.g. quick build, coding style checks, etc.).
|
||||
true
|
||||
}
|
||||
|
||||
# main -------------------------------------------------------------------------
|
||||
|
||||
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
|
||||
then
|
||||
remote=$(git config --default origin --get sendemail.validateRemote) &&
|
||||
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
|
||||
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
|
||||
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
|
||||
git config --replace-all sendemail.validateWorktree "$worktree"
|
||||
else
|
||||
worktree=$(git config --get sendemail.validateWorktree)
|
||||
fi || {
|
||||
echo "sendemail-validate: error: failed to prepare worktree" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
unset GIT_DIR GIT_WORK_TREE
|
||||
cd "$worktree" &&
|
||||
|
||||
if grep -q "^diff --git " "$1"
|
||||
then
|
||||
validate_patch "$1"
|
||||
else
|
||||
validate_cover_letter "$1"
|
||||
fi &&
|
||||
|
||||
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
|
||||
then
|
||||
git config --unset-all sendemail.validateWorktree &&
|
||||
trap 'git worktree remove -ff "$worktree"' EXIT &&
|
||||
validate_series
|
||||
fi
|
||||
128
TSI_Config.git/hooks/update.sample
Normal file
128
TSI_Config.git/hooks/update.sample
Normal file
@ -0,0 +1,128 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to block unannotated tags from entering.
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||
#
|
||||
# To enable this hook, rename this file to "update".
|
||||
#
|
||||
# Config
|
||||
# ------
|
||||
# hooks.allowunannotated
|
||||
# This boolean sets whether unannotated tags will be allowed into the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowdeletetag
|
||||
# This boolean sets whether deleting tags will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowmodifytag
|
||||
# This boolean sets whether a tag may be modified after creation. By default
|
||||
# it won't be.
|
||||
# hooks.allowdeletebranch
|
||||
# This boolean sets whether deleting branches will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.denycreatebranch
|
||||
# This boolean sets whether remotely creating branches will be denied
|
||||
# in the repository. By default this is allowed.
|
||||
#
|
||||
|
||||
# --- Command line
|
||||
refname="$1"
|
||||
oldrev="$2"
|
||||
newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
allowunannotated=$(git config --type=bool hooks.allowunannotated)
|
||||
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
|
||||
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
|
||||
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
|
||||
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
|
||||
|
||||
# check for no description
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
exit 0
|
||||
6
TSI_Config.git/info/exclude
Normal file
6
TSI_Config.git/info/exclude
Normal file
@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
TSI_Config.git/packed-refs
Normal file
8
TSI_Config.git/packed-refs
Normal file
@ -0,0 +1,8 @@
|
||||
# pack-refs with: peeled fully-peeled sorted
|
||||
50901aefed0ea44430da846ec52e579d41b5bdf6 refs/heads/dev
|
||||
74784e2e4083bb00e662b210afb0e03e5873326b refs/heads/feature1
|
||||
411a9c1a445a32e92b68a58e7211d1e95482369c refs/heads/master
|
||||
6b8fa0685e4498904aac3add51d3e62b35353bdd refs/heads/protocol_update
|
||||
0df5b3bf5168abee3d576e9e991476b38ac7012a refs/heads/self_dev
|
||||
bf725cd0ff19cb394abbceb011e4113c861f2b85 refs/tags/0.1
|
||||
^020e7fb47ec240d2cae6ac776f4d13d86274ff06
|
||||
@ -11,44 +11,93 @@ CONFIG += c++11
|
||||
SOURCES += \
|
||||
MyTcpClient.cpp \
|
||||
acceleration.cpp \
|
||||
cardbase.cpp \
|
||||
common.cpp \
|
||||
config_mgr.cpp \
|
||||
connect.cpp \
|
||||
dc_output_channel.cpp \
|
||||
dc_outputs.cpp \
|
||||
ethconfig.cpp \
|
||||
keyphase.cpp \
|
||||
keyphase_data.cpp \
|
||||
macconfig.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
mqtt_config.cpp \
|
||||
pointname.cpp \
|
||||
pressure_pulsation.cpp \
|
||||
radial_vibration.cpp \
|
||||
rangeslider.cpp \
|
||||
relaysetting.cpp \
|
||||
seismic_monitor.cpp \
|
||||
setpoint.cpp \
|
||||
setpoint_tachometer.cpp \
|
||||
singlerelay.cpp \
|
||||
singlerelay_data.cpp \
|
||||
tachometer.cpp \
|
||||
velocity.cpp
|
||||
tachometer_data.cpp \
|
||||
tmrrelayassociation.cpp \
|
||||
tmrrelayassociation_data.cpp \
|
||||
trust.cpp \
|
||||
velocity.cpp \
|
||||
vibrationdata.cpp
|
||||
|
||||
HEADERS += \
|
||||
MyTcpClient.h \
|
||||
acceleration.h \
|
||||
acceleration_ds.h \
|
||||
cardbase.h \
|
||||
common.h \
|
||||
config_mgr.h \
|
||||
connect.h \
|
||||
data_config.h \
|
||||
dc_output_channel.h \
|
||||
dc_outputs.h \
|
||||
displacement_ds.h \
|
||||
ethconfig.h \
|
||||
keyphase.h \
|
||||
keyphase_data.h \
|
||||
macconfig.h \
|
||||
mainwindow.h \
|
||||
mqtt_config.h \
|
||||
pointname.h \
|
||||
pressure_pulsation.h \
|
||||
radial_vibration.h \
|
||||
rangeslider.h \
|
||||
relaysetting.h \
|
||||
seismic_monitor.h \
|
||||
setpoint.h \
|
||||
setpoint_tachometer.h \
|
||||
singlerelay.h \
|
||||
singlerelay_data.h \
|
||||
tachometer.h \
|
||||
velocity.h
|
||||
tachometer_data.h \
|
||||
tmrrelayassociation.h \
|
||||
tmrrelayassociation_data.h \
|
||||
trust.h \
|
||||
trust_ds.h \
|
||||
velocity.h \
|
||||
velocity_ds.h \
|
||||
vibrationdata.h
|
||||
|
||||
FORMS += \
|
||||
acceleration.ui \
|
||||
connect.ui \
|
||||
dc_output_channel.ui \
|
||||
dc_outputs.ui \
|
||||
ethconfig.ui \
|
||||
keyphase.ui \
|
||||
macconfig.ui \
|
||||
mainwindow.ui \
|
||||
mqtt_config.ui \
|
||||
pointname.ui \
|
||||
pressure_pulsation.ui \
|
||||
radial_vibration.ui \
|
||||
relaysetting.ui \
|
||||
seismic_monitor.ui \
|
||||
setpoint.ui \
|
||||
setpoint_tachometer.ui \
|
||||
singlerelay.ui \
|
||||
tachometer.ui \
|
||||
tmrrelayassociation.ui \
|
||||
trust.ui \
|
||||
velocity.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
|
||||
516
acceleration.cpp
516
acceleration.cpp
@ -5,11 +5,14 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
Acceleration::Acceleration(int slot_no_,int channel_,bool active,QWidget *parent) :
|
||||
Acceleration::Acceleration(int slot_no_, int channel_, bool active, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Acceleration)
|
||||
{
|
||||
ui(new Ui::Acceleration) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
channel = channel_;
|
||||
@ -17,264 +20,299 @@ Acceleration::Acceleration(int slot_no_,int channel_,bool active,QWidget *parent
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_channel->setText(chan);
|
||||
ui->label_slot->setText(slot);
|
||||
if(active)
|
||||
if (active) {
|
||||
ui->label_active->setText("(启用)");
|
||||
else
|
||||
} else {
|
||||
ui->label_active->setText("(停用)");
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_filter);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_variables);
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
Acceleration::~Acceleration()
|
||||
{
|
||||
Acceleration::~Acceleration() {
|
||||
delete ui;
|
||||
}
|
||||
void Acceleration::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
if(filePath.contains("filter_")){
|
||||
QJsonArray filter_array = json_obj["filter"].toArray();
|
||||
for(int i = 0; i < filter_array.size(); i++){
|
||||
QJsonObject temp_obj = filter_array[i].toObject();
|
||||
filter[i].type = temp_obj["type"].toString();
|
||||
filter[i].low = temp_obj["low"].toInt();
|
||||
filter[i].high = temp_obj["high"].toInt();
|
||||
filter[i].checked = temp_obj["checked"].toBool();
|
||||
}
|
||||
}else if(filePath.contains("acceleration_variables_")){
|
||||
|
||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
||||
for(int i = 0; i < variables_array.size(); i++){
|
||||
QJsonObject temp_obj = variables_array[i].toObject();
|
||||
variables[i].type = temp_obj["type"].toString();
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].bias_voltage = temp_obj["bias_voltage"].toInt();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}
|
||||
}
|
||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
||||
delay.alert = delay_obj["alert"].toInt();
|
||||
delay.danger = delay_obj["danger"].toDouble();
|
||||
delay.active_100ms = delay_obj["100ms"].toBool();
|
||||
alert_variables.rms_active = json_obj["rms_active"].toBool();
|
||||
alert_variables.integrate_active = json_obj["integrate_active"].toBool();
|
||||
alert_variables.alert_latching = json_obj["alert_latching"].toBool();
|
||||
alert_variables.danger_latching = json_obj["danger_latching"].toBool();
|
||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
||||
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
||||
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
||||
alert_variables.comparision = json_obj["comparision"].toString();
|
||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
||||
void Acceleration::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Acceleration::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
}
|
||||
void Acceleration::Init()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].checked){
|
||||
if(filter[i].type == "band_pass"){
|
||||
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
||||
}
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if (ptr->base_config_[channel - 1].channel_type != kVibAcc) {
|
||||
qDebug() << "[Acceleration::Init] channel type changes";
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage));
|
||||
ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "[Acceleration::Init] no channel ptr";
|
||||
return;
|
||||
}
|
||||
ui->spinBox_alert->setValue(delay.alert);
|
||||
ui->doubleSpinBox_danger->setValue(delay.danger);
|
||||
ui->checkBox_100ms->setChecked(delay.active_100ms);
|
||||
ui->checkBox_rms->setChecked(alert_variables.rms_active);
|
||||
ui->checkBox_integrate->setChecked(alert_variables.integrate_active);
|
||||
ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching);
|
||||
ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching);
|
||||
ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok);
|
||||
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
||||
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
|
||||
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
|
||||
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
|
||||
|
||||
// processed output
|
||||
// -general
|
||||
if(variable_ptr->general.output_used)
|
||||
ui->comboBox_output_used->setCurrentIndex(0);
|
||||
else
|
||||
ui->comboBox_output_used->setCurrentIndex(1);
|
||||
ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit);
|
||||
ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function);
|
||||
// -alarm
|
||||
ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level));
|
||||
ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis));
|
||||
ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay));
|
||||
ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable);
|
||||
ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch);
|
||||
|
||||
ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level));
|
||||
ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis));
|
||||
ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay));
|
||||
ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable);
|
||||
ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch);
|
||||
|
||||
ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level));
|
||||
ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis));
|
||||
ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay));
|
||||
ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable);
|
||||
ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch);
|
||||
|
||||
ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level));
|
||||
ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis));
|
||||
ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay));
|
||||
ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable);
|
||||
ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch);
|
||||
|
||||
//
|
||||
ui->checkBox_enable->setChecked(variable_ptr->freband_output[0].enable);
|
||||
ui->lineEdit_start->setText(QString::number(variable_ptr->freband_output[0].start));
|
||||
ui->lineEdit_end->setText(QString::number(variable_ptr->freband_output[0].end));
|
||||
ui->checkBox_enable_2->setChecked(variable_ptr->freband_output[1].enable);
|
||||
ui->lineEdit_start_2->setText(QString::number(variable_ptr->freband_output[1].start));
|
||||
ui->lineEdit_end_2->setText(QString::number(variable_ptr->freband_output[1].end));
|
||||
ui->checkBox_enable_3->setChecked(variable_ptr->freband_output[2].enable);
|
||||
ui->lineEdit_start_3->setText(QString::number(variable_ptr->freband_output[2].start));
|
||||
ui->lineEdit_end_3->setText(QString::number(variable_ptr->freband_output[2].end));
|
||||
ui->checkBox_enable_4->setChecked(variable_ptr->freband_output[3].enable);
|
||||
ui->lineEdit_start_4->setText(QString::number(variable_ptr->freband_output[3].start));
|
||||
ui->lineEdit_end_4->setText(QString::number(variable_ptr->freband_output[3].end));
|
||||
ui->checkBox_enable_5->setChecked(variable_ptr->freband_output[4].enable);
|
||||
ui->lineEdit_start_5->setText(QString::number(variable_ptr->freband_output[4].start));
|
||||
ui->lineEdit_end_5->setText(QString::number(variable_ptr->freband_output[4].end));
|
||||
ui->checkBox_enable_6->setChecked(variable_ptr->freband_output[5].enable);
|
||||
ui->lineEdit_start_6->setText(QString::number(variable_ptr->freband_output[5].start));
|
||||
ui->lineEdit_end_6->setText(QString::number(variable_ptr->freband_output[5].end));
|
||||
ui->checkBox_enable_7->setChecked(variable_ptr->freband_output[6].enable);
|
||||
ui->lineEdit_start_7->setText(QString::number(variable_ptr->freband_output[6].start));
|
||||
ui->lineEdit_end_7->setText(QString::number(variable_ptr->freband_output[6].end));
|
||||
ui->checkBox_enable_8->setChecked(variable_ptr->freband_output[7].enable);
|
||||
ui->lineEdit_start_8->setText(QString::number(variable_ptr->freband_output[7].start));
|
||||
ui->lineEdit_end_8->setText(QString::number(variable_ptr->freband_output[7].end));
|
||||
ui->checkBox_enable_9->setChecked(variable_ptr->freband_output[8].enable);
|
||||
ui->lineEdit_start_9->setText(QString::number(variable_ptr->freband_output[8].start));
|
||||
ui->lineEdit_end_9->setText(QString::number(variable_ptr->freband_output[8].end));
|
||||
ui->checkBox_enable_10->setChecked(variable_ptr->freband_output[9].enable);
|
||||
ui->lineEdit_start_10->setText(QString::number(variable_ptr->freband_output[9].start));
|
||||
ui->lineEdit_end_10->setText(QString::number(variable_ptr->freband_output[9].end));
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].type == "band_pass"){
|
||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
||||
}
|
||||
void Acceleration::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Acceleration::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
}
|
||||
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
||||
QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高");
|
||||
return;
|
||||
}
|
||||
delay.alert = ui->spinBox_alert->value();
|
||||
delay.danger = ui->doubleSpinBox_danger->value();
|
||||
delay.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
alert_variables.rms_active = ui->checkBox_rms->isChecked();
|
||||
alert_variables.integrate_active = ui->checkBox_integrate->isChecked();
|
||||
alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked();
|
||||
alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked();
|
||||
alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked();
|
||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
ptr->base_config_[channel - 1].channel_type = kVibAcc;
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
std::shared_ptr<AccVelVariable> variable = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
|
||||
QJsonObject filter_obj,variables_obj;
|
||||
QJsonArray filter_array;
|
||||
for(int i = 0; i < 3; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",filter[i].type);
|
||||
temp_obj.insert("low",filter[i].low);
|
||||
temp_obj.insert("high",filter[i].high);
|
||||
temp_obj.insert("checked",filter[i].checked);
|
||||
filter_array.append(temp_obj);
|
||||
}
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 4; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",variables[i].type);
|
||||
if(variables[i].type == "direct"){
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||
if (variable_base == nullptr || variable_base->type_ != kVibAcc || variable == nullptr) {
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "no channel ptr";
|
||||
} else {
|
||||
ptr->RemoveChannel(channel);
|
||||
qDebug() << "channel type change";
|
||||
}
|
||||
variables_array.append(temp_obj);
|
||||
}
|
||||
variables_obj.insert("variables",variables_array);
|
||||
QJsonObject delay_obj;
|
||||
delay_obj.insert("alert",delay.alert);
|
||||
delay_obj.insert("danger",delay.danger);
|
||||
delay_obj.insert("100ms",delay.active_100ms);
|
||||
variables_obj.insert("delay",delay_obj);
|
||||
variables_obj.insert("rms_active",alert_variables.rms_active);
|
||||
variables_obj.insert("integrate_active",alert_variables.integrate_active);
|
||||
variables_obj.insert("alert_latching",alert_variables.alert_latching);
|
||||
variables_obj.insert("danger_latching",alert_variables.danger_latching);
|
||||
variables_obj.insert("timed_ok",alert_variables.timed_ok);
|
||||
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
||||
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
||||
variables_obj.insert("trip_multiply",alert_variables.trip_multiply);
|
||||
variables_obj.insert("comparision",alert_variables.comparision);
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("id",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QJsonDocument jsonDoc_filter(filter_obj);
|
||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath;
|
||||
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||
variable->id_ = channel;
|
||||
variable->type_ = kVibAcc;
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
// processed output
|
||||
// -general
|
||||
if(ui->comboBox_output_used->currentIndex() == 0)
|
||||
variable->general.output_used = true;
|
||||
else
|
||||
variable->general.output_used = false;
|
||||
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
||||
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
||||
// -alarm
|
||||
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
||||
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||||
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||||
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
||||
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
||||
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
||||
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||||
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||||
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
||||
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
||||
variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
||||
variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
||||
variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
||||
variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
||||
variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
||||
variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
||||
variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
||||
variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
||||
variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
||||
variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
||||
// -freband output
|
||||
variable->freband_output[0].enable = ui->checkBox_enable->isChecked();
|
||||
variable->freband_output[0].start = ui->lineEdit_start->text().toDouble();
|
||||
variable->freband_output[0].end = ui->lineEdit_end->text().toDouble();
|
||||
variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked();
|
||||
variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble();
|
||||
variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble();
|
||||
variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked();
|
||||
variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble();
|
||||
variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble();
|
||||
variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked();
|
||||
variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble();
|
||||
variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble();
|
||||
variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked();
|
||||
variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble();
|
||||
variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble();
|
||||
variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked();
|
||||
variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble();
|
||||
variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble();
|
||||
variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked();
|
||||
variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble();
|
||||
variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble();
|
||||
variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked();
|
||||
variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble();
|
||||
variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble();
|
||||
variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked();
|
||||
variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble();
|
||||
variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble();
|
||||
variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked();
|
||||
variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble();
|
||||
variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble();
|
||||
ptr->variables_.push_back(variable);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
file.write(jsonDoc_filter.toJson());
|
||||
file.close();
|
||||
QJsonDocument jsonDoc_variables(variables_obj);
|
||||
filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
file.setFileName(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath;
|
||||
return;
|
||||
}
|
||||
file.write(jsonDoc_variables.toJson());
|
||||
file.close();
|
||||
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
// processed output
|
||||
// -general
|
||||
if(ui->comboBox_output_used->currentIndex() == 0)
|
||||
variable->general.output_used = true;
|
||||
else
|
||||
variable->general.output_used = false;
|
||||
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
||||
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
||||
// -alarm
|
||||
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
||||
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||||
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||||
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
||||
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
||||
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
||||
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||||
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||||
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
||||
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
||||
variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
||||
variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
||||
variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
||||
variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
||||
variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
||||
variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
||||
variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
||||
variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
||||
variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
||||
variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
||||
// -freband output
|
||||
variable->freband_output[0].enable = ui->checkBox_enable->isChecked();
|
||||
variable->freband_output[0].start = ui->lineEdit_start->text().toDouble();
|
||||
variable->freband_output[0].end = ui->lineEdit_end->text().toDouble();
|
||||
variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked();
|
||||
variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble();
|
||||
variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble();
|
||||
variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked();
|
||||
variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble();
|
||||
variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble();
|
||||
variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked();
|
||||
variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble();
|
||||
variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble();
|
||||
variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked();
|
||||
variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble();
|
||||
variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble();
|
||||
variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked();
|
||||
variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble();
|
||||
variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble();
|
||||
variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked();
|
||||
variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble();
|
||||
variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble();
|
||||
variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked();
|
||||
variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble();
|
||||
variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble();
|
||||
variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked();
|
||||
variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble();
|
||||
variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble();
|
||||
variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked();
|
||||
variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble();
|
||||
variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_set_default_clicked() {
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Acceleration::on_pushButton_set_default_clicked()
|
||||
void Acceleration::on_lineEdit_alert_high_level_editingFinished()
|
||||
{
|
||||
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
||||
ui->lineEdit_danger_high_level->setText(ui->lineEdit_alert_high_level->text());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Acceleration::on_lineEdit_danger_high_level_editingFinished()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -8,30 +8,29 @@ namespace Ui {
|
||||
class Acceleration;
|
||||
}
|
||||
|
||||
class Acceleration : public QWidget
|
||||
{
|
||||
class Acceleration : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Acceleration(int slot_no_,int channel_,bool active,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Acceleration(int slot_no_, int channel_, bool active, QWidget *parent = nullptr);
|
||||
~Acceleration();
|
||||
int slot_no;
|
||||
int channel;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_set_default_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_lineEdit_alert_high_level_editingFinished();
|
||||
|
||||
void on_lineEdit_danger_high_level_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::Acceleration *ui;
|
||||
|
||||
Filter filter[3];
|
||||
Dealy delay;
|
||||
Variables variables[4];
|
||||
Alert_Variables alert_variables;
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
1648
acceleration.ui
1648
acceleration.ui
File diff suppressed because it is too large
Load Diff
46
acceleration_ds.h
Normal file
46
acceleration_ds.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef ACCELERATION_DS_H
|
||||
#define ACCELERATION_DS_H
|
||||
|
||||
// 加速度峰值的量程范围
|
||||
typedef enum {
|
||||
kAccPK20 = 0, // 0-20 m/s^2 pk
|
||||
kAccPK50 = 1, // 0-50 m/s^2 pk
|
||||
kAccPK100 = 2, // 0-100 m/s^2 pk
|
||||
kAccPK200 = 3, // 0-200 m/s^2 pk
|
||||
kAccPK250 = 4, // 0-250 m/s^2 pk
|
||||
kAccPK400 = 5, // 0-400 m/s^2 pk
|
||||
kAccPKCustom = 6 // custom
|
||||
} AccPKFullScaleRange;
|
||||
|
||||
// 加速度有效值的量程范围
|
||||
typedef enum {
|
||||
kAccRMS20 = 0, // 0-20 m/s^2 rms
|
||||
kAccRMS50 = 1, // 0-50 m/s^2 rms
|
||||
kAccRMS100 = 2, // 0-100 m/s^2 rms
|
||||
kAccRMS200 = 3, // 0-200 m/s^2 rms
|
||||
kAccRMSCustom = 4 // custom
|
||||
} AccRMSFullScaleRange;
|
||||
|
||||
// 速度峰值的量程范围
|
||||
typedef enum {
|
||||
kAccVelPK25 = 0, // 0-25 mm/s pk
|
||||
kAccVelPK50 = 1, // 0-50 mm/s pk
|
||||
kAccVelPK100 = 2, // 0-100 mm/s pk
|
||||
kAccVelCustom = 3 // custom
|
||||
} AccVelPKFullScaleRange;
|
||||
|
||||
typedef enum {
|
||||
kAccVelRMS25 = 0, // 0-25 mm/s rms
|
||||
kAccVelRMS50 = 1, // 0-50 mm/s rms
|
||||
kAccVelRMSCustom = 2 // custom
|
||||
} AccVelRMSFullScaleRange;
|
||||
|
||||
// recorder out
|
||||
typedef enum {
|
||||
kAccRecorderOutNone = 0,
|
||||
kAccRecorderOutDirectAmpl = 1,
|
||||
kAccRecorderOut1XAmpl = 2,
|
||||
kAccRecorderOut2XAmpl = 3,
|
||||
} AccRecorderOut;
|
||||
|
||||
#endif // ACCELERATION_DS_H
|
||||
6
cardbase.cpp
Normal file
6
cardbase.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "cardbase.h"
|
||||
|
||||
//CardBase::CardBase()
|
||||
//{
|
||||
|
||||
//}
|
||||
82
cardbase.h
Normal file
82
cardbase.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef CARDBASE_H
|
||||
#define CARDBASE_H
|
||||
|
||||
#include "data_config.h"
|
||||
//#ifdef NAME
|
||||
// #undef NAME
|
||||
//#endif
|
||||
//#define NAME(x) (x, #x)
|
||||
|
||||
class CardBase {
|
||||
public:
|
||||
CardBase() {}
|
||||
virtual ~CardBase() {}
|
||||
int version_;
|
||||
int slot_; // 从1~15
|
||||
CardType card_type_;
|
||||
};
|
||||
|
||||
class VariableBase {
|
||||
public:
|
||||
VariableBase() {}
|
||||
virtual ~VariableBase() {}
|
||||
|
||||
int id_;
|
||||
VibChannelType type_;
|
||||
Filter filter_[3];
|
||||
General general;
|
||||
AlarmDangerHigh danger_high;
|
||||
AlarmAlertHigh alert_high;
|
||||
AlarmDangerLow danger_low;
|
||||
AlarmAlertLow alert_low;
|
||||
|
||||
General gap_general;
|
||||
AlarmDangerHigh gap_danger_high;
|
||||
AlarmAlertHigh gap_alert_high;
|
||||
AlarmDangerLow gap_danger_low;
|
||||
AlarmAlertLow gap_alert_low;
|
||||
|
||||
FrequencybandOutput freband_output[10];
|
||||
};
|
||||
|
||||
// 位移
|
||||
class RadialVariable : public VariableBase {
|
||||
public:
|
||||
bool alert_latching_;
|
||||
bool danger_latching_;
|
||||
RadialImpl not1x_;
|
||||
RadialImpl smax_;
|
||||
};
|
||||
|
||||
// 加速度与速度
|
||||
class AccVelVariable : public VariableBase {
|
||||
public:
|
||||
bool alert_latching_;
|
||||
bool danger_latching_;
|
||||
bool timed_ok_;
|
||||
bool rms_active_;
|
||||
bool integrate_active_;
|
||||
};
|
||||
// 轴向位移
|
||||
class ThrustVariable : public VariableBase {
|
||||
public:
|
||||
bool alert_latching_;
|
||||
bool danger_latching_;
|
||||
bool timed_ok_;
|
||||
ZeroPosition zero_position;
|
||||
};
|
||||
// 动态压力脉动
|
||||
class PressurePulsationVariable : public VariableBase {
|
||||
public:
|
||||
bool fixed;
|
||||
int sample_rate;
|
||||
int bandwidth;
|
||||
int fft_points;
|
||||
bool spectral_synchron;
|
||||
int measuring_min;
|
||||
int measuring_max;
|
||||
int scale_min;
|
||||
int scale_max;
|
||||
bool inherited;
|
||||
};
|
||||
#endif // CARDBASE_H
|
||||
954
config_mgr.cpp
Normal file
954
config_mgr.cpp
Normal file
@ -0,0 +1,954 @@
|
||||
#include "config_mgr.h"
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "tachometer_data.h"
|
||||
#include "keyphase_data.h"
|
||||
#include "singlerelay_data.h"
|
||||
#include "tmrrelayassociation_data.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
ConfigMgr *ConfigMgr::instance = nullptr;
|
||||
|
||||
ConfigMgr::~ConfigMgr() {
|
||||
}
|
||||
|
||||
void ConfigMgr::Save(QString & file_path) {
|
||||
QJsonObject doc_obj;
|
||||
int slot = 0;
|
||||
QJsonArray card_type;
|
||||
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||
if (card_type_[i] == kCardNone) {
|
||||
continue;
|
||||
}
|
||||
QJsonObject card_item;
|
||||
slot = i + 1;
|
||||
card_item["type"] = card_type_[i];
|
||||
card_item["slot"] = slot;
|
||||
card_type.append(card_item);
|
||||
if (card_type_[i] != kCardVibSingle &&
|
||||
card_type_[i] != kCardVibTMRPrimary &&
|
||||
card_type_[i] != kCardSpeedSingle &&
|
||||
card_type_[i] != kCardSpeedTMRPrimary &&
|
||||
card_type_[i] != kCardKeyphaseSingle &&
|
||||
card_type_[i] != kCardRelaySingle &&
|
||||
card_type_[i] != kCardRelayTMRPrimary &&
|
||||
card_type_[i] != kCardRelaySingleNOK) {
|
||||
continue;
|
||||
}
|
||||
// process slot
|
||||
QJsonObject slot_item;
|
||||
if (card_type_[i] != kCardRelaySingle &&
|
||||
card_type_[i] != kCardRelayTMRPrimary &&
|
||||
card_type_[i] != kCardRelaySingleNOK &&
|
||||
card_type_[i] != kCardRelayTMRBackup) {
|
||||
QJsonObject dc_output;
|
||||
for (int cid = 0; cid < CHANNEL_COUNT; ++cid) {
|
||||
QJsonObject channel_item;
|
||||
if (card_type_[i] == kCardVibSingle ||
|
||||
card_type_[i] == kCardVibTMRPrimary) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
channel_item["standby"] = ptr->base_config_[cid].standby;
|
||||
channel_item["active"] = ptr->base_config_[cid].active;
|
||||
// channel_item["rack_type"] = 0; // TODO:
|
||||
channel_item["channel_type"] = ptr->base_config_[cid].channel_type;
|
||||
// channel_item["transducer_id"] = ptr->base_config_[cid].transducer_id;
|
||||
// channel_item["scale_factor"] = ptr->base_config_[cid].scale_factor;
|
||||
// channel_item["sampling_rate"] = ptr->base_config_[cid].sampling_rate;
|
||||
channel_item["power"] = ptr->base_config_[cid].power;
|
||||
channel_item["point_name"] = ptr->base_config_[cid].point_name;
|
||||
channel_item["chan_id"] = ptr->base_config_[cid].chan_id;
|
||||
channel_item["sensitivity_unit"] = ptr->base_config_[cid].sensitivity_unit;
|
||||
channel_item["signal_sensitivity"] = ptr->base_config_[cid].signal_sensitivity;
|
||||
|
||||
|
||||
QJsonArray voltage_range;
|
||||
voltage_range.append(ptr->base_config_[cid].normal_voltage_low);
|
||||
voltage_range.append(ptr->base_config_[cid].normal_voltage_high);
|
||||
channel_item["normal_voltage_range"] = voltage_range;
|
||||
// output channel
|
||||
QJsonObject dc_output_item;
|
||||
if(ptr->dc_output[cid].output_channel != -1){
|
||||
dc_output_item["output_channel"] = ptr->dc_output[cid].output_channel;
|
||||
dc_output_item["minmum"] = ptr->dc_output[cid].minmum;
|
||||
dc_output_item["maxmum"] = ptr->dc_output[cid].maxmum;
|
||||
dc_output[QString::number(cid + 1)] = dc_output_item;
|
||||
}
|
||||
if(ptr->base_config_[cid].channel_type == kVibRadial || ptr->base_config_[cid].channel_type == kVibThrust ||
|
||||
ptr->base_config_[cid].channel_type == kVibAcc || ptr->base_config_[cid].channel_type == kVibVelocity ){
|
||||
if(ptr->base_config_[cid].channel_type != kVibThrust){
|
||||
channel_item["keyphase"] = ptr->base_config_[cid].keyphase;
|
||||
channel_item["keyphase_slot"] = ptr->base_config_[cid].keyphase_slot;
|
||||
channel_item["keyphase_ch"] = ptr->base_config_[cid].keyphase_ch;
|
||||
}
|
||||
}
|
||||
// if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){
|
||||
// setpoint_data["low_upper"] = qRound(ptr->alert_danger_press[cid].low_upper * 10)/10.0;
|
||||
// setpoint_data["low_enable"] = ptr->alert_danger_press[cid].low_enable;
|
||||
// setpoint_data["mid1_upper"] = qRound(ptr->alert_danger_press[cid].mid1_upper * 10)/10.0;
|
||||
// setpoint_data["mid1_enable"] = ptr->alert_danger_press[cid].mid1_enable;
|
||||
// setpoint_data["mid2_upper"] = qRound(ptr->alert_danger_press[cid].mid2_upper * 10)/10.0;
|
||||
// setpoint_data["mid2_enable"] = ptr->alert_danger_press[cid].mid2_enable;
|
||||
// setpoint_data["danger_param"] = ptr->alert_danger_press[cid].danger_param;
|
||||
// setpoint_data["danger_upper"] = qRound(ptr->alert_danger_press[cid].danger_upper * 10)/10.0;
|
||||
// setpoint_data["danger_enable"] = ptr->alert_danger_press[cid].danger_enable;
|
||||
// }
|
||||
// channel_item["setpoint"] = setpoint_data;
|
||||
// variables
|
||||
QJsonObject variables;
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
|
||||
if (base_channel_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (ptr->base_config_[cid].channel_type == kVibRadial) {
|
||||
std::shared_ptr<RadialVariable> radial_ptr = std::dynamic_pointer_cast<RadialVariable>(base_channel_ptr);
|
||||
if(radial_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = radial_ptr->filter_[0].low;
|
||||
low_pass["high"] = radial_ptr->filter_[0].high;
|
||||
low_pass["checked"] = radial_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = radial_ptr->filter_[1].low;
|
||||
high_pass["high"] = radial_ptr->filter_[1].high;
|
||||
high_pass["checked"] = radial_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = radial_ptr->filter_[2].low;
|
||||
band_pass["high"] = radial_ptr->filter_[2].high;
|
||||
band_pass["checked"] = radial_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
// measurement
|
||||
QJsonObject measurement,general,alarm;
|
||||
general["output_used"] = radial_ptr->general.output_used;
|
||||
general["engieneering_unit"] = radial_ptr->general.engineering_unit;
|
||||
general["rectifier_function"] = radial_ptr->general.rectifier_function;
|
||||
|
||||
alarm["danger_high_level"] = radial_ptr->danger_high.level;
|
||||
alarm["danger_high_hysteresis"] = radial_ptr->danger_high.hysteresis;
|
||||
alarm["danger_high_delay"] = radial_ptr->danger_high.delay;
|
||||
alarm["danger_high_enable"] = radial_ptr->danger_high.enable;
|
||||
alarm["danger_high_latch"] = radial_ptr->danger_high.latch;
|
||||
alarm["alert_high_level"] = radial_ptr->alert_high.level;
|
||||
alarm["alert_high_hysteresis"] = radial_ptr->alert_high.hysteresis;
|
||||
alarm["alert_high_delay"] = radial_ptr->alert_high.delay;
|
||||
alarm["alert_high_enable"] = radial_ptr->alert_high.enable;
|
||||
alarm["alert_high_latch"] = radial_ptr->alert_high.latch;
|
||||
// alarm["danger_low_level"] = radial_ptr->danger_low.level;
|
||||
// alarm["danger_low_hysteresis"] = radial_ptr->danger_low.hysteresis;
|
||||
// alarm["danger_low_delay"] = radial_ptr->danger_low.delay;
|
||||
// alarm["danger_low_enable"] = radial_ptr->danger_low.enable;
|
||||
// alarm["danger_low_latch"] = radial_ptr->danger_low.latch;
|
||||
// alarm["alert_low_level"] = radial_ptr->alert_low.level;
|
||||
// alarm["alert_low_hysteresis"] = radial_ptr->alert_low.hysteresis;
|
||||
// alarm["alert_low_delay"] = radial_ptr->alert_low.delay;
|
||||
// alarm["alert_low_enable"] = radial_ptr->alert_low.enable;
|
||||
// alarm["alert_low_latch"] = radial_ptr->alert_low.latch;
|
||||
measurement["general"] = general;
|
||||
measurement["alarm"] = alarm;
|
||||
variables["measurement"] = measurement;
|
||||
// gap
|
||||
QJsonObject gap,gap_general,gap_alarm;
|
||||
gap_general["output_used"] = radial_ptr->gap_general.output_used;
|
||||
gap_general["engieneering_unit"] = radial_ptr->gap_general.engineering_unit;
|
||||
gap_general["rectifier_function"] = radial_ptr->gap_general.rectifier_function;
|
||||
|
||||
gap_alarm["danger_high_level"] = radial_ptr->gap_danger_high.level;
|
||||
gap_alarm["danger_high_hysteresis"] = radial_ptr->gap_danger_high.hysteresis;
|
||||
gap_alarm["danger_high_delay"] = radial_ptr->gap_danger_high.delay;
|
||||
gap_alarm["danger_high_enable"] = radial_ptr->gap_danger_high.enable;
|
||||
gap_alarm["danger_high_latch"] = radial_ptr->gap_danger_high.latch;
|
||||
gap_alarm["alert_high_level"] = radial_ptr->gap_alert_high.level;
|
||||
gap_alarm["alert_high_hysteresis"] = radial_ptr->gap_alert_high.hysteresis;
|
||||
gap_alarm["alert_high_delay"] = radial_ptr->gap_alert_high.delay;
|
||||
gap_alarm["alert_high_enable"] = radial_ptr->gap_alert_high.enable;
|
||||
gap_alarm["alert_high_latch"] = radial_ptr->gap_alert_high.latch;
|
||||
// gap_alarm["danger_low_level"] = radial_ptr->gap_danger_low.level;
|
||||
// gap_alarm["danger_low_hysteresis"] = radial_ptr->gap_danger_low.hysteresis;
|
||||
// gap_alarm["danger_low_delay"] = radial_ptr->gap_danger_low.delay;
|
||||
// gap_alarm["danger_low_enable"] = radial_ptr->gap_danger_low.enable;
|
||||
// gap_alarm["danger_low_latch"] = radial_ptr->gap_danger_low.latch;
|
||||
// gap_alarm["alert_low_level"] = radial_ptr->gap_alert_low.level;
|
||||
// gap_alarm["alert_low_hysteresis"] = radial_ptr->gap_alert_low.hysteresis;
|
||||
// gap_alarm["alert_low_delay"] = radial_ptr->gap_alert_low.delay;
|
||||
// gap_alarm["alert_low_enable"] = radial_ptr->gap_alert_low.enable;
|
||||
// gap_alarm["alert_low_latch"] = radial_ptr->gap_alert_low.latch;
|
||||
gap["general"] = gap_general;
|
||||
gap["alarm"] = gap_alarm;
|
||||
variables["gap"] = gap;
|
||||
|
||||
|
||||
}else if(ptr->base_config_[cid].channel_type == kVibThrust){
|
||||
std::shared_ptr<ThrustVariable> thrust_ptr = std::dynamic_pointer_cast<ThrustVariable>(base_channel_ptr);
|
||||
if(thrust_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = thrust_ptr->filter_[0].low;
|
||||
low_pass["high"] = thrust_ptr->filter_[0].high;
|
||||
low_pass["checked"] = thrust_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = thrust_ptr->filter_[1].low;
|
||||
high_pass["high"] = thrust_ptr->filter_[1].high;
|
||||
high_pass["checked"] = thrust_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = thrust_ptr->filter_[2].low;
|
||||
band_pass["high"] = thrust_ptr->filter_[2].high;
|
||||
band_pass["checked"] = thrust_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
// gap
|
||||
QJsonObject gap,gap_general,gap_alarm;
|
||||
gap_general["output_used"] = thrust_ptr->gap_general.output_used;
|
||||
gap_general["engieneering_unit"] = thrust_ptr->gap_general.engineering_unit;
|
||||
|
||||
gap_alarm["danger_high_level"] = thrust_ptr->gap_danger_high.level;
|
||||
gap_alarm["danger_high_hysteresis"] = thrust_ptr->gap_danger_high.hysteresis;
|
||||
gap_alarm["danger_high_delay"] = thrust_ptr->gap_danger_high.delay;
|
||||
gap_alarm["danger_high_enable"] = thrust_ptr->gap_danger_high.enable;
|
||||
gap_alarm["danger_high_latch"] = thrust_ptr->gap_danger_high.latch;
|
||||
gap_alarm["alert_high_level"] = thrust_ptr->gap_alert_high.level;
|
||||
gap_alarm["alert_high_hysteresis"] = thrust_ptr->gap_alert_high.hysteresis;
|
||||
gap_alarm["alert_high_delay"] = thrust_ptr->gap_alert_high.delay;
|
||||
gap_alarm["alert_high_enable"] = thrust_ptr->gap_alert_high.enable;
|
||||
gap_alarm["alert_high_latch"] = thrust_ptr->gap_alert_high.latch;
|
||||
gap_alarm["danger_low_level"] = thrust_ptr->gap_danger_low.level;
|
||||
gap_alarm["danger_low_hysteresis"] = thrust_ptr->gap_danger_low.hysteresis;
|
||||
gap_alarm["danger_low_delay"] = thrust_ptr->gap_danger_low.delay;
|
||||
gap_alarm["danger_low_enable"] = thrust_ptr->gap_danger_low.enable;
|
||||
gap_alarm["danger_low_latch"] = thrust_ptr->gap_danger_low.latch;
|
||||
gap_alarm["alert_low_level"] = thrust_ptr->gap_alert_low.level;
|
||||
gap_alarm["alert_low_hysteresis"] = thrust_ptr->gap_alert_low.hysteresis;
|
||||
gap_alarm["alert_low_delay"] = thrust_ptr->gap_alert_low.delay;
|
||||
gap_alarm["alert_low_enable"] = thrust_ptr->gap_alert_low.enable;
|
||||
gap_alarm["alert_low_latch"] = thrust_ptr->gap_alert_low.latch;
|
||||
gap["general"] = gap_general;
|
||||
gap["alarm"] = gap_alarm;
|
||||
variables["gap"] = gap;
|
||||
variables["negation"] = thrust_ptr->zero_position.negation;
|
||||
variables["zero_position"] = thrust_ptr->zero_position.value;
|
||||
|
||||
}else if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){
|
||||
std::shared_ptr<PressurePulsationVariable> pressure_ptr = std::dynamic_pointer_cast<PressurePulsationVariable>(base_channel_ptr);
|
||||
if(pressure_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = pressure_ptr->filter_[0].low;
|
||||
low_pass["high"] = pressure_ptr->filter_[0].high;
|
||||
low_pass["checked"] = pressure_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = pressure_ptr->filter_[1].low;
|
||||
high_pass["high"] = pressure_ptr->filter_[1].high;
|
||||
high_pass["checked"] = pressure_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = pressure_ptr->filter_[2].low;
|
||||
band_pass["high"] = pressure_ptr->filter_[2].high;
|
||||
band_pass["checked"] = pressure_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
QJsonObject sampling;
|
||||
QJsonObject scaling;
|
||||
sampling["fixed"] = pressure_ptr->fixed;
|
||||
sampling["sample_rate"] = pressure_ptr->sample_rate;
|
||||
sampling["band_width"] = pressure_ptr->bandwidth;
|
||||
sampling["fft_points"] = pressure_ptr->fft_points;
|
||||
scaling["measuring_min"] = pressure_ptr->measuring_min;
|
||||
scaling["measuring_max"] = pressure_ptr->measuring_max;
|
||||
scaling["scale_min"] = pressure_ptr->scale_min;
|
||||
scaling["scale_max"] = pressure_ptr->scale_max;
|
||||
variables["sampling"] = sampling;
|
||||
variables["scaling"] = scaling;
|
||||
QJsonObject general;
|
||||
general["engieneering_unit"] = pressure_ptr->general.engineering_unit;
|
||||
variables["general"] = general;
|
||||
QJsonObject freband_output,number;
|
||||
for (int var = 0; var < 10; ++var) {
|
||||
if(pressure_ptr->freband_output[var].start != 0 || pressure_ptr->freband_output[var].end != 0){
|
||||
freband_output["enable"] = pressure_ptr->freband_output[var].enable;
|
||||
freband_output["start"] = pressure_ptr->freband_output[var].start;
|
||||
freband_output["end"] = pressure_ptr->freband_output[var].end;
|
||||
number[QString::number(var + 1)] = freband_output;
|
||||
}
|
||||
}
|
||||
variables["freband_output"] = number;
|
||||
|
||||
} else if(ptr->base_config_[cid].channel_type == kVibAcc){
|
||||
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||
if(av_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = av_ptr->filter_[0].low;
|
||||
low_pass["high"] = av_ptr->filter_[0].high;
|
||||
low_pass["checked"] = av_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = av_ptr->filter_[1].low;
|
||||
high_pass["high"] = av_ptr->filter_[1].high;
|
||||
high_pass["checked"] = av_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = av_ptr->filter_[2].low;
|
||||
band_pass["high"] = av_ptr->filter_[2].high;
|
||||
band_pass["checked"] = av_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
// processed output
|
||||
QJsonObject processed_output,general,alarm;
|
||||
general["output_used"] = av_ptr->general.output_used;
|
||||
general["engieneering_unit"] = av_ptr->general.engineering_unit;
|
||||
general["rectifier_function"] = av_ptr->general.rectifier_function;
|
||||
|
||||
alarm["danger_high_level"] = av_ptr->danger_high.level;
|
||||
alarm["danger_high_hysteresis"] = av_ptr->danger_high.hysteresis;
|
||||
alarm["danger_high_delay"] = av_ptr->danger_high.delay;
|
||||
alarm["danger_high_enable"] = av_ptr->danger_high.enable;
|
||||
alarm["danger_high_latch"] = av_ptr->danger_high.latch;
|
||||
alarm["alert_high_level"] = av_ptr->alert_high.level;
|
||||
alarm["alert_high_hysteresis"] = av_ptr->alert_high.hysteresis;
|
||||
alarm["alert_high_delay"] = av_ptr->alert_high.delay;
|
||||
alarm["alert_high_enable"] = av_ptr->alert_high.enable;
|
||||
alarm["alert_high_latch"] = av_ptr->alert_high.latch;
|
||||
// alarm["danger_low_level"] = av_ptr->danger_low.level;
|
||||
// alarm["danger_low_hysteresis"] = av_ptr->danger_low.hysteresis;
|
||||
// alarm["danger_low_delay"] = av_ptr->danger_low.delay;
|
||||
// alarm["danger_low_enable"] = av_ptr->danger_low.enable;
|
||||
// alarm["danger_low_latch"] = av_ptr->danger_low.latch;
|
||||
// alarm["alert_low_level"] = av_ptr->alert_low.level;
|
||||
// alarm["alert_low_hysteresis"] = av_ptr->alert_low.hysteresis;
|
||||
// alarm["alert_low_delay"] = av_ptr->alert_low.delay;
|
||||
// alarm["alert_low_enable"] = av_ptr->alert_low.enable;
|
||||
// alarm["alert_low_latch"] = av_ptr->alert_low.latch;
|
||||
processed_output["general"] = general;
|
||||
processed_output["alarm"] = alarm;
|
||||
variables["processed_output"] = processed_output;
|
||||
QJsonObject freband_output,number;
|
||||
for (int var = 0; var < 10; ++var) {
|
||||
if(av_ptr->freband_output[var].start != 0 || av_ptr->freband_output[var].end != 0){
|
||||
freband_output["enable"] = av_ptr->freband_output[var].enable;
|
||||
freband_output["start"] = av_ptr->freband_output[var].start;
|
||||
freband_output["end"] = av_ptr->freband_output[var].end;
|
||||
number[QString::number(var + 1)] = freband_output;
|
||||
}
|
||||
}
|
||||
variables["freband_output"] = number;
|
||||
|
||||
}else if(ptr->base_config_[cid].channel_type == kVibVelocity){
|
||||
std::shared_ptr<AccVelVariable> vel_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||
if(vel_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = vel_ptr->filter_[0].low;
|
||||
low_pass["high"] = vel_ptr->filter_[0].high;
|
||||
low_pass["checked"] = vel_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = vel_ptr->filter_[1].low;
|
||||
high_pass["high"] = vel_ptr->filter_[1].high;
|
||||
high_pass["checked"] = vel_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = vel_ptr->filter_[2].low;
|
||||
band_pass["high"] = vel_ptr->filter_[2].high;
|
||||
band_pass["checked"] = vel_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
// processed output
|
||||
QJsonObject processed_output,general,alarm;
|
||||
general["output_used"] = vel_ptr->general.output_used;
|
||||
general["engieneering_unit"] = vel_ptr->general.engineering_unit;
|
||||
general["rectifier_function"] = vel_ptr->general.rectifier_function;
|
||||
|
||||
alarm["danger_high_level"] = vel_ptr->danger_high.level;
|
||||
alarm["danger_high_hysteresis"] = vel_ptr->danger_high.hysteresis;
|
||||
alarm["danger_high_delay"] = vel_ptr->danger_high.delay;
|
||||
alarm["danger_high_enable"] = vel_ptr->danger_high.enable;
|
||||
alarm["danger_high_latch"] = vel_ptr->danger_high.latch;
|
||||
alarm["alert_high_level"] = vel_ptr->alert_high.level;
|
||||
alarm["alert_high_hysteresis"] = vel_ptr->alert_high.hysteresis;
|
||||
alarm["alert_high_delay"] = vel_ptr->alert_high.delay;
|
||||
alarm["alert_high_enable"] = vel_ptr->alert_high.enable;
|
||||
alarm["alert_high_latch"] = vel_ptr->alert_high.latch;
|
||||
// alarm["danger_low_level"] = vel_ptr->danger_low.level;
|
||||
// alarm["danger_low_hysteresis"] = vel_ptr->danger_low.hysteresis;
|
||||
// alarm["danger_low_delay"] = vel_ptr->danger_low.delay;
|
||||
// alarm["danger_low_enable"] = vel_ptr->danger_low.enable;
|
||||
// alarm["danger_low_latch"] = vel_ptr->danger_low.latch;
|
||||
// alarm["alert_low_level"] = vel_ptr->alert_low.level;
|
||||
// alarm["alert_low_hysteresis"] = vel_ptr->alert_low.hysteresis;
|
||||
// alarm["alert_low_delay"] = vel_ptr->alert_low.delay;
|
||||
// alarm["alert_low_enable"] = vel_ptr->alert_low.enable;
|
||||
// alarm["alert_low_latch"] = vel_ptr->alert_low.latch;
|
||||
processed_output["general"] = general;
|
||||
processed_output["alarm"] = alarm;
|
||||
variables["processed_output"] = processed_output;
|
||||
}
|
||||
channel_item["variable"] = variables;
|
||||
} else if (card_type_[i] == kCardSpeedSingle || card_type_[i] == kCardSpeedTMRPrimary) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<TachometerData> ptr = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_low);
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_high);
|
||||
QJsonObject setpoint_data;
|
||||
setpoint_data["speed_upper"] = ptr->alert_danger[cid].speed_upper;
|
||||
setpoint_data["speed_lower"] = ptr->alert_danger[cid].speed_lower;
|
||||
setpoint_data["speed_upper_enable"] = ptr->alert_danger[cid].speed_upper_enable;
|
||||
setpoint_data["speed_lower_enable"] = ptr->alert_danger[cid].speed_lower_enable;
|
||||
setpoint_data["danger_speed_upper"] = ptr->alert_danger[cid].danger_speed_upper;
|
||||
channel_item["setpoint"] = setpoint_data;
|
||||
channel_item.insert("active", ptr->variables_[cid].active);
|
||||
channel_item.insert("normal_voltage_range", voltage_range_array);
|
||||
channel_item.insert("threshold", ptr->variables_[cid].threshold);
|
||||
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
|
||||
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution);
|
||||
channel_item.insert("record_output", ptr->variables_[cid].record_output);
|
||||
channel_item.insert("two_ma_clamp", ptr->variables_[cid].two_ma_clamp);
|
||||
channel_item.insert("alert_latching", ptr->variables_[cid].alert_latching);
|
||||
channel_item.insert("overspeed_latching", ptr->variables_[cid].overspeed_latching);
|
||||
channel_item.insert("normal_latching", ptr->variables_[cid].normal_latching);
|
||||
channel_item.insert("speed_peak", ptr->variables_[cid].speed_peek);
|
||||
channel_item.insert("default_speed", ptr->variables_[cid].default_speed);
|
||||
channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold);
|
||||
channel_item.insert("point_name",ptr->variables_[cid].point_name);
|
||||
|
||||
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<KeyphaseData> ptr = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_low);
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_high);
|
||||
channel_item.insert("active", ptr->variables_[cid].active);
|
||||
channel_item.insert("normal_voltage_range", voltage_range_array);
|
||||
channel_item.insert("threshold", ptr->variables_[cid].threshold);
|
||||
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
|
||||
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution);
|
||||
channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold);
|
||||
}
|
||||
slot_item[QString::number(cid + 1)] = channel_item;
|
||||
slot_item["dc_output"] = dc_output;
|
||||
}
|
||||
slot_item["version"] = 1;
|
||||
}else{
|
||||
for(int ch = 0;ch < RELAY_COUNT;++ch){
|
||||
QJsonObject channel_item;
|
||||
if(card_type_[i] == kCardRelaySingle){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<SingleRelayData> ptr = std::dynamic_pointer_cast<SingleRelayData>(base_ptr);
|
||||
if(ptr->single_relay[ch].logic_expression != ""){
|
||||
qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression;
|
||||
channel_item.insert("logic_expression", ptr->single_relay[ch].logic_expression);
|
||||
channel_item.insert("active", ptr->single_relay[ch].active);
|
||||
}
|
||||
|
||||
}
|
||||
if(!channel_item.isEmpty() ){
|
||||
slot_item[QString::number(ch + 1)] = channel_item;
|
||||
}
|
||||
}
|
||||
slot_item["version"] = 1;
|
||||
}
|
||||
doc_obj[QString::number(slot)] = slot_item;
|
||||
}
|
||||
doc_obj["card_type"] = card_type;
|
||||
// TODO: show success message box
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setObject(doc_obj);
|
||||
QFile file(file_path);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
}
|
||||
|
||||
void ConfigMgr::Load(QString filename) {
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
// TODO: show message box
|
||||
qDebug() << "Cannot open file for reading:" << filename;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
// TODO: show message box
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
// TODO: show message box
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
filename_ = filename;
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
// parse card_type
|
||||
QJsonArray card_type = json_obj["card_type"].toArray();
|
||||
int slot = 0;
|
||||
QJsonObject temp_obj;
|
||||
for (int i = 0; i < card_type.size(); ++i) {
|
||||
temp_obj = card_type[i].toObject();
|
||||
slot = temp_obj["slot"].toInt();
|
||||
card_type_[slot - 1] = static_cast<CardType>(temp_obj["type"].toInt());
|
||||
}
|
||||
// parse each slot
|
||||
QJsonObject channel;
|
||||
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||
if (card_type_[i] == kCardNone) {
|
||||
continue;
|
||||
}
|
||||
slot = i + 1;
|
||||
if (json_obj[QString::number(slot)].isNull() && card_type_[i] != kCardRelayTMRBackup) {
|
||||
continue;
|
||||
}
|
||||
temp_obj = json_obj[QString::number(slot)].toObject();
|
||||
if (card_type_[i] == kCardVibSingle) {
|
||||
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||
vib_data->version_ = temp_obj["version"].toInt();
|
||||
vib_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
vib_data->slot_ = slot;
|
||||
// dc_output
|
||||
QJsonObject dc_output_obj = temp_obj["dc_output"].toObject();
|
||||
if(!dc_output_obj.isEmpty()){
|
||||
QJsonObject output_obj;
|
||||
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||
output_obj = dc_output_obj[QString::number(var + 1)].toObject();
|
||||
if(output_obj.isEmpty())
|
||||
continue;
|
||||
vib_data->dc_output[var].output_channel = output_obj["output_channel"].toInt();
|
||||
vib_data->dc_output[var].minmum = output_obj["minmum"].toDouble();
|
||||
vib_data->dc_output[var].maxmum = output_obj["maxmum"].toDouble();
|
||||
}
|
||||
|
||||
}
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = vib_data->GetChannelPtr(j + 1);
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
if(channel.isEmpty())
|
||||
continue;
|
||||
// base info
|
||||
vib_data->base_config_[j].standby = channel["standby"].toBool();
|
||||
vib_data->base_config_[j].active = channel["active"].toBool();
|
||||
// vib_data->base_config_[j].rack_type = channel["rack_type"].toInt();
|
||||
// vib_data->base_config_[j].tmr_group = channel["tmr_group"].toString();
|
||||
vib_data->base_config_[j].channel_type = channel["channel_type"].toInt();
|
||||
vib_data->base_config_[j].transducer_id = channel["transducer_id"].toInt();
|
||||
// vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble();
|
||||
// vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt();
|
||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||
vib_data->base_config_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
vib_data->base_config_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
vib_data->base_config_[j].power = channel["power"].toBool();
|
||||
vib_data->base_config_[j].point_name = channel["point_name"].toString();
|
||||
vib_data->base_config_[j].chan_id = channel["chan_id"].toString();
|
||||
vib_data->base_config_[j].sensitivity_unit = channel["sensitivity_unit"].toInt();
|
||||
vib_data->base_config_[j].signal_sensitivity = channel["signal_sensitivity"].toDouble();
|
||||
vib_data->base_config_[j].keyphase = channel["keyphase"].toBool();
|
||||
vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt();
|
||||
vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt();
|
||||
//setpoint
|
||||
QJsonObject setpoint_data = channel["setpoint"].toObject();
|
||||
if(vib_data->base_config_[j].channel_type == kVibRadial || vib_data->base_config_[j].channel_type == kVibThrust ||
|
||||
vib_data->base_config_[j].channel_type == kVibAcc ||vib_data->base_config_[j].channel_type == kVibVelocity ){
|
||||
vib_data->base_config_[j].keyphase = channel["keyphase"].toBool();
|
||||
vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt();
|
||||
vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt();
|
||||
}
|
||||
|
||||
// if(vib_data->base_config_[j].channel_type == kVibPressurePulsation){
|
||||
// vib_data->alert_danger_press[j].low_upper = setpoint_data["low_upper"].toDouble();
|
||||
// vib_data->alert_danger_press[j].low_enable = setpoint_data["low_enable"].toBool();
|
||||
// vib_data->alert_danger_press[j].mid1_upper = setpoint_data["mid1_upper"].toDouble();
|
||||
// vib_data->alert_danger_press[j].mid1_enable = setpoint_data["mid1_enable"].toBool();
|
||||
// vib_data->alert_danger_press[j].mid2_upper = setpoint_data["mid2_upper"].toDouble();
|
||||
// vib_data->alert_danger_press[j].mid2_enable = setpoint_data["mid2_enable"].toBool();
|
||||
// vib_data->alert_danger_press[j].danger_param = setpoint_data["danger_param"].toInt();
|
||||
// vib_data->alert_danger_press[j].danger_upper = setpoint_data["danger_upper"].toDouble();
|
||||
// vib_data->alert_danger_press[j].danger_enable = setpoint_data["danger_enable"].toBool();
|
||||
// }
|
||||
// variables
|
||||
QJsonObject tmp_variable = channel["variable"].toObject();
|
||||
switch (vib_data->base_config_[j].channel_type) {
|
||||
case kVibRadial: {
|
||||
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject measurement, gap,m_general,m_alarm,g_general,g_alarm;
|
||||
measurement = tmp_variable["measurement"].toObject();
|
||||
gap = tmp_variable["gap"].toObject();
|
||||
m_general = measurement["general"].toObject();
|
||||
m_alarm = measurement["alarm"].toObject();
|
||||
g_general = gap["general"].toObject();
|
||||
g_alarm = gap["alarm"].toObject();
|
||||
variable->general.output_used = m_general["output_used"].toBool();
|
||||
variable->general.engineering_unit = m_general["engieneering_unit"].toInt();
|
||||
variable->general.rectifier_function = m_general["rectifier_function"].toInt();
|
||||
variable->danger_high.level = m_alarm["danger_high_level"].toDouble();
|
||||
variable->danger_high.hysteresis = m_alarm["danger_high_hysteresis"].toDouble();
|
||||
variable->danger_high.delay = m_alarm["danger_high_delay"].toInt();
|
||||
variable->danger_high.enable = m_alarm["danger_high_enable"].toBool();
|
||||
variable->danger_high.latch = m_alarm["danger_high_latch"].toBool();
|
||||
variable->alert_high.level = m_alarm["alert_high_level"].toDouble();
|
||||
variable->alert_high.hysteresis = m_alarm["alert_high_hysteresis"].toDouble();
|
||||
variable->alert_high.delay = m_alarm["alert_high_delay"].toInt();
|
||||
variable->alert_high.enable = m_alarm["alert_high_enable"].toBool();
|
||||
variable->alert_high.latch = m_alarm["alert_high_latch"].toBool();
|
||||
// variable->danger_low.level = m_alarm["danger_low_level"].toDouble();
|
||||
// variable->danger_low.hysteresis = m_alarm["danger_low_hysteresis"].toDouble();
|
||||
// variable->danger_low.delay = m_alarm["danger_low_delay"].toInt();
|
||||
// variable->danger_low.enable = m_alarm["danger_low_enable"].toBool();
|
||||
// variable->danger_low.latch = m_alarm["danger_low_latch"].toBool();
|
||||
// variable->alert_low.level = m_alarm["alert_low_level"].toDouble();
|
||||
// variable->alert_low.hysteresis = m_alarm["alert_low_hysteresis"].toDouble();
|
||||
// variable->alert_low.delay = m_alarm["alert_low_delay"].toInt();
|
||||
// variable->alert_low.enable = m_alarm["alert_low_enable"].toBool();
|
||||
// variable->alert_low.latch = m_alarm["alert_low_latch"].toBool();
|
||||
|
||||
variable->gap_general.output_used = g_general["output_used"].toBool();
|
||||
variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt();
|
||||
variable->gap_general.rectifier_function = g_general["rectifier_function"].toInt();
|
||||
variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble();
|
||||
variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble();
|
||||
variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt();
|
||||
variable->gap_danger_high.enable = g_alarm["danger_high_enable"].toBool();
|
||||
variable->gap_danger_high.latch = g_alarm["danger_high_latch"].toBool();
|
||||
variable->gap_alert_high.level = g_alarm["alert_high_level"].toDouble();
|
||||
variable->gap_alert_high.hysteresis = g_alarm["alert_high_hysteresis"].toDouble();
|
||||
variable->gap_alert_high.delay = g_alarm["alert_high_delay"].toInt();
|
||||
variable->gap_alert_high.enable = g_alarm["alert_high_enable"].toBool();
|
||||
variable->gap_alert_high.latch = g_alarm["alert_high_latch"].toBool();
|
||||
// variable->gap_danger_low.level = g_alarm["danger_low_level"].toDouble();
|
||||
// variable->gap_danger_low.hysteresis = g_alarm["danger_low_hysteresis"].toDouble();
|
||||
// variable->gap_danger_low.delay = g_alarm["danger_low_delay"].toInt();
|
||||
// variable->gap_danger_low.enable = g_alarm["danger_low_enable"].toBool();
|
||||
// variable->gap_danger_low.latch = g_alarm["danger_low_latch"].toBool();
|
||||
// variable->gap_alert_low.level = g_alarm["alert_low_level"].toDouble();
|
||||
// variable->gap_alert_low.hysteresis = g_alarm["alert_low_hysteresis"].toDouble();
|
||||
// variable->gap_alert_low.delay = g_alarm["alert_low_delay"].toInt();
|
||||
// variable->gap_alert_low.enable = g_alarm["alert_low_enable"].toBool();
|
||||
// variable->gap_alert_low.latch = g_alarm["alert_low_latch"].toBool();
|
||||
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
case kVibThrust: {
|
||||
std::shared_ptr<ThrustVariable> variable = std::make_shared<ThrustVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject gap,g_general,g_alarm;
|
||||
gap = tmp_variable["gap"].toObject();
|
||||
g_general = gap["general"].toObject();
|
||||
g_alarm = gap["alarm"].toObject();
|
||||
variable->gap_general.output_used = g_general["output_used"].toBool();
|
||||
variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt();
|
||||
variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble();
|
||||
variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble();
|
||||
variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt();
|
||||
variable->gap_danger_high.enable = g_alarm["danger_high_enable"].toBool();
|
||||
variable->gap_danger_high.latch = g_alarm["danger_high_latch"].toBool();
|
||||
variable->gap_alert_high.level = g_alarm["alert_high_level"].toDouble();
|
||||
variable->gap_alert_high.hysteresis = g_alarm["alert_high_hysteresis"].toDouble();
|
||||
variable->gap_alert_high.delay = g_alarm["alert_high_delay"].toInt();
|
||||
variable->gap_alert_high.enable = g_alarm["alert_high_enable"].toBool();
|
||||
variable->gap_alert_high.latch = g_alarm["alert_high_latch"].toBool();
|
||||
variable->gap_danger_low.level = g_alarm["danger_low_level"].toDouble();
|
||||
variable->gap_danger_low.hysteresis = g_alarm["danger_low_hysteresis"].toDouble();
|
||||
variable->gap_danger_low.delay = g_alarm["danger_low_delay"].toInt();
|
||||
variable->gap_danger_low.enable = g_alarm["danger_low_enable"].toBool();
|
||||
variable->gap_danger_low.latch = g_alarm["danger_low_latch"].toBool();
|
||||
variable->gap_alert_low.level = g_alarm["alert_low_level"].toDouble();
|
||||
variable->gap_alert_low.hysteresis = g_alarm["alert_low_hysteresis"].toDouble();
|
||||
variable->gap_alert_low.delay = g_alarm["alert_low_delay"].toInt();
|
||||
variable->gap_alert_low.enable = g_alarm["alert_low_enable"].toBool();
|
||||
variable->gap_alert_low.latch = g_alarm["alert_low_latch"].toBool();
|
||||
variable->zero_position.value = tmp_variable["zero_position"].toDouble();
|
||||
variable->zero_position.negation = tmp_variable["negation"].toBool();
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
case kVibPressurePulsation:{
|
||||
std::shared_ptr<PressurePulsationVariable> variable = std::make_shared<PressurePulsationVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject processed_output, general, alarm;
|
||||
processed_output = tmp_variable["processed_output"].toObject();
|
||||
general = processed_output["general"].toObject();
|
||||
alarm = processed_output["alarm"].toObject();
|
||||
variable->general.output_used = general["output_used"].toBool();
|
||||
variable->general.engineering_unit = general["engieneering_unit"].toInt();
|
||||
variable->general.rectifier_function = general["rectifier_function"].toInt();
|
||||
variable->danger_high.level = alarm["danger_high_level"].toDouble();
|
||||
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
|
||||
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
|
||||
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
|
||||
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
|
||||
variable->alert_high.level = alarm["alert_high_level"].toDouble();
|
||||
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
|
||||
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
|
||||
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
|
||||
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
|
||||
// variable->danger_low.level = alarm["danger_low_level"].toDouble();
|
||||
// variable->danger_low.hysteresis = alarm["danger_low_hysteresis"].toDouble();
|
||||
// variable->danger_low.delay = alarm["danger_low_delay"].toInt();
|
||||
// variable->danger_low.enable = alarm["danger_low_enable"].toBool();
|
||||
// variable->danger_low.latch = alarm["danger_low_latch"].toBool();
|
||||
// variable->alert_low.level = alarm["alert_low_level"].toDouble();
|
||||
// variable->alert_low.hysteresis = alarm["alert_low_hysteresis"].toDouble();
|
||||
// variable->alert_low.delay = alarm["alert_low_delay"].toInt();
|
||||
// variable->alert_low.enable = alarm["alert_low_enable"].toBool();
|
||||
// variable->alert_low.latch = alarm["alert_low_latch"].toBool();
|
||||
QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject();
|
||||
QJsonObject number_obj;
|
||||
for (int k = 0; k < 10; ++k) {
|
||||
number_obj = freband_output_obj[QString::number(k + 1)].toObject();
|
||||
if(number_obj.isEmpty())
|
||||
continue;
|
||||
FrequencybandOutput output;
|
||||
output.enable = number_obj["enable"].toBool();
|
||||
output.start = number_obj["start"].toInt();
|
||||
output.end = number_obj["end"].toInt();
|
||||
variable->freband_output[k] = output;
|
||||
}
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
case kVibVelocity:{
|
||||
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject processed_output, general, alarm;
|
||||
processed_output = tmp_variable["processed_output"].toObject();
|
||||
general = processed_output["general"].toObject();
|
||||
alarm = processed_output["alarm"].toObject();
|
||||
variable->general.output_used = general["output_used"].toBool();
|
||||
variable->general.engineering_unit = general["engieneering_unit"].toInt();
|
||||
variable->general.rectifier_function = general["rectifier_function"].toInt();
|
||||
variable->danger_high.level = alarm["danger_high_level"].toDouble();
|
||||
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
|
||||
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
|
||||
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
|
||||
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
|
||||
variable->alert_high.level = alarm["alert_high_level"].toDouble();
|
||||
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
|
||||
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
|
||||
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
|
||||
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
|
||||
// variable->danger_low.level = alarm["danger_low_level"].toDouble();
|
||||
// variable->danger_low.hysteresis = alarm["danger_low_hysteresis"].toDouble();
|
||||
// variable->danger_low.delay = alarm["danger_low_delay"].toInt();
|
||||
// variable->danger_low.enable = alarm["danger_low_enable"].toBool();
|
||||
// variable->danger_low.latch = alarm["danger_low_latch"].toBool();
|
||||
// variable->alert_low.level = alarm["alert_low_level"].toDouble();
|
||||
// variable->alert_low.hysteresis = alarm["alert_low_hysteresis"].toDouble();
|
||||
// variable->alert_low.delay = alarm["alert_low_delay"].toInt();
|
||||
// variable->alert_low.enable = alarm["alert_low_enable"].toBool();
|
||||
// variable->alert_low.latch = alarm["alert_low_latch"].toBool();
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
case kVibAcc: {
|
||||
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject processed_output, general, alarm;
|
||||
processed_output = tmp_variable["processed_output"].toObject();
|
||||
general = processed_output["general"].toObject();
|
||||
alarm = processed_output["alarm"].toObject();
|
||||
variable->general.output_used = general["output_used"].toBool();
|
||||
variable->general.engineering_unit = general["engieneering_unit"].toInt();
|
||||
variable->general.rectifier_function = general["rectifier_function"].toInt();
|
||||
variable->danger_high.level = alarm["danger_high_level"].toDouble();
|
||||
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
|
||||
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
|
||||
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
|
||||
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
|
||||
variable->alert_high.level = alarm["alert_high_level"].toDouble();
|
||||
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
|
||||
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
|
||||
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
|
||||
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
|
||||
// variable->danger_low.level = alarm["danger_low_level"].toDouble();
|
||||
// variable->danger_low.hysteresis = alarm["danger_low_hysteresis"].toDouble();
|
||||
// variable->danger_low.delay = alarm["danger_low_delay"].toInt();
|
||||
// variable->danger_low.enable = alarm["danger_low_enable"].toBool();
|
||||
// variable->danger_low.latch = alarm["danger_low_latch"].toBool();
|
||||
// variable->alert_low.level = alarm["alert_low_level"].toDouble();
|
||||
// variable->alert_low.hysteresis = alarm["alert_low_hysteresis"].toDouble();
|
||||
// variable->alert_low.delay = alarm["alert_low_delay"].toInt();
|
||||
// variable->alert_low.enable = alarm["alert_low_enable"].toBool();
|
||||
// variable->alert_low.latch = alarm["alert_low_latch"].toBool();
|
||||
QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject();
|
||||
QJsonObject number_obj;
|
||||
for (int k = 0; k < 10; ++k) {
|
||||
number_obj = freband_output_obj[QString::number(k + 1)].toObject();
|
||||
if(number_obj.isEmpty())
|
||||
continue;
|
||||
FrequencybandOutput output;
|
||||
output.enable = number_obj["enable"].toBool();
|
||||
output.start = number_obj["start"].toInt();
|
||||
output.end = number_obj["end"].toInt();
|
||||
variable->freband_output[k] = output;
|
||||
}
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cards_.push_back(vib_data);
|
||||
} else if (card_type_[i] == kCardSpeedSingle ||
|
||||
card_type_[i] == kCardSpeedTMRPrimary) {
|
||||
std::shared_ptr<TachometerData> speed_data = std::make_shared<TachometerData>();
|
||||
speed_data->slot_ = slot;
|
||||
speed_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
speed_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
speed_data->variables_[j].active = channel["active"].toBool();
|
||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||
speed_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
speed_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
speed_data->variables_[j].threshold = channel["threshold"].toDouble();
|
||||
speed_data->variables_[j].hysteresis = channel["hysteresis"].toDouble();
|
||||
speed_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt();
|
||||
speed_data->variables_[j].record_output = channel["record_output"].toInt();
|
||||
speed_data->variables_[j].two_ma_clamp = channel["two_ma_clamp"].toBool();
|
||||
speed_data->variables_[j].alert_latching = channel["alert_latching"].toBool();
|
||||
speed_data->variables_[j].overspeed_latching = channel["overspeed_latching"].toBool();
|
||||
speed_data->variables_[j].normal_latching = channel["normal_latching"].toBool();
|
||||
speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt();
|
||||
speed_data->variables_[j].default_speed = channel["default_speed"].toInt();
|
||||
speed_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool();
|
||||
speed_data->variables_[j].point_name = channel["point_name"].toString();
|
||||
|
||||
|
||||
QJsonObject setpoint_data = channel["setpoint"].toObject();
|
||||
speed_data->alert_danger[j].speed_upper = setpoint_data["speed_upper"].toDouble();
|
||||
speed_data->alert_danger[j].speed_lower = setpoint_data["speed_lower"].toDouble();
|
||||
speed_data->alert_danger[j].speed_upper_enable = setpoint_data["speed_upper_enable"].toBool();
|
||||
speed_data->alert_danger[j].speed_lower_enable = setpoint_data["speed_lower_enable"].toBool();
|
||||
speed_data->alert_danger[j].danger_speed_upper = setpoint_data["danger_speed_upper"].toDouble();
|
||||
}
|
||||
cards_.push_back(speed_data);
|
||||
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::make_shared<KeyphaseData>();
|
||||
keyphase_data->slot_ = slot;
|
||||
keyphase_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
keyphase_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
keyphase_data->variables_[j].active = channel["active"].toBool();
|
||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||
if(voltage_range_array.size() > 0){
|
||||
keyphase_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
keyphase_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
}
|
||||
keyphase_data->variables_[j].threshold = channel["threshold"].toDouble();
|
||||
keyphase_data->variables_[j].hysteresis = channel["hysteresis"].toDouble();
|
||||
keyphase_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt();
|
||||
keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool();
|
||||
}
|
||||
cards_.push_back(keyphase_data);
|
||||
}else if (card_type_[i] == kCardRelaySingle ){
|
||||
std::shared_ptr<SingleRelayData> singlerelay_data = std::make_shared<SingleRelayData>();
|
||||
singlerelay_data->slot_ = slot;
|
||||
singlerelay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
singlerelay_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < RELAY_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
singlerelay_data->single_relay[j].logic_expression = channel["logic_expression"].toString();
|
||||
singlerelay_data->single_relay[j].active = channel["active"].toBool();
|
||||
|
||||
}
|
||||
cards_.push_back(singlerelay_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<CardBase> ConfigMgr::GetSlotPtr(int slot) {
|
||||
for (auto &item : cards_) {
|
||||
if (item->slot_ == slot) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ConfigMgr::AddCard(std::shared_ptr<CardBase> ptr) {
|
||||
cards_.push_back(ptr);
|
||||
}
|
||||
void ConfigMgr::RemoveCard(std::shared_ptr<CardBase> ptr) {
|
||||
cards_.erase(remove(cards_.begin(), cards_.end(), ptr));
|
||||
}
|
||||
136
config_mgr.h
Normal file
136
config_mgr.h
Normal file
@ -0,0 +1,136 @@
|
||||
#ifndef CONFIG_MGR_H
|
||||
#define CONFIG_MGR_H
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "cardbase.h"
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDebug>
|
||||
#include <QListWidget>
|
||||
#include <QStandardItemModel> //数据模型类
|
||||
#include <QTreeView>
|
||||
|
||||
class DraggableListWidget : public QListWidget {
|
||||
public:
|
||||
DraggableListWidget(QWidget *parent = nullptr) : QListWidget(parent) {
|
||||
setDragEnabled(true);
|
||||
}
|
||||
|
||||
protected:
|
||||
void startDrag(Qt::DropActions supportedActions) override {
|
||||
QListWidgetItem *item = currentItem();
|
||||
if (!item) return;
|
||||
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
|
||||
// 获取显示文本和 UserRole 数据
|
||||
QString visibleText = item->text();
|
||||
QString userData = item->data(Qt::UserRole).toString();
|
||||
|
||||
// 使用 QDataStream 打包数据
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
stream << visibleText << userData; // 包含显示文本和 UserRole 数据
|
||||
|
||||
mimeData->setData("application/x-custom", data); // 设置自定义 MIME 数据
|
||||
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setMimeData(mimeData);
|
||||
drag->exec(Qt::CopyAction);
|
||||
}
|
||||
};
|
||||
class DropTreeModel : public QStandardItemModel {
|
||||
public:
|
||||
using QStandardItemModel::QStandardItemModel;
|
||||
|
||||
QStringList mimeTypes() const override {
|
||||
// 支持自定义类型和 QListWidget 默认类型
|
||||
return { "application/x-custom", "application/x-qabstractitemmodeldatalist" };
|
||||
}
|
||||
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override {
|
||||
QStandardItem *parentItem = this->itemFromIndex(parent);
|
||||
if (!parentItem)
|
||||
parentItem = this->invisibleRootItem();
|
||||
|
||||
if (data->hasFormat("application/x-custom")) {
|
||||
QByteArray rawData = data->data("application/x-custom");
|
||||
QString customText = QString::fromUtf8(rawData);
|
||||
|
||||
QStandardItem *newItem = new QStandardItem(customText);
|
||||
newItem->setData(customText, Qt::UserRole); // 假设 data 也就是内容
|
||||
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
|
||||
if (row < 0)
|
||||
parentItem->appendRow(newItem);
|
||||
else
|
||||
parentItem->insertRow(row, newItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||
QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist");
|
||||
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
int r, c;
|
||||
QMap<int, QVariant> roleDataMap;
|
||||
stream >> r >> c >> roleDataMap;
|
||||
|
||||
QString text = roleDataMap.value(Qt::DisplayRole).toString();
|
||||
QVariant userData = roleDataMap.value(Qt::UserRole);
|
||||
|
||||
QStandardItem *newItem = new QStandardItem(text);
|
||||
newItem->setData(userData, Qt::UserRole); // 保留附加数据
|
||||
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
|
||||
if (row < 0)
|
||||
parentItem->appendRow(newItem);
|
||||
else
|
||||
parentItem->insertRow(row, newItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::DropActions supportedDropActions() const override {
|
||||
return Qt::CopyAction | Qt::MoveAction;
|
||||
}
|
||||
};
|
||||
class ConfigMgr {
|
||||
private:
|
||||
static ConfigMgr *instance;
|
||||
ConfigMgr() {
|
||||
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||
card_type_[i] = kCardNone;
|
||||
}
|
||||
}
|
||||
public:
|
||||
int card_type_[15];
|
||||
static ConfigMgr *Instance() {
|
||||
if (instance == nullptr) {
|
||||
instance = new ConfigMgr();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
~ConfigMgr();
|
||||
void Save(QString & file_path);
|
||||
void Load(QString filename);
|
||||
std::shared_ptr<CardBase> GetSlotPtr(int slot);//1-15
|
||||
void AddCard(std::shared_ptr<CardBase> ptr);
|
||||
void RemoveCard(std::shared_ptr<CardBase> ptr);
|
||||
private:
|
||||
QString filename_;
|
||||
|
||||
std::vector<std::shared_ptr<CardBase>> cards_;
|
||||
};
|
||||
|
||||
#endif // CONFIG_MGR_H
|
||||
36
connect.cpp
Normal file
36
connect.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "connect.h"
|
||||
#include "ui_connect.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include "data_config.h"
|
||||
#include <QSettings>
|
||||
|
||||
Connect::Connect(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Connect)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QRegularExpression ipRegex(R"(^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$)");
|
||||
QRegularExpressionValidator *ipValidator = new QRegularExpressionValidator(ipRegex, this);
|
||||
ui->lineEdit_IP->setValidator(ipValidator);
|
||||
ui->lineEdit_IP->setText(g_strServerIp);
|
||||
}
|
||||
|
||||
Connect::~Connect()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Connect::on_pushButton_connect_clicked()
|
||||
{
|
||||
g_strServerIp = ui->lineEdit_IP->text();
|
||||
m_tcpClient = MyTcpClient::instance();
|
||||
// 连接服务器
|
||||
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
||||
QSettings *settings = new QSettings(QCoreApplication::applicationDirPath() + "/config/config.ini", QSettings::IniFormat);
|
||||
settings->setValue("Server/IP", ui->lineEdit_IP->text());
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
28
connect.h
Normal file
28
connect.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CONNECT_H
|
||||
#define CONNECT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "MyTcpClient.h"
|
||||
|
||||
namespace Ui {
|
||||
class Connect;
|
||||
}
|
||||
|
||||
class Connect : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Connect(QWidget *parent = nullptr);
|
||||
~Connect();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_connect_clicked();
|
||||
|
||||
private:
|
||||
Ui::Connect *ui;
|
||||
MyTcpClient* m_tcpClient;
|
||||
|
||||
};
|
||||
|
||||
#endif // CONNECT_H
|
||||
58
connect.ui
Normal file
58
connect.ui
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Connect</class>
|
||||
<widget class="QWidget" name="Connect">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton_connect">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>190</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>80</y>
|
||||
<width>221</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>CPU IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_IP">
|
||||
<property name="text">
|
||||
<string>192.168.0.101</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
774
data_config.h
774
data_config.h
@ -8,17 +8,181 @@
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
|
||||
extern QString g_strServerIp; // 服务端IP
|
||||
#define SLOT_NUM 15
|
||||
#define CHANNEL_COUNT 4
|
||||
#define RELAY_COUNT 16
|
||||
|
||||
#define CHANNLE_COUNT 4
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
bool used[4]; // 是否已配置
|
||||
int channel;
|
||||
}ChannelUsed;
|
||||
|
||||
extern QString g_strServerIp; // 服务端IP
|
||||
extern QString g_version;
|
||||
extern ChannelUsed ch_used[SLOT_NUM][22];
|
||||
|
||||
struct ExprNode {
|
||||
QString value;
|
||||
QList<ExprNode*> children;
|
||||
};
|
||||
struct ExprValidationResult {
|
||||
bool isValid;
|
||||
int errorPos;
|
||||
QString errorMsg;
|
||||
};
|
||||
typedef enum {
|
||||
kCardNone = 0,
|
||||
kCardCpu = 1,
|
||||
|
||||
kCardVibSingle = 10,
|
||||
kCardVibTMRPrimary = 11,
|
||||
kCardVibTMRBackup = 12,
|
||||
kCardVibDoublePrimary = 13,
|
||||
kCardVibDoubleBackup = 14,
|
||||
|
||||
kCardSpeedSingle = 20,
|
||||
kCardSpeedTMRPrimary = 21,
|
||||
kCardSpeedTMRBackup = 22,
|
||||
|
||||
kCardKeyphaseSingle = 30,
|
||||
kCardKeyphaseDouble = 31,
|
||||
kCardRelaySingle = 32,
|
||||
kCardRelayTMRPrimary = 33,
|
||||
kCardRelayTMRBackup = 34,
|
||||
kCardRelaySingleNOK = 35,
|
||||
|
||||
} CardType;
|
||||
|
||||
// 振动板通道类型
|
||||
typedef enum {
|
||||
kVibRadial = 0, // 径向位移
|
||||
kVibAcc = 1, // 加速度
|
||||
kVibVelocity = 2, // 速度
|
||||
kVibThrust = 3, //轴向位移
|
||||
kVibPressurePulsation = 4 //动态压力脉动
|
||||
} VibChannelType;
|
||||
enum TotalCalcValueType {
|
||||
// 转速
|
||||
kSpeedRpm = 0,
|
||||
|
||||
// 轴向位移
|
||||
kThrustGap = 2,
|
||||
|
||||
// 径向位移
|
||||
kRadialPk = 4,
|
||||
kRadialPk2Pk = 5,
|
||||
kRadialRmsScaledPeak = 6,
|
||||
kRadialRmsScaledPk2Pk = 7,
|
||||
|
||||
// 速度
|
||||
kVelPeak = 11,
|
||||
kVelRmsScaledPeak = 12,
|
||||
kVelRms = 13,
|
||||
|
||||
kVelDisPeak = 17,
|
||||
kVelDisPk2Pk = 18,
|
||||
kVelDisRmsScaledPeak = 19,
|
||||
kVelDisRmsScaledPk2Pk = 20,
|
||||
|
||||
// 加速度
|
||||
kAccPeak = 21,
|
||||
kAccRmsScaledPeak = 22,
|
||||
kAccRms = 23,
|
||||
|
||||
kAccVelPeak = 26,
|
||||
kAccVelRmsScaledPeak = 27,
|
||||
kAccVelRms = 28,
|
||||
|
||||
kAccDisPeak = 31,
|
||||
kAccDisPk2Pk = 32,
|
||||
kAccDisRmsScaledPeak = 33,
|
||||
kAccDisRmsScaledPk2Pk = 34,
|
||||
|
||||
// 压力脉动
|
||||
kPressPulsationPeak = 41,
|
||||
kPressPulsationRmsScaledPeak = 42,
|
||||
kPressPulsationRms = 43,
|
||||
|
||||
// kTriggerPressurePulsationLow = 11, // [10, 40]
|
||||
// kTriggerPressurePulsationMID1 = 12, // (40, 120]
|
||||
// kTriggerPressurePulsationMID2 = 13, // (120, 190]
|
||||
// kTriggerPressurePulsationHIGH1 = 14, // (190, 290]
|
||||
// kTriggerPressurePulsationHIGH2 = 15, // (290, 500]
|
||||
// kTriggerPressurePulsationHH1 = 16, // (500, 2000]
|
||||
// kTriggerPressurePulsationHH2 = 17, // (2000, 3200]
|
||||
// kTriggerPressurePulsationHH3 = 18, // (3200, 4200]
|
||||
// kTriggerPressurePulsationHH4 = 19, // (4200, 4600]
|
||||
// kTriggerPressurePulsationOA = 20, // [5, 500]
|
||||
|
||||
// 复合运算
|
||||
kSmax = 81, // 径向位移运算
|
||||
kDifferentialHousingExpansion = 82, // 差胀,针对轴向位移,做减法
|
||||
kRelativeShaftTaper = 83, // 径向位移,根据公式进行计算
|
||||
kRelativeShaftCollar = 84, // 径向位移,根据公式进行计算
|
||||
kDualMathematicalFunction = 85, // 公式计算
|
||||
|
||||
kDCValue = 100,
|
||||
};
|
||||
typedef enum{
|
||||
kTruePeak = 0,
|
||||
kTruePeakToPeak = 1,
|
||||
kRMSScalePeak = 2,
|
||||
kRMSScalePeakToPeak = 3,
|
||||
kAVG = 4,
|
||||
kRMSScaleAVG = 5,
|
||||
kRMS = 6
|
||||
} RectifierFuntion;
|
||||
|
||||
typedef enum{
|
||||
kUnit1 = 0, // g
|
||||
kUnit2 = 1, // m/s**2
|
||||
kUnit3 = 2, // mm/s
|
||||
kUnit4 = 3, // inch/s
|
||||
kUnit5 = 4, // um
|
||||
kUnit6 = 5, // mm
|
||||
kUnit7 = 6, // mils
|
||||
kUnit8 = 7, // inch/s**2
|
||||
kUnit9 = 9, // mbar
|
||||
kUnit10 = 10, // bar
|
||||
kUnit11 = 11, // psi
|
||||
kUnit12 = 12, // pa
|
||||
kUnit13 = 13 // user defined
|
||||
} EngineeringUnit;
|
||||
|
||||
typedef enum{
|
||||
kCh1Output1 = 0, // 通道1 输出1
|
||||
kCh2Output2 = 1, // 通道2 输出1
|
||||
kCh3Output3 = 2, // 通道3 输出1
|
||||
kCh4Output4 = 3, // 通道4 输出1
|
||||
kCh1Ch2 = 4, // 通道1 & 通道2
|
||||
kCh3Ch4 = 5, // 通道3 & 通道4
|
||||
kCh1FreBand1 = 6, // 通道1 分频段1
|
||||
kCh1FreBand2 = 7, // 通道1 分频段2
|
||||
kCh1FreBand3 = 8, // 通道1 分频段3
|
||||
kCh1FreBand4 = 9, // 通道1 分频段4
|
||||
kCh2FreBand1 = 10, // 通道2 分频段1
|
||||
kCh2FreBand2 = 11, // 通道2 分频段2
|
||||
kCh2FreBand3 = 12, // 通道2 分频段3
|
||||
kCh2FreBand4 = 13, // 通道2 分频段4
|
||||
kCh3FreBand1 = 14, // 通道3 分频段1
|
||||
kCh3FreBand2 = 15, // 通道3 分频段2
|
||||
kCh3FreBand3 = 16, // 通道3 分频段3
|
||||
kCh3FreBand4 = 17, // 通道3 分频段4
|
||||
kCh4FreBand1 = 18, // 通道4 分频段1
|
||||
kCh4FreBand2 = 19, // 通道4 分频段2
|
||||
kCh4FreBand3 = 20, // 通道4 分频段3
|
||||
kCh4FreBand4 = 21 // 通道4 分频段4
|
||||
} DCOutputChannel;
|
||||
|
||||
typedef struct SlotConfig_{
|
||||
int slot;
|
||||
QString slot_type;
|
||||
QString chan_display;
|
||||
QString rack_type;
|
||||
QPushButton* slot_btn;
|
||||
QLabel* slot_label;
|
||||
}SlotConfig;
|
||||
QPushButton *slot_btn;
|
||||
QLabel *slot_label;
|
||||
SlotConfig_(){
|
||||
slot_type = "";
|
||||
}
|
||||
} SlotConfig;
|
||||
|
||||
enum CMTCommand {
|
||||
kEigenvalueCmd = 1,
|
||||
@ -27,61 +191,227 @@ enum CMTCommand {
|
||||
kGetVersionInfo = 4,
|
||||
kRelaySetting = 5,
|
||||
kRelayStatus = 6,
|
||||
kUpgradeProgress = 7
|
||||
kUpgradeProgress = 7,
|
||||
kCalibrationMode = 8,
|
||||
kGetDcValue = 9,
|
||||
kSetCalibrationCoe = 10,
|
||||
kGetCalibrationCoe = 11,
|
||||
kClearCalibrationCoe = 12,
|
||||
kGetWaveData = 13,
|
||||
kUploadConfigFile = 14,
|
||||
kDownloadConfigFile = 15,
|
||||
kConfigSubCard = 16, // 请求无包体,响应有包体
|
||||
kRS485BaudrateSet = 17, // RS485波特率配置
|
||||
kRS485BaudrateGet = 18, // RS485波特率获取
|
||||
kConfigIPv4 = 19, // 配置IP地址
|
||||
kConfigMac = 20, // 配置Mac地址
|
||||
kRebootCard = 21, // 重启板卡
|
||||
kGetCardDcValue = 22, // 获取子板平均值
|
||||
kGetRelayStatus = 23, // 获取继电器状态
|
||||
kGetKeyphaseInfo = 24, // 获取键相信息
|
||||
kConfigProgress = 25, // 配置进度
|
||||
kTimingCmd = 26, // 校时
|
||||
kGetTimeInfo = 27, // 获取时间信息
|
||||
kGetLogInfo = 28, // 获取子板日志信息
|
||||
kCleanSubCardCfg = 29, // 清理子板配置
|
||||
kCleanSubCardLatch = 30, // 清理子板特定通道的Latch状态
|
||||
kConfigMQTTBrokerInfo = 31, // 配置与获取MQTT broker信息
|
||||
kConfigDeviceID = 32, // 配置设备编号,编号范围为1~99
|
||||
};
|
||||
enum RS485Baudrate {
|
||||
kBaudrate2400 = 0,
|
||||
kBaudrate4800 = 1,
|
||||
kBaudrate9600 = 2, // 默认值
|
||||
kBaudrate19200 = 3,
|
||||
kBaudrate38400 = 4,
|
||||
kBaudrate57600 = 5,
|
||||
kBaudrate115200 = 6
|
||||
};
|
||||
// 振动板采样率
|
||||
typedef enum {
|
||||
kVibSR16K = 0, // 16k
|
||||
kVibSR32K = 1, // 32k
|
||||
kVibSR64k = 2, // 64k
|
||||
kVibSR128K = 3, // 128k
|
||||
} VibSamplingRate;
|
||||
|
||||
// 振动板机架类型
|
||||
typedef enum {
|
||||
kVibRackSingle = 0, // 单一
|
||||
kVibRackTMR = 1 // 三冗余
|
||||
} VibRackType;
|
||||
|
||||
typedef struct{
|
||||
typedef struct SeismicMonitor_{
|
||||
int id;
|
||||
QString channel_name;
|
||||
QString point_name;
|
||||
QString chan_id;
|
||||
bool standby;
|
||||
bool active;
|
||||
QString rack_type;
|
||||
QString tmr_group;
|
||||
QString channel_type;
|
||||
QString transducer_name;
|
||||
QString scale_factor;
|
||||
QString sample_rate;
|
||||
int rack_type; // VibRackType
|
||||
// char tmr_group[32];
|
||||
int channel_type; // VibChannelType
|
||||
int transducer_id;
|
||||
float scale_factor;
|
||||
int sampling_rate; // VibSamplingRate
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
}SeismicMonitor;
|
||||
bool power;
|
||||
bool keyphase;
|
||||
int keyphase_slot;
|
||||
int keyphase_ch;
|
||||
int sensitivity_unit;
|
||||
float signal_sensitivity;
|
||||
SeismicMonitor_(){
|
||||
standby = false;
|
||||
active = false;
|
||||
normal_voltage_high = 20;
|
||||
normal_voltage_low = -20;
|
||||
signal_sensitivity = 8;
|
||||
}
|
||||
} SeismicMonitor;
|
||||
|
||||
typedef struct{
|
||||
QString type;
|
||||
typedef enum {
|
||||
kFilterTypeLowPass = 0,
|
||||
kFilterTypeHighPass = 1,
|
||||
kFilterTypeBandPass = 2,
|
||||
} FilterType;
|
||||
|
||||
typedef struct {
|
||||
int low;
|
||||
int high;
|
||||
bool checked;
|
||||
} Filter;
|
||||
|
||||
typedef struct{
|
||||
bool output_used;
|
||||
int engineering_unit;
|
||||
int rectifier_function;
|
||||
}General;
|
||||
|
||||
typedef struct{
|
||||
float level;
|
||||
float hysteresis;
|
||||
float delay;
|
||||
bool enable;
|
||||
bool latch;
|
||||
}AlarmDangerHigh,AlarmAlertHigh,AlarmDangerLow,AlarmAlertLow ;
|
||||
|
||||
typedef struct FrequencybandOutput_{
|
||||
bool enable;
|
||||
int start;
|
||||
int end;
|
||||
FrequencybandOutput_()
|
||||
{
|
||||
enable = false;
|
||||
start = 0;
|
||||
end = 0;
|
||||
}
|
||||
}FrequencybandOutput ;
|
||||
|
||||
typedef struct DCOutput_{
|
||||
int output_channel;
|
||||
float minmum;
|
||||
float maxmum;
|
||||
DCOutput_(){
|
||||
output_channel = -1;
|
||||
minmum = 0;
|
||||
maxmum = 0;
|
||||
}
|
||||
} DCOutput;
|
||||
|
||||
|
||||
//typedef struct {
|
||||
// Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass
|
||||
//} AllFilter;
|
||||
|
||||
typedef struct {
|
||||
QString type;
|
||||
QString full_sacle_range;
|
||||
int full_sacle_range;
|
||||
int bias_voltage;
|
||||
float clamp_value;
|
||||
int phase_lag;
|
||||
bool checked;
|
||||
float custom;
|
||||
} Variables;
|
||||
|
||||
typedef struct {
|
||||
int full_scale_range;
|
||||
float clamp_value;
|
||||
float custom;
|
||||
} DirectImpl;
|
||||
|
||||
typedef struct{
|
||||
int full_scale_range;
|
||||
float custom;
|
||||
}GapRange;
|
||||
|
||||
typedef struct {
|
||||
bool checked;
|
||||
int full_scale_range;
|
||||
float clamp_value;
|
||||
float custom;
|
||||
int phase_lag;
|
||||
} XImpl;
|
||||
|
||||
typedef struct {
|
||||
bool checked;
|
||||
int full_scale_range;
|
||||
float clamp_value;
|
||||
float custom;
|
||||
} RadialImpl;
|
||||
|
||||
typedef struct {
|
||||
int alert;
|
||||
float danger;
|
||||
bool active_100ms;
|
||||
} Dealy;
|
||||
typedef struct{
|
||||
} Delay;
|
||||
|
||||
typedef struct {
|
||||
float value;
|
||||
bool negation;
|
||||
} ZeroPosition;
|
||||
|
||||
typedef struct {
|
||||
bool rms_active;
|
||||
bool integrate_active;
|
||||
bool alert_latching;
|
||||
bool danger_latching;
|
||||
bool timed_ok;
|
||||
QString recorder_output;
|
||||
int recorder_output;
|
||||
bool two_ma_clamp;
|
||||
float trip_multiply;
|
||||
QString comparision;
|
||||
int comparision_percentage;
|
||||
} Alert_Variables;
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
int recorder_output;
|
||||
bool two_ma_clamp;
|
||||
float trip_multiply;
|
||||
int comparision;
|
||||
int percentage;
|
||||
} RecorderOut;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
QString point_name;
|
||||
bool active;
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
int speed_peek;
|
||||
int default_speed;
|
||||
bool automatic_threshold;
|
||||
float threshold;
|
||||
float hysteresis;
|
||||
int events_per_revolution;
|
||||
int record_output;
|
||||
bool two_ma_clamp;
|
||||
bool alert_latching;
|
||||
bool overspeed_latching;
|
||||
bool normal_latching;
|
||||
} TachometerVariables;
|
||||
|
||||
typedef struct {
|
||||
bool active;
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
@ -89,61 +419,401 @@ typedef struct{
|
||||
float threshold;
|
||||
float hysteresis;
|
||||
int events_per_revolution;
|
||||
QString record_output;
|
||||
bool two_ma_clamp;
|
||||
bool alert_latching;
|
||||
bool overspeed_latching;
|
||||
bool normal_latching;
|
||||
int alert_response_time;
|
||||
int danger_response_time;
|
||||
}Tachometer_Variables;
|
||||
} KeyphaseVariables;
|
||||
|
||||
typedef struct {
|
||||
QString transducer_name;
|
||||
double scale_factor;
|
||||
} Transducer;
|
||||
|
||||
typedef struct VibAlertDanger_{
|
||||
float direct_upper;
|
||||
bool direct_enable;
|
||||
float x1_ampl_upper;
|
||||
float x1_ampl_lower;
|
||||
bool x1_ampl_enable;
|
||||
float x2_ampl_upper;
|
||||
float x2_ampl_lower;
|
||||
bool x2_ampl_enable;
|
||||
int danger_param; //0: 直接值,1: 1倍频幅值,2: 2倍频幅值
|
||||
float danger_upper;
|
||||
bool danger_enable;
|
||||
VibAlertDanger_(){
|
||||
direct_upper = 0.0;
|
||||
direct_enable = false;
|
||||
x1_ampl_upper = 0.0;
|
||||
x1_ampl_lower = 0.0;
|
||||
x1_ampl_enable = false;
|
||||
x2_ampl_upper = 0.0;
|
||||
x2_ampl_lower = 0.0;
|
||||
x2_ampl_enable = false;
|
||||
danger_upper = 0.0;
|
||||
danger_enable = false;
|
||||
}
|
||||
} VibAlertDanger;
|
||||
|
||||
typedef struct VibAlertDangerPress_{
|
||||
float low_upper;
|
||||
bool low_enable;
|
||||
float mid1_upper;
|
||||
bool mid1_enable;
|
||||
float mid2_upper;
|
||||
bool mid2_enable;
|
||||
int danger_param; //0: 全频段OA
|
||||
float danger_upper;
|
||||
bool danger_enable;
|
||||
VibAlertDangerPress_(){
|
||||
low_upper = 0.0;
|
||||
low_enable = false;
|
||||
mid1_upper = 0.0;
|
||||
mid1_enable = false;
|
||||
mid2_upper = 0.0;
|
||||
mid2_enable = false;
|
||||
danger_upper = 0.0;
|
||||
danger_enable = false;
|
||||
}
|
||||
} VibAlertDangerPress;
|
||||
|
||||
typedef struct SpeedAlert_{
|
||||
int speed_upper;
|
||||
int speed_lower;
|
||||
bool speed_upper_enable;
|
||||
bool speed_lower_enable;
|
||||
int danger_speed_upper;
|
||||
SpeedAlert_(){
|
||||
speed_upper = 0;
|
||||
speed_lower = 0;
|
||||
danger_speed_upper = 0;
|
||||
speed_upper_enable = false;
|
||||
speed_lower_enable = false;
|
||||
}
|
||||
} SpeedAlert;
|
||||
|
||||
typedef struct SingleRelayNOK_{
|
||||
QString logic_expression;
|
||||
bool active;
|
||||
SingleRelayNOK_(){
|
||||
logic_expression = "";
|
||||
active = false;
|
||||
}
|
||||
} SingleRelayNOK;
|
||||
|
||||
typedef struct TMRRelay_{
|
||||
QString logic_expression;
|
||||
TMRRelay_(){
|
||||
logic_expression = "";
|
||||
}
|
||||
} TMRRelay;
|
||||
|
||||
#pragma pack(1)
|
||||
// kUpgradeCard
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // 命令
|
||||
int len; // 数据长度
|
||||
uint8_t crc; // 数据 CRC 校验和
|
||||
char data[0]; // 文件内容
|
||||
} PackageHead;
|
||||
|
||||
typedef struct {
|
||||
uint8_t card_id; // 0xff是本机,其它子卡是1~15
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
int len;
|
||||
uint8_t card_id;
|
||||
uint8_t crc;
|
||||
char data[0];
|
||||
} UpgradeCardReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t code; // 0: 上传成功
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 0: 上传成功
|
||||
} UpgradeRsp;
|
||||
|
||||
// kUpgradeProgress
|
||||
typedef struct {
|
||||
uint8_t card_id; // 0xff是本机,其它子卡是1~15
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t progress;
|
||||
} UpgradeProgress;
|
||||
|
||||
// kGetVersionInfo
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id;
|
||||
} GetVersionReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t fpga; // fpga版本号
|
||||
uint8_t sw; // 软件版本号
|
||||
char fpga_data[9]; // fpga版本日期
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t fpga; // fpga版本号
|
||||
uint8_t sw; // 软件版本号
|
||||
char fpga_date[9]; // fpga版本日期
|
||||
} VersionRsp;
|
||||
|
||||
// kRelaySetting
|
||||
typedef struct {
|
||||
uint8_t card_id; // 0xff是本机,其它子卡是1~15
|
||||
uint8_t led_id; // ok 灯 0xff,rx/tx 灯 0xf1,板卡测试模式 0xee,板卡状态 0xe1,其他 1 ~ 16
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id; // 0xff是本机,其它子卡是1~15
|
||||
uint8_t led_id; // ok 灯 0xff,rx/tx 灯 0xf1,板卡测试模式 0xee,板卡状态 0xe1,其他 1 ~ 16
|
||||
uint8_t led_operate; // 0 OFF,1 ON,2 红色,3 绿色,4 红色1Hz闪烁,5 红色2Hz闪烁,6 绿色闪烁,7 测试状态,8 手动状态,9 工作状态
|
||||
} RelaySettingReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code;
|
||||
} RelaySettingRsp;
|
||||
|
||||
// kRelayStatus
|
||||
typedef struct {
|
||||
uint8_t card_id; // 0xff是本机,其它子卡是1~15
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id;
|
||||
} RelayStatusReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 0: 成功 其它:失败
|
||||
uint8_t status; // 7 测试状态,8 手动状态,9 工作状态
|
||||
} RelayStatusRsp;
|
||||
|
||||
// kUploadConfigFile
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
int len;
|
||||
uint8_t sub_cmd; // 0: 仅上传配置文件,不配置子板 1:配置所有子板
|
||||
uint8_t crc;
|
||||
char data[0];
|
||||
} UploadConfigReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code;
|
||||
} UploadConfigRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 子板配置错误码
|
||||
uint8_t subcard_id; // 子板编号,从1开始
|
||||
uint8_t stage; // 0: 配置开始 1:配置结束
|
||||
} UploadConfigProgress;
|
||||
|
||||
// kDownloadConfigFile
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
} DownloadConfigReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code;
|
||||
int len;
|
||||
uint8_t crc;
|
||||
char data[0];
|
||||
} DownloadConfigRsp;
|
||||
|
||||
// kConfigSubCard = 16
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id;
|
||||
} ConfigSubCardReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id;
|
||||
uint8_t code; // 0: 成功 1: 没有配置文件
|
||||
} ConfigSubCardRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 子板配置错误码
|
||||
uint8_t subcard_id; // 子板编号,从1开始
|
||||
uint8_t stage; // 0: 配置开始 1:配置结束
|
||||
} ConfigSubCardProgress;
|
||||
// kRS485BaudrateGet
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
} BaudrateGetReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t baudrate;
|
||||
} BaudrateGetRsp;
|
||||
//kRS485BaudrateSet
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t baudrate;
|
||||
} BaudrateSetReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code;
|
||||
} BaudrateSetRsp;
|
||||
|
||||
//kConfigIPv4
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t ethn; // 0: eth0, 1: eth1
|
||||
char ip[16];
|
||||
char netmask[16];
|
||||
char gw[16];
|
||||
} ConfigIPv4Req;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code;
|
||||
} ConfigIPv4Rsp;
|
||||
|
||||
//ConfigMacReq
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t ethn; // 0: eth0, 1: eth1
|
||||
char mac[18];
|
||||
} ConfigMacReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code;
|
||||
} ConfigMacRsp;
|
||||
|
||||
// kGetLogInfo = 28
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id;
|
||||
uint8_t level;
|
||||
} GetSubCardLogReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id;
|
||||
uint8_t code;
|
||||
uint32_t len;
|
||||
char data[0]; // 请保存为.tar.gz文件
|
||||
} GetSubCardLogRsp;
|
||||
|
||||
// cmd: kTimingCmd = 26
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint32_t ts; // 时间戳
|
||||
} SetTimingReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 0: 成功 其它:失败
|
||||
} SetTimingRsp;
|
||||
|
||||
// cmd: kGetTimeInfo = 27
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
} GetTimeInfoReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint32_t ts; // 时间戳
|
||||
} GetTimeInfoRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kConfigMQTTBrokerInfo
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t sub_cmd; // 0: get, 1: set
|
||||
char ip[16]; // mqtt broker地址
|
||||
uint16_t port;
|
||||
} MQTTBrokerConfigInfoReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kConfigMQTTBrokerInfo
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // success:0, failure: others
|
||||
uint8_t sub_cmd; // 0: get, 1: set
|
||||
char ip[16]; // mqtt broker地址
|
||||
uint16_t port;
|
||||
} MQTTBrokerConfigInfoRsp;
|
||||
|
||||
// 子命令无响应,可观察灯板变化
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kCleanSubCardLatch
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t card_id; // 子板编号,1-15
|
||||
uint8_t sid; // 通道编号,1-4
|
||||
} CleanLatchStatusReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kConfigDeviceID
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t sub_cmd; // 0: get, 1: set
|
||||
uint8_t device_id; // 设备编号 0~99
|
||||
} DeviceIDConfigReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kConfigDeviceID
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // success:0, failure: others
|
||||
uint8_t sub_cmd; // 0: get, 1: set
|
||||
uint8_t device_id; // 设备编号
|
||||
} DeviceIDConfigRsp;
|
||||
|
||||
struct BaseHeader {
|
||||
uint8_t head[3]; // 固定 0xAA 0x55 0xAA
|
||||
uint8_t cmd;
|
||||
};
|
||||
|
||||
struct LargeHeaderExtra {
|
||||
uint8_t version;
|
||||
uint8_t code;
|
||||
int32_t len;
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif // DATA_CONFIG_H
|
||||
|
||||
79
dc_output_channel.cpp
Normal file
79
dc_output_channel.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include "dc_output_channel.h"
|
||||
#include "ui_dc_output_channel.h"
|
||||
#include <QMessageBox>
|
||||
#include "data_config.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
DC_Output_Channel::DC_Output_Channel(int slot_no_,QString unit_str_,int current_index_,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::DC_Output_Channel)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
unit_str = unit_str_;
|
||||
current_index = current_index_;
|
||||
slot_no = slot_no_;
|
||||
ui->label_min_unit->setText(unit_str);
|
||||
ui->label_max_unit->setText(unit_str);
|
||||
radiobtn[0] = ui->radioButton;
|
||||
radiobtn[1] = ui->radioButton_2;
|
||||
radiobtn[2] = ui->radioButton_3;
|
||||
radiobtn[3] = ui->radioButton_4;
|
||||
radiobtn[4] = ui->radioButton_5;
|
||||
int not_used = 0;
|
||||
for (int i = 0; i < 22; i++) {
|
||||
for (int j = 0; j < 4; j++){
|
||||
if(ch_used[slot_no][i].used[j] && current_index == i){
|
||||
radiobtn[j]->setEnabled(true);
|
||||
radiobtn[j]->setChecked(true);
|
||||
first_used = j;
|
||||
}else if(ch_used[slot_no][i].used[j] && current_index != i){
|
||||
radiobtn[j]->setEnabled(false);
|
||||
}else if(!ch_used[slot_no][i].used[j] && current_index == i){
|
||||
not_used ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(not_used == 4){
|
||||
ui->radioButton_5->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
DC_Output_Channel::~DC_Output_Channel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DC_Output_Channel::on_pushButton_confirm_clicked()
|
||||
{
|
||||
int channel = 0;
|
||||
if(!ui->radioButton_5->isChecked() && ((ui->lineEdit_minmum->text().toFloat() >= ui->lineEdit_maxmum->text().toFloat()) ||
|
||||
(ui->lineEdit_minmum->text().toFloat() == 0 && ui->lineEdit_maxmum->text().toFloat() == 0))){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "请填写正确的最小值和最大值");
|
||||
return;
|
||||
}
|
||||
if(ui->radioButton->isChecked()){
|
||||
channel = 1;
|
||||
}else if(ui->radioButton_2->isChecked()){
|
||||
channel = 2;
|
||||
}else if(ui->radioButton_3->isChecked()){
|
||||
channel = 3;
|
||||
}else if(ui->radioButton_4->isChecked()){
|
||||
channel = 4;
|
||||
}else if(ui->radioButton_5->isChecked()){
|
||||
ch_used[slot_no][current_index].used[first_used] = false;
|
||||
channel = 5;
|
||||
}else {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "请选择正确的通道");
|
||||
return;
|
||||
}
|
||||
emit output_channel_data_sg(channel,ui->lineEdit_minmum->text().toFloat(),ui->lineEdit_maxmum->text().toFloat(),first_used);
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void DC_Output_Channel::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
34
dc_output_channel.h
Normal file
34
dc_output_channel.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef DC_OUTPUT_CHANNEL_H
|
||||
#define DC_OUTPUT_CHANNEL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QRadioButton>
|
||||
|
||||
namespace Ui {
|
||||
class DC_Output_Channel;
|
||||
}
|
||||
|
||||
class DC_Output_Channel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DC_Output_Channel(int slot_no_,QString unit_str_,int current_index_,QWidget *parent = nullptr);
|
||||
~DC_Output_Channel();
|
||||
signals:
|
||||
void output_channel_data_sg(int channel,float minmun,float maxmum,int not_used);
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::DC_Output_Channel *ui;
|
||||
QString unit_str;
|
||||
int current_index;
|
||||
int first_used;
|
||||
int slot_no;
|
||||
QRadioButton *radiobtn[5];
|
||||
};
|
||||
|
||||
#endif // DC_OUTPUT_CHANNEL_H
|
||||
225
dc_output_channel.ui
Normal file
225
dc_output_channel.ui
Normal file
@ -0,0 +1,225 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DC_Output_Channel</class>
|
||||
<widget class="QWidget" name="DC_Output_Channel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>527</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>输出通道</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>50</y>
|
||||
<width>391</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>4 - 20 mA 输出</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>30</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>通道1</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>60</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>通道2</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>90</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>通道3</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>120</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>通道4</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>150</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>不使用</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_minmum">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>260</y>
|
||||
<width>113</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_maxmum">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>300</y>
|
||||
<width>113</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_min_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>270</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>- -</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_max_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>310</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>- -</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>270</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>最小值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>310</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>最大值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>360</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确认</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>360</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
422
dc_outputs.cpp
Normal file
422
dc_outputs.cpp
Normal file
@ -0,0 +1,422 @@
|
||||
#include "dc_outputs.h"
|
||||
#include "ui_dc_outputs.h"
|
||||
#include <QListView>
|
||||
#include "dc_output_channel.h"
|
||||
#include <QDebug>
|
||||
#include "config_mgr.h"
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
ChannelUsed ch_used[SLOT_NUM][22];
|
||||
|
||||
DC_Outputs::DC_Outputs(int slot_no_,int cardtype,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::DC_Outputs)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comboBox_ch_output->setView(new QListView());
|
||||
slot_no = slot_no_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
unit = "";
|
||||
current_index = ui->comboBox_ch_output->currentIndex();
|
||||
label_ch1[0] = ui->label_ch_1;
|
||||
label_ch1[1] = ui->label_ch_1_min;
|
||||
label_ch1[2] = ui->label_ch_1_min_unit;
|
||||
label_ch1[3] = ui->label_ch_1_max;
|
||||
label_ch1[4] = ui->label_ch_1_max_unit;
|
||||
|
||||
label_ch2[0] = ui->label_ch_2;
|
||||
label_ch2[1] = ui->label_ch_2_min;
|
||||
label_ch2[2] = ui->label_ch_2_min_unit;
|
||||
label_ch2[3] = ui->label_ch_2_max;
|
||||
label_ch2[4] = ui->label_ch_2_max_unit;
|
||||
|
||||
label_ch3[0] = ui->label_ch_3;
|
||||
label_ch3[1] = ui->label_ch_3_min;
|
||||
label_ch3[2] = ui->label_ch_3_min_unit;
|
||||
label_ch3[3] = ui->label_ch_3_max;
|
||||
label_ch3[4] = ui->label_ch_3_max_unit;
|
||||
|
||||
label_ch4[0] = ui->label_ch_4;
|
||||
label_ch4[1] = ui->label_ch_4_min;
|
||||
label_ch4[2] = ui->label_ch_4_min_unit;
|
||||
label_ch4[3] = ui->label_ch_4_max;
|
||||
label_ch4[4] = ui->label_ch_4_max_unit;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
DC_Outputs::~DC_Outputs()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DC_Outputs::Init(){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[DC_Outputs::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
vib_dc_output_ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
QString unit_str = "";
|
||||
|
||||
if(vib_dc_output_ptr->dc_output[0].output_channel != -1){
|
||||
unit_str = GetUnit(vib_dc_output_ptr->dc_output[0].output_channel);
|
||||
ui->label_ch_1->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[0].output_channel));
|
||||
ui->label_ch_1_min->setText(QString::number(vib_dc_output_ptr->dc_output[0].minmum));
|
||||
ui->label_ch_1_max->setText(QString::number(vib_dc_output_ptr->dc_output[0].maxmum));
|
||||
ui->label_ch_1_min_unit->setText(unit_str);
|
||||
ui->label_ch_1_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][vib_dc_output_ptr->dc_output[0].output_channel].used[0] = true;
|
||||
}
|
||||
if(vib_dc_output_ptr->dc_output[1].output_channel != -1){
|
||||
unit_str = GetUnit(vib_dc_output_ptr->dc_output[1].output_channel);
|
||||
ui->label_ch_2->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[1].output_channel));
|
||||
ui->label_ch_2_min->setText(QString::number(vib_dc_output_ptr->dc_output[1].minmum));
|
||||
ui->label_ch_2_max->setText(QString::number(vib_dc_output_ptr->dc_output[1].maxmum));
|
||||
ui->label_ch_2_min_unit->setText(unit_str);
|
||||
ui->label_ch_2_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][vib_dc_output_ptr->dc_output[1].output_channel].used[1] = true;
|
||||
}
|
||||
if(vib_dc_output_ptr->dc_output[2].output_channel != -1){
|
||||
unit_str = GetUnit(vib_dc_output_ptr->dc_output[2].output_channel);
|
||||
ui->label_ch_3->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[2].output_channel));
|
||||
ui->label_ch_3_min->setText(QString::number(vib_dc_output_ptr->dc_output[2].minmum));
|
||||
ui->label_ch_3_max->setText(QString::number(vib_dc_output_ptr->dc_output[2].maxmum));
|
||||
ui->label_ch_3_min_unit->setText(unit_str);
|
||||
ui->label_ch_3_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][vib_dc_output_ptr->dc_output[2].output_channel].used[2] = true;
|
||||
}
|
||||
if(vib_dc_output_ptr->dc_output[3].output_channel != -1){
|
||||
unit_str = GetUnit(vib_dc_output_ptr->dc_output[3].output_channel);
|
||||
ui->label_ch_4->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[3].output_channel));
|
||||
ui->label_ch_4_min->setText(QString::number(vib_dc_output_ptr->dc_output[3].minmum));
|
||||
ui->label_ch_4_max->setText(QString::number(vib_dc_output_ptr->dc_output[3].maxmum));
|
||||
ui->label_ch_4_min_unit->setText(unit_str);
|
||||
ui->label_ch_4_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][vib_dc_output_ptr->dc_output[3].output_channel].used[3] = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
QString DC_Outputs::GetUnit(int com_index){
|
||||
int unit_num = -1,channel_num = 0;
|
||||
QString unit_str = "";
|
||||
channel_num = com_index;
|
||||
if(com_index > 5 && com_index < 9){
|
||||
channel_num = 0;
|
||||
}
|
||||
if(com_index > 9 && com_index < 13){
|
||||
channel_num = 1;
|
||||
}
|
||||
if(com_index > 13 && com_index < 17){
|
||||
channel_num = 2;
|
||||
}
|
||||
if(com_index > 17 && com_index < 21){
|
||||
channel_num = 3;
|
||||
}
|
||||
if(com_index == 4) {
|
||||
channel_num = 0;
|
||||
}else if(com_index == 5){
|
||||
channel_num = 2;
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = vib_dc_output_ptr->GetChannelPtr(channel_num + 1);
|
||||
if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibRadial) {
|
||||
std::shared_ptr<RadialVariable> variable_ptr = std::dynamic_pointer_cast<RadialVariable>(variable_base);
|
||||
unit_num = variable_ptr->general.engineering_unit;
|
||||
qDebug() << "unit_num1" << unit_num ;
|
||||
}
|
||||
if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibAcc) {
|
||||
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
unit_num = variable_ptr->general.engineering_unit;
|
||||
qDebug() << "unit_num2" << unit_num ;
|
||||
}
|
||||
if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibVelocity) {
|
||||
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
unit_num = variable_ptr->general.engineering_unit;
|
||||
qDebug() << "unit_num3" << unit_num ;
|
||||
}
|
||||
if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibThrust) {
|
||||
std::shared_ptr<ThrustVariable> variable_ptr = std::dynamic_pointer_cast<ThrustVariable>(variable_base);
|
||||
unit_num = variable_ptr->general.engineering_unit;
|
||||
qDebug() << "unit_num4" << unit_num ;
|
||||
}
|
||||
if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibPressurePulsation) {
|
||||
std::shared_ptr<PressurePulsationVariable> variable_ptr = std::dynamic_pointer_cast<PressurePulsationVariable>(variable_base);
|
||||
unit_num = variable_ptr->general.engineering_unit;
|
||||
qDebug() << "unit_num5" << unit_num ;
|
||||
}
|
||||
switch (unit_num) {
|
||||
case kUnit1:{
|
||||
unit_str = "g";
|
||||
break;
|
||||
}
|
||||
case kUnit2:{
|
||||
unit_str = "m/s**2";
|
||||
break;
|
||||
}
|
||||
case kUnit3:{
|
||||
unit_str = "mm/s";
|
||||
break;
|
||||
}
|
||||
case kUnit4:{
|
||||
unit_str = "inch/s";
|
||||
break;
|
||||
}
|
||||
case kUnit5:{
|
||||
unit_str = "um";
|
||||
break;
|
||||
}
|
||||
case kUnit6:{
|
||||
unit_str = "mm";
|
||||
break;
|
||||
}
|
||||
case kUnit7:{
|
||||
unit_str = "mils";
|
||||
break;
|
||||
}
|
||||
case kUnit8:{
|
||||
unit_str = "inch/s**2";
|
||||
break;
|
||||
}
|
||||
case kUnit9:{
|
||||
unit_str = "mbar";
|
||||
break;
|
||||
}
|
||||
case kUnit10:{
|
||||
unit_str = "bar";
|
||||
break;
|
||||
}
|
||||
case kUnit11:{
|
||||
unit_str = "psi";
|
||||
break;
|
||||
}
|
||||
case kUnit12:{
|
||||
unit_str = "pa";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return unit_str;
|
||||
}
|
||||
void DC_Outputs::on_comboBox_ch_output_activated(int index)
|
||||
{
|
||||
current_index = index;
|
||||
QString unit_str = GetUnit(current_index);
|
||||
DC_Output_Channel *dc_output_channel = new DC_Output_Channel(slot_no,unit_str,current_index);
|
||||
dc_output_channel->setWindowModality(Qt::ApplicationModal);
|
||||
connect(dc_output_channel,SIGNAL(output_channel_data_sg(int,float,float,int)),this,SLOT(output_channel_data(int,float,float,int)));
|
||||
dc_output_channel->show();
|
||||
}
|
||||
|
||||
void DC_Outputs::output_channel_data(int channel,float minmun,float maxmum,int not_used){
|
||||
qDebug() << channel << minmun << maxmum ;
|
||||
QString unit_str = GetUnit(current_index);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if(ch_used[slot_no][current_index].used[i] && i != (channel - 1)){
|
||||
if(i == 0){
|
||||
label_ch1[0]->setText("未使用");
|
||||
label_ch1[1]->setText("-----");
|
||||
label_ch1[2]->setText("-----");
|
||||
label_ch1[3]->setText("-----");
|
||||
label_ch1[4]->setText("-----");
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[0] = false;
|
||||
vib_dc_output_ptr->dc_output[0].output_channel = -1;
|
||||
}else if(i == 1){
|
||||
label_ch2[0]->setText("未使用");
|
||||
label_ch2[1]->setText("-----");
|
||||
label_ch2[2]->setText("-----");
|
||||
label_ch2[3]->setText("-----");
|
||||
label_ch2[4]->setText("-----");
|
||||
ch_used[slot_no][current_index].used[1] = false;
|
||||
vib_dc_output_ptr->dc_output[1].output_channel = -1;
|
||||
}else if(i == 2){
|
||||
label_ch3[0]->setText("未使用");
|
||||
label_ch3[1]->setText("-----");
|
||||
label_ch3[2]->setText("-----");
|
||||
label_ch3[3]->setText("-----");
|
||||
label_ch3[4]->setText("-----");
|
||||
ch_used[slot_no][current_index].used[2] = false;
|
||||
vib_dc_output_ptr->dc_output[2].output_channel = -1;
|
||||
}else if(i == 3){
|
||||
label_ch4[0]->setText("未使用");
|
||||
label_ch4[1]->setText("-----");
|
||||
label_ch4[2]->setText("-----");
|
||||
label_ch4[3]->setText("-----");
|
||||
label_ch4[4]->setText("-----");
|
||||
ch_used[slot_no][current_index].used[3] = false;
|
||||
vib_dc_output_ptr->dc_output[3].output_channel = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(channel == 1){
|
||||
ui->label_ch_1->setText(ui->comboBox_ch_output->currentText());
|
||||
ui->label_ch_1_min->setText(QString::number(minmun));
|
||||
ui->label_ch_1_max->setText(QString::number(maxmum));
|
||||
ui->label_ch_1_min_unit->setText(unit_str);
|
||||
ui->label_ch_1_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[0] = true;
|
||||
vib_dc_output_ptr->dc_output[0].output_channel = current_index;
|
||||
vib_dc_output_ptr->dc_output[0].minmum = ui->label_ch_1_min->text().toFloat();
|
||||
vib_dc_output_ptr->dc_output[0].maxmum = ui->label_ch_1_max->text().toFloat();
|
||||
}else if(channel == 2){
|
||||
ui->label_ch_2->setText(ui->comboBox_ch_output->currentText());
|
||||
ui->label_ch_2_min->setText(QString::number(minmun));
|
||||
ui->label_ch_2_max->setText(QString::number(maxmum));
|
||||
ui->label_ch_2_min_unit->setText(unit_str);
|
||||
ui->label_ch_2_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[1] = true;
|
||||
vib_dc_output_ptr->dc_output[1].output_channel = current_index;
|
||||
vib_dc_output_ptr->dc_output[1].minmum = ui->label_ch_2_min->text().toFloat();
|
||||
vib_dc_output_ptr->dc_output[1].maxmum = ui->label_ch_2_max->text().toFloat();
|
||||
}else if(channel == 3){
|
||||
ui->label_ch_3->setText(ui->comboBox_ch_output->currentText());
|
||||
ui->label_ch_3_min->setText(QString::number(minmun));
|
||||
ui->label_ch_3_max->setText(QString::number(maxmum));
|
||||
ui->label_ch_3_min_unit->setText(unit_str);
|
||||
ui->label_ch_3_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[2] = true;
|
||||
vib_dc_output_ptr->dc_output[2].output_channel = current_index;
|
||||
vib_dc_output_ptr->dc_output[2].minmum = ui->label_ch_3_min->text().toFloat();
|
||||
vib_dc_output_ptr->dc_output[2].maxmum = ui->label_ch_3_max->text().toFloat();
|
||||
}else if(channel == 4){
|
||||
ui->label_ch_4->setText(ui->comboBox_ch_output->currentText());
|
||||
ui->label_ch_4_min->setText(QString::number(minmun));
|
||||
ui->label_ch_4_max->setText(QString::number(maxmum));
|
||||
ui->label_ch_4_min_unit->setText(unit_str);
|
||||
ui->label_ch_4_max_unit->setText(unit_str);
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[3] = true;
|
||||
vib_dc_output_ptr->dc_output[3].output_channel = current_index;
|
||||
vib_dc_output_ptr->dc_output[3].minmum = ui->label_ch_4_min->text().toFloat();
|
||||
vib_dc_output_ptr->dc_output[3].maxmum = ui->label_ch_4_max->text().toFloat();
|
||||
}else if(channel == 5){
|
||||
if(not_used == 0){
|
||||
label_ch1[0]->setText("未使用");
|
||||
label_ch1[1]->setText("-----");
|
||||
label_ch1[2]->setText("-----");
|
||||
label_ch1[3]->setText("-----");
|
||||
label_ch1[4]->setText("-----");
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[0] = false;
|
||||
vib_dc_output_ptr->dc_output[0].output_channel = -1;
|
||||
}else if(not_used == 1){
|
||||
label_ch2[0]->setText("未使用");
|
||||
label_ch2[1]->setText("-----");
|
||||
label_ch2[2]->setText("-----");
|
||||
label_ch2[3]->setText("-----");
|
||||
label_ch2[4]->setText("-----");
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[1] = false;
|
||||
vib_dc_output_ptr->dc_output[1].output_channel = -1;
|
||||
}else if(not_used == 2){
|
||||
label_ch3[0]->setText("未使用");
|
||||
label_ch3[1]->setText("-----");
|
||||
label_ch3[2]->setText("-----");
|
||||
label_ch3[3]->setText("-----");
|
||||
label_ch3[4]->setText("-----");
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[2] = false;
|
||||
vib_dc_output_ptr->dc_output[2].output_channel = -1;
|
||||
}else if(not_used == 3){
|
||||
label_ch4[0]->setText("未使用");
|
||||
label_ch4[1]->setText("-----");
|
||||
label_ch4[2]->setText("-----");
|
||||
label_ch4[3]->setText("-----");
|
||||
label_ch4[4]->setText("-----");
|
||||
ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[3] = false;
|
||||
vib_dc_output_ptr->dc_output[3].output_channel = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DC_Outputs::on_pushButton_confirm_clicked()
|
||||
{
|
||||
|
||||
// if(ui->label_ch_1->text() != "未使用" && current_index){
|
||||
// vib_dc_output_ptr->dc_output[0].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[0].dc_output_channel = 1;
|
||||
// vib_dc_output_ptr->dc_output[0].minmum = ui->label_ch_1_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[0].maxmum = ui->label_ch_1_max->text().toFloat();
|
||||
// }
|
||||
// if(ui->label_ch_2->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[1].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[1].dc_output_channel = 2;
|
||||
// vib_dc_output_ptr->dc_output[1].minmum = ui->label_ch_2_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[1].maxmum = ui->label_ch_2_max->text().toFloat();
|
||||
// }
|
||||
// if(ui->label_ch_3->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[2].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[2].dc_output_channel = 3;
|
||||
// vib_dc_output_ptr->dc_output[2].minmum = ui->label_ch_3_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[2].maxmum = ui->label_ch_3_max->text().toFloat();
|
||||
// }
|
||||
// if(ui->label_ch_4->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[3].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[3].dc_output_channel = 4;
|
||||
// vib_dc_output_ptr->dc_output[3].minmum = ui->label_ch_4_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[3].maxmum = ui->label_ch_4_max->text().toFloat();
|
||||
// }
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void DC_Outputs::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void DC_Outputs::on_comboBox_ch_output_currentIndexChanged(int index)
|
||||
{
|
||||
qDebug() << "on_comboBox_ch_output_currentIndexChanged" ;
|
||||
// if(ui->label_ch_1->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[0].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[0].dc_output_channel = 1;
|
||||
// vib_dc_output_ptr->dc_output[0].minmum = ui->label_ch_1_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[0].maxmum = ui->label_ch_1_max->text().toFloat();
|
||||
// }
|
||||
// if(ui->label_ch_2->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[1].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[1].dc_output_channel = 2;
|
||||
// vib_dc_output_ptr->dc_output[1].minmum = ui->label_ch_2_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[1].maxmum = ui->label_ch_2_max->text().toFloat();
|
||||
// }
|
||||
// if(ui->label_ch_3->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[2].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[2].dc_output_channel = 3;
|
||||
// vib_dc_output_ptr->dc_output[2].minmum = ui->label_ch_3_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[2].maxmum = ui->label_ch_3_max->text().toFloat();
|
||||
// }
|
||||
// if(ui->label_ch_4->text() != "未使用"){
|
||||
// vib_dc_output_ptr->dc_output[3].output_channel = current_index;
|
||||
// vib_dc_output_ptr->dc_output[3].dc_output_channel = 4;
|
||||
// vib_dc_output_ptr->dc_output[3].minmum = ui->label_ch_4_min->text().toFloat();
|
||||
// vib_dc_output_ptr->dc_output[3].maxmum = ui->label_ch_4_max->text().toFloat();
|
||||
// }
|
||||
|
||||
// current_index = index;
|
||||
// QString unit_str = GetUnit();
|
||||
// if(vib_dc_output_ptr->dc_output[0].dc_output_channel == 1 && current_index == vib_dc_output_ptr->dc_output[0].output_channel){
|
||||
// ui->label_ch_1->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[0].output_channel));
|
||||
// ui->label_ch_1_min->setText(QString::number(vib_dc_output_ptr->dc_output[0].minmum));
|
||||
// ui->label_ch_1_max->setText(QString::number(vib_dc_output_ptr->dc_output[0].maxmum));
|
||||
// ch_used[slot_no][current_index].used[0] = true;
|
||||
// }
|
||||
// if(vib_dc_output_ptr->dc_output[1].dc_output_channel == 2 && current_index == vib_dc_output_ptr->dc_output[1].output_channel){
|
||||
// ui->label_ch_2->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[1].output_channel));
|
||||
// ui->label_ch_2_min->setText(QString::number(vib_dc_output_ptr->dc_output[1].minmum));
|
||||
// ui->label_ch_2_max->setText(QString::number(vib_dc_output_ptr->dc_output[1].maxmum));
|
||||
// ch_used[slot_no][current_index].used[1] = true;
|
||||
// }
|
||||
// if(vib_dc_output_ptr->dc_output[2].dc_output_channel == 3 && current_index == vib_dc_output_ptr->dc_output[2].output_channel){
|
||||
// ui->label_ch_3->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[2].output_channel));
|
||||
// ui->label_ch_3_min->setText(QString::number(vib_dc_output_ptr->dc_output[2].minmum));
|
||||
// ui->label_ch_3_max->setText(QString::number(vib_dc_output_ptr->dc_output[2].maxmum));
|
||||
// ch_used[slot_no][current_index].used[2] = true;
|
||||
// }
|
||||
// if(vib_dc_output_ptr->dc_output[3].dc_output_channel == 4 && current_index == vib_dc_output_ptr->dc_output[3].output_channel){
|
||||
// ui->label_ch_4->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[3].output_channel));
|
||||
// ui->label_ch_4_min->setText(QString::number(vib_dc_output_ptr->dc_output[3].minmum));
|
||||
// ui->label_ch_4_max->setText(QString::number(vib_dc_output_ptr->dc_output[3].maxmum));
|
||||
// ch_used[slot_no][current_index].used[3] = true;
|
||||
// }
|
||||
}
|
||||
|
||||
45
dc_outputs.h
Normal file
45
dc_outputs.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef DC_OUTPUTS_H
|
||||
#define DC_OUTPUTS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
namespace Ui {
|
||||
class DC_Outputs;
|
||||
}
|
||||
|
||||
class DC_Outputs : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DC_Outputs(int slot_no_,int cardtype,QWidget *parent = nullptr);
|
||||
~DC_Outputs();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_comboBox_ch_output_activated(int index);
|
||||
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void output_channel_data(int channel,float minmun,float maxmum,int not_used);
|
||||
|
||||
void on_comboBox_ch_output_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::DC_Outputs *ui;
|
||||
std::shared_ptr<VibrationData> vib_dc_output_ptr = nullptr;
|
||||
void Init();
|
||||
QString GetUnit(int com_index);
|
||||
QLabel *label_ch1[5];
|
||||
QLabel *label_ch2[5];
|
||||
QLabel *label_ch3[5];
|
||||
QLabel *label_ch4[5];
|
||||
int current_index;
|
||||
QString unit;
|
||||
};
|
||||
|
||||
#endif // DC_OUTPUTS_H
|
||||
528
dc_outputs.ui
Normal file
528
dc_outputs.ui
Normal file
@ -0,0 +1,528 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DC_Outputs</class>
|
||||
<widget class="QWidget" name="DC_Outputs">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>727</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>直流输出</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboBox_ch_output">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>40</y>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道1 输出1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道2 输出1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道3 输出1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道4 输出1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道1 & 通道2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道3 & 通道4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道1 分频段1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道1 分频段2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道1 分频段3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道1 分频段4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道2 分频段1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道2 分频段2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道2 分频段3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道2 分频段4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道3 分频段1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道3 分频段2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道3 分频段3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道3 分频段4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道4 分频段1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道4 分频段2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道4 分频段3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道4 分频段4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>160</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>200</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>240</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>280</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>110</y>
|
||||
<width>101</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IOC 直流 输出</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>110</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>最小值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<y>110</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>最大值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>160</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>未使用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>200</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>未使用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>240</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>未使用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>280</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>未使用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_1_min">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>160</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_2_min">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>200</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_1_max">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>160</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_2_max">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>200</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_3_min">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>240</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_4_min">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>280</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_3_max">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>240</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_4_max">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>280</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>380</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确认</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>380</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_1_min_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>160</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_1_max_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>160</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_2_min_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>200</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_2_max_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>200</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_3_min_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>240</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_3_max_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>240</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_4_min_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>280</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>----- </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ch_4_max_unit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>280</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-----</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
21
displacement_ds.h
Normal file
21
displacement_ds.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef DISPLACEMENT_DS_H
|
||||
#define DISPLACEMENT_DS_H
|
||||
// 位移峰峰值的量程范围
|
||||
typedef enum {
|
||||
kDisPP100 = 0, // 0-100 um
|
||||
kDisPP150 = 1, // 0-150 um
|
||||
kDisPP200 = 2, // 0-200 um
|
||||
kDisPP400 = 3, // 0-400 um
|
||||
kDisPP500 = 4, // 0-500 um
|
||||
kDisPPCustom = 5 // custom
|
||||
} DisPPFullScaleRange;
|
||||
|
||||
// recorder out
|
||||
typedef enum {
|
||||
kDisRecorderOutNone = 0,
|
||||
kDisRecorderOutDirectAmpl = 1,
|
||||
kDisRecorderOut1XAmpl = 2,
|
||||
kDisRecorderOut2XAmpl = 3
|
||||
} DisRecorderOut;
|
||||
|
||||
#endif // DISPLACEMENT_DS_H
|
||||
0
doc/ReadME.txt
Normal file
0
doc/ReadME.txt
Normal file
@ -1,46 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"slot":1,
|
||||
"id":1,
|
||||
"rms_active":true,
|
||||
"integrate_active":true,
|
||||
"variables":[
|
||||
{
|
||||
"type":"direct",
|
||||
"full_sacle_range":"0-20 m/s^2 pk",
|
||||
"clamp_value":1.25
|
||||
},
|
||||
{
|
||||
"type":"bias_volt",
|
||||
"bias_voltage": -24,
|
||||
"clamp_value":1.25
|
||||
},
|
||||
{
|
||||
"type":"1x_ampl",
|
||||
"full_sacle_range":"0-2 m/s^2 pk",
|
||||
"clamp_value":1.25,
|
||||
"phase_lag":180,
|
||||
"checked":true
|
||||
},
|
||||
{
|
||||
"type":"2x_ampl",
|
||||
"full_sacle_range":"0-2 m/s^2 pk",
|
||||
"clamp_value":1.25,
|
||||
"phase_lag":180,
|
||||
"checked":true
|
||||
}
|
||||
],
|
||||
"delay":{
|
||||
"alert":30,
|
||||
"danger":30.0,
|
||||
"100ms":true
|
||||
},
|
||||
"alert_latching":true,
|
||||
"danger_latching":true,
|
||||
"timed_ok":true,
|
||||
"recorder_output":"direct",
|
||||
"two_ma_clamp":true,
|
||||
"trip_mutiply":1.00,
|
||||
"comparision":"direct",
|
||||
"comparision_percentage":5
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
{
|
||||
"slot":1,
|
||||
"id":1,
|
||||
"filter":[
|
||||
{
|
||||
"type":"high_pass",
|
||||
"low":5,
|
||||
"high":1000,
|
||||
"checked":true
|
||||
},
|
||||
{
|
||||
"type":"low_pass",
|
||||
"low":5,
|
||||
"high":1000,
|
||||
"checked":true
|
||||
},
|
||||
{
|
||||
"type":"band_pass",
|
||||
"low":5,
|
||||
"high":1000,
|
||||
"checked":true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -7,49 +7,49 @@
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 1,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 2,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 3,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 4,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "键相",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 5,
|
||||
"slot_type": "KPM834"
|
||||
},
|
||||
{
|
||||
"chan_display": "键相",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 6,
|
||||
"slot_type": "KPM834"
|
||||
},
|
||||
{
|
||||
"chan_display": "键相",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 7,
|
||||
"slot_type": "KPM834"
|
||||
},
|
||||
{
|
||||
"chan_display": "转速",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 8,
|
||||
"slot_type": "OPM844"
|
||||
},
|
||||
@ -73,25 +73,25 @@
|
||||
},
|
||||
{
|
||||
"chan_display": "继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 12,
|
||||
"slot_type": "DOM810"
|
||||
},
|
||||
{
|
||||
"chan_display": "三冗余继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "TMR1",
|
||||
"slot": 13,
|
||||
"slot_type": "DOM810"
|
||||
},
|
||||
{
|
||||
"chan_display": "三冗余继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "TMR2",
|
||||
"slot": 14,
|
||||
"slot_type": "DOM810"
|
||||
},
|
||||
{
|
||||
"chan_display": "三冗余继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "TMR3",
|
||||
"slot": 15,
|
||||
"slot_type": "DOM810"
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
{
|
||||
"card_type": 1,
|
||||
"chan": [
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "acceleration",
|
||||
"id": 1,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "1-3",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "acceleration",
|
||||
"id": 2,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "1-3",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "velocity",
|
||||
"id": 3,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "3-5",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "velocity",
|
||||
"id": 4,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "3-5",
|
||||
"transducer_name": ""
|
||||
}
|
||||
],
|
||||
"slot": 3,
|
||||
"version": 1
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
{
|
||||
"card_type": 1,
|
||||
"chan": [
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
}
|
||||
],
|
||||
"slot": 4,
|
||||
"version": 1
|
||||
}
|
||||
4
doc/config/transducer.json
Normal file
4
doc/config/transducer.json
Normal file
@ -0,0 +1,4 @@
|
||||
[{"transducer_name":"测试1","scale_factor":1.25},
|
||||
{"transducer_name":"测试2","scale_factor":1.26},
|
||||
{"transducer_name":"测试3","scale_factor":1.27},
|
||||
{"transducer_name":"测试4","scale_factor":1.28}]
|
||||
47
ethconfig.cpp
Normal file
47
ethconfig.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "ethconfig.h"
|
||||
#include "ui_ethconfig.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
|
||||
EthConfig::EthConfig(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::EthConfig)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QRegularExpression ipRegex(R"(^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$)");
|
||||
QRegularExpressionValidator *ipValidator = new QRegularExpressionValidator(ipRegex, this);
|
||||
|
||||
ui->lineEdit_IP->setValidator(ipValidator);
|
||||
ui->lineEdit_netmask->setValidator(ipValidator);
|
||||
ui->lineEdit_gw->setValidator(ipValidator);
|
||||
}
|
||||
|
||||
EthConfig::~EthConfig()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EthConfig::on_pushButton_confirm_clicked()
|
||||
{
|
||||
ConfigIPv4Req config_ip = { {0xAA, 0x55, 0xAA}, kRebootCard, 1,0,{},{},{} };
|
||||
config_ip.ethn = ui->comboBox_eth->currentIndex();
|
||||
memcpy(config_ip.ip,ui->lineEdit_IP->text().toStdString().c_str(),sizeof(config_ip.ip));
|
||||
memcpy(config_ip.netmask,ui->lineEdit_netmask->text().toStdString().c_str(),sizeof(config_ip.netmask));
|
||||
memcpy(config_ip.gw,ui->lineEdit_gw->text().toStdString().c_str(),sizeof(config_ip.gw));
|
||||
char send_buf[100] ={0};
|
||||
memcpy(send_buf, (char*)&config_ip, sizeof(ConfigIPv4Req));
|
||||
|
||||
int length = sizeof(ConfigIPv4Req);
|
||||
qint64 bytesWritten = m_tcpClient->sendData(send_buf, length);
|
||||
m_tcpClient->waitForRead();
|
||||
qDebug() << "bytesWritten: " << bytesWritten;
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void EthConfig::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
30
ethconfig.h
Normal file
30
ethconfig.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef ETHCONFIG_H
|
||||
#define ETHCONFIG_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "MyTcpClient.h"
|
||||
|
||||
namespace Ui {
|
||||
class EthConfig;
|
||||
}
|
||||
|
||||
class EthConfig : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EthConfig(QWidget *parent = nullptr);
|
||||
~EthConfig();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::EthConfig *ui;
|
||||
|
||||
MyTcpClient* m_tcpClient;
|
||||
};
|
||||
|
||||
#endif // ETHCONFIG_H
|
||||
165
ethconfig.ui
Normal file
165
ethconfig.ui
Normal file
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EthConfig</class>
|
||||
<widget class="QWidget" name="EthConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>361</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>以太网配置</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>以太网:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_eth">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>40</y>
|
||||
<width>111</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>90</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>33</x>
|
||||
<y>120</y>
|
||||
<width>81</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>子网掩码:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>150</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>网关:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_IP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>90</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_netmask">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>120</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_gw">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>150</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>222</y>
|
||||
<width>71</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>222</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
380
keyphase.cpp
380
keyphase.cpp
@ -6,192 +6,262 @@
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
|
||||
KeyPhase::KeyPhase(int slot_no_,QWidget *parent)
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "keyphase_data.h"
|
||||
|
||||
KeyPhase::KeyPhase(int slot_no_,int cardtype, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::KeyPhase)
|
||||
{
|
||||
, ui(new Ui::KeyPhase) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
slot_no = slot_no_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_slot->setText(slot);
|
||||
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||
readJsonFile(filePath_keyphase);
|
||||
// QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||
// readJsonFile(filePath_keyphase);
|
||||
Init();
|
||||
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_1_clicked);
|
||||
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_2_clicked);
|
||||
connect(ui->radioButton_manual_threshold_3, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_3_clicked);
|
||||
connect(ui->radioButton_manual_threshold_4, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_4_clicked);
|
||||
}
|
||||
|
||||
KeyPhase::~KeyPhase()
|
||||
{
|
||||
KeyPhase::~KeyPhase() {
|
||||
delete ui;
|
||||
}
|
||||
void KeyPhase::readJsonFile(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
|
||||
void KeyPhase::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_1_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_2_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_3_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
keyphase_variables[i].id = temp_obj["id"].toInt();
|
||||
keyphase_variables[i].active = temp_obj["active"].toBool();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
keyphase_variables[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
keyphase_variables[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
keyphase_variables[i].threshold = temp_obj["threshold"].toDouble();
|
||||
keyphase_variables[i].hysteresis = temp_obj["hysteresis"].toDouble();
|
||||
keyphase_variables[i].events_per_revolution = temp_obj["events_per_revolution"].toInt();
|
||||
keyphase_variables[i].record_output = temp_obj["record_output"].toString();
|
||||
keyphase_variables[i].two_ma_clamp = temp_obj["two_ma_clamp"].toBool();
|
||||
keyphase_variables[i].alert_latching = temp_obj["alert_latching"].toBool();
|
||||
keyphase_variables[i].overspeed_latching = temp_obj["overspeed_latching"].toBool();
|
||||
keyphase_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_4_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data) {
|
||||
keyphase_data->card_type_ = kCardKeyphaseSingle;
|
||||
keyphase_data->slot_ = slot_no;
|
||||
keyphase_data->version_ = 1;
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_1->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
} else if (i + 1 == 2) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_2->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
} else if (i + 1 == 3) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_3->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
} else if (i + 1 == 4) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_4->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
void KeyPhase::Init()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(keyphase_variables[i].id == 1){
|
||||
ui->checkBox_enable_1->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
|
||||
void KeyPhase::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::make_shared<KeyphaseData>();
|
||||
keyphase_data->card_type_ = car_type;
|
||||
keyphase_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(keyphase_data);
|
||||
UpdateData(keyphase_data);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
ui->checkBox_enable_1->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_1->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(keyphase_variables[i].events_per_revolution);
|
||||
|
||||
}
|
||||
if(keyphase_variables[i].id == 2)
|
||||
{
|
||||
ui->checkBox_enable_2->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
} else if (i + 1 == 2) {
|
||||
ui->checkBox_enable_2->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_2->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(keyphase_variables[i].events_per_revolution);
|
||||
|
||||
}
|
||||
if(keyphase_variables[i].id == 3){
|
||||
ui->checkBox_enable_3->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_enable_3->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_3->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(keyphase_variables[i].events_per_revolution);
|
||||
}
|
||||
if(keyphase_variables[i].id == 4){
|
||||
ui->checkBox_enable_4->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
} else if (i + 1 == 4) {
|
||||
ui->checkBox_enable_4->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_4->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(keyphase_variables[i].events_per_revolution);
|
||||
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
}
|
||||
}
|
||||
}
|
||||
void KeyPhase::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(keyphase_variables[i].id == 1){
|
||||
keyphase_variables[i].active = ui->checkBox_enable_1->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
}
|
||||
if(keyphase_variables[i].id == 2){
|
||||
keyphase_variables[i].active = ui->checkBox_enable_2->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
}
|
||||
if(keyphase_variables[i].id == 3){
|
||||
keyphase_variables[i].active = ui->checkBox_enable_3->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
}
|
||||
if(keyphase_variables[i].id == 4){
|
||||
keyphase_variables[i].active = ui->checkBox_enable_4->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
}
|
||||
}
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||
QFile file(filePath_keyphase);
|
||||
if(!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug() << "Could not open file for writing";
|
||||
void KeyPhase::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << " should not be here";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj;
|
||||
QJsonArray chan_array;
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("id", keyphase_variables[i].id);
|
||||
temp_obj.insert("active", keyphase_variables[i].active);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(keyphase_variables[i].normal_voltage_low);
|
||||
voltage_range_array.append(keyphase_variables[i].normal_voltage_high);
|
||||
temp_obj.insert("normal_voltage_range", voltage_range_array);
|
||||
temp_obj.insert("threshold", keyphase_variables[i].threshold);
|
||||
temp_obj.insert("hysteresis", keyphase_variables[i].hysteresis);
|
||||
temp_obj.insert("events_per_revolution", keyphase_variables[i].events_per_revolution);
|
||||
temp_obj.insert("automatic_threshold",keyphase_variables[i].automatic_threshold);
|
||||
chan_array.append(temp_obj);
|
||||
}
|
||||
json_obj.insert("chan", chan_array);
|
||||
json_obj.insert("version",1);
|
||||
json_obj.insert("slot",slot_no);
|
||||
json_obj.insert("card_type",2);
|
||||
QJsonDocument json_doc;
|
||||
json_doc.setObject(json_obj);
|
||||
QByteArray byte_array = json_doc.toJson();
|
||||
file.write(byte_array);
|
||||
file.close();
|
||||
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||
UpdateData(keyphase_data);
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_1_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_1->isChecked()){
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_1_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_1->isChecked()){
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_2_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_2->isChecked()){
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_2_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_2->isChecked()){
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_3_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_3->isChecked()){
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_3_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_3->isChecked()){
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_4_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_4->isChecked()){
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_4_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_4->isChecked()){
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
39
keyphase.h
39
keyphase.h
@ -1,28 +1,49 @@
|
||||
#ifndef KEYPHASE_H
|
||||
#define KEYPHASE_H
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
#include "data_config.h"
|
||||
#include "keyphase_data.h"
|
||||
namespace Ui {
|
||||
class KeyPhase;
|
||||
}
|
||||
|
||||
class KeyPhase : public QDialog
|
||||
{
|
||||
class KeyPhase : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KeyPhase(int slot_no_,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit KeyPhase(int slot_no_,int cardtype, QWidget *parent = nullptr);
|
||||
~KeyPhase();
|
||||
int slot_no;
|
||||
|
||||
private slots:
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_manual_threshold_1_clicked(bool checked);
|
||||
void on_manual_threshold_2_clicked(bool checked);
|
||||
void on_manual_threshold_3_clicked(bool checked);
|
||||
void on_manual_threshold_4_clicked(bool checked);
|
||||
void on_radioButton_manual_threshold_1_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_1_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_2_clicked();
|
||||
|
||||
void on_radioButton_manual_threshold_2_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_3_clicked();
|
||||
|
||||
void on_radioButton_manual_threshold_3_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_4_clicked();
|
||||
|
||||
void on_radioButton_manual_threshold_4_clicked();
|
||||
|
||||
private:
|
||||
Ui::KeyPhase *ui;
|
||||
Tachometer_Variables keyphase_variables[4];
|
||||
void readJsonFile(const QString &filePath);
|
||||
void UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data);
|
||||
// TachometerVariables keyphase_variables[4];
|
||||
// void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
207
keyphase.ui
207
keyphase.ui
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>660</width>
|
||||
<height>580</height>
|
||||
<width>691</width>
|
||||
<height>598</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -31,7 +31,7 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_body" native="true">
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
@ -45,9 +45,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<x>480</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
@ -73,7 +76,7 @@
|
||||
<widget class="QLabel" name="label_39">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<x>326</x>
|
||||
<y>310</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
@ -83,23 +86,10 @@
|
||||
<string> ===</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>296</x>
|
||||
<x>322</x>
|
||||
<y>250</y>
|
||||
<width>51</width>
|
||||
<height>32</height>
|
||||
@ -114,12 +104,12 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>281</width>
|
||||
<width>301</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -197,6 +187,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_1">
|
||||
<property name="geometry">
|
||||
@ -219,6 +221,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_50">
|
||||
<property name="geometry">
|
||||
@ -373,6 +387,15 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
@ -428,6 +451,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -524,7 +550,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>251</width>
|
||||
<width>281</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -552,6 +578,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_2">
|
||||
<property name="geometry">
|
||||
@ -574,6 +612,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_94">
|
||||
<property name="geometry">
|
||||
@ -667,7 +717,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>251</width>
|
||||
<width>281</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -744,13 +794,22 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>90</y>
|
||||
<width>111</width>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -763,7 +822,7 @@
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>130</y>
|
||||
<width>101</width>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -799,6 +858,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -835,7 +897,7 @@
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>294</x>
|
||||
<x>320</x>
|
||||
<y>360</y>
|
||||
<width>51</width>
|
||||
<height>32</height>
|
||||
@ -846,9 +908,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<x>390</x>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -861,14 +926,14 @@
|
||||
<widget class="QTabWidget" name="tabWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<x>380</x>
|
||||
<y>60</y>
|
||||
<width>281</width>
|
||||
<width>301</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_5">
|
||||
<attribute name="title">
|
||||
@ -946,6 +1011,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_3">
|
||||
<property name="geometry">
|
||||
@ -968,6 +1045,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_78">
|
||||
<property name="geometry">
|
||||
@ -1164,6 +1253,15 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="geometry">
|
||||
@ -1219,6 +1317,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -1273,7 +1374,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>251</width>
|
||||
<width>281</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1301,6 +1402,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_4">
|
||||
<property name="geometry">
|
||||
@ -1323,6 +1436,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_86">
|
||||
<property name="geometry">
|
||||
@ -1413,7 +1538,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>251</width>
|
||||
<width>281</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1490,13 +1615,22 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>90</y>
|
||||
<width>111</width>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1509,7 +1643,7 @@
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>130</y>
|
||||
<width>101</width>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1545,6 +1679,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -1628,7 +1765,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_standby">
|
||||
<property name="text">
|
||||
<string>5-6</string>
|
||||
<string>--</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
6
keyphase_data.cpp
Normal file
6
keyphase_data.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "keyphase_data.h"
|
||||
|
||||
KeyphaseData::KeyphaseData()
|
||||
{
|
||||
|
||||
}
|
||||
11
keyphase_data.h
Normal file
11
keyphase_data.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef KEYPHASEDATA_H
|
||||
#define KEYPHASEDATA_H
|
||||
|
||||
#include "cardbase.h"
|
||||
class KeyphaseData : public CardBase {
|
||||
public:
|
||||
KeyphaseData();
|
||||
KeyphaseVariables variables_[4];
|
||||
};
|
||||
|
||||
#endif // KEYPHASEDATA_H
|
||||
40
macconfig.cpp
Normal file
40
macconfig.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "macconfig.h"
|
||||
#include "ui_macconfig.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
MacConfig::MacConfig(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::MacConfig)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QRegularExpression macRegex("^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$");
|
||||
QRegularExpressionValidator *macValidator = new QRegularExpressionValidator(macRegex, this);
|
||||
ui->lineEdit_mac->setValidator(macValidator);
|
||||
}
|
||||
|
||||
MacConfig::~MacConfig()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MacConfig::on_pushButton_confirm_clicked()
|
||||
{
|
||||
ConfigMacReq config_mac = { {0xAA, 0x55, 0xAA}, kConfigMac, 1,0,{} };
|
||||
memcpy(config_mac.mac,ui->lineEdit_mac->text().toStdString().c_str(),sizeof(config_mac.mac));
|
||||
char send_buf[50] ={0};
|
||||
memcpy(send_buf, (char*)&config_mac, sizeof(ConfigMacReq));
|
||||
|
||||
int length = sizeof(ConfigMacReq);
|
||||
qint64 bytesWritten = m_tcpClient->sendData(send_buf, length);
|
||||
m_tcpClient->waitForRead();
|
||||
qDebug() << "bytesWritten: " << bytesWritten;
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void MacConfig::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
29
macconfig.h
Normal file
29
macconfig.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef MACCONFIG_H
|
||||
#define MACCONFIG_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "MyTcpClient.h"
|
||||
|
||||
namespace Ui {
|
||||
class MacConfig;
|
||||
}
|
||||
|
||||
class MacConfig : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MacConfig(QWidget *parent = nullptr);
|
||||
~MacConfig();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::MacConfig *ui;
|
||||
MyTcpClient* m_tcpClient;
|
||||
};
|
||||
|
||||
#endif // MACCONFIG_H
|
||||
74
macconfig.ui
Normal file
74
macconfig.ui
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MacConfig</class>
|
||||
<widget class="QWidget" name="MacConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>mac配置</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>80</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MAC:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>80</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>212</y>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>212</y>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
1082
mainwindow.cpp
1082
mainwindow.cpp
File diff suppressed because it is too large
Load Diff
19
mainwindow.h
19
mainwindow.h
@ -45,6 +45,9 @@ private:
|
||||
QTcpSocket *socket;
|
||||
|
||||
QProgressBar *progressBar;
|
||||
CardType card_type;
|
||||
int current_slot;
|
||||
QString tsi_config_file;
|
||||
|
||||
void createMenu();
|
||||
void createMenu(const QString& rootTitle, QPushButton* button = nullptr);
|
||||
@ -54,15 +57,28 @@ private:
|
||||
void readJsonFile(const QString &filePath);
|
||||
void sendUpgradePackage(int slot);
|
||||
void getVersion(int slot);
|
||||
void ConfigSubCard(int slot);
|
||||
void GetSubLog(int slot);
|
||||
void initStyle();
|
||||
void connectServer();
|
||||
void UploadConfigFile(uint8_t sub_cmd);
|
||||
|
||||
private slots:
|
||||
|
||||
void onDisConnected();
|
||||
void onConnected();
|
||||
void readData(const QByteArray&);
|
||||
void onerrorOccurred(const QString &errorMsg);
|
||||
void onMenuAction_relay();
|
||||
void OnButtonGroup(QAbstractButton *);
|
||||
void onConnect();
|
||||
void onDisconnect();
|
||||
void onEthConfig();
|
||||
void onMACConfig();
|
||||
void onSetTime();
|
||||
void onMqttConfig();
|
||||
void onConfigDeviceID();
|
||||
void onGetDeviceID();
|
||||
|
||||
void onMenuActionTriggered();
|
||||
void on_pushButton_slot_clicked();
|
||||
@ -71,5 +87,8 @@ private slots:
|
||||
void on_pushButton_point_name_clicked();
|
||||
void on_pushButton_save_clicked();
|
||||
void on_pushButton_open_clicked();
|
||||
void on_pushButton_download_clicked();
|
||||
void on_pushButton_upload_clicked();
|
||||
void on_pushButton_upload_config_clicked();
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
190
mainwindow.ui
190
mainwindow.ui
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
<string>TSI_Config</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -48,31 +48,6 @@
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton_save">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_open">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
@ -93,14 +68,17 @@
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>保存配置</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_22">
|
||||
<widget class="QPushButton" name="pushButton_open">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
@ -118,11 +96,14 @@
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>打开配置文件</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_23">
|
||||
<widget class="QPushButton" name="pushButton_upload">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
@ -143,14 +124,17 @@
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>上传配置文件</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>上传</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_24">
|
||||
<widget class="QPushButton" name="pushButton_download">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<x>260</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
@ -168,14 +152,17 @@
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>下载配置文件</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>下载</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_25">
|
||||
<widget class="QPushButton" name="pushButton_upload_config">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<x>200</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
@ -193,58 +180,11 @@
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
<property name="toolTip">
|
||||
<string>上传配置文件并下发到子板卡</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_27">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -314,7 +254,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>触发配置</string>
|
||||
<string>直流输出</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
@ -784,7 +724,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>电源板</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
@ -831,7 +771,7 @@
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -850,7 +790,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -869,7 +809,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -888,7 +828,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1121,17 +1061,18 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1129</width>
|
||||
<height>21</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
<widget class="QMenu" name="menu_start">
|
||||
<property name="title">
|
||||
<string>文件</string>
|
||||
<string>开始</string>
|
||||
</property>
|
||||
<addaction name="actionNEW"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actiondaoru"/>
|
||||
<addaction name="actionlianjie"/>
|
||||
<addaction name="action_new"/>
|
||||
<addaction name="action_open"/>
|
||||
<addaction name="action_import"/>
|
||||
<addaction name="action_connect"/>
|
||||
<addaction name="action_disconnect"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_2">
|
||||
<property name="title">
|
||||
@ -1144,18 +1085,23 @@
|
||||
</property>
|
||||
<addaction name="action_realy"/>
|
||||
<addaction name="action_time"/>
|
||||
<addaction name="action_eth"/>
|
||||
<addaction name="action_mac"/>
|
||||
<addaction name="action_mqtt"/>
|
||||
<addaction name="action_deviveID"/>
|
||||
<addaction name="action_get_deviceID"/>
|
||||
</widget>
|
||||
<addaction name="menu"/>
|
||||
<addaction name="menu_2"/>
|
||||
<addaction name="menu_start"/>
|
||||
<addaction name="menu_tool"/>
|
||||
<addaction name="menu_2"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionNEW">
|
||||
<action name="action_new">
|
||||
<property name="text">
|
||||
<string>新建</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<action name="action_open">
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
@ -1167,19 +1113,49 @@
|
||||
</action>
|
||||
<action name="action_time">
|
||||
<property name="text">
|
||||
<string>校时功能</string>
|
||||
<string>校时</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actiondaoru">
|
||||
<action name="action_import">
|
||||
<property name="text">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionlianjie">
|
||||
<action name="action_connect">
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_disconnect">
|
||||
<property name="text">
|
||||
<string>断开</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_eth">
|
||||
<property name="text">
|
||||
<string>网络配置</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_mac">
|
||||
<property name="text">
|
||||
<string>MAC配置</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_mqtt">
|
||||
<property name="text">
|
||||
<string>MQTT配置</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_deviveID">
|
||||
<property name="text">
|
||||
<string>设备ID配置</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_get_deviceID">
|
||||
<property name="text">
|
||||
<string>获取设备ID</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
53
mqtt_config.cpp
Normal file
53
mqtt_config.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "mqtt_config.h"
|
||||
#include "ui_mqtt_config.h"
|
||||
#include <QRegExpValidator>
|
||||
MqttConfig::MqttConfig(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::MqttConfig)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QString exp = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)"
|
||||
"{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b";
|
||||
QRegExp rege(exp);
|
||||
QValidator *Validator = new QRegExpValidator(rege);
|
||||
ui->lineEdit_ip->setValidator(Validator);
|
||||
m_tcpClient = MyTcpClient::instance();
|
||||
connect(m_tcpClient, SIGNAL(dataReceived(const QByteArray &)), this, SLOT(readData(const QByteArray &)));
|
||||
|
||||
}
|
||||
|
||||
MqttConfig::~MqttConfig()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void MqttConfig::readData(const QByteArray &data) {
|
||||
qDebug() << "Received from server:" << data;
|
||||
uint8_t cmd = data[3];
|
||||
if (cmd == kConfigMQTTBrokerInfo) {
|
||||
MQTTBrokerConfigInfoRsp mqtt_config_rsp;
|
||||
memcpy(&mqtt_config_rsp, data.data(), sizeof(MQTTBrokerConfigInfoRsp));
|
||||
qDebug() << "mqtt_config_rsp code" << mqtt_config_rsp.code ;
|
||||
}
|
||||
}
|
||||
void MqttConfig::on_pushButton_confirm_clicked()
|
||||
{
|
||||
MQTTBrokerConfigInfoReq mqtt_config = { {0xAA, 0x55, 0xAA}, kConfigMQTTBrokerInfo, 1,1,{} };
|
||||
memcpy(mqtt_config.ip,ui->lineEdit_ip->text().toStdString().c_str(),sizeof(mqtt_config.ip));
|
||||
mqtt_config.port = ui->lineEdit_port->text().toInt();
|
||||
char send_buf[100] ={0};
|
||||
memcpy(send_buf, (char*)&mqtt_config, sizeof(MQTTBrokerConfigInfoReq));
|
||||
|
||||
int length = sizeof(MQTTBrokerConfigInfoReq);
|
||||
qint64 bytesWritten = m_tcpClient->sendData(send_buf, length);
|
||||
m_tcpClient->waitForRead();
|
||||
qDebug() << "bytesWritten: " << bytesWritten;
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void MqttConfig::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
28
mqtt_config.h
Normal file
28
mqtt_config.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef MQTT_CONFIG_H
|
||||
#define MQTT_CONFIG_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "MyTcpClient.h"
|
||||
namespace Ui {
|
||||
class MqttConfig;
|
||||
}
|
||||
|
||||
class MqttConfig : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MqttConfig(QWidget *parent = nullptr);
|
||||
~MqttConfig();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
void readData(const QByteArray&);
|
||||
private:
|
||||
Ui::MqttConfig *ui;
|
||||
MyTcpClient* m_tcpClient;
|
||||
};
|
||||
|
||||
#endif // MQTT_CONFIG_H
|
||||
116
mqtt_config.ui
Normal file
116
mqtt_config.ui
Normal file
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MqttConfig</class>
|
||||
<widget class="QWidget" name="MqttConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>412</width>
|
||||
<height>314</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MQTT 配置</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>30</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MQTT 服务器配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>90</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_ip">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>80</y>
|
||||
<width>151</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>130</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>端口:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_port">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>120</y>
|
||||
<width>151</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>230</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>230</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
72
pointname.cpp
Normal file
72
pointname.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "pointname.h"
|
||||
#include "ui_pointname.h"
|
||||
#include "config_mgr.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "tachometer_data.h"
|
||||
|
||||
PointName::PointName(int slot_no_,int cardtype,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PointName)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
ui->label_slot->setText(QString::number(slot_no));
|
||||
Init();
|
||||
}
|
||||
|
||||
PointName::~PointName()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PointName::Init()
|
||||
{
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
if(base_ptr->card_type_ == kCardVibSingle){
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
|
||||
ui->lineEdit_pointname_1->setText(vib_data->base_config_[0].point_name);
|
||||
ui->lineEdit_pointname_2->setText(vib_data->base_config_[1].point_name);
|
||||
ui->lineEdit_pointname_3->setText(vib_data->base_config_[2].point_name);
|
||||
ui->lineEdit_pointname_4->setText(vib_data->base_config_[3].point_name);
|
||||
}else if(base_ptr->card_type_ == kCardSpeedSingle){
|
||||
std::shared_ptr<TachometerData> tac_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
ui->lineEdit_pointname_1->setText(tac_data->variables_[0].point_name);
|
||||
ui->lineEdit_pointname_2->setText(tac_data->variables_[1].point_name);
|
||||
ui->lineEdit_pointname_3->setText(tac_data->variables_[2].point_name);
|
||||
ui->lineEdit_pointname_4->setText(tac_data->variables_[3].point_name);
|
||||
}
|
||||
}
|
||||
|
||||
void PointName::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void PointName::on_pushButton_confirm_clicked()
|
||||
{
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
if(base_ptr->card_type_ == kCardVibSingle){
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
vib_data->base_config_[0].point_name = ui->lineEdit_pointname_1->text();
|
||||
vib_data->base_config_[1].point_name = ui->lineEdit_pointname_2->text();
|
||||
vib_data->base_config_[2].point_name = ui->lineEdit_pointname_3->text();
|
||||
vib_data->base_config_[3].point_name = ui->lineEdit_pointname_4->text();
|
||||
}else if(base_ptr->card_type_ == kCardSpeedSingle){
|
||||
std::shared_ptr<TachometerData> tac_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
tac_data->variables_[0].point_name = ui->lineEdit_pointname_1->text();
|
||||
tac_data->variables_[1].point_name = ui->lineEdit_pointname_2->text();
|
||||
tac_data->variables_[2].point_name = ui->lineEdit_pointname_3->text();
|
||||
tac_data->variables_[3].point_name = ui->lineEdit_pointname_4->text();
|
||||
}
|
||||
this->close();
|
||||
}
|
||||
|
||||
31
pointname.h
Normal file
31
pointname.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef POINTNAME_H
|
||||
#define POINTNAME_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
|
||||
namespace Ui {
|
||||
class PointName;
|
||||
}
|
||||
|
||||
class PointName : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointName(int slot_no_,int cardtype,QWidget *parent = nullptr);
|
||||
~PointName();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
private:
|
||||
Ui::PointName *ui;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif // POINTNAME_H
|
||||
211
pointname.ui
Normal file
211
pointname.ui
Normal file
@ -0,0 +1,211 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PointName</class>
|
||||
<widget class="QWidget" name="PointName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>槽位号:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_slot">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>30</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>slot</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>232</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>232</y>
|
||||
<width>71</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>70</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>通道1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_1"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>110</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>通道2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>150</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>通道3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_3"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>190</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>通道4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_4"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
314
pressure_pulsation.cpp
Normal file
314
pressure_pulsation.cpp
Normal file
@ -0,0 +1,314 @@
|
||||
#include "pressure_pulsation.h"
|
||||
#include "ui_pressure_pulsation.h"
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QMessageBox>
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
PressurePulsation::PressurePulsation(int slot_no_, int channel_, bool active,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PressurePulsation)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
channel = channel_;
|
||||
QString chan = QString("%1").arg(channel);
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_channel->setText(chan);
|
||||
ui->label_slot->setText(slot);
|
||||
if (active) {
|
||||
ui->label_active->setText("(启用)");
|
||||
} else {
|
||||
ui->label_active->setText("(停用)");
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
PressurePulsation::~PressurePulsation()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void PressurePulsation::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Radial::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if (ptr->base_config_[channel - 1].channel_type != kVibPressurePulsation) {
|
||||
qDebug() << "[Radial::Init] channel type changes";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "[Radial::Init] no channel ptr";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<PressurePulsationVariable> variable_ptr = std::dynamic_pointer_cast<PressurePulsationVariable>(variable_base);
|
||||
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
|
||||
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
|
||||
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
|
||||
// processed output
|
||||
// -general
|
||||
if(variable_ptr->general.output_used)
|
||||
ui->comboBox_output_used->setCurrentIndex(0);
|
||||
else
|
||||
ui->comboBox_output_used->setCurrentIndex(1);
|
||||
ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit);
|
||||
ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function);
|
||||
// -alarm
|
||||
ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level));
|
||||
ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis));
|
||||
ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay));
|
||||
ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable);
|
||||
ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch);
|
||||
|
||||
ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level));
|
||||
ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis));
|
||||
ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay));
|
||||
ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable);
|
||||
ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch);
|
||||
|
||||
ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level));
|
||||
ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis));
|
||||
ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay));
|
||||
ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable);
|
||||
ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch);
|
||||
|
||||
ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level));
|
||||
ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis));
|
||||
ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay));
|
||||
ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable);
|
||||
ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch);
|
||||
|
||||
//
|
||||
ui->checkBox_enable->setChecked(variable_ptr->freband_output[0].enable);
|
||||
ui->lineEdit_start->setText(QString::number(variable_ptr->freband_output[0].start));
|
||||
ui->lineEdit_end->setText(QString::number(variable_ptr->freband_output[0].end));
|
||||
ui->checkBox_enable_2->setChecked(variable_ptr->freband_output[1].enable);
|
||||
ui->lineEdit_start_2->setText(QString::number(variable_ptr->freband_output[1].start));
|
||||
ui->lineEdit_end_2->setText(QString::number(variable_ptr->freband_output[1].end));
|
||||
ui->checkBox_enable_3->setChecked(variable_ptr->freband_output[2].enable);
|
||||
ui->lineEdit_start_3->setText(QString::number(variable_ptr->freband_output[2].start));
|
||||
ui->lineEdit_end_3->setText(QString::number(variable_ptr->freband_output[2].end));
|
||||
ui->checkBox_enable_4->setChecked(variable_ptr->freband_output[3].enable);
|
||||
ui->lineEdit_start_4->setText(QString::number(variable_ptr->freband_output[3].start));
|
||||
ui->lineEdit_end_4->setText(QString::number(variable_ptr->freband_output[3].end));
|
||||
ui->checkBox_enable_5->setChecked(variable_ptr->freband_output[4].enable);
|
||||
ui->lineEdit_start_5->setText(QString::number(variable_ptr->freband_output[4].start));
|
||||
ui->lineEdit_end_5->setText(QString::number(variable_ptr->freband_output[4].end));
|
||||
ui->checkBox_enable_6->setChecked(variable_ptr->freband_output[5].enable);
|
||||
ui->lineEdit_start_6->setText(QString::number(variable_ptr->freband_output[5].start));
|
||||
ui->lineEdit_end_6->setText(QString::number(variable_ptr->freband_output[5].end));
|
||||
ui->checkBox_enable_7->setChecked(variable_ptr->freband_output[6].enable);
|
||||
ui->lineEdit_start_7->setText(QString::number(variable_ptr->freband_output[6].start));
|
||||
ui->lineEdit_end_7->setText(QString::number(variable_ptr->freband_output[6].end));
|
||||
ui->checkBox_enable_8->setChecked(variable_ptr->freband_output[7].enable);
|
||||
ui->lineEdit_start_8->setText(QString::number(variable_ptr->freband_output[7].start));
|
||||
ui->lineEdit_end_8->setText(QString::number(variable_ptr->freband_output[7].end));
|
||||
ui->checkBox_enable_9->setChecked(variable_ptr->freband_output[8].enable);
|
||||
ui->lineEdit_start_9->setText(QString::number(variable_ptr->freband_output[8].start));
|
||||
ui->lineEdit_end_9->setText(QString::number(variable_ptr->freband_output[8].end));
|
||||
ui->checkBox_enable_10->setChecked(variable_ptr->freband_output[9].enable);
|
||||
ui->lineEdit_start_10->setText(QString::number(variable_ptr->freband_output[9].start));
|
||||
ui->lineEdit_end_10->setText(QString::number(variable_ptr->freband_output[9].end));
|
||||
|
||||
}
|
||||
void PressurePulsation::on_pushButton_confirm_clicked()
|
||||
{
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Radial::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
||||
QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
ptr->base_config_[channel - 1].channel_type = kVibPressurePulsation;
|
||||
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
std::shared_ptr<PressurePulsationVariable> variable = std::dynamic_pointer_cast<PressurePulsationVariable>(variable_base);
|
||||
|
||||
if (variable_base == nullptr || variable_base->type_ != kVibThrust || variable == nullptr) {
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "no channel ptr";
|
||||
} else {
|
||||
ptr->RemoveChannel(channel);
|
||||
qDebug() << "channel type change";
|
||||
}
|
||||
std::shared_ptr<PressurePulsationVariable> variable = std::make_shared<PressurePulsationVariable>();
|
||||
variable->id_ = channel;
|
||||
variable->type_ = kVibPressurePulsation;
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->checkState();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->checkState();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->checkState();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
// processed output
|
||||
// -general
|
||||
if(ui->comboBox_output_used->currentIndex() == 0)
|
||||
variable->general.output_used = true;
|
||||
else
|
||||
variable->general.output_used = false;
|
||||
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
||||
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
||||
// -alarm
|
||||
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
||||
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||||
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||||
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
||||
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
||||
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
||||
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||||
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||||
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
||||
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
||||
variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
||||
variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
||||
variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
||||
variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
||||
variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
||||
variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
||||
variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
||||
variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
||||
variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
||||
variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
||||
// -freband output
|
||||
variable->freband_output[0].enable = ui->checkBox_enable->isChecked();
|
||||
variable->freband_output[0].start = ui->lineEdit_start->text().toDouble();
|
||||
variable->freband_output[0].end = ui->lineEdit_end->text().toDouble();
|
||||
variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked();
|
||||
variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble();
|
||||
variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble();
|
||||
variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked();
|
||||
variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble();
|
||||
variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble();
|
||||
variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked();
|
||||
variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble();
|
||||
variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble();
|
||||
variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked();
|
||||
variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble();
|
||||
variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble();
|
||||
variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked();
|
||||
variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble();
|
||||
variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble();
|
||||
variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked();
|
||||
variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble();
|
||||
variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble();
|
||||
variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked();
|
||||
variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble();
|
||||
variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble();
|
||||
variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked();
|
||||
variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble();
|
||||
variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble();
|
||||
variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked();
|
||||
variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble();
|
||||
variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble();
|
||||
|
||||
ptr->variables_.push_back(variable);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->checkState();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->checkState();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->checkState();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
// processed output
|
||||
// -general
|
||||
if(ui->comboBox_output_used->currentIndex() == 0)
|
||||
variable->general.output_used = true;
|
||||
else
|
||||
variable->general.output_used = false;
|
||||
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
||||
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
||||
// -alarm
|
||||
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
||||
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||||
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||||
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
||||
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
||||
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
||||
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||||
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||||
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
||||
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
||||
variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
||||
variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
||||
variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
||||
variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
||||
variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
||||
variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
||||
variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
||||
variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
||||
variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
||||
variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
||||
// -freband output
|
||||
variable->freband_output[0].enable = ui->checkBox_enable->isChecked();
|
||||
variable->freband_output[0].start = ui->lineEdit_start->text().toDouble();
|
||||
variable->freband_output[0].end = ui->lineEdit_end->text().toDouble();
|
||||
variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked();
|
||||
variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble();
|
||||
variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble();
|
||||
variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked();
|
||||
variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble();
|
||||
variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble();
|
||||
variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked();
|
||||
variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble();
|
||||
variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble();
|
||||
variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked();
|
||||
variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble();
|
||||
variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble();
|
||||
variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked();
|
||||
variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble();
|
||||
variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble();
|
||||
variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked();
|
||||
variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble();
|
||||
variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble();
|
||||
variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked();
|
||||
variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble();
|
||||
variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble();
|
||||
variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked();
|
||||
variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble();
|
||||
variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble();
|
||||
variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked();
|
||||
variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble();
|
||||
variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble();
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void PressurePulsation::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void PressurePulsation::on_lineEdit_alert_high_level_editingFinished()
|
||||
{
|
||||
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
||||
ui->lineEdit_danger_high_level->setText(ui->lineEdit_alert_high_level->text());
|
||||
}
|
||||
}
|
||||
|
||||
32
pressure_pulsation.h
Normal file
32
pressure_pulsation.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef PRESSURE_PULSATION_H
|
||||
#define PRESSURE_PULSATION_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class PressurePulsation;
|
||||
}
|
||||
|
||||
class PressurePulsation : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PressurePulsation(int slot_no_, int channel_, bool active,QWidget *parent = nullptr);
|
||||
~PressurePulsation();
|
||||
int slot_no;
|
||||
int channel;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_lineEdit_alert_high_level_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::PressurePulsation *ui;
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif // PRESSURE_PULSATION_H
|
||||
1439
pressure_pulsation.ui
Normal file
1439
pressure_pulsation.ui
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,11 +5,14 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QMessageBox>
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget *parent)
|
||||
Radial::Radial(int slot_no_, int channel_, bool active, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::Radial_vibration)
|
||||
{
|
||||
, ui(new Ui::Radial_vibration) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
channel = channel_;
|
||||
@ -17,279 +20,300 @@ Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_channel->setText(chan);
|
||||
ui->label_slot->setText(slot);
|
||||
if(active)
|
||||
if (active) {
|
||||
ui->label_active->setText("(启用)");
|
||||
else
|
||||
} else {
|
||||
ui->label_active->setText("(停用)");
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_filter);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_variables);
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
Radial_vibration::~Radial_vibration()
|
||||
{
|
||||
Radial::~Radial() {
|
||||
delete ui;
|
||||
}
|
||||
void Radial_vibration::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
if(filePath.contains("filter_")){
|
||||
QJsonArray filter_array = json_obj["filter"].toArray();
|
||||
for(int i = 0; i < filter_array.size(); i++){
|
||||
QJsonObject temp_obj = filter_array[i].toObject();
|
||||
filter[i].type = temp_obj["type"].toString();
|
||||
filter[i].low = temp_obj["low"].toInt();
|
||||
filter[i].high = temp_obj["high"].toInt();
|
||||
filter[i].checked = temp_obj["checked"].toBool();
|
||||
}
|
||||
}else if(filePath.contains("radial_vibration_variables_")){
|
||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
||||
for(int i = 0; i < variables_array.size(); i++){
|
||||
QJsonObject temp_obj = variables_array[i].toObject();
|
||||
variables[i].type = temp_obj["type"].toString();
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}else if(variables[i].type == "not_1x_ampl"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
}else if(variables[i].type == "smax_ampl"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
}
|
||||
}
|
||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
||||
delay.alert = delay_obj["alert"].toInt();
|
||||
delay.danger = delay_obj["danger"].toDouble();
|
||||
delay.active_100ms = delay_obj["active_100ms"].toBool();
|
||||
alert_variables.alert_latching = json_obj["alert_latching"].toBool();
|
||||
alert_variables.danger_latching = json_obj["danger_latching"].toBool();
|
||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
||||
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
||||
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
||||
alert_variables.comparision = json_obj["comparision"].toString();
|
||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
||||
}
|
||||
|
||||
void Radial::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Radial_vibration::Init()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].type == "band_pass"){
|
||||
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "gap"){
|
||||
ui->comboBox_gap_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
ui->checkBox_1x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
ui->checkBox_2x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||
}else if(variables[i].type == "not_1x_ampl"){
|
||||
ui->checkBox_not_1x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_not_1x_ampl->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "smax_ampl"){
|
||||
ui->checkBox_smax_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_smax_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_smax_clamp->setValue(variables[i].clamp_value);
|
||||
}
|
||||
}
|
||||
ui->spinBox_alert_delay->setValue(delay.alert);
|
||||
ui->doubleSpinBox_danger_delay->setValue(delay.danger);
|
||||
ui->checkBox_100ms_delay->setChecked(delay.active_100ms);
|
||||
ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching);
|
||||
ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching);
|
||||
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
||||
}
|
||||
|
||||
void Radial_vibration::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].checked){
|
||||
if(filter[i].type == "band_pass"){
|
||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
}else if(variables[i].type == "gap"){
|
||||
variables[i].full_sacle_range = ui->comboBox_gap_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_gap_clamp->value();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "not_1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_not_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_not_1x_ampl->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_not_1x_ampl_clamp->value();
|
||||
}else if(variables[i].type == "smax_ampl"){
|
||||
variables[i].checked = ui->checkBox_smax_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_smax_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_smax_clamp->value();
|
||||
}
|
||||
}
|
||||
delay.alert = ui->spinBox_alert_delay->value();
|
||||
delay.danger = ui->doubleSpinBox_danger_delay->value();
|
||||
delay.active_100ms = ui->checkBox_100ms_delay->isChecked();
|
||||
alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked();
|
||||
alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked();
|
||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
||||
QJsonObject filter_obj,variables_obj;
|
||||
QJsonArray filter_array;
|
||||
for(int i = 0; i < 3; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",filter[i].type);
|
||||
temp_obj.insert("low",filter[i].low);
|
||||
temp_obj.insert("high",filter[i].high);
|
||||
temp_obj.insert("checked",filter[i].checked);
|
||||
filter_array.append(temp_obj);
|
||||
}
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 6; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",variables[i].type);
|
||||
if(variables[i].type == "direct"){
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}else if(variables[i].type == "gap"){
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||
}else if(variables[i].type == "not_1x_ampl" || variables[i].type == "smax_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}
|
||||
variables_array.append(temp_obj);
|
||||
}
|
||||
variables_obj.insert("variables",variables_array);
|
||||
QJsonObject delay_obj;
|
||||
delay_obj.insert("alert",delay.alert);
|
||||
delay_obj.insert("danger",delay.danger);
|
||||
delay_obj.insert("100ms",delay.active_100ms);
|
||||
variables_obj.insert("delay",delay_obj);
|
||||
variables_obj.insert("alert_latching",alert_variables.alert_latching);
|
||||
variables_obj.insert("danger_latching",alert_variables.danger_latching);
|
||||
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
||||
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
||||
variables_obj.insert("trip_multiply",alert_variables.trip_multiply);
|
||||
variables_obj.insert("comparision",alert_variables.comparision);
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("id",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
QFile file_filter(filePath_filter);
|
||||
QFile file_variables(filePath_variables);
|
||||
if (!file_filter.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath_filter;
|
||||
return;
|
||||
}
|
||||
if (!file_variables.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath_variables;
|
||||
return;
|
||||
}
|
||||
QJsonDocument jsonDoc_filter(filter_obj);
|
||||
QJsonDocument jsonDoc_variables(variables_obj);
|
||||
file_filter.write(jsonDoc_filter.toJson());
|
||||
file_variables.write(jsonDoc_variables.toJson());
|
||||
file_filter.close();
|
||||
file_variables.close();
|
||||
}
|
||||
|
||||
|
||||
void Radial_vibration::on_pushButton_set_default_clicked()
|
||||
{
|
||||
void Radial::on_checkBox_1x_ampl_toggled(bool checked) {
|
||||
|
||||
}
|
||||
|
||||
void Radial::on_checkBox_2x_ampl_toggled(bool checked) {
|
||||
|
||||
}
|
||||
|
||||
void Radial::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Radial::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if (ptr->base_config_[channel - 1].channel_type != kVibRadial) {
|
||||
qDebug() << "[Radial::Init] channel type changes";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "[Radial::Init] no channel ptr";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RadialVariable> variable_ptr = std::dynamic_pointer_cast<RadialVariable>(variable_base);
|
||||
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
|
||||
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
|
||||
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
|
||||
// processed output
|
||||
// -general
|
||||
if(variable_ptr->general.output_used)
|
||||
ui->comboBox_output_used->setCurrentIndex(0);
|
||||
else
|
||||
ui->comboBox_output_used->setCurrentIndex(1);
|
||||
ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit);
|
||||
ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function);
|
||||
// -alarm
|
||||
ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level));
|
||||
ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis));
|
||||
ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay));
|
||||
ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable);
|
||||
ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch);
|
||||
|
||||
ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level));
|
||||
ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis));
|
||||
ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay));
|
||||
ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable);
|
||||
ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch);
|
||||
|
||||
ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level));
|
||||
ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis));
|
||||
ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay));
|
||||
ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable);
|
||||
ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch);
|
||||
|
||||
ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level));
|
||||
ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis));
|
||||
ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay));
|
||||
ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable);
|
||||
ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch);
|
||||
|
||||
// Gap
|
||||
// -general
|
||||
if(variable_ptr->gap_general.output_used)
|
||||
ui->comboBox_output_used_2->setCurrentIndex(0);
|
||||
else
|
||||
ui->comboBox_output_used_2->setCurrentIndex(1);
|
||||
ui->comboBox_engineering_unit_2->setCurrentIndex(variable_ptr->general.engineering_unit);
|
||||
ui->comboBox_rectifier_funtion_2->setCurrentIndex(variable_ptr->general.rectifier_function);
|
||||
// -alarm
|
||||
ui->lineEdit_danger_high_level_2->setText(QString::number(variable_ptr->gap_danger_high.level));
|
||||
ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_high.hysteresis));
|
||||
ui->lineEdit_danger_high_delay_2->setText(QString::number(variable_ptr->gap_danger_high.delay));
|
||||
ui->checkBox_danger_high_enable_2->setChecked(variable_ptr->gap_danger_high.enable);
|
||||
ui->checkBox_danger_high_latch_2->setChecked(variable_ptr->gap_danger_high.latch);
|
||||
|
||||
ui->lineEdit_alert_high_level_2->setText(QString::number(variable_ptr->gap_alert_high.level));
|
||||
ui->lineEdit_alert_high_hysteresis_2->setText(QString::number(variable_ptr->gap_alert_high.hysteresis));
|
||||
ui->lineEdit_alert_high_delay_2->setText(QString::number(variable_ptr->gap_alert_high.delay));
|
||||
ui->checkBox_alert_high_enable_2->setChecked(variable_ptr->gap_alert_high.enable);
|
||||
ui->checkBox_alert_high_latch_2->setChecked(variable_ptr->gap_alert_high.latch);
|
||||
|
||||
ui->lineEdit_danger_low_level_2->setText(QString::number(variable_ptr->gap_danger_low.level));
|
||||
ui->lineEdit_danger_low_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_low.hysteresis));
|
||||
ui->lineEdit_danger_low_delay_2->setText(QString::number(variable_ptr->gap_danger_low.delay));
|
||||
ui->checkBox_danger_low_enable_2->setChecked(variable_ptr->gap_danger_low.enable);
|
||||
ui->checkBox_danger_low_latch_2->setChecked(variable_ptr->gap_danger_low.latch);
|
||||
|
||||
ui->lineEdit_alert_low_level_2->setText(QString::number(variable_ptr->gap_alert_low.level));
|
||||
ui->lineEdit_alert_low_hysteresis_2->setText(QString::number(variable_ptr->gap_alert_low.hysteresis));
|
||||
ui->lineEdit_alert_low_delay_2->setText(QString::number(variable_ptr->gap_alert_low.delay));
|
||||
ui->checkBox_alert_low_enable_2->setChecked(variable_ptr->gap_alert_low.enable);
|
||||
ui->checkBox_alert_low_latch_2->setChecked(variable_ptr->gap_alert_low.latch);
|
||||
}
|
||||
|
||||
void Radial::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Radial::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
||||
QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
ptr->base_config_[channel - 1].channel_type = kVibRadial;
|
||||
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
std::shared_ptr<RadialVariable> variable = std::dynamic_pointer_cast<RadialVariable>(variable_base);
|
||||
|
||||
if (variable_base == nullptr || variable_base->type_ != kVibRadial || variable == nullptr) {
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "no channel ptr";
|
||||
} else {
|
||||
ptr->RemoveChannel(channel);
|
||||
qDebug() << "channel type change";
|
||||
}
|
||||
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
|
||||
variable->id_ = channel;
|
||||
variable->type_ = kVibRadial;
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
// processed output
|
||||
// -general
|
||||
if(ui->comboBox_output_used->currentIndex() == 0)
|
||||
variable->general.output_used = true;
|
||||
else
|
||||
variable->general.output_used = false;
|
||||
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
||||
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
||||
// -alarm
|
||||
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
||||
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||||
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||||
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
||||
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
||||
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
||||
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||||
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||||
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
||||
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
||||
// variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
||||
// variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
||||
// variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
||||
// variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
||||
// variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
||||
// variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
||||
// variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
||||
// variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
||||
// variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
||||
// variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
||||
// Gap
|
||||
// -general
|
||||
if(ui->comboBox_output_used_2->currentIndex() == 0)
|
||||
variable->gap_general.output_used = true;
|
||||
else
|
||||
variable->gap_general.output_used = false;
|
||||
variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentIndex();
|
||||
variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentIndex();
|
||||
// -alarm
|
||||
variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble();
|
||||
variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble();
|
||||
variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay_2->text().toDouble();
|
||||
variable->gap_danger_high.enable = ui->checkBox_danger_high_enable_2->isChecked();
|
||||
variable->gap_danger_high.latch = ui->checkBox_danger_high_latch_2->isChecked();
|
||||
variable->gap_alert_high.level = ui->lineEdit_alert_high_level_2->text().toDouble();
|
||||
variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble();
|
||||
variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay_2->text().toDouble();
|
||||
variable->gap_alert_high.enable = ui->checkBox_alert_high_enable_2->isChecked();
|
||||
variable->gap_alert_high.latch = ui->checkBox_alert_high_latch_2->isChecked();
|
||||
// variable->gap_danger_low.level = ui->lineEdit_danger_low_level_2->text().toDouble();
|
||||
// variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble();
|
||||
// variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay_2->text().toDouble();
|
||||
// variable->gap_danger_low.enable = ui->checkBox_danger_low_enable_2->isChecked();
|
||||
// variable->gap_danger_low.latch = ui->checkBox_danger_low_latch_2->isChecked();
|
||||
// variable->gap_alert_low.level = ui->lineEdit_alert_low_level_2->text().toDouble();
|
||||
// variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble();
|
||||
// variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay_2->text().toDouble();
|
||||
// variable->gap_alert_low.enable = ui->checkBox_alert_low_enable_2->isChecked();
|
||||
// variable->gap_alert_low.latch = ui->checkBox_alert_low_latch_2->isChecked();
|
||||
// add to ptr
|
||||
ptr->variables_.push_back(variable);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
// processed output
|
||||
// -general
|
||||
if(ui->comboBox_output_used->currentIndex() == 0)
|
||||
variable->general.output_used = true;
|
||||
else
|
||||
variable->general.output_used = false;
|
||||
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
||||
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
||||
// -alarm
|
||||
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
||||
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||||
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||||
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
||||
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
||||
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
||||
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||||
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||||
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
||||
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
||||
// variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
||||
// variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
||||
// variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
||||
// variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
||||
// variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
||||
// variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
||||
// variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
||||
// variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
||||
// variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
||||
// variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
||||
// Gap
|
||||
// -general
|
||||
if(ui->comboBox_output_used_2->currentIndex() == 0)
|
||||
variable->gap_general.output_used = true;
|
||||
else
|
||||
variable->gap_general.output_used = false;
|
||||
variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentIndex();
|
||||
variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentIndex();
|
||||
// -alarm
|
||||
variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble();
|
||||
variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble();
|
||||
variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay_2->text().toDouble();
|
||||
variable->gap_danger_high.enable = ui->checkBox_danger_high_enable_2->isChecked();
|
||||
variable->gap_danger_high.latch = ui->checkBox_danger_high_latch_2->isChecked();
|
||||
variable->gap_alert_high.level = ui->lineEdit_alert_high_level_2->text().toDouble();
|
||||
variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble();
|
||||
variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay_2->text().toDouble();
|
||||
variable->gap_alert_high.enable = ui->checkBox_alert_high_enable_2->isChecked();
|
||||
variable->gap_alert_high.latch = ui->checkBox_alert_high_latch_2->isChecked();
|
||||
// variable->gap_danger_low.level = ui->lineEdit_danger_low_level_2->text().toDouble();
|
||||
// variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble();
|
||||
// variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay_2->text().toDouble();
|
||||
// variable->gap_danger_low.enable = ui->checkBox_danger_low_enable_2->isChecked();
|
||||
// variable->gap_danger_low.latch = ui->checkBox_danger_low_latch_2->isChecked();
|
||||
// variable->gap_alert_low.level = ui->lineEdit_alert_low_level_2->text().toDouble();
|
||||
// variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble();
|
||||
// variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay_2->text().toDouble();
|
||||
// variable->gap_alert_low.enable = ui->checkBox_alert_low_enable_2->isChecked();
|
||||
// variable->gap_alert_low.latch = ui->checkBox_alert_low_latch_2->isChecked();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Radial::on_pushButton_set_default_clicked() {
|
||||
}
|
||||
|
||||
|
||||
void Radial::on_lineEdit_alert_high_level_editingFinished()
|
||||
{
|
||||
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
||||
ui->lineEdit_danger_high_level->setText(ui->lineEdit_alert_high_level->text());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,28 +7,26 @@ namespace Ui {
|
||||
class Radial_vibration;
|
||||
}
|
||||
|
||||
class Radial_vibration : public QWidget
|
||||
{
|
||||
class Radial : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Radial_vibration(int slot_no_,int channel_,bool active,QWidget *parent = nullptr);
|
||||
~Radial_vibration();
|
||||
public:
|
||||
explicit Radial(int slot_no_, int channel_, bool active, QWidget *parent = nullptr);
|
||||
~Radial();
|
||||
int slot_no;
|
||||
int channel;
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_pushButton_set_default_clicked();
|
||||
|
||||
void on_checkBox_1x_ampl_toggled(bool checked);
|
||||
void on_checkBox_2x_ampl_toggled(bool checked);
|
||||
void on_lineEdit_alert_high_level_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::Radial_vibration *ui;
|
||||
|
||||
Filter filter[3];
|
||||
Dealy delay;
|
||||
Variables variables[6];
|
||||
Alert_Variables alert_variables;
|
||||
void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
1925
radial_vibration.ui
1925
radial_vibration.ui
File diff suppressed because it is too large
Load Diff
171
rangeslider.cpp
Normal file
171
rangeslider.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
#include "rangeslider.h"
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
RangeSlider::RangeSlider(int style_,QWidget *parent)
|
||||
: QWidget(parent) {
|
||||
setMinimumSize(20, 240);
|
||||
style = style_;
|
||||
}
|
||||
|
||||
void RangeSlider::setRange(float min, float max) {
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_lower = qBound(m_min, m_lower, m_max);
|
||||
m_upper = qBound(m_lower, m_upper, m_max);
|
||||
update();
|
||||
}
|
||||
|
||||
void RangeSlider::setSliderWidth(int width) {
|
||||
sliderWidth = width;
|
||||
update(); // 更新界面
|
||||
}
|
||||
|
||||
float RangeSlider::lowerValue() const { return m_lower; }
|
||||
float RangeSlider::upperValue() const { return m_upper; }
|
||||
|
||||
float RangeSlider::valueToY(float value) const {
|
||||
double ratio = (value - m_min) / double(m_max - m_min);
|
||||
return height() - handleRadius - ratio * (height() - 2 * handleRadius);
|
||||
}
|
||||
|
||||
float RangeSlider::yToValue(float y) const {
|
||||
double ratio = (height() - handleRadius - y) / double(height() - 2 * handleRadius);
|
||||
ratio = qBound(0.0, ratio, 1.0);
|
||||
float rawValue = m_min + ratio * (m_max - m_min);
|
||||
float steppedValue = qRound(rawValue * 10) / 10.0f;
|
||||
return qBound(m_min, steppedValue, m_max);
|
||||
}
|
||||
|
||||
RangeSlider::HandleType RangeSlider::handleHitTest(float y) const {
|
||||
int yLower = valueToY(m_lower);
|
||||
int yUpper = valueToY(m_upper);
|
||||
if (qAbs(y - yLower) <= handleRadius + 2) return LowerHandle;
|
||||
if (qAbs(y - yUpper) <= handleRadius + 2) return UpperHandle;
|
||||
return NoHandle;
|
||||
}
|
||||
|
||||
void RangeSlider::mousePressEvent(QMouseEvent *event) {
|
||||
currentHandle = handleHitTest(event->pos().y());
|
||||
}
|
||||
|
||||
void RangeSlider::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (currentHandle == NoHandle) return;
|
||||
|
||||
float val = yToValue(event->pos().y());
|
||||
if (currentHandle == LowerHandle) {
|
||||
m_lower = qBound(m_min, val, m_upper);
|
||||
} else if (currentHandle == UpperHandle) {
|
||||
m_upper = qBound(m_lower, val, m_max);
|
||||
}
|
||||
update();
|
||||
emit rangeChanged(m_lower, m_upper);
|
||||
}
|
||||
|
||||
void RangeSlider::mouseReleaseEvent(QMouseEvent *) {
|
||||
currentHandle = NoHandle;
|
||||
}
|
||||
|
||||
void RangeSlider::paintEvent(QPaintEvent *) {
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int x = width() / 2;
|
||||
int yLower = valueToY(m_lower);
|
||||
int yUpper = valueToY(m_upper);
|
||||
|
||||
// Draw Temperature-style background (gradient)
|
||||
drawTemperatureStyle(&p);
|
||||
|
||||
// Draw selected range (green)
|
||||
// Draw selected range (green)
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(Qt::green);
|
||||
p.drawRect(x - sliderWidth / 2, yUpper, sliderWidth, yLower - yUpper);
|
||||
|
||||
// Draw simple black handles (lines)
|
||||
p.setPen(QPen(Qt::black, 2));
|
||||
p.drawLine(x - sliderWidth / 2, yLower, x + sliderWidth, yLower);
|
||||
p.drawLine(x - sliderWidth / 2, yUpper, x + sliderWidth, yUpper);
|
||||
|
||||
// Draw ticks
|
||||
drawTicks(&p);
|
||||
}
|
||||
void RangeSlider::setLowerValue(float val) {
|
||||
m_lower = qBound(m_min, val, m_upper);
|
||||
update();
|
||||
emit rangeChanged(m_lower, m_upper);
|
||||
}
|
||||
|
||||
void RangeSlider::setUpperValue(float val) {
|
||||
m_upper = qBound(m_lower, val, m_max);
|
||||
update();
|
||||
emit rangeChanged(m_lower, m_upper);
|
||||
}
|
||||
void RangeSlider::drawTemperatureStyle(QPainter *p) {
|
||||
int x = width() / 2;
|
||||
int yTop = handleRadius;
|
||||
int yBottom = height() - handleRadius;
|
||||
|
||||
// Draw border (black)
|
||||
p->setPen(Qt::black);
|
||||
p->setBrush(Qt::NoBrush);
|
||||
p->drawRect(x - sliderWidth / 2, yTop, sliderWidth, yBottom - yTop);
|
||||
|
||||
// Draw yellow outside the range
|
||||
if(style != 0){
|
||||
p->setBrush(Qt::red);
|
||||
p->drawRect(x - sliderWidth / 2, yTop, sliderWidth, valueToY(m_lower) - yTop); // Above lower range
|
||||
p->drawRect(x - sliderWidth / 2, valueToY(m_upper), sliderWidth, yBottom - valueToY(m_upper)); // Below upper range
|
||||
}else{
|
||||
p->setBrush(Qt::yellow);
|
||||
p->drawRect(x - sliderWidth / 2, yTop, sliderWidth, valueToY(m_lower) - yTop); // Above lower range
|
||||
p->drawRect(x - sliderWidth / 2, valueToY(m_upper), sliderWidth, yBottom - valueToY(m_upper)); // Below upper range
|
||||
}
|
||||
|
||||
// Draw green inside the range
|
||||
p->setBrush(Qt::green);
|
||||
p->drawRect(x - sliderWidth / 2, valueToY(m_upper), sliderWidth, valueToY(m_lower) - valueToY(m_upper)); // Green area
|
||||
}
|
||||
int RangeSlider::niceStep(int range, int maxLabels) {
|
||||
double rawStep = static_cast<double>(range) / maxLabels;
|
||||
|
||||
// 取一个"好看"的步长
|
||||
double magnitude = pow(10, floor(log10(rawStep))); // 10 的整数次幂
|
||||
double residual = rawStep / magnitude;
|
||||
|
||||
double niceResidual;
|
||||
if (residual < 1.5)
|
||||
niceResidual = 1;
|
||||
else if (residual < 3)
|
||||
niceResidual = 2;
|
||||
else if (residual < 7)
|
||||
niceResidual = 5;
|
||||
else
|
||||
niceResidual = 10;
|
||||
|
||||
return static_cast<int>(niceResidual * magnitude);
|
||||
}
|
||||
void RangeSlider::drawTicks(QPainter *p) {
|
||||
int range = m_max - m_min;
|
||||
int labelStep = niceStep(range, 10);
|
||||
int minorStep = qMax(1, labelStep / 5);
|
||||
|
||||
int x = width() / 2 + handleRadius + 4;
|
||||
p->setFont(QFont("Arial", 8));
|
||||
|
||||
for (int val = m_min; val <= m_max; val += minorStep) {
|
||||
int y = valueToY(val);
|
||||
|
||||
if (val % labelStep == 0) {
|
||||
p->setPen(QPen(Qt::black, 1.5)); // 主刻度
|
||||
p->drawLine(x, y, x + 6, y);
|
||||
p->drawText(x + 10, y + 4, QString::number(val));
|
||||
} else {
|
||||
p->setPen(QPen(Qt::gray, 1)); // 次刻度
|
||||
p->drawLine(x, y, x + 3, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
rangeslider.h
Normal file
48
rangeslider.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef RANGESLIDER_H
|
||||
#define RANGESLIDER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class RangeSlider : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RangeSlider(int style_ = 0,QWidget *parent = nullptr);
|
||||
|
||||
void setRange(float min, float max);
|
||||
void setSliderWidth(int width); // 新增方法:设置宽度
|
||||
float lowerValue() const;
|
||||
float upperValue() const;
|
||||
void setLowerValue(float val);
|
||||
void setUpperValue(float val);
|
||||
float m_lower = 3.5;
|
||||
float m_upper = 6.5;
|
||||
int style = 0;
|
||||
signals:
|
||||
void rangeChanged(float lower, float upper);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseMoveEvent(QMouseEvent *) override;
|
||||
void mouseReleaseEvent(QMouseEvent *) override;
|
||||
|
||||
private:
|
||||
float m_min = 0;
|
||||
float m_max = 10;
|
||||
|
||||
int sliderWidth = 10; // 默认宽度(可以根据需求调整)
|
||||
|
||||
int handleRadius = 8;
|
||||
enum HandleType { NoHandle, LowerHandle, UpperHandle };
|
||||
HandleType currentHandle = NoHandle;
|
||||
|
||||
float valueToY(float value) const;
|
||||
float yToValue(float y) const;
|
||||
HandleType handleHitTest(float y) const;
|
||||
int niceStep(int range, int maxLabels);
|
||||
void drawTicks(QPainter *p);
|
||||
void drawTemperatureStyle(QPainter *p);
|
||||
};
|
||||
|
||||
#endif // RANGESLIDER_H
|
||||
200
relaysetting.cpp
200
relaysetting.cpp
@ -10,16 +10,12 @@
|
||||
|
||||
RelaySetting::RelaySetting(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::RelaySetting)
|
||||
{
|
||||
, ui(new Ui::RelaySetting) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
readJsonFile(QCoreApplication::applicationDirPath() + "\\config\\main.json");
|
||||
|
||||
for (int var = 0; var < map_slot_config.size(); ++var) {
|
||||
if(map_slot_config[var].slot_type == 30){
|
||||
ui->comboBox_slot->addItem(QString::number(map_slot_config[var].slot));
|
||||
}
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
for (int var = 0; var < SLOT_NUM; ++var) {
|
||||
ui->comboBox_slot->addItem(QString::number(var + 1));
|
||||
}
|
||||
connect(ui->buttonGroup_OK, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||
this, &RelaySetting::onRadioButtonClicked);
|
||||
@ -62,14 +58,34 @@ RelaySetting::RelaySetting(QWidget *parent)
|
||||
connect(ui->buttonGroup_STATUS, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||
this, &RelaySetting::onRadioButtonClicked);
|
||||
|
||||
m_tcpClient = MyTcpClient::instance();
|
||||
connect(m_tcpClient, SIGNAL(dataReceived(const QByteArray &)), this, SLOT(readData(const QByteArray &)));
|
||||
}
|
||||
void RelaySetting::readData(const QByteArray &data) {
|
||||
qDebug() << "Received from server:" << data;
|
||||
|
||||
RelaySetting::~RelaySetting()
|
||||
{
|
||||
uint8_t cmd = data[3];
|
||||
if (cmd == kRelaySetting) {
|
||||
RelaySettingRsp relay_setting_rsp;
|
||||
memcpy(&relay_setting_rsp, data.data(), sizeof(RelaySettingRsp));
|
||||
qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code ;
|
||||
}else if(cmd == kRelayStatus){
|
||||
RelayStatusRsp relay_status_rsp;
|
||||
memcpy(&relay_status_rsp, data.data(), sizeof(RelayStatusRsp));
|
||||
qDebug() << "relay_setting_rsp status" << relay_status_rsp.status ;
|
||||
if (relay_status_rsp.status == 7) {
|
||||
ui->label_status->setText("测试");
|
||||
} else if (relay_status_rsp.status == 8) {
|
||||
ui->label_status->setText("手动");
|
||||
} else if (relay_status_rsp.status == 9) {
|
||||
ui->label_status->setText("工作");
|
||||
}
|
||||
}
|
||||
}
|
||||
RelaySetting::~RelaySetting() {
|
||||
delete ui;
|
||||
}
|
||||
void RelaySetting::readJsonFile(const QString &filePath)
|
||||
{
|
||||
void RelaySetting::readJsonFile(const QString &filePath) {
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
@ -78,9 +94,7 @@ void RelaySetting::readJsonFile(const QString &filePath)
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
@ -98,19 +112,17 @@ void RelaySetting::readJsonFile(const QString &filePath)
|
||||
QJsonObject obj = value.toObject();
|
||||
slot_config.slot = obj["slot"].toInt();
|
||||
slot_config.slot_type = obj["slot_type"].toInt();
|
||||
slot_config.chan_display = obj["chan_display"].toString();
|
||||
slot_config.rack_type = obj["rack_type"].toString();
|
||||
map_slot_config.insert(slot_id,slot_config);
|
||||
map_slot_config.insert(slot_id, slot_config);
|
||||
slot_id ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RelaySetting::onRadioButtonClicked(QAbstractButton *button)
|
||||
{
|
||||
void RelaySetting::onRadioButtonClicked(QAbstractButton *button) {
|
||||
QButtonGroup *group = qobject_cast<QButtonGroup *>(sender());
|
||||
if (!group || !button) return;
|
||||
|
||||
if (!group || !button) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "Group:" << group << ", Selected button text:" << button->text();
|
||||
QTcpSocket socket;
|
||||
// 连接到服务器
|
||||
@ -119,104 +131,74 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button)
|
||||
qDebug() << "Connection failed!";
|
||||
return;
|
||||
}
|
||||
PackageHead header = { {0xAA, 0x55, 0xAA}, kRelaySetting, sizeof(RelaySettingReq),0,{} };
|
||||
|
||||
RelaySettingReq relay_setting_req = { {0xAA, 0x55, 0xAA}, kRelaySetting,1, 0, 0, 0 };
|
||||
int slot = ui->comboBox_slot->currentText().toInt();
|
||||
qDebug() << "slot" << slot <<endl;
|
||||
RelaySettingReq relay_setting_req;
|
||||
if(slot == 0)
|
||||
qDebug() << "slot" << slot ;
|
||||
if (slot == 0) {
|
||||
relay_setting_req.card_id = 0xFF;
|
||||
else
|
||||
} else {
|
||||
relay_setting_req.card_id = slot & 0xFF;
|
||||
QString led_id = group->objectName().mid(12);
|
||||
qDebug() << "led_id" << led_id <<endl;
|
||||
if(led_id == "OK")
|
||||
relay_setting_req.led_id = 0xff;
|
||||
else if(led_id == "TX_RX")
|
||||
relay_setting_req.led_id = 0xf1;
|
||||
else if(led_id == "TEST")
|
||||
relay_setting_req.led_id = 0xee;
|
||||
else if(led_id == "STATUS")
|
||||
relay_setting_req.led_id = 0xe1;
|
||||
else
|
||||
relay_setting_req.led_id = led_id.toInt() & 0xFF;
|
||||
|
||||
if(button->text() == "OFF")
|
||||
relay_setting_req.led_operate = 0;
|
||||
else if(button->text() == "ON")
|
||||
relay_setting_req.led_operate = 1;
|
||||
else if(button->text() == "红色")
|
||||
relay_setting_req.led_operate = 2;
|
||||
else if(button->text() == "绿色")
|
||||
relay_setting_req.led_operate = 3;
|
||||
else if(button->text() == "红色1Hz闪烁" || button->text() == "红色闪烁")
|
||||
relay_setting_req.led_operate = 4;
|
||||
else if(button->text() == "红色2Hz闪烁")
|
||||
relay_setting_req.led_operate = 5;
|
||||
else if(button->text() == "绿色闪烁")
|
||||
relay_setting_req.led_operate = 6;
|
||||
else if(button->text() == "测试")
|
||||
relay_setting_req.led_operate = 7;
|
||||
else if(button->text() == "手动")
|
||||
relay_setting_req.led_operate = 8;
|
||||
else if(button->text() == "工作")
|
||||
relay_setting_req.led_operate = 9;
|
||||
qDebug() << "relay_setting_req.led_operate " << relay_setting_req.led_operate;
|
||||
char send_buf[20] ={0};
|
||||
memcpy(send_buf, (char*)&header, sizeof(PackageHead));
|
||||
memcpy(send_buf + sizeof(PackageHead), (char*)&relay_setting_req, sizeof(RelaySettingReq));
|
||||
int length = sizeof(PackageHead) + sizeof(RelaySettingReq);
|
||||
qint64 bytesWritten = socket.write(send_buf, length);
|
||||
qDebug() << "Server response: " << bytesWritten;
|
||||
if (socket.waitForReadyRead()) {
|
||||
QByteArray response = socket.readAll();
|
||||
PackageHead header;
|
||||
RelaySettingRsp relay_setting_rsp;
|
||||
memcpy(&header,response.data(),sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len << endl;
|
||||
memcpy(&relay_setting_rsp,response.data() + sizeof(PackageHead),sizeof(RelaySettingRsp));
|
||||
qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code << endl;
|
||||
}
|
||||
QString led_id = group->objectName().mid(12);
|
||||
qDebug() << "led_id" << led_id ;
|
||||
if (led_id == "OK") {
|
||||
relay_setting_req.led_id = 0xff;
|
||||
} else if (led_id == "TX_RX") {
|
||||
relay_setting_req.led_id = 0xf1;
|
||||
} else if (led_id == "TEST") {
|
||||
relay_setting_req.led_id = 0xee;
|
||||
} else if (led_id == "STATUS") {
|
||||
relay_setting_req.led_id = 0xe1;
|
||||
} else {
|
||||
relay_setting_req.led_id = led_id.toInt() & 0xFF;
|
||||
}
|
||||
if (button->text() == "OFF") {
|
||||
relay_setting_req.led_operate = 0;
|
||||
} else if (button->text() == "ON") {
|
||||
relay_setting_req.led_operate = 1;
|
||||
} else if (button->text() == "红色") {
|
||||
relay_setting_req.led_operate = 2;
|
||||
} else if (button->text() == "绿色") {
|
||||
relay_setting_req.led_operate = 3;
|
||||
} else if (button->text() == "红色1Hz闪烁" || button->text() == "红色闪烁") {
|
||||
relay_setting_req.led_operate = 4;
|
||||
} else if (button->text() == "红色2Hz闪烁") {
|
||||
relay_setting_req.led_operate = 5;
|
||||
} else if (button->text() == "绿色闪烁") {
|
||||
relay_setting_req.led_operate = 6;
|
||||
} else if (button->text() == "测试") {
|
||||
relay_setting_req.led_operate = 7;
|
||||
} else if (button->text() == "手动") {
|
||||
relay_setting_req.led_operate = 8;
|
||||
} else if (button->text() == "工作") {
|
||||
relay_setting_req.led_operate = 9;
|
||||
}
|
||||
qDebug() << "relay_setting_req.led_operate " << relay_setting_req.led_operate;
|
||||
char send_buf[20] = {0};
|
||||
memcpy(send_buf, (char *)&relay_setting_req, sizeof(RelaySettingReq));
|
||||
int length = sizeof(RelaySettingReq) + sizeof(RelaySettingReq);
|
||||
qint64 bytesWritten = m_tcpClient->sendData((char*)&send_buf, length);
|
||||
m_tcpClient->waitForRead();
|
||||
qDebug() << "Server response: " << bytesWritten;
|
||||
|
||||
}
|
||||
|
||||
void RelaySetting::on_pushButton_status_clicked()
|
||||
{
|
||||
QTcpSocket socket;
|
||||
// 连接到服务器
|
||||
socket.connectToHost(g_strServerIp, 10000);
|
||||
if (!socket.waitForConnected()) {
|
||||
qDebug() << "Connection failed!";
|
||||
return;
|
||||
}
|
||||
PackageHead header = { {0xAA, 0x55, 0xAA}, kRelayStatus, sizeof(RelaySettingReq),0,{} };
|
||||
void RelaySetting::on_pushButton_status_clicked() {
|
||||
|
||||
int slot = ui->comboBox_slot->currentText().toInt();
|
||||
qDebug() << "slot" << slot <<endl;
|
||||
RelayStatusReq relay_status_req;
|
||||
if(slot == 0)
|
||||
qDebug() << "slot" << slot ;
|
||||
RelayStatusReq relay_status_req { {0xAA, 0x55, 0xAA}, kRelayStatus, 1, 0 };
|
||||
if (slot == 0) {
|
||||
relay_status_req.card_id = 0xFF;
|
||||
else
|
||||
} else {
|
||||
relay_status_req.card_id = slot & 0xFF;
|
||||
char send_buf[20] ={0};
|
||||
memcpy(send_buf, (char*)&header, sizeof(PackageHead));
|
||||
memcpy(send_buf + sizeof(PackageHead), (char*)&relay_status_req, sizeof(RelayStatusReq));
|
||||
int length = sizeof(PackageHead) + sizeof(RelayStatusReq);
|
||||
qint64 bytesWritten = socket.write(send_buf, length);
|
||||
qDebug() << "Server response: " << bytesWritten;
|
||||
if (socket.waitForReadyRead()) {
|
||||
QByteArray response = socket.readAll();
|
||||
PackageHead header;
|
||||
RelayStatusRsp relay_status_rsp;
|
||||
memcpy(&header,response.data(),sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len << endl;
|
||||
memcpy(&relay_status_rsp,response.data() + sizeof(PackageHead),sizeof(RelayStatusRsp));
|
||||
qDebug() << "relay_setting_rsp status" << relay_status_rsp.status << endl;
|
||||
if(relay_status_rsp.status == 7)
|
||||
ui->label_status->setText("测试");
|
||||
else if(relay_status_rsp.status == 8)
|
||||
ui->label_status->setText("手动");
|
||||
else if(relay_status_rsp.status == 9)
|
||||
ui->label_status->setText("工作");
|
||||
}
|
||||
char send_buf[20] = {0};
|
||||
memcpy(send_buf, (char *)&relay_status_req, sizeof(RelayStatusReq));
|
||||
int length = sizeof(RelayStatusReq);
|
||||
qint64 bytesWritten = m_tcpClient->sendData((char*)&send_buf, length);
|
||||
m_tcpClient->waitForRead();
|
||||
qDebug() << "Server response: " << bytesWritten;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
#include "MyTcpClient.h"
|
||||
|
||||
namespace Ui {
|
||||
class RelaySetting;
|
||||
@ -20,10 +21,11 @@ private slots:
|
||||
void onRadioButtonClicked(QAbstractButton *button);
|
||||
|
||||
void on_pushButton_status_clicked();
|
||||
|
||||
void readData(const QByteArray&);
|
||||
private:
|
||||
Ui::RelaySetting *ui;
|
||||
QMap<int,SlotConfig> map_slot_config;
|
||||
MyTcpClient* m_tcpClient;
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
};
|
||||
|
||||
@ -1024,17 +1024,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>绿色闪烁</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_TX_RX</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>绿色</string>
|
||||
<string>黄绿色闪烁</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_TX_RX</string>
|
||||
@ -1168,7 +1158,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="text">
|
||||
<string>绿色</string>
|
||||
<string>黄绿</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_OK</string>
|
||||
@ -1328,24 +1318,24 @@
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup_16"/>
|
||||
<buttongroup name="buttonGroup_12"/>
|
||||
<buttongroup name="buttonGroup_TX_RX"/>
|
||||
<buttongroup name="buttonGroup_OK"/>
|
||||
<buttongroup name="buttonGroup_9"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup_8"/>
|
||||
<buttongroup name="buttonGroup_TEST"/>
|
||||
<buttongroup name="buttonGroup_1"/>
|
||||
<buttongroup name="buttonGroup_3"/>
|
||||
<buttongroup name="buttonGroup_6"/>
|
||||
<buttongroup name="buttonGroup_4"/>
|
||||
<buttongroup name="buttonGroup_7"/>
|
||||
<buttongroup name="buttonGroup_10"/>
|
||||
<buttongroup name="buttonGroup_14"/>
|
||||
<buttongroup name="buttonGroup_11"/>
|
||||
<buttongroup name="buttonGroup_5"/>
|
||||
<buttongroup name="buttonGroup_STATUS"/>
|
||||
<buttongroup name="buttonGroup_8"/>
|
||||
<buttongroup name="buttonGroup_6"/>
|
||||
<buttongroup name="buttonGroup_15"/>
|
||||
<buttongroup name="buttonGroup_OK"/>
|
||||
<buttongroup name="buttonGroup_7"/>
|
||||
<buttongroup name="buttonGroup_11"/>
|
||||
<buttongroup name="buttonGroup_3"/>
|
||||
<buttongroup name="buttonGroup_4"/>
|
||||
<buttongroup name="buttonGroup_TX_RX"/>
|
||||
<buttongroup name="buttonGroup_5"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup_TEST"/>
|
||||
<buttongroup name="buttonGroup_9"/>
|
||||
<buttongroup name="buttonGroup_12"/>
|
||||
<buttongroup name="buttonGroup_10"/>
|
||||
<buttongroup name="buttonGroup_13"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
@ -9,288 +9,496 @@
|
||||
#include "acceleration.h"
|
||||
#include "velocity.h"
|
||||
#include "radial_vibration.h"
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "trust.h"
|
||||
#include <QMessageBox>
|
||||
#include "pressure_pulsation.h"
|
||||
|
||||
Seismic_monitor::Seismic_monitor(int slot,QWidget *parent) :
|
||||
Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Seismic_monitor)
|
||||
{
|
||||
ui(new Ui::Seismic_monitor) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
ui->comboBox_chan_type_1->setView(new QListView());
|
||||
ui->comboBox_chan_type_2->setView(new QListView());
|
||||
ui->comboBox_chan_type_3->setView(new QListView());
|
||||
ui->comboBox_chan_type_4->setView(new QListView());
|
||||
|
||||
slot_no = slot;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
QString slot_no_ = QString("%1").arg(slot_no);
|
||||
ui->label_slot_no->setText(slot_no_);
|
||||
|
||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
||||
readJsonFile(filePath);
|
||||
ui->checkBox_standby_1->hide();
|
||||
ui->checkBox_standby_2->hide();
|
||||
Init();
|
||||
}
|
||||
|
||||
Seismic_monitor::~Seismic_monitor()
|
||||
{
|
||||
Seismic_monitor::~Seismic_monitor() {
|
||||
delete ui;
|
||||
}
|
||||
void Seismic_monitor::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
|
||||
void Seismic_monitor::Init() {
|
||||
// for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||
// ui->comboBox_transducer_name_1->addItem(vec_transducer[var].transducer_name);
|
||||
// ui->comboBox_transducer_name_2->addItem(vec_transducer[var].transducer_name);
|
||||
// ui->comboBox_transducer_name_3->addItem(vec_transducer[var].transducer_name);
|
||||
// ui->comboBox_transducer_name_4->addItem(vec_transducer[var].transducer_name);
|
||||
// }
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qDebug() << "base_ptr";
|
||||
// do nothing or use template to init it.
|
||||
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||
vib_data->slot_ = slot_no;
|
||||
vib_data->card_type_ = car_type;
|
||||
ConfigMgr::Instance()->AddCard(vib_data);
|
||||
UpdateData(vib_data);
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
qDebug() << vib_data->base_config_[i].channel_type ;
|
||||
ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->checkBox_standby_1->setChecked(vib_data->base_config_[i].standby);
|
||||
ui->comboBox_sensitivity_unit_1->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit);
|
||||
ui->lineEdit_signal_sensitivity_1->setText(QString::number(vib_data->base_config_[i].signal_sensitivity));
|
||||
|
||||
ui->checkBox_enable_1->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_1->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_1->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
|
||||
ui->checkBox_keyphase->setChecked(vib_data->base_config_[i].keyphase);
|
||||
ui->comboBox_keyphase_ch->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch));
|
||||
ui->comboBox_keyphase_slot->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot));
|
||||
|
||||
} else if (i + 1 == 2) {
|
||||
ui->comboBox_chan_type_2->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_sensitivity_unit_2->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit);
|
||||
ui->lineEdit_signal_sensitivity_2->setText(QString::number(vib_data->base_config_[i].signal_sensitivity));
|
||||
|
||||
ui->checkBox_enable_2->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_2->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_2->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
|
||||
ui->checkBox_keyphase_2->setChecked(vib_data->base_config_[i].keyphase);
|
||||
ui->comboBox_keyphase_ch_2->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch));
|
||||
ui->comboBox_keyphase_slot_2->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot));
|
||||
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_standby_2->setChecked(vib_data->base_config_[i].standby);
|
||||
ui->comboBox_chan_type_3->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_sensitivity_unit_3->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit);
|
||||
ui->lineEdit_signal_sensitivity_3->setText(QString::number(vib_data->base_config_[i].signal_sensitivity));
|
||||
|
||||
ui->checkBox_keyphase_3->setChecked(vib_data->base_config_[i].keyphase);
|
||||
ui->comboBox_keyphase_ch_3->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch));
|
||||
ui->comboBox_keyphase_slot_3->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot));
|
||||
|
||||
ui->checkBox_enable_3->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_3->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_3->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
|
||||
} else if (i + 1 == 4) {
|
||||
ui->comboBox_chan_type_4->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_sensitivity_unit_4->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit);
|
||||
ui->lineEdit_signal_sensitivity_4->setText(QString::number(vib_data->base_config_[i].signal_sensitivity));
|
||||
|
||||
ui->checkBox_keyphase_4->setChecked(vib_data->base_config_[i].keyphase);
|
||||
ui->comboBox_keyphase_ch_4->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch));
|
||||
ui->comboBox_keyphase_slot_4->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot));
|
||||
|
||||
ui->checkBox_enable_4->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_4->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_4->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||
if (var + 1 == 1) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_1->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_1->currentIndex();
|
||||
vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_1->currentIndex();
|
||||
vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_1->text().toFloat();
|
||||
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
vib_data->base_config_[var].keyphase = ui->checkBox_keyphase->isChecked();
|
||||
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot->currentText().toInt();
|
||||
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch->currentText().toInt();
|
||||
} else if (var + 1 == 2) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_2->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_2->currentIndex();
|
||||
vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_2->currentIndex();
|
||||
vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_2->text().toFloat();
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
vib_data->base_config_[var].keyphase = ui->checkBox_keyphase_2->isChecked();
|
||||
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_2->currentText().toInt();
|
||||
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch_2->currentText().toInt();
|
||||
} else if (var + 1 == 3) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_3->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_3->currentIndex();
|
||||
vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_3->currentIndex();
|
||||
vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_3->text().toFloat();
|
||||
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
vib_data->base_config_[var].keyphase = ui->checkBox_keyphase_3->isChecked();
|
||||
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_3->currentText().toInt();
|
||||
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch_3->currentText().toInt();
|
||||
} else if (var + 1 == 4) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_4->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_4->currentIndex();
|
||||
vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_4->currentIndex();
|
||||
vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_4->text().toFloat();
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
vib_data->base_config_[var].keyphase = ui->checkBox_keyphase_4->isChecked();
|
||||
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_4->currentText().toInt();
|
||||
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch_4->currentText().toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << " should not be here";
|
||||
// std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||
// ConfigMgr::Instance()->AddCard(vib_data);
|
||||
// UpdateData(vib_data);
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase->isChecked()) {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "第一通道键相槽位选择错误!");
|
||||
return;
|
||||
}
|
||||
if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_2->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_2->isChecked()) {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "第二通道键相槽位选择错误!");
|
||||
return;
|
||||
}
|
||||
if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_3->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_3->isChecked()) {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "第三通道键相槽位选择错误!");
|
||||
return;
|
||||
}
|
||||
if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_4->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_4->isChecked()) {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "第四通道键相槽位选择错误!");
|
||||
return;
|
||||
}
|
||||
if(ui->lineEdit_signal_sensitivity_1->text() == "0" ||
|
||||
ui->lineEdit_signal_sensitivity_2->text() == "0" ||
|
||||
ui->lineEdit_signal_sensitivity_3->text() == "0" ||
|
||||
ui->lineEdit_signal_sensitivity_4->text() == "0"){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "传感器灵敏度填写错误!");
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
card_type = json_obj["card_type"].toInt();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
seismic_monitor[i].id = temp_obj["id"].toInt();
|
||||
seismic_monitor[i].channel_name = temp_obj["channle_name"].toString();
|
||||
seismic_monitor[i].standby = temp_obj["standby"].toBool();
|
||||
seismic_monitor[i].active = temp_obj["active"].toBool();
|
||||
seismic_monitor[i].rack_type = temp_obj["rack_type"].toString();
|
||||
seismic_monitor[i].tmr_group = temp_obj["tmr_group"].toString();
|
||||
seismic_monitor[i].channel_type = temp_obj["channel_type"].toString();
|
||||
seismic_monitor[i].transducer_name = temp_obj["transducer_name"].toString();
|
||||
seismic_monitor[i].scale_factor = temp_obj["scale_factor"].toString();
|
||||
seismic_monitor[i].sample_rate = temp_obj["sample_rate"].toString();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
seismic_monitor[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
seismic_monitor[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
}
|
||||
}
|
||||
void Seismic_monitor::Init()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(seismic_monitor[i].id == 1){
|
||||
qDebug() << seismic_monitor[i].channel_type ;
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_1->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_1->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_1->setCurrentText("位移");
|
||||
}
|
||||
//ui->comboBox_transducer_name_1->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_1->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_1->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_1->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_1->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_1->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
if(seismic_monitor[i].id == 2){
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_2->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_2->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_2->setCurrentText("位移");
|
||||
}
|
||||
//ui->comboBox_transducer_name_2->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_2->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_2->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_2->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_2->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_2->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
if(seismic_monitor[i].id == 3){
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_3->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_3->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_3->setCurrentText("位移");
|
||||
}
|
||||
//ui->lineEdit_transducer_name_3->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_3->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_3->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_3->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_3->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_3->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
if(seismic_monitor[i].id == 4){
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_4->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_4->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_4->setCurrentText("位移");
|
||||
}
|
||||
//ui->lineEdit_transducer_name_4->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_4->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_4->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_4->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_4->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_4->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void Seismic_monitor::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int var = 0; var < CHANNLE_COUNT; ++var){
|
||||
if(seismic_monitor[var].id == 1){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_1->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_1->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_1->isChecked();
|
||||
if(ui->comboBox_sample_rate_1->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
}else if(seismic_monitor[var].id == 2){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_2->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_2->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_2->isChecked();
|
||||
if(ui->comboBox_sample_rate_2->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
}else if(seismic_monitor[var].id == 3){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_3->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_3->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_3->isChecked();
|
||||
if(ui->comboBox_sample_rate_3->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
}else if(seismic_monitor[var].id == 4){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_4->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_3->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_4->isChecked();
|
||||
if(ui->comboBox_sample_rate_4->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
}
|
||||
}
|
||||
QJsonObject monitor_obj,item_obj;
|
||||
QJsonArray chan_array;
|
||||
for(int i = 0; i < CHANNLE_COUNT;i++){
|
||||
item_obj["id"] = seismic_monitor[i].id;
|
||||
item_obj["channel_name"] = seismic_monitor[i].channel_name;
|
||||
item_obj["standby"] = seismic_monitor[i].standby;
|
||||
item_obj["active"] = seismic_monitor[i].active;
|
||||
item_obj["rack_type"] = seismic_monitor[i].rack_type;
|
||||
item_obj["tmr_group"] = seismic_monitor[i].tmr_group;
|
||||
item_obj["channel_type"] = seismic_monitor[i].channel_type;
|
||||
item_obj["transducer_name"] = seismic_monitor[i].transducer_name;
|
||||
item_obj["scale_factor"] = seismic_monitor[i].scale_factor;
|
||||
item_obj["sample_rate"] = seismic_monitor[i].sample_rate;
|
||||
QJsonArray normal_voltage_array;
|
||||
normal_voltage_array.append(seismic_monitor[i].normal_voltage_low);
|
||||
normal_voltage_array.append(seismic_monitor[i].normal_voltage_high);
|
||||
item_obj["normal_voltage_range"] = normal_voltage_array;
|
||||
chan_array.append(item_obj);
|
||||
}
|
||||
monitor_obj["chan"] = chan_array;
|
||||
monitor_obj["slot"] = slot_no;
|
||||
monitor_obj["version"] = 1;
|
||||
monitor_obj["card_type"] = 1;
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setObject(monitor_obj);
|
||||
QString file_name = QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
||||
QFile file(QCoreApplication::applicationDirPath() + file_name);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
UpdateData(vib_data);
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_pushButton_set_default_clicked()
|
||||
{
|
||||
|
||||
void Seismic_monitor::on_pushButton_set_default_clicked() {
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_1_clicked()
|
||||
{
|
||||
void Seismic_monitor::on_pushButton_config_1_clicked() {
|
||||
channel = 1;
|
||||
if(ui->comboBox_chan_type_1->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_1->isChecked());
|
||||
if (ui->comboBox_chan_type_1->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_1->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_1->isChecked());
|
||||
} else if (ui->comboBox_chan_type_1->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_1->currentText() == "速度"){
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_1->isChecked());
|
||||
} else if (ui->comboBox_chan_type_1->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}else if (ui->comboBox_chan_type_1->currentIndex() == kVibThrust) {
|
||||
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
trust->setWindowModality(Qt::ApplicationModal);
|
||||
trust->show();
|
||||
}else if (ui->comboBox_chan_type_1->currentIndex() == kVibPressurePulsation) {
|
||||
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
|
||||
pressure_pulsation->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_2_clicked()
|
||||
{
|
||||
void Seismic_monitor::on_pushButton_config_2_clicked() {
|
||||
channel = 2;
|
||||
if(ui->comboBox_chan_type_2->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_2->isChecked());
|
||||
if (ui->comboBox_chan_type_2->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_2->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_2->isChecked());
|
||||
} else if (ui->comboBox_chan_type_2->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_2->currentText() == "速度"){
|
||||
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_2->isChecked());
|
||||
} else if (ui->comboBox_chan_type_2->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}else if (ui->comboBox_chan_type_2->currentIndex() == kVibThrust) {
|
||||
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
trust->setWindowModality(Qt::ApplicationModal);
|
||||
trust->show();
|
||||
}else if (ui->comboBox_chan_type_2->currentIndex() == kVibPressurePulsation) {
|
||||
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
|
||||
pressure_pulsation->show();
|
||||
}
|
||||
}
|
||||
void Seismic_monitor::on_pushButton_config_3_clicked()
|
||||
{
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_3_clicked() {
|
||||
channel = 3;
|
||||
if(ui->comboBox_chan_type_3->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_3->isChecked());
|
||||
if (ui->comboBox_chan_type_3->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_3->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_3->isChecked());
|
||||
} else if (ui->comboBox_chan_type_3->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_3->currentText() == "速度"){
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_3->isChecked());
|
||||
} else if (ui->comboBox_chan_type_3->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}else if (ui->comboBox_chan_type_3->currentIndex() == kVibThrust) {
|
||||
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
trust->setWindowModality(Qt::ApplicationModal);
|
||||
trust->show();
|
||||
}else if (ui->comboBox_chan_type_3->currentIndex() == kVibPressurePulsation) {
|
||||
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
|
||||
pressure_pulsation->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_4_clicked()
|
||||
{
|
||||
void Seismic_monitor::on_pushButton_config_4_clicked() {
|
||||
channel = 4;
|
||||
if(ui->comboBox_chan_type_4->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_4->isChecked());
|
||||
if (ui->comboBox_chan_type_4->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_4->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_4->isChecked());
|
||||
} else if (ui->comboBox_chan_type_4->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_4->currentText() == "速度"){
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_4->isChecked());
|
||||
} else if (ui->comboBox_chan_type_4->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}else if (ui->comboBox_chan_type_4->currentIndex() == kVibThrust) {
|
||||
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
trust->setWindowModality(Qt::ApplicationModal);
|
||||
trust->show();
|
||||
}else if (ui->comboBox_chan_type_4->currentIndex() == kVibPressurePulsation) {
|
||||
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
|
||||
pressure_pulsation->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_1_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_1->currentIndex()) {
|
||||
case kVibRadial:
|
||||
|
||||
EnableKeyphase();
|
||||
break;
|
||||
case kVibAcc:
|
||||
|
||||
EnableKeyphase();
|
||||
break;
|
||||
case kVibVelocity:
|
||||
|
||||
EnableKeyphase();
|
||||
break;
|
||||
case kVibThrust:
|
||||
|
||||
DisableKeyphase();
|
||||
break;
|
||||
case kVibPressurePulsation:
|
||||
DisableKeyphase();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_2->currentIndex()) {
|
||||
case kVibRadial:
|
||||
EnableKeyphase();
|
||||
break;
|
||||
case kVibAcc:
|
||||
EnableKeyphase2();
|
||||
break;
|
||||
case kVibVelocity:
|
||||
EnableKeyphase2();
|
||||
break;
|
||||
case kVibThrust:
|
||||
DisableKeyphase2();
|
||||
break;
|
||||
case kVibPressurePulsation:
|
||||
DisableKeyphase2();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_3->currentIndex()) {
|
||||
case kVibRadial:
|
||||
EnableKeyphase();
|
||||
break;
|
||||
case kVibAcc:
|
||||
EnableKeyphase3();
|
||||
break;
|
||||
case kVibVelocity:
|
||||
EnableKeyphase3();
|
||||
break;
|
||||
case kVibThrust:
|
||||
DisableKeyphase3();
|
||||
break;
|
||||
case kVibPressurePulsation:
|
||||
DisableKeyphase3();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_4_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_4->currentIndex()) {
|
||||
case kVibRadial:
|
||||
EnableKeyphase4();
|
||||
break;
|
||||
case kVibAcc:
|
||||
EnableKeyphase4();
|
||||
break;
|
||||
case kVibVelocity:
|
||||
EnableKeyphase4();
|
||||
break;
|
||||
case kVibThrust:
|
||||
DisableKeyphase4();
|
||||
break;
|
||||
case kVibPressurePulsation:
|
||||
DisableKeyphase4();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1) {
|
||||
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1) {
|
||||
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1) {
|
||||
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1) {
|
||||
|
||||
}
|
||||
void Seismic_monitor::EnableKeyphase(){
|
||||
ui->checkBox_keyphase->setCheckable(true);
|
||||
ui->checkBox_keyphase->setEnabled(true);
|
||||
ui->comboBox_keyphase_ch->setEnabled(true);
|
||||
ui->comboBox_keyphase_slot->setEnabled(true);
|
||||
}
|
||||
void Seismic_monitor::EnableKeyphase2(){
|
||||
ui->checkBox_keyphase_2->setCheckable(true);
|
||||
ui->checkBox_keyphase_2->setEnabled(true);
|
||||
ui->comboBox_keyphase_ch_2->setEnabled(true);
|
||||
ui->comboBox_keyphase_slot_2->setEnabled(true);
|
||||
}
|
||||
void Seismic_monitor::EnableKeyphase3(){
|
||||
ui->checkBox_keyphase_3->setCheckable(true);
|
||||
ui->checkBox_keyphase_3->setEnabled(true);
|
||||
ui->comboBox_keyphase_ch_3->setEnabled(true);
|
||||
ui->comboBox_keyphase_slot_3->setEnabled(true);
|
||||
}
|
||||
void Seismic_monitor::EnableKeyphase4(){
|
||||
ui->checkBox_keyphase_4->setCheckable(true);
|
||||
ui->checkBox_keyphase_4->setEnabled(true);
|
||||
ui->comboBox_keyphase_ch_4->setEnabled(true);
|
||||
ui->comboBox_keyphase_slot_4->setEnabled(true);
|
||||
}
|
||||
void Seismic_monitor::DisableKeyphase(){
|
||||
ui->checkBox_keyphase->setCheckable(false);
|
||||
ui->checkBox_keyphase->setEnabled(false);
|
||||
ui->comboBox_keyphase_ch->setEnabled(false);
|
||||
ui->comboBox_keyphase_slot->setEnabled(false);
|
||||
}
|
||||
void Seismic_monitor::DisableKeyphase2(){
|
||||
ui->checkBox_keyphase_2->setCheckable(false);
|
||||
ui->checkBox_keyphase_2->setEnabled(false);
|
||||
ui->comboBox_keyphase_ch_2->setEnabled(false);
|
||||
ui->comboBox_keyphase_slot_2->setEnabled(false);
|
||||
}
|
||||
void Seismic_monitor::DisableKeyphase3(){
|
||||
ui->checkBox_keyphase_3->setCheckable(false);
|
||||
ui->checkBox_keyphase_3->setEnabled(false);
|
||||
ui->comboBox_keyphase_ch_3->setEnabled(false);
|
||||
ui->comboBox_keyphase_slot_3->setEnabled(false);
|
||||
|
||||
}
|
||||
void Seismic_monitor::DisableKeyphase4(){
|
||||
ui->checkBox_keyphase_4->setCheckable(false);
|
||||
ui->checkBox_keyphase_4->setEnabled(false);
|
||||
ui->comboBox_keyphase_ch_4->setEnabled(false);
|
||||
ui->comboBox_keyphase_slot_4->setEnabled(false);
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_sensitivity_unit_1_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
QString str = QString("信号灵敏度(mV/%1)").arg(arg1);
|
||||
ui->label_signal_sensitivity_1->setText(str);
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
QString str = QString("信号灵敏度(mV/%1)").arg(arg1);
|
||||
ui->label_signal_sensitivity_2->setText(str);
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_comboBox_sensitivity_unit_3_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
QString str = QString("信号灵敏度(mV/%1)").arg(arg1);
|
||||
ui->label_signal_sensitivity_3->setText(str);
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_comboBox_sensitivity_unit_4_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
QString str = QString("信号灵敏度(mV/%1)").arg(arg1);
|
||||
ui->label_signal_sensitivity_4->setText(str);
|
||||
}
|
||||
|
||||
|
||||
@ -3,21 +3,22 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
namespace Ui {
|
||||
class Seismic_monitor;
|
||||
}
|
||||
|
||||
class Seismic_monitor : public QWidget
|
||||
{
|
||||
class Seismic_monitor : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Seismic_monitor(int slot,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Seismic_monitor(int slot,int cardtype, QWidget *parent = nullptr);
|
||||
~Seismic_monitor();
|
||||
int slot_no;
|
||||
int channel;
|
||||
private slots:
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_set_default_clicked();
|
||||
@ -30,14 +31,48 @@ private slots:
|
||||
|
||||
void on_pushButton_config_4_clicked();
|
||||
|
||||
void on_comboBox_chan_type_1_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_chan_type_2_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_chan_type_3_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_chan_type_4_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_sensitivity_unit_1_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_sensitivity_unit_3_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_sensitivity_unit_4_currentTextChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
Ui::Seismic_monitor *ui;
|
||||
|
||||
void UpdateData(std::shared_ptr<VibrationData> vib_data);
|
||||
int card_type;
|
||||
void readJsonFile(const QString &filePath);
|
||||
SeismicMonitor seismic_monitor[CHANNLE_COUNT];
|
||||
|
||||
// void readJsonFile(const QString &filePath);
|
||||
// SeismicMonitor seismic_monitor[CHANNLE_COUNT];
|
||||
QVector<Transducer> vec_transducer;
|
||||
void Init();
|
||||
void EnableKeyphase();
|
||||
void EnableKeyphase2();
|
||||
void EnableKeyphase3();
|
||||
void EnableKeyphase4();
|
||||
void DisableKeyphase();
|
||||
void DisableKeyphase2();
|
||||
void DisableKeyphase3();
|
||||
void DisableKeyphase4();
|
||||
};
|
||||
|
||||
#endif // SEISMIC_MONITOR_H
|
||||
|
||||
2148
seismic_monitor.ui
2148
seismic_monitor.ui
File diff suppressed because it is too large
Load Diff
14
setpoint.cpp
14
setpoint.cpp
@ -1,14 +0,0 @@
|
||||
#include "Setpoint.h"
|
||||
#include "ui_Setpoint.h"
|
||||
|
||||
Setpoint::Setpoint(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Setpoint)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
Setpoint::~Setpoint()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
setpoint.h
22
setpoint.h
@ -1,22 +0,0 @@
|
||||
#ifndef setpoint_H
|
||||
#define setpoint_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class Setpoint;
|
||||
}
|
||||
|
||||
class Setpoint : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Setpoint(QWidget *parent = nullptr);
|
||||
~Setpoint();
|
||||
|
||||
private:
|
||||
Ui::Setpoint *ui;
|
||||
};
|
||||
|
||||
#endif // setpoint_H
|
||||
445
setpoint.ui
445
setpoint.ui
@ -1,445 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Setpoint</class>
|
||||
<widget class="QWidget" name="Setpoint">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>722</width>
|
||||
<height>560</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>危险 / 警报 2</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboBox_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>69</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>30</y>
|
||||
<width>69</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>23</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>520</y>
|
||||
<width>119</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>槽位号2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_6">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 1</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>500</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>521</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>告警 / 警报 1</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>23</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_28">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>113</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>197</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>复制</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
125
setpoint_tachometer.cpp
Normal file
125
setpoint_tachometer.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
#include "setpoint_tachometer.h"
|
||||
#include "ui_setpoint_tachometer.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
Setpoint_Tachometer::Setpoint_Tachometer(int slot_no_,int cardtype,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Setpoint_Tachometer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
ui->label_slot->setText(QString::number(slot_no));
|
||||
Init();
|
||||
connect(ui->comboBox_chan, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &Setpoint_Tachometer::onComboBoxIndexChanged);
|
||||
current_index = ui->comboBox_chan->currentIndex();
|
||||
}
|
||||
|
||||
Setpoint_Tachometer::~Setpoint_Tachometer()
|
||||
{
|
||||
if(slider_alert != nullptr)
|
||||
delete slider_alert;
|
||||
if(slider_danger != nullptr)
|
||||
delete slider_danger;
|
||||
delete ui;
|
||||
}
|
||||
void Setpoint_Tachometer::Init(){
|
||||
|
||||
QVBoxLayout *layout_alert = new QVBoxLayout(ui->widget_alert);
|
||||
slider_alert = new RangeSlider;
|
||||
layout_alert->addWidget(slider_alert);
|
||||
|
||||
QVBoxLayout *layout_danger = new QVBoxLayout(ui->widget_danger);
|
||||
slider_danger = new RangeSlider(1);
|
||||
layout_danger->addWidget(slider_danger);
|
||||
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
speed_alert_ptr = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
|
||||
switch (car_type) {
|
||||
case kCardSpeedSingle:{
|
||||
slider_alert->m_upper = 3500;
|
||||
slider_alert->m_lower = 1500;
|
||||
slider_alert->setRange(0,5000);
|
||||
slider_danger->m_upper = 4250;
|
||||
slider_danger->m_lower = 750;
|
||||
slider_danger->setRange(0,5000);
|
||||
|
||||
int chan = ui->comboBox_chan->currentIndex();
|
||||
std::shared_ptr<TachometerData> setpoint_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
ui->lineEdit_alert_upper->setText(QString::number(setpoint_data->alert_danger[chan].speed_upper));
|
||||
ui->lineEdit_alert_lower->setText(QString::number(setpoint_data->alert_danger[chan].speed_lower));
|
||||
ui->checkBox_alert_upper->setChecked(setpoint_data->alert_danger[chan].speed_upper_enable);
|
||||
ui->checkBox_alert_lower->setChecked(setpoint_data->alert_danger[chan].speed_lower_enable);
|
||||
if(setpoint_data->alert_danger[chan].speed_upper > 0 && setpoint_data->alert_danger[chan].speed_lower){
|
||||
slider_alert->m_upper = setpoint_data->alert_danger[chan].speed_upper;
|
||||
slider_alert->m_lower = setpoint_data->alert_danger[chan].speed_lower;
|
||||
}
|
||||
ui->lineEdit_danger_upper->setText(QString::number(setpoint_data->alert_danger[chan].danger_speed_upper));
|
||||
if(setpoint_data->alert_danger[chan].danger_speed_upper > 0 ){
|
||||
slider_danger->m_upper = setpoint_data->alert_danger[chan].danger_speed_upper;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
QObject::connect(ui->lineEdit_alert_upper, &QLineEdit::editingFinished, [&]() {
|
||||
slider_alert->setUpperValue(ui->lineEdit_alert_upper->text().toFloat());
|
||||
});
|
||||
QObject::connect(ui->lineEdit_alert_lower, &QLineEdit::editingFinished, [&]() {
|
||||
slider_alert->setLowerValue(ui->lineEdit_alert_lower->text().toFloat());
|
||||
});
|
||||
QObject::connect(slider_alert, &RangeSlider::rangeChanged, [&](float low,float high) {
|
||||
ui->lineEdit_alert_upper->setText(QString::number((int)high));
|
||||
ui->lineEdit_alert_lower->setText(QString::number((int)low));
|
||||
});
|
||||
|
||||
QObject::connect(ui->lineEdit_danger_upper, &QLineEdit::editingFinished, [&]() {
|
||||
slider_danger->setUpperValue(ui->lineEdit_danger_upper->text().toFloat());
|
||||
});
|
||||
QObject::connect(slider_danger, &RangeSlider::rangeChanged, [&](float low,float high) {
|
||||
ui->lineEdit_danger_upper->setText(QString::number((int)high));
|
||||
});
|
||||
}
|
||||
void Setpoint_Tachometer::onComboBoxIndexChanged(int index){
|
||||
|
||||
speed_alert_ptr->alert_danger[current_index].speed_upper = ui->lineEdit_alert_upper->text().toFloat();
|
||||
speed_alert_ptr->alert_danger[current_index].speed_lower = ui->lineEdit_alert_lower->text().toFloat();
|
||||
speed_alert_ptr->alert_danger[current_index].speed_upper_enable = ui->checkBox_alert_upper->checkState();
|
||||
speed_alert_ptr->alert_danger[current_index].speed_lower_enable = ui->checkBox_alert_lower->checkState();
|
||||
speed_alert_ptr->alert_danger[current_index].danger_speed_upper = ui->lineEdit_danger_upper->text().toFloat();
|
||||
|
||||
current_index = index;
|
||||
ui->lineEdit_alert_upper->setText(QString::number(speed_alert_ptr->alert_danger[index].speed_upper));
|
||||
ui->lineEdit_alert_lower->setText(QString::number(speed_alert_ptr->alert_danger[index].speed_lower));
|
||||
ui->checkBox_alert_upper->setChecked(speed_alert_ptr->alert_danger[index].speed_upper_enable);
|
||||
ui->checkBox_alert_lower->setChecked(speed_alert_ptr->alert_danger[index].speed_lower_enable);
|
||||
if(speed_alert_ptr->alert_danger[index].speed_upper > 0 && speed_alert_ptr->alert_danger[index].speed_lower){
|
||||
slider_alert->m_upper = speed_alert_ptr->alert_danger[index].speed_upper;
|
||||
slider_alert->m_lower = speed_alert_ptr->alert_danger[index].speed_lower;
|
||||
}
|
||||
ui->lineEdit_danger_upper->setText(QString::number(speed_alert_ptr->alert_danger[index].danger_speed_upper));
|
||||
if(speed_alert_ptr->alert_danger[index].danger_speed_upper > 0){
|
||||
slider_danger->m_upper = speed_alert_ptr->alert_danger[index].danger_speed_upper;
|
||||
}
|
||||
}
|
||||
|
||||
void Setpoint_Tachometer::on_pushButton_confirm_clicked()
|
||||
{
|
||||
if (speed_alert_ptr == nullptr) {
|
||||
qCritical() << "[Setpoint_Tachometer::confirm] should not be here";
|
||||
return;
|
||||
}
|
||||
speed_alert_ptr->alert_danger[current_index].speed_upper = ui->lineEdit_alert_upper->text().toFloat();
|
||||
speed_alert_ptr->alert_danger[current_index].speed_lower = ui->lineEdit_alert_lower->text().toFloat();
|
||||
speed_alert_ptr->alert_danger[current_index].speed_upper_enable = ui->checkBox_alert_upper->checkState();
|
||||
speed_alert_ptr->alert_danger[current_index].speed_lower_enable = ui->checkBox_alert_lower->checkState();
|
||||
speed_alert_ptr->alert_danger[current_index].danger_speed_upper = ui->lineEdit_danger_upper->text().toFloat();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Setpoint_Tachometer::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
37
setpoint_tachometer.h
Normal file
37
setpoint_tachometer.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef SETPOINT_TACHOMETER_H
|
||||
#define SETPOINT_TACHOMETER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
#include "rangeslider.h"
|
||||
#include "tachometer_data.h"
|
||||
|
||||
namespace Ui {
|
||||
class Setpoint_Tachometer;
|
||||
}
|
||||
|
||||
class Setpoint_Tachometer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Setpoint_Tachometer(int slot_no_,int cardtype,QWidget *parent = nullptr);
|
||||
~Setpoint_Tachometer();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void onComboBoxIndexChanged(int index);
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::Setpoint_Tachometer *ui;
|
||||
RangeSlider *slider_alert;
|
||||
RangeSlider *slider_danger;
|
||||
std::shared_ptr<TachometerData> speed_alert_ptr = nullptr;
|
||||
int current_index;
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif // SETPOINT_TACHOMETER_H
|
||||
375
setpoint_tachometer.ui
Normal file
375
setpoint_tachometer.ui
Normal file
@ -0,0 +1,375 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Setpoint_Tachometer</class>
|
||||
<widget class="QWidget" name="Setpoint_Tachometer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>710</width>
|
||||
<height>522</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>触发配置</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>480</y>
|
||||
<width>666</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>槽位号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_slot">
|
||||
<property name="text">
|
||||
<string>slot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_chan">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置为默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>危险 / 警报 2</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>40</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>rpm</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>80</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_danger" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>107</y>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>521</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>告警 / 警报 1</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>80</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_alert" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>107</y>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>40</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>rpm</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_alert_lower">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>420</y>
|
||||
<width>65</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_alert_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>65</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_lower">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>380</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
474
singlerelay.cpp
474
singlerelay.cpp
@ -1,14 +1,478 @@
|
||||
#include "singlerelay.h"
|
||||
#include "ui_singlerelay.h"
|
||||
#include "vibrationdata.h"
|
||||
#include <QStack>
|
||||
#include <QMessageBox>
|
||||
#include <QMenu>
|
||||
|
||||
SingleRelay::SingleRelay(QWidget *parent)
|
||||
SingleRelay::SingleRelay(int slot,int cardtype,QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::SingleRelay)
|
||||
{
|
||||
, ui(new Ui::SingleRelay) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
ui->label_slot_no->setText(QString::number(slot_no));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
|
||||
list_widget_available = new QListWidget();
|
||||
layout_available->addWidget(list_widget_available);
|
||||
list_widget_available->setDragEnabled(true);
|
||||
|
||||
QVBoxLayout *layout_relay = new QVBoxLayout(ui->widget_relay);
|
||||
treeView_relay = new QTreeView;
|
||||
layout_relay->addWidget(treeView_relay);
|
||||
treeView_relay->setDragEnabled(true); // 启用拖动
|
||||
treeView_relay->setAcceptDrops(true); // 接受放下
|
||||
treeView_relay->setDropIndicatorShown(true); // 显示放置指示器
|
||||
treeView_relay->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
model_Relay = new DropTreeModel(this); //创建模型指定父类
|
||||
treeView_relay->setModel(model_Relay);
|
||||
treeView_relay->setHeaderHidden(true);
|
||||
|
||||
btnGroup_slot = new QButtonGroup(this);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot1);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot2);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot3);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot4);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot5);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot6);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot7);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot8);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot9);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot10);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot11);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot12);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot13);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot14);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot15);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot16);
|
||||
|
||||
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
|
||||
connect(ui->comboBox_relay_ch, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &SingleRelay::onComboBoxIndexChanged);
|
||||
treeView_relay->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(treeView_relay,&QTreeView::customContextMenuRequested,this,&SingleRelay::on_treeView_Relay_customContextMenuRequested);
|
||||
current_index = ui->comboBox_relay_ch->currentIndex();
|
||||
Init();
|
||||
onComboBoxIndexChanged(current_index);
|
||||
|
||||
}
|
||||
|
||||
SingleRelay::~SingleRelay()
|
||||
{
|
||||
SingleRelay::~SingleRelay() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SingleRelay::Init(){
|
||||
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||
for (int i = 1; i < buttonList.count() + 1; i++) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(i);
|
||||
if(base_ptr != nullptr){
|
||||
switch (base_ptr->card_type_) {
|
||||
case kCardVibSingle :{
|
||||
buttonList[i - 1]->setText("振动");
|
||||
break;
|
||||
}
|
||||
case kCardKeyphaseSingle:{
|
||||
buttonList[i - 1]->setText("键相");
|
||||
break;
|
||||
}
|
||||
case kCardSpeedSingle:{
|
||||
buttonList[i - 1]->setText("转速");
|
||||
break;
|
||||
}
|
||||
case kCardRelaySingle:
|
||||
case kCardRelaySingleNOK:
|
||||
case kCardRelayTMRPrimary:{
|
||||
buttonList[i - 1]->setText("继电器");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
relay_data = std::make_shared<SingleRelayData>();
|
||||
relay_data->card_type_ = car_type;
|
||||
relay_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(relay_data);
|
||||
return;
|
||||
}
|
||||
relay_data = std::dynamic_pointer_cast<SingleRelayData>(base_ptr);
|
||||
|
||||
qDebug() << "logic" <<relay_data->single_relay[current_index].logic_expression;
|
||||
qDebug() << "active" <<relay_data->single_relay[current_index].active << "index" << current_index;
|
||||
|
||||
for(int i = 0 ; i < SLOT_NUM ; i++){
|
||||
std::shared_ptr<CardBase> cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
|
||||
if(cardbase_ptr != nullptr &&
|
||||
cardbase_ptr->card_type_ == kCardVibSingle){
|
||||
qDebug() << "i" << i;
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(cardbase_ptr);
|
||||
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(var + 1);
|
||||
QString item_data,item_str;
|
||||
if(variable_base->alert_high.enable){
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 警报高)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1A2").arg(ptr->base_config_[var].chan_id);
|
||||
}
|
||||
channelNameMap[item_data] = item_str;
|
||||
if(variable_base->danger_high.enable){
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 危险高)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1A1").arg(ptr->base_config_[var].chan_id);
|
||||
}
|
||||
channelNameMap[item_data] = item_str;
|
||||
if(variable_base->alert_low.enable){
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 警报低)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1A3").arg(ptr->base_config_[var].chan_id);
|
||||
}
|
||||
channelNameMap[item_data] = item_str;
|
||||
if(variable_base->danger_low.enable){
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 危险低)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1A4").arg(ptr->base_config_[var].chan_id);
|
||||
}
|
||||
if(var == 3){
|
||||
qDebug() << "alert" << variable_base->danger_high.enable<<variable_base->danger_high.enable;
|
||||
}
|
||||
channelNameMap[item_data] = item_str;
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1P##NO").arg(ptr->base_config_[var].chan_id);
|
||||
channelNameMap[item_data] = item_str;
|
||||
}
|
||||
}else if(cardbase_ptr != nullptr &&
|
||||
cardbase_ptr->card_type_ == kCardSpeedSingle){
|
||||
}
|
||||
}
|
||||
if(!relay_data->single_relay[current_index].logic_expression.isEmpty()){
|
||||
setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic_expression);
|
||||
}
|
||||
ui->checkBox_active->setChecked(relay_data->single_relay[current_index].active);
|
||||
}
|
||||
void SingleRelay::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) {
|
||||
if (slot_btn != NULL) {
|
||||
list_widget_available->clear();
|
||||
QString object_name = slot_btn->objectName();
|
||||
qDebug() << object_name ;
|
||||
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if(ptr == nullptr)
|
||||
return;
|
||||
QListWidgetItem *item_and = new QListWidgetItem("AND");
|
||||
item_and->setData(Qt::UserRole, "*");
|
||||
list_widget_available->addItem(item_and);
|
||||
|
||||
QListWidgetItem *item_or = new QListWidgetItem("OR");
|
||||
item_or->setData(Qt::UserRole, "+");
|
||||
list_widget_available->addItem(item_or);
|
||||
|
||||
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(var + 1);
|
||||
if(base_ptr->card_type_ == kCardVibSingle){
|
||||
QString item_data;
|
||||
if(variable_base->alert_high.enable){
|
||||
QString item_str = QString("%1 (槽位 %3 通道 %4 警报高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
|
||||
if(variable_base->danger_high.enable){
|
||||
QString item_str = QString("%1 (槽位 %3 通道 %4 危险高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
item_data = QString("S%1C%2A1").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
if(variable_base->danger_low.enable){
|
||||
QString item_str = QString("%1 (槽位 %3 通道 %4 危险低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
item_data = QString("S%1C%2A4").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
if(variable_base->alert_low.enable){
|
||||
QString item_str = QString("%1 (槽位 %3 通道 %4 警报低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
item_data = QString("S%1C%2A3").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
QString item_data_nok = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data_nok);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SingleRelay::keyPressEvent(QKeyEvent *event) {
|
||||
// if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
|
||||
// removeLastElement();
|
||||
// return;
|
||||
// }
|
||||
// QTextEdit::keyPressEvent(event);
|
||||
}
|
||||
QString SingleRelay::buildLogicExpression(QStandardItem *item) {
|
||||
if (!item) return "";
|
||||
|
||||
int childCount = item->rowCount();
|
||||
QVariant userData = item->data(Qt::UserRole);
|
||||
QString text = userData.toString().trimmed();
|
||||
qDebug() << "item" << userData;
|
||||
if (childCount == 0) {
|
||||
// 叶子节点,直接返回表达式,比如 S01C01A1
|
||||
return text;
|
||||
}
|
||||
|
||||
// 判断当前是 +(OR)还是 *(AND)
|
||||
QString opStr = (text == "+") ? "+" :
|
||||
(text == "*") ? "*" : "";
|
||||
|
||||
// 如果不是 +/*,视为叶子节点
|
||||
if (opStr.isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
|
||||
QStringList subExprs;
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
QStandardItem *child = item->child(i);
|
||||
subExprs << buildLogicExpression(child);
|
||||
}
|
||||
|
||||
return "(" + subExprs.join(" " + opStr + " ") + ")";
|
||||
}
|
||||
void SingleRelay::on_pushButton_confirm_clicked()
|
||||
{
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QString finalExpr;
|
||||
for (int i = 0; i < root->rowCount(); ++i) {
|
||||
QStandardItem *topItem = root->child(i);
|
||||
QString expr = buildLogicExpression(topItem);
|
||||
finalExpr += expr;
|
||||
}
|
||||
ExprValidationResult result = validateLogicExpression(finalExpr);
|
||||
if (!result.isValid && !finalExpr.isEmpty()) {
|
||||
QMessageBox::warning(this, "表达式错误",
|
||||
QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg));
|
||||
return;
|
||||
}
|
||||
relay_data->single_relay[current_index].logic_expression = finalExpr;
|
||||
relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked();
|
||||
qDebug() << "逻辑表达式:" << finalExpr;
|
||||
this->close();
|
||||
}
|
||||
void SingleRelay::onComboBoxIndexChanged(int index){
|
||||
|
||||
qDebug()<< "[SingleRelay]:index " << index;
|
||||
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QString finalExpr;
|
||||
for (int i = 0; i < root->rowCount(); ++i) {
|
||||
QStandardItem *topItem = root->child(i);
|
||||
QString expr = buildLogicExpression(topItem);
|
||||
finalExpr += expr;
|
||||
}
|
||||
ExprValidationResult result = validateLogicExpression(finalExpr);
|
||||
if (!result.isValid && !finalExpr.isEmpty()) {
|
||||
QMessageBox::warning(this, "表达式错误",
|
||||
QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg));
|
||||
return;
|
||||
}
|
||||
qDebug() << "finalExpr" << finalExpr;
|
||||
relay_data->single_relay[current_index].logic_expression = finalExpr;
|
||||
relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked();
|
||||
current_index = index;
|
||||
qDebug() << "active" << relay_data->single_relay[index].active;
|
||||
ui->checkBox_active->setChecked(relay_data->single_relay[index].active);
|
||||
if(relay_data->single_relay[index].logic_expression != "")
|
||||
setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic_expression);
|
||||
else
|
||||
model_Relay->clear();
|
||||
}
|
||||
ExprNode* SingleRelay::parseExpression(const QString& expr, int& pos) {
|
||||
auto skipSpaces = [&]() {
|
||||
while (pos < expr.length() && expr[pos].isSpace()) pos++;
|
||||
};
|
||||
|
||||
QStack<ExprNode*> nodeStack;
|
||||
QStack<QString> opStack;
|
||||
|
||||
while (pos < expr.length()) {
|
||||
skipSpaces();
|
||||
if (pos >= expr.length()) break;
|
||||
|
||||
QChar ch = expr[pos];
|
||||
|
||||
if (ch == '(') {
|
||||
pos++;
|
||||
nodeStack.push(parseExpression(expr, pos));
|
||||
} else if (ch == ')') {
|
||||
pos++;
|
||||
break;
|
||||
} else if (ch == '+' || ch == '*') {
|
||||
opStack.push(QString(ch));
|
||||
pos++;
|
||||
} else {
|
||||
QString token;
|
||||
while (pos < expr.length() && !QString("()+* ").contains(expr[pos])) {
|
||||
token += expr[pos++];
|
||||
}
|
||||
if (!token.isEmpty()) {
|
||||
nodeStack.push(new ExprNode{token, {}});
|
||||
}
|
||||
}
|
||||
|
||||
while (opStack.size() > 0 && nodeStack.size() >= 2) {
|
||||
QString op = opStack.pop();
|
||||
ExprNode* right = nodeStack.pop();
|
||||
ExprNode* left = nodeStack.pop();
|
||||
|
||||
if (left->value == op) {
|
||||
left->children.append(right);
|
||||
nodeStack.push(left);
|
||||
} else if (right->value == op) {
|
||||
right->children.prepend(left);
|
||||
nodeStack.push(right);
|
||||
} else {
|
||||
ExprNode* parent = new ExprNode{op, {left, right}};
|
||||
nodeStack.push(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodeStack.isEmpty() ? nullptr : nodeStack.top();
|
||||
}
|
||||
QStandardItem* SingleRelay::buildItemTree(ExprNode* node) {
|
||||
if (!node) return nullptr;
|
||||
QString displayText;
|
||||
if (node->value == "+" || node->value == "*") {
|
||||
displayText = (node->value == "+") ? "OR" : "AND"; // 运算符显示
|
||||
} else {
|
||||
displayText = channelNameMap.value(node->value, node->value); // 显示名
|
||||
qDebug() << "display" <<displayText << node->value;
|
||||
}
|
||||
QStandardItem* item = new QStandardItem(displayText);
|
||||
item->setData(node->value, Qt::UserRole); // 原始表达式key
|
||||
for (ExprNode* child : node->children) {
|
||||
item->appendRow(buildItemTree(child));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
ExprValidationResult SingleRelay::validateLogicExpression(const QString& expr) {
|
||||
int bracketCount = 0;
|
||||
bool lastWasOperator = true;
|
||||
bool lastWasOpenParen = false;
|
||||
|
||||
for (int i = 0; i < expr.length(); ++i) {
|
||||
QChar ch = expr[i];
|
||||
|
||||
if (ch.isSpace()) continue;
|
||||
|
||||
if (ch == '(') {
|
||||
bracketCount++;
|
||||
lastWasOpenParen = true;
|
||||
lastWasOperator = true;
|
||||
} else if (ch == ')') {
|
||||
bracketCount--;
|
||||
if (bracketCount < 0) {
|
||||
return {false, i, "多余的右括号 ')'"};
|
||||
}
|
||||
lastWasOpenParen = false;
|
||||
lastWasOperator = false;
|
||||
} else if (ch == '+' || ch == '*') {
|
||||
if (lastWasOperator || lastWasOpenParen) {
|
||||
return {false, i, QString("无效的运算符 '%1' 的位置").arg(ch)};
|
||||
}
|
||||
lastWasOperator = true;
|
||||
lastWasOpenParen = false;
|
||||
} else if (ch.isLetterOrNumber()) {
|
||||
QString token;
|
||||
int start = i;
|
||||
while (i < expr.length() && expr[i].isLetterOrNumber()) {
|
||||
token += expr[i];
|
||||
++i;
|
||||
}
|
||||
--i; // 修正多读了一位
|
||||
if (token.isEmpty()) {
|
||||
return {false, start, "变量名称缺失"};
|
||||
}
|
||||
lastWasOperator = false;
|
||||
lastWasOpenParen = false;
|
||||
} else if (ch.isLetterOrNumber() || ch == '#' || ch.unicode() > 127) {
|
||||
QString token;
|
||||
int start = i;
|
||||
while (i < expr.length() &&
|
||||
(expr[i].isLetterOrNumber() || expr[i] == '#' || expr[i].unicode() > 127)) {
|
||||
token += expr[i];
|
||||
++i;
|
||||
}
|
||||
--i;
|
||||
if (token.isEmpty()) {
|
||||
return {false, start, "变量名称缺失"};
|
||||
}
|
||||
lastWasOperator = false;
|
||||
lastWasOpenParen = false;
|
||||
}else {
|
||||
return {false, i, QString("不支持的字符 '%1'").arg(ch)};
|
||||
}
|
||||
}
|
||||
|
||||
if (bracketCount != 0) {
|
||||
return {false, expr.length(), "括号不匹配"};
|
||||
}
|
||||
|
||||
if (lastWasOperator) {
|
||||
return {false, expr.length() - 1, "表达式不能以运算符结尾"};
|
||||
}
|
||||
|
||||
return {true, -1, ""};
|
||||
}
|
||||
void SingleRelay::setExpressionToTreeView(QTreeView* treeView, const QString& expr) {
|
||||
int pos = 0;
|
||||
model_Relay->clear();
|
||||
qDebug() << "expr" << expr;
|
||||
ExprNode* root = parseExpression(expr, pos);
|
||||
QStandardItem* rootItem = buildItemTree(root);
|
||||
|
||||
model_Relay->appendRow(rootItem);
|
||||
treeView_relay->expandAll();
|
||||
}
|
||||
void SingleRelay::slotDeleteItem()
|
||||
{
|
||||
QModelIndex curIndex = treeView_relay->currentIndex();
|
||||
if(curIndex.isValid()){
|
||||
model_Relay->removeRow(curIndex.row(),curIndex.parent());
|
||||
}
|
||||
|
||||
}
|
||||
void SingleRelay::on_treeView_Relay_customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
qDebug() << "on_treeView_Relay_customContextMenuRequested" <<endl;
|
||||
QModelIndex curIndex = treeView_relay->indexAt(pos); //当前点击的元素的index
|
||||
QModelIndex index = curIndex.sibling(curIndex.row(),0); //该行的第1列元素的index
|
||||
QMenu menu(this);
|
||||
if (index.isValid()){
|
||||
//添加一行菜单,进行展开
|
||||
menu.addAction(QStringLiteral("删除"), this, SLOT(slotDeleteItem()));
|
||||
menu.addSeparator(); //添加一个分隔线
|
||||
}
|
||||
menu.exec(QCursor::pos()); //显示菜单
|
||||
}
|
||||
|
||||
@ -2,21 +2,55 @@
|
||||
#define SINGLERELAY_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTextEdit>
|
||||
#include <QButtonGroup>
|
||||
#include <QPushButton>
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "singlerelay_data.h"
|
||||
#include <QStandardItemModel> //数据模型类
|
||||
#include <QTreeView>
|
||||
|
||||
namespace Ui {
|
||||
class SingleRelay;
|
||||
}
|
||||
|
||||
class SingleRelay : public QDialog
|
||||
{
|
||||
class SingleRelay : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SingleRelay(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit SingleRelay(int slot,int cardtype,QWidget *parent = nullptr);
|
||||
~SingleRelay();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void on_pushButton_cancel_clicked();
|
||||
void OnButtonGroup(QAbstractButton *);
|
||||
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void onComboBoxIndexChanged(int index);
|
||||
void slotDeleteItem();
|
||||
|
||||
void on_treeView_Relay_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
private:
|
||||
Ui::SingleRelay *ui;
|
||||
QButtonGroup * btnGroup_slot = nullptr;
|
||||
QListWidget *list_widget_available = nullptr;
|
||||
QTreeView *treeView_relay;
|
||||
QStandardItemModel *model_Relay;
|
||||
std::shared_ptr<SingleRelayData> relay_data = nullptr;
|
||||
int current_index;
|
||||
QMap<QString, QString> channelNameMap;
|
||||
|
||||
void Init();
|
||||
void buildTreeFromExpression(QTreeView *treeView, const QString &expr);
|
||||
ExprNode* parseExpression(const QString& expr, int& pos);
|
||||
QStandardItem* buildItemTree(ExprNode* node);
|
||||
void setExpressionToTreeView(QTreeView* treeView, const QString& expr);
|
||||
QString buildLogicExpression(QStandardItem *item);
|
||||
ExprValidationResult validateLogicExpression(const QString& expr);
|
||||
};
|
||||
|
||||
#endif // SINGLERELAY_H
|
||||
|
||||
327
singlerelay.ui
327
singlerelay.ui
@ -6,18 +6,18 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>943</width>
|
||||
<width>994</width>
|
||||
<height>569</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>单一继电器组态</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>360</y>
|
||||
<x>620</x>
|
||||
<y>20</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@ -26,7 +26,7 @@
|
||||
<string>告警驱动逻辑:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_10">
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
@ -39,57 +39,11 @@
|
||||
<string>确 定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>750</x>
|
||||
<y>535</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>NCT6100T</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>690</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>或(*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>380</y>
|
||||
<width>551</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
li.checked::marker { content: "\2612"; }
|
||||
</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.AppleSystemUIFont'; font-size:13pt;">S02C01P##NO</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>30</y>
|
||||
<x>230</x>
|
||||
<y>350</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@ -98,10 +52,13 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>可用的告警:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<x>420</x>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -111,36 +68,6 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>打 印...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>50</y>
|
||||
<width>301</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C01P##NO (Slot 2 Channel 1 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C02P##NO (Slot 2 Channel 2 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C03P##NO (Slot 2 Channel 3 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C04P##NO (Slot 2 Channel 4 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -153,7 +80,7 @@ li.checked::marker { content: "\2612"; }
|
||||
<property name="title">
|
||||
<string>继电器关联</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<widget class="QComboBox" name="comboBox_relay_ch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
@ -243,7 +170,7 @@ li.checked::marker { content: "\2612"; }
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="checkBox_active">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>26</x>
|
||||
@ -270,58 +197,6 @@ li.checked::marker { content: "\2612"; }
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>690</x>
|
||||
<y>270</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>113</x>
|
||||
<y>9</y>
|
||||
<width>31</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 13</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>与(*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>270</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>(</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -335,23 +210,13 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>继电器槽位:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>760</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_12">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>600</x>
|
||||
<x>520</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
@ -361,50 +226,11 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>帮 助</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<y>270</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CLR</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><---</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_13">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
@ -413,19 +239,6 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>取 消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>320</y>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>总告警信号</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -798,7 +611,7 @@ li.checked::marker { content: "\2612"; }
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_17">
|
||||
<widget class="QPushButton" name="pushButton_slot1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -812,12 +625,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_18">
|
||||
<widget class="QPushButton" name="pushButton_slot2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -831,12 +644,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_20">
|
||||
<widget class="QPushButton" name="pushButton_slot3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -850,12 +663,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_19">
|
||||
<widget class="QPushButton" name="pushButton_slot4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -869,12 +682,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_24">
|
||||
<widget class="QPushButton" name="pushButton_slot5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -888,12 +701,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_23">
|
||||
<widget class="QPushButton" name="pushButton_slot6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -907,12 +720,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_22">
|
||||
<widget class="QPushButton" name="pushButton_slot7">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -926,12 +739,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_21">
|
||||
<widget class="QPushButton" name="pushButton_slot8">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -945,12 +758,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_32">
|
||||
<widget class="QPushButton" name="pushButton_slot9">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -964,12 +777,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_31">
|
||||
<widget class="QPushButton" name="pushButton_slot10">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -983,12 +796,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_30">
|
||||
<widget class="QPushButton" name="pushButton_slot11">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1002,12 +815,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_27">
|
||||
<widget class="QPushButton" name="pushButton_slot12">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1021,12 +834,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_28">
|
||||
<widget class="QPushButton" name="pushButton_slot13">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1040,12 +853,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_25">
|
||||
<widget class="QPushButton" name="pushButton_slot14">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1059,12 +872,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_26">
|
||||
<widget class="QPushButton" name="pushButton_slot15">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1078,12 +891,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_29">
|
||||
<widget class="QPushButton" name="pushButton_slot16">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1097,7 +910,7 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1106,6 +919,42 @@ li.checked::marker { content: "\2612"; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_relay" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>40</y>
|
||||
<width>341</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_available" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>370</y>
|
||||
<width>391</width>
|
||||
<height>141</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_slot_no">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>10</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
4
singlerelay_data.cpp
Normal file
4
singlerelay_data.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "singlerelay_data.h"
|
||||
SingleRelayData::SingleRelayData(){
|
||||
|
||||
}
|
||||
11
singlerelay_data.h
Normal file
11
singlerelay_data.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef SINGLERELAY_DATA_H
|
||||
#define SINGLERELAY_DATA_H
|
||||
|
||||
#include "cardbase.h"
|
||||
class SingleRelayData : public CardBase {
|
||||
public:
|
||||
SingleRelayData();
|
||||
SingleRelayNOK single_relay[RELAY_COUNT];
|
||||
};
|
||||
|
||||
#endif // SINGLERELAY_DATA_H
|
||||
479
tachometer.cpp
479
tachometer.cpp
@ -7,269 +7,306 @@
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonArray>
|
||||
|
||||
Tachometer::Tachometer(int slot_no_,QWidget *parent)
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "tachometer_data.h"
|
||||
|
||||
Tachometer::Tachometer(int slot_no_,int cardtype, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::Tachometer)
|
||||
{
|
||||
, ui(new Ui::Tachometer) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
slot_no = slot_no_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_slot->setText(slot);
|
||||
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||
readJsonFile(filePath_tachometer);
|
||||
Init();
|
||||
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_1_clicked);
|
||||
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_2_clicked);
|
||||
connect(ui->radioButton_manual_threshold_3, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_3_clicked);
|
||||
connect(ui->radioButton_manual_threshold_4, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_4_clicked);
|
||||
}
|
||||
|
||||
Tachometer::~Tachometer()
|
||||
{
|
||||
|
||||
Tachometer::~Tachometer() {
|
||||
delete ui;
|
||||
}
|
||||
void Tachometer::readJsonFile(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
tachometer_variables[i].id = temp_obj["id"].toInt();
|
||||
tachometer_variables[i].active = temp_obj["active"].toBool();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
tachometer_variables[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
tachometer_variables[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
tachometer_variables[i].threshold = temp_obj["threshold"].toDouble();
|
||||
tachometer_variables[i].hysteresis = temp_obj["hysteresis"].toDouble();
|
||||
tachometer_variables[i].events_per_revolution = temp_obj["events_per_revolution"].toInt();
|
||||
tachometer_variables[i].record_output = temp_obj["record_output"].toString();
|
||||
tachometer_variables[i].two_ma_clamp = temp_obj["two_ma_clamp"].toBool();
|
||||
tachometer_variables[i].alert_latching = temp_obj["alert_latching"].toBool();
|
||||
tachometer_variables[i].overspeed_latching = temp_obj["overspeed_latching"].toBool();
|
||||
tachometer_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||
tachometer_variables[i].alert_response_time = temp_obj["alert_response_time"].toInt();
|
||||
tachometer_variables[i].danger_response_time = temp_obj["danger_response_time"].toInt();
|
||||
}
|
||||
|
||||
void Tachometer::on_manual_threshold_1_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
}
|
||||
void Tachometer::Init()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(tachometer_variables[i].id == 1){
|
||||
ui->checkBox_chan_1->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
|
||||
void Tachometer::on_manual_threshold_2_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
}
|
||||
|
||||
void Tachometer::on_manual_threshold_3_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
}
|
||||
|
||||
void Tachometer::on_manual_threshold_4_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
}
|
||||
|
||||
void Tachometer::UpdateData(std::shared_ptr<TachometerData> &speed_data) {
|
||||
speed_data->card_type_ = kCardSpeedSingle;
|
||||
speed_data->slot_ = slot_no;
|
||||
speed_data->version_ = 1;
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_1->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_1->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_1->value();
|
||||
if(ui->radioButton_automatic_threshold_1->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_1->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_1->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_1->isChecked();
|
||||
} else if (i + 1 == 2) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_2->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_2->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_2->value();
|
||||
if(ui->radioButton_automatic_threshold_2->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_2->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
|
||||
} else if (i + 1 == 3) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_3->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_3->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_3->value();
|
||||
if(ui->radioButton_automatic_threshold_3->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_3->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
|
||||
} else if (i + 1 == 4) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_4->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_4->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_4->value();
|
||||
if(ui->radioButton_automatic_threshold_4->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_4->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_4->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_4->isChecked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tachometer::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
std::shared_ptr<TachometerData> speed_data = std::make_shared<TachometerData>();
|
||||
speed_data->card_type_ = car_type;
|
||||
speed_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(speed_data);
|
||||
UpdateData(speed_data);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
ui->checkBox_chan_1->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_1->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_1->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_1->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_1->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_1->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_1->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_1->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->variables_[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_1->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_1->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_1->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_1->setCheckable(false);
|
||||
}
|
||||
if(tachometer_variables[i].id == 2){
|
||||
ui->checkBox_chan_2->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
}
|
||||
} else if (i + 1 == 2) {
|
||||
ui->checkBox_chan_2->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_2->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_2->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_2->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_2->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_2->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_2->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_2->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->variables_[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_2->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_2->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_2->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_2->setCheckable(false);
|
||||
if(tachometer_variables[i].normal_latching)
|
||||
ui->radioButton_normal_latching_2->setCheckable(true);
|
||||
else
|
||||
ui->radioButton_not_normal_latching_2->setCheckable(false);
|
||||
}
|
||||
if(tachometer_variables[i].id == 3){
|
||||
ui->checkBox_chan_3->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
}
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_chan_3->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_3->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_3->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_3->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_3->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_3->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_3->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_3->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->variables_[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_3->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_3->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_3->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_3->setCheckable(false);
|
||||
if(tachometer_variables[i].normal_latching)
|
||||
ui->radioButton_normal_latching_3->setCheckable(true);
|
||||
else
|
||||
ui->radioButton_not_normal_latching_3->setCheckable(false);
|
||||
}
|
||||
if(tachometer_variables[i].id == 4){
|
||||
ui->checkBox_chan_4->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
}
|
||||
} else if (i + 1 == 4) {
|
||||
ui->checkBox_chan_4->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_4->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_4->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||
ui->doubleSpinBox_threshold_4->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_4->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_4->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_4->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_4->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->variables_[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_4->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_4->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_4->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_4->setCheckable(false);
|
||||
if(tachometer_variables[i].normal_latching)
|
||||
ui->radioButton_normal_latching_4->setCheckable(true);
|
||||
else
|
||||
ui->radioButton_not_normal_latching_4->setCheckable(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tachometer::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(tachometer_variables[i].id == 1){
|
||||
tachometer_variables[i].active = ui->checkBox_chan_1->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_1->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_1->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_1->isChecked();
|
||||
}
|
||||
if(tachometer_variables[i].id == 2){
|
||||
tachometer_variables[i].active = ui->checkBox_chan_2->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_2->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
|
||||
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_2->isChecked();
|
||||
}
|
||||
if(tachometer_variables[i].id == 3){
|
||||
tachometer_variables[i].active = ui->checkBox_chan_3->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_3->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
|
||||
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_3->isChecked();
|
||||
}
|
||||
if(tachometer_variables[i].id == 4){
|
||||
tachometer_variables[i].active = ui->checkBox_chan_4->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_4->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_4->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_4->isChecked();
|
||||
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_4->isChecked();
|
||||
}
|
||||
}
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||
QFile file(filePath_tachometer);
|
||||
if(!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug() << "Could not open file for writing";
|
||||
void Tachometer::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << " should not be here";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj;
|
||||
QJsonArray chan_array;
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("id", tachometer_variables[i].id);
|
||||
temp_obj.insert("active", tachometer_variables[i].active);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(tachometer_variables[i].normal_voltage_low);
|
||||
voltage_range_array.append(tachometer_variables[i].normal_voltage_high);
|
||||
temp_obj.insert("normal_voltage_range", voltage_range_array);
|
||||
temp_obj.insert("threshold", tachometer_variables[i].threshold);
|
||||
temp_obj.insert("hysteresis", tachometer_variables[i].hysteresis);
|
||||
temp_obj.insert("events_per_revolution", tachometer_variables[i].events_per_revolution);
|
||||
temp_obj.insert("record_output", tachometer_variables[i].record_output);
|
||||
temp_obj.insert("two_ma_clamp", tachometer_variables[i].two_ma_clamp);
|
||||
temp_obj.insert("alert_latching", tachometer_variables[i].alert_latching);
|
||||
temp_obj.insert("overspeed_latching", tachometer_variables[i].overspeed_latching);
|
||||
temp_obj.insert("normal_latching", tachometer_variables[i].normal_latching);
|
||||
temp_obj.insert("alert_response_time", tachometer_variables[i].alert_response_time);
|
||||
temp_obj.insert("danger_response_time", tachometer_variables[i].danger_response_time);
|
||||
chan_array.append(temp_obj);
|
||||
}
|
||||
json_obj.insert("chan", chan_array);
|
||||
json_obj.insert("version",1);
|
||||
json_obj.insert("slot",slot_no);
|
||||
json_obj.insert("card_type",2);
|
||||
QJsonDocument json_doc;
|
||||
json_doc.setObject(json_obj);
|
||||
QByteArray byte_array = json_doc.toJson();
|
||||
file.write(byte_array);
|
||||
file.close();
|
||||
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
UpdateData(speed_data);
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Tachometer::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Tachometer::on_radioButton_automatic_threshold_1_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
24
tachometer.h
24
tachometer.h
@ -3,27 +3,35 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "tachometer_data.h"
|
||||
namespace Ui {
|
||||
class Tachometer;
|
||||
}
|
||||
|
||||
class Tachometer : public QDialog
|
||||
{
|
||||
class Tachometer : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Tachometer(int slot_no_,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Tachometer(int slot_no_,int cardtype, QWidget *parent = nullptr);
|
||||
~Tachometer();
|
||||
int slot_no;
|
||||
private slots:
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_manual_threshold_1_clicked(bool checked);
|
||||
void on_manual_threshold_2_clicked(bool checked);
|
||||
void on_manual_threshold_3_clicked(bool checked);
|
||||
void on_manual_threshold_4_clicked(bool checked);
|
||||
void on_radioButton_automatic_threshold_1_clicked();
|
||||
|
||||
private:
|
||||
Ui::Tachometer *ui;
|
||||
void UpdateData(std::shared_ptr<TachometerData> &speed_data);
|
||||
// Tachometer_Variables tachometer_variables[4];
|
||||
|
||||
Tachometer_Variables tachometer_variables[4];
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
// void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
657
tachometer.ui
657
tachometer.ui
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>转速配置</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget_body" native="true">
|
||||
<property name="geometry">
|
||||
@ -23,9 +23,12 @@
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<x>420</x>
|
||||
<y>550</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -36,6 +39,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_chan_1">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
@ -51,10 +57,10 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<x>260</x>
|
||||
<y>550</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -80,7 +86,7 @@
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>630</x>
|
||||
<x>610</x>
|
||||
<y>550</y>
|
||||
<width>91</width>
|
||||
<height>32</height>
|
||||
@ -103,13 +109,16 @@
|
||||
<string>通道3激活</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>530</x>
|
||||
<x>510</x>
|
||||
<y>550</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
@ -122,7 +131,7 @@
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<x>130</x>
|
||||
<y>550</y>
|
||||
<width>101</width>
|
||||
<height>32</height>
|
||||
@ -145,7 +154,7 @@
|
||||
<string>通道4激活</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
@ -197,6 +206,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-18.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_1">
|
||||
<property name="geometry">
|
||||
@ -219,6 +240,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_50">
|
||||
<property name="geometry">
|
||||
@ -314,7 +347,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
@ -405,6 +438,15 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
@ -460,8 +502,11 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -579,7 +624,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -587,14 +632,14 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>10</y>
|
||||
<x>480</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
@ -675,6 +720,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_1">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -691,6 +739,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_1">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -707,53 +758,82 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>通道 2</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>正常模式</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_normal_latching_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 锁存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_not_normal_latching_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非锁存</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_13">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -787,6 +867,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-18.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_2">
|
||||
<property name="geometry">
|
||||
@ -809,6 +901,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_52">
|
||||
<property name="geometry">
|
||||
@ -899,7 +1003,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -907,7 +1011,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_31">
|
||||
@ -920,7 +1024,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
@ -1105,6 +1209,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1121,6 +1228,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1219,6 +1329,15 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="geometry">
|
||||
@ -1274,11 +1393,85 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@ -1317,6 +1510,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-18.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_3">
|
||||
<property name="geometry">
|
||||
@ -1339,6 +1544,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_54">
|
||||
<property name="geometry">
|
||||
@ -1429,7 +1646,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1437,7 +1654,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_39">
|
||||
@ -1450,7 +1667,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_22">
|
||||
@ -1596,48 +1813,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>正常模式</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_normal_latching_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 锁存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_not_normal_latching_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非锁存</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_27">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -1677,6 +1852,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1693,6 +1871,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1791,6 +1972,15 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="geometry">
|
||||
@ -1846,11 +2036,85 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_46">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_47">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
@ -1889,6 +2153,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-18.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_4">
|
||||
<property name="geometry">
|
||||
@ -1911,6 +2187,21 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_56">
|
||||
<property name="geometry">
|
||||
@ -1993,7 +2284,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_events_per_revolution_4">
|
||||
@ -2001,7 +2292,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2009,7 +2300,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_45">
|
||||
@ -2125,7 +2416,7 @@
|
||||
<widget class="QGroupBox" name="groupBox_34">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<x>480</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>91</height>
|
||||
@ -2168,48 +2459,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_35">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>正常模式</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_normal_latching_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 锁存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_not_normal_latching_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非锁存</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_36">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -2249,6 +2498,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -2265,6 +2517,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -2363,6 +2618,15 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_41">
|
||||
<property name="geometry">
|
||||
@ -2418,11 +2682,85 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_35">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_49">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_chan_2">
|
||||
@ -2438,20 +2776,7 @@
|
||||
<string>通道2激活</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>550</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
@ -2499,7 +2824,7 @@
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup_3"/>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user