HomePage.qml 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  1. import QtQuick
  2. import QtQuick.Controls
  3. import Felgo 4.0
  4. import "../controls"
  5. import "../common"
  6. import "../model"
  7. AppPage {
  8. id: home_Page
  9. signal updatebv(string bv)
  10. property string originalString: ""
  11. property string iccidString: ""
  12. property string boxtemptureString: ""
  13. property string collectString: ""
  14. property string gps_state: "定位中..."
  15. property string jsonenable_String: "关闭"
  16. property string imagenable_String: "关闭"
  17. property bool connect_board: false
  18. property var tt
  19. property bool isonline: false
  20. property var net_list:[]
  21. property real tapeUsage: 0.00
  22. property real tape_used: 0
  23. property real tape_max: 0
  24. property bool tapeAlertShown: false // 胶带更换提醒是否已弹出
  25. navigationBarHidden: true
  26. backgroundColor: app.theme_backgroundColor
  27. Component.onCompleted: {
  28. // 主题初始化已由Main.qml的onInitTheme统一处理
  29. // 此处不再重复读取主题配置,避免颜色闪烁
  30. console.log("HomePage loaded, current theme:", app.theme_select)
  31. }
  32. Connections {
  33. target: networkMonitor
  34. // 监听可达性变化(如从断开到连接)
  35. function onReachabilityChanged() {
  36. let status = ""
  37. if(networkMonitor.reachability===0)
  38. {
  39. status = "未知"
  40. net_sta.color = "red"
  41. }else if(networkMonitor.reachability===1){
  42. status = "离线"
  43. net_sta.color = "red"
  44. }else if(networkMonitor.reachability===2){
  45. status = "本地"
  46. }else if(networkMonitor.reachability===3){
  47. status = "局域网"
  48. }else if(networkMonitor.reachability===4){
  49. status = "在线"
  50. net_sta.color = "green"
  51. }
  52. console.log("onReachabilityChanged:",networkMonitor.reachability)
  53. net_sta.text = "网络状态:" + status
  54. }
  55. // 监听传输介质变化(如从 Wi-Fi 切换到 4G)
  56. function onTransportMediumChanged() {
  57. let nettype = "未知"
  58. console.log("onTransportMediumChanged:",networkMonitor.transportMedium)
  59. if(networkMonitor.transportMedium===0)
  60. {
  61. nettype = "未知"
  62. }else if(networkMonitor.transportMedium===2){
  63. nettype = "移动网络"
  64. }else if(networkMonitor.transportMedium===1){
  65. nettype = "有线"
  66. }else if(networkMonitor.transportMedium===3){
  67. nettype = "WIFI"
  68. }else if(networkMonitor.transportMedium===4){
  69. nettype = "蓝牙"
  70. }
  71. net_type.text = "网络类型:" + nettype
  72. }
  73. // 监听受限网络状态(如公共 Wi-Fi 登录页)
  74. function onIsBehindCaptivePortalChanged() {
  75. }
  76. // 监听计量网络状态(如移动数据流量限制)
  77. function onIsMeteredChanged() {
  78. }
  79. }
  80. // 接收并显示日志消息
  81. Connections {
  82. target: mqtt
  83. function onConnected() {
  84. console.log("mqtt connect")
  85. }
  86. function onDisconnected() {
  87. console.log("mqtt disconnect")
  88. //mqtt_text.detailText="MQTT已断开"
  89. }
  90. }
  91. // Connections{
  92. // target: myClass
  93. // }
  94. //串口
  95. Connections{
  96. target: serial
  97. function onDataReceived(data){
  98. var jsonData = JSON.parse(data)
  99. console.log("接收到主板数据:",data.toString())
  100. if(jsonData.ext.work_sta==="0"){
  101. text_devicesta.text = qsTr("<b>工作状态:</b> 待机")
  102. if(jsonData.ext.ds==="0"){
  103. }else{
  104. }
  105. }else if(jsonData.ext.work_sta==="1"){
  106. text_devicesta.text = qsTr("<b>工作状态:</b> 采集")
  107. }else if(jsonData.ext.work_sta==="2"){
  108. text_devicesta.text = qsTr("<b>工作状态:</b> 拍照")
  109. }else{
  110. text_devicesta.text = qsTr("<b>工作状态:</b>",jsonData.ext.work_sta)
  111. }
  112. if(jsonData.ext.gps==="1"){
  113. gps_state = "成功"
  114. }
  115. if(jsonData.ext.imei){
  116. originalString = jsonData.ext.imei
  117. }
  118. if(jsonData.ext.iccid){
  119. iccidString= jsonData.ext.iccid
  120. }
  121. if(jsonData.ext.coll_time&&jsonData.ext.coll_min){
  122. var sh1Arry = jsonData.ext.coll_time[0].split('-')
  123. var sh2Arry = jsonData.ext.coll_time[1].split('-')
  124. var sh3Arry = jsonData.ext.coll_time[2].split('-')
  125. var min_arry0 = jsonData.ext.coll_min[0].split('-')
  126. var min_arry1 = jsonData.ext.coll_min[1].split('-')
  127. var min_arry2 = jsonData.ext.coll_min[2].split('-')
  128. sh1.text = parseInt(sh1Arry[0])+ ":" + parseInt(min_arry0[0]) + " - " + parseInt(sh1Arry[1]) + ":" + parseInt(min_arry0[1])
  129. sh2.text = parseInt(sh2Arry[0])+ ":" + parseInt(min_arry1[0]) + " - " + parseInt(sh2Arry[1]) + ":" + parseInt(min_arry1[1])
  130. sh3.text = parseInt(sh3Arry[0])+ ":" + parseInt(min_arry2[0]) + " - " + parseInt(sh3Arry[1]) + ":" + parseInt(min_arry2[1])
  131. }
  132. if(jsonData.ext.dat_f){
  133. serial.update_dat_f_main(jsonData.ext.dat_f);
  134. }
  135. if(jsonData.ext.boxtem){
  136. text_tempture0.text = "箱内温度:" + jsonData.ext.boxtem + "℃"
  137. }
  138. text_tempture.text = "环境温度:" + jsonData.ext.at + "℃"
  139. text_humidity.text = "湿度:" + jsonData.ext.ah + "%RH"
  140. text_vbat.text = "电压:" + jsonData.ext.vbat + "V"
  141. text_current.text = "电流:" + jsonData.ext.current + "mA"
  142. text_lat.text = "lat:" + jsonData.ext.lat
  143. text_lng.text = "lng:" + jsonData.ext.lng
  144. const x_init_dis = jsonData?.ext?.x_init_dis;
  145. const y_init_dis = jsonData?.ext?.y_init_dis;
  146. if(y_init_dis ===0)
  147. {
  148. serial.recoverMcuParam();
  149. }
  150. if(jsonData.ext.tps){
  151. if("1"===jsonData.ext.tps){
  152. text_tempture_sta.text = "保护:" + "["+ jsonData.ext.tpl +"]"
  153. app.tempProtectionState = true // 更新温度保护状态为保护中
  154. }else{
  155. text_tempture_sta.text = "正常:" + "["+ jsonData.ext.tpl +"]"
  156. app.tempProtectionState = false // 更新温度保护状态为正常
  157. }
  158. }
  159. if(jsonData.ext.tph&&temp_setting.visible===false){
  160. highTempSlider.value = jsonData.ext.tph
  161. }
  162. if(jsonData.ext.tpl&&temp_setting.visible===false){
  163. lowTempSlider.value = jsonData.ext.tpl
  164. }
  165. var dvs = jsonData.ext.dver
  166. dvs = dvs.split("-")
  167. app.bvReceived(dvs[0])
  168. app.appReceived(dvs[1])
  169. if(jsonData.ext.tape_used !== undefined && jsonData.ext.tape_max !== undefined && jsonData.ext.tape_max !== null){
  170. // 解析胶带使用量和最大用量,计算百分比
  171. tape_used = jsonData.ext.tape_used
  172. tape_max = jsonData.ext.tape_max
  173. // 计算百分比:(已使用/最大用量) * 100
  174. if(tape_max > 0){
  175. tapeUsage = (tape_used / tape_max) * 100
  176. } else {
  177. tapeUsage = 0
  178. }
  179. if(tapeUsage >= 100 && !tapeAlertShown){
  180. tapeAlertShown = true
  181. nativeUtils.displayMessageBox("胶带更换提醒", "胶带使用量已达到100%,请及时更换胶带!", 1)
  182. }
  183. if(tapeUsage < 100) tapeAlertShown = false
  184. }
  185. }
  186. function onDisconnect_485(){
  187. text_devicesta.text =qsTr("485未连接,读取数据失败");
  188. originalString =serial.getId()
  189. iccidString=serial.getIccid()
  190. app.appReceived(serial.get_app_version())
  191. }
  192. function onGpsSuccess(){
  193. gps_state = "成功"
  194. text_lat.text = serial.getlat()
  195. text_lng.text = serial.getlng()
  196. }
  197. }
  198. // 胶带重置输入对话框
  199. AppModal {
  200. id: tapeResetModal
  201. fullscreen: false
  202. modalHeight: dp(200)
  203. visible: false
  204. Column {
  205. anchors.fill: parent
  206. padding: dp(20)
  207. spacing: dp(15)
  208. AppText {
  209. anchors.horizontalCenter: parent.horizontalCenter
  210. text: "请输入胶带使用量:"
  211. fontSize: 16
  212. font.bold: true
  213. }
  214. TextField {
  215. id: tapeInput
  216. anchors.horizontalCenter: parent.horizontalCenter
  217. width: dp(200)
  218. height: dp(40)
  219. text: "50000"
  220. inputMethodHints: Qt.ImhDigitsOnly
  221. }
  222. Row {
  223. anchors.horizontalCenter: parent.horizontalCenter
  224. spacing: dp(30)
  225. AppButton {
  226. text: "确定"
  227. onClicked: {
  228. tapeResetModal.close()
  229. serial.makeJsonRpc("tape_reset", tapeInput.text)
  230. }
  231. }
  232. AppButton {
  233. text: "取消"
  234. onClicked: {
  235. tapeResetModal.close()
  236. }
  237. }
  238. }
  239. }
  240. }
  241. Timer {
  242. interval: 100
  243. running: true
  244. repeat: true
  245. onTriggered: {
  246. text_stamp.text = getCurrentTime()
  247. }
  248. }
  249. function handleThemeChange(mode){
  250. theme_select = mode
  251. console.log("theme_select",theme_select)
  252. }
  253. function getCurrentTime() {
  254. var currentTime = new Date();
  255. var years = currentTime.getFullYear()
  256. var mon = currentTime.getMonth() + 1
  257. var dates = currentTime.getDate()
  258. var hours = currentTime.getHours()
  259. var mins = currentTime.getMinutes()
  260. var secs = currentTime.getSeconds()
  261. if(app.theme_md==="auto"){
  262. if(hours>=6&&hours<=18){
  263. app.theme_select = "day"
  264. }else{
  265. app.theme_select = "night"
  266. }
  267. }
  268. // 关键:将月、日、时、分、秒补到两位(不足补0)
  269. var formatNum = (num) => String(num).padStart(2, '0')
  270. return `${years}-${formatNum(mon)}-${formatNum(dates)} ${formatNum(hours)}:${formatNum(mins)}:${formatNum(secs)}`
  271. }
  272. Grid {
  273. anchors.fill: parent
  274. anchors.leftMargin: 5
  275. anchors.topMargin: 5
  276. //anchors.horizontalCenter: parent.horizontalCenter
  277. columns: 1
  278. rows: 3
  279. columnSpacing: 10
  280. rowSpacing: 5
  281. horizontalItemAlignment: Grid.AlignHCenter
  282. Row {
  283. width: parent.width *0.995
  284. height: parent.height*0.1
  285. Rectangle {
  286. width: parent.width
  287. height: parent.height
  288. color: app.cardColor
  289. radius: 2
  290. // 使用Item作为容器,设置固定位置和大小
  291. Item {
  292. anchors.fill: parent
  293. Row {
  294. anchors.verticalCenter: parent.verticalCenter
  295. width: parent.width
  296. height: parent.height
  297. spacing: dp(20)
  298. AppText{
  299. id: text_stamp
  300. verticalAlignment: Text.AlignVCenter
  301. height: parent.height
  302. text: ""
  303. fontSize: 20
  304. color: app.fontColor
  305. }
  306. AppText{
  307. id: text_imei
  308. verticalAlignment: Text.AlignVCenter
  309. height: parent.height
  310. text:"设备ID:" + originalString.toLowerCase()
  311. fontSize: 20
  312. color: app.fontColor
  313. }
  314. AppText{
  315. id: net_sta
  316. verticalAlignment: Text.AlignVCenter
  317. height: parent.height
  318. color: app.fontColor
  319. text: "联网状态:"
  320. fontSize: 20
  321. //font.bold: true
  322. }
  323. AppText{
  324. id: net_type
  325. verticalAlignment: Text.AlignVCenter
  326. height: parent.height
  327. color: app.fontColor
  328. text: "联网类型:"
  329. fontSize: 20
  330. //font.bold: true
  331. }
  332. AppText{
  333. id: text_gps
  334. verticalAlignment: Text.AlignVCenter
  335. height: parent.height
  336. text: "GPS状态:" + gps_state
  337. color: app.fontColor
  338. //font.bold: true
  339. fontSize: 20
  340. }
  341. }
  342. }
  343. }
  344. }
  345. Row{
  346. //anchors.fill: parent
  347. width: parent.width
  348. height: parent.height*0.5
  349. spacing:5
  350. Rectangle {
  351. id: container
  352. width: parent.width * 0.245
  353. height: parent.height
  354. color: app.cardColor
  355. radius: 5
  356. Column {
  357. anchors.centerIn: parent
  358. spacing: 12
  359. visible: true
  360. AppImage {
  361. id: image_01
  362. anchors.horizontalCenter: parent.horizontalCenter
  363. anchors.topMargin: 30
  364. source: "../../assets/a.svg"
  365. fillMode: Image.PreserveAspectFit
  366. }
  367. AppText {
  368. id: text_devicesta
  369. anchors.horizontalCenter: parent.horizontalCenter
  370. text: "工作状态:"
  371. color: app.fontColor
  372. font.bold: true
  373. font.pixelSize: 16
  374. }
  375. // 胶带使用量
  376. Column {
  377. anchors.horizontalCenter: parent.horizontalCenter
  378. spacing: 3
  379. width: dp(120)
  380. AppText {
  381. id: tapeText
  382. anchors.horizontalCenter: parent.horizontalCenter
  383. text: "胶带使用量(" + Number(tape_used).toString() + "/" + Number(tape_max).toString() + "):" + tapeUsage.toFixed(2)+"%"
  384. color: tapeUsage >= 100 ? "red" : "gray"
  385. fontSize: 12
  386. // 长按弹出重置确认对话框
  387. Timer {
  388. id: tapeLongPressTimer
  389. interval: 1000
  390. onTriggered: {
  391. tapeInput.text = "0"
  392. tapeResetModal.open()
  393. }
  394. }
  395. MouseArea {
  396. anchors.fill: parent
  397. onPressed: tapeLongPressTimer.start()
  398. onReleased: tapeLongPressTimer.stop()
  399. onCanceled: tapeLongPressTimer.stop()
  400. }
  401. }
  402. ProgressBar {
  403. id: tapeProgressBar
  404. anchors.horizontalCenter: parent.horizontalCenter
  405. width: dp(100)
  406. height: dp(8)
  407. from: 0
  408. to: 100
  409. value: Math.min(tapeUsage, 100)
  410. }
  411. }
  412. // AppImage {
  413. // id: focus_xy_set
  414. // anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  415. // fillMode: Image.PreserveAspectFit // 保持纵横比适应
  416. // source: "../../assets/set.svg"
  417. // AppButton{
  418. // anchors.fill: parent
  419. // //text:" 修改"
  420. // textColor: "GRAY"
  421. // textSize: 10
  422. // flat: true
  423. // onClicked: {
  424. // focus_setting.visible = !focus_setting.visible
  425. // text_devicesta.visible = !text_devicesta.visible
  426. // image_01.visible = !image_01.visible
  427. // }
  428. // }
  429. // }
  430. }
  431. }
  432. Rectangle {
  433. radius: 5
  434. width: parent.width*0.245
  435. height: parent.height
  436. color: app.cardColor
  437. Timer {
  438. interval: 500
  439. running: true
  440. repeat: true
  441. onTriggered: {
  442. if(mqtt.checkLink()){
  443. mqtt_text.text="MQTT已连接:" + net_list[5]
  444. }else{
  445. mqtt_text.text="MQTT已断开:" + net_list[5]
  446. }
  447. net_list = mqtt.netMessage()
  448. if(mqtt.cache_Json_enable()===1){
  449. jsonenable_String = "开启"
  450. }else{
  451. jsonenable_String = "关闭"
  452. }
  453. if(mqtt.cache_image_enable()===1){
  454. imagenable_String = "开启"
  455. }else{
  456. imagenable_String = "关闭"
  457. }
  458. cache_json_text.text= "数据缓存:" + mqtt.cache_json_num() +
  459. "("+ mqtt.cache_Json_Maxnum()+")" + jsonenable_String
  460. cache_image_text.text = "图片缓存:" + mqtt.cache_image_num()+
  461. "("+mqtt.cache_image_Maxnum()+")" + imagenable_String
  462. if(net_list){
  463. if(net_list[0]==="1"){isonline = true}else{isonline = false}
  464. net_sta.text = qsTr("<b>联网状态:</b> %1").arg(isonline? "已联网" : "未联网")
  465. net_sta.color = qsTr("%1").arg(isonline? "green" : "red")
  466. ipv4.text = qsTr("<b>[IPV4] </b> %1").arg(net_list[4])
  467. //mac.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3])
  468. datt_text.text = "数据上传间隔:" + net_list[6] + "分钟"
  469. netxd_text.text = "下一次数据上传:" + net_list[7] + "秒"
  470. iccid_text.text = "SIM卡号:" + iccidString
  471. }
  472. }
  473. }
  474. Timer {
  475. id: longPressTimer
  476. interval: 1000 // 1秒
  477. onTriggered: {
  478. console.log("长按触发")
  479. serial.uploadData_Mqtt()
  480. }
  481. }
  482. MouseArea {
  483. anchors.fill: parent
  484. onPressed:{
  485. longPressTimer.start()
  486. }
  487. onReleased:{
  488. longPressTimer.stop()
  489. }
  490. }
  491. Column{
  492. anchors.centerIn: parent
  493. spacing: 5
  494. AppImage {
  495. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  496. anchors.topMargin: 30
  497. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  498. source: "../../assets/net.svg"
  499. }
  500. AppText{
  501. id: text_net_title
  502. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  503. text: "网络信息"
  504. color: app.fontColor
  505. font.bold: true
  506. }
  507. AppText{
  508. id: ipv4
  509. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  510. text:"IPv4:"
  511. fontSize: 10
  512. color: "gray"
  513. }
  514. AppText{
  515. id: mqtt_text
  516. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  517. text:"MQTT断开连接:"
  518. fontSize: 10
  519. color: "gray"
  520. }
  521. AppText{
  522. id: datt_text
  523. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  524. text:"数据上传间隔:"
  525. fontSize: 10
  526. color: "gray"
  527. }
  528. AppText{
  529. id: netxd_text
  530. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  531. text:"下一次数据传:"
  532. fontSize: 10
  533. color: "gray"
  534. }
  535. AppText{
  536. id: iccid_text
  537. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  538. text:"SIM卡号:"
  539. fontSize: 10
  540. color: "gray"
  541. }
  542. AppText{
  543. id: cache_json_text
  544. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  545. text:"数据缓存:"
  546. fontSize: 10
  547. color: "gray"
  548. }
  549. AppText{
  550. id: cache_image_text
  551. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  552. text:"图片缓存:"
  553. fontSize: 10
  554. color: "gray"
  555. }
  556. }
  557. }
  558. Rectangle {
  559. radius: 5
  560. width: parent.width*0.245
  561. height: parent.height
  562. color: app.cardColor
  563. Column{
  564. anchors.centerIn: parent
  565. spacing: 5
  566. AppImage {
  567. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  568. anchors.topMargin: 30
  569. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  570. source: "../../assets/gps.svg"
  571. }
  572. AppText{
  573. id: text_gps_title
  574. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  575. text: "定位信息"
  576. color: app.fontColor
  577. font.bold: true
  578. }
  579. AppText{
  580. id: text_lat
  581. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  582. text:"lat:"
  583. fontSize: 10
  584. color: "gray"
  585. }
  586. AppText{
  587. id: text_lng
  588. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  589. text:"lng:"
  590. fontSize: 10
  591. color: "gray"
  592. }
  593. }
  594. }
  595. Rectangle {
  596. radius: 5
  597. width: parent.width*0.245
  598. height: parent.height
  599. color: app.cardColor
  600. Rectangle{
  601. id: rec_seting
  602. anchors.fill: parent
  603. visible: false
  604. Column {
  605. anchors.fill: parent
  606. anchors.margins: 5
  607. spacing: 8
  608. AppText {
  609. anchors.horizontalCenter: parent.horizontalCenter
  610. text:"采集时间设置"
  611. color: app.fontColor
  612. font.bold: true
  613. }
  614. // 第一时间段
  615. Row {
  616. anchors.horizontalCenter: parent.horizontalCenter
  617. spacing: 2
  618. AppTextField {
  619. id: sh1_hour
  620. width: 35
  621. height: 28
  622. borderWidth: dp(1)
  623. radius: 3
  624. placeholderText: "时"
  625. inputMethodHints: Qt.ImhDigitsOnly
  626. validator: IntValidator {
  627. bottom: 0
  628. top: 23
  629. }
  630. }
  631. AppText {
  632. anchors.verticalCenter: parent.verticalCenter
  633. text: ":"
  634. color: app.fontColor
  635. fontSize: 14
  636. font.bold: true
  637. }
  638. AppTextField {
  639. id: sh1_min
  640. width: 35
  641. height: 28
  642. borderWidth: dp(1)
  643. radius: 3
  644. placeholderText: "分"
  645. inputMethodHints: Qt.ImhDigitsOnly
  646. validator: IntValidator {
  647. bottom: 0
  648. top: 59
  649. }
  650. }
  651. AppText {
  652. anchors.verticalCenter: parent.verticalCenter
  653. text: "-"
  654. color: app.fontColor
  655. fontSize: 14
  656. font.bold: true
  657. }
  658. AppTextField {
  659. id: sh2_hour
  660. width: 35
  661. height: 28
  662. borderWidth: dp(1)
  663. radius: 3
  664. placeholderText: "时"
  665. inputMethodHints: Qt.ImhDigitsOnly
  666. validator: IntValidator {
  667. bottom: 0
  668. top: 23
  669. }
  670. }
  671. AppText {
  672. anchors.verticalCenter: parent.verticalCenter
  673. text: ":"
  674. color: app.fontColor
  675. fontSize: 14
  676. font.bold: true
  677. }
  678. AppTextField {
  679. id: sh2_min
  680. width: 35
  681. height: 28
  682. borderWidth: dp(1)
  683. radius: 3
  684. placeholderText: "分"
  685. inputMethodHints: Qt.ImhDigitsOnly
  686. validator: IntValidator {
  687. bottom: 0
  688. top: 59
  689. }
  690. }
  691. }
  692. // 第二时间段
  693. Row {
  694. anchors.horizontalCenter: parent.horizontalCenter
  695. spacing: 2
  696. AppTextField {
  697. id: sh3_hour
  698. width: 35
  699. height: 28
  700. borderWidth: dp(1)
  701. radius: 3
  702. placeholderText: "时"
  703. inputMethodHints: Qt.ImhDigitsOnly
  704. validator: IntValidator {
  705. bottom: 0
  706. top: 23
  707. }
  708. }
  709. AppText {
  710. anchors.verticalCenter: parent.verticalCenter
  711. text: ":"
  712. color: app.fontColor
  713. fontSize: 14
  714. font.bold: true
  715. }
  716. AppTextField {
  717. id: sh3_min
  718. width: 35
  719. height: 28
  720. borderWidth: dp(1)
  721. radius: 3
  722. placeholderText: "分"
  723. inputMethodHints: Qt.ImhDigitsOnly
  724. validator: IntValidator {
  725. bottom: 0
  726. top: 59
  727. }
  728. }
  729. AppText {
  730. anchors.verticalCenter: parent.verticalCenter
  731. text: "-"
  732. color: app.fontColor
  733. fontSize: 14
  734. font.bold: true
  735. }
  736. AppTextField {
  737. id: sh4_hour
  738. width: 35
  739. height: 28
  740. borderWidth: dp(1)
  741. radius: 3
  742. placeholderText: "时"
  743. inputMethodHints: Qt.ImhDigitsOnly
  744. validator: IntValidator {
  745. bottom: 0
  746. top: 23
  747. }
  748. }
  749. AppText {
  750. anchors.verticalCenter: parent.verticalCenter
  751. text: ":"
  752. color: app.fontColor
  753. fontSize: 14
  754. font.bold: true
  755. }
  756. AppTextField {
  757. id: sh4_min
  758. width: 35
  759. height: 28
  760. borderWidth: dp(1)
  761. radius: 3
  762. placeholderText: "分"
  763. inputMethodHints: Qt.ImhDigitsOnly
  764. validator: IntValidator {
  765. bottom: 0
  766. top: 59
  767. }
  768. }
  769. }
  770. // 第三时间段
  771. Row {
  772. anchors.horizontalCenter: parent.horizontalCenter
  773. spacing: 2
  774. AppTextField {
  775. id: sh5_hour
  776. width: 35
  777. height: 28
  778. borderWidth: dp(1)
  779. radius: 3
  780. placeholderText: "时"
  781. inputMethodHints: Qt.ImhDigitsOnly
  782. validator: IntValidator {
  783. bottom: 0
  784. top: 23
  785. }
  786. }
  787. AppText {
  788. anchors.verticalCenter: parent.verticalCenter
  789. text: ":"
  790. color: app.fontColor
  791. fontSize: 14
  792. font.bold: true
  793. }
  794. AppTextField {
  795. id: sh5_min
  796. width: 35
  797. height: 28
  798. borderWidth: dp(1)
  799. radius: 3
  800. placeholderText: "分"
  801. inputMethodHints: Qt.ImhDigitsOnly
  802. validator: IntValidator {
  803. bottom: 0
  804. top: 59
  805. }
  806. }
  807. AppText {
  808. anchors.verticalCenter: parent.verticalCenter
  809. text: "-"
  810. color: app.fontColor
  811. fontSize: 14
  812. font.bold: true
  813. }
  814. AppTextField {
  815. id: sh6_hour
  816. width: 35
  817. height: 28
  818. borderWidth: dp(1)
  819. radius: 3
  820. placeholderText: "时"
  821. inputMethodHints: Qt.ImhDigitsOnly
  822. validator: IntValidator {
  823. bottom: 0
  824. top: 23
  825. }
  826. }
  827. AppText {
  828. anchors.verticalCenter: parent.verticalCenter
  829. text: ":"
  830. color: app.fontColor
  831. fontSize: 14
  832. font.bold: true
  833. }
  834. AppTextField {
  835. id: sh6_min
  836. width: 35
  837. height: 28
  838. borderWidth: dp(1)
  839. radius: 3
  840. placeholderText: "分"
  841. inputMethodHints: Qt.ImhDigitsOnly
  842. validator: IntValidator {
  843. bottom: 0
  844. top: 59
  845. }
  846. }
  847. }
  848. }
  849. Row {
  850. anchors.horizontalCenter: parent.horizontalCenter
  851. anchors.bottom: parent.bottom
  852. anchors.bottomMargin: 5
  853. spacing: 10
  854. AppButton {
  855. minimumWidth: 45
  856. minimumHeight: 20
  857. textSize: 12
  858. fontBold: false
  859. text: "取消"
  860. textColor: "black"
  861. flat: false
  862. backgroundColor: "#e9e9e9"
  863. borderColor: "white"
  864. onClicked: {
  865. rec_seting.visible = false
  866. column_colt.visible = true
  867. appimage_set.visible = true
  868. image_timesvg.visible = true
  869. }
  870. }
  871. AppButton {
  872. minimumWidth: 45
  873. minimumHeight: 20
  874. textSize: 12
  875. text: "保存"
  876. textColor: "white"
  877. flat: false
  878. backgroundColor: "#0aa26b"
  879. borderColor: "white"
  880. onClicked: {
  881. var int_sh1 = parseInt(sh1_hour.text) || 0
  882. var int_sh1_min = parseInt(sh1_min.text) || 0
  883. var int_eh1 = parseInt(sh2_hour.text) || 0
  884. var int_eh1_min = parseInt(sh2_min.text) || 0
  885. var int_sh2 = parseInt(sh3_hour.text) || 0
  886. var int_sh2_min = parseInt(sh3_min.text) || 0
  887. var int_eh2 = parseInt(sh4_hour.text) || 0
  888. var int_eh2_min = parseInt(sh4_min.text) || 0
  889. var int_sh3 = parseInt(sh5_hour.text) || 0
  890. var int_sh3_min = parseInt(sh5_min.text) || 0
  891. var int_eh3 = parseInt(sh6_hour.text) || 0
  892. var int_eh3_min = parseInt(sh6_min.text) || 0
  893. // 格式化时间字符串
  894. var time1 = (int_sh1 < 10 ? "0" + int_sh1 : int_sh1) + ":" + (int_sh1_min < 10 ? "0" + int_sh1_min : int_sh1_min) + "-" +
  895. (int_eh1 < 10 ? "0" + int_eh1 : int_eh1) + ":" + (int_eh1_min < 10 ? "0" + int_eh1_min : int_eh1_min)
  896. var time2 = (int_sh2 < 10 ? "0" + int_sh2 : int_sh2) + ":" + (int_sh2_min < 10 ? "0" + int_sh2_min : int_sh2_min) + "-" +
  897. (int_eh2 < 10 ? "0" + int_eh2 : int_eh2) + ":" + (int_eh2_min < 10 ? "0" + int_eh2_min : int_eh2_min)
  898. var time3 = (int_sh3 < 10 ? "0" + int_sh3 : int_sh3) + ":" + (int_sh3_min < 10 ? "0" + int_sh3_min : int_sh3_min) + "-" +
  899. (int_eh3 < 10 ? "0" + int_eh3 : int_eh3) + ":" + (int_eh3_min < 10 ? "0" + int_eh3_min : int_eh3_min)
  900. // 更新显示
  901. sh1.text = time1
  902. sh2.text = time2
  903. sh3.text = time3
  904. // 调用serial接口(注意:这里可能需要根据实际接口调整参数)
  905. serial.setCollt(int_sh1, int_eh1, int_sh2, int_eh2, int_sh3, int_eh3)
  906. serial.setCollt_min(int_sh1_min, int_eh1_min, int_sh2_min, int_eh2_min, int_sh3_min, int_eh3_min)
  907. rec_seting.visible = false
  908. column_colt.visible = true
  909. appimage_set.visible = true
  910. image_timesvg.visible = true
  911. }
  912. }
  913. }
  914. }
  915. Column{
  916. id: column_colt
  917. anchors.centerIn: parent
  918. spacing: 5
  919. visible: true
  920. AppImage {
  921. id: image_timesvg
  922. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  923. anchors.topMargin: 30
  924. visible: true
  925. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  926. source: "../../assets/time.svg"
  927. }
  928. AppText{
  929. id: text_coll
  930. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  931. text: "采集时间"
  932. color: app.fontColor
  933. font.bold: true
  934. }
  935. AppText{
  936. id: sh1
  937. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  938. text:"09:00-10:00"
  939. fontSize: 10
  940. color: "gray"
  941. }
  942. AppText{
  943. id: sh2
  944. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  945. text:"14:00-16:00"
  946. fontSize: 10
  947. color: "gray"
  948. }
  949. AppText{
  950. id: sh3
  951. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  952. text:"17:00-19:00"
  953. fontSize: 10
  954. color: "gray"
  955. }
  956. AppImage {
  957. id: appimage_set
  958. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  959. visible: true
  960. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  961. source: "../../assets/set.svg"
  962. AppButton{
  963. id: settime
  964. anchors.fill: parent
  965. //text:" 修改"
  966. textColor: "GRAY"
  967. textSize: 10
  968. flat: true
  969. onClicked: {
  970. var sh1Arry = sh1.text.split('-')
  971. var sh2Arry = sh2.text.split('-')
  972. var sh3Arry = sh3.text.split('-')
  973. // 解析第一时间段
  974. var time1_start = sh1Arry[0].split(':')
  975. var time1_end = sh1Arry[1].split(':')
  976. sh1_hour.text = parseInt(time1_start[0]) || 0
  977. sh1_min.text = parseInt(time1_start[1]) || 0
  978. sh2_hour.text = parseInt(time1_end[0]) || 0
  979. sh2_min.text = parseInt(time1_end[1]) || 0
  980. // 解析第二时间段
  981. var time2_start = sh2Arry[0].split(':')
  982. var time2_end = sh2Arry[1].split(':')
  983. sh3_hour.text = parseInt(time2_start[0]) || 0
  984. sh3_min.text = parseInt(time2_start[1]) || 0
  985. sh4_hour.text = parseInt(time2_end[0]) || 0
  986. sh4_min.text = parseInt(time2_end[1]) || 0
  987. // 解析第三时间段
  988. var time3_start = sh3Arry[0].split(':')
  989. var time3_end = sh3Arry[1].split(':')
  990. sh5_hour.text = parseInt(time3_start[0]) || 0
  991. sh5_min.text = parseInt(time3_start[1]) || 0
  992. sh6_hour.text = parseInt(time3_end[0]) || 0
  993. sh6_min.text = parseInt(time3_end[1]) || 0
  994. column_colt.visible = false
  995. appimage_set.visible = false
  996. image_timesvg.visible = false
  997. rec_seting.visible = true
  998. }
  999. }
  1000. }
  1001. }
  1002. }
  1003. }
  1004. Row {
  1005. width: parent.width
  1006. height: parent.height*0.38
  1007. spacing: 5
  1008. Rectangle {
  1009. id: temp_card
  1010. radius: 5
  1011. width: parent.width*0.245
  1012. height: parent.height
  1013. color: app.cardColor
  1014. Rectangle {
  1015. id: temp_setting
  1016. anchors.fill: parent
  1017. visible: false
  1018. radius: 5
  1019. color: app.cardColor
  1020. Column {
  1021. anchors.fill: parent
  1022. anchors.margins: 8
  1023. spacing: 8
  1024. AppText {
  1025. anchors.horizontalCenter: parent.horizontalCenter
  1026. text: "温度保护设置"
  1027. color: app.fontColor
  1028. font.bold: true
  1029. fontSize: 14
  1030. }
  1031. // 高温保护阈值
  1032. Item {
  1033. width: parent.width
  1034. height: 50
  1035. Column {
  1036. anchors.fill: parent
  1037. spacing: 3
  1038. AppText {
  1039. text: "高温保护: " + highTempSlider.value + "℃"
  1040. color: app.fontColor
  1041. fontSize: 11
  1042. }
  1043. Slider {
  1044. id: highTempSlider
  1045. width: parent.width - 20
  1046. anchors.horizontalCenter: parent.horizontalCenter
  1047. from: 30
  1048. to: 70
  1049. value: 50
  1050. snapMode: Slider.SnapOnRelease
  1051. stepSize: 1
  1052. }
  1053. }
  1054. }
  1055. // 低温保护阈值
  1056. Item {
  1057. width: parent.width
  1058. height: 50
  1059. Column {
  1060. anchors.fill: parent
  1061. spacing: 3
  1062. AppText {
  1063. text: "低温保护: " + lowTempSlider.value + "℃"
  1064. color: app.fontColor
  1065. fontSize: 11
  1066. }
  1067. Slider {
  1068. id: lowTempSlider
  1069. width: parent.width - 20
  1070. anchors.horizontalCenter: parent.horizontalCenter
  1071. from: -40
  1072. to: 10
  1073. value: 20
  1074. snapMode: Slider.SnapOnRelease
  1075. stepSize: 1
  1076. }
  1077. }
  1078. }
  1079. Item {
  1080. width: parent.width
  1081. height: 40
  1082. Row {
  1083. anchors.centerIn: parent
  1084. spacing: 10
  1085. AppButton {
  1086. minimumWidth: 50
  1087. minimumHeight: 25
  1088. textSize: 10
  1089. text: "取消"
  1090. textColor: "black"
  1091. flat: false
  1092. backgroundColor: "#e9e9e9"
  1093. onClicked: {
  1094. temp_setting.visible = false
  1095. temp_display.visible = true
  1096. }
  1097. }
  1098. AppButton {
  1099. minimumWidth: 50
  1100. minimumHeight: 25
  1101. textSize: 10
  1102. text: "保存"
  1103. textColor: "white"
  1104. flat: false
  1105. backgroundColor: "#0aa26b"
  1106. onClicked: {
  1107. console.log("保存温度设置 - 高温:", highTempSlider.value, "低温:", lowTempSlider.value)
  1108. serial.setTempconf(lowTempSlider.value,highTempSlider.value);
  1109. // 这里可以添加保存设置的逻辑
  1110. temp_setting.visible = false
  1111. temp_display.visible = true
  1112. }
  1113. }
  1114. }
  1115. }
  1116. }
  1117. }
  1118. Column {
  1119. id: temp_display
  1120. anchors.centerIn: parent
  1121. spacing: 5
  1122. AppImage {
  1123. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1124. anchors.topMargin: 30
  1125. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  1126. source: "../../assets/tempture.svg"
  1127. }
  1128. AppText{
  1129. id: text_tempture
  1130. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1131. text: "环境温度:"
  1132. color: app.fontColor
  1133. font.bold: true
  1134. }
  1135. AppText{
  1136. id: text_tempture0
  1137. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1138. text: "箱内温度:"
  1139. color: app.fontColor
  1140. font.bold: true
  1141. }
  1142. AppText{
  1143. id: text_tempture_sta
  1144. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1145. text:"正常"
  1146. fontSize: 10
  1147. color: "gray"
  1148. }
  1149. AppImage {
  1150. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1151. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  1152. source: "../../assets/set.svg"
  1153. AppButton{
  1154. anchors.fill: parent
  1155. textColor: "gray"
  1156. textSize: 10
  1157. flat: true
  1158. onClicked: {
  1159. temp_display.visible = false
  1160. temp_setting.visible = true
  1161. }
  1162. }
  1163. }
  1164. }
  1165. }
  1166. Rectangle {
  1167. radius: 5
  1168. width: parent.width*0.245
  1169. height: parent.height
  1170. color: app.cardColor
  1171. Column {
  1172. anchors.centerIn: parent
  1173. spacing: 5
  1174. AppImage {
  1175. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1176. anchors.topMargin: 30
  1177. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  1178. source: "../../assets/humidity.svg"
  1179. }
  1180. AppText{
  1181. id: text_humidity
  1182. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1183. text: "湿度:"
  1184. color: app.fontColor
  1185. font.bold: true
  1186. }
  1187. }
  1188. }
  1189. Rectangle {
  1190. radius: 5
  1191. width: parent.width*0.245
  1192. height: parent.height
  1193. color: app.cardColor
  1194. Column {
  1195. anchors.centerIn: parent
  1196. spacing: 5
  1197. AppImage {
  1198. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1199. anchors.topMargin: 30
  1200. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  1201. source: "../../assets/vbat.svg"
  1202. }
  1203. AppText{
  1204. id: text_vbat
  1205. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1206. text: "电压:"
  1207. color: app.fontColor
  1208. font.bold: true
  1209. }
  1210. }
  1211. }
  1212. Rectangle {
  1213. radius: 5
  1214. width: parent.width*0.245
  1215. height: parent.height
  1216. color: app.cardColor
  1217. Column {
  1218. anchors.centerIn: parent
  1219. spacing: 5
  1220. AppImage {
  1221. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1222. anchors.topMargin: 30
  1223. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  1224. source: "../../assets/current.svg"
  1225. }
  1226. AppText{
  1227. id: text_current
  1228. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  1229. text: "电流:"
  1230. color: app.fontColor
  1231. font.bold: true
  1232. }
  1233. }
  1234. }
  1235. }
  1236. }
  1237. } // page