feat:提交
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
module.exports = {
|
||||
transform: {
|
||||
'^.+\\.(t|j)sx?$': '@swc/jest',
|
||||
},
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
extensionsToTreatAsEsm: ['.ts', '.tsx']
|
||||
};
|
26
package.json
26
package.json
@@ -11,32 +11,40 @@
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"release": "pnpm pack --pack-destination ./dist-packs",
|
||||
"clean": "rimraf ./dist",
|
||||
"test": "jest"
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run",
|
||||
"test:browser": "vitest --browser"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b",
|
||||
"devDependencies": {
|
||||
"@jest/globals": "^30.0.2",
|
||||
"@peculiar/webcrypto": "^1.5.0",
|
||||
"@swc/core": "^1.12.4",
|
||||
"@swc/jest": "^0.2.38",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@vitest/browser": "^3.2.4",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"@vitest/ui": "^3.2.4",
|
||||
"cadapi": "http://gitea.cf/MES-FE/webcad-api/archive/0.0.60.tar.gz",
|
||||
"jest": "^30.0.2",
|
||||
"jest-worker": "^30.0.2",
|
||||
"happy-dom": "^18.0.1",
|
||||
"js-angusj-clipper": "^1.0.4",
|
||||
"playwright": "^1.54.1",
|
||||
"rimraf": "^6.0.1",
|
||||
"ts-jest": "^29.4.0",
|
||||
"typescript": "^5.8.3"
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^1.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"jest-worker": "^30.0.2",
|
||||
"@babel/preset-typescript": "^7.27.1",
|
||||
"@types/node": "^22.16.3",
|
||||
"comlink": "^4.4.2",
|
||||
"import-meta-resolve": "^4.1.0",
|
||||
"three": "^0.178.0",
|
||||
"vite": "^5.0.0",
|
||||
"webworker": "^0.8.4"
|
||||
}
|
||||
}
|
2863
pnpm-lock.yaml
generated
2863
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
45
samples/WorkerHelper.ts
Normal file
45
samples/WorkerHelper.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import path from 'path';
|
||||
import { Worker as NodeWorker } from 'worker_threads';
|
||||
|
||||
export class UniversalWorker {
|
||||
private worker: NodeWorker | Worker;
|
||||
|
||||
constructor(workerPath: string | URL) {
|
||||
if (typeof window !== 'undefined' && 'Worker' in window) {
|
||||
// 浏览器环境
|
||||
this.worker = new Worker(workerPath);
|
||||
} else {
|
||||
// Node.js 环境
|
||||
// const resolvedPath = require.resolve(workerPath);
|
||||
this.worker = new NodeWorker(workerPath, { eval: false });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
postMessage(message: any): void {
|
||||
this.worker.postMessage(message);
|
||||
}
|
||||
|
||||
onMessage(callback: (data: any) => void): void {
|
||||
if ('onmessage' in this.worker) {
|
||||
this.worker.onmessage = (event) => callback(event.data);
|
||||
} else {
|
||||
this.worker.on('message', callback);
|
||||
}
|
||||
}
|
||||
|
||||
onError(callback: (err: Error) => void): void {
|
||||
if ('onerror' in this.worker) {
|
||||
this.worker.onerror = (event) => callback(new Error(event.message));
|
||||
} else {
|
||||
this.worker.on('error', callback);
|
||||
}
|
||||
}
|
||||
|
||||
terminate(): void {
|
||||
this.worker.terminate();
|
||||
}
|
||||
getWorker(){
|
||||
return this.worker
|
||||
}
|
||||
}
|
@@ -1478,6 +1478,7 @@ export class BlockModel {
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('handle hasContour error',error)
|
||||
val = false
|
||||
}
|
||||
|
||||
return val // this.originModeling?.outline.map(e=>e?.pts).length >0 //this.originModeling?.outline?.pts?.length > 0
|
||||
|
@@ -1,6 +1,11 @@
|
||||
|
||||
import { ProcessorModule, StepControllerProcessor } from "../../src/device";
|
||||
import { RectOptimizeMachineModule } from "../moduleManager/module1";
|
||||
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";
|
||||
import { Init2VModel } from "../moduleManager/module_init2VModel";
|
||||
/**
|
||||
* demo 开料机处理器
|
||||
*
|
||||
@@ -10,8 +15,7 @@ export class demoHandleGroupCutting {
|
||||
processorName = "cutting"
|
||||
processor: StepControllerProcessor<any, any>
|
||||
constructor() {
|
||||
|
||||
const callbackStyleModule: ProcessorModule<any, any> = {
|
||||
const demoCallbackModule: ProcessorModule<any, any> = {
|
||||
moduleName: "callbackStyle",
|
||||
process(input, next, context) {
|
||||
|
||||
@@ -23,43 +27,28 @@ export class demoHandleGroupCutting {
|
||||
|
||||
Reflect.set(context, 'CallBack', callBack1)
|
||||
// 决定是否调用 next
|
||||
this.onMessage('测试传消息给处理器');
|
||||
|
||||
function callBack1(v) {
|
||||
console.log('接收到其它模块回传的数据', v);
|
||||
console.log('接收到其它模块回传的数据');
|
||||
}
|
||||
|
||||
// 调用 next 继续流程
|
||||
return next(input);
|
||||
}
|
||||
};
|
||||
const demoModule: ProcessorModule<string, string> = {
|
||||
moduleName: "demoModule",
|
||||
|
||||
process(input, next, context) {
|
||||
// 写入上下文
|
||||
context.processedAt = new Date().toLocaleString();
|
||||
context.originalLength = input.length;
|
||||
// 设置下一步需要的上下文
|
||||
context.previousStep = "demoModule";
|
||||
if (context.CallBack) {
|
||||
context.CallBack("demoModule end and callback")
|
||||
}
|
||||
return next(input);
|
||||
}
|
||||
};
|
||||
|
||||
this.processor = new StepControllerProcessor<any, any>();
|
||||
this.processor.setOnMessageFunc(this.getMessageByModules)
|
||||
this.processor.use([
|
||||
{
|
||||
moduleName: "traditional",
|
||||
handle(input, next) {
|
||||
// 第一个流程
|
||||
console.log(`第一个模块功能:有${input?.blockList.length}片小板,可以做些计算`)
|
||||
return next ? next(input) : input;
|
||||
}
|
||||
},
|
||||
callbackStyleModule,
|
||||
demoModule,
|
||||
RectOptimizeMachineModule,
|
||||
demoCallbackModule,
|
||||
ToolsModule, // 刀库
|
||||
CheckMaterial,
|
||||
CheckBlocks,
|
||||
ResetModelContour,
|
||||
Init2VModel,
|
||||
RectOptimizeMachineModule, // 优化
|
||||
{
|
||||
moduleName: "final",
|
||||
process(input, next) {
|
||||
@@ -70,6 +59,10 @@ export class demoHandleGroupCutting {
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
}
|
||||
|
||||
getMessageByModules(data) {
|
||||
console.log('getMessageByModules', data);
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
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) => {
|
||||
// import {Worker} from "worker_threads"
|
||||
import { Worker as NodeWorker } from 'worker_threads';
|
||||
const ctx: NodeWorker | Worker = self as any
|
||||
if (typeof window !== 'undefined' && 'Worker' in window) {
|
||||
ctx.addEventListener('message', async (event) => {
|
||||
let m = new RectOptimizeMachine()
|
||||
m.CallBack = async (best, fit, arg, info) => {
|
||||
|
||||
@@ -32,35 +32,10 @@ ctx.addListener('message', async (event) => {
|
||||
ctx.postMessage([[], null, null, info])
|
||||
ctx?.terminate()
|
||||
}
|
||||
})
|
||||
// ctx.addEventListener('message', async (event) => {
|
||||
// let m = new RectOptimizeMachine()
|
||||
// m.CallBack = async (best, fit, arg, info) => {
|
||||
})
|
||||
} else {
|
||||
|
||||
// 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)
|
||||
|
@@ -86,7 +86,7 @@ export interface xbang
|
||||
}
|
||||
|
||||
/** 大板 */
|
||||
export interface Big_bang //待优化的板
|
||||
export class Big_bang //待优化的板
|
||||
{
|
||||
l: number; //长
|
||||
w: number; //宽
|
||||
|
365
samples/handleAbility/common/ArrayExt.js
Normal file
365
samples/handleAbility/common/ArrayExt.js
Normal file
@@ -0,0 +1,365 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.arrayRemoveDuplicateBySort = exports.GroupItem = exports.ArrayExt = exports.List = void 0;
|
||||
var List = /** @class */ (function (_super) {
|
||||
__extends(List, _super);
|
||||
function List() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/** 返回符合条件的第一个元素 */
|
||||
List.prototype.first = function (fn) {
|
||||
if (this.length == 0)
|
||||
return null;
|
||||
for (var _i = 0, _a = this; _i < _a.length; _i++) {
|
||||
var item = _a[_i];
|
||||
if (fn(item))
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/** 返回符合条件的最后一元素 */
|
||||
List.prototype.last = function (fn) {
|
||||
if (this.length == 0)
|
||||
return null;
|
||||
for (var i = this.length - 1; i >= 0; i--) {
|
||||
if (fn(this[i]))
|
||||
return this[i];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/** 最大值 */
|
||||
List.prototype.max = function (fn) {
|
||||
var maxV;
|
||||
for (var _i = 0, _a = this; _i < _a.length; _i++) {
|
||||
var i = _a[_i];
|
||||
var v = fn(i);
|
||||
if (maxV == null) {
|
||||
maxV = fn(i);
|
||||
}
|
||||
else {
|
||||
if (v > maxV) {
|
||||
maxV = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return maxV;
|
||||
};
|
||||
/** 最小值 */
|
||||
List.prototype.min = function (fn) {
|
||||
var minV;
|
||||
for (var _i = 0, _a = this; _i < _a.length; _i++) {
|
||||
var i = _a[_i];
|
||||
var v = fn(i);
|
||||
if (minV == null) {
|
||||
minV = fn(i);
|
||||
}
|
||||
else {
|
||||
if (v < minV) {
|
||||
minV = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return minV;
|
||||
};
|
||||
/** 累加 */
|
||||
List.prototype.sum = function (fn) {
|
||||
var v = 0;
|
||||
for (var _i = 0, _a = this; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
v = v + fn(t);
|
||||
}
|
||||
return v;
|
||||
};
|
||||
/** 平均值 */
|
||||
List.prototype.avg = function (fn) {
|
||||
if (this.length == 0)
|
||||
return 0;
|
||||
var sum = this.sum(fn);
|
||||
return sum / this.length;
|
||||
};
|
||||
/** 满足条件的元素数量 */
|
||||
List.prototype.count = function (fn) {
|
||||
if (this.length == 0)
|
||||
return 0;
|
||||
var c = 0;
|
||||
for (var _i = 0, _a = this; _i < _a.length; _i++) {
|
||||
var item = _a[_i];
|
||||
if (fn(item))
|
||||
c = c + 1;
|
||||
}
|
||||
return c;
|
||||
};
|
||||
List.prototype.FindMax = function (fn) {
|
||||
return this.reduce(function (a, b) { return fn(a) > fn(b) ? a : b; });
|
||||
};
|
||||
return List;
|
||||
}(Array));
|
||||
exports.List = List;
|
||||
var ArrayExt = /** @class */ (function () {
|
||||
function ArrayExt() {
|
||||
}
|
||||
/** 返回满足条件的元素数量 */
|
||||
ArrayExt.count = function (list, fn) {
|
||||
if (list.length == 0)
|
||||
return 0;
|
||||
var c = 0;
|
||||
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
|
||||
var item = list_1[_i];
|
||||
if (fn(item))
|
||||
c = c + 1;
|
||||
}
|
||||
return c;
|
||||
};
|
||||
/** 移除 */
|
||||
ArrayExt.remove = function (list, obj) {
|
||||
var index = list.findIndex(function (t) { return t == obj; });
|
||||
if (index == -1)
|
||||
return;
|
||||
list.splice(index, 1);
|
||||
};
|
||||
/** 返回符合条件的第一个元素 */
|
||||
ArrayExt.first = function (list, fn, orderFn1, orderFn2) {
|
||||
if (orderFn1 === void 0) { orderFn1 = null; }
|
||||
if (orderFn2 === void 0) { orderFn2 = null; }
|
||||
if (list.length == 0)
|
||||
return null;
|
||||
if (orderFn1 == null) {
|
||||
for (var _i = 0, list_2 = list; _i < list_2.length; _i++) {
|
||||
var item = list_2[_i];
|
||||
if (fn(item))
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var minValue1;
|
||||
var minValue2;
|
||||
var minItem;
|
||||
for (var _a = 0, list_3 = list; _a < list_3.length; _a++) {
|
||||
var item = list_3[_a];
|
||||
if (fn(item) == false)
|
||||
continue;
|
||||
var v1 = orderFn1(item);
|
||||
var v2 = orderFn2 != null ? orderFn2(item) : 0;
|
||||
if (minValue1 == null || v1 < minValue1 || (v1 == minValue1 && v2 < minValue2)) {
|
||||
minValue1 = v1;
|
||||
minValue2 = v2;
|
||||
minItem = item;
|
||||
}
|
||||
}
|
||||
return minItem;
|
||||
};
|
||||
/** 返回符合条件的最后一元素 */
|
||||
ArrayExt.last = function (list, fn, orderFn1, orderFn2) {
|
||||
if (orderFn1 === void 0) { orderFn1 = null; }
|
||||
if (orderFn2 === void 0) { orderFn2 = null; }
|
||||
if (list.length == 0)
|
||||
return null;
|
||||
if (orderFn1 == null) {
|
||||
for (var i = list.length - 1; i >= 0; i--) {
|
||||
if (fn(list[i]))
|
||||
return list[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//
|
||||
var maxValue1;
|
||||
var maxValue2;
|
||||
var maxItem;
|
||||
for (var _i = 0, list_4 = list; _i < list_4.length; _i++) {
|
||||
var item = list_4[_i];
|
||||
if (fn(item) == false)
|
||||
continue;
|
||||
var v1 = orderFn1(item);
|
||||
var v2 = orderFn2 ? orderFn2(item) : 0;
|
||||
if (maxValue1 == null || v1 > maxValue1 || (v1 == maxValue1 && v2 > maxValue2)) {
|
||||
maxValue1 = v1;
|
||||
maxValue2 = v2;
|
||||
maxItem = item;
|
||||
}
|
||||
}
|
||||
return maxItem;
|
||||
};
|
||||
/** 取最大值 */
|
||||
ArrayExt.max = function (list, fn, whereF, defaultV) {
|
||||
if (whereF === void 0) { whereF = null; }
|
||||
if (defaultV === void 0) { defaultV = null; }
|
||||
var maxV;
|
||||
for (var _i = 0, list_5 = list; _i < list_5.length; _i++) {
|
||||
var i = list_5[_i];
|
||||
if (whereF && whereF(i) == false)
|
||||
continue;
|
||||
var v = fn(i);
|
||||
if (maxV == undefined) {
|
||||
maxV = fn(i);
|
||||
}
|
||||
else {
|
||||
if (v > maxV) {
|
||||
maxV = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxV != undefined)
|
||||
return maxV;
|
||||
return defaultV;
|
||||
};
|
||||
/** 最小值 */
|
||||
ArrayExt.min = function (list, fn, whereF, defaultV) {
|
||||
if (whereF === void 0) { whereF = null; }
|
||||
if (defaultV === void 0) { defaultV = null; }
|
||||
var minV;
|
||||
for (var _i = 0, list_6 = list; _i < list_6.length; _i++) {
|
||||
var i = list_6[_i];
|
||||
if (whereF && whereF(i) == false)
|
||||
continue;
|
||||
var v = fn(i);
|
||||
if (minV == undefined) {
|
||||
minV = v;
|
||||
}
|
||||
else {
|
||||
if (v < minV) {
|
||||
minV = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (minV != undefined)
|
||||
return minV;
|
||||
return defaultV;
|
||||
};
|
||||
/** 累加 */
|
||||
ArrayExt.sum = function (list, fn, wn) {
|
||||
var v = 0;
|
||||
for (var _i = 0, list_7 = list; _i < list_7.length; _i++) {
|
||||
var t = list_7[_i];
|
||||
if (wn && wn(t) == false)
|
||||
continue;
|
||||
v = v + fn(t);
|
||||
}
|
||||
return v;
|
||||
};
|
||||
/** 平均值 */
|
||||
ArrayExt.avg = function (list, fn) {
|
||||
if (this.length == 0)
|
||||
return 0;
|
||||
var sum = ArrayExt.sum(list, fn);
|
||||
return sum / this.length;
|
||||
};
|
||||
/** 排序 */
|
||||
ArrayExt.sortBy = function (list, fn, fn2) {
|
||||
if (fn2 === void 0) { fn2 = null; }
|
||||
if (fn2 == null)
|
||||
return list.sort(function (a, b) { return fn(a) - fn(b); });
|
||||
else
|
||||
return list.sort(function (a, b) { return fn(a) == fn(b) ? (fn2(a) - fn2(b)) : fn(a) - fn(b); });
|
||||
};
|
||||
/** 降序 排序 */
|
||||
ArrayExt.sortByDescending = function (list, fn) {
|
||||
list.sort(function (a, b) { return fn(b) - fn(a); });
|
||||
};
|
||||
/** 排序成新的数组 */
|
||||
ArrayExt.orderBy = function (list, fn, fn2) {
|
||||
if (fn2 === void 0) { fn2 = null; }
|
||||
var newList = list.concat([]);
|
||||
if (fn2 == null)
|
||||
return newList.sort(function (a, b) { return fn(a) - fn(b); });
|
||||
else
|
||||
return newList.sort(function (a, b) { return fn(a) == fn(b) ? (fn2(a) - fn2(b)) : fn(a) - fn(b); });
|
||||
};
|
||||
/** 降序成新的数组 */
|
||||
ArrayExt.orderByDescending = function (list, fn, fn2) {
|
||||
if (fn2 === void 0) { fn2 = null; }
|
||||
var newList = list.concat([]);
|
||||
if (fn2 == null)
|
||||
return list.sort(function (a, b) { return fn(b) - fn(a); });
|
||||
else
|
||||
return list.sort(function (a, b) { return fn(a) == fn(b) ? (fn2(b) - fn2(a)) : fn(b) - fn(a); });
|
||||
};
|
||||
/** 分组 */
|
||||
ArrayExt.groupBy = function (list, fn) {
|
||||
var groups = new Array();
|
||||
var _loop_1 = function (item) {
|
||||
var key = fn(item);
|
||||
var group = groups.find(function (t) { return t.key == key; });
|
||||
if (group == null) {
|
||||
group = new GroupItem(key);
|
||||
groups.push(group);
|
||||
}
|
||||
group.push(item);
|
||||
};
|
||||
for (var _i = 0, list_8 = list; _i < list_8.length; _i++) {
|
||||
var item = list_8[_i];
|
||||
_loop_1(item);
|
||||
}
|
||||
return groups;
|
||||
};
|
||||
/**
|
||||
* 选择
|
||||
* let newObjectList = ArrayExt.Select(list,t=>({pA:t.name, pB:t.age + "_"+ t.month}) ) ;
|
||||
*/
|
||||
ArrayExt.Select = function (list, fn) {
|
||||
var newList = new Array();
|
||||
for (var _i = 0, list_9 = list; _i < list_9.length; _i++) {
|
||||
var t = list_9[_i];
|
||||
newList.push(fn(t));
|
||||
}
|
||||
return newList;
|
||||
};
|
||||
/** 过来,并按顺序排序 */
|
||||
ArrayExt.where = function (list, whereFn, orderfn1, orderfn2) {
|
||||
if (orderfn1 === void 0) { orderfn1 = null; }
|
||||
if (orderfn2 === void 0) { orderfn2 = null; }
|
||||
var newList = list.filter(whereFn);
|
||||
if (orderfn1 == null && orderfn2 == null)
|
||||
return newList;
|
||||
return ArrayExt.sortBy(newList, orderfn1, orderfn2);
|
||||
};
|
||||
return ArrayExt;
|
||||
}());
|
||||
exports.ArrayExt = ArrayExt;
|
||||
var GroupItem = /** @class */ (function () {
|
||||
function GroupItem(k) {
|
||||
this.key = k;
|
||||
this.list = [];
|
||||
}
|
||||
Object.defineProperty(GroupItem.prototype, "count", {
|
||||
get: function () { return this.list.length; },
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
GroupItem.prototype.push = function (d) {
|
||||
this.list.push(d);
|
||||
};
|
||||
return GroupItem;
|
||||
}());
|
||||
exports.GroupItem = GroupItem;
|
||||
/**
|
||||
* 对排序好的数组进行去重操作
|
||||
* @param {(e1, e2) => boolean} [checkFuction] 校验对象相等函数
|
||||
* @returns {Array<T>} 返回自身
|
||||
*/
|
||||
function arrayRemoveDuplicateBySort(arr, checkFuction) {
|
||||
if (checkFuction === void 0) { checkFuction = checkEqual; }
|
||||
if (arr.length < 2)
|
||||
return arr;
|
||||
var j = 1;
|
||||
for (var i = 1, l = arr.length; i < l; i++)
|
||||
if (!checkFuction(arr[j - 1], arr[i]))
|
||||
arr[j++] = arr[i];
|
||||
arr.length = j;
|
||||
return arr;
|
||||
}
|
||||
exports.arrayRemoveDuplicateBySort = arrayRemoveDuplicateBySort;
|
141
samples/handleAbility/common/Box2.js
Normal file
141
samples/handleAbility/common/Box2.js
Normal file
@@ -0,0 +1,141 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Box2 = void 0;
|
||||
var Vector2_js_1 = require("./Vector2.js");
|
||||
var Box2 = /** @class */ (function () {
|
||||
function Box2(min, max) {
|
||||
if (min === void 0) { min = new Vector2_js_1.Vector2(+Number.POSITIVE_INFINITY, +Number.POSITIVE_INFINITY); }
|
||||
if (max === void 0) { max = new Vector2_js_1.Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); }
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
Object.defineProperty(Box2.prototype, "area", {
|
||||
/** 获取面积 */
|
||||
get: function () {
|
||||
return (this.max.x - this.min.x) * (this.max.y - this.min.y);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/** */
|
||||
Box2.prototype.set = function (min, max) {
|
||||
this.min.copy(min);
|
||||
this.max.copy(max);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.setFromPoints = function (points) {
|
||||
this.makeEmpty();
|
||||
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
|
||||
var p = points_1[_i];
|
||||
this.expandByPoint(p);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.setFromCenterAndSize = function (center, size) {
|
||||
var v1 = Box2._setFromCenterAndSize_v1;
|
||||
var halfSize = v1.copy(size).multiplyScalar(0.5);
|
||||
this.min.copy(center).sub(halfSize);
|
||||
this.max.copy(center).add(halfSize);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.clone = function () {
|
||||
return new this.constructor().copy(this);
|
||||
};
|
||||
Box2.prototype.copy = function (box) {
|
||||
this.min.copy(box.min);
|
||||
this.max.copy(box.max);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.makeEmpty = function () {
|
||||
this.min.x = this.min.y = +Number.POSITIVE_INFINITY;
|
||||
this.max.x = this.max.y = Number.NEGATIVE_INFINITY;
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.isEmpty = function () {
|
||||
// this is a more robust check for empty than (volume <= 0) because volume can get positive with two negative axes
|
||||
return (this.max.x < this.min.x) || (this.max.y < this.min.y);
|
||||
};
|
||||
Box2.prototype.getCenter = function (result) {
|
||||
if (result === void 0) { result = new Vector2_js_1.Vector2(); }
|
||||
return this.isEmpty() ? result.set(0, 0) : result.addVectors(this.min, this.max).multiplyScalar(0.5);
|
||||
};
|
||||
Box2.prototype.getSize = function (result) {
|
||||
if (result === void 0) { result = new Vector2_js_1.Vector2(); }
|
||||
return this.isEmpty() ? result.set(0, 0) : result.subVectors(this.max, this.min);
|
||||
};
|
||||
Box2.prototype.expandByPoint = function (point) {
|
||||
this.min.min(point);
|
||||
this.max.max(point);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.expandByVector = function (vector) {
|
||||
this.min.sub(vector);
|
||||
this.max.add(vector);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.expandByScalar = function (scalar) {
|
||||
this.min.addScalar(-scalar);
|
||||
this.max.addScalar(scalar);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.containsPoint = function (point) {
|
||||
if (point.x < this.min.x || point.x > this.max.x
|
||||
|| point.y < this.min.y || point.y > this.max.y) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Box2.prototype.containsBox = function (box) {
|
||||
if ((this.min.x <= box.min.x) && (box.max.x <= this.max.x)
|
||||
&& (this.min.y <= box.min.y) && (box.max.y <= this.max.y)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Box2.prototype.getParameter = function (point, result) {
|
||||
if (result === void 0) { result = new Vector2_js_1.Vector2(); }
|
||||
// This can potentially have a divide by zero if the box
|
||||
// has a size dimension of 0.
|
||||
return result.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y));
|
||||
};
|
||||
Box2.prototype.intersectsBox = function (box) {
|
||||
// using 6 splitting planes to rule out intersections.
|
||||
if (box.max.x < this.min.x || box.min.x > this.max.x
|
||||
|| box.max.y < this.min.y || box.min.y > this.max.y) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Box2.prototype.clampPoint = function (point, result) {
|
||||
if (result === void 0) { result = new Vector2_js_1.Vector2(); }
|
||||
return result.copy(point).clamp(this.min, this.max);
|
||||
};
|
||||
Box2.prototype.distanceToPoint = function (point) {
|
||||
var v1 = Box2._distanceToPoint_v1;
|
||||
var clampedPoint = v1.copy(point).clamp(this.min, this.max);
|
||||
return clampedPoint.sub(point).length();
|
||||
};
|
||||
Box2.prototype.intersect = function (box) {
|
||||
this.min.max(box.min);
|
||||
this.max.min(box.max);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.union = function (box) {
|
||||
this.min.min(box.min);
|
||||
this.max.max(box.max);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.translate = function (offset) {
|
||||
this.min.add(offset);
|
||||
this.max.add(offset);
|
||||
return this;
|
||||
};
|
||||
Box2.prototype.equals = function (box) {
|
||||
return box.min.equals(this.min) && box.max.equals(this.max);
|
||||
};
|
||||
Box2._setFromCenterAndSize_v1 = new Vector2_js_1.Vector2();
|
||||
Box2._distanceToPoint_v1 = new Vector2_js_1.Vector2();
|
||||
return Box2;
|
||||
}());
|
||||
exports.Box2 = Box2;
|
||||
;
|
@@ -7,7 +7,6 @@ import type { Curve2d } from '../base/CAD'
|
||||
import { Arc2d, Point2d, copyTextToClipboard } from '../base/CAD'
|
||||
import { CurveWrap } from './Curves2Parts'
|
||||
|
||||
// import type { Curve2d } from '../../common/base/CAD'
|
||||
|
||||
export class PolylineHelper {
|
||||
/** 创建闭合多段线 */
|
||||
|
@@ -42,14 +42,6 @@
|
||||
"y": 1091.42,
|
||||
"pbg": 106.01,
|
||||
"pbk": 171.01
|
||||
},
|
||||
{
|
||||
"bangid": "25044454404",
|
||||
"line": 0,
|
||||
"x": 1032.03,
|
||||
"y": 1197.43,
|
||||
"pbg": 105.01,
|
||||
"pbk": 171.01
|
||||
}
|
||||
]
|
||||
],
|
||||
|
231
src/device.ts
231
src/device.ts
@@ -1,3 +1,4 @@
|
||||
import { error } from "console";
|
||||
|
||||
// 回调函数类型定义
|
||||
type ProcessCallback<T, R> = (
|
||||
@@ -13,8 +14,45 @@ type ModuleConfig = Record<string, any>;
|
||||
// 回调函数类型
|
||||
type ModuleCallback<T, R> = (result: R, input?: T) => void | Promise<void>;
|
||||
|
||||
export interface ErrorInfo {
|
||||
moduleName?: string
|
||||
moduleVersion?: string
|
||||
info?: any
|
||||
}
|
||||
|
||||
export class ProcessorManager<T, R> implements ProcessorCollection<T, R> {
|
||||
private processors = new Map<string, Processor<T, R>>();
|
||||
private currentProcessor?: Processor<T, R>;
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
/** 注册模块流程 */
|
||||
registerProcessor(name: string, processor: Processor<T, R>): this {
|
||||
this.processors.set(name, processor);
|
||||
return this;
|
||||
}
|
||||
/** 使用处理器 */
|
||||
useProcessor(name: string): Processor<T, R> {
|
||||
const processor = this.processors.get(name);
|
||||
if (!processor) {
|
||||
throw new Error(`Processor ${name} not found`);
|
||||
}
|
||||
this.currentProcessor = processor;
|
||||
return processor;
|
||||
}
|
||||
/** 获取处理器 */
|
||||
getProcessor(name: string): Processor<T, R> | undefined {
|
||||
return this.processors.get(name);
|
||||
}
|
||||
/** 获取正在使用的处理器 */
|
||||
getCurrentProcessor(): Processor<T, R> | undefined {
|
||||
return this.currentProcessor;
|
||||
}
|
||||
}
|
||||
|
||||
// 扩展后的功能模块接口
|
||||
export interface ProcessorModule<T, R> {
|
||||
export interface ProcessorModuleBase<T, R> {
|
||||
// 主处理函数(可回调)
|
||||
process?: ProcessCallback<T, R>;
|
||||
|
||||
@@ -23,11 +61,14 @@ export interface ProcessorModule<T, R> {
|
||||
|
||||
// 模块名称(用于标识和排序)
|
||||
moduleName?: string;
|
||||
|
||||
/** 模块版本号 */
|
||||
moduleVersion?: string
|
||||
// 模块配置
|
||||
config?: ModuleConfig;
|
||||
|
||||
getConfigList?: () => ModuleConfig
|
||||
// 多线程列表
|
||||
workerList?: any[]
|
||||
// 获取配置列表
|
||||
getConfigList?: () => any[]
|
||||
// 设置配置的方法
|
||||
setConfig?: (config: ModuleConfig) => void;
|
||||
|
||||
@@ -39,8 +80,24 @@ export interface ProcessorModule<T, R> {
|
||||
|
||||
// 错误处理回调
|
||||
onError?: (error: unknown, input?: T) => void | Promise<void>;
|
||||
|
||||
// 消息传递 模块将数据传给处理器
|
||||
onMessage?: Function//(data:unknown) => void | Promise<void>;
|
||||
// [key: string]:any
|
||||
}
|
||||
|
||||
/** 支持自定义函数 */
|
||||
export interface ProcessorModuleExtensions {
|
||||
/** 允许在模块内添加自定义函数 和属性 */
|
||||
[key: string]: ((...args: any[]) => any) | undefined;
|
||||
}
|
||||
|
||||
export interface strictModuleExtensions {
|
||||
|
||||
}
|
||||
|
||||
export type ProcessorModule<T, R> = ProcessorModuleBase<T, R> // & ProcessorModuleExtensions;
|
||||
|
||||
export interface Processor<T, R> {
|
||||
// 注册模块
|
||||
use(module: ProcessorModule<T, R> | ProcessorModule<T, R>[]): this;
|
||||
@@ -55,7 +112,18 @@ export interface Processor<T, R> {
|
||||
getModules(): ProcessorModule<T, R>[];
|
||||
|
||||
// 新增方法:更新模块配置
|
||||
updateModuleConfig(moduleName: string, config: ModuleConfig): this;
|
||||
updateModuleConfig(config: ModuleConfig): this;
|
||||
|
||||
/**
|
||||
获取模块的配置项
|
||||
*/
|
||||
getModuleConfig(): ModuleConfig
|
||||
/**
|
||||
* 获取模块配置列表
|
||||
*/
|
||||
getModuleConfigList(): any[]
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
// 处理器集合接口
|
||||
@@ -78,13 +146,14 @@ export interface ProcessorCollection<T, R> {
|
||||
export class StepControllerProcessor<T, R> implements Processor<T, R> {
|
||||
private modules: ProcessorModule<T, R>[] = [];
|
||||
private modulesMap = new Map<string, ProcessorModule<T, R>>();
|
||||
|
||||
private onMessageFunction: Function = () => { }
|
||||
use(module: ProcessorModule<T, R> | ProcessorModule<T, R>[]): this {
|
||||
const modules = Array.isArray(module) ? module : [module];
|
||||
|
||||
modules.forEach(m => {
|
||||
if (m.moduleName) {
|
||||
this.modulesMap.set(m.moduleName, m);
|
||||
m.onMessage = this.onMessageFunction
|
||||
}
|
||||
this.modules.push(m);
|
||||
});
|
||||
@@ -104,16 +173,94 @@ export class StepControllerProcessor<T, R> implements Processor<T, R> {
|
||||
this.modules = [...orderedModules, ...remainingModules];
|
||||
return this;
|
||||
}
|
||||
/** 更新处理器 内的模块的配置 */
|
||||
updateModuleConfig(config: ModuleConfig): this {
|
||||
// const module = this.modulesMap.get(moduleName)
|
||||
let log = []
|
||||
for (const m of this.modules) {
|
||||
if (m.config != undefined) {
|
||||
let conArr = Object.keys(m.config)
|
||||
let m_config = {}
|
||||
for (const keyStr of conArr) {
|
||||
if (Reflect.has(config, keyStr)) {
|
||||
// m.config[keyStr] = config[keyStr]
|
||||
Reflect.set(m_config, keyStr, config[keyStr])
|
||||
} else {
|
||||
let noConfigInfo = {
|
||||
moduleName: m.moduleName,
|
||||
configKey: keyStr,
|
||||
info: '没有配置参数!'
|
||||
}
|
||||
log.push(noConfigInfo)
|
||||
}
|
||||
}
|
||||
if (m?.setConfig) {
|
||||
m?.setConfig(m_config)
|
||||
} else {
|
||||
let noConfigInfo = {
|
||||
moduleName: m.moduleName,
|
||||
configKey: '',
|
||||
info: '模块设置了【config】,却没有设置【setConfig】;'
|
||||
}
|
||||
log.push(noConfigInfo)
|
||||
}
|
||||
|
||||
updateModuleConfig(moduleName: string, config: ModuleConfig): this {
|
||||
const module = this.modulesMap.get(moduleName);
|
||||
if (module && module.setConfig) {
|
||||
module.setConfig(config);
|
||||
} else if (module) {
|
||||
module.config = { ...module.config, ...config };
|
||||
}
|
||||
}
|
||||
if (log.length > 0) {
|
||||
let str = log.map(e => {
|
||||
let s = '模块:' + e.moduleName
|
||||
if (e.configKey) {
|
||||
s = s + ',' + e.configKey
|
||||
}
|
||||
s = s + ',' + e.info + ';'
|
||||
return s
|
||||
})
|
||||
console.warn('加载配置异常:', str)
|
||||
}
|
||||
return this;
|
||||
}
|
||||
getModuleConfig(): ModuleConfig {
|
||||
let config:ModuleConfig = {}
|
||||
for (const m of this.modules) {
|
||||
config = {...config,...m.config}
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
getModuleConfigList(){
|
||||
//#region 方式1
|
||||
|
||||
let configList:any[] = []
|
||||
let config:ModuleConfig = {}
|
||||
for (const m of this.modules) {
|
||||
config = {...config,...m.config}
|
||||
// let keys = Object.keys(m.config)
|
||||
}
|
||||
let keys = Object.keys(config)
|
||||
for (const key of keys) {
|
||||
let temp= {
|
||||
key: key,
|
||||
value: config[key]
|
||||
}
|
||||
configList.push(temp)
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 方式二
|
||||
let configList1:any[] = []
|
||||
for (const m of this.modules) {
|
||||
if(Reflect.has(m,'getConfigList')){
|
||||
let m_configList = m.getConfigList() || []
|
||||
configList1 = [...configList1,...m_configList]
|
||||
}
|
||||
|
||||
}
|
||||
//#endregion
|
||||
return configList
|
||||
}
|
||||
|
||||
private async executeModule(
|
||||
module: ProcessorModule<T, R>,
|
||||
@@ -185,64 +332,14 @@ export class StepControllerProcessor<T, R> implements Processor<T, R> {
|
||||
return executeNext(input);
|
||||
}
|
||||
|
||||
// async process(input: T): Promise<R> {
|
||||
// if (this.modules.length === 0) {
|
||||
// throw new Error("No modules registered");
|
||||
// }
|
||||
|
||||
// let currentIndex = 0;
|
||||
// const modules = this.modules;
|
||||
// const context: Record<string, any> = {}; // 共享上下文
|
||||
|
||||
// const executeNext = async (currentInput: T): Promise<R> => {
|
||||
// const currentModule = modules[currentIndex++];
|
||||
// if (!currentModule) {
|
||||
// return currentInput as unknown as R;
|
||||
// }
|
||||
|
||||
// try {
|
||||
// // 执行前置回调
|
||||
// if (currentModule.before) {
|
||||
// await currentModule.before(currentInput, currentInput);
|
||||
// }
|
||||
|
||||
// // 执行主处理函数
|
||||
// const next = async (nextInput: T): Promise<R> => {
|
||||
// return executeNext(nextInput);
|
||||
// };
|
||||
|
||||
// let result: R;
|
||||
// const processResult = currentModule.process(currentInput, next, context);
|
||||
|
||||
// if (processResult instanceof Promise) {
|
||||
// result = await processResult;
|
||||
// } else {
|
||||
// result = processResult;
|
||||
// }
|
||||
|
||||
// // 执行后置回调
|
||||
// if (currentModule.after) {
|
||||
// await currentModule.after(result, currentInput);
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// } catch (error) {
|
||||
// // 执行错误处理
|
||||
// if (currentModule.onError) {
|
||||
// await currentModule.onError(error, currentInput);
|
||||
// } else {
|
||||
// throw error; // 如果没有错误处理,则向上抛出
|
||||
// }
|
||||
|
||||
// // 根据错误处理结果决定是否继续
|
||||
// return currentInput as unknown as R;
|
||||
// }
|
||||
// };
|
||||
|
||||
// return executeNext(input);
|
||||
// }
|
||||
|
||||
getModules(): ProcessorModule<T, R>[] {
|
||||
return [...this.modules];
|
||||
}
|
||||
|
||||
setOnMessageFunc(func: Function) {
|
||||
this.onMessageFunction = func
|
||||
}
|
||||
|
||||
}
|
@@ -1,10 +1,12 @@
|
||||
import { test } from '@jest/globals'
|
||||
import { describe, it, expect, test } from 'vitest';
|
||||
import { DemoParser } from '../samples/demoParser';
|
||||
import { ProcessorModule, StepControllerProcessor } from '../src/device';
|
||||
import { ProcessorManager } from '../samples/demoDataHandleServer';
|
||||
import { ProcessorManager } from '../src/device';
|
||||
import { demoHandleGroupCutting } from '../samples/demoDatahandle/demoDataHandle1';
|
||||
import testJson from "./test.json"
|
||||
test('demoParser', () => {
|
||||
import { Worker, parentPort } from 'worker_threads';
|
||||
import { UniversalWorker } from '../samples/WorkerHelper';
|
||||
describe('demoParser', () => {
|
||||
const text = `FSTART
|
||||
TD 5
|
||||
G0 X100 Y100 Z10 F8000
|
||||
@@ -21,7 +23,14 @@ FEND
|
||||
|
||||
})
|
||||
|
||||
test('data', async () => {
|
||||
describe('data', async () => {
|
||||
const sysConfig = {
|
||||
placeStyle: 1,
|
||||
boardWidth: 2440,
|
||||
boardLength: 1220,
|
||||
// 测试刀库数据
|
||||
knifeList: [knifeData, knifeData1, knifeData2]
|
||||
}
|
||||
const json = testJson
|
||||
// 创建处理器集合
|
||||
const processorManager = new ProcessorManager<any, any>();
|
||||
@@ -30,10 +39,147 @@ test('data', async () => {
|
||||
// 注册处理器
|
||||
processorManager.registerProcessor(cuttingHandle.processorName, cuttingHandle.processor)
|
||||
// 使用XX处理器 会返回激活【正在使用】的 处理器
|
||||
const processor = processorManager.useProcessor(cuttingHandle.processorName)
|
||||
|
||||
let processor = processorManager.useProcessor(cuttingHandle.processorName)
|
||||
// 或者 这样 获取 正在使用的处理器 注:若未执行useProcessor 将会返回 undefind
|
||||
// processor = processorManager.getCurrentProcessor()
|
||||
/** 处理器配置加载 */
|
||||
processor.updateModuleConfig(sysConfig)
|
||||
const res = await processor.process(json)
|
||||
console.log('处理器所有流程都结束了', res);
|
||||
|
||||
|
||||
// console.log('处理器所有流程都结束了', res);
|
||||
})
|
||||
|
||||
/** demo 刀具数据 */
|
||||
export const knifeData = {
|
||||
"isEnabled": true,
|
||||
"axleId": 2,
|
||||
"knifeId": 2,
|
||||
"processFace": "",
|
||||
"knifeName": "T1",
|
||||
"knifeType": 3,
|
||||
"ability": [
|
||||
5
|
||||
],
|
||||
"diameter": 5,
|
||||
"length": 20,
|
||||
"sawThiness": 7,
|
||||
"sawDirection": 2,
|
||||
"processDirection": 4,
|
||||
"speed": 0,
|
||||
"stepDepth": 0,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"offsetZ": 0,
|
||||
"baseX": 0,
|
||||
"baseY": 0,
|
||||
"isModularDrill": false,
|
||||
"isPreStartEnabled": false,
|
||||
"preStartAheadActionCount": 5,
|
||||
"isPreStartToolChangeDelay": false,
|
||||
"preStartToolChangeDelayCode": "",
|
||||
"isAxisStartCodePostpost": false,
|
||||
"isAxisStopCodePrepose": false,
|
||||
"drillGroupCode": "",
|
||||
"axisStartCode": "M03 S18000\n",
|
||||
"knifeStartCode": `M06 T1\nG43 H1\n`,
|
||||
"drillGroupStartCode": "T1",
|
||||
"drillGroupEndCode": "",
|
||||
"knifeStopCode": "",
|
||||
"axisStopCode": "M05\n",
|
||||
"preStartActionDeferCode": "",
|
||||
"useHolesGroupKnife": false,
|
||||
"preStartActionStepsLimit": "",
|
||||
"knifeNo": "",
|
||||
"editable": true,
|
||||
"isDefaultCutKnife": false,
|
||||
"isPreStartChangeKnifeDefer": false
|
||||
}
|
||||
export const knifeData1 = {
|
||||
"isEnabled": true,
|
||||
"axleId": 2,
|
||||
"knifeId": 2,
|
||||
"processFace": "",
|
||||
"knifeName": "T2",
|
||||
"knifeType": 3,
|
||||
"ability": [
|
||||
5
|
||||
],
|
||||
"diameter": 6,
|
||||
"length": 20,
|
||||
"sawThiness": 7,
|
||||
"sawDirection": 2,
|
||||
"processDirection": 4,
|
||||
"speed": 0,
|
||||
"stepDepth": 0,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"offsetZ": 0,
|
||||
"baseX": 0,
|
||||
"baseY": 0,
|
||||
"isModularDrill": false,
|
||||
"isPreStartEnabled": false,
|
||||
"preStartAheadActionCount": 5,
|
||||
"isPreStartToolChangeDelay": false,
|
||||
"preStartToolChangeDelayCode": "",
|
||||
"isAxisStartCodePostpost": false,
|
||||
"isAxisStopCodePrepose": false,
|
||||
"drillGroupCode": "",
|
||||
"axisStartCode": "M03 S18000\n",
|
||||
"knifeStartCode": `M06 T2\nG43 H2\n`,
|
||||
"drillGroupStartCode": "T2",
|
||||
"drillGroupEndCode": "",
|
||||
"knifeStopCode": "",
|
||||
"axisStopCode": "M05\n",
|
||||
"preStartActionDeferCode": "",
|
||||
"useHolesGroupKnife": false,
|
||||
"preStartActionStepsLimit": "",
|
||||
"knifeNo": "",
|
||||
"editable": true,
|
||||
"isDefaultCutKnife": false,
|
||||
"isPreStartChangeKnifeDefer": false
|
||||
}
|
||||
export const knifeData2 = {
|
||||
"isEnabled": true,
|
||||
"axleId": 2,
|
||||
"knifeId": 2,
|
||||
"processFace": "",
|
||||
"knifeName": "T3",
|
||||
"knifeType": 3,
|
||||
"ability": [
|
||||
5
|
||||
],
|
||||
"diameter": 6,
|
||||
"length": 20,
|
||||
"sawThiness": 7,
|
||||
"sawDirection": 2,
|
||||
"processDirection": 4,
|
||||
"speed": 0,
|
||||
"stepDepth": 0,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"offsetZ": 0,
|
||||
"baseX": 0,
|
||||
"baseY": 0,
|
||||
"isModularDrill": false,
|
||||
"isPreStartEnabled": false,
|
||||
"preStartAheadActionCount": 5,
|
||||
"isPreStartToolChangeDelay": false,
|
||||
"preStartToolChangeDelayCode": "",
|
||||
"isAxisStartCodePostpost": false,
|
||||
"isAxisStopCodePrepose": false,
|
||||
"drillGroupCode": "",
|
||||
|
||||
"axisStartCode": "M03 S18000\n",
|
||||
"knifeStartCode": `M06 T2\nG43 H2\n`,
|
||||
"drillGroupStartCode": "T3",
|
||||
"drillGroupEndCode": "",
|
||||
"knifeStopCode": "",
|
||||
"axisStopCode": "M05\n",
|
||||
|
||||
"preStartActionDeferCode": "",
|
||||
"useHolesGroupKnife": false,
|
||||
"preStartActionStepsLimit": "",
|
||||
"knifeNo": "",
|
||||
"editable": true,
|
||||
"isDefaultCutKnife": false,
|
||||
"isPreStartChangeKnifeDefer": false
|
||||
}
|
||||
|
@@ -1,28 +1,29 @@
|
||||
{
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules","samples","tests"],
|
||||
// "compilerOptions": {
|
||||
// "target": "ES6",
|
||||
"module": "ESNext", // 必须用 ESNext
|
||||
// "esModuleInterop": true,
|
||||
// "moduleResolution": "node",
|
||||
// "skipLibCheck": true,
|
||||
// "sourceMap": true,
|
||||
// "outDir": "./dist",
|
||||
// "rootDir": ".", // 改为 "." 包含所有文件
|
||||
// "strict": true,
|
||||
// "baseUrl": ".", // 确保路径解析正确
|
||||
// "paths": {
|
||||
// // 可选:自定义路径映射(如 "@/*": ["src/*"])
|
||||
// }
|
||||
// },
|
||||
// "include": ["src/**/*", "tests/**/*"], // 包含测试文件
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Language and Environment */
|
||||
// "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
"target": "ES6",
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
|
||||
/* Emit */
|
||||
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||
"rootDir": "./src",
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
||||
"sourceMap": true
|
||||
}
|
||||
"types": [],
|
||||
"resolveJsonModule": true, // 允许导入 .json 文件
|
||||
"esModuleInterop": true, // 确保 CommonJS/ESM 兼容
|
||||
"module": "ESNext", // 推荐使用 ESM
|
||||
"moduleResolution": "Node" // 确保 Node.js 模块解析
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user