| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432 |
- 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 tapeMax: 50000
- property real tapeUsed: 0
- property real filterUsage: 0
- property bool tapeAlertShown: false
- property bool filterAlertShown: 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"
- text_current.text = "电流:" + jsonData.ext.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){
- tapeUsage = Number(jsonData.ext.tape_used)
- tapeUsed = Number(jsonData.ext.tape_used)
- if(tapeUsage >= 100 && !tapeAlertShown){
- tapeAlertShown = true
- nativeUtils.displayMessageBox("胶带更换提醒", "胶带使用量已达到100%,请及时更换胶带!", 1)
- }
- if(tapeUsage < 100) tapeAlertShown = false
- }
- }
-
- 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()
- }
- }
- 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)}`
- }
- // 胶带重置输入对话框
- 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: tapeMax.toFixed(0)
- 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()
- }
- }
- }
- }
- }
- 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
- }
- }
- }
- }
- }
- 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 {
- id: tapeText
- anchors.horizontalCenter: parent.horizontalCenter
- text: "胶带使用量(" + Number(tapeUsed).toString() + "/" + Number(tapeMax).toString() + "):" + tapeUsage.toFixed(2)+"%"
- color: tapeUsage >= 100 ? "red" : "gray"
- 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()
- }
- }
- ProgressBar {
- id: tapeProgressBar
- anchors.horizontalCenter: parent.horizontalCenter
- width: dp(100)
- height: dp(8)
- from: 0
- to: 100
- value: Math.min(tapeUsage, 100)
- }
- }
- }
- }
- 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"
- }
- }
- }
- 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: 5
- spacing: 8
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text:"采集时间设置"
- color: app.fontColor
- font.bold: true
- }
- // 第一时间段
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 2
- AppTextField {
- id: sh1_hour
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh1_min
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: "-"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh2_hour
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh2_min
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- }
- // 第二时间段
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 2
- AppTextField {
- id: sh3_hour
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh3_min
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: "-"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh4_hour
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh4_min
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- }
- // 第三时间段
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 2
- AppTextField {
- id: sh5_hour
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh5_min
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "分"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 59
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: "-"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh6_hour
- width: 35
- height: 28
- borderWidth: dp(1)
- radius: 3
- placeholderText: "时"
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator {
- bottom: 0
- top: 23
- }
- }
- AppText {
- anchors.verticalCenter: parent.verticalCenter
- text: ":"
- color: app.fontColor
- fontSize: 14
- font.bold: true
- }
- AppTextField {
- id: sh6_min
- width: 35
- height: 28
- 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: 45
- minimumHeight: 20
- 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: 45
- minimumHeight: 20
- 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
- }
- }
- }
- }
- }
- } // page
|