HomePage.qml 59 KB

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