Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
taskbus
提交
9bb1baec
taskbus
项目概览
colorEagleStdio
/
taskbus
通知
159
Star
11
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
taskbus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9bb1baec
编写于
4月 26, 2022
作者:
M
manjaro-xfce
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加入控制面板。现在各种参数可以通过发布-更新机制,在运行时进行修改。这种功能用于实时的频率、增益调整。
上级
64d5d10c
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
841 addition
and
13 deletion
+841
-13
modules/CMakeLists.txt
modules/CMakeLists.txt
+1
-1
modules/modules.pro
modules/modules.pro
+1
-0
modules/pannel/CMakeLists.txt
modules/pannel/CMakeLists.txt
+2
-0
modules/pannel/control_pannel/CMakeLists.txt
modules/pannel/control_pannel/CMakeLists.txt
+51
-0
modules/pannel/control_pannel/control_pannel.exe.json
modules/pannel/control_pannel/control_pannel.exe.json
+13
-0
modules/pannel/control_pannel/control_pannel.pro
modules/pannel/control_pannel/control_pannel.pro
+38
-0
modules/pannel/control_pannel/control_pannel.qrc
modules/pannel/control_pannel/control_pannel.qrc
+5
-0
modules/pannel/control_pannel/dialogpannel.cpp
modules/pannel/control_pannel/dialogpannel.cpp
+215
-0
modules/pannel/control_pannel/dialogpannel.h
modules/pannel/control_pannel/dialogpannel.h
+45
-0
modules/pannel/control_pannel/dialogpannel.ui
modules/pannel/control_pannel/dialogpannel.ui
+36
-0
modules/pannel/control_pannel/listen_thread.cpp
modules/pannel/control_pannel/listen_thread.cpp
+54
-0
modules/pannel/control_pannel/listen_thread.h
modules/pannel/control_pannel/listen_thread.h
+21
-0
modules/pannel/control_pannel/main.cpp
modules/pannel/control_pannel/main.cpp
+84
-0
modules/uhd/uhd_usrp_continous/uhd_io_continous.cpp
modules/uhd/uhd_usrp_continous/uhd_io_continous.cpp
+102
-1
modules/uhd/uhd_usrp_io/main.cpp
modules/uhd/uhd_usrp_io/main.cpp
+2
-2
modules/uhd/uhd_usrp_io/uhd_io.cpp
modules/uhd/uhd_usrp_io/uhd_io.cpp
+104
-2
projects/usrp_fm_emitter.tbj
projects/usrp_fm_emitter.tbj
+20
-1
projects/usrp_fm_reciever.tbj
projects/usrp_fm_reciever.tbj
+20
-1
tb_interface/tb_interface.h
tb_interface/tb_interface.h
+27
-5
未找到文件。
modules/CMakeLists.txt
浏览文件 @
9bb1baec
...
...
@@ -8,7 +8,7 @@ add_subdirectory(sinks)
add_subdirectory
(
sources
)
add_subdirectory
(
transforms
)
add_subdirectory
(
warppers
)
add_subdirectory
(
pannel
)
if
(
TB_UHD
)
add_subdirectory
(
uhd
)
endif
()
modules/modules.pro
浏览文件 @
9bb1baec
...
...
@@ -2,6 +2,7 @@ TEMPLATE = subdirs
#
main
framework
project
SUBDIRS
+=
\
pannel
/
control_pannel
\
sources
/
source_plutosdr
\
transforms
/
transform_fft
\
transforms
/
mod_fm
\
...
...
modules/pannel/CMakeLists.txt
0 → 100644
浏览文件 @
9bb1baec
cmake_minimum_required
(
VERSION 3.5
)
add_subdirectory
(
control_pannel
)
modules/pannel/control_pannel/CMakeLists.txt
0 → 100644
浏览文件 @
9bb1baec
cmake_minimum_required
(
VERSION 3.5
)
set
(
CMAKE_INCLUDE_CURRENT_DIR ON
)
set
(
CMAKE_AUTOUIC ON
)
set
(
CMAKE_AUTOMOC ON
)
set
(
CMAKE_AUTORCC ON
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
find_package
(
QT NAMES Qt6 COMPONENTS Core Widgets REQUIRED
)
find_package
(
Qt
${
QT_VERSION_MAJOR
}
COMPONENTS Core Widgets REQUIRED
)
include_directories
(
${
TASKBUS_INTERFACEDIR
}
)
set
(
PRJ_HEADERS
dialogpannel.h
listen_thread.h
)
set
(
PRJ_SOURCES
main.cpp
dialogpannel.cpp
listen_thread.cpp
)
set
(
PRJ_FORMS
dialogpannel.ui
)
set
(
PRJ_RESOURCES
control_pannel.qrc
)
#############Target======================
qt_add_executable
(
control_pannel
MANUAL_FINALIZATION
${
PRJ_HEADERS
}
${
PRJ_SOURCES
}
${
PRJ_FORMS
}
${
PRJ_RESOURCES
}
)
target_link_libraries
(
control_pannel PRIVATE
Qt
${
QT_VERSION_MAJOR
}
::Widgets
)
set_target_properties
(
control_pannel PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER taskBus.modules.control_pannel
MACOSX_BUNDLE_BUNDLE_VERSION
${
PROJECT_VERSION
}
MACOSX_BUNDLE_SHORT_VERSION_STRING
${
PROJECT_VERSION_MAJOR
}
.
${
PROJECT_VERSION_MINOR
}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
qt_finalize_executable
(
control_pannel
)
modules/pannel/control_pannel/control_pannel.exe.json
0 → 100644
浏览文件 @
9bb1baec
{
"control_pannel"
:{
"name"
:
"CtrlPannel"
,
"version"
:
"1,1,0"
,
"parameters"
:{
},
"input_subjects"
:{
},
"output_subjects"
:{
}
}
}
modules/pannel/control_pannel/control_pannel.pro
0 → 100644
浏览文件 @
9bb1baec
#-------------------------------------------------
#
#
Project
created
by
QtCreator
2018
-
07
-
27
T16
:
02
:
44
#
#-------------------------------------------------
QT
+=
core
gui
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
INCLUDEPATH
+=
..
/../../
tb_interface
DESTDIR
=
$$
OUT_PWD
/../../../
bin
/
modules
TARGET
=
control_pannel
TEMPLATE
=
app
#
You
can
also
make
your
code
fail
to
compile
if
you
use
deprecated
APIs
.
#
In
order
to
do
so
,
uncomment
the
following
line
.
#
You
can
also
select
to
disable
deprecated
APIs
only
up
to
a
certain
version
of
Qt
.
#
DEFINES
+=
QT_DISABLE_DEPRECATED_BEFORE
=
0
x060000
#
disables
all
the
APIs
deprecated
before
Qt
6.0
.
0
INCLUDEPATH
+=
"../../../tb_interface"
SOURCES
+=
\
main
.
cpp
\
dialogpannel
.
cpp
\
listen_thread
.
cpp
HEADERS
+=
\
dialogpannel
.
h
\
listen_thread
.
h
FORMS
+=
\
dialogpannel
.
ui
DISTFILES
+=
\
control_pannel
.
exe
.
json
\
control_pannel
.
zh_CN
.
json
RESOURCES
+=
\
control_pannel
.
qrc
modules/pannel/control_pannel/control_pannel.qrc
0 → 100644
浏览文件 @
9bb1baec
<RCC>
<qresource prefix="/json">
<file>control_pannel.exe.json</file>
</qresource>
</RCC>
modules/pannel/control_pannel/dialogpannel.cpp
0 → 100644
浏览文件 @
9bb1baec
#
include
"dialogpannel.h"
#include "ui_dialogpannel.h"
#include "tb_interface.h"
#include <algorithm>
#include <QSpinBox>
#include <QLineEdit>
#include <QDoubleSpinBox>
#include <QScrollArea>
#include <QComboBox>
#include <QLabel>
#include <QGridLayout>
DialogPannel
::
DialogPannel
(
const
TASKBUS
::
cmdlineParser
*
ps
,
QWidget
*
parent
)
:
QDialog
(
parent
),
ui
(
new
Ui
::
DialogPannel
),
m_log
(
new
QStandardItemModel
(
this
)),
m_pCmd
(
ps
),
m_rthread
(
new
reciv_thread
(
ps
,
this
))
{
ui
->
setupUi
(
this
);
ui
->
listView_log
->
setModel
(
m_log
);
connect
(
m_rthread
,
&
reciv_thread
::
sig_quit
,
this
,
&
DialogPannel
::
close
);
connect
(
m_rthread
,
&
reciv_thread
::
new_message
,
this
,
&
DialogPannel
::
deal_message
,
Qt
::
QueuedConnection
);
Qt
::
WindowFlags
flg
=
windowFlags
();
flg
|=
Qt
::
WindowMinMaxButtonsHint
;
setWindowFlags
(
flg
);
m_rthread
->
start
();
}
DialogPannel
::~
DialogPannel
()
{
m_rthread
->
terminate
();
m_rthread
->
wait
();
delete
ui
;
}
void
DialogPannel
::
deal_message
(
QString
message
)
{
m_log
->
appendRow
(
new
QStandardItem
(
message
));
if
(
m_log
->
rowCount
()
>
256
)
m_log
->
removeRows
(
0
,
m_log
->
rowCount
()
-
256
);
std
::
map
<
std
::
string
,
std
::
string
>
cmd
=
TASKBUS
::
string_to_map
(
message
.
toStdString
());
if
(
cmd
[
"function"
]
==
std
::
string
(
"handle_annouce"
))
AddHandle
(
cmd
);
else
if
(
cmd
[
"function"
]
==
std
::
string
(
"handle_set"
))
{
}
}
void
DialogPannel
::
AddHandle
(
std
::
map
<
std
::
string
,
std
::
string
>
&
cmd
)
{
const
QString
source
=
QString
::
fromStdString
(
cmd
[
"source"
]).
trimmed
();
const
QString
handle
=
QString
::
fromStdString
(
cmd
[
"handle"
]).
trimmed
();
const
QString
label
=
QString
::
fromStdString
(
cmd
[
"label"
]).
trimmed
();
const
QString
type
=
QString
::
fromStdString
(
cmd
[
"type"
]).
trimmed
();
const
QString
range
=
QString
::
fromStdString
(
cmd
[
"range"
]).
trimmed
();
const
QString
value
=
QString
::
fromStdString
(
cmd
[
"value"
]).
trimmed
();
const
QString
step
=
QString
::
fromStdString
(
cmd
[
"step"
]).
trimmed
();
const
QString
decimal
=
QString
::
fromStdString
(
cmd
[
"decimal"
]).
trimmed
();
if
(
source
.
length
()
<
1
||
handle
.
length
()
<
1
)
return
;
if
(
!
m_tabs
.
contains
(
source
))
{
QScrollArea
*
area
=
new
QScrollArea
(
this
);
QGridLayout
*
grid_layout
=
new
QGridLayout
(
this
);
area
->
setLayout
(
grid_layout
);
ui
->
tabWidget
->
addTab
(
area
,
QString
(
"source=%1"
).
arg
(
source
));
m_tabs
[
source
]
=
grid_layout
;
}
QGridLayout
*
grid_layout
=
m_tabs
[
source
];
const
int
nRows
=
grid_layout
->
rowCount
();
QWidget
*
w
=
0
;
if
(
type
==
"int"
)
{
QStringList
rgs
=
range
.
split
(
":"
,
Qt
::
SkipEmptyParts
);
long
long
n_min
=
0
,
n_max
=
0
;
if
(
rgs
.
size
()
==
2
)
{
n_min
=
rgs
.
first
().
toLongLong
();
n_max
=
rgs
.
last
().
toLongLong
();
}
//Create
if
(
n_min
<
n_max
)
{
QDoubleSpinBox
*
s
=
new
QDoubleSpinBox
(
this
);
s
->
setRange
(
n_min
,
n_max
);
s
->
setValue
(
value
.
toInt
());
s
->
setDecimals
(
0
);
s
->
setSingleStep
(
step
.
toInt
()
==
0
?
1
:
step
.
toInt
());
w
=
s
;
connect
(
s
,
&
QDoubleSpinBox
::
valueChanged
,[
=
](
double
newv
)
->
void
{
QString
nv
=
QString
(
"%1"
).
arg
((
long
long
)
newv
);
HandleChanged
(
source
,
handle
,
nv
);
});
m_handles
[
source
][
handle
]
=
[
=
](
QString
newv
)
->
void
{
long
long
nv
=
newv
.
toLongLong
();
if
(
nv
>=
s
->
minimum
()
&&
nv
<=
s
->
maximum
())
s
->
setValue
(
nv
);
};
}
else
{
QLineEdit
*
v
=
new
QLineEdit
(
this
);
v
->
setText
(
value
);
w
=
v
;
connect
(
v
,
&
QLineEdit
::
returnPressed
,[
=
]()
->
void
{
HandleChanged
(
source
,
handle
,
v
->
text
());
});
m_handles
[
source
][
handle
]
=
[
=
](
QString
newv
)
->
void
{
v
->
setText
(
newv
);
};
}
}
else
if
(
type
==
"double"
)
{
QStringList
rgs
=
range
.
split
(
":"
,
Qt
::
SkipEmptyParts
);
double
n_min
=
0
,
n_max
=
0
;
if
(
rgs
.
size
()
==
2
)
{
n_min
=
rgs
.
first
().
toDouble
();
n_max
=
rgs
.
last
().
toDouble
();
}
//Create
if
(
n_min
<
n_max
)
{
QDoubleSpinBox
*
s
=
new
QDoubleSpinBox
(
this
);
s
->
setRange
(
n_min
,
n_max
);
s
->
setValue
(
value
.
toDouble
());
s
->
setDecimals
(
decimal
.
toInt
());
s
->
setSingleStep
(
step
.
toInt
()
==
0
?
1
:
step
.
toInt
());
w
=
s
;
connect
(
s
,
&
QDoubleSpinBox
::
valueChanged
,[
=
](
double
newv
)
->
void
{
QString
nv
=
QString
(
"%1"
).
arg
(
newv
,
0
,
'f'
,
2
);
HandleChanged
(
source
,
handle
,
nv
);
});
m_handles
[
source
][
handle
]
=
[
=
](
QString
newv
)
->
void
{
double
nv
=
newv
.
toInt
();
if
(
nv
>=
s
->
minimum
()
&&
nv
<=
s
->
maximum
())
s
->
setValue
(
nv
);
};
}
else
{
QLineEdit
*
v
=
new
QLineEdit
(
this
);
v
->
setText
(
value
);
w
=
v
;
connect
(
v
,
&
QLineEdit
::
returnPressed
,[
=
]()
->
void
{
HandleChanged
(
source
,
handle
,
v
->
text
());
});
m_handles
[
source
][
handle
]
=
[
=
](
QString
newv
)
->
void
{
v
->
setText
(
newv
);
};
}
}
else
{
QStringList
rgs
=
range
.
split
(
","
,
Qt
::
SkipEmptyParts
);
if
(
rgs
.
size
())
{
QComboBox
*
c
=
new
QComboBox
(
this
);
QStandardItemModel
*
m
=
new
QStandardItemModel
(
this
);
c
->
setModel
(
m
);
foreach
(
QString
s
,
rgs
)
m
->
appendRow
(
new
QStandardItem
(
s
));
c
->
setCurrentText
(
value
);
w
=
c
;
connect
(
c
,
&
QComboBox
::
currentIndexChanged
,[
=
](
int
idx
)
->
void
{
if
(
idx
<
0
||
idx
>
m
->
rowCount
())
HandleChanged
(
source
,
handle
,
""
);
else
HandleChanged
(
source
,
handle
,
m
->
data
(
m
->
index
(
idx
,
0
)).
toString
());
});
m_handles
[
source
][
handle
]
=
[
=
](
QString
newv
)
->
void
{
c
->
setCurrentText
(
newv
);
};
}
else
{
QLineEdit
*
v
=
new
QLineEdit
(
this
);
v
->
setText
(
value
);
w
=
v
;
connect
(
v
,
&
QLineEdit
::
returnPressed
,[
=
]()
->
void
{
HandleChanged
(
source
,
handle
,
v
->
text
());
});
m_handles
[
source
][
handle
]
=
[
=
](
QString
newv
)
->
void
{
v
->
setText
(
newv
);
};
}
}
m_ctrls
[
source
][
handle
]
=
w
;
QLabel
*
lb
=
new
QLabel
(
this
);
lb
->
setText
(
handle
);
if
(
label
.
length
())
lb
->
setText
(
label
);
grid_layout
->
addWidget
(
lb
,
nRows
,
0
);
grid_layout
->
addWidget
(
w
,
nRows
,
1
);
}
void
DialogPannel
::
HandleChanged
(
QString
source
,
QString
handle
,
QString
value
)
{
QString
cmd
=
QString
(
"function=handle_set;source=%1;destin=%2;handle=%3;value=%4;"
)
.
arg
(
m_pCmd
->
toInt
(
"instance"
,
0
))
.
arg
(
source
)
.
arg
(
handle
)
.
arg
(
value
)
;
QByteArray
arr
=
cmd
.
toUtf8
();
TASKBUS
::
push_subject
(
TB_SUBJECT_CMD
,
0
,
arr
.
size
(),
(
const
unsigned
char
*
)
arr
.
constData
()
);
}
modules/pannel/control_pannel/dialogpannel.h
0 → 100644
浏览文件 @
9bb1baec
#
ifndef
DIALOGPANNEL_H
#define DIALOGPANNEL_H
#include <QDialog>
#include <QByteArray>
#include <QMap>
#include <QVector>
#include <QStandardItemModel>
#include <functional>
#include "listen_thread.h"
#include "cmdlineparser.h"
class
QGridLayout
;
namespace
Ui
{
class
DialogPannel
;
}
class
DialogPannel
:
public
QDialog
{
Q_OBJECT
public:
explicit
DialogPannel
(
const
TASKBUS
::
cmdlineParser
*
ps
,
QWidget
*
parent
=
0
);
~
DialogPannel
();
private:
Ui
::
DialogPannel
*
ui
;
QStandardItemModel
*
m_log
;
const
TASKBUS
::
cmdlineParser
*
m_pCmd
=
nullptr
;
reciv_thread
*
m_rthread
=
nullptr
;
protected:
//Source, tabs
QMap
<
QString
,
QGridLayout
*
>
m_tabs
;
//Source ,handel,Widgets
QMap
<
QString
,
QMap
<
QString
,
QWidget
*
>
>
m_ctrls
;
//Source ,handel,Handles
QMap
<
QString
,
QMap
<
QString
,
std
::
function
<
void
(
QString
)
>
>
>
m_handles
;
private
slots
:
void
deal_message
(
QString
);
private:
void
AddHandle
(
std
::
map
<
std
::
string
,
std
::
string
>
&
cmd
);
void
HandleChanged
(
QString
source
,
QString
handle
,
QString
value
);
};
#endif // DIALOGPANNEL_H
modules/pannel/control_pannel/dialogpannel.ui
0 → 100644
浏览文件 @
9bb1baec
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
DialogPannel
</class>
<widget
class=
"QDialog"
name=
"DialogPannel"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
495
</width>
<height>
265
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Taskbus Control Pannel
</string>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QTabWidget"
name=
"tabWidget"
>
<widget
class=
"QWidget"
name=
"monitor"
>
<attribute
name=
"title"
>
<string>
Monitor
</string>
</attribute>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QListView"
name=
"listView_log"
/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault
spacing=
"6"
margin=
"11"
/>
<resources/>
<connections/>
</ui>
modules/pannel/control_pannel/listen_thread.cpp
0 → 100644
浏览文件 @
9bb1baec
#
include
"listen_thread.h"
#include "tb_interface.h"
#include <QByteArray>
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QDateTime>
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#endif
reciv_thread
::
reciv_thread
(
const
TASKBUS
::
cmdlineParser
*
pCmd
,
QObject
*
parent
)
:
QThread
(
parent
)
,
m_pCmd
(
pCmd
)
{
}
void
reciv_thread
::
run
()
{
using
namespace
TASKBUS
;
bool
bfinished
=
false
;
QDateTime
dtmLastCmt
=
QDateTime
::
currentDateTime
();
while
(
false
==
bfinished
)
{
subject_package_header
header
;
std
::
vector
<
unsigned
char
>
packagedta
=
pull_subject
(
&
header
);
if
(
false
==
is_valid_header
(
header
))
{
continue
;
}
if
(
is_control_subject
(
header
)
&&
packagedta
.
size
())
{
//收到命令进程退出的广播消息,退出
if
(
strstr
(
control_subject
(
header
,
packagedta
).
c_str
(),
"function=quit;"
))
{
bfinished
=
true
;
qDebug
()
<<
"Quit!"
;
emit
sig_quit
();
}
else
{
QByteArray
arr
((
char
*
)
packagedta
.
data
(),
packagedta
.
size
());
emit
new_message
(
QString
::
fromUtf8
(
arr
));
}
}
else
{
}
}
return
;
}
modules/pannel/control_pannel/listen_thread.h
0 → 100644
浏览文件 @
9bb1baec
#ifndef LISTENTHREAD_H
#define LISTENTHREAD_H
#include <QByteArray>
#include <QObject>
#include <QThread>
#include "cmdlineparser.h"
class
reciv_thread
:
public
QThread
{
Q_OBJECT
public:
explicit
reciv_thread
(
const
TASKBUS
::
cmdlineParser
*
m_pCmd
,
QObject
*
parent
);
void
run
()
override
;
signals:
void
new_message
(
QString
arr
);
void
err_message
(
QString
err
);
void
sig_quit
();
private:
const
TASKBUS
::
cmdlineParser
*
m_pCmd
=
nullptr
;
};
#endif
modules/pannel/control_pannel/main.cpp
0 → 100644
浏览文件 @
9bb1baec
#include "dialogpannel.h"
#include <QApplication>
#include <QTextStream>
#include "cmdlineparser.h"
#include "tb_interface.h"
#include <QFile>
/*! TASKBUS控制面板
* TASKBUS的模块可以通过广播,发布自己可以配置的参数。格式:
* 广播专题=0xffffffffu,也就是 TB_SUBJECT_CMD
* 通路:0
* 内容:
* function=handle_annouce;
* source=进程的instance_id
* //所有模块,或者可以填写pannel模块的instance_id
* destin=0;
* handle=变量名;
* label=控件的名字,如果不提供,就是handel.
* type=[int/double/string];
* step=单步;
* decimal=小数位数;
* //范围,不提供,则创建的是文本框
* range=min:max;/range=a,b,c,d,...;
* value=当前值;
* ==============================================
* 本模块收到这样的声明,会为这个请求创建一个控件。
* 当控件的值被修改时,向对应模块发送消息
* function=handle_set;
* source=pannel进程的instance_id;
* destin=handle进程的instance_id;
* handle=变量名;
* value=当前值;
* ==============================================
* 当handle模块的变量发生改变后,可以更新本模块的显示
* function=handle_set;
* source=handle进程的instance_id;
* destin=pannel进程的instance_id;
* handle=变量名;
* value=当前值;
*
*/
using
namespace
TASKBUS
;
//#define OFFLINEDEBUG
int
main
(
int
argc
,
char
*
argv
[])
{
QApplication
a
(
argc
,
argv
);
init_client
();
#ifdef OFFLINEDEBUG
FILE
*
old_stdin
,
*
old_stdout
;
auto
ars
=
debug
(
"/home/user/codes/build-taskbus-qt6-Debug/bin/debug/pid25106/"
,
&
old_stdin
,
&
old_stdout
);
const
cmdlineParser
args
(
ars
);
#else
const
cmdlineParser
args
(
argc
,
argv
);
#endif
int
ret
=
0
;
//每个模块要响应 --information参数,打印自己的功能定义字符串。或者提供一个json文件。
if
(
args
.
contains
(
"information"
))
{
QFile
fp
(
":/json/control_pannel.exe.json"
);
fp
.
open
(
QIODevice
::
ReadOnly
);
if
(
fp
.
isOpen
())
{
QByteArray
arr
=
fp
.
readAll
();
arr
.
push_back
(
'\0'
);
puts
(
arr
.
constData
());
fflush
(
stdout
);
}
ret
=
-
1
;
}
else
{
DialogPannel
w
(
&
args
);
w
.
show
();
if
(
args
.
toInt
(
"hide_window"
,
0
)
!=
0
)
w
.
hide
();
ret
=
a
.
exec
();
}
return
ret
;
}
modules/uhd/uhd_usrp_continous/uhd_io_continous.cpp
浏览文件 @
9bb1baec
...
...
@@ -27,7 +27,7 @@ void sigint_handler(int code){
(
void
)
code
;
stop_signal_called
=
true
;
}
void
cmd_dealing
(
uhd_usrp_handle
usrp
,
std
::
vector
<
unsigned
char
>
&
cmd
);
static
char
error_string
[
512
];
int
do_iio
(
const
cmdlineParser
&
args
)
{
...
...
@@ -138,6 +138,16 @@ int do_iio(const cmdlineParser & args)
uhd_usrp_set_rx_agc
(
usrp
,
true
,
rx_channels
[
ch
]);
uhd_usrp_set_rx_dc_offset_enabled
(
usrp
,
true
,
rx_channels
[
ch
]);
}
else
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"rxgain_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
rx_gain
[
ch
]).
toStdString
(),
QString
(
"rxgain_%1"
).
arg
(
ch
).
toStdString
(),
"int"
,
"0:100"
);
// Set frequency
// Create other necessary structs
uhd_tune_request_t
rx_tune_request
=
...
...
@@ -156,6 +166,15 @@ int do_iio(const cmdlineParser & args)
// See what frequency actually isrx_streamer
UHD_DO
(
uhd_usrp_get_rx_freq
(
usrp
,
rx_channels
[
ch
],
&
rx_freq
[
ch
]));
fprintf
(
stderr
,
"Actual RX frequency: %lf MHz...
\n
"
,
rx_freq
[
ch
]
/
1e6
);
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"rxfreq_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
rx_freq
[
ch
]).
toStdString
(),
QString
(
"rxfreq_%1"
).
arg
(
ch
).
toStdString
(),
"double"
,
"0:6000000000"
,
"100000"
,
"0"
);
fprintf
(
stderr
,
"Setting RX Bandwidth: %lf MHz...
\n
"
,
rx_bw
[
ch
]
/
1e6
);
UHD_DO
(
uhd_usrp_set_rx_bandwidth
(
usrp
,
rx_bw
[
ch
],
rx_channels
[
ch
]));
...
...
@@ -191,6 +210,15 @@ int do_iio(const cmdlineParser & args)
// See what gain actually is
UHD_DO
(
uhd_usrp_get_tx_gain
(
usrp
,
tx_channels
[
ch
],
""
,
&
tx_gain
[
ch
]));
fprintf
(
stderr
,
"Actual TX Gain: %lf...
\n
"
,
tx_gain
[
ch
]);
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"txgain_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
tx_gain
[
ch
]).
toStdString
(),
QString
(
"txgain_%1"
).
arg
(
ch
).
toStdString
(),
"int"
,
"0:100"
);
// Create other necessary structs for TX
uhd_tune_request_t
tx_tune_request
=
{
/*.target_freq = */
tx_freq
[
ch
],
...
...
@@ -208,6 +236,15 @@ int do_iio(const cmdlineParser & args)
// See what frequency actually is
UHD_DO
(
uhd_usrp_get_tx_freq
(
usrp
,
tx_channels
[
ch
],
&
tx_freq
[
ch
]));
fprintf
(
stderr
,
"Actual TX frequency: %f MHz...
\n
"
,
tx_freq
[
ch
]
/
1e6
);
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"txfreq_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
tx_freq
[
ch
]).
toStdString
(),
QString
(
"txfreq_%1"
).
arg
(
ch
).
toStdString
(),
"double"
,
"0:6000000000"
,
"100000"
,
"0"
);
//Band
fprintf
(
stderr
,
"Setting TX Bandwidth: %f MHz...
\n
"
,
tx_bw
[
ch
]
/
1e6
);
...
...
@@ -399,6 +436,8 @@ int do_iio(const cmdlineParser & args)
fflush
(
stderr
);
stop_signal_called
=
true
;
}
else
cmd_dealing
(
usrp
,
packagedta
);
}
else
{
...
...
@@ -536,3 +575,65 @@ int do_iio(const cmdlineParser & args)
fflush
(
stderr
);
return
return_code
;
}
void
cmd_dealing
(
uhd_usrp_handle
usrp
,
std
::
vector
<
unsigned
char
>
&
cmd
)
{
std
::
map
<
std
::
string
,
std
::
string
>
mcmd
=
TASKBUS
::
ctrlpackage_to_map
(
cmd
);
if
(
mcmd
[
"function"
]
==
"handle_set"
)
{
if
(
mcmd
[
"handle"
].
find
(
"rxgain_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
int
gain
=
atoi
(
mcmd
[
"value"
].
c_str
());
uhd_usrp_set_rx_gain
(
usrp
,
gain
,
channel
,
""
);
double
dgain
=
0
;
uhd_usrp_get_rx_gain
(
usrp
,
channel
,
""
,
&
dgain
);
fprintf
(
stderr
,
"Actual RX Gain: %lf...
\n
"
,
dgain
);
}
else
if
(
mcmd
[
"handle"
].
find
(
"txgain_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
int
gain
=
atoi
(
mcmd
[
"value"
].
c_str
());
uhd_usrp_set_tx_gain
(
usrp
,
gain
,
channel
,
""
);
double
dgain
=
0
;
uhd_usrp_get_tx_gain
(
usrp
,
channel
,
""
,
&
dgain
);
fprintf
(
stderr
,
"Actual TX Gain: %lf...
\n
"
,
dgain
);
}
else
if
(
mcmd
[
"handle"
].
find
(
"rxfreq_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
double
freq
=
atof
(
mcmd
[
"value"
].
c_str
());
uhd_tune_request_t
rx_tune_request
=
{
/*.target_freq = */
freq
,
/*.rf_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.rf_freq = */
0
,
/*.dsp_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.dsp_freq = */
0
,
/*.args = */
0
};
uhd_tune_result_t
rx_tune_result
;
fprintf
(
stderr
,
"Setting RX frequency: %lf MHz...
\n
"
,
freq
/
1e6
);
uhd_usrp_set_rx_freq
(
usrp
,
&
rx_tune_request
,
channel
,
&
rx_tune_result
);
}
else
if
(
mcmd
[
"handle"
].
find
(
"txfreq_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
double
freq
=
atof
(
mcmd
[
"value"
].
c_str
());
uhd_tune_request_t
tx_tune_request
=
{
/*.target_freq = */
freq
,
/*.rf_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.rf_freq = */
0
,
/*.dsp_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.dsp_freq = */
0
,
/*.args = */
0
};
uhd_tune_result_t
rx_tune_result
;
fprintf
(
stderr
,
"Setting RX frequency: %lf MHz...
\n
"
,
freq
/
1e6
);
uhd_usrp_set_tx_freq
(
usrp
,
&
tx_tune_request
,
channel
,
&
rx_tune_result
);
}
}
}
modules/uhd/uhd_usrp_io/main.cpp
浏览文件 @
9bb1baec
...
...
@@ -19,7 +19,7 @@
#endif
using
namespace
TASKBUS
;
using
namespace
std
;
//#define OFFLINEDEBUG 0
int
do_iio
(
const
cmdlineParser
&
args
);
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -28,7 +28,7 @@ int main(int argc, char * argv[])
init_client
();
#ifdef OFFLINEDEBUG
FILE
*
old_stdin
,
*
old_stdout
;
auto
ars
=
debug
(
"
D:
\\
pid1008
"
,
&
old_stdin
,
&
old_stdout
);
auto
ars
=
debug
(
"
/home/user/codes/build-taskbus-qt6-Release/bin/debug/pid31171/
"
,
&
old_stdin
,
&
old_stdout
);
const
cmdlineParser
args
(
ars
);
#else
const
cmdlineParser
args
(
argc
,
argv
);
...
...
modules/uhd/uhd_usrp_io/uhd_io.cpp
浏览文件 @
9bb1baec
...
...
@@ -69,6 +69,8 @@ struct tag_tx_plain{
qint64
length_left
;
};
void
cmd_dealing
(
uhd_usrp_handle
usrp
,
std
::
vector
<
unsigned
char
>
&
cmd
);
static
char
error_string
[
512
];
int
do_iio
(
const
cmdlineParser
&
args
)
...
...
@@ -177,6 +179,16 @@ int do_iio(const cmdlineParser & args)
uhd_usrp_set_rx_agc
(
usrp
,
true
,
rx_channels
[
ch
]);
uhd_usrp_set_rx_dc_offset_enabled
(
usrp
,
true
,
rx_channels
[
ch
]);
}
else
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"rxgain_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
rx_gain
[
ch
]).
toStdString
(),
QString
(
"rxgain_%1"
).
arg
(
ch
).
toStdString
(),
"int"
,
"0:100"
);
// Set frequency
// Create other necessary structs
uhd_tune_request_t
rx_tune_request
=
...
...
@@ -195,7 +207,15 @@ int do_iio(const cmdlineParser & args)
// See what frequency actually isrx_streamer
UHD_DO
(
uhd_usrp_get_rx_freq
(
usrp
,
rx_channels
[
ch
],
&
rx_freq
[
ch
]));
fprintf
(
stderr
,
"Actual RX frequency: %lf MHz...
\n
"
,
rx_freq
[
ch
]
/
1e6
);
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"rxfreq_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
rx_freq
[
ch
]).
toStdString
(),
QString
(
"rxfreq_%1"
).
arg
(
ch
).
toStdString
(),
"double"
,
"0:6000000000"
,
"100000"
,
"0"
);
fprintf
(
stderr
,
"Setting RX Bandwidth: %lf MHz...
\n
"
,
rx_bw
[
ch
]
/
1e6
);
UHD_DO
(
uhd_usrp_set_rx_bandwidth
(
usrp
,
rx_bw
[
ch
],
rx_channels
[
ch
]));
//Band
...
...
@@ -228,6 +248,16 @@ int do_iio(const cmdlineParser & args)
// See what gain actually is
UHD_DO
(
uhd_usrp_get_tx_gain
(
usrp
,
tx_channels
[
ch
],
""
,
&
tx_gain
[
ch
]));
fprintf
(
stderr
,
"Actual TX Gain: %lf...
\n
"
,
tx_gain
[
ch
]);
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"txgain_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
tx_gain
[
ch
]).
toStdString
(),
QString
(
"txgain_%1"
).
arg
(
ch
).
toStdString
(),
"int"
,
"0:100"
);
// Create other necessary structs for TX
uhd_tune_request_t
tx_tune_request
=
{
/*.target_freq = */
tx_freq
[
ch
],
...
...
@@ -245,7 +275,15 @@ int do_iio(const cmdlineParser & args)
// See what frequency actually is
UHD_DO
(
uhd_usrp_get_tx_freq
(
usrp
,
tx_channels
[
ch
],
&
tx_freq
[
ch
]));
fprintf
(
stderr
,
"Actual TX frequency: %f MHz...
\n
"
,
tx_freq
[
ch
]
/
1e6
);
annouce_handle
(
args
.
toString
(
"instance"
,
"0"
),
"0"
,
QString
(
"txfreq_%1"
).
arg
(
ch
).
toStdString
(),
QString
(
"%1"
).
arg
(
tx_freq
[
ch
]).
toStdString
(),
QString
(
"txfreq_%1"
).
arg
(
ch
).
toStdString
(),
"double"
,
"0:6000000000"
,
"100000"
,
"0"
);
//Band
fprintf
(
stderr
,
"Setting TX Bandwidth: %f MHz...
\n
"
,
tx_bw
[
ch
]
/
1e6
);
UHD_DO
(
uhd_usrp_set_tx_bandwidth
(
usrp
,
tx_bw
[
ch
],
tx_channels
[
ch
]));
...
...
@@ -464,6 +502,8 @@ int do_iio(const cmdlineParser & args)
fflush
(
stderr
);
stop_signal_called
=
true
;
}
else
cmd_dealing
(
usrp
,
packagedta
);
}
else
{
...
...
@@ -688,3 +728,65 @@ int do_iio(const cmdlineParser & args)
fflush
(
stderr
);
return
return_code
;
}
void
cmd_dealing
(
uhd_usrp_handle
usrp
,
std
::
vector
<
unsigned
char
>
&
cmd
)
{
std
::
map
<
std
::
string
,
std
::
string
>
mcmd
=
TASKBUS
::
ctrlpackage_to_map
(
cmd
);
if
(
mcmd
[
"function"
]
==
"handle_set"
)
{
if
(
mcmd
[
"handle"
].
find
(
"rxgain_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
int
gain
=
atoi
(
mcmd
[
"value"
].
c_str
());
uhd_usrp_set_rx_gain
(
usrp
,
gain
,
channel
,
""
);
double
dgain
=
0
;
uhd_usrp_get_rx_gain
(
usrp
,
channel
,
""
,
&
dgain
);
fprintf
(
stderr
,
"Actual RX Gain: %lf...
\n
"
,
dgain
);
}
else
if
(
mcmd
[
"handle"
].
find
(
"txgain_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
int
gain
=
atoi
(
mcmd
[
"value"
].
c_str
());
uhd_usrp_set_tx_gain
(
usrp
,
gain
,
channel
,
""
);
double
dgain
=
0
;
uhd_usrp_get_tx_gain
(
usrp
,
channel
,
""
,
&
dgain
);
fprintf
(
stderr
,
"Actual TX Gain: %lf...
\n
"
,
dgain
);
}
else
if
(
mcmd
[
"handle"
].
find
(
"rxfreq_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
double
freq
=
atof
(
mcmd
[
"value"
].
c_str
());
uhd_tune_request_t
rx_tune_request
=
{
/*.target_freq = */
freq
,
/*.rf_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.rf_freq = */
0
,
/*.dsp_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.dsp_freq = */
0
,
/*.args = */
0
};
uhd_tune_result_t
rx_tune_result
;
fprintf
(
stderr
,
"Setting RX frequency: %lf MHz...
\n
"
,
freq
/
1e6
);
uhd_usrp_set_rx_freq
(
usrp
,
&
rx_tune_request
,
channel
,
&
rx_tune_result
);
}
else
if
(
mcmd
[
"handle"
].
find
(
"txfreq_"
)
!=
mcmd
[
"handle"
].
npos
)
{
int
channel
=
atoi
(
mcmd
[
"handle"
].
substr
(
7
).
c_str
());
double
freq
=
atof
(
mcmd
[
"value"
].
c_str
());
uhd_tune_request_t
tx_tune_request
=
{
/*.target_freq = */
freq
,
/*.rf_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.rf_freq = */
0
,
/*.dsp_freq_policy = */
UHD_TUNE_REQUEST_POLICY_AUTO
,
/*.dsp_freq = */
0
,
/*.args = */
0
};
uhd_tune_result_t
rx_tune_result
;
fprintf
(
stderr
,
"Setting RX frequency: %lf MHz...
\n
"
,
freq
/
1e6
);
uhd_usrp_set_tx_freq
(
usrp
,
&
tx_tune_request
,
channel
,
&
rx_tune_result
);
}
}
}
projects/usrp_fm_emitter.tbj
浏览文件 @
9bb1baec
...
...
@@ -298,6 +298,21 @@
}
}
},
"mod3": {
"control_pannel": {
"instance": {
"additional_args": "nice=0;",
"exec": "modules/control_pannel",
"instance_value": 4
},
"name": {
"name": "CtrlPannel"
},
"version": {
"version": "1,1,0"
}
}
},
"pos0": {
"x": 1701,
"y": 1596
...
...
@@ -310,5 +325,9 @@
"x": 2048,
"y": 1596
},
"total_mods": 3
"pos3": {
"x": 1448,
"y": 1552
},
"total_mods": 4
}
projects/usrp_fm_reciever.tbj
浏览文件 @
9bb1baec
...
...
@@ -522,6 +522,21 @@
}
}
},
"mod7": {
"control_pannel": {
"instance": {
"additional_args": "nice=0;",
"exec": "modules/control_pannel",
"instance_value": 8
},
"name": {
"name": "CtrlPannel"
},
"version": {
"version": "1,1,0"
}
}
},
"pos0": {
"x": 1519,
"y": 1375
...
...
@@ -550,5 +565,9 @@
"x": 2378,
"y": 1518
},
"total_mods": 7
"pos7": {
"x": 1513,
"y": 1556
},
"total_mods": 8
}
tb_interface/tb_interface.h
浏览文件 @
9bb1baec
...
...
@@ -67,16 +67,13 @@ namespace TASKBUS{
//调试,利用记录的打桩进程的stdin和命令行调试。会返回命令行
inline
std
::
vector
<
std
::
string
>
debug
(
const
char
*
logpath
,
FILE
**
old_stdin
,
FILE
**
old_stdout
);
//用于方便操作指令的函数, text command mod functions
//--------------------------------------------------------------------
#if _MSC_VER >=1200 || __cplusplus >= 201103L
inline
std
::
string
trim_elems
(
const
std
::
string
&
text
);
inline
std
::
map
<
std
::
string
,
std
::
string
>
string_to_map
(
const
std
::
string
&
s
);
inline
std
::
map
<
std
::
string
,
std
::
string
>
ctrlpackage_to_map
(
const
std
::
vector
<
unsigned
char
>
&
s
);
inline
std
::
string
map_to_string
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
s
);
inline
std
::
vector
<
unsigned
char
>
map_to_ctrlpackage
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
s
);
#endif
/**
*以下部分为具体实现。The following sections are the implementation
* -----------------------------------------------------------------------
...
...
@@ -323,7 +320,6 @@ namespace TASKBUS{
}
#if _MSC_VER >=1200 || __cplusplus >= 201103L
/*!
* \brief trim_elems trim all spaces of a string.
* \param text string to be trimmed.
...
...
@@ -406,7 +402,33 @@ namespace TASKBUS{
v
.
push_back
(
0
);
return
v
;
}
//播告功能
inline
void
annouce_handle
(
const
std
::
string
&
source
,
const
std
::
string
&
destin
,
const
std
::
string
&
handle
,
const
std
::
string
&
value
,
const
std
::
string
&
label
=
""
,
const
std
::
string
&
type
=
""
,
const
std
::
string
&
range
=
""
,
const
std
::
string
&
step
=
""
,
const
std
::
string
&
decimal
=
""
)
{
std
::
map
<
std
::
string
,
std
::
string
>
mp
;
mp
[
"source"
]
=
source
;
mp
[
"function"
]
=
"handle_annouce"
;
mp
[
"destin"
]
=
destin
;
mp
[
"handle"
]
=
handle
;
mp
[
"value"
]
=
value
;
if
(
label
.
size
())
mp
[
"label"
]
=
label
;
if
(
type
.
size
())
mp
[
"type"
]
=
type
;
if
(
range
.
size
())
mp
[
"range"
]
=
range
;
if
(
range
.
size
())
mp
[
"step"
]
=
step
;
if
(
range
.
size
())
mp
[
"decimal"
]
=
decimal
;
std
::
vector
<
unsigned
char
>
v
=
map_to_ctrlpackage
(
mp
);
push_subject
(
TB_SUBJECT_CMD
,
0
,
v
.
size
(),
v
.
data
());
}
#endif
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录