TestPage.qml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. import QtQuick
  2. import Felgo
  3. import QtMultimedia
  4. import QtQuick.Controls
  5. // import QtQuick.Controls.Material 2.0 // 移除:与Felgo主题冲突,导致AppSwitch颜色异常
  6. import "../controls"
  7. import "../common"
  8. import Frames 0.1
  9. AppPage {
  10. objectName: "autoFocus_Page"
  11. navigationBarHidden: true
  12. backgroundColor: app.theme_backgroundColor
  13. property var videoFormats
  14. // 定义电机状态
  15. property int currentAxis: 0 // 当前选择的轴 (0: X, 1: Y, 2: Z)
  16. property var axisPositions: [0, 0, 0] // 各轴当前位置
  17. property int speed: 50 // 当前速度 (0-100)
  18. property int stepDistance: 20 // 步进脉冲数量
  19. property string fExposureTime: "0"
  20. property bool motorUnlocked: false
  21. function autotake(sw){
  22. if(sw)
  23. {
  24. console.log("autotakestart")
  25. frames.camera_sw = true
  26. //frames.auto_clicked = true //开始对焦
  27. auto_timer.start() //启动对焦定时器
  28. console.log("相机已打开")
  29. photoTimer.interval=60*1000
  30. photoTimer.start()
  31. }else{
  32. frames.camera_sw = true
  33. console.log("打开相机单次拍照!")
  34. }
  35. }
  36. Frames {
  37. objectName: "Frames"
  38. id: frames
  39. videoSink: output.videoSink
  40. onCameraOpenFailed:function(err){
  41. console.log("onCameraOpenFailed",err)
  42. nativeUtils.displayMessageBox("相机打开失败!",err,1)
  43. focus_switch.checked = false
  44. focus_switch.enabled = true
  45. takephoto_switch.checked = false
  46. takephoto_switch.enabled = true
  47. }
  48. onVideoSinkChanged: {
  49. console.log("onVideoSinkChanged")
  50. photoTimer.start() //两秒后关闭相机,因为相机加载的慢,否则关不住
  51. }
  52. onQulityStringChanged: {
  53. loginpage.logintimeout = 600; //拍照刷新熄屏计时
  54. photoTimer.interval = 180*1000 //3分钟超时
  55. photoTimer.restart()
  56. }
  57. onCameraStaChanged: function(sta_cam) {
  58. if(sta_cam){
  59. //camera.active = sta_cam
  60. //camera.start()
  61. loginpage.logintimeout = 600; //拍照刷新熄屏计时
  62. output.visible = sta_cam
  63. photoTimer.interval = 180*1000 //3分钟超时
  64. photoTimer.start()
  65. //uvc_camera.visible = false
  66. }else{
  67. //camera.active = sta_cam
  68. //camera.stop()
  69. output.visible= sta_cam
  70. photoTimer.stop() //停止计时器
  71. //uvc_camera.visible = true
  72. //关闭相机重置按钮状态
  73. focus_switch.enabled = true
  74. focus_switch.checked = false
  75. takephoto_switch.checked = false
  76. takephoto_switch.enabled = true
  77. }
  78. console.log("相机状态改变",sta_cam)
  79. }
  80. onStepCountChanged: function(step){
  81. console.log("坐标改变",step)
  82. step_apptextfield.text = step
  83. }
  84. onExposureTimeChanged: {
  85. fExposureTime = frames.cam_ExposureTime
  86. }
  87. }
  88. Timer {
  89. id: photoTimer
  90. interval: 2000 // 设置点击频率限制的时间间隔(以毫秒为单位)
  91. running: false // 初始状态下定时器停止
  92. repeat: false // 设置为false,以便只执行一次
  93. onTriggered: {
  94. // 定时器触发后,设置按钮可用
  95. // camera.active = false
  96. // camera.stop()
  97. output.visible = false
  98. frames.camera_sw = false
  99. }
  100. }
  101. Timer {
  102. id: auto_timer
  103. interval: 1000 // 设置点击频率限制的时间间隔(以毫秒为单位)
  104. running: false // 初始状态下定时器停止
  105. repeat: false // 设置为false,以便只执行一次
  106. onTriggered: {
  107. // 定时器触发后,开始对焦
  108. frames.auto_clicked = true
  109. }
  110. }
  111. Connections{
  112. target: mqtt
  113. function onMessagePub(message) {
  114. if(app.showPubData){
  115. var time = new Date().toLocaleTimeString()
  116. app.txDataLog = "[" + time + "] " + message + "\n" + app.txDataLog
  117. if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
  118. }
  119. }
  120. function onMessageSub(message) {
  121. if(app.showSubData){
  122. var time = new Date().toLocaleTimeString()
  123. app.rxDataLog = "[" + time + "] " + message + "\n" + app.rxDataLog
  124. if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
  125. }
  126. }
  127. function onSignal_set_camera_exposure(exposureTime) {
  128. console.log("收到远程相机曝光设置指令,曝光时间:" + exposureTime)
  129. frames.cam_ExposureTime = exposureTime.toString()
  130. }
  131. }
  132. Connections {
  133. target: serial
  134. function onTakephotodone() {
  135. console.log("立即拍照完成!")
  136. apptext_res.text = "立即拍照完成!"
  137. focus_switch.enabled = true
  138. focus_switch.checked = false
  139. takephoto_switch.checked = false
  140. takephoto_switch.enabled = true
  141. }
  142. function onAutotestdone() {
  143. console.log("自动对焦完成!")
  144. apptext_res.text = "自动对焦完成!"
  145. autotest_switch.enabled = true
  146. autotest_switch.checked = false
  147. }
  148. onTranslatedone:function() {
  149. console.log("胶带传送完成!")
  150. apptext_res.text = "胶带传送完成!"
  151. jiaodai_switch.enabled = true
  152. jiaodai_switch.checked = false
  153. }
  154. onDataReceived:function(data) {
  155. if(app.showRxData){
  156. var time = new Date().toLocaleTimeString()
  157. app.rxDataLog = "[" + time + "] " + data + "\n" + app.rxDataLog
  158. if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
  159. }
  160. // 同步坐标值到输入框
  161. try {
  162. var jsonData = JSON.parse(data)
  163. if(jsonData.ext && !textInput_y.focus && jsonData.ext.y_init_dis !== undefined) {
  164. textInput_y.text = jsonData.ext.y_init_dis.toString()
  165. }
  166. } catch(e) {
  167. console.log("解析坐标数据失败:", e)
  168. }
  169. }
  170. onNetMessage:function(data) {
  171. if(app.showTxData){
  172. var time = new Date().toLocaleTimeString()
  173. app.txDataLog = "[" + time + "] " + data + "\n" + app.txDataLog
  174. if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
  175. }
  176. }
  177. }
  178. SplitView{
  179. anchors.fill: parent
  180. orientation: Qt.Horizontal
  181. Rectangle {
  182. SplitView.preferredWidth: parent.width * 0.7
  183. height: parent.height
  184. color: app.cardColor
  185. radius: 5
  186. AppButton {
  187. id: normButton
  188. //anchors.horizontalCenter: parent.horizontalCenter
  189. anchors.centerIn: parent
  190. anchors.fill: parent
  191. //text: "打开相机"
  192. flat: true //边框是否可视
  193. onClicked: {
  194. console.log("相机状态:",frames.camera_sw)
  195. //if(camera.active){
  196. if(frames.camera_sw){
  197. text = "相机已关闭"
  198. output.visible = false
  199. frames.camera_sw = false
  200. //uvc_camera.visible = false
  201. }else{
  202. text = "打开相机"
  203. output.visible = true
  204. frames.camera_sw = true
  205. //uvc_camera.visible = true
  206. }
  207. }
  208. AppImage{
  209. id: image_picdis
  210. anchors.centerIn: parent
  211. source: "../../assets/photoico.svg"
  212. }
  213. }
  214. VideoOutput{
  215. id: output
  216. anchors.fill: parent
  217. visible: false
  218. fillMode: VideoOutput.PreserveAspectFit //根据视频的纵横比例等比例缩放
  219. //fillMode: VideoOutput.Stretch
  220. Component.onCompleted: {
  221. console.log("output onCompleted")
  222. }
  223. }
  224. Row {
  225. AppText {
  226. id: photoclarity_text
  227. width: parent.width
  228. text: frames.fpsString
  229. color: "red"
  230. }
  231. AppText {
  232. visible: true//app.photoclarity
  233. id: photoclarity2_text
  234. anchors.top: photoclarity_text.bottom
  235. width: parent.width
  236. text: "清晰度:" + frames.qulityString
  237. color: "green"
  238. }
  239. }
  240. }
  241. ScrollView
  242. {
  243. SplitView.preferredWidth: parent.width*0.29
  244. SplitView.minimumWidth: 200
  245. clip: true
  246. Column {
  247. width: parent.width
  248. spacing: dp(15)
  249. Row {
  250. spacing: 80
  251. AppText {
  252. id: text_title
  253. text: "测试调试"
  254. font.bold: true
  255. color: "#28a779"
  256. fontSize: 20
  257. }
  258. AppText {
  259. id: apptext_res
  260. text: "[测试结果]"
  261. fontSize:15
  262. color: "grey"
  263. anchors.verticalCenter: text_title.verticalCenter
  264. }
  265. }
  266. Row {
  267. spacing: 100
  268. AppText{
  269. text: "一键测试"
  270. fontSize: 15
  271. color: app.fontColor
  272. //font.bold: true
  273. anchors.verticalCenter: autotest_switch.verticalCenter
  274. }
  275. AppSwitch {
  276. id: autotest_switch
  277. onToggled: {
  278. if(autotest_switch.checked==true){
  279. autotest_switch.enabled = false
  280. serial.sendCmd("autotest",true,"","");
  281. t_autotest.start()
  282. }else{
  283. console.log("t_autotest 计数:",t_autotest.interval)
  284. }
  285. }
  286. }
  287. Timer {
  288. id: t_autotest
  289. interval: 1000*60
  290. running: false
  291. repeat: false
  292. onTriggered: {
  293. autotest_switch.enabled = true
  294. autotest_switch.checked = false
  295. }
  296. }
  297. }
  298. Row {
  299. spacing: 100
  300. AppText{
  301. text: "风机测试"
  302. color: app.fontColor
  303. fontSize: 15
  304. //font.bold: true
  305. anchors.verticalCenter: fantest_switch.verticalCenter
  306. }
  307. AppSwitch {
  308. id: fantest_switch
  309. onToggled: {
  310. if(fantest_switch.checked==true){
  311. serial.sendCmd("fan",true,"","");
  312. apptext_res.text = "打开风机"
  313. }else{
  314. serial.sendCmd("fan",false,"","");
  315. apptext_res.text = "关闭风机"
  316. }
  317. }
  318. }
  319. }
  320. Row {
  321. spacing: 100
  322. AppText{
  323. text: "胶带测试"
  324. fontSize: 15
  325. color: app.fontColor
  326. //font.bold: true
  327. anchors.verticalCenter: jiaodai_switch.verticalCenter
  328. }
  329. AppSwitch {
  330. id: jiaodai_switch
  331. onToggled: {
  332. if(jiaodai_switch.checked==true){
  333. // 检查是否处于温度保护状态
  334. if(app.tempProtectionState === true){
  335. // 弹出提示对话框
  336. nativeUtils.displayMessageBox(
  337. "提示",
  338. "当前处于温控状态,请解除温控后再进行测试胶带传送",
  339. 1
  340. );
  341. // 恢复开关状态为未选中
  342. jiaodai_switch.checked = false;
  343. return;
  344. }
  345. // 正常执行胶带测试
  346. //jiaodai_switch.enabled = false
  347. apptext_res.text = "胶带测试开始"
  348. serial.sendCmd("jiaodai",true,"","");
  349. }
  350. }
  351. }
  352. }
  353. Row {
  354. spacing: 100
  355. AppText{
  356. text: "补光测试"
  357. color: app.fontColor
  358. fontSize: 15
  359. //font.bold: true
  360. anchors.verticalCenter: led_switch.verticalCenter
  361. }
  362. AppSwitch {
  363. id: led_switch
  364. onToggled: {
  365. if(led_switch.checked==true){
  366. serial.sendCmd("led",true,"","");
  367. apptext_res.text = "补光灯已打开"
  368. }else{
  369. serial.sendCmd("led",false,"","");
  370. apptext_res.text = "补光灯已关闭"
  371. }
  372. }
  373. }
  374. }
  375. Row {
  376. spacing: 100
  377. AppText{
  378. text: "立即拍照"
  379. color: app.fontColor
  380. fontSize: 15
  381. //font.bold: true
  382. anchors.verticalCenter: takephoto_switch.verticalCenter
  383. }
  384. AppSwitch {
  385. id: takephoto_switch
  386. onToggled: {
  387. if(takephoto_switch.checked==true){
  388. apptext_res.text = "立即拍照"
  389. frames.captureImage()
  390. }
  391. }
  392. }
  393. }
  394. Row {
  395. spacing: 100
  396. AppText{
  397. text: "对焦拍照"
  398. color: app.fontColor
  399. fontSize: 15
  400. //font.bold: true
  401. anchors.verticalCenter: focus_switch.verticalCenter
  402. }
  403. AppSwitch {
  404. id: focus_switch
  405. onToggled: {
  406. if(focus_switch.checked==true){
  407. apptext_res.text = "开始对焦"
  408. focus_switch.enabled = false
  409. serial.auto_takephoto(true)
  410. }
  411. }
  412. }
  413. }
  414. // 分割线
  415. Rectangle {
  416. visible: !motorUnlocked
  417. width: parent.width
  418. height: dp(1)
  419. color: "#e0e0e0"
  420. }
  421. // 分割线
  422. Rectangle {
  423. width: parent.width
  424. height: dp(2)
  425. color: "#28a779"
  426. }
  427. // 密码输入区域(未解锁时显示)
  428. Rectangle {
  429. visible: !motorUnlocked
  430. width: parent.width
  431. height: passwordColumn.height + dp(16)
  432. color: app.cardColor
  433. radius: dp(8)
  434. border.color: "#28a779"
  435. border.width: dp(1)
  436. Column {
  437. id: passwordColumn
  438. anchors.centerIn: parent
  439. spacing: dp(10)
  440. AppText {
  441. anchors.horizontalCenter: parent.horizontalCenter
  442. text: "请输入密码解锁高级设置"
  443. color: app.fontColor
  444. font.bold: true
  445. fontSize: 14
  446. }
  447. Row {
  448. anchors.horizontalCenter: parent.horizontalCenter
  449. spacing: dp(8)
  450. AppTextField {
  451. id: motorPasswordInput
  452. width: dp(130)
  453. height: dp(38)
  454. echoMode: TextInput.Password
  455. placeholderText: "密码"
  456. inputMethodHints: Qt.ImhDigitsOnly
  457. anchors.verticalCenter: parent.verticalCenter
  458. onAccepted: {
  459. if(text === "666888"){
  460. motorUnlocked = true
  461. text = ""
  462. }else{
  463. apptext_res.text = "密码错误"
  464. text = ""
  465. }
  466. }
  467. }
  468. AppButton {
  469. text: "确认"
  470. textColor: "white"
  471. flat: false
  472. backgroundColor: "#28a779"
  473. minimumHeight: dp(38)
  474. minimumWidth: dp(55)
  475. anchors.verticalCenter: parent.verticalCenter
  476. onClicked: {
  477. if(motorPasswordInput.text === "666888"){
  478. motorUnlocked = true
  479. motorPasswordInput.text = ""
  480. }else{
  481. apptext_res.text = "密码错误"
  482. motorPasswordInput.text = ""
  483. }
  484. }
  485. }
  486. }
  487. }
  488. }
  489. // 电机控制及以下所有控件(解锁后显示)
  490. Item {
  491. id: motorSection
  492. visible: motorUnlocked
  493. width: parent.width
  494. height: motorContent.height + dp(20)
  495. property alias content: motorContent
  496. Column {
  497. id: motorContent
  498. spacing: dp(12)
  499. width: parent.width
  500. // 锁定按钮
  501. Row {
  502. spacing: dp(5)
  503. width: parent.width
  504. AppText {
  505. text: "高级控制"
  506. font.bold: true
  507. color: "#28a779"
  508. fontSize: 20
  509. anchors.verticalCenter: parent.verticalCenter
  510. }
  511. AppButton {
  512. text: "锁定"
  513. textColor: "white"
  514. flat: false
  515. backgroundColor: "#d9534f"
  516. minimumHeight: dp(25)
  517. minimumWidth: dp(50)
  518. anchors.verticalCenter: parent.verticalCenter
  519. onClicked: motorUnlocked = false
  520. }
  521. }
  522. AppText {
  523. id: text_title2
  524. text: "三轴步进电机控制"
  525. font.bold: true
  526. color: "#28a779"
  527. fontSize: 20
  528. }
  529. // 轴选择
  530. Row {
  531. spacing: dp(8)
  532. width: parent.width
  533. AppText {
  534. text: "选择轴:"
  535. width: dp(60)
  536. color: app.fontColor
  537. anchors.verticalCenter: parent.verticalCenter
  538. }
  539. ComboBox {
  540. width: parent.width - dp(100)
  541. height: dp(40)
  542. model: ["Y轴"]
  543. onCurrentIndexChanged: currentAxis = currentIndex
  544. }
  545. AppButton {
  546. text: "校准"
  547. textColor: "black"
  548. flat: false
  549. borderColor: "black"
  550. borderWidth: dp(1)
  551. backgroundColor: "white"
  552. minimumHeight: dp(30)
  553. minimumWidth: dp(50)
  554. onClicked:
  555. {
  556. autotake(false)
  557. if(currentAxis==0)
  558. {
  559. console.log("校准y")
  560. serial.sendCmd("calibrate",false,"y",speed.toString())
  561. }
  562. }
  563. }
  564. }
  565. // 速度调节
  566. Row {
  567. spacing: dp(10)
  568. width: parent.width
  569. AppText {
  570. text: "速度:"
  571. width: dp(40)
  572. color: app.fontColor
  573. anchors.verticalCenter: parent.verticalCenter
  574. }
  575. AppSlider {
  576. width: parent.width - dp(60)
  577. from: 0
  578. to: 100
  579. value: speed
  580. stepSize: 1
  581. onValueChanged: speed = value
  582. anchors.verticalCenter: parent.verticalCenter
  583. }
  584. AppText {
  585. text: speed
  586. width: dp(40)
  587. anchors.verticalCenter: parent.verticalCenter
  588. }
  589. }
  590. // 步进距离设置
  591. Row {
  592. spacing: dp(10)
  593. width: parent.width
  594. AppText {
  595. text: "步进脉冲次数:"
  596. width: dp(120)
  597. color: app.fontColor
  598. anchors.verticalCenter: parent.verticalCenter
  599. }
  600. AppTextField {
  601. id: step_apptextfield
  602. width: parent.width - dp(120)
  603. text: stepDistance
  604. validator: IntValidator { bottom: 0; top: 2000 }
  605. onTextChanged: stepDistance = parseInt(text)
  606. }
  607. }
  608. // 运动控制按钮
  609. Row {
  610. spacing: dp(20)
  611. width: parent.width
  612. AppButton {
  613. text: " 正转 "
  614. textColor: "black"
  615. flat: false
  616. borderColor: "black"
  617. borderWidth: dp(1)
  618. backgroundColor: "grey"
  619. minimumHeight: dp(30)
  620. minimumWidth: dp(50)
  621. width: (parent.width - dp(30))/4
  622. onClicked:
  623. {
  624. if(currentAxis==0)
  625. {
  626. console.log("Y轴正转:",stepDistance)
  627. serial.sendCmd("movy",false,"f"+stepDistance,speed.toString())
  628. }
  629. }
  630. }
  631. AppButton {
  632. text: " 停止 "
  633. textColor: "black"
  634. flat: false
  635. borderColor: "black"
  636. borderWidth: dp(1)
  637. backgroundColor: "red"
  638. minimumHeight: dp(30)
  639. minimumWidth: dp(50)
  640. width: (parent.width - dp(30))/4
  641. onClicked:
  642. {
  643. console.log("停止")
  644. serial.sendCmd("movy",false,"f0","")
  645. }
  646. }
  647. AppButton {
  648. text: " 反转 "
  649. textColor: "black"
  650. flat: false
  651. borderColor: "black"
  652. borderWidth: dp(1)
  653. backgroundColor: "grey"
  654. minimumHeight: dp(30)
  655. minimumWidth: dp(50)
  656. width: (parent.width - dp(30))/4
  657. onClicked:
  658. {
  659. if(currentAxis==0)
  660. {
  661. console.log("Y轴反转:",stepDistance)
  662. serial.sendCmd("movy",false,"b"+stepDistance,speed.toString())
  663. }
  664. }
  665. }
  666. AppButton {
  667. text: " 复位 "
  668. textColor: "black"
  669. flat: false
  670. borderColor: "black"
  671. borderWidth: dp(1)
  672. backgroundColor: "grey"
  673. minimumHeight: dp(30)
  674. minimumWidth: dp(50)
  675. width: (parent.width - dp(30))/4
  676. onClicked: {
  677. if(currentAxis==0)
  678. {
  679. console.log("Y轴复位!")
  680. serial.sendCmd("movy",true,"",speed.toString())
  681. }
  682. }
  683. }
  684. }
  685. // ===== 坐标参数 =====
  686. AppText {
  687. text: "坐标参数"
  688. font.bold: true
  689. color: "#28a779"
  690. fontSize: 20
  691. }
  692. // Y 坐标输入行
  693. Row {
  694. spacing: dp(5)
  695. width: parent.width
  696. AppText {
  697. text: "Y坐标:"
  698. width: dp(50)
  699. color: app.fontColor
  700. fontSize: 15
  701. anchors.verticalCenter: textInput_y.verticalCenter
  702. }
  703. AppTextField {
  704. id: textInput_y
  705. width: parent.width - dp(80)
  706. height: dp(40)
  707. placeholderText: "0"
  708. text: "0"
  709. font.family: "Arial"
  710. font.pixelSize: 15
  711. validator: DoubleValidator { decimals: 2 }
  712. EnterKey.type: Qt.EnterKeyDone
  713. inputMethodHints: Qt.ImhFormattedNumbersOnly
  714. property real numericValue_y: Number(text) || 0
  715. Keys.onReturnPressed: {
  716. serial.setHt_xy_dis("0", numericValue_y)
  717. Qt.inputMethod.hide()
  718. }
  719. onAccepted: {
  720. serial.setHt_xy_dis("0", numericValue_y)
  721. }
  722. }
  723. }
  724. // 分割线
  725. Rectangle {
  726. width: parent.width
  727. height: dp(2)
  728. color: "#e0e0e0"
  729. }
  730. // ===== 相机参数 =====
  731. AppText {
  732. id: text_camera
  733. text: "相机参数"
  734. font.bold: true
  735. color: "#28a779"
  736. fontSize: 20
  737. }
  738. Row {
  739. spacing: dp(10)
  740. width: parent.width
  741. AppText {
  742. id: txt_fExposureTime
  743. text: "曝光值:"
  744. color: app.fontColor
  745. }
  746. AppTextField {
  747. anchors.verticalCenter: txt_fExposureTime.verticalCenter
  748. placeholderText: fExposureTime
  749. text: fExposureTime
  750. width: parent.width - dp(10)
  751. EnterKey.type: Qt.EnterKeyDone
  752. wrapMode: Text.NoWrap
  753. inputMethodHints: Qt.ImhFormattedNumbersOnly |
  754. Qt.ImhPreferDone |
  755. Qt.ImhNoPredictiveText
  756. validator: DoubleValidator {
  757. bottom: 100.00
  758. top: 500000.00
  759. decimals: 0
  760. }
  761. // 关键:兜底(IME 再作妖也不怕)
  762. Keys.onReturnPressed: {
  763. frames.cam_ExposureTime = text
  764. console.log("设置曝光时间:",text)
  765. Qt.inputMethod.hide()
  766. }
  767. onAccepted: {
  768. frames.cam_ExposureTime = text
  769. console.log("设置曝光时间",text)
  770. }
  771. }
  772. }
  773. AppText {
  774. id: text_debug
  775. text: "通信调试"
  776. font.bold: true
  777. color: "#28a779"
  778. fontSize: 20
  779. }
  780. Row {
  781. spacing: dp(12)
  782. AppText {
  783. text: "显示Serial发送数据"
  784. color: app.fontColor
  785. fontSize: 15
  786. anchors.verticalCenter: txSwitch.verticalCenter
  787. }
  788. AppSwitch {
  789. id: txSwitch
  790. onToggled: {
  791. app.floatPanel = checked
  792. app.showTxData = checked
  793. app.floatPanel_title = "Serial发送数据"
  794. }
  795. }
  796. }
  797. Row {
  798. spacing: dp(12)
  799. AppText {
  800. text: "显示Serial接收数据"
  801. color: app.fontColor
  802. fontSize: 15
  803. anchors.verticalCenter: rxSwitch.verticalCenter
  804. }
  805. AppSwitch {
  806. id: rxSwitch
  807. onToggled: {
  808. app.floatPanel = checked
  809. app.showRxData = checked
  810. app.floatPanel_title = "Serial接收数据"
  811. }
  812. }
  813. }
  814. Row {
  815. spacing: dp(12)
  816. AppText {
  817. text: "显示MQTT发送数据"
  818. color: app.fontColor
  819. fontSize: 15
  820. anchors.verticalCenter: pubSwitch.verticalCenter
  821. }
  822. AppSwitch {
  823. id: pubSwitch
  824. onToggled: {
  825. app.floatPanel = checked
  826. app.showPubData = checked
  827. app.showSubData = false
  828. app.floatPanel_title = "MQTT发送数据"
  829. }
  830. }
  831. }
  832. Row {
  833. spacing: dp(12)
  834. AppText {
  835. text: "显示MQTT接收数据"
  836. color: app.fontColor
  837. fontSize: 15
  838. anchors.verticalCenter: subSwitch.verticalCenter
  839. }
  840. AppSwitch {
  841. id: subSwitch
  842. onToggled: {
  843. app.floatPanel = checked
  844. app.showSubData = checked
  845. app.showPubData = false
  846. app.floatPanel_title = "MQTT接收数据"
  847. }
  848. }
  849. }
  850. } // motorContent
  851. } // motorSection
  852. }
  853. }
  854. }
  855. }