| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343 |
- 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.00
- property real tape_used: 0
- property real tape_max: 0
- property bool tapeAlertShown: false // 胶带更换提醒是否已弹出
- 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===2){
- nettype = "移动网络"
- }else if(networkMonitor.transportMedium===1){
- 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(y_init_dis ===0)
- {
- serial.recoverMcuParam();
- }
- 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 !== undefined && jsonData.ext.tape_max !== undefined && jsonData.ext.tape_max !== null){
- // 解析胶带使用量和最大用量,计算百分比
- tape_used = jsonData.ext.tape_used
- tape_max = jsonData.ext.tape_max
- // 计算百分比:(已使用/最大用量) * 100
- if(tape_max > 0){
- tapeUsage = (tape_used / tape_max) * 100
- } else {
- tapeUsage = 0
- }
- 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()
- }
- }
- // 胶带重置输入对话框
- 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()
- }
- }
- }
- }
- }
- 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
- }
- }
- }
- }
- }
- 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
- Column {
- anchors.centerIn: parent
- spacing: 12
- visible: true
- AppImage {
- id: image_01
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.topMargin: 30
- 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(tape_used).toString() + "/" + Number(tape_max).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)
- }
- }
- // AppImage {
- // id: focus_xy_set
- // anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- // fillMode: Image.PreserveAspectFit // 保持纵横比适应
- // source: "../../assets/set.svg"
- // AppButton{
- // anchors.fill: parent
- // //text:" 修改"
- // textColor: "GRAY"
- // textSize: 10
- // flat: true
- // onClicked: {
- // focus_setting.visible = !focus_setting.visible
- // text_devicesta.visible = !text_devicesta.visible
- // image_01.visible = !image_01.visible
- // }
- // }
- // }
- }
- }
- 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
|