feat: 提交
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import type { Big_bang, xbang } from './bang'
|
||||
import { RectOptimizeMachine } from './RectOptimizeMachine'
|
||||
// import {Worker} from "worker_threads"
|
||||
import { Worker as NodeWorker } from 'worker_threads';
|
||||
const ctx: NodeWorker | Worker = self as any
|
||||
debugger
|
||||
if (typeof window !== 'undefined' && 'Worker' in window) {
|
||||
ctx.addEventListener('message', async (event) => {
|
||||
let m = new RectOptimizeMachine()
|
||||
m.CallBack = async (best, fit, arg, info) => {
|
||||
|
||||
ctx.postMessage([best, fit, arg, info])
|
||||
}
|
||||
if (event.data.type == 'start') {
|
||||
/**
|
||||
* blockList 小板列表
|
||||
* boardList 大板(N个元素,前N-1个元素表示余料板且余料板须为矩形,第N个元素表示大板)
|
||||
* boardCount 余料板数量(bigBang中前N-1个元素对应的数量,如果bigBang中只有一个元素即只有大板没有余料板,则为空数组)
|
||||
* optimizeTimes 新优化次数
|
||||
* isDoubleFaceBlockFirst 双面加工的小板是否优先排入
|
||||
* gap 排版缝隙 = 开料刀直径 + 缝隙
|
||||
* gzpb 规则排版
|
||||
* isDoubleFaceBlockInRemain 余料板是否排入双面加工的小板
|
||||
*/
|
||||
let [blockList, boardList, boardCount, optimizeTimes, isDoubleFaceBlockFirst, gap, gzpb, isDoubleFaceBlockInRemain] = (event.data.data) as [xbang[], Big_bang[], number[], number, boolean, number, boolean, boolean]
|
||||
|
||||
m.Start(blockList, boardList, boardCount, optimizeTimes, isDoubleFaceBlockFirst, gap, gzpb, isDoubleFaceBlockInRemain)
|
||||
} else {
|
||||
const info = {
|
||||
type: 'isStop',
|
||||
}
|
||||
await m.Stop(info)
|
||||
ctx.postMessage([[], null, null, info])
|
||||
ctx?.terminate()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default {} as typeof Worker & (new () => Worker)
|
Reference in New Issue
Block a user