2025-07-09 16:36:26 +08:00
|
|
|
|
|
2025-07-14 16:04:08 +08:00
|
|
|
|
import { ProcessorModule, StepControllerProcessor, Processor } from "../../src/device";
|
|
|
|
|
import { RectOptimizeMachineModule } from "../moduleManager/module_RectOptimizeMachine";
|
|
|
|
|
import { ToolsModule } from "../moduleManager/module_tools";
|
|
|
|
|
import { CheckMaterial } from "../moduleManager/module_checkMaterial";
|
|
|
|
|
import { CheckBlocks } from "../moduleManager/module_checkBlocks";
|
|
|
|
|
import { ResetModelContour } from "../moduleManager/module_resetModelContour";
|
2025-07-22 18:38:25 +08:00
|
|
|
|
import { AutoCalcCutOrder } from "../moduleManager/module_autoCalcCutOrder";
|
|
|
|
|
import { HandleMaterialPlaceResult } from "../moduleManager/module_handleMaterialPlaceResult";
|
|
|
|
|
import { handlePlaceResultToPlaceMaterial } from "../moduleManager/module_handlePlaceResultToPlaceMaterial";
|
|
|
|
|
// import { Init2VModel } from "../moduleManager/module_init2VModel";
|
2025-07-09 16:36:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* demo 开料机处理器
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
export class demoHandleGroupCutting {
|
|
|
|
|
processorName = "cutting"
|
|
|
|
|
processor: StepControllerProcessor<any, any>
|
|
|
|
|
constructor() {
|
2025-07-22 18:38:25 +08:00
|
|
|
|
// 主线程
|
2025-07-14 16:04:08 +08:00
|
|
|
|
const demoCallbackModule: ProcessorModule<any, any> = {
|
2025-07-09 16:36:26 +08:00
|
|
|
|
moduleName: "callbackStyle",
|
|
|
|
|
process(input, next, context) {
|
|
|
|
|
|
|
|
|
|
console.log("做优化");
|
|
|
|
|
const _input = input
|
2025-07-14 16:04:08 +08:00
|
|
|
|
const _next = next
|
2025-07-09 16:36:26 +08:00
|
|
|
|
const _context = context
|
|
|
|
|
// 可以在这里调用异步操作
|
2025-07-14 16:04:08 +08:00
|
|
|
|
|
2025-07-09 16:36:26 +08:00
|
|
|
|
Reflect.set(context, 'CallBack', callBack1)
|
|
|
|
|
// 决定是否调用 next
|
2025-07-14 16:04:08 +08:00
|
|
|
|
this.onMessage('测试传消息给处理器');
|
|
|
|
|
|
2025-07-09 16:36:26 +08:00
|
|
|
|
function callBack1(v) {
|
2025-07-14 16:04:08 +08:00
|
|
|
|
console.log('接收到其它模块回传的数据');
|
2025-07-09 16:36:26 +08:00
|
|
|
|
}
|
2025-07-14 16:04:08 +08:00
|
|
|
|
|
2025-07-09 16:36:26 +08:00
|
|
|
|
// 调用 next 继续流程
|
|
|
|
|
return next(input);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.processor = new StepControllerProcessor<any, any>();
|
2025-07-14 16:04:08 +08:00
|
|
|
|
this.processor.setOnMessageFunc(this.getMessageByModules)
|
2025-07-22 18:38:25 +08:00
|
|
|
|
|
2025-07-09 16:36:26 +08:00
|
|
|
|
this.processor.use([
|
2025-07-22 18:38:25 +08:00
|
|
|
|
// demoCallbackModule,
|
2025-07-14 16:04:08 +08:00
|
|
|
|
ToolsModule, // 刀库
|
2025-07-22 18:38:25 +08:00
|
|
|
|
// CheckMaterial,
|
|
|
|
|
// CheckBlocks,
|
|
|
|
|
// ResetModelContour,
|
|
|
|
|
// Init2VModel,
|
2025-07-14 16:04:08 +08:00
|
|
|
|
RectOptimizeMachineModule, // 优化
|
2025-07-22 18:38:25 +08:00
|
|
|
|
// {
|
|
|
|
|
// moduleName: "final",
|
|
|
|
|
// process(input, next,context) {
|
|
|
|
|
// // 不调用 next,终止流程
|
|
|
|
|
// console.log('结束了')
|
|
|
|
|
// return next(input);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2025-07-09 16:36:26 +08:00
|
|
|
|
])
|
2025-07-14 16:04:08 +08:00
|
|
|
|
|
|
|
|
|
|
2025-07-09 16:36:26 +08:00
|
|
|
|
}
|
2025-07-22 18:38:25 +08:00
|
|
|
|
// 获取到模块的消息
|
|
|
|
|
async getMessageByModules(data) {
|
2025-07-14 16:04:08 +08:00
|
|
|
|
console.log('getMessageByModules', data);
|
2025-07-22 18:38:25 +08:00
|
|
|
|
this.processor = new StepControllerProcessor<any, any>();
|
|
|
|
|
switch (data.moduleName) {
|
|
|
|
|
// 处理优化模块的消息
|
|
|
|
|
case 'RectOptimizeMachine':
|
|
|
|
|
|
|
|
|
|
// 处理优化数据
|
|
|
|
|
this.processor.use([HandleMaterialPlaceResult,
|
|
|
|
|
handlePlaceResultToPlaceMaterial,
|
|
|
|
|
AutoCalcCutOrder])
|
|
|
|
|
this.processor.setOnMessageFunc(this.getMessageByModules)
|
|
|
|
|
let bList = []
|
|
|
|
|
data.pm.blockList.forEach(b => {
|
|
|
|
|
bList[b.blockNo] = b
|
|
|
|
|
});
|
|
|
|
|
let params = {
|
|
|
|
|
bList: bList,
|
|
|
|
|
best:data.result[0],
|
|
|
|
|
yl:data.result[1],
|
|
|
|
|
pm:data.pm,
|
|
|
|
|
width:data.pm.width,
|
|
|
|
|
length:data.pm.length
|
|
|
|
|
}
|
|
|
|
|
let context = {
|
|
|
|
|
MaterialPlaceSource:params
|
|
|
|
|
}
|
|
|
|
|
let res = await this.processor.process(data.input,context)
|
|
|
|
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
// this.processor.use(handlePlaceResultToPlaceMaterial)
|
|
|
|
|
// let params1 = res
|
|
|
|
|
// let res1 = await this.processor.process(res)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-07-14 16:04:08 +08:00
|
|
|
|
}
|
2025-07-22 18:38:25 +08:00
|
|
|
|
|
2025-07-09 16:36:26 +08:00
|
|
|
|
}
|