HomePage.qml 55 KB

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