| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 |
- import QtQuick 2.5
- import QtQuick.Controls 2.0
- import Qt.labs.settings 1.0 as QtLabs
- import QtQuick.Controls.Material 2.0
- import QtLocation 5.5
- import QtPositioning 5.5
- import QtMultimedia 5.5
- import Qt5Compat.GraphicalEffects
- import Felgo 4.0
- import "../controls"
- import "../common"
- import "../model"
- AppPage {
- id: home_Page
- signal updatebv(string bv)
- property string originalString: ""
- property string collectString: ""
- property string gps_state: "定位中..."
- property bool connect_board: false
- property var tt
- property bool isonline: false
- property var net_list:[]
- navigationBarHidden: true
- backgroundColor: app.theme_backgroundColor
- Component.onCompleted: {
- var theme_m = settings.getValue("theme_mode")
- if (theme_m === undefined) {
- theme_m = "day"
- app.theme_select = "day"
- settings.setValue("theme_mode","day")
- }else{
- theme_md = theme_m
- if(theme_m!=="auto"){
- app.theme_select = theme_m
- }
- console.log("读取到配置主题模式:",app.theme_select,theme_m)
- Theme.navigationTabBar.titlePressedColor= "green"
- Theme.navigationTabBar.backgroundColor= app.cardColor
- Theme.navigationTabBar.titleColor = app.fontColor
- }
- }
- // Connections {
- // target: app
- // onTmChange:{
- // console.log("配置主题模式:",md)
- // theme_select = md
- // }
- // }
- // 接收并显示日志消息
- Connections {
- target: mqtt
- onConnected: {
- console.log("mqtt connect")
- }
- onDisconnected: {
- console.log("mqtt disconnect")
- //mqtt_text.detailText="MQTT已断开"
- }
- }
- // Connections{
- // target: myClass
- // }
- //串口
- Connections{
- target: serial
- onDataReceived:{
- var jsonData = JSON.parse(data)
- console.log("接收到主板数据:",data.toString())
- if(jsonData.ext.work_sta==="0"){
- text_devicesta.text = qsTr("<b>工作状态:</b> 待机")
- if(jsonData.ext.ds==="0"){
- }else{
- }
- }else if(jsonData.ext.work_sta==="1"){
- text_devicesta.text = qsTr("<b>工作状态:</b> 采集")
- }
- if(jsonData.ext.gps==="1"){
- gps_state = "成功"
- }
- if(jsonData.ext.imei){
- originalString = jsonData.ext.imei
- }
- if(jsonData.ext.coll_time){
- var sh1Arry = jsonData.ext.coll_time[0].split('-')
- var sh2Arry = jsonData.ext.coll_time[1].split('-')
- var sh3Arry = jsonData.ext.coll_time[2].split('-')
- sh1.text = parseInt(sh1Arry[0])+ ":00 - " + parseInt(sh1Arry[1]) + ":00"
- sh2.text = parseInt(sh2Arry[0])+ ":00 - " + parseInt(sh2Arry[1]) + ":00"
- sh3.text = parseInt(sh3Arry[0])+ ":00 - " + parseInt(sh3Arry[1]) + ":00"
- }
- if(jsonData.ext.dat_f){
- serial.update_dat_f_main(jsonData.ext.dat_f);
- }
- text_tempture.text = "温度:" + jsonData.ext.at + "℃"
- text_humidity.text = "湿度:" + jsonData.ext.ah + "%RH"
- text_vbat.text = "电压:" + jsonData.ext.vbat + "V"
- text_current.text = "电流:" + jsonData.ext.current + "mA"
- text_lat.text = "lat:" + jsonData.ext.lat
- text_lng.text = "lng:" + jsonData.ext.lng
- var dvs = jsonData.ext.dver
- dvs = dvs.split("-")
- app.bvReceived(dvs[0])
- app.appReceived(dvs[1])
- }
- onDisconnect_485:{
- text_devicesta.text =qsTr("485未连接,读取数据失败");
- }
- }
- Timer {
- interval: 100
- running: true
- repeat: true
- onTriggered: {
- text_stamp.text = getCurrentTime()
- }
- }
- function handleThemeChange(mode){
- theme_select = mode
- console.log("theme_select",theme_select)
- }
- function getCurrentTime() {
- var currentTime = new Date();
- var years = currentTime.getFullYear()
- var mon = currentTime.getMonth() + 1
- var dates = currentTime.getDate()
- var hours = currentTime.getHours()
- var mins = currentTime.getMinutes()
- var secs = currentTime.getSeconds()
- if(app.theme_md==="auto"){
- if(hours>=6&&hours<=18){
- app.theme_select = "day"
- }else{
- app.theme_select = "night"
- }
- }
- return years + "-" + mon + "-" + dates + " " + hours + ":" + mins + ":" + secs
- }
- Grid {
- anchors.fill: parent
- anchors.leftMargin: 5
- anchors.topMargin: 5
- //anchors.horizontalCenter: parent.horizontalCenter
- columns: 1
- rows: 3
- columnSpacing: 10
- rowSpacing: 5
- horizontalItemAlignment: Grid.AlignHCenter
- Row {
- width: parent.width *0.995
- height: parent.height*0.1
- Rectangle {
- anchors.fill: parent
- color: app.cardColor
- radius: 2
- Row {
- anchors.fill: parent
- spacing: dp(20)
- AppText{
- id: text_stamp
- anchors.verticalCenter: parent.verticalCenter
- text: ""
- fontSize: 20
- color: app.fontColor
- }
- AppText{
- id: text_imei
- anchors.verticalCenter: parent.verticalCenter
- text:"设备ID:" + originalString.toLowerCase()
- fontSize: 20
- color: app.fontColor
- }
- AppText{
- id: net_sta
- anchors.verticalCenter: parent.verticalCenter
- color: app.fontColor
- text: "联网状态:"
- fontSize: 20
- //font.bold: true
- }
- AppText{
- id: text_gps
- anchors.verticalCenter: parent.verticalCenter
- text: "GPS状态:" + gps_state
- color: app.fontColor
- font.bold: true
- //fontSize: 20
- }
- }
- }
- }
- Row{
- //anchors.fill: parent
- width: parent.width
- height: parent.height*0.5
- spacing:5
- Rectangle {
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- radius: 5
- Column{
- anchors.fill: parent
- spacing: 5
- //anchors.leftMargin: 10
- AppImage {
- id: image_01
- // 将元素的顶部锚定到父元素的顶部
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/a.svg"
- }
- AppText{
- id: text_devicesta
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "工作状态:"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Timer {
- interval: 500
- running: true
- repeat: true
- onTriggered: {
- text_gps.text = "GPS状态:" + gps_state
- if(mqtt.checkLink()){
- mqtt_text.text="MQTT已连接:" + net_list[5]
- }else{
- mqtt_text.text="MQTT已断开:" + net_list[5]
- }
- net_list = mqtt.netMessage()
- if(net_list){
- if(net_list[0]==="1"){isonline = true}else{isonline = false}
- net_sta.text = qsTr("<b>联网状态:</b> %1").arg(isonline? "已联网" : "未联网")
- net_sta.color = qsTr("%1").arg(isonline? "green" : "red")
- ipv4.text = qsTr("<b>[IPV4] </b> %1").arg(net_list[4])
- mac.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3])
- datt_text.text = "数据上传间隔:" + net_list[6] + "分钟"
- netxd_text.text = "下一次数据上传:" + net_list[7] + "秒"
- }
- }
- }
- Column{
- anchors.fill: parent
- spacing: 5
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/net.svg"
- }
- AppText{
- id: text_net_title
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "网络信息"
- color: app.fontColor
- font.bold: true
- }
- AppText{
- id: ipv4
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"IPv4:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: mac
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"MAC:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: mqtt_text
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"MQTT断开连接:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: datt_text
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"数据上传间隔:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: netxd_text
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"下一次数据传:"
- fontSize: 10
- color: "gray"
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Column{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- spacing: 5
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/gps.svg"
- }
- AppText{
- id: text_gps_title
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "定位信息"
- color: app.fontColor
- font.bold: true
- }
- AppText{
- id: text_lat
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"lat:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: text_lng
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"lng:"
- fontSize: 10
- color: "gray"
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Rectangle{
- id: rec_seting
- anchors.fill: parent
- visible: false
- AppText {
- //anchors.top: parent
- //anchors.topMargin:10
- text:"采集时间设置"
- anchors.horizontalCenter: parent.horizontalCenter
- font.bold: true
- }
- Grid {
- anchors.centerIn: parent
- //anchors.horizontalCenter: parent.horizontalCenter
- columns: 2
- rows: 3
- rowSpacing: 5
- columnSpacing: 20
- AppTextField {
- id: sh1_textfield
- width: 60
- height: 30
- borderWidth: dp(1)
- radius: 5
- // Displays a number only keyboard on mobiles
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppTextField {
- id: sh2_textfield
- width: 60
- height: 30
- borderWidth: dp(1)
- radius: 5
- // Displays a number only keyboard on mobiles
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppTextField {
- id: sh3_textfield
- width: 60
- height: 30
- borderWidth: dp(1)
- radius: 5
- // Displays a number only keyboard on mobiles
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppTextField {
- id: sh4_textfield
- width: 60
- height: 30
- borderWidth: dp(1)
- radius: 5
- // Displays a number only keyboard on mobiles
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppTextField {
- id: sh5_textfield
- width: 60
- height: 30
- borderWidth: dp(1)
- radius: 5
- // Displays a number only keyboard on mobiles
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppTextField {
- id: sh6_textfield
- width: 60
- height: 30
- borderWidth: dp(1)
- radius: 5
- // Displays a number only keyboard on mobiles
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- }
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 5
- //spacing: -15
- AppButton {
- minimumWidth: 30
- minimumHeight: 15
- textSize: 15
- fontBold: false
- iconSize: 10
- text: "取消"
- textColor: "black"
- flat: false
- backgroundColor: "#e9e9e9"
- borderColor: "white"
- onClicked: {
- rec_seting.visible = false
- column_colt.visible = true
- appimage_set.visible = true
- image_timesvg.visible = true
- }
- }
- AppButton {
- minimumWidth: 30
- minimumHeight: 15
- textSize: 15
- text: "保存"
- textColor: "white"
- flat: false
- backgroundColor: "#0aa26b"
- borderColor: "white"
- onClicked: {
- var int_sh1 = parseInt(sh1_textfield.text)
- var int_eh1 = parseInt(sh2_textfield.text)
- var int_sh2 = parseInt(sh3_textfield.text)
- var int_eh2 = parseInt(sh4_textfield.text)
- var int_sh3 = parseInt(sh5_textfield.text)
- var int_eh3 = parseInt(sh6_textfield.text)
- serial.setCollt(int_sh1,int_eh1,int_sh2,int_eh2,int_sh3,int_eh3)
- rec_seting.visible = false
- column_colt.visible = true
- appimage_set.visible = true
- image_timesvg.visible = true
- }
- }
- }
- }
- Column{
- id: column_colt
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- spacing: 5
- AppImage {
- id: image_timesvg
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/time.svg"
- }
- AppText{
- id: text_coll
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "采集时间"
- color: app.fontColor
- font.bold: true
- }
- AppText{
- id: sh1
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"09:00-10:00"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: sh2
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"14:00-16:00"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: sh3
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"17:00-19:00"
- fontSize: 10
- color: "gray"
- }
- AppImage {
- id: appimage_set
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/set.svg"
- AppButton{
- id: settime
- anchors.fill: parent
- //text:" 修改"
- textColor: "GRAY"
- textSize: 10
- flat: true
- onClicked: {
- var sh1Arry = sh1.text.split('-')
- var sh2Arry = sh2.text.split('-')
- var sh3Arry = sh3.text.split('-')
- sh1_textfield.text = parseInt(sh1Arry[0]);
- sh2_textfield.text= parseInt(sh1Arry[1]);
- sh3_textfield.text = parseInt(sh2Arry[0]);
- sh4_textfield.text = parseInt(sh2Arry[1]);
- sh5_textfield.text = parseInt(sh3Arry[0]);
- sh6_textfield.text = parseInt(sh3Arry[1]);
- column_colt.visible = false
- appimage_set.visible = false
- image_timesvg.visible = false
- rec_seting.visible = true
- }
- }
- }
- }
- }
- }
- Row {
- width: parent.width
- height: parent.height*0.38
- spacing: 5
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Column {
- anchors.centerIn: parent
- spacing: 5
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/tempture.svg"
- }
- AppText{
- id: text_tempture
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "温度:"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Column {
- anchors.centerIn: parent
- spacing: 5
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/humidity.svg"
- }
- AppText{
- id: text_humidity
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "湿度:"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Column {
- anchors.centerIn: parent
- spacing: 5
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/vbat.svg"
- }
- AppText{
- id: text_vbat
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "电压:"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Column {
- anchors.centerIn: parent
- spacing: 5
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/current.svg"
- }
- AppText{
- id: text_current
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "电流:"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- }
- }
- } // page
|