import { Application, exportScene, system } from '../../src' import { defaultConfig, defaultToolCoordinates, defaultUserCoordinatesWithLift } from './DefaultPalletizingConfig' import { PalletizingSimulateSystem } from './PalletizingSimulateSystem' import vcControl from './vcControl' import exClient from './exchangeClient' const el: any = document.getElementById('app') const app = new Application(el) app.start() const system = new PalletizingSimulateSystem() app.addSystem(system) const { EventManager } = app setTimeout(async () => { EventManager.publish('palletizing:simulate:init', { params: defaultConfig, userCoordinates: defaultUserCoordinatesWithLift, toolCoordinates: defaultToolCoordinates, initialJoint: [28.9, -37.41, -47.57, -5.02, 90, 118] }) // setTimeout(() => { // console.log('download') // exportScene(app.scene, 'abc') // }, 10000) const res: any = await vcControl.requestResource() vcControl.setResource(res.resource, res.deviceId) exClient.connect( () => {}, () => {}, () => {} ) exClient.subscribe('exchange', (data: any, interval: number) => { vcControl.setPose(data.cartesianCoordinate, data.jointCoordinate) EventManager.publish('palletizing:simulate:status', { data, interval }) }) exClient.subscribe('simulate', (type: string, data: any) => { if (type == 'realtime') { EventManager.publish('palletizing:simulate:process', data) } else if (type == 'robotAction') { EventManager.publish('palletizing:simulate:robotAction', data) } else if (type == 'partitionAction') { EventManager.publish('palletizing:simulate:partitionAction', data) } else if (type == 'liftAction') { EventManager.publish('palletizing:simulate:liftAction', data) } else if (type == 'clearPallets') { EventManager.publish('palletizing:simulate:clearBoxes', data) } }) await vcControl.clearAlarms() await vcControl.setDebuggerStop() await vcControl.setAuto('auto') await vcControl.setSpeedRatio(100) await vcControl.setDebuggerStart('palletStation_simulation') }, 2000)