| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629 |
- import QtQuick
- import QtQuick.Controls
- import Felgo 4.0
- import "../controls"
- import "../common"
- import "../model"
- AppPage {
- id: home_Page
- signal updatebv(string bv)
- property string originalString: ""
- property string iccidString: ""
- property string boxtemptureString: ""
- property string collectString: ""
- property string gps_state: "定位中..."
- property string jsonenable_String: "关闭"
- property string imagenable_String: "关闭"
- property bool connect_board: false
- property var tt
- property bool isonline: false
- property var net_list:[]
- property real tapeUsage: 0
- property real filterUsage: 0
- property bool tapeAlertShown: false
- property bool filterAlertShown: false
- property bool lowVoltageAlertShown: false
- property real freq_filter: 0
- property real worked_day: 0
- navigationBarHidden: true
- backgroundColor: app.theme_backgroundColor
- Component.onCompleted: {
- // 主题初始化已由Main.qml的onInitTheme统一处理
- // 此处不再重复读取主题配置,避免颜色闪烁
- console.log("HomePage loaded, current theme:", app.theme_select)
- }
- Connections {
- target: networkMonitor
- // 监听可达性变化(如从断开到连接)
- function onReachabilityChanged() {
- let status = ""
- if(networkMonitor.reachability===0)
- {
- status = "未知"
- net_sta.color = "red"
- }else if(networkMonitor.reachability===1){
- status = "离线"
- net_sta.color = "red"
- }else if(networkMonitor.reachability===2){
- status = "本地"
- }else if(networkMonitor.reachability===3){
- status = "局域网"
- }else if(networkMonitor.reachability===4){
- status = "在线"
- net_sta.color = "green"
- }
- console.log("onReachabilityChanged:",networkMonitor.reachability)
- net_sta.text = "网络状态:" + status
- }
- // 监听传输介质变化(如从 Wi-Fi 切换到 4G)
- function onTransportMediumChanged() {
- let nettype = "未知"
- console.log("onTransportMediumChanged:",networkMonitor.transportMedium)
- if(networkMonitor.transportMedium===0)
- {
- nettype = "未知"
- }else if(networkMonitor.transportMedium===1){
- nettype = "有线"
- }else if(networkMonitor.transportMedium===2){
- nettype = "移动网络"
- }else if(networkMonitor.transportMedium===3){
- nettype = "WIFI"
- }else if(networkMonitor.transportMedium===4){
- nettype = "蓝牙"
- }
- net_type.text = "网络类型:" + nettype
- }
- // 监听受限网络状态(如公共 Wi-Fi 登录页)
- function onIsBehindCaptivePortalChanged() {
- }
- // 监听计量网络状态(如移动数据流量限制)
- function onIsMeteredChanged() {
- }
- }
- // 接收并显示日志消息
- Connections {
- target: mqtt
- function onConnected() {
- console.log("mqtt connect")
- }
- function onDisconnected() {
- console.log("mqtt disconnect")
- //mqtt_text.detailText="MQTT已断开"
- }
- }
- // Connections{
- // target: myClass
- // }
- //串口
- Connections{
- target: serial
- function onDataReceived(data){
- 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> 采集")
- }else if(jsonData.ext.work_sta==="2"){
- text_devicesta.text = qsTr("<b>工作状态:</b> 拍照")
- }else{
- text_devicesta.text = qsTr("<b>工作状态:</b>",jsonData.ext.work_sta)
- }
- if(jsonData.ext.gps==="1"){
- gps_state = "成功"
- }
- if(jsonData.ext.imei){
- originalString = jsonData.ext.imei
- }
- if(jsonData.ext.iccid){
- iccidString= jsonData.ext.iccid
- }
- if(jsonData.ext.coll_time&&jsonData.ext.coll_min){
- var sh1Arry = jsonData.ext.coll_time[0].split('-')
- var sh2Arry = jsonData.ext.coll_time[1].split('-')
- var sh3Arry = jsonData.ext.coll_time[2].split('-')
- var min_arry0 = jsonData.ext.coll_min[0].split('-')
- var min_arry1 = jsonData.ext.coll_min[1].split('-')
- var min_arry2 = jsonData.ext.coll_min[2].split('-')
- sh1.text = parseInt(sh1Arry[0])+ ":" + parseInt(min_arry0[0]) + " - " + parseInt(sh1Arry[1]) + ":" + parseInt(min_arry0[1])
- sh2.text = parseInt(sh2Arry[0])+ ":" + parseInt(min_arry1[0]) + " - " + parseInt(sh2Arry[1]) + ":" + parseInt(min_arry1[1])
- sh3.text = parseInt(sh3Arry[0])+ ":" + parseInt(min_arry2[0]) + " - " + parseInt(sh3Arry[1]) + ":" + parseInt(min_arry2[1])
- }
- if(jsonData.ext.dat_f){
- serial.update_dat_f_main(jsonData.ext.dat_f);
- }
- if(jsonData.ext.boxtem){
- text_tempture0.text = "箱内温度:" + jsonData.ext.boxtem + "℃"
- }
- text_tempture.text = "环境温度:" + jsonData.ext.at + "℃"
- text_humidity.text = "湿度:" + jsonData.ext.ah + "%RH"
- text_vbat.text = "电压:" + jsonData.ext.vbat + "V"
- // 电压低于10V时弹框提示电源断电
- if(Number(jsonData.ext.vbat) < 10 && !lowVoltageAlertShown){
- lowVoltageAlertShown = true
- nativeUtils.displayMessageBox("电源断电提醒", "检测到电压低于10V,电源可能断电,请检查供电!", 1)
- }
- if(Number(jsonData.ext.vbat) >= 10) lowVoltageAlertShown = false
- text_current.text = "负载电流:" + jsonData.ext.current + "mA"
- if(jsonData.ext.fan_current){
- text_fan_current.text = "风机电流:" + jsonData.ext.fan_current + "mA"
- }
- text_lat.text = "lat:" + jsonData.ext.lat
- text_lng.text = "lng:" + jsonData.ext.lng
- const x_init_dis = jsonData?.ext?.x_init_dis;
- const y_init_dis = jsonData?.ext?.y_init_dis;
- if(x_init_dis ===0 || y_init_dis ===0)
- {
- serial.recoverMcuParam();
- }
- if(!textInput_x.focus){
- textInput_x.text = x_init_dis.toString();
- }
- if(!textInput_y.focus){
- textInput_y.text = y_init_dis.toString();
- }
- if(jsonData.ext.tps){
- if("1"===jsonData.ext.tps){
- text_tempture_sta.text = "保护:" + "["+ jsonData.ext.tpl +"]"
- app.tempProtectionState = true
- }else{
- text_tempture_sta.text = "正常:" + "["+ jsonData.ext.tpl +"]"
- app.tempProtectionState = false
- }
- }
- if(jsonData.ext.tph&&temp_setting.visible===false){
- highTempSlider.value = jsonData.ext.tph
- }
- if(jsonData.ext.tpl&&temp_setting.visible===false){
- lowTempSlider.value = jsonData.ext.tpl
- }
- var dvs = jsonData.ext.dver
- dvs = dvs.split("-")
- app.bvReceived(dvs[0])
- app.appReceived(dvs[1])
- if(jsonData.ext.tape_used){
- // tape_used为已使用量, tape_max为总长度, 使用百分比 = 已使用/总长 * 100
- if(Number(jsonData.ext.tape_max) > 0){
- tapeUsage = Number(jsonData.ext.tape_used) / Number(jsonData.ext.tape_max) * 100
- }else{
- tapeUsage = 0
- }
- if(tapeUsage >= 100 && !tapeAlertShown){
- tapeAlertShown = true
- nativeUtils.displayMessageBox("胶带更换提醒", "胶带使用量已达到100%,请及时更换胶带!", 1)
- }
- if(tapeUsage < 100) tapeAlertShown = false
- }
- if(jsonData.ext.filter_used){
- // filter_used为已使用量, filter_max为总长度, 使用百分比 = 已使用/总长 * 100
- if(Number(jsonData.ext.filter_max) > 0){
- filterUsage = Number(jsonData.ext.filter_used) / Number(jsonData.ext.filter_max) * 100
- }else{
- filterUsage = 0
- }
- if(filterUsage >= 100 && !filterAlertShown){
- filterAlertShown = true
- nativeUtils.displayMessageBox("滤网更换提醒", "滤网使用量已达到100%,请及时更换滤网!", 1)
- }
- if(filterUsage < 100) filterAlertShown = false
- }
- if(jsonData.ext.freq_filter){
- freq_filter = jsonData.ext.freq_filter
- }
- if(jsonData.ext.worked_day){
- worked_day = jsonData.ext.worked_day
- }
- }
-
- function onDisconnect_485(){
- text_devicesta.text =qsTr("485未连接,读取数据失败");
- originalString =serial.getId()
- iccidString=serial.getIccid()
- app.appReceived(serial.get_app_version())
- }
- function onGpsSuccess(){
- gps_state = "成功"
- text_lat.text = serial.getlat()
- text_lng.text = serial.getlng()
- }
- }
- // 胶带/滤网重置输入对话框
- AppModal {
- id: tapeResetModal
- fullscreen: false
- modalHeight: dp(200)
- visible: false
- Column {
- anchors.fill: parent
- padding: dp(20)
- spacing: dp(15)
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "请输入胶带使用量:"
- fontSize: 16
- font.bold: true
- }
- TextField {
- id: tapeInput
- anchors.horizontalCenter: parent.horizontalCenter
- width: dp(200)
- height: dp(40)
- text: "50000"
- inputMethodHints: Qt.ImhDigitsOnly
- }
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: dp(30)
- AppButton {
- text: "确定"
- onClicked: {
- tapeResetModal.close()
- serial.makeJsonRpc("tape_reset", tapeInput.text)
- }
- }
- AppButton {
- text: "取消"
- onClicked: {
- tapeResetModal.close()
- }
- }
- }
- }
- }
- // 滤网重置输入对话框
- AppModal {
- id: filterResetModal
- fullscreen: false
- modalHeight: dp(200)
- visible: false
- Column {
- anchors.fill: parent
- padding: dp(20)
- spacing: dp(15)
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "请输入滤网使用量:"
- fontSize: 16
- font.bold: true
- }
- TextField {
- id: filterInput
- anchors.horizontalCenter: parent.horizontalCenter
- width: dp(200)
- height: dp(40)
- text: "1000"
- inputMethodHints: Qt.ImhDigitsOnly
- }
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: dp(30)
- AppButton {
- text: "确定"
- onClicked: {
- filterResetModal.close()
- serial.makeJsonRpc("filter_reset", filterInput.text)
- }
- }
- AppButton {
- text: "取消"
- onClicked: {
- filterResetModal.close()
- }
- }
- }
- }
- }
- 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"
- }
- }
- // 关键:将月、日、时、分、秒补到两位(不足补0)
- var formatNum = (num) => String(num).padStart(2, '0')
- return `${years}-${formatNum(mon)}-${formatNum(dates)} ${formatNum(hours)}:${formatNum(mins)}:${formatNum(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 {
- width: parent.width
- height: parent.height
- color: app.cardColor
- radius: 2
- // 使用Item作为容器,设置固定位置和大小
- Item {
- anchors.fill: parent
- Row {
- anchors.verticalCenter: parent.verticalCenter
- width: parent.width
- height: parent.height
- spacing: dp(20)
- AppText{
- id: text_stamp
- verticalAlignment: Text.AlignVCenter
- height: parent.height
- text: ""
- fontSize: 20
- color: app.fontColor
- }
- AppText{
- id: text_imei
- verticalAlignment: Text.AlignVCenter
- height: parent.height
- text:"设备ID:" + originalString.toLowerCase()
- fontSize: 20
- color: app.fontColor
- }
- AppText{
- id: net_sta
- verticalAlignment: Text.AlignVCenter
- height: parent.height
- color: app.fontColor
- text: "联网状态:"
- fontSize: 20
- //font.bold: true
- }
- AppText{
- id: net_type
- verticalAlignment: Text.AlignVCenter
- height: parent.height
- color: app.fontColor
- text: "联网类型:"
- fontSize: 20
- //font.bold: true
- }
- AppText{
- id: text_gps
- verticalAlignment: Text.AlignVCenter
- height: parent.height
- text: "GPS状态:" + gps_state
- color: app.fontColor
- //font.bold: true
- fontSize: 20
- }
- // 相机连接状态:绿=已连接 红=未连接
- // 状态源:serial 3秒一次后台枚举海康相机,枚举数量>0=已连接,=0=未连接
- AppText{
- id: text_cam_sta
- verticalAlignment: Text.AlignVCenter
- height: parent.height
- text: "相机状态:" + (serial.cameraConnected ? "已连接" : "未连接")
- color: serial.cameraConnected ? "#28a779" : "#e74c3c"
- fontSize: 20
- }
- }
- }
- }
- }
- Row{
- //anchors.fill: parent
- width: parent.width
- height: parent.height*0.5
- spacing:5
- Rectangle {
- id: container
- width: parent.width * 0.245
- height: parent.height
- color: app.cardColor
- radius: 5
- Rectangle {
- id: focus_setting
- anchors.fill: parent
- visible: false
- radius: 5
- color: app.cardColor
- // X坐标输入行(结构同优化前)
- Column {
- anchors.fill: parent
- spacing: 10
- Row {
- width: parent.width*0.6
- spacing: 5
- AppText {
- text: "X坐标:"
- color: app.fontColor
- font.pixelSize: 20
- }
- // 使用边框包裹
- ItemDelegate {
- width: parent.width
- height: 42
- padding: 0
- contentItem: AppTextInput {
- id: textInput_x
- width: parent.width
- height: parent.height
- placeholderText: "x_init_dis"
- text: "0"
- font.family: "Arial"
- font.pixelSize: 20
- inputMethodHints: Qt.ImhMultiLine
- // 使用验证器替代inputMask
- validator: DoubleValidator {
- decimals: 2
- }
- property real numericValue_x: Number(text) || 0
- Keys.onReturnPressed: {
- console.log("X坐标:", numericValue_x)
- serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
- coordinateInputs.visible = false
- }
- }
- // 边框样式
- Rectangle {
- anchors.fill: parent
- color: "transparent"
- border.color: textInput_x.activeFocus ? "blue" : "gray"
- border.width: 1
- radius: 4
- }
- }
- }
- // Y坐标输入行(结构同优化前)
- Row {
- width: parent.width*0.6
- spacing: 5
- AppText {
- text: "Y坐标:"
- color: app.fontColor
- font.pixelSize: 20
- }
- // 使用边框包裹
- ItemDelegate {
- width: parent.width
- height: 42
- padding: 0
- contentItem: AppTextInput {
- id: textInput_y
- width: parent.width
- height: parent.height
- placeholderText: "y_init_dis"
- text: "0"
- font.family: "Arial"
- font.pixelSize: 20
- wrapMode: Text.NoWrap
- inputMethodHints: Qt.ImhMultiLine
- // 使用验证器替代inputMask
- validator: DoubleValidator {
- decimals: 0
- }
- property real numericValue_y: Number(text) || 0
- Keys.onReturnPressed: {
- console.log("Y坐标:", numericValue_y)
- serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
- coordinateInputs.visible = false
- }
- }
- // 边框样式
- Rectangle {
- anchors.fill: parent
- color: "transparent"
- border.color: textInput_x.activeFocus ? "blue" : "gray"
- border.width: 1
- radius: 4
- }
- }
- }
- }
- }
- Column {
- anchors.centerIn: parent
- spacing: 8
- visible: true
- AppImage {
- id: image_01
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.topMargin: 15
- source: "../../assets/a.svg"
- fillMode: Image.PreserveAspectFit
- }
- AppText {
- id: text_devicesta
- anchors.horizontalCenter: parent.horizontalCenter
- text: "工作状态:"
- color: app.fontColor
- font.bold: true
- font.pixelSize: 16
- }
- // 胶带使用量
- Column {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 3
- width: dp(120)
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "胶带: " + tapeUsage.toFixed(2) + "%"
- color: tapeUsage >= 100 ? "#ff4444" : "#666666"
- fontSize: 12
- // 长按弹出重置确认对话框
- Timer {
- id: tapeLongPressTimer
- interval: 1000
- onTriggered: {
- tapeInput.text = "0"
- tapeResetModal.open()
- }
- }
- MouseArea {
- anchors.fill: parent
- onPressed: tapeLongPressTimer.start()
- onReleased: tapeLongPressTimer.stop()
- onCanceled: tapeLongPressTimer.stop()
- }
- }
- Rectangle {
- anchors.horizontalCenter: parent.horizontalCenter
- width: dp(100)
- height: dp(6)
- color: "#e8e8e8"
- radius: dp(3)
- Rectangle {
- width: parent.width * Math.min(tapeUsage, 100) / 100
- height: parent.height
- color: tapeUsage >= 100 ? "#ff4444" : "#28a779"
- radius: dp(3)
- }
- }
- }
- // 滤网使用量
- Column {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 3
- width: dp(120)
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "滤网: " + filterUsage.toFixed(2) + "%"
- color: filterUsage >= 100 ? "#ff4444" : "#666666"
- fontSize: 12
- // 长按弹出重置确认对话框
- Timer {
- id: filterLongPressTimer
- interval: 1000
- onTriggered: {
- filterInput.text = "0"
- filterResetModal.open()
- }
- }
- MouseArea {
- anchors.fill: parent
- onPressed: filterLongPressTimer.start()
- onReleased: filterLongPressTimer.stop()
- onCanceled: filterLongPressTimer.stop()
- }
- }
- Rectangle {
- anchors.horizontalCenter: parent.horizontalCenter
- width: dp(100)
- height: dp(6)
- color: "#e8e8e8"
- radius: dp(3)
- Rectangle {
- width: parent.width * Math.min(filterUsage, 100) / 100
- height: parent.height
- color: filterUsage >= 100 ? "#ff4444" : "#28a779"
- radius: dp(3)
- }
- }
- }
- // 自清洁周期
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "自清洁周期: " + Number(worked_day).toString() + "/" + Number(freq_filter).toString()
- color: app.fontColor
- fontSize: 11
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Timer {
- interval: 500
- running: true
- repeat: true
- onTriggered: {
- if(mqtt.checkLink()){
- mqtt_text.text="MQTT已连接:" + net_list[5]
- }else{
- mqtt_text.text="MQTT已断开:" + net_list[5]
- }
- net_list = mqtt.netMessage()
- if(mqtt.cache_Json_enable()===1){
- jsonenable_String = "开启"
- }else{
- jsonenable_String = "关闭"
- }
- if(mqtt.cache_image_enable()===1){
- imagenable_String = "开启"
- }else{
- imagenable_String = "关闭"
- }
- cache_json_text.text= "数据缓存:" + mqtt.cache_json_num() +
- "("+ mqtt.cache_Json_Maxnum()+")" + jsonenable_String
- cache_image_text.text = "图片缓存:" + mqtt.cache_image_num()+
- "("+mqtt.cache_image_Maxnum()+")" + imagenable_String
- 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] + "秒"
- iccid_text.text = "SIM卡号:" + iccidString
- }
- }
- }
- Timer {
- id: longPressTimer
- interval: 1000 // 1秒
- onTriggered: {
- console.log("长按触发")
- serial.uploadData_Mqtt()
- }
- }
- MouseArea {
- anchors.fill: parent
- onPressed:{
- longPressTimer.start()
- }
- onReleased:{
- longPressTimer.stop()
- }
- }
- Column{
- anchors.centerIn: 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: 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"
- }
- AppText{
- id: iccid_text
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"SIM卡号:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: cache_json_text
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"数据缓存:"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: cache_image_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.centerIn: parent
- 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"
- }
- AppText{
- id: text_alt
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"海拔:--"
- fontSize: 10
- color: "gray"
- }
- AppText{
- id: text_sat
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"卫星:可视--/已用--"
- fontSize: 10
- color: "gray"
- }
- }
- // 海拔/卫星数来自面板自身GNSS(main.cpp GPSInfo写入param),定时刷新
- // 注:MCU的data报文目前只有lat/lng,海拔与卫星数取自面板GNSS
- Timer {
- interval: 1000
- running: true
- repeat: true
- onTriggered: {
- var alt = serial.getElevation()
- var view = serial.getSatView()
- var used = serial.getSatUsed()
- text_alt.text = "海拔:" + (alt !== "" ? alt + "m" : "--")
- text_sat.text = "卫星:可视" + (view !== "" ? view : "--") + "/已用" + (used !== "" ? used : "--")
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Rectangle{
- id: rec_seting
- anchors.fill: parent
- visible: false
- Column {
- anchors.fill: parent
- anchors.margins: dp(8)
- spacing: dp(6)
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text:"采集时间设置"
- color: app.fontColor
- font.bold: true
- }
- // 第一时间段
- Row {
- width: parent.width
- spacing: dp(2)
- AppTextField {
- id: sh1_hour
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh1_min
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: "-"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh2_hour
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh2_min
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- }
- // 第二时间段
- Row {
- width: parent.width
- spacing: dp(2)
- AppTextField {
- id: sh3_hour
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh3_min
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: "-"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh4_hour
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh4_min
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- }
- // 第三时间段
- Row {
- width: parent.width
- spacing: dp(2)
- AppTextField {
- id: sh5_hour
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh5_min
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: "-"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh6_hour
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- width: dp(12)
- horizontalAlignment: Text.AlignHCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh6_min
- width: (parent.width - dp(48)) / 4
- height: dp(38)
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- }
- }
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 5
- spacing: 10
- AppButton {
- minimumWidth: dp(70)
- minimumHeight: dp(34)
- textSize: 12
- fontBold: false
- 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: dp(70)
- minimumHeight: dp(34)
- textSize: 12
- text: "保存"
- textColor: "white"
- flat: false
- backgroundColor: "#0aa26b"
- borderColor: "white"
- onClicked: {
- var int_sh1 = parseInt(sh1_hour.text) || 0
- var int_sh1_min = parseInt(sh1_min.text) || 0
- var int_eh1 = parseInt(sh2_hour.text) || 0
- var int_eh1_min = parseInt(sh2_min.text) || 0
- var int_sh2 = parseInt(sh3_hour.text) || 0
- var int_sh2_min = parseInt(sh3_min.text) || 0
- var int_eh2 = parseInt(sh4_hour.text) || 0
- var int_eh2_min = parseInt(sh4_min.text) || 0
- var int_sh3 = parseInt(sh5_hour.text) || 0
- var int_sh3_min = parseInt(sh5_min.text) || 0
- var int_eh3 = parseInt(sh6_hour.text) || 0
- var int_eh3_min = parseInt(sh6_min.text) || 0
- // 格式化时间字符串
- var time1 = (int_sh1 < 10 ? "0" + int_sh1 : int_sh1) + ":" + (int_sh1_min < 10 ? "0" + int_sh1_min : int_sh1_min) + "-" +
- (int_eh1 < 10 ? "0" + int_eh1 : int_eh1) + ":" + (int_eh1_min < 10 ? "0" + int_eh1_min : int_eh1_min)
- var time2 = (int_sh2 < 10 ? "0" + int_sh2 : int_sh2) + ":" + (int_sh2_min < 10 ? "0" + int_sh2_min : int_sh2_min) + "-" +
- (int_eh2 < 10 ? "0" + int_eh2 : int_eh2) + ":" + (int_eh2_min < 10 ? "0" + int_eh2_min : int_eh2_min)
- var time3 = (int_sh3 < 10 ? "0" + int_sh3 : int_sh3) + ":" + (int_sh3_min < 10 ? "0" + int_sh3_min : int_sh3_min) + "-" +
- (int_eh3 < 10 ? "0" + int_eh3 : int_eh3) + ":" + (int_eh3_min < 10 ? "0" + int_eh3_min : int_eh3_min)
- // 更新显示
- sh1.text = time1
- sh2.text = time2
- sh3.text = time3
- // 调用serial接口(注意:这里可能需要根据实际接口调整参数)
- serial.setCollt(int_sh1, int_eh1, int_sh2, int_eh2, int_sh3, int_eh3)
- serial.setCollt_min(int_sh1_min, int_eh1_min, int_sh2_min, int_eh2_min, int_sh3_min, int_eh3_min)
- rec_seting.visible = false
- column_colt.visible = true
- appimage_set.visible = true
- image_timesvg.visible = true
- }
- }
- }
- }
- Column{
- id: column_colt
- anchors.centerIn: parent
- spacing: 5
- visible: true
- AppImage {
- id: image_timesvg
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- visible: true
- 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 //垂直居中显示
- visible: true
- 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('-')
- // 解析第一时间段
- var time1_start = sh1Arry[0].split(':')
- var time1_end = sh1Arry[1].split(':')
- sh1_hour.text = parseInt(time1_start[0]) || 0
- sh1_min.text = parseInt(time1_start[1]) || 0
- sh2_hour.text = parseInt(time1_end[0]) || 0
- sh2_min.text = parseInt(time1_end[1]) || 0
- // 解析第二时间段
- var time2_start = sh2Arry[0].split(':')
- var time2_end = sh2Arry[1].split(':')
- sh3_hour.text = parseInt(time2_start[0]) || 0
- sh3_min.text = parseInt(time2_start[1]) || 0
- sh4_hour.text = parseInt(time2_end[0]) || 0
- sh4_min.text = parseInt(time2_end[1]) || 0
- // 解析第三时间段
- var time3_start = sh3Arry[0].split(':')
- var time3_end = sh3Arry[1].split(':')
- sh5_hour.text = parseInt(time3_start[0]) || 0
- sh5_min.text = parseInt(time3_start[1]) || 0
- sh6_hour.text = parseInt(time3_end[0]) || 0
- sh6_min.text = parseInt(time3_end[1]) || 0
- 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 {
- id: temp_card
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- Rectangle {
- id: temp_setting
- anchors.fill: parent
- visible: false
- radius: 5
- color: app.cardColor
- Column {
- anchors.fill: parent
- anchors.margins: 8
- spacing: 8
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "温度保护设置"
- color: app.fontColor
- font.bold: true
- fontSize: 14
- }
- // 高温保护阈值
- Item {
- width: parent.width
- height: 50
- Column {
- anchors.fill: parent
- spacing: 3
- AppText {
- text: "高温保护: " + highTempSlider.value + "℃"
- color: app.fontColor
- fontSize: 11
- }
- Slider {
- id: highTempSlider
- width: parent.width - 20
- anchors.horizontalCenter: parent.horizontalCenter
- from: 30
- to: 70
- value: 50
- snapMode: Slider.SnapOnRelease
- stepSize: 1
- }
- }
- }
- // 低温保护阈值
- Item {
- width: parent.width
- height: 50
- Column {
- anchors.fill: parent
- spacing: 3
- AppText {
- text: "低温保护: " + lowTempSlider.value + "℃"
- color: app.fontColor
- fontSize: 11
- }
- Slider {
- id: lowTempSlider
- width: parent.width - 20
- anchors.horizontalCenter: parent.horizontalCenter
- from: -40
- to: 10
- value: 20
- snapMode: Slider.SnapOnRelease
- stepSize: 1
- }
- }
- }
- Item {
- width: parent.width
- height: 40
- Row {
- anchors.centerIn: parent
- spacing: 10
- AppButton {
- minimumWidth: 50
- minimumHeight: 25
- textSize: 10
- text: "取消"
- textColor: "black"
- flat: false
- backgroundColor: "#e9e9e9"
- onClicked: {
- temp_setting.visible = false
- temp_display.visible = true
- }
- }
- AppButton {
- minimumWidth: 50
- minimumHeight: 25
- textSize: 10
- text: "保存"
- textColor: "white"
- flat: false
- backgroundColor: "#0aa26b"
- onClicked: {
- console.log("保存温度设置 - 高温:", highTempSlider.value, "低温:", lowTempSlider.value)
- serial.setTempconf(lowTempSlider.value,highTempSlider.value);
- // 这里可以添加保存设置的逻辑
- temp_setting.visible = false
- temp_display.visible = true
- }
- }
- }
- }
- }
- }
- Column {
- id: temp_display
- 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
- }
- AppText{
- id: text_tempture0
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "箱内温度:"
- color: app.fontColor
- font.bold: true
- }
- AppText{
- id: text_tempture_sta
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text:"正常"
- fontSize: 10
- color: "gray"
- }
- AppImage {
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/set.svg"
- AppButton{
- anchors.fill: parent
- textColor: "GRAY"
- textSize: 10
- flat: true
- onClicked: {
- temp_display.visible = false
- temp_setting.visible = 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
- }
- AppText{
- id: text_fan_current
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "风机电流:"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- }
- }
- } // page
|