| | |
| | | map: [], |
| | | currentLev: 1, |
| | | mapFps: 0, |
| | | ws: null, |
| | | wsReconnectTimer: null, |
| | | wsReconnectAttempts: 0, |
| | | wsReconnectBaseDelay: 1000, |
| | | wsReconnectMaxDelay: 15000, |
| | | pixiApp: null, |
| | | pixiStageList: [], |
| | | pixiStaMap: new Map(), |
| | | pixiCrnMap: new Map(), |
| | | pixiDualCrnMap: new Map(), |
| | | pixiRgvMap: new Map(), |
| | | pixiShelfMap: new Map(), |
| | | pixiTrackMap: new Map(), |
| | |
| | | pixiCrnColorTextureMap: new Map(), |
| | | pixiRgvColorTextureMap: new Map(), |
| | | crnList: [], |
| | | dualCrnList: [], |
| | | rgvList: [], |
| | | objectsContainer: null, |
| | | objectsContainer2: null, |
| | |
| | | isSwitchingFloor: false |
| | | } |
| | | }, |
| | | mounted() { |
| | | mounted() { |
| | | this.currentLev = this.lev || 1; |
| | | this.createMap(); |
| | | this.getMap(this.currentLev); |
| | | this.connectWs(); |
| | | |
| | | setTimeout(() => { |
| | | this.getMap(this.currentLev); |
| | | }, 1000); |
| | | |
| | | this.timer = setInterval(() => { |
| | | this.getCrnInfo(); |
| | | this.getDualCrnInfo(); |
| | | this.getSiteInfo(); |
| | | this.getRgvInfo(); |
| | | }, 1000); |
| | |
| | | if (this.timer) { clearInterval(this.timer); } |
| | | if (this.pixiApp) { this.pixiApp.destroy(true, { children: true }); } |
| | | window.removeEventListener('resize', this.resizeToContainer); |
| | | if (this.wsReconnectTimer) { clearTimeout(this.wsReconnectTimer); this.wsReconnectTimer = null; } |
| | | if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) { try { this.ws.close(); } catch (e) {} } |
| | | }, |
| | | watch: { |
| | | lev(newLev) { |
| | |
| | | |
| | | //*******************FPS******************* |
| | | let g_Time = 0; |
| | | let fpsLastUpdateTs = 0; |
| | | let fpsDeltaSumMs = 0; |
| | | let fpsFrameCount = 0; |
| | | const fpsUpdateInterval = 200; |
| | | this.pixiApp.ticker.add((delta) => { |
| | | const timeNow = (new Date()).getTime(); |
| | | const timeDiff = timeNow - g_Time; |
| | | g_Time = timeNow; |
| | | const fps = 1000 / timeDiff; |
| | | this.mapFps = parseInt(fps); |
| | | fpsDeltaSumMs += timeDiff; |
| | | fpsFrameCount += 1; |
| | | if (timeNow - fpsLastUpdateTs >= fpsUpdateInterval) { |
| | | const avgFps = fpsDeltaSumMs > 0 ? (fpsFrameCount * 1000 / fpsDeltaSumMs) : 0; |
| | | this.mapFps = Math.round(avgFps); |
| | | fpsDeltaSumMs = 0; |
| | | fpsFrameCount = 0; |
| | | fpsLastUpdateTs = timeNow; |
| | | } |
| | | }); |
| | | //*******************FPS******************* |
| | | }, |
| | |
| | | } |
| | | }, |
| | | getMap() { |
| | | $.ajax({ |
| | | url: baseUrl + "/basMap/lev/" + this.currentLev + "/auth", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'get', |
| | | success: (res) => { |
| | | const data = res.data; |
| | | const mapData = JSON.parse(data); |
| | | this.createMapData(mapData); |
| | | } |
| | | }) |
| | | this.sendWs(JSON.stringify({ url: "/basMap/lev/" + this.currentLev + "/auth", data: {} })); |
| | | }, |
| | | changeFloor(lev) { |
| | | this.currentLev = lev; |
| | |
| | | if (this.tracksContainer) { this.tracksContainer.removeChildren(); } |
| | | if (this.shelvesContainer) { this.shelvesContainer.removeChildren(); } |
| | | this.crnList = []; |
| | | this.dualCrnList = []; |
| | | this.rgvList = []; |
| | | this.pixiCrnMap = new Map(); |
| | | this.pixiDualCrnMap = new Map(); |
| | | this.pixiRgvMap = new Map(); |
| | | this.pixiStaMap = new Map(); |
| | | this.pixiStageList = []; |
| | | this.getMap(); |
| | | }, |
| | | createMapData(map) { |
| | | this.pixiStageList = [map.length]; |
| | | this.pixiStaMap = new Map(); |
| | | if (window.gsap) { |
| | | this.pixiStaMap && this.pixiStaMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | this.pixiCrnMap && this.pixiCrnMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | this.pixiDualCrnMap && this.pixiDualCrnMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | this.pixiRgvMap && this.pixiRgvMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | } |
| | | this.objectsContainer.removeChildren(); |
| | | this.objectsContainer2.removeChildren(); |
| | | if (this.tracksContainer) { this.tracksContainer.removeChildren(); } |
| | | if (this.shelvesContainer) { this.shelvesContainer.removeChildren(); } |
| | | this.crnList = []; |
| | | this.dualCrnList = []; |
| | | this.rgvList = []; |
| | | this.pixiCrnMap = new Map(); |
| | | this.pixiDualCrnMap = new Map(); |
| | | this.pixiRgvMap = new Map(); |
| | | this.pixiStaMap = new Map(); |
| | | this.pixiStageList = []; |
| | | this.pixiStageList = [map.length]; |
| | | const bayHeightList = this.initHeight(map); |
| | | const bayWidthList = this.initWidth(map); |
| | | map.forEach((item, index) => { |
| | |
| | | this.objectsContainer2.addChild(sprite); |
| | | }); |
| | | |
| | | this.dualCrnList.forEach((item) => { |
| | | if (this.graphicsCrn == null) { this.graphicsCrn = this.createCrnTexture(item.width * 0.9, item.height * 0.9); } |
| | | let sprite = new PIXI.Sprite(this.graphicsCrn); |
| | | const deviceNo = this.getDeviceNo(item.value); |
| | | const taskNo = this.getTaskNo(item.value); |
| | | const style = new PIXI.TextStyle({ fontFamily: 'Arial', fontSize: 12, fill: '#000000', stroke: '#ffffff', strokeThickness: 1 }); |
| | | const txt = taskNo > 0 ? (deviceNo + "(" + taskNo + ")") : String(deviceNo); |
| | | const text = new PIXI.Text(txt, style); |
| | | text.anchor.set(0.5); |
| | | text.position.set(sprite.width / 2, sprite.height / 2); |
| | | sprite.addChild(text); |
| | | sprite.textObj = text; |
| | | sprite.position.set(item.posX, item.posY); |
| | | sprite.interactive = true; |
| | | sprite.buttonMode = true; |
| | | sprite.on('pointerdown', () => { |
| | | if (window.gsap) { window.gsap.killTweensOf(sprite); } |
| | | sprite.alpha = 1; |
| | | const id = parseInt(deviceNo, 10); |
| | | this.$emit('dual-crn-click', id); |
| | | }); |
| | | let rowIndexForCrn = 0; |
| | | for (let r = 0; r < map.length; r++) { |
| | | if (map[r].length > 0) { |
| | | const rowY = map[r][0].posY; |
| | | if (Math.abs(rowY - item.posY) < 0.5) { rowIndexForCrn = r; break; } |
| | | } |
| | | } |
| | | sprite.rowIndex = rowIndexForCrn; |
| | | this.pixiDualCrnMap.set(parseInt(deviceNo), sprite); |
| | | this.objectsContainer2.addChild(sprite); |
| | | }); |
| | | |
| | | this.rgvList.forEach((item) => { |
| | | if (this.graphicsRgv == null) { this.graphicsRgv = this.createRgvTexture(item.width * 0.9, item.height * 0.9); } |
| | | let sprite = new PIXI.Sprite(this.graphicsRgv); |
| | |
| | | this.updateColor(sta, 0x30bffc); |
| | | } else if (status === "machine-pakout") { |
| | | this.updateColor(sta, 0x97b400); |
| | | } else if (status === "site-run-block") { |
| | | this.updateColor(sta, 0xe69138); |
| | | } else { |
| | | this.updateColor(sta, 0xb8b8b8); |
| | | } |
| | |
| | | }, |
| | | getCrnInfo() { |
| | | if (this.isSwitchingFloor) { return; } |
| | | $.ajax({ |
| | | url: baseUrl + "/console/latest/data/crn", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'POST', |
| | | success: (res) => { |
| | | if (res.code === 200) { |
| | | var crns = res.data; |
| | | for (var i = 0; i < crns.length; i++) { |
| | | const id = parseInt(crns[i].crnId); |
| | | const sprite = this.pixiCrnMap.get(id); |
| | | if (!sprite) { continue; } |
| | | const taskNo = crns[i].taskNo; |
| | | if (taskNo != null && taskNo > 0) { sprite.textObj.text = id + "(" + taskNo + ")"; } else { sprite.textObj.text = String(id); } |
| | | const status = crns[i].crnStatus; |
| | | const statusColor = this.getCrnStatusColor(status); |
| | | this.updateCrnTextureColor(sprite, statusColor); |
| | | let bay = parseInt(crns[i].bay, 10); |
| | | if (isNaN(bay) || bay < 1 || bay === -2) { bay = 1; } |
| | | let rowIndex = (sprite.rowIndex != null) ? sprite.rowIndex : -1; |
| | | if (rowIndex === -1) { |
| | | for (let r = 0; r < this.map.length; r++) { |
| | | if (this.map[r].length > 0) { |
| | | const rowY = this.map[r][0].posY; |
| | | if (Math.abs(rowY - sprite.y) < 0.5) { rowIndex = r; break; } |
| | | } |
| | | } |
| | | if (rowIndex === -1) { rowIndex = 0; } |
| | | } |
| | | let targetCell = null; |
| | | let crnCount = 0; |
| | | for (let c = 0; c < this.map[rowIndex].length; c++) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && cell.type === 'crn') { crnCount++; if (crnCount === bay) { targetCell = cell; break; } } |
| | | } |
| | | if (!targetCell) { |
| | | for (let c = this.map[rowIndex].length - 1; c >= 0; c--) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && cell.type === 'crn') { targetCell = cell; break; } |
| | | } |
| | | } |
| | | if (!targetCell) { continue; } |
| | | const targetX = targetCell.posX + (targetCell.width - sprite.width) / 2; |
| | | const dx = Math.abs(targetX - sprite.x); |
| | | if (dx < 1) { |
| | | } else if (dx < 5) { |
| | | sprite.x = targetX; |
| | | } else if (window.gsap) { |
| | | window.gsap.killTweensOf(sprite); |
| | | window.gsap.to(sprite, { x: targetX, duration: 0.3, ease: "power1.inOut" }); |
| | | } else { |
| | | sprite.x = targetX; |
| | | } |
| | | } |
| | | } |
| | | this.scheduleAdjustLabels(); |
| | | } |
| | | }); |
| | | this.sendWs(JSON.stringify({ url: "/console/latest/data/crn", data: {} })); |
| | | }, |
| | | getDualCrnInfo() { |
| | | if (this.isSwitchingFloor) { return; } |
| | | this.sendWs(JSON.stringify({ url: "/console/latest/data/dualcrn", data: {} })); |
| | | }, |
| | | getSiteInfo() { |
| | | if (this.isSwitchingFloor) { return; } |
| | | $.ajax({ |
| | | url: baseUrl + "/console/latest/data/station", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'POST', |
| | | success: (res) => { this.setSiteInfo(res); } |
| | | }); |
| | | this.sendWs(JSON.stringify({ url: "/console/latest/data/station", data: {} })); |
| | | }, |
| | | getRgvInfo() { |
| | | if (this.isSwitchingFloor) { return; } |
| | | $.ajax({ |
| | | url: baseUrl + "/console/latest/data/rgv", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | method: 'POST', |
| | | success: (res) => { |
| | | if (res.code === 200) { |
| | | const rgvs = res.data; |
| | | for (let i = 0; i < rgvs.length; i++) { |
| | | const id = parseInt(rgvs[i].rgvNo, 10); |
| | | const sprite = this.pixiRgvMap.get(id); |
| | | if (!sprite) { continue; } |
| | | const taskNo = rgvs[i].taskNo; |
| | | if (sprite.textObj) { if (taskNo != null && taskNo > 0) { sprite.textObj.text = id + "(" + taskNo + ")"; } else { sprite.textObj.text = String(id); } } |
| | | const statusColor = this.getRgvStatusColor(rgvs[i].rgvStatus); |
| | | this.updateRgvTextureColor(sprite, statusColor); |
| | | let trackSiteNo = parseInt(rgvs[i].trackSiteNo, 10); |
| | | if (!trackSiteNo || trackSiteNo <= 0) { continue; } |
| | | let rowIndex = (sprite.rowIndex != null) ? sprite.rowIndex : 0; |
| | | let targetCell = null; |
| | | for (let c = 0; c < this.map[rowIndex].length; c++) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (!cell || cell.type !== 'rgv') { continue; } |
| | | const ts = this.getTrackSiteNo(cell.value); |
| | | if (ts === trackSiteNo) { targetCell = cell; break; } |
| | | } |
| | | if (!targetCell) { |
| | | for (let c = this.map[rowIndex].length - 1; c >= 0; c--) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && cell.type === 'rgv') { targetCell = cell; break; } |
| | | } |
| | | } |
| | | if (!targetCell) { continue; } |
| | | const targetX = targetCell.posX + (targetCell.width - sprite.width) / 2; |
| | | const dx = Math.abs(targetX - sprite.x); |
| | | if (dx < 1) { |
| | | } else if (dx < 5) { |
| | | sprite.x = targetX; |
| | | } else if (window.gsap) { |
| | | window.gsap.killTweensOf(sprite); |
| | | window.gsap.to(sprite, { x: targetX, duration: 0.3, ease: "power1.inOut" }); |
| | | } else { |
| | | sprite.x = targetX; |
| | | } |
| | | this.sendWs(JSON.stringify({ url: "/console/latest/data/rgv", data: {} })); |
| | | }, |
| | | setCrnInfo(res) { |
| | | let crns = Array.isArray(res) ? res : (res && res.code === 200 ? res.data : null); |
| | | if (!crns) { return; } |
| | | for (var i = 0; i < crns.length; i++) { |
| | | const id = parseInt(crns[i].crnId); |
| | | const sprite = this.pixiCrnMap.get(id); |
| | | if (!sprite) { continue; } |
| | | const taskNo = crns[i].taskNo; |
| | | if (taskNo != null && taskNo > 0) { sprite.textObj.text = id + "(" + taskNo + ")"; } else { sprite.textObj.text = String(id); } |
| | | const status = crns[i].crnStatus; |
| | | const statusColor = this.getCrnStatusColor(status); |
| | | this.updateCrnTextureColor(sprite, statusColor); |
| | | let bay = parseInt(crns[i].bay, 10); |
| | | if (isNaN(bay) || bay < 1 || bay === -2) { bay = 1; } |
| | | let rowIndex = (sprite.rowIndex != null) ? sprite.rowIndex : -1; |
| | | if (rowIndex === -1) { |
| | | for (let r = 0; r < this.map.length; r++) { |
| | | if (this.map[r].length > 0) { |
| | | const rowY = this.map[r][0].posY; |
| | | if (Math.abs(rowY - sprite.y) < 0.5) { rowIndex = r; break; } |
| | | } |
| | | } |
| | | this.scheduleAdjustLabels(); |
| | | if (rowIndex === -1) { rowIndex = 0; } |
| | | } |
| | | }); |
| | | let targetCell = null; |
| | | let crnCount = 0; |
| | | for (let c = 0; c < this.map[rowIndex].length; c++) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && cell.type === 'crn') { crnCount++; if (crnCount === bay) { targetCell = cell; break; } } |
| | | } |
| | | if (!targetCell) { |
| | | for (let c = this.map[rowIndex].length - 1; c >= 0; c--) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && cell.type === 'crn') { targetCell = cell; break; } |
| | | } |
| | | } |
| | | if (!targetCell) { continue; } |
| | | const targetX = targetCell.posX + (targetCell.width - sprite.width) / 2; |
| | | const dx = Math.abs(targetX - sprite.x); |
| | | if (dx < 1) { |
| | | } else if (dx < 5) { |
| | | sprite.x = targetX; |
| | | } else if (window.gsap) { |
| | | window.gsap.killTweensOf(sprite); |
| | | window.gsap.to(sprite, { x: targetX, duration: 0.3, ease: "power1.inOut" }); |
| | | } else { |
| | | sprite.x = targetX; |
| | | } |
| | | } |
| | | this.scheduleAdjustLabels(); |
| | | }, |
| | | setDualCrnInfo(res) { |
| | | let crns = Array.isArray(res) ? res : (res && res.code === 200 ? res.data : null); |
| | | if (!crns) { return; } |
| | | for (var i = 0; i < crns.length; i++) { |
| | | const id = parseInt(crns[i].crnId); |
| | | const sprite = this.pixiDualCrnMap.get(id); |
| | | if (!sprite) { continue; } |
| | | const taskNo = crns[i].taskNo; |
| | | if (taskNo != null && taskNo > 0) { sprite.textObj.text = id + "(" + taskNo + ")"; } else { sprite.textObj.text = String(id); } |
| | | const status = crns[i].crnStatus; |
| | | const statusColor = this.getCrnStatusColor(status); |
| | | this.updateCrnTextureColor(sprite, statusColor); |
| | | let bay = parseInt(crns[i].bay, 10); |
| | | if (isNaN(bay) || bay < 1 || bay === -2) { bay = 1; } |
| | | let rowIndex = (sprite.rowIndex != null) ? sprite.rowIndex : -1; |
| | | if (rowIndex === -1) { |
| | | for (let r = 0; r < this.map.length; r++) { |
| | | if (this.map[r].length > 0) { |
| | | const rowY = this.map[r][0].posY; |
| | | if (Math.abs(rowY - sprite.y) < 0.5) { rowIndex = r; break; } |
| | | } |
| | | } |
| | | if (rowIndex === -1) { rowIndex = 0; } |
| | | } |
| | | let targetCell = null; |
| | | let crnCount = 0; |
| | | for (let c = 0; c < this.map[rowIndex].length; c++) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && (cell.type === 'dualCrn' || cell.type === 'dualcrn')) { |
| | | crnCount++; |
| | | if (crnCount === bay) { targetCell = cell; break; } |
| | | } |
| | | } |
| | | if (!targetCell) { |
| | | for (let c = this.map[rowIndex].length - 1; c >= 0; c--) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && (cell.type === 'dualCrn' || cell.type === 'dualcrn')) { targetCell = cell; break; } |
| | | } |
| | | } |
| | | if (!targetCell) { continue; } |
| | | const targetX = targetCell.posX + (targetCell.width - sprite.width) / 2; |
| | | const dx = Math.abs(targetX - sprite.x); |
| | | if (dx < 1) { |
| | | } else if (dx < 5) { |
| | | sprite.x = targetX; |
| | | } else if (window.gsap) { |
| | | window.gsap.killTweensOf(sprite); |
| | | window.gsap.to(sprite, { x: targetX, duration: 0.3, ease: "power1.inOut" }); |
| | | } else { |
| | | sprite.x = targetX; |
| | | } |
| | | } |
| | | this.scheduleAdjustLabels(); |
| | | }, |
| | | setRgvInfo(res) { |
| | | let rgvs = Array.isArray(res) ? res : (res && res.code === 200 ? res.data : null); |
| | | if (!rgvs) { return; } |
| | | for (let i = 0; i < rgvs.length; i++) { |
| | | const id = parseInt(rgvs[i].rgvNo, 10); |
| | | const sprite = this.pixiRgvMap.get(id); |
| | | if (!sprite) { continue; } |
| | | const taskNo = rgvs[i].taskNo; |
| | | if (sprite.textObj) { if (taskNo != null && taskNo > 0) { sprite.textObj.text = id + "(" + taskNo + ")"; } else { sprite.textObj.text = String(id); } } |
| | | const statusColor = this.getRgvStatusColor(rgvs[i].rgvStatus); |
| | | this.updateRgvTextureColor(sprite, statusColor); |
| | | let trackSiteNo = parseInt(rgvs[i].trackSiteNo, 10); |
| | | if (!trackSiteNo || trackSiteNo <= 0) { continue; } |
| | | let rowIndex = (sprite.rowIndex != null) ? sprite.rowIndex : 0; |
| | | let targetCell = null; |
| | | for (let c = 0; c < this.map[rowIndex].length; c++) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (!cell || cell.type !== 'rgv') { continue; } |
| | | const ts = this.getTrackSiteNo(cell.value); |
| | | if (ts === trackSiteNo) { targetCell = cell; break; } |
| | | } |
| | | if (!targetCell) { |
| | | for (let c = this.map[rowIndex].length - 1; c >= 0; c--) { |
| | | const cell = this.map[rowIndex][c]; |
| | | if (cell && cell.type === 'rgv') { targetCell = cell; break; } |
| | | } |
| | | } |
| | | if (!targetCell) { continue; } |
| | | const targetX = targetCell.posX + (targetCell.width - sprite.width) / 2; |
| | | const dx = Math.abs(targetX - sprite.x); |
| | | if (dx < 1) { |
| | | } else if (dx < 5) { |
| | | sprite.x = targetX; |
| | | } else if (window.gsap) { |
| | | window.gsap.killTweensOf(sprite); |
| | | window.gsap.to(sprite, { x: targetX, duration: 0.3, ease: "power1.inOut" }); |
| | | } else { |
| | | sprite.x = targetX; |
| | | } |
| | | } |
| | | this.scheduleAdjustLabels(); |
| | | }, |
| | | setMap(res) { |
| | | this.createMapData(JSON.parse(res.data)); |
| | | }, |
| | | webSocketOnOpen(e) { |
| | | if (this.wsReconnectTimer) { clearTimeout(this.wsReconnectTimer); this.wsReconnectTimer = null; } |
| | | this.wsReconnectAttempts = 0; |
| | | this.getMap(this.currentLev); |
| | | }, |
| | | webSocketOnError(e) { |
| | | this.scheduleReconnect(); |
| | | }, |
| | | webSocketOnMessage(e) { |
| | | const result = JSON.parse(e.data); |
| | | if (result.url === "/console/latest/data/station" || result.url === "/console/latest/data/site") { |
| | | this.setSiteInfo(JSON.parse(result.data)); |
| | | } else if (result.url === "/console/latest/data/crn") { |
| | | this.setCrnInfo(JSON.parse(result.data)); |
| | | } else if (result.url === "/console/latest/data/dualcrn") { |
| | | this.setDualCrnInfo(JSON.parse(result.data)); |
| | | } else if (result.url === "/console/latest/data/rgv") { |
| | | this.setRgvInfo(JSON.parse(result.data)); |
| | | } else if (typeof result.url === "string" && result.url.indexOf("/basMap/lev/") === 0) { |
| | | this.setMap(JSON.parse(result.data)); |
| | | } |
| | | }, |
| | | webSocketClose(e) { |
| | | this.scheduleReconnect(); |
| | | }, |
| | | sendWs(message) { |
| | | if (this.ws && this.ws.readyState === WebSocket.OPEN) { |
| | | this.ws.send(message); |
| | | } |
| | | }, |
| | | connectWs() { |
| | | if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) { return; } |
| | | this.ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket"); |
| | | this.ws.onopen = this.webSocketOnOpen; |
| | | this.ws.onerror = this.webSocketOnError; |
| | | this.ws.onmessage = this.webSocketOnMessage; |
| | | this.ws.onclose = this.webSocketClose; |
| | | }, |
| | | scheduleReconnect() { |
| | | if (this.wsReconnectTimer) { return; } |
| | | const attempt = this.wsReconnectAttempts + 1; |
| | | const jitter = Math.floor(Math.random() * 300); |
| | | const delay = Math.min(this.wsReconnectMaxDelay, this.wsReconnectBaseDelay * Math.pow(2, this.wsReconnectAttempts)) + jitter; |
| | | this.wsReconnectTimer = setTimeout(() => { |
| | | this.wsReconnectTimer = null; |
| | | this.wsReconnectAttempts = attempt; |
| | | this.connectWs(); |
| | | }, delay); |
| | | }, |
| | | createShelfSprite(width, height) { |
| | | let idx = width + "-" + height; |
| | |
| | | sprite = this.createTrackSprite(item.width, item.height); |
| | | sprite._kind = 'crn-track'; |
| | | if (this.getDeviceNo(value) > 0) { this.crnList.push(item); } |
| | | } else if (item.type == 'dualCrn') { |
| | | sprite = this.createTrackSprite(item.width, item.height); |
| | | sprite._kind = 'crn-track'; |
| | | if (this.getDeviceNo(value) > 0) { this.dualCrnList.push(item); } |
| | | } else if (item.type == 'rgv') { |
| | | sprite = this.createTrackSprite(item.width, item.height); |
| | | sprite._kind = 'rgv-track'; |
| | |
| | | const on = sx >= -margin && sy >= -margin && sx <= vw + margin && sy <= vh + margin; |
| | | textObj.visible = (s >= 0.25) && on; |
| | | }); |
| | | this.pixiDualCrnMap && this.pixiDualCrnMap.forEach((sprite) => { |
| | | const textObj = sprite && sprite.textObj; |
| | | if (!textObj) { return; } |
| | | const base = (textObj.style && textObj.style.fontSize) ? textObj.style.fontSize : 12; |
| | | let scale = minPx / (base * s); |
| | | if (!isFinite(scale)) { scale = 1; } |
| | | scale = Math.max(0.8, Math.min(scale, 3)); |
| | | textObj.scale.set(scale); |
| | | textObj.position.set(sprite.width / 2, sprite.height / 2); |
| | | const sx = pos.x + sprite.x * s; |
| | | const sy = pos.y + sprite.y * s; |
| | | const on = sx >= -margin && sy >= -margin && sx <= vw + margin && sy <= vh + margin; |
| | | textObj.visible = (s >= 0.25) && on; |
| | | }); |
| | | this.pixiRgvMap && this.pixiRgvMap.forEach((sprite) => { |
| | | const textObj = sprite && sprite.textObj; |
| | | if (!textObj) { return; } |