RobotErrorHandle.ets 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. import CommonConstants from '../common/constants/CommonConstants'
  2. import RobotErrorHandleRequest from '../common/util/request/RobotErrorHandleRequest'
  3. import MechanicalArmDebuggingRequest from '../common/util/request/MechanicalArmDebuggingRequest'
  4. import RobotInfo from '../model/RobotInfo'
  5. import RequestParam from '../viewmodel/RobotErrorHandle/RequestParam'
  6. import router from '@ohos.router'
  7. @Entry
  8. @Component
  9. export struct RobotErrorHandle {
  10. @State robots: RobotInfo[] = CommonConstants.ROBOTS
  11. @State list: Resource[] = [$r('app.media.car_preview'), $r('app.media.car_preview')]
  12. @State selectRobot: number = 0
  13. @State HingingLevel: number = 0
  14. @State HingingIndex: number = 0
  15. @State HingingString: string = '原位'
  16. @State colorArray: number[] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
  17. @State clickStatus: number[] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
  18. @State reminds:string='1'
  19. @State robotArray: Array<SelectOption> = []
  20. aboutToAppear(): void {
  21. if (this.robots && this.robots.length > 0) {
  22. for (const robot of this.robots ) {
  23. let option: SelectOption = { value: robot.robotCode ? robot.robotCode : ''}
  24. this.robotArray.push(option)
  25. }
  26. }
  27. }
  28. remindController: CustomDialogController = new CustomDialogController({
  29. builder: RemindDialog({
  30. remind: this.reminds,}
  31. ),
  32. })
  33. RobotSingleMoveController: CustomDialogController = new CustomDialogController({
  34. builder: RobotSingleMoveDialog({
  35. robots: this.robots,
  36. selectRobot: this.selectRobot,
  37. }
  38. ),
  39. alignment: DialogAlignment.Center,
  40. autoCancel: true,
  41. customStyle: true,
  42. })
  43. setRobotLocationController: CustomDialogController = new CustomDialogController({
  44. builder: SetRobotLocationDialog({
  45. robots: this.robots,
  46. selectRobot: this.selectRobot,
  47. }),
  48. alignment: DialogAlignment.Center,
  49. autoCancel: true,
  50. customStyle: true,
  51. })
  52. /*handleMoveErrorController: CustomDialogController = new CustomDialogController({
  53. builder: HandleMoveErrorDialog({
  54. robots: this.robots,
  55. selectRobot: this.selectRobot,
  56. }),
  57. alignment: DialogAlignment.Center,
  58. autoCancel: true,
  59. customStyle: true,
  60. })*/
  61. build() {
  62. Column() {
  63. Row() {
  64. Row() {
  65. Image($r('app.media.return'))
  66. .height(px2vp(48))
  67. .width(px2vp(48))
  68. .onClick(async () => {
  69. router.back()
  70. })
  71. }
  72. .width('20%')
  73. Row() {
  74. Text('机器人控制')
  75. .padding(10)
  76. .height('100%')
  77. .fontSize($r('app.float.title_font_size'))
  78. }
  79. .justifyContent(FlexAlign.End)
  80. .width('40%')
  81. Row() {
  82. Text('机器人:')
  83. .fontWeight(FontWeight.Medium)
  84. .fontSize($r('app.float.fontSize_18'))
  85. .width('20%')
  86. .height('100%')
  87. .textAlign(TextAlign.End)
  88. Select(this.robotArray)
  89. .selected(this.selectRobot)
  90. .value(this.robots && this.robots[this.selectRobot] && this.robots[this.selectRobot].robotCode ? this.robots[this.selectRobot].robotCode : '')
  91. .font({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
  92. .fontColor($r('app.color.black_100'))
  93. .borderRadius($r('app.float.general_border_radius'))
  94. .width('40%')
  95. .height('100%')
  96. .margin({right: '5%'})
  97. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  98. .selectedOptionFontColor($r('app.color.blue_100'))
  99. .selectedOptionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Bold})
  100. .optionFontColor($r('app.color.black_100'))
  101. .optionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Medium})
  102. .menuAlign(MenuAlignType.START, {dx:0, dy:0})
  103. .onSelect((index: number) => {
  104. this.selectRobot = index
  105. })
  106. }
  107. .width('40%')
  108. .height('100%')
  109. .justifyContent(FlexAlign.End)
  110. }
  111. .width('100%')
  112. .height('8%')
  113. .padding({ left: px2vp(24) })
  114. .alignItems(VerticalAlign.Center)
  115. .justifyContent(FlexAlign.Start)
  116. Row(){
  117. Column() {
  118. Image($r('app.media.robot_move'))
  119. .width($r('app.float.general_icon_size'))
  120. .height($r('app.float.general_icon_size'))
  121. Text('位移')
  122. .fontSize($r('app.float.set_card_font_size'))
  123. .fontColor($r('app.color.general_font_color'))
  124. .opacity($r('app.float.general_font_opacity'))
  125. .fontWeight(FontWeight.Medium)
  126. }
  127. .borderRadius($r('app.float.general_border_radius'))
  128. .justifyContent(FlexAlign.Center)
  129. .width('10%')
  130. .height('100%')
  131. Divider().vertical(true).color($r('app.color.black_100')).height('80%')
  132. .margin({right: '2%'})
  133. Row() {
  134. Column() {
  135. Text('设置小车位置')
  136. .fontSize($r('app.float.robot_set_font_size'))
  137. .fontWeight(FontWeight.Medium)
  138. .margin({left: '10%'})
  139. }
  140. .width('70%')
  141. Column() {
  142. Image($r('app.media.coordinate_edit'))
  143. .width('55px')
  144. .height('55px')
  145. }
  146. .width('30%')
  147. }
  148. .width('20%')
  149. .height('60%')
  150. .backgroundColor(this.colorArray[0] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  151. .alignItems(VerticalAlign.Center)
  152. .justifyContent(FlexAlign.End)
  153. .borderRadius($r('app.float.process_call_image_radius'))
  154. .margin({right: '2%' })
  155. .onClick(async ()=>{
  156. this.colorArray[0] = 2
  157. delayExecution(()=>{
  158. this.colorArray[0] = 1
  159. }, 100)
  160. this.setRobotLocationController.open()
  161. })
  162. Row() {
  163. Column() {
  164. Text('查询小车位置')
  165. .fontSize($r('app.float.robot_set_font_size'))
  166. .fontWeight(FontWeight.Medium)
  167. .margin({left: '10%'})
  168. }
  169. .width('70%')
  170. Column() {
  171. Image($r('app.media.robot_list'))
  172. .width('55px')
  173. .height('55px')
  174. }
  175. .width('30%')
  176. }
  177. .width('20%')
  178. .height('60%')
  179. .backgroundColor(this.colorArray[1] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  180. .alignItems(VerticalAlign.Center)
  181. .justifyContent(FlexAlign.End)
  182. .borderRadius($r('app.float.process_call_image_radius'))
  183. .margin({right: '2%' })
  184. .onClick(async ()=>{
  185. this.colorArray[1] = 2
  186. delayExecution(()=>{
  187. this.colorArray[1] = 1
  188. }, 100)
  189. if (this.clickStatus[1] == 1) {
  190. this.clickStatus[1] = 2
  191. delayExecution(()=>{
  192. console.log('hhtest','状态修改')
  193. this.clickStatus[1] = 1
  194. }, 2000)
  195. console.log('hhtest','执行函数:查询小车')
  196. let res: RgvInfo = await RobotErrorHandleRequest.get('/api/v1/wcs/rgv/' + this.robots[this.selectRobot].robotCode, {}) as RgvInfo
  197. if(res) {
  198. this.reminds = this.robots[this.selectRobot].robotCode+'小车位置:' + 'x:' + (res.x ? res.x : '') + ' y:' + (res.y ? res.y : '');
  199. this.remindController.open()
  200. delayExecution(() => {
  201. console.log('hhtest', '状态修改')
  202. this.remindController.close()
  203. }, 2000)
  204. }
  205. }
  206. })
  207. Row() {
  208. Column() {
  209. Text('查询小车状态')
  210. .fontSize($r('app.float.robot_set_font_size'))
  211. .fontWeight(FontWeight.Medium)
  212. .margin({left: '10%'})
  213. }
  214. .width('70%')
  215. Column() {
  216. Image($r('app.media.search_state'))
  217. .width('55px')
  218. .height('55px')
  219. }
  220. .width('30%')
  221. }
  222. .width('20%')
  223. .height('60%')
  224. .backgroundColor(this.colorArray[12] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  225. .alignItems(VerticalAlign.Center)
  226. .justifyContent(FlexAlign.End)
  227. .borderRadius($r('app.float.process_call_image_radius'))
  228. .margin({right: '2%' })
  229. .onClick(async ()=>{
  230. this.colorArray[12] = 2
  231. delayExecution(()=>{
  232. this.colorArray[12] = 1
  233. }, 100)
  234. if (this.clickStatus[12] == 1) {
  235. this.clickStatus[12] = 2
  236. delayExecution(()=>{
  237. console.log('hhtest','状态修改')
  238. this.clickStatus[12] = 1
  239. }, 2000)
  240. console.log('hhtest','执行函数:查询小车')
  241. let res: RgvInfo = await RobotErrorHandleRequest.get('/api/v1/wcs/rgv/' + this.robots[this.selectRobot].robotCode, {}) as RgvInfo
  242. let status:string = (res.status? res.status : '')
  243. if(status==='0')
  244. {
  245. this.reminds=this.robots[this.selectRobot].robotCode+'小车状态:静止'
  246. }
  247. else if (status==='1')
  248. {
  249. this.reminds=this.robots[this.selectRobot].robotCode+'小车状态:任务或充电'
  250. }
  251. else if (status==='2')
  252. {
  253. this.reminds=this.robots[this.selectRobot].robotCode+'小车状态:故障'
  254. }
  255. else{
  256. this.reminds=this.robots[this.selectRobot].robotCode+'小车状态:故障'
  257. }
  258. this.remindController.open()
  259. delayExecution(() => {
  260. console.log('hhtest', '状态修改')
  261. this.remindController.close()
  262. }, 2000)
  263. }
  264. })
  265. Row() {
  266. Column() {
  267. Text('单步移动小车')
  268. .fontSize($r('app.float.robot_set_font_size'))
  269. .fontWeight(FontWeight.Medium)
  270. .margin({left: '10%'})
  271. }
  272. .width('70%')
  273. Column() {
  274. Image($r('app.media.single_move'))
  275. .width('55px')
  276. .height('55px')
  277. }
  278. .width('30%')
  279. }
  280. .width('20%')
  281. .height('60%')
  282. .backgroundColor(this.colorArray[13] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  283. .alignItems(VerticalAlign.Center)
  284. .justifyContent(FlexAlign.End)
  285. .borderRadius($r('app.float.process_call_image_radius'))
  286. .margin({right: '2%' })
  287. .onClick(async ()=>{
  288. this.colorArray[13] = 2
  289. delayExecution(()=>{
  290. this.colorArray[13] = 1
  291. }, 100)
  292. this.RobotSingleMoveController.open()
  293. })
  294. }
  295. .height('22%')
  296. .width('100%')
  297. /* */
  298. Row(){
  299. Column() {
  300. Image($r('app.media.hanging_basket'))
  301. .width($r('app.float.general_icon_size'))
  302. .height($r('app.float.general_icon_size'))
  303. Text('吊篮')
  304. .fontSize($r('app.float.set_card_font_size'))
  305. .fontColor($r('app.color.general_font_color'))
  306. .opacity($r('app.float.general_font_opacity'))
  307. .fontWeight(FontWeight.Medium)
  308. }
  309. .borderRadius($r('app.float.general_border_radius'))
  310. .justifyContent(FlexAlign.Center)
  311. .width('10%')
  312. .height('100%')
  313. Divider().vertical(true).color($r('app.color.black_100')).height('80%')
  314. .margin({right: '2%'})
  315. Row() {
  316. Column() {
  317. Text('移动吊盘')
  318. .fontSize($r('app.float.robot_set_font_size'))
  319. .fontWeight(FontWeight.Medium)
  320. .margin({left: '10%'})
  321. }
  322. .width('70%')
  323. Column() {
  324. Image($r('app.media.hanging_basket_up'))
  325. .width('55px')
  326. .height('55px')
  327. }
  328. .width('30%')
  329. }
  330. .width('20%')
  331. .height('60%')
  332. .backgroundColor(this.colorArray[3] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  333. .alignItems(VerticalAlign.Center)
  334. .justifyContent(FlexAlign.End)
  335. .borderRadius($r('app.float.process_call_image_radius'))
  336. .margin({right: '2%' })
  337. .onClick(async ()=>{
  338. this.colorArray[3] = 2
  339. delayExecution(()=>{
  340. this.colorArray[3] = 1
  341. }, 100)
  342. if (this.clickStatus[3] == 1) {
  343. this.clickStatus[3] = 2
  344. delayExecution(()=>{
  345. console.log('hhtest','状态修改')
  346. this.clickStatus[3] = 1
  347. }, 2000)
  348. console.log('hhtest','执行函数:移动吊盘')
  349. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/moveBasket', {
  350. rgvNo: this.robots[this.selectRobot].robotCode,
  351. level: this.HingingLevel.toString(),
  352. } as RequestParam)
  353. console.log('移动吊盘:' + res.toString())
  354. this.reminds = '移动吊盘'
  355. this.remindController.open()
  356. delayExecution(()=>{
  357. console.log('hhtest','状态修改')
  358. this.remindController.close()
  359. }, 2000)
  360. }
  361. })
  362. Row(){
  363. Text('层数:')
  364. .fontWeight(FontWeight.Medium)
  365. .fontSize($r('app.float.fontSize_18'))
  366. .width('20%')
  367. .height('100%')
  368. .textAlign(TextAlign.End)
  369. // TextInput({ placeholder: '请输入数字', text: this.HingingLevel + ''})
  370. // .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  371. // .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  372. // .fontColor($r('app.color.login_text_input_font_color'))
  373. // .fontWeight(FontWeight.Medium)
  374. // .type(InputType.Number)
  375. // .maxLength(6)
  376. // .fontSize($r('app.float.fontSize_24'))
  377. // .width('60%')
  378. // .height('100%')
  379. // .opacity($r('app.float.general_font_opacity'))
  380. // .borderRadius($r('app.float.general_border_radius'))
  381. // .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  382. // .onChange((value: string) => {
  383. // this.HingingLevel = parseInt(value)
  384. // })
  385. Select([
  386. {value:"原位"},
  387. {value:"第一层"},
  388. {value:"第二层"},
  389. {value:"第三层"},
  390. {value:"第四层"},
  391. {value:"第五层"},
  392. {value:"第六层"},
  393. {value:"抽屉位"},
  394. ])
  395. .selected(this.HingingIndex)
  396. .value(this.HingingString)
  397. .font({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
  398. .fontColor($r('app.color.black_100'))
  399. .borderRadius($r('app.float.general_border_radius'))
  400. .width('80%')
  401. .height('100%')
  402. .margin({right: '5%'})
  403. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  404. .selectedOptionFontColor($r('app.color.blue_100'))
  405. .selectedOptionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Bold})
  406. .optionFontColor($r('app.color.black_100'))
  407. .optionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Medium})
  408. .menuAlign(MenuAlignType.START, {dx:0, dy:0})
  409. .onSelect((index: number,text:string) => {
  410. if(index!=7){
  411. this.HingingLevel = index
  412. }else{
  413. this.HingingLevel = 128
  414. }
  415. this.HingingString = text
  416. this.HingingIndex = index
  417. })
  418. }
  419. .width('20%')
  420. .height('30%')
  421. Row() {
  422. Column() {
  423. Text('抓夹张开')
  424. .fontSize($r('app.float.robot_set_font_size'))
  425. .fontWeight(FontWeight.Medium)
  426. .margin({left: '10%'})
  427. }
  428. .width('70%')
  429. Column() {
  430. Image($r('app.media.open_zhuajia'))
  431. .width('55px')
  432. .height('55px')
  433. }
  434. .width('30%')
  435. }
  436. .width('20%')
  437. .height('60%')
  438. .backgroundColor(this.colorArray[4] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  439. .alignItems(VerticalAlign.Center)
  440. .justifyContent(FlexAlign.End)
  441. .borderRadius($r('app.float.process_call_image_radius'))
  442. .margin({right: '2%',left:"23"})
  443. .onClick(async ()=>{
  444. this.colorArray[4] = 2
  445. delayExecution(()=>{
  446. this.colorArray[4] = 1
  447. }, 100)
  448. if (this.clickStatus[4] == 1) {
  449. this.clickStatus[4] = 2
  450. delayExecution(() => {
  451. console.log('hhtest', '状态修改')
  452. this.clickStatus[4] = 1
  453. }, 2000)
  454. console.log('hhtest', '执行函数:张开抓夹')
  455. // 张开抓夹
  456. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/controlClip', {
  457. rgvNo: this.robots[this.selectRobot].robotCode,
  458. action: '1',
  459. } as RequestParam)
  460. console.log('抓夹张开:' + res.toString())
  461. this.reminds = '抓夹张开'
  462. this.remindController.open()
  463. delayExecution(()=>{
  464. this.remindController.close()
  465. }, 2000)
  466. }
  467. })
  468. Row() {
  469. Column() {
  470. Text('抓夹闭合')
  471. .fontSize($r('app.float.robot_set_font_size'))
  472. .fontWeight(FontWeight.Medium)
  473. .margin({left: '10%'})
  474. }
  475. .width('70%')
  476. Column() {
  477. Image($r('app.media.close_zhuajia'))
  478. .width('55px')
  479. .height('55px')
  480. }
  481. .width('30%')
  482. }
  483. .width('20%')
  484. .height('60%')
  485. .backgroundColor(this.colorArray[5] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  486. .alignItems(VerticalAlign.Center)
  487. .justifyContent(FlexAlign.End)
  488. .borderRadius($r('app.float.process_call_image_radius'))
  489. .margin({right: '2%' })
  490. .onClick(async ()=>{
  491. this.colorArray[5] = 2
  492. delayExecution(()=>{
  493. this.colorArray[5] = 1
  494. }, 100)
  495. if (this.clickStatus[5] == 1) {
  496. this.clickStatus[5] = 2
  497. delayExecution(() => {
  498. console.log('hhtest', '状态修改')
  499. this.clickStatus[5] = 1
  500. }, 2000)
  501. this.reminds = '抓夹闭合'
  502. this.remindController.open()
  503. delayExecution(()=>{
  504. this.remindController.close()
  505. }, 2000)
  506. // 闭合抓夹
  507. console.log('hhtest', '执行函数:闭合抓夹')
  508. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/controlClip', {
  509. rgvNo: this.robots[this.selectRobot].robotCode,
  510. action: '2',
  511. } as RequestParam)
  512. console.log('抓夹闭合:' + res.toString())
  513. this.reminds = '抓夹闭合'
  514. this.remindController.open()
  515. delayExecution(()=>{
  516. this.remindController.close()
  517. }, 2000)
  518. }
  519. })
  520. }
  521. .height('22%')
  522. .width('100%')
  523. Row(){
  524. Column() {
  525. Image($r('app.media.robot_battery'))
  526. .width($r('app.float.general_icon_size'))
  527. .height($r('app.float.general_icon_size'))
  528. Text('电源')
  529. .fontSize($r('app.float.set_card_font_size'))
  530. .fontColor($r('app.color.general_font_color'))
  531. .opacity($r('app.float.general_font_opacity'))
  532. .fontWeight(FontWeight.Medium)
  533. }
  534. .borderRadius($r('app.float.general_border_radius'))
  535. .justifyContent(FlexAlign.Center)
  536. .width('10%')
  537. .height('100%')
  538. Divider().vertical(true).color($r('app.color.black_100')).height('80%')
  539. .margin({right: '2%'})
  540. Row() {
  541. Column() {
  542. Text('电机开机')
  543. .fontSize($r('app.float.robot_set_font_size'))
  544. .fontWeight(FontWeight.Medium)
  545. .margin({left: '10%'})
  546. }
  547. .width('70%')
  548. Column() {
  549. Image($r('app.media.electrical_machinery_on'))
  550. .width('55px')
  551. .height('55px')
  552. }
  553. .width('30%')
  554. }
  555. .width('20%')
  556. .height('60%')
  557. .backgroundColor(this.colorArray[6] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  558. .alignItems(VerticalAlign.Center)
  559. .justifyContent(FlexAlign.End)
  560. .borderRadius($r('app.float.process_call_image_radius'))
  561. .margin({right: '2%' })
  562. .onClick(async ()=>{
  563. this.colorArray[6] = 2
  564. delayExecution(()=>{
  565. this.colorArray[6] = 1
  566. }, 100)
  567. if (this.clickStatus[6] == 1) {
  568. this.clickStatus[6] = 2
  569. delayExecution(() => {
  570. console.log('hhtest', '状态修改')
  571. this.clickStatus[6] = 1
  572. }, 2000)
  573. console.log('hhtest', '执行函数:电机开机---')
  574. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
  575. rgvNo: this.robots[this.selectRobot].robotCode,
  576. option: 'motor'
  577. } as RequestParam)
  578. console.log('机器人开机:' + res.toString());
  579. delayExecution(async () => {
  580. res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
  581. rgvNo: this.robots[this.selectRobot].robotCode,
  582. option: 'mainPower'
  583. } as RequestParam);
  584. console.log('机器人开机:' + res.toString());
  585. res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
  586. rgvNo: this.robots[this.selectRobot].robotCode,
  587. option: 'mcu'
  588. } as RequestParam);
  589. console.log('机器人开机:' + res.toString());
  590. }, 5000);
  591. this.reminds = '机器人开机'
  592. this.remindController.open()
  593. delayExecution(()=>{
  594. this.remindController.close()
  595. }, 2000)
  596. }
  597. })
  598. Row() {
  599. Column() {
  600. Text('电机关机')
  601. .fontSize($r('app.float.robot_set_font_size'))
  602. .fontWeight(FontWeight.Medium)
  603. .margin({left: '10%'})
  604. }
  605. .width('70%')
  606. Column() {
  607. Image($r('app.media.electrical_machinery_off'))
  608. .width('55px')
  609. .height('55px')
  610. }
  611. .width('30%')
  612. }
  613. .width('20%')
  614. .height('60%')
  615. .backgroundColor(this.colorArray[7] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  616. .alignItems(VerticalAlign.Center)
  617. .justifyContent(FlexAlign.End)
  618. .borderRadius($r('app.float.process_call_image_radius'))
  619. .margin({right: '2%' })
  620. .onClick(async ()=>{
  621. this.colorArray[7] = 2
  622. delayExecution(()=>{
  623. this.colorArray[7] = 1
  624. }, 100)
  625. if (this.clickStatus[7] == 1) {
  626. this.clickStatus[7] = 2
  627. delayExecution(() => {
  628. console.log('hhtest', '状态修改')
  629. this.clickStatus[7] = 1
  630. }, 2000)
  631. console.log('hhtest', '执行函数:电机关机---')
  632. let res1: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
  633. rgvNo: this.robots[this.selectRobot].robotCode,
  634. option: 'off'
  635. } as RequestParam);
  636. console.log('机器人关机:' + res1.toString());
  637. delayExecution(async () => {
  638. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
  639. rgvNo: this.robots[this.selectRobot].robotCode,
  640. option: 'motor'
  641. } as RequestParam);
  642. console.log('机器人关机:' + res.toString());
  643. delayExecution(async () => {
  644. res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
  645. rgvNo: this.robots[this.selectRobot].robotCode,
  646. option: 'mainPower'
  647. } as RequestParam);
  648. console.log('机器人关机:' + res.toString());
  649. res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
  650. rgvNo: this.robots[this.selectRobot].robotCode,
  651. option: 'mcu'
  652. } as RequestParam);
  653. console.log('机器人关机:' + res.toString());
  654. this.reminds = '机器人关机';
  655. this.remindController.open();
  656. delayExecution(() => {
  657. this.remindController.close();
  658. }, 2000);
  659. }, 5000);
  660. }, 5000);
  661. }
  662. })
  663. Row() {
  664. Column() {
  665. Text('开始充电')
  666. .fontSize($r('app.float.robot_set_font_size'))
  667. .fontWeight(FontWeight.Medium)
  668. .margin({left: '10%'})
  669. }
  670. .width('70%')
  671. Column() {
  672. Image($r('app.media.robot_charge_connect'))
  673. .width('55px')
  674. .height('55px')
  675. }
  676. .width('30%')
  677. }
  678. .width('20%')
  679. .height('60%')
  680. .backgroundColor(this.colorArray[8] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  681. .alignItems(VerticalAlign.Center)
  682. .justifyContent(FlexAlign.End)
  683. .borderRadius($r('app.float.process_call_image_radius'))
  684. .margin({right: '2%' })
  685. .onClick(async ()=>{
  686. this.colorArray[8] = 2
  687. delayExecution(()=>{
  688. this.colorArray[8] = 1
  689. }, 100)
  690. if (this.clickStatus[8] == 1) {
  691. this.clickStatus[8] = 2
  692. delayExecution(() => {
  693. console.log('hhtest', '状态修改')
  694. this.clickStatus[8] = 1
  695. }, 2000)
  696. console.log('hhtest', '执行函数:开始充电---')
  697. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
  698. rgvNo: this.robots[this.selectRobot].robotCode,
  699. option: 'on'
  700. } as RequestParam)
  701. console.log('手动充电:' + res.toString())
  702. this.reminds = '充电开始'
  703. this.remindController.open()
  704. delayExecution(()=>{
  705. this.remindController.close()
  706. }, 2000)
  707. }
  708. })
  709. Row() {
  710. Column() {
  711. Text('停止充电')
  712. .fontSize($r('app.float.robot_set_font_size'))
  713. .fontWeight(FontWeight.Medium)
  714. .margin({left: '10%'})
  715. }
  716. .width('70%')
  717. Column() {
  718. Image($r('app.media.robot_charge_disconnect'))
  719. .width('55px')
  720. .height('55px')
  721. }
  722. .width('30%')
  723. }
  724. .width('20%')
  725. .height('60%')
  726. .backgroundColor(this.colorArray[9] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  727. .alignItems(VerticalAlign.Center)
  728. .justifyContent(FlexAlign.End)
  729. .borderRadius($r('app.float.process_call_image_radius'))
  730. .margin({right: '2%' })
  731. .onClick(async ()=>{
  732. this.colorArray[9] = 2
  733. delayExecution(()=>{
  734. this.colorArray[9] = 1
  735. }, 100)
  736. if (this.clickStatus[9] == 1) {
  737. this.clickStatus[9] = 2
  738. delayExecution(() => {
  739. console.log('hhtest', '状态修改')
  740. this.clickStatus[9] = 1
  741. }, 2000)
  742. console.log('hhtest', '执行函数:停止充电---')
  743. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
  744. rgvNo: this.robots[this.selectRobot].robotCode,
  745. option: 'off'
  746. } as RequestParam)
  747. console.log('手动充电结束:' + res.toString())
  748. this.reminds = '充电结束'
  749. this.remindController.open()
  750. delayExecution(()=>{
  751. this.remindController.close()
  752. }, 2000)
  753. }
  754. })
  755. }
  756. .height('22%')
  757. .width('100%')
  758. Row(){
  759. Column() {
  760. Image($r('app.media.open_close_door'))
  761. .width($r('app.float.general_icon_size'))
  762. .height($r('app.float.general_icon_size'))
  763. Text('开关门')
  764. .fontSize($r('app.float.set_card_font_size'))
  765. .fontColor($r('app.color.general_font_color'))
  766. .opacity($r('app.float.general_font_opacity'))
  767. .fontWeight(FontWeight.Medium)
  768. }
  769. .borderRadius($r('app.float.general_border_radius'))
  770. .justifyContent(FlexAlign.Center)
  771. .width('10%')
  772. .height('100%')
  773. Divider().vertical(true).color($r('app.color.black_100')).height('80%')
  774. .margin({right: '2%'})
  775. Row() {
  776. Column() {
  777. Text('充电室开门')
  778. .fontSize($r('app.float.robot_set_font_size'))
  779. .fontWeight(FontWeight.Medium)
  780. .margin({left: '10%'})
  781. }
  782. .width('70%')
  783. Column() {
  784. Image($r('app.media.open_door'))
  785. .width('55px')
  786. .height('55px')
  787. }
  788. .width('30%')
  789. }
  790. .width('20%')
  791. .height('60%')
  792. .backgroundColor(this.colorArray[10] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  793. .alignItems(VerticalAlign.Center)
  794. .justifyContent(FlexAlign.End)
  795. .borderRadius($r('app.float.process_call_image_radius'))
  796. .margin({right: '2%' })
  797. .onClick(async ()=>{
  798. this.colorArray[10] = 2
  799. delayExecution(()=>{
  800. this.colorArray[10] = 1
  801. }, 100)
  802. if (this.clickStatus[10] == 1) {
  803. this.clickStatus[10] = 2
  804. delayExecution(()=>{
  805. console.log('hhtest','状态修改')
  806. this.clickStatus[10] = 1
  807. }, 2000)
  808. console.log('hhtest','执行函数:充电室开门')
  809. let res: object = await MechanicalArmDebuggingRequest.post('/api/v1/device/setup', {
  810. deviceNo: "EC2A-IM24R00",
  811. data: {
  812. output: "g0b20:1"
  813. }
  814. } as EtherCATInfo)
  815. console.log('http:' + res.toString())
  816. this.reminds = '充电室开门'
  817. this.remindController.open()
  818. delayExecution(()=>{
  819. console.log('hhtest','状态修改')
  820. this.remindController.close()
  821. }, 2000)
  822. }
  823. })
  824. Row() {
  825. Column() {
  826. Text('充电室关门')
  827. .fontSize($r('app.float.robot_set_font_size'))
  828. .fontWeight(FontWeight.Medium)
  829. .margin({left: '10%'})
  830. }
  831. .width('70%')
  832. Column() {
  833. Image($r('app.media.close_door'))
  834. .width('55px')
  835. .height('55px')
  836. }
  837. .width('30%')
  838. }
  839. .width('20%')
  840. .height('60%')
  841. .backgroundColor(this.colorArray[11] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  842. .alignItems(VerticalAlign.Center)
  843. .justifyContent(FlexAlign.End)
  844. .borderRadius($r('app.float.process_call_image_radius'))
  845. .margin({right: '2%' })
  846. .onClick(async ()=>{
  847. this.colorArray[11] = 2
  848. delayExecution(()=>{
  849. this.colorArray[11] = 1
  850. }, 100)
  851. if (this.clickStatus[11] == 1) {
  852. this.clickStatus[11] = 2
  853. delayExecution(()=>{
  854. console.log('hhtest','状态修改')
  855. this.clickStatus[11] = 1
  856. }, 2000)
  857. console.log('hhtest','执行函数:充电室关门')
  858. let res: object = await MechanicalArmDebuggingRequest.post('/api/v1/device/setup', {
  859. deviceNo: "EC2A-IM24R00",
  860. data: {
  861. output: "g0b20:0"
  862. }
  863. } as EtherCATInfo)
  864. console.log('http:' + res.toString())
  865. this.reminds = '充电室关门'
  866. this.remindController.open()
  867. delayExecution(()=>{
  868. console.log('hhtest','状态修改')
  869. this.remindController.close()
  870. }, 2000)
  871. }
  872. })
  873. Row() {
  874. Column() {
  875. Text('清除错误')
  876. .fontSize($r('app.float.robot_set_font_size'))
  877. .fontWeight(FontWeight.Medium)
  878. .margin({left: '10%'})
  879. }
  880. .width('70%')
  881. Column() {
  882. Image($r('app.media.robot_clean'))
  883. .width('55px')
  884. .height('55px')
  885. }
  886. .width('30%')
  887. }
  888. .width('20%')
  889. .height('60%')
  890. .backgroundColor(this.colorArray[2] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  891. .alignItems(VerticalAlign.Center)
  892. .justifyContent(FlexAlign.End)
  893. .borderRadius($r('app.float.process_call_image_radius'))
  894. .margin({right: '2%' })
  895. .onClick(async ()=>{
  896. this.colorArray[2] = 2
  897. delayExecution(()=>{
  898. this.colorArray[2] = 1
  899. }, 100)
  900. if (this.clickStatus[2] == 1) {
  901. this.clickStatus[2] = 2
  902. delayExecution(()=>{
  903. console.log('hhtest','状态修改')
  904. this.clickStatus[2] = 1
  905. }, 2000)
  906. console.log('hhtest','执行函数:清除错误')
  907. let res: ErrorMessage = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/clearRgvError', {
  908. rgvNo: this.robots[this.selectRobot].robotCode,
  909. } as RequestParam)
  910. console.log('清除错误:' + res.toString())
  911. this.reminds = '清除错误'
  912. this.remindController.open()
  913. delayExecution(()=>{
  914. console.log('hhtest','状态修改')
  915. this.remindController.close()
  916. }, 2000)
  917. }
  918. })
  919. }
  920. .height('22%')
  921. .width('100%')
  922. }
  923. .backgroundColor($r('app.color.white_f1f3f5'))
  924. .width('100%')
  925. .height('100%')
  926. }
  927. }
  928. @CustomDialog
  929. struct RemindDialog {
  930. controller: CustomDialogController
  931. @Link remind: string
  932. build() {
  933. Column() {
  934. Text(this.remind)
  935. .fontSize(20)
  936. .margin({ top: 10, bottom: 10 })
  937. }
  938. }
  939. }
  940. @CustomDialog
  941. struct RobotSingleMoveDialog {
  942. controller: CustomDialogController
  943. @Link robots: RobotInfo[]
  944. @Link selectRobot: number
  945. @State isInputEnabled: boolean = false;
  946. @State plusXDirection:number = 0
  947. @State plusYDirection:number =0
  948. @State minusXDirection:number =0
  949. @State minusYDirection:number =0
  950. @State moveColorArray: number[] = [1,1,1,1]
  951. build() {
  952. Column() {
  953. Row(){
  954. Text('小车单步移动控制')
  955. .fontWeight(FontWeight.Medium)
  956. .fontSize($r('app.float.fontSize_30'))
  957. .focusable(true)
  958. .defaultFocus(true)
  959. }
  960. .height('20%')
  961. Row() {
  962. Row() {
  963. Text('X轴')
  964. .fontSize($r('app.float.fontSize_30'))
  965. .fontColor($r('app.color.general_font_color'))
  966. .opacity($r('app.float.general_font_opacity'))
  967. .fontWeight(FontWeight.Medium)
  968. }
  969. .borderRadius($r('app.float.general_border_radius'))
  970. .justifyContent(FlexAlign.Center)
  971. .width('15%')
  972. .height('90%')
  973. Divider().vertical(true).color($r('app.color.black_100')).height('80%')
  974. .margin({right: '2%'})
  975. Row() {
  976. Text('正方向移动')
  977. .fontWeight(FontWeight.Medium)
  978. .fontSize($r('app.float.fontSize_24'))
  979. .height('100%')
  980. .textAlign(TextAlign.End)
  981. }.borderRadius($r('app.float.process_call_image_radius'))
  982. .margin({right: '2%',left:'3%' })
  983. .justifyContent(FlexAlign.Center)
  984. .width('20%')
  985. .height('90%')
  986. .backgroundColor(this.moveColorArray[0] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  987. .onClick(async ()=>{
  988. this.moveColorArray[0] = 2
  989. delayExecution(()=>{
  990. this.moveColorArray[0] = 1
  991. }, 100)
  992. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
  993. rgvNo: this.robots[this.selectRobot].robotCode,
  994. direction: 'x+',
  995. len:this.plusXDirection.toString(),
  996. } as RobotSingleMovePost)
  997. console.log('小车X正向移动:' + res.toString())
  998. })
  999. Row() {
  1000. TextInput({ placeholder: '请输入数字', text: this.plusXDirection + '' })
  1001. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1002. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1003. .fontColor($r('app.color.login_text_input_font_color'))
  1004. .fontWeight(FontWeight.Medium)
  1005. .type(InputType.Number)
  1006. .maxLength(6)
  1007. .fontSize($r('app.float.fontSize_24'))
  1008. .width('10%')
  1009. .height('50%')
  1010. .opacity($r('app.float.general_font_opacity'))
  1011. .borderRadius($r('app.float.general_border_radius'))
  1012. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1013. .onChange((value: string) => {
  1014. this.plusXDirection = parseInt(value)
  1015. })
  1016. Text('步')
  1017. .fontWeight(FontWeight.Medium)
  1018. .fontSize($r('app.float.fontSize_18'))
  1019. .height('100%')
  1020. .textAlign(TextAlign.End)
  1021. }
  1022. Row() {
  1023. Text('负方向移动')
  1024. .fontWeight(FontWeight.Medium)
  1025. .fontSize($r('app.float.fontSize_24'))
  1026. .height('100%')
  1027. .textAlign(TextAlign.End)
  1028. }.borderRadius($r('app.float.process_call_image_radius'))
  1029. .margin({right: '2%',left:'3%' })
  1030. .justifyContent(FlexAlign.Center)
  1031. .width('20%')
  1032. .height('90%')
  1033. .backgroundColor(this.moveColorArray[1] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  1034. .onClick(async ()=>{
  1035. this.moveColorArray[1] = 2
  1036. delayExecution(()=>{
  1037. this.moveColorArray[1] = 1
  1038. }, 100)
  1039. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
  1040. rgvNo: this.robots[this.selectRobot].robotCode,
  1041. direction: 'x-',
  1042. len:this.minusXDirection.toString(),
  1043. } as RobotSingleMovePost)
  1044. console.log('小车X负向移动:' + res.toString())
  1045. })
  1046. Row() {
  1047. TextInput({ placeholder: '请输入数字', text: this.minusXDirection + '' })
  1048. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1049. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1050. .fontColor($r('app.color.login_text_input_font_color'))
  1051. .fontWeight(FontWeight.Medium)
  1052. .type(InputType.Number)
  1053. .maxLength(6)
  1054. .fontSize($r('app.float.fontSize_24'))
  1055. .width('10%')
  1056. .height('50%')
  1057. .opacity($r('app.float.general_font_opacity'))
  1058. .borderRadius($r('app.float.general_border_radius'))
  1059. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1060. .onChange((value: string) => {
  1061. this.minusXDirection = parseInt(value)
  1062. })
  1063. Text('步')
  1064. .fontWeight(FontWeight.Medium)
  1065. .fontSize($r('app.float.fontSize_18'))
  1066. .height('100%')
  1067. .textAlign(TextAlign.End)
  1068. }
  1069. }.width('90%')
  1070. .height('30%')
  1071. .justifyContent(FlexAlign.Start)
  1072. Row() {
  1073. Row() {
  1074. Text('Y轴')
  1075. .fontSize($r('app.float.fontSize_30'))
  1076. .fontColor($r('app.color.general_font_color'))
  1077. .opacity($r('app.float.general_font_opacity'))
  1078. .fontWeight(FontWeight.Medium)
  1079. }
  1080. .borderRadius($r('app.float.general_border_radius'))
  1081. .justifyContent(FlexAlign.Center)
  1082. .width('15%')
  1083. .height('90%')
  1084. Divider().vertical(true).color($r('app.color.black_100')).height('80%')
  1085. .margin({right: '2%'})
  1086. Row() {
  1087. Text('正方向移动')
  1088. .fontWeight(FontWeight.Medium)
  1089. .fontSize($r('app.float.fontSize_24'))
  1090. .height('100%')
  1091. .textAlign(TextAlign.End)
  1092. }.borderRadius($r('app.float.process_call_image_radius'))
  1093. .margin({right: '2%',left:'3%' })
  1094. .justifyContent(FlexAlign.Center)
  1095. .width('20%')
  1096. .height('90%')
  1097. .backgroundColor(this.moveColorArray[2] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  1098. .onClick(async ()=>{
  1099. this.moveColorArray[2] = 2
  1100. delayExecution(()=>{
  1101. this.moveColorArray[2] = 1
  1102. }, 100)
  1103. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
  1104. rgvNo: this.robots[this.selectRobot].robotCode,
  1105. direction: 'y+',
  1106. len:this.plusYDirection.toString(),
  1107. } as RobotSingleMovePost)
  1108. console.log('小车Y正向移动:' + res.toString())
  1109. })
  1110. Row() {
  1111. TextInput({ placeholder: '请输入数字', text: this.plusYDirection + '' })
  1112. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1113. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1114. .fontColor($r('app.color.login_text_input_font_color'))
  1115. .fontWeight(FontWeight.Medium)
  1116. .type(InputType.Number)
  1117. .maxLength(6)
  1118. .fontSize($r('app.float.fontSize_24'))
  1119. .width('10%')
  1120. .height('50%')
  1121. .opacity($r('app.float.general_font_opacity'))
  1122. .borderRadius($r('app.float.general_border_radius'))
  1123. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1124. .onChange((value: string) => {
  1125. this.plusYDirection = parseInt(value)
  1126. })
  1127. Text('步')
  1128. .fontWeight(FontWeight.Medium)
  1129. .fontSize($r('app.float.fontSize_18'))
  1130. .height('100%')
  1131. .textAlign(TextAlign.End)
  1132. }
  1133. Row() {
  1134. Text('负方向移动')
  1135. .fontWeight(FontWeight.Medium)
  1136. .fontSize($r('app.float.fontSize_24'))
  1137. .height('100%')
  1138. .textAlign(TextAlign.End)
  1139. }.borderRadius($r('app.float.process_call_image_radius'))
  1140. .margin({right: '2%',left:'3%' })
  1141. .justifyContent(FlexAlign.Center)
  1142. .width('20%')
  1143. .height('90%')
  1144. .backgroundColor(this.moveColorArray[3] == 1 ? $r('app.color.process_divider_white_color') : $r('app.color.process_nameplate_grey_color'))
  1145. .onClick(async ()=>{
  1146. this.moveColorArray[3] = 2
  1147. delayExecution(()=>{
  1148. this.moveColorArray[3] = 1
  1149. }, 100)
  1150. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
  1151. rgvNo: this.robots[this.selectRobot].robotCode,
  1152. direction: 'y-',
  1153. len:this.minusYDirection.toString(),
  1154. } as RobotSingleMovePost)
  1155. console.log('小车Y负向移动:' + res.toString())
  1156. })
  1157. Row() {
  1158. TextInput({ placeholder: '请输入数字', text: this.minusYDirection + '' })
  1159. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1160. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1161. .fontColor($r('app.color.login_text_input_font_color'))
  1162. .fontWeight(FontWeight.Medium)
  1163. .type(InputType.Number)
  1164. .maxLength(6)
  1165. .fontSize($r('app.float.fontSize_24'))
  1166. .width('10%')
  1167. .height('50%')
  1168. .opacity($r('app.float.general_font_opacity'))
  1169. .borderRadius($r('app.float.general_border_radius'))
  1170. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1171. .onChange((value: string) => {
  1172. this.minusYDirection = parseInt(value)
  1173. })
  1174. Text('步')
  1175. .fontWeight(FontWeight.Medium)
  1176. .fontSize($r('app.float.fontSize_18'))
  1177. .height('100%')
  1178. .textAlign(TextAlign.End)
  1179. }
  1180. }.width('90%')
  1181. .height('30%')
  1182. .justifyContent(FlexAlign.Start)
  1183. } .width('50%')
  1184. .height('30%')
  1185. .backgroundColor($r('app.color.page_general_background'))
  1186. .justifyContent(FlexAlign.SpaceEvenly)
  1187. .borderRadius($r('app.float.general_border_radius'))
  1188. }
  1189. }
  1190. //设置车位置弹窗
  1191. @CustomDialog
  1192. struct SetRobotLocationDialog {
  1193. controller: CustomDialogController
  1194. @Link robots: RobotInfo[]
  1195. @Link selectRobot: number
  1196. @State robotX: number = 0
  1197. @State robotY: number = 0
  1198. @State tempSelect: number = 1
  1199. @State robotArray: Array<SelectOption> = []
  1200. aboutToAppear(): void {
  1201. this.tempSelect = this.selectRobot
  1202. if (this.robots && this.robots.length > 0) {
  1203. for (const robot of this.robots ) {
  1204. let option: SelectOption = { value: robot.robotCode ? robot.robotCode : ''}
  1205. this.robotArray.push(option)
  1206. }
  1207. }
  1208. }
  1209. build() {
  1210. Column() {
  1211. Row(){
  1212. Text('设置位置')
  1213. .fontWeight(FontWeight.Medium)
  1214. .fontSize($r('app.float.fontSize_50'))
  1215. }
  1216. .height('20%')
  1217. Row() {
  1218. Text('机器人:')
  1219. .fontWeight(FontWeight.Medium)
  1220. .fontSize($r('app.float.fontSize_18'))
  1221. .width('20%')
  1222. .height('100%')
  1223. .textAlign(TextAlign.End)
  1224. Select(this.robotArray)
  1225. .selected(this.selectRobot)
  1226. .value(this.robots && this.robots[this.selectRobot] && this.robots[this.selectRobot].robotCode ? this.robots[this.selectRobot].robotCode : '')
  1227. .font({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
  1228. .fontColor($r('app.color.black_100'))
  1229. .borderRadius($r('app.float.general_border_radius'))
  1230. .width('60%')
  1231. .height('100%')
  1232. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1233. .selectedOptionFontColor($r('app.color.blue_100'))
  1234. .selectedOptionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Bold})
  1235. .optionFontColor($r('app.color.black_100'))
  1236. .optionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Medium})
  1237. .menuAlign(MenuAlignType.START, {dx:0, dy:0})
  1238. .onSelect((index: number) => {
  1239. console.log('hhtest', index);
  1240. this.tempSelect = index
  1241. })
  1242. }
  1243. .width('80%')
  1244. .height('15%')
  1245. .justifyContent(FlexAlign.Center)
  1246. Row(){
  1247. Text('X轴:')
  1248. .fontWeight(FontWeight.Medium)
  1249. .fontSize($r('app.float.fontSize_18'))
  1250. .width('20%')
  1251. .height('100%')
  1252. .textAlign(TextAlign.End)
  1253. TextInput({ placeholder: '请输入数字', text: this.robotX + ''})
  1254. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1255. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1256. .fontColor($r('app.color.login_text_input_font_color'))
  1257. .fontWeight(FontWeight.Medium)
  1258. .type(InputType.Number)
  1259. .maxLength(6)
  1260. .fontSize($r('app.float.fontSize_24'))
  1261. .width('60%')
  1262. .height('100%')
  1263. .opacity($r('app.float.general_font_opacity'))
  1264. .borderRadius($r('app.float.general_border_radius'))
  1265. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1266. .onChange((value: string) => {
  1267. this.robotX = parseInt(value)
  1268. })
  1269. }
  1270. .width('80%')
  1271. .height('15%')
  1272. .justifyContent(FlexAlign.Center)
  1273. Row(){
  1274. Text('Y轴:')
  1275. .fontWeight(FontWeight.Medium)
  1276. .fontSize($r('app.float.fontSize_18'))
  1277. .width('20%')
  1278. .height('100%')
  1279. .textAlign(TextAlign.End)
  1280. TextInput({ placeholder: '请输入数字', text: this.robotY + ''})
  1281. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1282. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1283. .fontColor($r('app.color.login_text_input_font_color'))
  1284. .fontWeight(FontWeight.Medium)
  1285. .type(InputType.Number)
  1286. .maxLength(6)
  1287. .fontSize($r('app.float.fontSize_24'))
  1288. .width('60%')
  1289. .height('100%')
  1290. .opacity($r('app.float.general_font_opacity'))
  1291. .borderRadius($r('app.float.general_border_radius'))
  1292. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1293. .onChange((value: string) => {
  1294. this.robotY = parseInt(value)
  1295. })
  1296. }
  1297. .width('80%')
  1298. .height('15%')
  1299. .justifyContent(FlexAlign.Center)
  1300. Row() {
  1301. Button('取消')
  1302. .fontSize($r('app.float.robot_set_font_size'))
  1303. .fontWeight(FontWeight.Medium)
  1304. .fontColor($r('app.color.robot_set_card_blue'))
  1305. .width('32%')
  1306. .height('50%')
  1307. .borderRadius($r('app.float.robot_set_radius'))
  1308. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1309. .onClick(() => {
  1310. this.controller?.close()
  1311. })
  1312. Row()
  1313. .width('2.5%')
  1314. Button('确认')
  1315. .fontSize($r('app.float.robot_set_font_size'))
  1316. .fontWeight(FontWeight.Medium)
  1317. .fontColor($r('app.color.general_font_white_color'))
  1318. .width('32%')
  1319. .height('50%')
  1320. .borderRadius($r('app.float.robot_set_radius'))
  1321. .backgroundColor($r('app.color.robot_set_card_blue'))
  1322. .onClick(async() => {
  1323. this.selectRobot = this.tempSelect
  1324. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/newposition', {
  1325. rgvNo: this.robots[this.selectRobot].robotCode,
  1326. x: this.robotX.toString(),
  1327. y: this.robotY.toString()
  1328. } as RequestParam)
  1329. console.log('设置机器人位置:' + res.toString())
  1330. if (this.controller != undefined) {
  1331. this.controller.close()
  1332. }
  1333. })
  1334. }
  1335. .justifyContent(FlexAlign.Center)
  1336. .height('25%')
  1337. .width('100%')
  1338. }
  1339. .width('48%')
  1340. .height('74%')
  1341. .backgroundColor($r('app.color.page_general_background'))
  1342. .justifyContent(FlexAlign.SpaceBetween)
  1343. .borderRadius($r('app.float.general_border_radius'))
  1344. }
  1345. }
  1346. //处理移动错误弹窗
  1347. /*@CustomDialog
  1348. struct HandleMoveErrorDialog {
  1349. controller: CustomDialogController
  1350. @Link robots: RobotInfo[]
  1351. @Link selectRobot: number
  1352. @State robotX: number = 0
  1353. @State robotY: number = 0
  1354. @State tempSelect: number = 1
  1355. @State robotArray: Array<SelectOption> = []
  1356. // 料箱
  1357. @State boxArray: Array<SelectOption> = []
  1358. @State boxCode: string = ''
  1359. @State boxX: string = ''
  1360. @State boxY: string = ''
  1361. async aboutToAppear() {
  1362. this.tempSelect = this.selectRobot
  1363. if (this.robots && this.robots.length > 0) {
  1364. for (const robot of this.robots ) {
  1365. let option: SelectOption = { value: robot.robotCode ? robot.robotCode : ''}
  1366. this.robotArray.push(option)
  1367. }
  1368. }
  1369. let res : Array<BoxInfo> = await RobotErrorHandleRequest.get('/api/v1/wcs/boxs', {})
  1370. if (res && res.length > 0) {
  1371. for (const box of res ) {
  1372. let option: SelectOption = { value: box.no ? box.no : '' }
  1373. this.boxArray.push(option)
  1374. }
  1375. }
  1376. }
  1377. build() {
  1378. Row() {
  1379. Column() {
  1380. Row(){
  1381. Text('查询料箱应在位置')
  1382. .fontWeight(FontWeight.Medium)
  1383. .fontSize($r('app.float.fontSize_50'))
  1384. }
  1385. .height('20%')
  1386. Row() {
  1387. Text('选择料箱:')
  1388. .fontWeight(FontWeight.Medium)
  1389. .fontSize($r('app.float.fontSize_18'))
  1390. .width('30%')
  1391. .height('100%')
  1392. Select(this.boxArray)
  1393. .value(this.boxCode)
  1394. .font({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
  1395. .fontColor($r('app.color.black_100'))
  1396. .borderRadius($r('app.float.general_border_radius'))
  1397. .width('50%')
  1398. .height('100%')
  1399. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1400. .selectedOptionFontColor($r('app.color.blue_100'))
  1401. .selectedOptionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Bold})
  1402. .optionFontColor($r('app.color.black_100'))
  1403. .optionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Medium})
  1404. .menuAlign(MenuAlignType.START, {dx:0, dy:0})
  1405. .onSelect(async (index: number) => {
  1406. this.boxCode = this.boxArray[index].value.toString()
  1407. if (this.boxCode && this.boxCode.length > 0) {
  1408. let res: BoxLocation = await RobotErrorHandleRequest.get('/api/v1/wcs/box/state/' + this.boxCode, {}) as BoxLocation
  1409. if (res && res.pos && res.pos.length > 0 && res.pos.includes('-')) {
  1410. let strArray: string[] = res.pos.split('-')
  1411. if (strArray.length === 2) {
  1412. this.boxX = strArray[0]
  1413. this.boxY = strArray[1]
  1414. }
  1415. }
  1416. }
  1417. })
  1418. }
  1419. .width('80%')
  1420. .height('20%')
  1421. .justifyContent(FlexAlign.Center)
  1422. Row(){
  1423. Text('X轴:')
  1424. .fontWeight(FontWeight.Medium)
  1425. .fontSize($r('app.float.fontSize_18'))
  1426. .width('20%')
  1427. .height('100%')
  1428. Text(this.boxX)
  1429. .fontColor($r('app.color.login_text_input_font_color'))
  1430. .fontWeight(FontWeight.Medium)
  1431. .fontSize($r('app.float.fontSize_24'))
  1432. .width('60%')
  1433. .height('100%')
  1434. .opacity($r('app.float.general_font_opacity'))
  1435. .borderRadius($r('app.float.general_border_radius'))
  1436. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1437. }
  1438. .width('80%')
  1439. .height('20%')
  1440. .justifyContent(FlexAlign.Center)
  1441. Row(){
  1442. Text('Y轴:')
  1443. .fontWeight(FontWeight.Medium)
  1444. .fontSize($r('app.float.fontSize_18'))
  1445. .width('20%')
  1446. .height('100%')
  1447. Text(this.boxY)
  1448. .fontColor($r('app.color.login_text_input_font_color'))
  1449. .fontWeight(FontWeight.Medium)
  1450. .fontSize($r('app.float.fontSize_24'))
  1451. .width('60%')
  1452. .height('100%')
  1453. .opacity($r('app.float.general_font_opacity'))
  1454. .borderRadius($r('app.float.general_border_radius'))
  1455. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1456. }
  1457. .width('80%')
  1458. .height('20%')
  1459. .justifyContent(FlexAlign.Center)
  1460. }
  1461. .height('100%')
  1462. .width('49.5%')
  1463. .justifyContent(FlexAlign.SpaceEvenly)
  1464. Column(){
  1465. Divider().vertical(true).color($r('app.color.black_100'))
  1466. .height('100%')
  1467. }
  1468. .width('1%')
  1469. .height('100%')
  1470. Column() {
  1471. Row(){
  1472. Text('设置位置')
  1473. .fontWeight(FontWeight.Medium)
  1474. .fontSize($r('app.float.fontSize_50'))
  1475. }
  1476. .height('20%')
  1477. Row() {
  1478. Text('机器人:')
  1479. .fontWeight(FontWeight.Medium)
  1480. .fontSize($r('app.float.fontSize_18'))
  1481. .width('20%')
  1482. .height('100%')
  1483. .textAlign(TextAlign.End)
  1484. Select(this.robotArray)
  1485. .selected(this.tempSelect)
  1486. .value(this.robots && this.robots[this.tempSelect] && this.robots[this.tempSelect].robotCode ? this.robots[this.tempSelect].robotCode : '')
  1487. .font({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
  1488. .fontColor($r('app.color.black_100'))
  1489. .borderRadius($r('app.float.general_border_radius'))
  1490. .width('60%')
  1491. .height('100%')
  1492. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1493. .selectedOptionFontColor($r('app.color.blue_100'))
  1494. .selectedOptionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Bold})
  1495. .optionFontColor($r('app.color.black_100'))
  1496. .optionFont({size: $r('app.float.fontSize_16'), weight: FontWeight.Medium})
  1497. .menuAlign(MenuAlignType.START, {dx:0, dy:0})
  1498. .onSelect((index: number) => {
  1499. this.tempSelect = index
  1500. })
  1501. }
  1502. .width('80%')
  1503. .height('15%')
  1504. .justifyContent(FlexAlign.Center)
  1505. Row(){
  1506. Text('X轴:')
  1507. .fontWeight(FontWeight.Medium)
  1508. .fontSize($r('app.float.fontSize_18'))
  1509. .width('20%')
  1510. .height('100%')
  1511. .textAlign(TextAlign.End)
  1512. TextInput({ placeholder: '请输入数字', text: this.robotX + ''})
  1513. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1514. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1515. .fontColor($r('app.color.login_text_input_font_color'))
  1516. .fontWeight(FontWeight.Medium)
  1517. .type(InputType.Number)
  1518. .maxLength(6)
  1519. .fontSize($r('app.float.fontSize_24'))
  1520. .width('60%')
  1521. .height('100%')
  1522. .opacity($r('app.float.general_font_opacity'))
  1523. .borderRadius($r('app.float.general_border_radius'))
  1524. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1525. .onChange((value: string) => {
  1526. this.robotX = parseInt(value)
  1527. })
  1528. }
  1529. .width('80%')
  1530. .height('15%')
  1531. .justifyContent(FlexAlign.Center)
  1532. Row(){
  1533. Text('Y轴:')
  1534. .fontWeight(FontWeight.Medium)
  1535. .fontSize($r('app.float.fontSize_18'))
  1536. .width('20%')
  1537. .height('100%')
  1538. .textAlign(TextAlign.End)
  1539. TextInput({ placeholder: '请输入数字', text: this.robotY + ''})
  1540. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  1541. .placeholderFont({ size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium })
  1542. .fontColor($r('app.color.login_text_input_font_color'))
  1543. .fontWeight(FontWeight.Medium)
  1544. .type(InputType.Number)
  1545. .maxLength(6)
  1546. .fontSize($r('app.float.fontSize_24'))
  1547. .width('60%')
  1548. .height('100%')
  1549. .opacity($r('app.float.general_font_opacity'))
  1550. .borderRadius($r('app.float.general_border_radius'))
  1551. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1552. .onChange((value: string) => {
  1553. this.robotY = parseInt(value)
  1554. })
  1555. }
  1556. .width('80%')
  1557. .height('15%')
  1558. .justifyContent(FlexAlign.Center)
  1559. Row() {
  1560. Button('取消')
  1561. .fontSize($r('app.float.robot_set_font_size'))
  1562. .fontWeight(FontWeight.Medium)
  1563. .fontColor($r('app.color.robot_set_card_blue'))
  1564. .width('32%')
  1565. .height('50%')
  1566. .borderRadius($r('app.float.robot_set_radius'))
  1567. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1568. .onClick(() => {
  1569. this.controller?.close()
  1570. })
  1571. Row()
  1572. .width('2.5%')
  1573. Button('确认')
  1574. .fontSize($r('app.float.robot_set_font_size'))
  1575. .fontWeight(FontWeight.Medium)
  1576. .fontColor($r('app.color.general_font_white_color'))
  1577. .width('32%')
  1578. .height('50%')
  1579. .borderRadius($r('app.float.robot_set_radius'))
  1580. .backgroundColor($r('app.color.robot_set_card_blue'))
  1581. .onClick(async() => {
  1582. this.selectRobot = this.tempSelect
  1583. let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/newposition', {
  1584. rgvNo: this.robots[this.selectRobot].robotCode,
  1585. x: this.robotX.toString(),
  1586. y: this.robotY.toString()
  1587. } as RequestParam)
  1588. console.log('设置机器人位置:' + res.toString())
  1589. res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/clearRgvError', {
  1590. rgvNo: this.robots[this.selectRobot].robotCode,
  1591. } as RequestParam)
  1592. console.log('清除错误:' + res.toString())
  1593. res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/clearRgvError', {
  1594. rgvNo: this.robots[this.selectRobot].robotCode,
  1595. } as RequestParam)
  1596. console.log('清除错误:' + res.toString())
  1597. if (this.controller != undefined) {
  1598. this.controller.close()
  1599. }
  1600. })
  1601. }
  1602. .justifyContent(FlexAlign.Center)
  1603. .height('25%')
  1604. .width('100%')
  1605. }
  1606. .height('100%')
  1607. .width('49.5%')
  1608. .justifyContent(FlexAlign.SpaceBetween)
  1609. }
  1610. .width('80%')
  1611. .height('74%')
  1612. .backgroundColor($r('app.color.page_general_background'))
  1613. .justifyContent(FlexAlign.SpaceBetween)
  1614. .borderRadius($r('app.float.general_border_radius'))
  1615. }
  1616. }*/
  1617. /*function delayExecution(callback: Function, delay: number) {
  1618. setTimeout(() => {
  1619. callback();
  1620. }, delay);
  1621. }*/
  1622. function delayExecution(callback: Function, delay: number) {
  1623. let timerId = setInterval(() => {
  1624. clearInterval(timerId);
  1625. callback();
  1626. }, delay);
  1627. }
  1628. class ErrorMessage{
  1629. code?:string
  1630. message?:string
  1631. data?:string
  1632. }
  1633. class RgvInfo{
  1634. id?:string
  1635. x?:string
  1636. y?:string
  1637. status?:string
  1638. auto?:string
  1639. dx?:string
  1640. dy?:string
  1641. mv?:string
  1642. batlevel?:string
  1643. charging?:string
  1644. errCode?:string
  1645. cmd?:string
  1646. load?:string
  1647. boxNo?:string
  1648. regTime?:string
  1649. traMiles?:string
  1650. chargeCount?:string
  1651. forward?:string
  1652. ts?:string
  1653. }
  1654. class DeviceData {
  1655. output?: string;
  1656. }
  1657. class EtherCATInfo{
  1658. deviceNo?:string
  1659. data?:DeviceData;
  1660. }
  1661. class RobotSingleMovePost{
  1662. rgvNo?:string
  1663. direction?:string;
  1664. len?:string;
  1665. }