代码拉取完成,页面将自动刷新
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>"
}
}
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。