TestPage.qml 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import Felgo
  4. import QtMultimedia
  5. import QtQuick.Controls
  6. import Qt.labs.settings 1.0 as QtLabs
  7. import QtQuick.Controls.Material 2.0
  8. import QtLocation 5.5
  9. import QtPositioning 5.5
  10. import Qt5Compat.GraphicalEffects
  11. import "../controls"
  12. import "../common"
  13. import Frames 0.1
  14. AppPage {
  15. objectName: "autoFocus_Page"
  16. navigationBarHidden: true
  17. backgroundColor: app.theme_backgroundColor
  18. property var videoFormats
  19. // 定义电机状态
  20. property int currentAxis: 0 // 当前选择的轴 (0: X, 1: Y, 2: Z)
  21. property var axisPositions: [0, 0, 0] // 各轴当前位置
  22. property int speed: 50 // 当前速度 (0-100)
  23. property int stepDistance: 20 // 步进脉冲数量
  24. property string fExposureTime: "0"
  25. property bool motorUnlocked: false
  26. // ===== 上传进度网格(32格), 蛇形编号, 1 在右上角 =====
  27. // 数组下标 = GridLayout 摆放顺序(左上→右下), 元素 = 该格显示/对应的图片序号
  28. property var uploadGridSerials: [
  29. 32,25,24,17,16, 9, 8, 1,
  30. 31,26,23,18,15,10, 7, 2,
  31. 30,27,22,19,14,11, 6, 3,
  32. 29,28,21,20,13,12, 5, 4
  33. ]
  34. ListModel { id: uploadGridModel }
  35. Component.onCompleted: {
  36. for(var i = 0; i < 32; i++){
  37. uploadGridModel.append({serial: uploadGridSerials[i], percent: 0, done: false})
  38. }
  39. }
  40. // 从上传文件路径解析图片序号
  41. // 归档命名有两种(都会上传):
  42. // 最清晰帧 <时间戳>z<z>x<x>_<序号>.jpg
  43. // 融合图 <时间戳>z<z>x<x>_sharp_<序号>.jpg
  44. // 故统一取"文件名末尾下划线后的数字",兼容两种命名及后续新增后缀
  45. function uploadSerialFromPath(filePath) {
  46. if(!filePath) return -1
  47. // 只处理图片(录制视频流 .rawv 不参与进度网格)
  48. if(!/\.(jpe?g|png)$/i.test(filePath.replace(/\?.*$/, ""))) return -1
  49. // 去掉扩展名(兼容查询串),再取末尾 _数字
  50. var base = filePath.replace(/\?.*$/, "").replace(/\.[^.\/\\]+$/, "")
  51. var m = base.match(/_(\d+)$/)
  52. if(m && m.length > 1) return parseInt(m[1])
  53. // 兜底:兼容历史上只认 _sharp_N 的命名
  54. m = filePath.match(/sharp_(\d+)/)
  55. if(m && m.length > 1) return parseInt(m[1])
  56. return -1
  57. }
  58. // 由图片序号(1..32)换算成网格摆放索引(0..31, 蛇形, 1 在右上角)
  59. function uploadSerialToIndex(serial){
  60. var n = serial - 1
  61. var q = Math.floor(n / 4) // 0..7 列组(自右向左)
  62. var pos = n % 4 // 组内 0..3
  63. var col = 7 - q
  64. var row = (q % 2 === 0) ? pos : (3 - pos)
  65. return row * 8 + col
  66. }
  67. // 更新某个网格格子的状态
  68. function setUploadCell(serial, percent, done) {
  69. var idx = uploadSerialToIndex(serial)
  70. if(idx < 0 || idx > 31) return
  71. var p = Math.max(0, Math.min(100, percent))
  72. uploadGridModel.setProperty(idx, "percent", p)
  73. uploadGridModel.setProperty(idx, "done", done)
  74. }
  75. // 清空网格全部状态(percent=0, done=false)
  76. function resetUploadGrid() {
  77. for(var i = 0; i < uploadGridModel.count; i++){
  78. uploadGridModel.setProperty(i, "percent", 0)
  79. uploadGridModel.setProperty(i, "done", false)
  80. }
  81. }
  82. function autotake(sw){
  83. if(sw)
  84. {
  85. console.log("autotakestart")
  86. frames.camera_sw = true
  87. //frames.auto_clicked = true //开始对焦
  88. auto_timer.start() //启动对焦定时器
  89. console.log("相机已打开")
  90. photoTimer.interval=180*1000
  91. photoTimer.start()
  92. }else{
  93. frames.camera_sw = true
  94. console.log("打开相机单次拍照!")
  95. }
  96. }
  97. Frames {
  98. objectName: "Frames"
  99. id: frames
  100. videoSink: output.videoSink
  101. onCameraOpenFailed:function(err){
  102. console.log("onCameraOpenFailed",err)
  103. nativeUtils.displayMessageBox("相机打开失败!",err,1)
  104. focus_switch.checked = false
  105. focus_switch.enabled = true
  106. takephoto_switch.checked = false
  107. takephoto_switch.enabled = true
  108. }
  109. onVideoSinkChanged: {
  110. console.log("onVideoSinkChanged")
  111. photoTimer.start() //两秒后关闭相机,因为相机加载的慢,否则关不住
  112. }
  113. onQulityStringChanged: {
  114. loginpage.logintimeout = 600; //拍照刷新熄屏计时
  115. photoTimer.interval = 180*1000 //3分钟超时
  116. photoTimer.restart()
  117. }
  118. onRecordFileSaved: function(path){
  119. console.log("录制视频流已保存:", path)
  120. apptext_res.text = "录制已保存:" + path.split("/").pop()
  121. }
  122. onCameraStaChanged: function(sta_cam) {
  123. if(sta_cam){
  124. //camera.active = sta_cam
  125. //camera.start()
  126. //每次(重新)打开相机后清空上传进度网格(上一次采集的进度/完成状态不再保留)
  127. resetUploadGrid()
  128. loginpage.logintimeout = 600; //拍照刷新熄屏计时
  129. output.visible = sta_cam
  130. photoTimer.interval = 180*1000 //3分钟超时
  131. photoTimer.start()
  132. //uvc_camera.visible = false
  133. }else{
  134. //camera.active = sta_cam
  135. //camera.stop()
  136. output.visible= sta_cam
  137. photoTimer.stop() //停止计时器
  138. focus_switch.checked = false
  139. focus_switch.enabled = true
  140. takephoto_switch.checked = false
  141. takephoto_switch.enabled = true
  142. //uvc_camera.visible = true
  143. }
  144. console.log("相机状态改变",sta_cam)
  145. }
  146. onStepCountChanged: function(step){
  147. console.log("坐标改变",step)
  148. step_apptextfield.text = step
  149. }
  150. onExposureTimeChanged: {
  151. fExposureTime = frames.cam_ExposureTime
  152. }
  153. }
  154. Timer {
  155. id: photoTimer
  156. interval: 2000 // 设置点击频率限制的时间间隔(以毫秒为单位)
  157. running: false // 初始状态下定时器停止
  158. repeat: false // 设置为false,以便只执行一次
  159. onTriggered: {
  160. // 定时器触发后,设置按钮可用
  161. // camera.active = false
  162. // camera.stop()
  163. output.visible = false
  164. frames.camera_sw = false
  165. }
  166. }
  167. Timer {
  168. id: auto_timer
  169. interval: 1000 // 设置点击频率限制的时间间隔(以毫秒为单位)
  170. running: false // 初始状态下定时器停止
  171. repeat: false // 设置为false,以便只执行一次
  172. onTriggered: {
  173. // 定时器触发后,开始对焦
  174. frames.auto_clicked = true
  175. }
  176. }
  177. Connections{
  178. target: mqtt
  179. function onMessagePub(message) {
  180. if(app.showPubData){
  181. var time = new Date().toLocaleTimeString()
  182. app.txDataLog = "[" + time + "] " + message + "\n" + app.txDataLog
  183. if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
  184. }
  185. }
  186. function onMessageSub(message) {
  187. if(app.showSubData){
  188. var time = new Date().toLocaleTimeString()
  189. app.rxDataLog = "[" + time + "] " + message + "\n" + app.rxDataLog
  190. if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
  191. }
  192. }
  193. function onSignal_set_camera_exposure(exposureTime) {
  194. console.log("收到远程相机曝光设置指令,曝光时间:" + exposureTime)
  195. frames.cam_ExposureTime = exposureTime.toString()
  196. }
  197. // 远程校准指令: {"cmd":"slide","ext":{"calibrate":"y","speed":"50"}} → 打开相机
  198. function onSignal_open_camera() {
  199. console.log("收到远程相机开启指令,打开相机!")
  200. frames.camera_sw = true
  201. }
  202. }
  203. // 图片上传进度 → 右上角 32 格进度网格
  204. Connections {
  205. target: curl_picture
  206. function onProgressChanged(uploadedPercent, filePath){
  207. var serial = uploadSerialFromPath(filePath)
  208. if(serial < 1 || serial > 32){
  209. console.log("上传进度: 无法识别图片序号", filePath)
  210. return
  211. }
  212. setUploadCell(serial, uploadedPercent, uploadedPercent >= 100)
  213. }
  214. }
  215. Connections{
  216. target: serial
  217. onTakephotodone:{
  218. console.log("立即拍照完成!")
  219. apptext_res.text = "立即拍照完成!"
  220. focus_switch.enabled = true
  221. focus_switch.checked = false
  222. }
  223. onAutotestdone: {
  224. console.log("自动对焦完成!")
  225. apptext_res.text = "自动对焦完成!"
  226. autotest_switch.enabled = true
  227. autotest_switch.checked = false
  228. }
  229. onTranslatedone: {
  230. console.log("胶带传送完成!")
  231. apptext_res.text = "胶带传送完成!"
  232. jiaodai_switch.enabled = true
  233. jiaodai_switch.checked = false
  234. }
  235. onDataReceived:function(data) {
  236. if(app.showRxData){
  237. var time = new Date().toLocaleTimeString()
  238. app.rxDataLog = "[" + time + "] " + data + "\n" + app.rxDataLog
  239. if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
  240. }
  241. // 同步坐标值到输入框
  242. try {
  243. var jsonData = JSON.parse(data)
  244. if(jsonData.ext && !textInput_x.focus && jsonData.ext.x_init_dis !== undefined) {
  245. textInput_x.text = jsonData.ext.x_init_dis.toString()
  246. }
  247. if(jsonData.ext && !textInput_y.focus && jsonData.ext.y_init_dis !== undefined) {
  248. textInput_y.text = jsonData.ext.y_init_dis.toString()
  249. }
  250. } catch(e) {
  251. console.log("解析坐标数据失败:", e)
  252. }
  253. }
  254. onNetMessage:function(data) {
  255. if(app.showTxData){
  256. var time = new Date().toLocaleTimeString()
  257. app.txDataLog = "[" + time + "] " + data + "\n" + app.txDataLog
  258. if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
  259. }
  260. }
  261. }
  262. SplitView{
  263. anchors.fill: parent
  264. orientation: Qt.Horizontal
  265. Rectangle {
  266. SplitView.preferredWidth: parent.width * 0.7
  267. height: parent.height
  268. color: app.cardColor
  269. radius: 5
  270. AppButton {
  271. id: normButton
  272. //anchors.horizontalCenter: parent.horizontalCenter
  273. anchors.centerIn: parent
  274. anchors.fill: parent
  275. //text: "打开相机"
  276. flat: true //边框是否可视
  277. onClicked: {
  278. console.log("相机状态:",frames.camera_sw)
  279. //if(camera.active){
  280. if(frames.camera_sw){
  281. text = "相机已关闭"
  282. output.visible = false
  283. frames.camera_sw = false
  284. //uvc_camera.visible = false
  285. }else{
  286. text = "打开相机"
  287. output.visible = true
  288. frames.camera_sw = true
  289. //uvc_camera.visible = true
  290. }
  291. }
  292. Timer {
  293. id: longPressTimer
  294. interval: 1000 // 长按时间1000ms
  295. running: false // 初始状态下定时器停止
  296. repeat: false // 设置为false,以便只执行一次
  297. onTriggered: {
  298. console.log("长按触发")
  299. }
  300. }
  301. onPressed: {
  302. console.log("按钮按下,开始计时")
  303. longPressTimer.start()
  304. }
  305. onReleased: {
  306. console.log("按钮释放,停止计时")
  307. longPressTimer.stop()
  308. }
  309. AppImage{
  310. id: image_picdis
  311. anchors.centerIn: parent
  312. source: "../../assets/photoico.svg"
  313. }
  314. }
  315. VideoOutput
  316. {
  317. id: output
  318. anchors.fill: parent
  319. visible: false
  320. fillMode: VideoOutput.PreserveAspectFit //根据视频的纵横比例等比例缩放
  321. //fillMode: VideoOutput.Stretch
  322. Component.onCompleted: {
  323. console.log("output onCompleted")
  324. }
  325. }
  326. Row {
  327. AppText {
  328. id: photoclarity_text
  329. width: parent.width
  330. text: frames.fpsString
  331. color: "red"
  332. }
  333. AppText {
  334. visible: true//app.photoclarity
  335. id: photoclarity2_text
  336. anchors.top: photoclarity_text.bottom
  337. width: parent.width
  338. text: frames.qulityString
  339. color: "green"
  340. }
  341. }
  342. // 图片上传进度网格(8列 x 4行 = 32格), 蛇形编号 1 在右上角, 常显示; 可按住拖动位置
  343. Rectangle {
  344. id: uploadGridWrap
  345. visible: true
  346. width: uploadGrid.implicitWidth
  347. height: uploadGrid.implicitHeight
  348. color: "transparent"
  349. // 初始位置: 画面右上角
  350. Component.onCompleted: {
  351. uploadGridWrap.x = uploadGridWrap.parent.width - uploadGridWrap.width - dp(10)
  352. uploadGridWrap.y = dp(10)
  353. }
  354. GridLayout {
  355. id: uploadGrid
  356. columns: 8
  357. columnSpacing: dp(2)
  358. rowSpacing: dp(2)
  359. Repeater {
  360. id: uploadGridRepeater
  361. model: uploadGridModel
  362. Rectangle {
  363. width: dp(42)
  364. height: dp(34)
  365. radius: dp(3)
  366. color: model.done ? "#8C1f9e4d" : "transparent"
  367. border.color: model.done ? "#37a24b" : "#66ffffff"
  368. border.width: 1
  369. Column {
  370. anchors.fill: parent
  371. spacing: 0
  372. AppText {
  373. text: model.serial
  374. color: "white"
  375. font.bold: true
  376. font.pixelSize: 11
  377. anchors.horizontalCenter: parent.horizontalCenter
  378. }
  379. AppText {
  380. text: model.percent > 0 ? Math.round(model.percent) + "%" : ""
  381. color: model.done ? "white" : "#ffb020"
  382. font.pixelSize: 10
  383. anchors.horizontalCenter: parent.horizontalCenter
  384. }
  385. }
  386. }
  387. }
  388. }
  389. // 按住拖动整个网格(DragHandler原生手势,平滑不卡顿;支持鼠标与触摸)
  390. DragHandler {
  391. id: gridDragHandler
  392. target: null
  393. acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchScreen
  394. property real startX: 0
  395. property real startY: 0
  396. onActiveChanged: {
  397. if(active){
  398. // 记录按下瞬间网格位置
  399. startX = uploadGridWrap.x
  400. startY = uploadGridWrap.y
  401. }
  402. }
  403. onTranslationChanged: {
  404. if(!active) return
  405. var nx = startX + translation.x
  406. var ny = startY + translation.y
  407. // 限制在父容器范围内
  408. nx = Math.max(0, Math.min(uploadGridWrap.parent.width - uploadGridWrap.width, nx))
  409. ny = Math.max(0, Math.min(uploadGridWrap.parent.height - uploadGridWrap.height, ny))
  410. uploadGridWrap.x = nx
  411. uploadGridWrap.y = ny
  412. }
  413. }
  414. }
  415. // 抓图按钮:仅相机打开时显示,画面右下角透明背景,点击=模拟MCU拍照指令(按序号保存/锐化/上传)
  416. Rectangle {
  417. id: captureBtn
  418. visible: frames.camera_sw
  419. width: dp(56)
  420. height: dp(56)
  421. radius: width / 2
  422. color: "transparent"
  423. border.color: "#80ffffff"
  424. border.width: dp(2)
  425. anchors.right: parent.right
  426. anchors.bottom: parent.bottom
  427. anchors.rightMargin: dp(12)
  428. anchors.bottomMargin: dp(12)
  429. AppImage {
  430. anchors.centerIn: parent
  431. width: dp(34)
  432. height: dp(34)
  433. source: "../../assets/photoico.svg"
  434. }
  435. MouseArea {
  436. anchors.fill: parent
  437. onClicked: {
  438. console.log("抓图按钮点击!")
  439. frames.manualCapture()
  440. }
  441. }
  442. }
  443. // 录制按钮:仅相机打开时显示,画面右下角(抓图按钮左侧)
  444. // 点击开始录制原始(未压缩)视频流,再次点击停止并把视频流保存到相机打开时创建的文件夹
  445. Rectangle {
  446. id: recordBtn
  447. visible: frames.camera_sw
  448. width: dp(56)
  449. height: dp(56)
  450. radius: width / 2
  451. color: "transparent"
  452. border.color: frames.recording ? "#e74c3c" : "#80ffffff"
  453. border.width: dp(2)
  454. anchors.right: captureBtn.left
  455. anchors.bottom: parent.bottom
  456. anchors.rightMargin: dp(12)
  457. anchors.bottomMargin: dp(12)
  458. // 未录制:红色圆点(开始);录制中:红色方块(停止)
  459. Rectangle {
  460. anchors.centerIn: parent
  461. width: frames.recording ? dp(22) : dp(26)
  462. height: frames.recording ? dp(22) : dp(26)
  463. radius: frames.recording ? dp(3) : width / 2
  464. color: "#e74c3c"
  465. }
  466. MouseArea {
  467. anchors.fill: parent
  468. onClicked: {
  469. if(frames.recording){
  470. console.log("停止录制视频流")
  471. frames.stopRecord()
  472. }else{
  473. console.log("开始录制视频流")
  474. if(frames.startRecord()){
  475. apptext_res.text = "开始录制视频流"
  476. }else{
  477. nativeUtils.displayMessageBox("提示","录制失败,请先打开相机!",1)
  478. }
  479. }
  480. }
  481. }
  482. }
  483. // 分析/融合处理期间:挂起相机画面输出,用进度/过程替代画面
  484. Rectangle {
  485. id: processOverlay
  486. visible: frames.processing
  487. anchors.fill: parent
  488. color: "#E6000000"
  489. z: 20
  490. Column {
  491. anchors.centerIn: parent
  492. spacing: dp(12)
  493. BusyIndicator {
  494. anchors.horizontalCenter: parent.horizontalCenter
  495. running: frames.processing
  496. width: dp(56)
  497. height: dp(56)
  498. }
  499. AppText {
  500. anchors.horizontalCenter: parent.horizontalCenter
  501. text: frames.processMessage
  502. color: "white"
  503. fontSize: 16
  504. }
  505. AppText {
  506. anchors.horizontalCenter: parent.horizontalCenter
  507. text: "处理中 " + frames.processPercent + "%"
  508. color: "#28a779"
  509. fontSize: 15
  510. }
  511. // 进度条
  512. Rectangle {
  513. width: dp(280)
  514. height: dp(8)
  515. radius: dp(4)
  516. color: "#33ffffff"
  517. anchors.horizontalCenter: parent.horizontalCenter
  518. Rectangle {
  519. width: parent.width * frames.processPercent / 100
  520. height: parent.height
  521. radius: parent.radius
  522. color: "#28a779"
  523. }
  524. }
  525. }
  526. }
  527. }
  528. ScrollView
  529. {
  530. SplitView.preferredWidth: parent.width*0.29
  531. SplitView.minimumWidth: 200
  532. clip: true
  533. Column {
  534. spacing: dp(15)
  535. Row {
  536. spacing: 80
  537. AppText {
  538. id: text_title
  539. text: "测试调试"
  540. font.bold: true
  541. color: "#28a779"
  542. fontSize: 20
  543. }
  544. AppText {
  545. id: apptext_res
  546. text: "[测试结果]"
  547. fontSize:15
  548. color: "grey"
  549. anchors.verticalCenter: text_title.verticalCenter
  550. }
  551. }
  552. Row {
  553. spacing: dp(120)
  554. AppText{
  555. text: "一键测试"
  556. fontSize: 15
  557. color: app.fontColor
  558. anchors.verticalCenter: autotest_switch.verticalCenter
  559. }
  560. AppSwitch {
  561. id: autotest_switch
  562. onToggled: {
  563. if(autotest_switch.checked==true){
  564. autotest_switch.enabled = false
  565. serial.sendCmd("autotest",true,"","");
  566. t_autotest.start()
  567. }else{
  568. console.log("t_autotest 计数:",t_autotest.interval)
  569. }
  570. }
  571. }
  572. Timer {
  573. id: t_autotest
  574. interval: 1000*60
  575. running: false
  576. repeat: false
  577. onTriggered: {
  578. autotest_switch.enabled = true
  579. autotest_switch.checked = false
  580. }
  581. }
  582. }
  583. Row {
  584. spacing: dp(120)
  585. AppText{
  586. text: "风机测试"
  587. color: app.fontColor
  588. fontSize: 15
  589. anchors.verticalCenter: fantest_switch.verticalCenter
  590. }
  591. AppSwitch {
  592. id: fantest_switch
  593. onToggled: {
  594. if(fantest_switch.checked==true){
  595. serial.sendCmd("fan",true,"","");
  596. apptext_res.text = "打开风机"
  597. }else{
  598. serial.sendCmd("fan",false,"","");
  599. apptext_res.text = "关闭风机"
  600. }
  601. }
  602. }
  603. }
  604. Row {
  605. spacing: dp(120)
  606. AppText{
  607. text: "胶带测试"
  608. fontSize: 15
  609. color: app.fontColor
  610. //font.bold: true
  611. anchors.verticalCenter: jiaodai_switch.verticalCenter
  612. }
  613. AppSwitch {
  614. id: jiaodai_switch
  615. onToggled: {
  616. if(jiaodai_switch.checked==true){
  617. // 检查是否处于温度保护状态
  618. if(app.tempProtectionState === true){
  619. // 弹出提示对话框
  620. nativeUtils.displayMessageBox(
  621. "提示",
  622. "当前处于温控状态,请解除温控后再进行测试胶带传送",
  623. 1
  624. );
  625. // 恢复开关状态为未选中
  626. jiaodai_switch.checked = false;
  627. return;
  628. }
  629. // 正常执行胶带测试
  630. //jiaodai_switch.enabled = false
  631. apptext_res.text = "胶带测试开始"
  632. serial.sendCmd("jiaodai",true,"","");
  633. }
  634. }
  635. }
  636. }
  637. Row {
  638. spacing: dp(120)
  639. AppText {
  640. text: "补光测试"
  641. color: app.fontColor
  642. fontSize: 15
  643. anchors.verticalCenter: led_switch.verticalCenter
  644. }
  645. AppSwitch {
  646. id: led_switch
  647. onToggled: {
  648. if(led_switch.checked==true){
  649. serial.sendCmd("led",true,"","");
  650. apptext_res.text = "补光灯已打开"
  651. }else{
  652. serial.sendCmd("led",false,"","");
  653. apptext_res.text = "补光灯已关闭"
  654. }
  655. }
  656. }
  657. }
  658. Row {
  659. spacing: dp(120)
  660. AppText {
  661. text: "立即拍照"
  662. color: app.fontColor
  663. fontSize: 15
  664. anchors.verticalCenter: takephoto_switch.verticalCenter
  665. }
  666. AppSwitch {
  667. id: takephoto_switch
  668. onToggled: {
  669. if(takephoto_switch.checked==true){
  670. apptext_res.text = "立即拍照"
  671. frames.captureImage()
  672. }
  673. }
  674. }
  675. }
  676. Row {
  677. spacing: dp(120)
  678. AppText {
  679. text: "对焦拍照"
  680. color: app.fontColor
  681. fontSize: 15
  682. anchors.verticalCenter: focus_switch.verticalCenter
  683. }
  684. AppSwitch {
  685. id: focus_switch
  686. onToggled: {
  687. if(focus_switch.checked==true){
  688. apptext_res.text = "开始对焦"
  689. focus_switch.enabled = false
  690. serial.auto_takephoto(true)
  691. }
  692. }
  693. }
  694. }
  695. // 滤网更换测试按钮(始终可见)
  696. Row {
  697. spacing: dp(120)
  698. AppText {
  699. text: "滤网更换"
  700. color: app.fontColor
  701. fontSize: 15
  702. anchors.verticalCenter: selfclean_switch.verticalCenter
  703. }
  704. AppSwitch {
  705. id: selfclean_switch
  706. onToggled: {
  707. if(selfclean_switch.checked==true){
  708. apptext_res.text = "自清洁测试中..."
  709. serial.sendCmd("selfclean",true,"","");
  710. }
  711. }
  712. }
  713. }
  714. // 分割线
  715. Rectangle {
  716. visible: !motorUnlocked
  717. width: parent.width
  718. height: dp(1)
  719. color: "#e0e0e0"
  720. }
  721. // 分割线
  722. Rectangle {
  723. width: parent.width
  724. height: dp(2)
  725. color: "#28a779"
  726. }
  727. // 密码输入区域(未解锁时显示)
  728. Rectangle {
  729. visible: !motorUnlocked
  730. width: parent.width
  731. height: passwordColumn.height + dp(16)
  732. color: app.cardColor
  733. radius: dp(8)
  734. border.color: "#28a779"
  735. border.width: dp(1)
  736. Column {
  737. id: passwordColumn
  738. anchors.centerIn: parent
  739. spacing: dp(10)
  740. AppText {
  741. anchors.horizontalCenter: parent.horizontalCenter
  742. text: "请输入密码解锁电机控制"
  743. color: app.fontColor
  744. font.bold: true
  745. fontSize: 14
  746. }
  747. Row {
  748. anchors.horizontalCenter: parent.horizontalCenter
  749. spacing: dp(8)
  750. AppTextField {
  751. id: motorPasswordInput
  752. width: dp(130)
  753. height: dp(38)
  754. echoMode: TextInput.Password
  755. placeholderText: "密码"
  756. inputMethodHints: Qt.ImhDigitsOnly
  757. anchors.verticalCenter: parent.verticalCenter
  758. onAccepted: {
  759. if(text === "666888"){
  760. motorUnlocked = true
  761. text = ""
  762. }else{
  763. apptext_res.text = "密码错误"
  764. text = ""
  765. }
  766. }
  767. }
  768. AppButton {
  769. text: "确认"
  770. textColor: "white"
  771. flat: false
  772. backgroundColor: "#28a779"
  773. minimumHeight: dp(38)
  774. minimumWidth: dp(55)
  775. anchors.verticalCenter: parent.verticalCenter
  776. onClicked: {
  777. if(motorPasswordInput.text === "666888"){
  778. motorUnlocked = true
  779. motorPasswordInput.text = ""
  780. }else{
  781. apptext_res.text = "密码错误"
  782. motorPasswordInput.text = ""
  783. }
  784. }
  785. }
  786. }
  787. }
  788. }
  789. // 电机控制及以下所有控件(解锁后显示)
  790. Item {
  791. id: motorSection
  792. visible: motorUnlocked
  793. width: parent.width
  794. height: motorContent.height + dp(20)
  795. property alias content: motorContent
  796. Column {
  797. id: motorContent
  798. spacing: dp(12)
  799. width: parent.width
  800. // 锁定按钮
  801. Row {
  802. spacing: dp(5)
  803. width: parent.width
  804. AppText {
  805. text: "高级控制"
  806. font.bold: true
  807. color: "#28a779"
  808. fontSize: 20
  809. anchors.verticalCenter: parent.verticalCenter
  810. }
  811. AppButton {
  812. text: "锁定"
  813. textColor: "white"
  814. flat: false
  815. backgroundColor: "#d9534f"
  816. minimumHeight: dp(25)
  817. minimumWidth: dp(50)
  818. anchors.verticalCenter: parent.verticalCenter
  819. onClicked: motorUnlocked = false
  820. }
  821. }
  822. AppText {
  823. id: text_title2
  824. text: "三轴步进电机控制"
  825. font.bold: true
  826. color: "#28a779"
  827. fontSize: 20
  828. }
  829. // 轴选择
  830. Row {
  831. spacing: dp(8)
  832. width: parent.width
  833. AppText {
  834. text: "选择轴:"
  835. width: dp(60)
  836. color: app.fontColor
  837. anchors.verticalCenter: parent.verticalCenter
  838. }
  839. ComboBox {
  840. width: parent.width - dp(100)
  841. height: dp(40)
  842. model: ["X轴", "Y轴", "Z轴"]
  843. onCurrentIndexChanged: currentAxis = currentIndex
  844. }
  845. AppButton {
  846. text: "校准"
  847. textColor: "black"
  848. flat: false
  849. borderColor: "black"
  850. borderWidth: dp(1)
  851. backgroundColor: "white"
  852. minimumHeight: dp(30)
  853. minimumWidth: dp(50)
  854. onClicked:
  855. {
  856. autotake(false)
  857. if(currentAxis==0)
  858. {
  859. console.log("校准X")
  860. serial.sendCmd("calibrate",false,"x",speed.toString())
  861. }else if(currentAxis==1)
  862. {
  863. console.log("校准Y")
  864. serial.sendCmd("calibrate",false,"y",speed.toString())
  865. }else if(currentAxis==2)
  866. {
  867. console.log("校准Z")
  868. serial.sendCmd("calibrate",false,"z",speed.toString())
  869. }
  870. }
  871. }
  872. }
  873. // 速度调节
  874. Row {
  875. spacing: dp(10)
  876. width: parent.width
  877. AppText {
  878. text: "速度:"
  879. width: dp(40)
  880. color: app.fontColor
  881. anchors.verticalCenter: parent.verticalCenter
  882. }
  883. AppSlider {
  884. width: parent.width - dp(60)
  885. from: 0
  886. to: 100
  887. value: speed
  888. stepSize: 1
  889. onValueChanged: speed = value
  890. anchors.verticalCenter: parent.verticalCenter
  891. }
  892. AppText {
  893. text: speed
  894. width: dp(40)
  895. anchors.verticalCenter: parent.verticalCenter
  896. }
  897. }
  898. // 步进距离设置
  899. Row {
  900. spacing: dp(10)
  901. width: parent.width
  902. AppText {
  903. text: "步进脉冲次数:"
  904. width: dp(120)
  905. color: app.fontColor
  906. anchors.verticalCenter: parent.verticalCenter
  907. }
  908. AppTextField {
  909. id: step_apptextfield
  910. width: parent.width - dp(120)
  911. text: stepDistance
  912. validator: IntValidator { bottom: 0; top: 2000 }
  913. onTextChanged: stepDistance = parseInt(text)
  914. }
  915. }
  916. // 运动控制按钮
  917. Row {
  918. spacing: dp(10)
  919. width: parent.width
  920. AppButton {
  921. text: " 正转 "
  922. textColor: "black"
  923. flat: false
  924. borderColor: "black"
  925. borderWidth: dp(1)
  926. backgroundColor: "grey"
  927. minimumHeight: dp(30)
  928. minimumWidth: dp(50)
  929. width: (parent.width - dp(30))/4
  930. onClicked:
  931. {
  932. if(currentAxis==0)
  933. {
  934. console.log("X轴正转:",stepDistance)
  935. serial.sendCmd("movx",false,"f"+stepDistance,speed.toString())
  936. }else if(currentAxis==1)
  937. {
  938. console.log("Y轴正转:",stepDistance)
  939. serial.sendCmd("movy",false,"f"+stepDistance,speed.toString())
  940. }else if(currentAxis==2)
  941. {
  942. console.log("Z轴正转:",stepDistance)
  943. serial.sendCmd("movz",false,"f"+stepDistance,speed.toString())
  944. }
  945. }
  946. }
  947. AppButton {
  948. text: " 停止 "
  949. textColor: "black"
  950. flat: false
  951. borderColor: "black"
  952. borderWidth: dp(1)
  953. backgroundColor: "red"
  954. minimumHeight: dp(30)
  955. minimumWidth: dp(50)
  956. width: (parent.width - dp(30))/4
  957. onClicked:
  958. {
  959. console.log("停止")
  960. serial.sendCmd("movx",false,"f0","")
  961. }
  962. }
  963. AppButton {
  964. text: " 反转 "
  965. textColor: "black"
  966. flat: false
  967. borderColor: "black"
  968. borderWidth: dp(1)
  969. backgroundColor: "grey"
  970. minimumHeight: dp(30)
  971. minimumWidth: dp(50)
  972. width: (parent.width - dp(30))/4
  973. onClicked:
  974. {
  975. if(currentAxis==0)
  976. {
  977. console.log("X轴反转:",stepDistance)
  978. serial.sendCmd("movx",false,"b"+stepDistance,speed.toString())
  979. }else if(currentAxis==1)
  980. {
  981. console.log("Y轴反转:",stepDistance)
  982. serial.sendCmd("movy",false,"b"+stepDistance,speed.toString())
  983. }else if(currentAxis==2)
  984. {
  985. console.log("Z轴反转:",stepDistance)
  986. serial.sendCmd("movz",false,"b"+stepDistance,speed.toString())
  987. }
  988. }
  989. }
  990. AppButton {
  991. text: " 复位 "
  992. textColor: "black"
  993. flat: false
  994. borderColor: "black"
  995. borderWidth: dp(1)
  996. backgroundColor: "grey"
  997. minimumHeight: dp(30)
  998. minimumWidth: dp(50)
  999. width: (parent.width - dp(30))/4
  1000. onClicked: {
  1001. if(currentAxis==0)
  1002. {
  1003. console.log("X轴复位!")
  1004. serial.sendCmd("movx",true,"",speed.toString())
  1005. }else if(currentAxis==1)
  1006. {
  1007. console.log("Y轴复位!")
  1008. serial.sendCmd("movy",true,"",speed.toString())
  1009. }else if(currentAxis==2)
  1010. {
  1011. console.log("Z轴复位!")
  1012. serial.sendCmd("movz",true,"",speed.toString())
  1013. }
  1014. }
  1015. }
  1016. }
  1017. // ===== 坐标参数 =====
  1018. AppText {
  1019. text: "坐标参数"
  1020. font.bold: true
  1021. color: "#28a779"
  1022. fontSize: 20
  1023. }
  1024. // X 坐标输入行
  1025. Row {
  1026. spacing: dp(5)
  1027. width: parent.width
  1028. AppText {
  1029. text: "X坐标:"
  1030. width: dp(50)
  1031. color: app.fontColor
  1032. fontSize: 15
  1033. anchors.verticalCenter: textInput_x.verticalCenter
  1034. }
  1035. AppTextField {
  1036. id: textInput_x
  1037. width: parent.width - dp(80)
  1038. height: dp(40)
  1039. placeholderText: "0"
  1040. text: "0"
  1041. font.family: "Arial"
  1042. font.pixelSize: 15
  1043. validator: DoubleValidator { decimals: 2 }
  1044. EnterKey.type: Qt.EnterKeyDone
  1045. inputMethodHints: Qt.ImhFormattedNumbersOnly
  1046. property real numericValue_x: Number(text) || 0
  1047. Keys.onReturnPressed: {
  1048. serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
  1049. Qt.inputMethod.hide()
  1050. }
  1051. onAccepted: {
  1052. serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
  1053. }
  1054. }
  1055. }
  1056. // Y 坐标输入行
  1057. Row {
  1058. spacing: dp(5)
  1059. width: parent.width
  1060. AppText {
  1061. text: "Y坐标:"
  1062. width: dp(50)
  1063. color: app.fontColor
  1064. fontSize: 15
  1065. anchors.verticalCenter: textInput_y.verticalCenter
  1066. }
  1067. AppTextField {
  1068. id: textInput_y
  1069. width: parent.width - dp(80)
  1070. height: dp(40)
  1071. placeholderText: "0"
  1072. text: "0"
  1073. font.family: "Arial"
  1074. font.pixelSize: 15
  1075. validator: DoubleValidator { decimals: 2 }
  1076. EnterKey.type: Qt.EnterKeyDone
  1077. inputMethodHints: Qt.ImhFormattedNumbersOnly
  1078. property real numericValue_y: Number(text) || 0
  1079. Keys.onReturnPressed: {
  1080. serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
  1081. Qt.inputMethod.hide()
  1082. }
  1083. onAccepted: {
  1084. serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
  1085. }
  1086. }
  1087. }
  1088. // 分割线
  1089. Rectangle {
  1090. width: parent.width
  1091. height: dp(2)
  1092. color: "#e0e0e0"
  1093. }
  1094. // ===== 相机参数 =====
  1095. AppText {
  1096. id: text_camera
  1097. text: "相机参数"
  1098. font.bold: true
  1099. color: "#28a779"
  1100. fontSize: 20
  1101. }
  1102. Row {
  1103. spacing: dp(10)
  1104. width: parent.width
  1105. AppText {
  1106. id: txt_fExposureTime
  1107. text: "曝光值:"
  1108. color: app.fontColor
  1109. }
  1110. AppTextField {
  1111. anchors.verticalCenter: txt_fExposureTime.verticalCenter
  1112. placeholderText: fExposureTime
  1113. text: fExposureTime
  1114. width: parent.width - dp(10)
  1115. EnterKey.type: Qt.EnterKeyDone
  1116. wrapMode: Text.NoWrap
  1117. inputMethodHints: Qt.ImhFormattedNumbersOnly |
  1118. Qt.ImhPreferDone |
  1119. Qt.ImhNoPredictiveText
  1120. validator: DoubleValidator {
  1121. bottom: 100.00
  1122. top: 500000.00
  1123. decimals: 0
  1124. }
  1125. // 关键:兜底(IME 再作妖也不怕)
  1126. Keys.onReturnPressed: {
  1127. frames.cam_ExposureTime = text
  1128. console.log("设置曝光时间:",text)
  1129. Qt.inputMethod.hide()
  1130. }
  1131. onAccepted: {
  1132. frames.cam_ExposureTime = text
  1133. console.log("设置曝光时间",text)
  1134. }
  1135. }
  1136. }
  1137. // 相机型号(海康工业相机,打开相机后自动读取展示)
  1138. Row {
  1139. spacing: dp(10)
  1140. width: parent.width
  1141. AppText {
  1142. id: txt_camModel
  1143. text: "相机型号:"
  1144. color: app.fontColor
  1145. fontSize: 15
  1146. anchors.verticalCenter: parent.verticalCenter
  1147. }
  1148. AppText {
  1149. text: frames.cam_ModelName
  1150. color: "#28a779"
  1151. font.bold: true
  1152. fontSize: 15
  1153. elide: Text.ElideRight
  1154. width: parent.width - txt_camModel.width - dp(10)
  1155. anchors.verticalCenter: parent.verticalCenter
  1156. }
  1157. }
  1158. // 亮度(自动曝光目标灰度0-255,设置后切换为自动曝光,手动曝光值失效)
  1159. Row {
  1160. spacing: dp(10)
  1161. width: parent.width
  1162. AppText {
  1163. id: txt_fBrightness
  1164. text: "亮度:"
  1165. color: app.fontColor
  1166. fontSize: 15
  1167. anchors.verticalCenter: parent.verticalCenter
  1168. }
  1169. AppTextField {
  1170. anchors.verticalCenter: txt_fBrightness.verticalCenter
  1171. placeholderText: frames.cam_Brightness
  1172. text: frames.cam_Brightness
  1173. width: parent.width - dp(10)
  1174. EnterKey.type: Qt.EnterKeyDone
  1175. wrapMode: Text.NoWrap
  1176. inputMethodHints: Qt.ImhDigitsOnly |
  1177. Qt.ImhPreferDone |
  1178. Qt.ImhNoPredictiveText
  1179. validator: IntValidator {
  1180. bottom: 0
  1181. top: 255
  1182. }
  1183. Keys.onReturnPressed: {
  1184. frames.cam_Brightness = text
  1185. console.log("设置亮度:", text)
  1186. Qt.inputMethod.hide()
  1187. }
  1188. onAccepted: {
  1189. frames.cam_Brightness = text
  1190. console.log("设置亮度:", text)
  1191. }
  1192. }
  1193. }
  1194. // 白平衡自动模式(关闭后可手动调下方红/蓝比例)
  1195. Row {
  1196. spacing: dp(10)
  1197. width: parent.width
  1198. AppText {
  1199. text: "白平衡:"
  1200. color: app.fontColor
  1201. fontSize: 15
  1202. anchors.verticalCenter: wbModeBox.verticalCenter
  1203. }
  1204. ComboBox {
  1205. id: wbModeBox
  1206. width: parent.width - dp(80)
  1207. height: dp(40)
  1208. model: ["关闭", "自动一次", "连续自动"]
  1209. currentIndex: frames.cam_WhiteBalanceMode
  1210. onActivated: {
  1211. frames.cam_WhiteBalanceMode = currentIndex
  1212. apptext_res.text = "白平衡模式:" + model[currentIndex]
  1213. console.log("设置白平衡模式:", model[currentIndex])
  1214. //用户选择会打断currentIndex的属性绑定,重新建立以保持相机参数回显同步
  1215. wbModeBox.currentIndex = Qt.binding(function(){ return frames.cam_WhiteBalanceMode })
  1216. }
  1217. }
  1218. }
  1219. // 白平衡红/蓝比例(手动模式下生效,写入时自动切为关闭模式)
  1220. Row {
  1221. spacing: dp(8)
  1222. width: parent.width
  1223. AppText {
  1224. text: "红/蓝比例:"
  1225. color: app.fontColor
  1226. fontSize: 13
  1227. anchors.verticalCenter: parent.verticalCenter
  1228. }
  1229. AppTextField {
  1230. id: wbRatioRField
  1231. width: (parent.width - dp(80)) / 2
  1232. placeholderText: "红 " + frames.cam_BalanceRatioR
  1233. text: frames.cam_BalanceRatioR
  1234. EnterKey.type: Qt.EnterKeyDone
  1235. wrapMode: Text.NoWrap
  1236. inputMethodHints: Qt.ImhDigitsOnly |
  1237. Qt.ImhPreferDone |
  1238. Qt.ImhNoPredictiveText
  1239. validator: IntValidator {
  1240. bottom: 0
  1241. top: 16383
  1242. }
  1243. Keys.onReturnPressed: {
  1244. frames.cam_BalanceRatioR = text
  1245. console.log("设置白平衡红比例:", text)
  1246. Qt.inputMethod.hide()
  1247. }
  1248. onAccepted: {
  1249. frames.cam_BalanceRatioR = text
  1250. console.log("设置白平衡红比例:", text)
  1251. }
  1252. }
  1253. AppTextField {
  1254. id: wbRatioBField
  1255. width: (parent.width - dp(80)) / 2
  1256. placeholderText: "蓝 " + frames.cam_BalanceRatioB
  1257. text: frames.cam_BalanceRatioB
  1258. EnterKey.type: Qt.EnterKeyDone
  1259. wrapMode: Text.NoWrap
  1260. inputMethodHints: Qt.ImhDigitsOnly |
  1261. Qt.ImhPreferDone |
  1262. Qt.ImhNoPredictiveText
  1263. validator: IntValidator {
  1264. bottom: 0
  1265. top: 16383
  1266. }
  1267. Keys.onReturnPressed: {
  1268. frames.cam_BalanceRatioB = text
  1269. console.log("设置白平衡蓝比例:", text)
  1270. Qt.inputMethod.hide()
  1271. }
  1272. onAccepted: {
  1273. frames.cam_BalanceRatioB = text
  1274. console.log("设置白平衡蓝比例:", text)
  1275. }
  1276. }
  1277. }
  1278. AppText {
  1279. id: text_debug
  1280. text: "通信调试"
  1281. font.bold: true
  1282. color: "#28a779"
  1283. fontSize: 20
  1284. }
  1285. Row {
  1286. spacing: dp(12)
  1287. AppText {
  1288. text: "显示Serial发送数据"
  1289. color: app.fontColor
  1290. fontSize: 15
  1291. anchors.verticalCenter: txSwitch.verticalCenter
  1292. }
  1293. AppSwitch {
  1294. id: txSwitch
  1295. onToggled: {
  1296. app.floatPanel = checked
  1297. app.showTxData = checked
  1298. app.floatPanel_title = "Serial发送数据"
  1299. }
  1300. }
  1301. }
  1302. Row {
  1303. spacing: dp(12)
  1304. AppText {
  1305. text: "显示Serial接收数据"
  1306. color: app.fontColor
  1307. fontSize: 15
  1308. anchors.verticalCenter: rxSwitch.verticalCenter
  1309. }
  1310. AppSwitch {
  1311. id: rxSwitch
  1312. onToggled: {
  1313. app.floatPanel = checked
  1314. app.showRxData = checked
  1315. app.floatPanel_title = "Serial接收数据"
  1316. }
  1317. }
  1318. }
  1319. Row {
  1320. spacing: dp(12)
  1321. AppText {
  1322. text: "显示MQTT发送数据"
  1323. color: app.fontColor
  1324. fontSize: 15
  1325. anchors.verticalCenter: pubSwitch.verticalCenter
  1326. }
  1327. AppSwitch {
  1328. id: pubSwitch
  1329. onToggled: {
  1330. app.floatPanel = checked
  1331. app.showPubData = checked
  1332. app.showSubData = false
  1333. app.floatPanel_title = "MQTT发送数据"
  1334. }
  1335. }
  1336. }
  1337. Row {
  1338. spacing: dp(12)
  1339. AppText {
  1340. text: "显示MQTT接收数据"
  1341. color: app.fontColor
  1342. fontSize: 15
  1343. anchors.verticalCenter: subSwitch.verticalCenter
  1344. }
  1345. AppSwitch {
  1346. id: subSwitch
  1347. onToggled: {
  1348. app.floatPanel = checked
  1349. app.showSubData = checked
  1350. app.showPubData = false
  1351. app.floatPanel_title = "MQTT接收数据"
  1352. }
  1353. }
  1354. }
  1355. } // motorContent
  1356. } // motorSection
  1357. }
  1358. }
  1359. }
  1360. }