| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- import QtQuick
- import QtQuick.Controls
- import Qt.labs.settings 1.0 as QtLabs
- import QtQuick.Controls.Material 2.0
- import QtLocation 5.5
- import QtPositioning 5.5
- import QtMultimedia
- import Qt5Compat.GraphicalEffects
- import Felgo 4.0
- import "../controls"
- import "../common"
- //import MqttClient 1.0
- AppPage {
- id: controlsPage
- property string originalString: ""
- property string collectString: ""
- property string gps_state: "正在定位..."
- property string board_version: ""
- property bool connect_board: false
- property var tt
- property bool isonline: false
- property var net_list:[]
- property var picinfo_list:[]
- Material.accent: Theme.tintColor
- rightBarItem: IconButtonBarItem {
- iconType: IconType.paintbrush
- onClicked: {
- themeModal.open()
- }
- }
- Component.onCompleted: {
- originalString = myClass.deviceid
- }
- // 接收并显示日志消息
- Connections {
- target: mqtt
- onConnected: {
- console.log("mqtt connect")
- mqtt_sta.detailText="MQTT已连接"
- }
- onDisconnected: {
- console.log("mqtt disconnect")
- mqtt_sta.detailText="MQTT已断开"
- }
- }
- Connections{
- target: myClass
- }
- //串口
- Connections{
- target: serial
- onDataReceived:{
- var jsonData = JSON.parse(data)
- console.debug("接收到主板数据:",data.toString())
- if(jsonData.ext.work_sta==="0"){
- if(jsonData.ext.ds==="0"){
- work_header.text =qsTr("<b>设备开关:</b> 关机") + "-" + qsTr("<b>工作状态:</b> 待机")
- }else{
- work_header.text =qsTr("<b>设备开关:</b> 开机") + "-" + qsTr("<b>工作状态:</b> 待机")
- }
- }else if(jsonData.ext.work_sta==="1"){
- if(jsonData.ext.ds==="0"){
- work_header.text = qsTr("<b>设备开关:</b> 关机") + "-" + qsTr("<b>工作状态:</b> 采集")
- }else{
- work_header.text = qsTr("<b>设备开关:</b> 开机") + "-" + qsTr("<b>工作状态:</b> 采集")
- }
- }
- if(jsonData.ext.gps==="1"){
- gps_state = "成功"
- }
- if(jsonData.ext.coll_time){
- collectString = " [" +jsonData.ext.coll_time[0] + "," + jsonData.ext.coll_time[1] + "," + jsonData.ext.coll_time[2] + "]";
- }
- if(jsonData.ext.dat_f){
- serial.update_dat_f_main(jsonData.ext.dat_f);
- }
- board_version = jsonData.ext.dver
- work_header.detailText = "电压:" + jsonData.ext.vbat + " 电流:" + jsonData.ext.current + " 温度:" + jsonData.ext.at + " 湿度:" + jsonData.ext.ah ;
- }
- onDisconnect_485:{
- work_header.text =qsTr("485未连接,读取数据失败");
- }
- }
- MediaPlayer{
- id: audio
- audioOutput: AudioOutput{}
- source: Qt.resolvedUrl("../../assets/mp3/button.mp3")
- }
- AppFlickable {
- id: scroll
- anchors.fill: parent
- contentHeight: content.height
- // remove focus from controls if clicked outside
- MouseArea {
- anchors.fill: parent
- onClicked: {
- scroll.forceActiveFocus()
- }
- }
- Column {
- id: content
- width: parent.width
- Timer {
- interval: 500
- running: true
- repeat: true
- onTriggered: {
- menutab.title = Date().toString() + " 设备ID:" + originalString.toLowerCase() + " GPS状态:" + gps_state
- if(mqtt.checkLink()){
- mqtt_sta.detailText="MQTT已连接"
- }else{
- mqtt_sta.detailText="MQTT已断开"
- }
- net_list = mqtt.netMessage()
- if(net_list){
- if(net_list[0]==="1"){isonline = true}else{isonline = false}
- mqtt_sta.text = qsTr("<b>联网状态:</b> %1 (网卡名称:%2) (描述:%3)").arg(isonline? "已联网" : "未联网").arg(net_list[1]).arg(net_list[2])
- net_mes.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3]) + qsTr("<b>[IPV4] </b> %1").arg(net_list[4])
- mqtt_sta.detailText += "<服务器地址:>" + net_list[5]
- mqtt_sta.detailText += "<数据上传间隔:>" + net_list[6] + "(" +net_list[7] + ")" + "分钟";
- }
- }
- }
- Section {
- id: menutab
- title: Date().toString()
- //SectionItem {
- //title: "运行状态"
- //anchors.horizontalCenter: parent.horizontalCenter
- AppCard {
- id: card
- width: parent.width
- // property real resetX: 0
- // x: resetX
- margin: dp(5)
- paper.radius: dp(5)
- header: SimpleRow {
- id: work_header
- //imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
- text: qsTr("<b>设备开关:</b> 开机") + qsTr("<b>工作状态:</b> 待机")
- detailText: "电压:" + jsonData.ext.vbat + " 电流:" + jsonData.ext.current + " 温度:" + jsonData.ext.at + " 湿度:" + jsonData.ext.ah ;
- badgeColor: "green"
- image.radius: image.width / 2
- image.fillMode: Image.PreserveAspectCrop
- style: StyleSimpleRow {
- showDisclosure: false
- backgroundColor: "transparent"
- }
- }
- media: AppImage {
- width: card.width
- fillMode: Image.PreserveAspectFit
- source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
- }
- content: AppText{
- id: work_apptext
- width: card.width
- padding: dp(15)
- text: "设定采集时间:" + collectString;
- }
- }
- AppCard {
- id: card_net
- width: parent.width
- property real resetX: 0
- x: resetX
- margin: dp(5)
- paper.radius: dp(5)
- header: SimpleRow {
- id: mqtt_sta
- //imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
- text: qsTr("<b>联网状态:</b> %1 (%2)").arg(app.isOnline ? "已联网" : "未联网").arg(nativeUtils.connectionType)
- detailText: "AppCard detailed text"
- image.radius: image.width / 2
- image.fillMode: Image.PreserveAspectCrop
- style: StyleSimpleRow {
- showDisclosure: false
- backgroundColor: "transparent"
- }
- }
- media: AppImage {
- width: parent.width
- fillMode: Image.PreserveAspectFit
- source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
- }
- content: AppText{
- id: net_mes
- width: parent.width
- padding: dp(15)
- text: "Mac" + "ipv4:";
- }
- }
- // AppCard {
- // id: card_cfg
- // width: parent.width
- // height: width*1.5
- // property real resetX: 0
- // x: resetX
- // margin: dp(5)
- // paper.radius: dp(5)
- // header: SimpleRow {
- // imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
- // text: "参数"
- // detailText: "AppCard detailed text"
- // image.radius: image.width / 2
- // image.fillMode: Image.PreserveAspectCrop
- // style: StyleSimpleRow {
- // showDisclosure: false
- // backgroundColor: "transparent"
- // }
- // }
- // media: AppImage {
- // width: card_cfg.width
- // fillMode: Image.PreserveAspectFit
- // source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
- // }
- // content: AppText{
- // width: card_cfg.width
- // padding: dp(15)
- // text: "此界面显示参数等信息,运行时间等"
- // }
- // cardSwipeArea.onSwipeOutCompleted: {
- // card_cfg.x = card_cfg.resetX
- // card_cfg.rotation = 0
- // }
- // }
- //} // AppCard section
- } // convenience controls section
- Timer {
- interval: 1000
- running: true
- repeat: true
- onTriggered: {
- picinfo_list = serial.pathinfo()
- pic_path.text = "图片存储目录:" + picinfo_list[0]
- pic_count.text = "文件数量:" + picinfo_list[1]
- pic_total.text = "占用大小:" + picinfo_list[2] + "(Mb)"
- }
- }
- Section {
- title: "存储信息"
- bottomPadding: dp(Theme.navigationBar.defaultBarItemPadding)
- Grid {
- anchors.horizontalCenter: parent.horizontalCenter
- columns: 2
- rows: 4
- //horizontalItemAlignment: Grid.AlignHCenter
- Column{
- AppButton {
- text: "查询"
- flat: false
- onClicked: {
- serial.readPathinfo()
- }
- }
- AppButton {
- text: "清理"
- flat: false
- onClicked: {
- serial.removepic()
- }
- }
- }
- Column{
- AppText {
- id: pic_path
- text: "图片存储目录:" + picinfo_list[0]
- }
- AppText{
- id: pic_count
- text: "文件数量:" + picinfo_list[1]
- }
- AppText{
- id: pic_total
- text: "占用大小:" + picinfo_list[2]
- }
- }
- }
- } // native utils section }
- Section {
- title: "Device Info"
- bottomPadding: dp(15)
- Row {
- width: parent.width - dp(30)
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: dp(5)
- Column {
- id: firstInfoColumn
- spacing: dp(5)
- width: (parent.width - parent.spacing) * 0.5
- AppText {
- text: "<b>OS Type:</b> " + system.osType
- font.pixelSize: sp(11)
- visible: system.osType !== "undefined"
- }
- AppText {
- text: "<b>OS Version:</b> " + system.osVersion
- font.pixelSize: sp(11)
- visible: system.osVersion !== "undefined"
- }
- AppText {
- text: "<b>Device Model:</b> " + nativeUtils.deviceModel()
- font.pixelSize: sp(11)
- visible: nativeUtils.deviceModel() !== "undefined"
- }
- AppText {
- text: qsTr("<b>Device Online:</b> %1 (%2)").arg(app.isOnline ? "Yes" : "No").arg(nativeUtils.connectionType)
- font.pixelSize: sp(11)
- }
- AppText {
- text: "<b>MAC Address:</b> " + system.macAddress
- font.pixelSize: sp(11)
- width: parent.width
- wrapMode: Text.WrapAtWordBoundaryOrAnywhere
- visible: system.macAddress !== "undefined"
- }
- AppText {
- text: "<b>Unique Device Id:</b> " + system.UDID
- font.pixelSize: sp(11)
- width: parent.width
- wrapMode: Text.WrapAtWordBoundaryOrAnywhere
- visible: system.UDID !== "undefined"
- }
- }
- Column {
- id: secondInfoColumn
- spacing: dp(5)
- width: firstInfoColumn.width
- AppText {
- text: "<b>Orientation:</b> " + (Theme.isPortrait ? "portrait" : "landscape")
- font.pixelSize: sp(11)
- }
- AppText {
- text: "<b>Statusbar Height:</b> " + Theme.statusBarHeight
- font.pixelSize: sp(11)
- }
- AppText {
- text: "<b>App Identifier:</b> " + system.appIdentifier
- font.pixelSize: sp(11)
- width: parent.width
- wrapMode: Text.WrapAtWordBoundaryOrAnywhere
- visible: system.appIdentifier !== "undefined"
- }
- AppText {
- text: "<b>App Version:</b> " + system.appVersionCode
- font.pixelSize: sp(11)
- }
- AppText {
- text: "<b>Qt Version:</b> " + system.qtVersion
- font.pixelSize: sp(11)
- }
- AppText {
- text: "<b>Felgo Version:</b> " + system.felgoVersion + " (" + system.felgoVersionRef + ")"
- font.pixelSize: sp(11)
- }
- }
- }
- } // device info section
- } // content column
- } // flickable
- ThemeModal {
- id: themeModal
- pushBackContent: navigationStack
- } // theme modal
- } // page
|