You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
6.2 KiB

  1. <script lang="ts" setup>
  2. import { getContainerList } from '@/apis/container'
  3. import { getSelfStatus } from '@/apis/self'
  4. import { useHomeStore } from 'stores/homeStore'
  5. import { onMounted, ref, watch } from 'vue'
  6. interface SelfStatus {
  7. name: string
  8. isOrign: boolean
  9. value: string
  10. type: string
  11. }
  12. const props = defineProps({
  13. checking: Boolean,
  14. })
  15. const emits = defineEmits(['update:checking'])
  16. const homeStore = useHomeStore()
  17. const visible = ref(props.checking)
  18. const chemicalList = ref<Container.ContainerItem[]>([])
  19. watch(() => props.checking, (newVal) => {
  20. visible.value = newVal
  21. })
  22. onMounted(() => {
  23. querySelfStatus()
  24. queryContainerList()
  25. })
  26. const statusMap: Record<string, Record<string, string>> = {
  27. gantryXOrigin: {
  28. name: '机械臂x轴',
  29. value: 'x',
  30. type: 'axis',
  31. },
  32. gantryYOrigin: {
  33. name: '机械臂y轴',
  34. value: 'y',
  35. type: 'axis',
  36. },
  37. gantryZOrigin: {
  38. name: '机械臂z轴',
  39. value: 'y',
  40. type: 'axis',
  41. },
  42. dualRobotJoint1Origin: {
  43. name: '机械臂01',
  44. value: 'largeArm',
  45. type: 'liquid',
  46. },
  47. dualRobotJoint2Origin: {
  48. name: '机械臂02',
  49. value: 'smallArm',
  50. type: 'liquid',
  51. },
  52. capLiftingOrigin: {
  53. name: '拍子电机升降',
  54. value: '',
  55. type: 'cap',
  56. },
  57. trayLifting01Origin: {
  58. name: '加热区01托盘升降',
  59. value: 'heat_module_01',
  60. type: 'heat',
  61. },
  62. trayLifting02Origin: {
  63. name: '加热区02托盘升降',
  64. value: 'heat_module_01',
  65. type: 'heat',
  66. },
  67. trayLifting03Origin: {
  68. name: '加热区03托盘升降',
  69. value: 'heat_module_01',
  70. type: 'heat',
  71. },
  72. trayLifting04Origin: {
  73. name: '加热区04托盘升降',
  74. value: 'heat_module_04',
  75. type: 'heat',
  76. },
  77. trayLifting05Origin: {
  78. name: '加热区05托盘升降',
  79. value: 'heat_module_05',
  80. type: 'heat',
  81. },
  82. trayLifting06Origin: {
  83. name: '加热区06托盘升降',
  84. value: 'heat_module_06',
  85. type: 'heat',
  86. },
  87. }
  88. const deviceStatusList = ref<SelfStatus[]>([])
  89. const querySelfStatus = () => {
  90. getSelfStatus().then((res) => {
  91. if (res) {
  92. const list: SelfStatus[] = []
  93. Object.keys(res).forEach((item) => {
  94. list.push({
  95. name: statusMap[item].name,
  96. isOrign: res[item],
  97. value: statusMap[item].value,
  98. type: statusMap[item].type,
  99. })
  100. })
  101. deviceStatusList.value = list
  102. }
  103. })
  104. }
  105. // const pumpId = ref()
  106. const queryContainerList = () => {
  107. getContainerList().then((res) => {
  108. if (res) {
  109. const list: Container.ContainerItem[] = res
  110. const solutionList: Container.ContainerItem[] = []
  111. list.forEach((item, index) => {
  112. // 只有8种,不会多也不会少, 多的不要
  113. if (index < 8) {
  114. solutionList.push({
  115. ...item,
  116. solutionName: `加液泵_0${index + 1}`,
  117. })
  118. }
  119. })
  120. chemicalList.value = solutionList
  121. }
  122. })
  123. }
  124. const resetOrign = (item: SelfStatus) => {
  125. if (item.value === 'x' || item.value === 'y' || item.value === 'z') {
  126. gantry_origin(item.value)
  127. }
  128. else if (item.type === 'liquied') {
  129. dual_robot_joint_origin(item.value)
  130. }
  131. else if (item.type === 'heat') {
  132. tray_lifting_origin(item.value)
  133. }
  134. else if (item.type === 'cap') {
  135. cap_lifting_origin()
  136. }
  137. }
  138. // 先注释 TODO
  139. // const currentPumpId = ref()
  140. // const onPumpChange = (value: string) => {
  141. // currentPumpId.value = value
  142. // }
  143. // const onPumpEmpty = () => {
  144. // console.log('===currentPumpId===', currentPumpId.value)
  145. // }
  146. let currentCommandId = ''
  147. const gantry_origin = async (motor: 'x' | 'y' | 'z') => {
  148. currentCommandId = Date.now().toString()
  149. const params = {
  150. commandId: currentCommandId,
  151. command: 'gantry_origin',
  152. params: {
  153. [motor]: true,
  154. },
  155. }
  156. await homeStore.sendControl(params)
  157. }
  158. const dual_robot_joint_origin = async (arm: string) => {
  159. currentCommandId = Date.now().toString()
  160. const params = {
  161. commandId: currentCommandId,
  162. command: 'dual_robot_joint_origin',
  163. params: {
  164. target: [arm],
  165. },
  166. }
  167. await homeStore.sendControl(params)
  168. }
  169. const cap_lifting_origin = async () => {
  170. currentCommandId = Date.now().toString()
  171. const params = {
  172. commandId: currentCommandId,
  173. command: 'cap_lifting_origin',
  174. params: {},
  175. }
  176. await homeStore.sendControl(params)
  177. }
  178. const tray_lifting_origin = async (heatId: string) => {
  179. currentCommandId = Date.now().toString()
  180. const params = {
  181. commandId: currentCommandId,
  182. command: 'tray_lifting_origin',
  183. params: {
  184. heatId,
  185. },
  186. }
  187. await homeStore.sendControl(params)
  188. }
  189. const cancel = () => {
  190. emits('update:checking', false)
  191. visible.value = false
  192. }
  193. </script>
  194. <template>
  195. <FtDialog v-model="visible" title="设备初始化" width="50%">
  196. <div class="check-main">
  197. <div class="check-status">
  198. <h3>名称</h3>
  199. <h3>是否在原点</h3>
  200. <h3 style="text-align: center;">
  201. 操作
  202. </h3>
  203. </div>
  204. <div v-for="(item) in deviceStatusList" :key="item.name" class="check-status">
  205. <div>
  206. {{ item.name }}
  207. </div>
  208. <div style="margin-left: 2rem;">
  209. <el-icon v-if="!item.isOrign" style="color:red;font-size: 25px;">
  210. <CloseBold />
  211. </el-icon>
  212. <el-icon v-else style="color:#25be25;font-size: 25px;">
  213. <Select />
  214. </el-icon>
  215. </div>
  216. <div style="text-align: center;">
  217. <el-link type="primary" @click="resetOrign(item)">
  218. 回原点
  219. </el-link>
  220. </div>
  221. </div>
  222. <!-- <div class="check-status">
  223. <div>
  224. 加液泵
  225. <el-select v-model="pumpId" size="small" style="width:10rem" @change="onPumpChange">
  226. <el-option v-for="item in chemicalList" :key="item.solutionId" :label="item.solutionName" :value="item.pumpId" />
  227. </el-select>
  228. </div>
  229. <div></div>
  230. <div style="text-align: center;">
  231. <el-link type="primary" @click="onPumpEmpty()">
  232. 排空
  233. </el-link>
  234. </div>
  235. </div> -->
  236. </div>
  237. <template #footer>
  238. <FtButton @click="cancel">
  239. 取消
  240. </FtButton>
  241. </template>
  242. </FtDialog>
  243. </template>
  244. <style scoped>
  245. .check-main{
  246. height: 60vh;
  247. }
  248. .check-status{
  249. display: grid;
  250. grid-template-columns: 2fr 1fr 1fr;
  251. margin-top: 5px;
  252. }
  253. </style>