feat:处理器初步实现---有接上了新优化,回显需要再看下

This commit is contained in:
2025-07-09 16:36:26 +08:00
parent 92b49c7035
commit 595675a08a
42 changed files with 70546 additions and 1993 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
import type { Big_bang, xbang } from './bang'
import { RectOptimizeMachine } from './RectOptimizeMachine'
import {Worker} from "worker_threads"
const ctx: Worker = self as any
ctx.addListener('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()
}
})
// 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()
// }
// })
export default {} as typeof Worker & (new () => Worker)

View File

@@ -0,0 +1,115 @@
export type Con = YH_bang[];//单块1220*2440的板结果 Container
export type Inv = Con[]; //个体:优化结果 包含多个大板 Individual
/**纹路类型 Positive=0正纹 Reverse=1反纹 CanReversal=2可翻转 */
export enum LineType
{
/**正纹 */
Positive = 0,
/**反纹 */
Reverse = 1,
/**可翻转 */
CanReversal = 2,
}
/**优化的大板 */
export interface YH_bang
{
/**板ID */
bangid: number;
/**纹路 */
line: LineType;
x: number;
y: number;
/**排版高 */
pbg: number;
/**排版宽 */
pbk: number;
ishb?: boolean;//是否参与合并的板
hb?: number[]; //合在并的板
isgr?: boolean; //是否关连
gr?: number[];//关联的板的集合
grid?: number; //跟别的板关联的ID
isbig?: boolean;//是否为合并的大板
isqg?: boolean;//是否被切掉的板
}
/**版面类型: Positive=0正面 Reverse=1反面 Arbitrary=2任意面 */
export enum ComposingType
{
/**正面 */
Positive = 0,
/**反面 */
Reverse = 1,
/**任意面 */
Arbitrary = 2
}
/**孔类型 None=0无 Positive=1正面 Reverse=2反面 Two=3正反 */
export enum HoleType
{
/**无 */
None = 0,
/**正面 */
Positive = 1,
/**反面 */
Reverse = 2,
/**正反 */
Two = 3
}
/** 小板 */
export interface xbang
{
/**长 */
l: number;
/**宽 */
w: number;
/**纹路 */
line: LineType;
/**排版面 */
face: ComposingType;
/**小板ID */
id: number;
/**小板编号 */
bno: string;
/**孔面: 0无孔 1正面有孔 2反面有孔 3正反面都有孔 */
holeFaceCount: HoleType;
/**是矩形 */
isRect?: boolean;
/**有孔 */
hasHole?: boolean;
/**false单面 true双面 */
isdtwosided?: boolean;
}
/** 大板 */
export interface Big_bang //待优化的板
{
l: number; //长
w: number; //宽
x: number; //x
y: number; //y
}
export enum BlockRegion
{
/** 左下 = 0 */
LEFT_BOTTOM = 0,
/** 右下 = 1 */
RIGHT_BOTTOM = 1,
/** 右上 = 2 */
RIGHT_TOP = 2,
/** 左上 = 3 */
LEFT_TOP = 3,
}
export class WorkerItemType {
w?: Worker
goodsId?: string | number
pm?: any
status?: 'start' | 'stop'
}

View File

@@ -0,0 +1 @@
# 新优化