| | |
| | | const handleMessage = (data) => { |
| | | // 进炉中 |
| | | if(data.intoGlass!=null){ |
| | | adjustedRects.value = data.intoGlass[0].map(rect => ({ |
| | | adjustedRects.value = data.intoGlass[0].map(rect => { |
| | | let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta; |
| | | if (rect.angle === 90) { |
| | | adjustedWidth = rect.height * 0.3; |
| | | adjustedHeight = rect.width * 0.3; |
| | | adjustedWidtha = rect.height; |
| | | adjustedHeighta = rect.width; |
| | | } else { |
| | | adjustedWidth = rect.width * 0.3; |
| | | adjustedHeight = rect.height * 0.3; |
| | | adjustedWidtha = rect.width; |
| | | adjustedHeighta = rect.height; |
| | | } |
| | | return { |
| | | ...rect, |
| | | xcoordinate: rect.xCoordinate * 0.3, |
| | | ycoordinate: rect.yCoordinate * 0.3, |
| | | width: rect.width * 0.2, |
| | | height: rect.height * 0.2, |
| | | widtha: rect.width, |
| | | heighta: rect.height, |
| | | })); |
| | | } |
| | | width: adjustedWidth, |
| | | height: adjustedHeight, |
| | | widtha: adjustedWidtha, |
| | | heighta: adjustedHeighta, |
| | | }; |
| | | }); |
| | | } |
| | | if(data.intoGlass2!=null){ |
| | | adjustedRects2.value = data.intoGlass2[0].map(rect => ({ |
| | | adjustedRects2.value = data.intoGlass2[0].map(rect => { |
| | | let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta; |
| | | if (rect.angle === 90) { |
| | | adjustedWidth = rect.height * 0.3; |
| | | adjustedHeight = rect.width * 0.3; |
| | | adjustedWidtha = rect.height; |
| | | adjustedHeighta = rect.width; |
| | | } else { |
| | | adjustedWidth = rect.width * 0.3; |
| | | adjustedHeight = rect.height * 0.3; |
| | | adjustedWidtha = rect.width; |
| | | adjustedHeighta = rect.height; |
| | | } |
| | | return { |
| | | ...rect, |
| | | xcoordinate: rect.xCoordinate * 0.3, |
| | | ycoordinate: rect.yCoordinate * 0.3, |
| | | width: rect.width * 0.2, |
| | | height: rect.height * 0.2, |
| | | widtha: rect.width, |
| | | heighta: rect.height, |
| | | })); |
| | | } |
| | | width: adjustedWidth, |
| | | height: adjustedHeight, |
| | | widtha: adjustedWidtha, |
| | | heighta: adjustedHeighta, |
| | | }; |
| | | }); |
| | | } |
| | | // 进炉前 |
| | | if(data.waitingGlass!=null){ |
| | | adjustedRectsa.value = data.waitingGlass[0].map(rect => ({ |
| | | ...rect, // 复制原始对象的其他属性 |
| | | x: rect.xCoordinate * 0.4, |
| | | y: rect.yCoordinate * 0.4, |
| | | width: rect.width * 0.4, |
| | | height: rect.height * 0.4, |
| | | widtha: rect.width, |
| | | heighta: rect.height, |
| | | state: rect.state, |
| | | })); |
| | | } |
| | | adjustedRectsa.value = data.waitingGlass[0].map(rect => { |
| | | let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta; |
| | | if (rect.angle === 90) { |
| | | adjustedWidth = rect.height * 0.4; |
| | | adjustedHeight = rect.width * 0.4; |
| | | adjustedWidtha = rect.height; |
| | | adjustedHeighta = rect.width; |
| | | } else { |
| | | adjustedWidth = rect.width * 0.4; |
| | | adjustedHeight = rect.height * 0.4; |
| | | adjustedWidtha = rect.width; |
| | | adjustedHeighta = rect.height; |
| | | } |
| | | return { |
| | | ...rect, |
| | | x: rect.xCoordinate * 0.4, |
| | | y: rect.yCoordinate * 0.4, |
| | | width: adjustedWidth, |
| | | height: adjustedHeight, |
| | | widtha: adjustedWidtha, |
| | | heighta: adjustedHeighta, |
| | | }; |
| | | }); |
| | | } |
| | | // 已出炉 |
| | | if(data.outGlass!=null){ |
| | | adjustedRectsb.value = data.outGlass[0].map(rect => ({ |
| | | adjustedRectsb.value = data.outGlass[0].map(rect => { |
| | | let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta; |
| | | if (rect.angle === 90) { |
| | | adjustedWidth = rect.height * 0.4; |
| | | adjustedHeight = rect.width * 0.4; |
| | | adjustedWidtha = rect.height; |
| | | adjustedHeighta = rect.width; |
| | | } else { |
| | | adjustedWidth = rect.width * 0.4; |
| | | adjustedHeight = rect.height * 0.4; |
| | | adjustedWidtha = rect.width; |
| | | adjustedHeighta = rect.height; |
| | | } |
| | | return { |
| | | ...rect, // 复制原始对象的其他属性 |
| | | x: rect.xCoordinate * 0.4, |
| | | y: rect.yCoordinate * 0.4, |
| | | width: rect.width * 0.4, |
| | | height: rect.height * 0.4, |
| | | widtha: rect.width, |
| | | heighta: rect.height, |
| | | state: rect.state |
| | | })); |
| | | console.log(data.outGlass[0]); |
| | | } |
| | | width: adjustedWidth, |
| | | height: adjustedHeight, |
| | | widtha: adjustedWidtha, |
| | | heighta: adjustedHeighta, |
| | | }; |
| | | }); |
| | | } |
| | | }; |
| | | onMounted(() => { |
| | | initializeWebSocket(socketUrl, handleMessage); |