加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.qml 35.48 KB
一键复制 编辑 原始数据 按行查看 历史
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick3D
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQml
import QtQuick.Layouts
import QtCharts
import QtDataVisualization 1.4
import runner 1.0
import "."
Window {
id:mainScreen
property real scale: 0.9
width: Screen.width * mainScreen.scale
height: Screen.height * mainScreen.scale
visible: true
maximumHeight: mainScreen.height
minimumHeight: mainScreen.height
maximumWidth: mainScreen.width
minimumWidth: mainScreen.width
//禁止缩放界面
x:(Screen.width * (1-mainScreen.scale))/2
y:(Screen.height * (1-mainScreen.scale))/2
title: qsTr("digital twin system")
Timer
{
id:chart_update_timer
interval:100
repeat: true
running:true
onTriggered:
{
experiment_pane.experiment_chart_update()
var sensor_info = runner.sensor_info_get()
if( sensor_info.is_update )
{
flight_status_menu.update_chart(sensor_info)
runner.sensor_info_count++
view_real_status_3d.yaw = sensor_info.yaw
view_real_status_3d.pitch = sensor_info.pitch
view_real_status_3d.roll = sensor_info.roll
yaw_animation.complete()
yaw_animation.start()
roll_animation.complete()
roll_animation.start()
pitch_animation.complete()
pitch_animation.start()
}
var input_info = runner.input_info_get()
if( input_info.is_update )
{
flight_status_menu.update_input_chart(input_info)
runner.input_info_count++
}
var expect_info = runner.expect_info_get()
if( expect_info.is_update )
{
flight_status_menu.update_expect_chart(expect_info)
runner.expect_info_count++
}
}
}
Pane
{
id:main_pane
Material.theme:Material.Light
width: parent.width
height: parent.height
TabBar
{
id: feature_column
x:0
y:0
width:parent.width
property real btn_cnt:7;
TabButton
{
id:digital_twin_btn
text: "孪生模型"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = true
setting_pane.visible = false
system_info_pane.visible = false
experiment_pane.visible = false
operator_menue.visible = false
flight_status_menu.visible = false
}
}
TabButton
{
id:flight_status_btn
text: "飞行状态"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = false
setting_pane.visible = false
system_info_pane.visible = false
experiment_pane.visible = false
operator_menue.visible = false
flight_status_menu.visible = true
input_status_pane.visible = false
}
}
TabButton
{
id:input_status_btn
text: "输入状态"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = false
setting_pane.visible = false
system_info_pane.visible = false
experiment_pane.visible = false
operator_menue.visible = false
flight_status_menu.visible = false
input_status_pane.visible = true
}
}
TabButton
{
id:operator_btn
text: "指令中枢"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = false
setting_pane.visible = false
system_info_pane.visible = false
experiment_pane.visible = false
operator_menue.visible = true
flight_status_menu.visible = false
input_status_pane.visible = false
}
}
TabButton
{
id:experiment_btn
text: "实验"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = false
setting_pane.visible = false
system_info_pane.visible = false
experiment_pane.visible = true
operator_menue.visible = false
flight_status_menu.visible = false
input_status_pane.visible = false
}
}
TabButton
{
id:log_info_btn
text: "日志"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = false
setting_pane.visible = false
system_info_pane.visible = true
experiment_pane.visible = false
operator_menue.visible = false
flight_status_menu.visible = false
input_status_pane.visible = false
}
}
TabButton
{
id:setting_btn
text: "设置"
width: feature_column.width/feature_column.btn_cnt
font.family:"Helvetica"
font.bold:true
font.pointSize: 18
onClicked:
{
digital_twin_menu.visible = false
setting_pane.visible = true
system_info_pane.visible = false
experiment_pane.visible = false
operator_menue.visible = false
flight_status_menu.visible = false
input_status_pane.visible = false
}
}
}
//界面栏
SystemStatus
{
id:flight_status_menu
visible: false
x:digital_twin_menu.board_width
y:feature_column.y + feature_column.height + digital_twin_menu.board_height
//起点
width:main_pane.width - (digital_twin_menu.board_width * 2)
height:main_pane.height - feature_column.height - (digital_twin_menu.board_height * 2)
}
InputStatus
{
id:input_status_pane
visible: false
x:digital_twin_menu.board_width
y:feature_column.y + feature_column.height + digital_twin_menu.board_height
//起点
width:main_pane.width - (digital_twin_menu.board_width * 2)
height:main_pane.height - feature_column.height - (digital_twin_menu.board_height * 2)
}
Experiment
{
id:experiment_pane
visible:false
x:digital_twin_menu.board_width
y:feature_column.y + feature_column.height + digital_twin_menu.board_height
//起点
width:main_pane.width - (digital_twin_menu.board_width * 2)
height:main_pane.height - feature_column.height - (digital_twin_menu.board_height * 2)
}
Pane
{
id:system_info_pane
visible:false
property real board_width: 10
property real board_height: 10
x:digital_twin_menu.board_width
y:feature_column.y + feature_column.height + digital_twin_menu.board_height
//起点
width:main_pane.width - (digital_twin_menu.board_width * 2)
height:main_pane.height - feature_column.height - (digital_twin_menu.board_height * 2)
Material.theme:Material.Dark
ScrollView
{
id:system_info_view
anchors.fill:parent
ScrollBar.vertical.pressed:true
ScrollBar.vertical.interactive:true
ScrollBar.vertical.minimumSize:0.1
ScrollBar.vertical.snapMode:ScrollBar.SnapAlways
ScrollBar.vertical.policy:ScrollBar.AlwaysOn
TextArea
{
id:system_info_text_area
text:" ----------------------------------system infomation----------------------------------"
color:"white"
font.pixelSize: 20
font.bold:true
readOnly: true
selectedTextColor: "gray"
onTextChanged:
{
system_info_view.ScrollBar.vertical.position = 1 - system_info_view.ScrollBar.vertical.visualSize
}
}
}
}
Runner
{
id:runner
property real sensor_info_count: 0
property real experiment_info_count:0
property real input_info_count:0
property real expect_info_count:0
onExperiment_status_change_signal:
{
var experiment_status_info = experiment_info_get()
experiment_pane.experiment_status_update(experiment_status_info)
}
onFc_lift_experiment_info_update_signal:
{
var info = fc_lift_experiment_data_get();
runner.experiment_info_count++
experiment_pane.experiment_lift_update(info)
}
onFc_servo_force_experiment_info_update_signal:
{
var fc_servo_info = fc_servo_force_experiment_data_get();
runner.experiment_info_count++
experiment_pane.experiment_servo_force_update(fc_servo_info)
}
onFc_servo_force_dynamic_experiment_info_update_signal:
{
var info = fc_servo_force_dynamic_experiment_data_get();
runner.experiment_info_count++
experiment_pane.experiment_servo_dynamic_update(info)
}
onSensor_info_update_signal: //飞行器的传感器信息
{
}
onInput_info_update_signal: //飞行器的输入信息
{
}
onSystem_initial_signal:
{
var info = system_initial_info_get();
/*system initial information get */
var experiment_info = info.experiment_list;
experiment_pane.experiment_list_update(experiment_info);
}
onDs_port_name_list_update_signal:
{
var port_info = runner.get_port_info(2);
ds_port_name_model.clear()
//clear port name model
if(port_info.port_cnt !== 0)
{
var i=0
for(;i<port_info.port_cnt;i++)
{
ds_port_name_model.append({text:port_info.port_name_list[i]})
}
}
else
{
ds_port_name_model.append({text:"未识别到串口"})
}
}
onDs_port_status_update_signal:
{
var port_info = runner.get_port_info(2);
if( port_info.port_status )
{
ds_openClose_btn.text="关闭串口"
}
else
{
ds_openClose_btn.text="打开串口"
}
}
onFc_port_name_list_update_signal:
{
var port_info = runner.get_port_info(1);
fc_port_name_model.clear()
//clear port name model
if(port_info.port_cnt !== 0)
{
var i=0
for(;i<port_info.port_cnt;i++)
{
fc_port_name_model.append({text:port_info.port_name_list[i]})
}
}
else
{
fc_port_name_model.append({text:"未识别到串口"})
}
}
onFc_port_status_update_signal:
{
var port_info = runner.get_port_info(1);
if( port_info.port_status )
{
fc_openClose_btn.text="关闭串口"
runner.sensor_info_count = 0
runner.input_info_count = 0
runner.expect_info_count = 0
flight_status_menu.clean_chart()
input_status_pane.clean_chart()
}
else
{
fc_openClose_btn.text = "打开串口"
}
}
onRoll_fft_data_update_signal:
{
var amp = roll_fft_amp_get();
var maxY = Math.max.apply(null,amp);
var sample_freq = 500; //hz
if( isFinite(maxY) )
{
if( maxY >= fft_chart_axisY.max )
{
if(maxY >= 2000)
fft_chart_axisY.max = 2000;
else
fft_chart_axisY.max = maxY;
}
fft_chart_axisX.min = 0;
if( fft_chart_axisX.max < sample_freq / 2)
fft_chart_axisX.max = sample_freq / 2;
roll_amp_chart_series.clear();
var i;
for(i=0;i<amp.length;i++)
{
roll_amp_chart_series.append(sample_freq*i/(2*amp.length),amp[i]);
}
}
}
onPitch_fft_data_update_signal:
{
var amp = pitch_fft_amp_get();
var maxY = Math.max.apply(null,amp);
var sample_freq = 500; //hz
if( isFinite(maxY) )
{
if( maxY >= fft_chart_axisY.max )
{
if(maxY >= 2000)
fft_chart_axisY.max = 2000;
else
fft_chart_axisY.max = maxY;
}
fft_chart_axisX.min = 0;
if( fft_chart_axisX.max < sample_freq / 2)
fft_chart_axisX.max = sample_freq / 2;
pitch_amp_chart_series.clear();
var i;
for(i=0;i<amp.length;i++)
{
pitch_amp_chart_series.append(sample_freq*i/(2*amp.length),amp[i]);
}
}
}
onYaw_fft_data_update_signal:
{
var amp = yaw_fft_amp_get();
var maxY = Math.max.apply(null,amp);
var sample_freq = 500; //hz
if( isFinite(maxY) )
{
if( maxY >= fft_chart_axisY.max )
{
if(maxY >= 2000)
fft_chart_axisY.max = 2000;
else
fft_chart_axisY.max = maxY;
}
fft_chart_axisX.min = 0;
if( fft_chart_axisX.max < sample_freq / 2)
fft_chart_axisX.max = sample_freq / 2;
yaw_amp_chart_series.clear();
var i;
for(i=0;i<amp.length;i++)
{
yaw_amp_chart_series.append(sample_freq*i/(2*amp.length),amp[i]);
}
}
}
onPrint_info_update_signal:
{
//print log update
system_info_text_area.append(print_info_get());
}
}
Pane
{
id:setting_pane
visible:false
x:digital_twin_menu.board_width
y:feature_column.y + feature_column.height + digital_twin_menu.board_height
//起点
width:main_pane.width - (digital_twin_menu.board_width * 2)
height:main_pane.height - feature_column.height - (digital_twin_menu.board_height * 2)
Rectangle
{
id:fc_serial_rect
x:parent.x
y:parent.y
width:parent.width/6
height:parent.height/4
ColumnLayout
{
id:fc_serial_button_layout
anchors.fill:parent
spacing:5
Text
{
text: "<b>--飞控通信设置--</b>"
font.pixelSize: 20
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
ComboBox
{
id:fc_port_name_list
editable: false
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter
model:ListModel
{
id:fc_port_name_model
}
}
Button
{
id:fc_search_btn
text:"搜索串口"
Layout.fillWidth: true
Layout.fillHeight: true
onClicked:
{
runner.search_port_button_callback(1);
}
}
Button
{
id:fc_openClose_btn
text:"打开串口"
Layout.fillWidth: true
Layout.fillHeight: true
onClicked:
{
runner.open_port_button_callback(fc_port_name_list.currentText,1)
}
}
}
}
Rectangle
{
id:ds_serial_rect
x:parent.x
y:fc_serial_rect.y + fc_serial_rect.height
width:parent.width/6
height:parent.height/4
ColumnLayout
{
id:ds_serial_button_layout
anchors.fill:parent
spacing:5
Text
{
text: "<b>--数字采样器通信设置--</b>"
font.pixelSize: 20
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
ComboBox
{
id:ds_port_name_list
editable: false
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter
model:ListModel
{
id:ds_port_name_model
}
}
Button
{
id:ds_search_btn
text:"搜索串口"
Layout.fillWidth: true
Layout.fillHeight: true
onClicked:
{
runner.search_port_button_callback(2);
}
}
Button
{
id:ds_openClose_btn
text:"打开串口"
Layout.fillWidth: true
Layout.fillHeight: true
onClicked:
{
runner.open_port_button_callback(ds_port_name_list.currentText,2)
}
}
}
}
}
Pane
{
id:digital_twin_menu
visible:true
property real board_width: 10
property real board_height: 10
x:digital_twin_menu.board_width
y:feature_column.y + feature_column.height + digital_twin_menu.board_height
//起点
width:main_pane.width - (digital_twin_menu.board_width * 2)
height:main_pane.height - feature_column.height - (digital_twin_menu.board_height * 2)
RowLayout
{
anchors.fill: parent
spacing:10
Rectangle
{
id:view3D_part
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
Layout.fillHeight: true
ColumnLayout
{
anchors.fill: parent
spacing: 10
Rectangle
{
id:real_status
Layout.fillWidth: true
Layout.fillHeight: true
border.color: "black"
border.width: 5
radius: 10
View3D
{
id:view_real_status_3d
anchors.fill: parent
camera: camera
property real yaw:0
property real pitch:0
property real roll:0
environment: SceneEnvironment {
id: sceneEnvironment_real
clearColor: "#f0f0f0"
backgroundMode: SceneEnvironment.Color
antialiasingMode: SceneEnvironment.NoAA
antialiasingQuality: SceneEnvironment.VeryHigh
temporalAAEnabled: false
temporalAAStrength: 100
}
PerspectiveCamera {
position.z: 50.0
position.y: 8.0
position.x: 0
clipNear: 1.0
clipFar: 60.0
}
DirectionalLight {
eulerRotation.x: -30
eulerRotation.y: -70
ambientColor: Qt.rgba(0.3, 0.3, 0.3, 1.0)
}
Node {
id: scene_real
Model {
source: "ac.mesh"
position.x:0
position.y:0
position.z:0
//scale:Qt.vector3d(1,1,1)
materials: DefaultMaterial {
//baseColor: "#faee45"
diffuseColor: Qt.rgba(0.8, 0.8, 0.8, 1.0)
}
//
SequentialAnimation on eulerRotation.y{
id:yaw_animation
NumberAnimation { to: view_real_status_3d.yaw; duration: 500 }
}
SequentialAnimation on eulerRotation.x {
id:roll_animation
NumberAnimation { to: view_real_status_3d.roll; duration: 500 }
}
SequentialAnimation on eulerRotation.z {
id:pitch_animation
NumberAnimation { to: view_real_status_3d.pitch; duration: 500 }
}
}
}
}
}
Rectangle
{
id:digital_twin_status
Layout.fillWidth: true
Layout.fillHeight: true
border.color: "black"
border.width: 5
radius: 10
View3D
{
id:view_dt_status_3d
anchors.fill: parent
camera: camera
environment: SceneEnvironment {
id: sceneEnvironment_dt
clearColor: "#f0f0f0"
backgroundMode: SceneEnvironment.Color
antialiasingMode: SceneEnvironment.NoAA
antialiasingQuality: SceneEnvironment.VeryHigh
temporalAAEnabled: false
temporalAAStrength: 100
}
PerspectiveCamera {
position.z: 50.0
position.y: 8.0
position.x: 0
clipNear: 1.0
clipFar: 60.0
}
DirectionalLight {
eulerRotation.x: -30
eulerRotation.y: -70
ambientColor: Qt.rgba(0.3, 0.3, 0.3, 1.0)
}
Node {
id: scene_dt
Model {
source: "ac.mesh"
position.x:0
position.y:0
position.z:0
//scale:Qt.vector3d(1,1,1)
materials: DefaultMaterial {
//baseColor: "#faee45"
diffuseColor: Qt.rgba(0.4, 0.4, 0.4, 0.5)
}
}
}
}
}
}
}
Rectangle
{
id:chart_status
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
Layout.fillHeight: true
ColumnLayout
{
anchors.fill:parent
Rectangle
{
id:sensor_chart_rect_checkout
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
Layout.preferredHeight:chart_status.height * 0.04
RowLayout
{
anchors.centerIn: parent
spacing:1
CheckBox
{
id:euro_checkout
text:"欧拉角"
checked: true
}
CheckBox
{
id:gyro_checkout
text:"角速度"
checked: false
}
CheckBox
{
id:accel_checkout
text:"加速度"
checked: false
}
CheckBox
{
id:velocity_checkout
text:"速度"
checked: false
}
CheckBox
{
id:pos_checkout
text:"位置"
checked: false
}
}
}
Rectangle
{
id:fft_chart_pane
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
// Layout.fillHeight: true
Layout.preferredHeight:chart_status.height * 0.475
ChartView
{
id:fft_chart
anchors.fill:parent
legend.alignment: Qt.AlignTop
title:"频域分析曲线"
ValuesAxis
{
id:fft_chart_axisX
min:0
max:25
tickCount: 10
}
ValuesAxis
{
id:fft_chart_axisY
tickCount: 10
min:0
max:200
}
SplineSeries {
id:roll_amp_chart_series
name:"amp-roll"
width:2
color:"#0000ff"
axisX: fft_chart_axisX
axisY: fft_chart_axisY
visible:euro_checkout.checked
}
SplineSeries {
id:pitch_amp_chart_series
name:"amp-pitch"
width:2
color:"#00ff00"
axisX: fft_chart_axisX
axisY: fft_chart_axisY
visible:euro_checkout.checked
}
SplineSeries {
id:yaw_amp_chart_series
name:"amp-yaw"
width:2
color:"#ff0000"
axisX: fft_chart_axisX
axisY: fft_chart_axisY
visible:euro_checkout.checked
}
}
}
}
}
}
}
}
Pane
{
id:operator_menue
visible:false
property real board_width: 10
property real board_height: 10
x:operator_menue.board_width
y:feature_column.y + feature_column.height + operator_menue.board_height
//起点
width:main_pane.width - (operator_menue.board_width * 2)
height:main_pane.height - feature_column.height - (operator_menue.board_height * 2)
Pane
{
id:fligiht_control_pane
Layout.alignment: Qt.AlignCenter
Layout.fillHeight: operator_menue.height * 0.4
Layout.preferredWidth:operator_menue.width * 0.2
ColumnLayout
{
anchors.fill: parent
spacing:10
Text
{
id:status_record_text
text: "<b>飞行状态记录</b>"
font.pixelSize: 20
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment:Qt.AlignVCenter
horizontalAlignment:Text.AlignHCenter
verticalAlignment:Text.AlignVCenter
}
Button
{
id:record_switch_btn
text:"<b>开始记录</b>"
Layout.fillWidth: true
Layout.fillHeight: true
onClicked:
{
runner.record_switch_button_callback()
var sta = runner.get_record_status()
if(sta.status === 1)
{
record_switch_btn.text = "<b>结束记录</b>"
}
else
{
record_switch_btn.text = "<b>开始记录</b>"
}
}
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化