TestPage.qml 42 KB

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