feat:提交

This commit is contained in:
2025-09-05 11:37:39 +08:00
parent f4bb32d32a
commit 5dae2aa242
8 changed files with 783 additions and 85 deletions

View File

@@ -21,8 +21,8 @@
"./utils": "./src/utils/index.ts"
},
"dependencies": {
"cut-abstractions": "http://gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.3.tgz",
"mes-processors":"http://gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.1.tgz"
"cut-abstractions": "http://gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.5.tgz",
"mes-processors":"http://gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.2.tgz"
},
"devDependencies": {
"@types/node": "^24.0.10",

20
pnpm-lock.yaml generated
View File

@@ -6,11 +6,11 @@ settings:
dependencies:
cut-abstractions:
specifier: http://gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.3.tgz
version: '@gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.3.tgz'
specifier: http://gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.5.tgz
version: '@gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.5.tgz'
mes-processors:
specifier: http://gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.1.tgz
version: '@gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.1.tgz'
specifier: http://gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.2.tgz
version: '@gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.2.tgz'
devDependencies:
'@types/node':
@@ -2462,10 +2462,16 @@ packages:
version: 0.3.3
dev: false
'@gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.1.tgz':
resolution: {tarball: http://gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.1.tgz}
'@gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.5.tgz':
resolution: {tarball: http://gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.5.tgz}
name: cut-abstractions
version: 0.3.5
dev: false
'@gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.2.tgz':
resolution: {tarball: http://gitea.cf/MES-FE/mes-packages/releases/download/0.2/mes-processors-libs-0.2.2.tgz}
name: '@mes-processors/libs'
version: 0.2.1
version: 0.2.2
dependencies:
cut-abstractions: '@gitea.cf/MES-FE/cut-abstractions/releases/download/0.3/cut-abstractions-0.3.3.tgz'
dev: false

View File

@@ -1,68 +1,202 @@
import { test } from "vitest";
import { CncConverter, CncTemplateParams, TemplateEndTargetType } from "./processors/CncConverter/CncConverter";
import { CncConverter, CncTemplateParams, CncTemplatePropertyType, TemplateEndTargetType } from "./processors/CncConverter/CncConverter";
import { ToolHelper, KnifeParams, Tool } from "./processors/toolsHelp/toolHelper";
import { LogicalFilterType } from "./processors/LogicHelper/LogicHelper";
import { KnifeType } from "cut-abstractions";
test('cncTest', async () => {
const testData: CncTemplateParams = {
templateName: 'MicroDrawBan_XML',
propertyList: [{
propertyName: 'Version',
propertyValue: '3.0',
}, {
propertyName: 'Time',
propertyValue: '20250903',
}, {
propertyName: 'Source',
propertyValue: '福州晨丰科技有限公司',
}, {
propertyName: 'SourceType',
propertyValue: 'CNC-Drilling',
}],
children: [{
templateName: 'Plane',
propertyList: [{
propertyName: 'Name',
propertyValue: '板名称',
}, {
propertyName: 'Code',
propertyValue: '板编号',
},
{
propertyName: 'Order',
propertyValue: '生产单号',
}],
children: [{
templateName: 'Outline',
propertyList: [],
children: [
{
templateName: 'Point',
propertyList: [{
propertyName:'Value',
propertyValue: 213,
}],
children: [],
templateEndType: TemplateEndTargetType.SingleEnd
}
],
templateEndType: TemplateEndTargetType.DoubleEnd
},
{
templateName:'HoleV',
propertyList:[
{
propertyName:'Name',
propertyValue:"HoleV"
},
],
children:[],
templateEndType: TemplateEndTargetType.SingleEnd
}
],
templateEndType: TemplateEndTargetType.DoubleEnd
}],
templateEndType: TemplateEndTargetType.DoubleEnd
/** 测试样例
*
* src\processors\CncConverter\demoXmlData.xml
*/
/** 编排数据 */
let testData = new CncTemplateParams()
testData.templateName = 'KDTPanelFormat'
testData.value = '123'
let property: CncTemplatePropertyType = {
propertyName: 'ABC',
propertyValue: '123'
}
let pp1: CncTemplatePropertyType = {
propertyName: 'CDE',
propertyValue: '456'
}
testData.appendProperty(property)
testData.appendProperty(pp1)
let node1 = new CncTemplateParams()
node1.templateName = 'CoordinateSystem'
node1.value = 3
testData.appendChildren(node1)
let node2 = new CncTemplateParams()
node2.templateName = 'Inch'
node2.value = 0
testData.appendChildren(node2)
let node_params = new CncTemplateParams()
node_params.templateName = 'Params'
let node_param1 = new CncTemplateParams()
node_param1.templateName = 'Param'
node_param1.templateEndType = TemplateEndTargetType.SingleEnd
node_param1.appendProperty({
propertyName: 'Value',
propertyValue: '"600.00"'
})
node_param1.appendProperty({
propertyName: 'Comment',
propertyValue: '板长'
})
node_param1.appendProperty({
propertyName: 'Key',
propertyValue: 'L'
})
let node_param2 = new CncTemplateParams()
node_param2.templateName = 'Param'
node_param2.templateEndType = TemplateEndTargetType.SingleEnd
node_param2.appendProperty({
propertyName: 'Value',
propertyValue: '"400.00"'
})
node_param2.appendProperty({
propertyName: 'Comment',
propertyValue: '板宽'
})
node_param2.appendProperty({
propertyName: 'Key',
propertyValue: 'W'
})
let node_param3 = new CncTemplateParams()
node_param3.templateName = 'Param'
node_param3.templateEndType = TemplateEndTargetType.SingleEnd
node_param3.appendProperty({
propertyName: 'Value',
propertyValue: '"18.00"'
})
node_param3.appendProperty({
propertyName: 'Comment',
propertyValue: '板厚'
})
node_param3.appendProperty({
propertyName: 'Key',
propertyValue: 'T'
})
node_params.appendChildren(node_param1)
node_params.appendChildren(node_param2)
node_params.appendChildren(node_param3)
/** 测试 */
let testNode = new CncTemplateParams()
testNode.templateName = 'testNode'
testNode.value = '123testNode'
node_params.appendChildren(testNode)
/** 测试1 */
let testNode1 = new CncTemplateParams()
testNode1.templateName = 'testNode1'
let valNode1 = new CncTemplateParams()
valNode1.appendProperty({
propertyName:'测试属性',
propertyValue:'hello world'
})
valNode1.templateName = '测试1哦'
let valNode2 = new CncTemplateParams()
valNode2.templateName = '测试2哦'
valNode2.value = 'hello'
valNode1.appendChildren(valNode2)
testNode1.appendChildren(valNode1)
node_params.appendChildren(testNode1)
testData.appendChildren(node_params)
/** 依据数据生成 CNC XML内容 */
let cncWriter = new CncConverter()
await cncWriter.doXML([testData])
debugger
await cncWriter.doXML([testData])
let str = cncWriter.toString()
console.log(str)
})
test('tools', async () => {
//#region 初始化部分
const knifeList: Tool[] = []
let knife1 = new Tool()
knife1.id = 1
knife1.diameter = 6
knife1.name = 't1'
knife1.type = KnifeType.Cut | KnifeType.Milling | KnifeType.Model | KnifeType.Hole
let knife2 = new Tool()
knife2.id = 2
knife2.diameter = 5
knife2.name = 't2'
knife2.type = KnifeType.Hole | KnifeType.Model
const toolHelper = new ToolHelper()
// 方式1
toolHelper.appendKnife(knife1)
toolHelper.appendKnife(knife2)
// 方式2
knifeList.push(knife1)
knifeList.push(knife2)
toolHelper.initTools(knifeList)
let knife3 = new Tool()
knife3.id = 3
knife3.diameter = 4
knife3.name = 't3'
knife3.type = KnifeType.Cut | KnifeType.Milling
// 方式3
toolHelper.appendTools([knife3])
//#endregion
//#region 找刀部分 示例
let params: KnifeParams = {
diameter: 6
}
let k1 = toolHelper.getKnife(params)
console.log('找6 的刀', k1);
let params1: KnifeParams = {
diameter: 5
}
let k2 = toolHelper.getKnife(params1, LogicalFilterType.lessThanEqualTo)
console.log('找小于等于5 的刀', k2)
let params2: KnifeParams = {
diameter: 5
}
let k3 = toolHelper.getKnife(params2, LogicalFilterType.lessThan)
console.log('找刀半径小于5的刀', k3)
//#endregion
let params3: KnifeParams = {
name: 't2'
}
let k4 = toolHelper.getKnife(params3)
console.log('找叫t2的刀', k4);
let k5 = toolHelper.getKnife({ type: KnifeType.Cut | KnifeType.Milling })
console.log('找叫开料和修边的刀', k4);
// let params4: KnifeParams = {
// type:
// }
})

View File

@@ -19,10 +19,11 @@ export class CncConverter implements ICncWriter {
await this.doCncTemplate(template)
}
}
async doCncTemplate(templateItem: CncTemplateParams, level: number = 0) {
this.nodes.push(templateItem)
/** 行缩进 内容 */
let tabContent = ` `
/** 实际行缩进输出内容 */
@@ -33,36 +34,74 @@ export class CncConverter implements ICncWriter {
tabVal = tabVal + tabContent;
}
/** 分析标识--是否有子节点 */
const hasChildren = Array.isArray(templateItem.children) && templateItem.children.length > 0
/** 分析标识--是否有子值 */
const hasValue = templateItem.value != undefined
//#region 分析标识 -- 节点结束的形式
/**
* double <p></p> 有 子节点 children 或者 value
* single <p /> 子节点 和value 都没有
*/
let lineType = ''
if (hasValue && !hasChildren) {
lineType = 'line'
} else {
lineType = 'splitLine'
}
//#endregion
let node: any[] = []
node.push(tabVal)
if (tabVal) {
node.push(tabVal)
}
let startCode = `<${templateItem.templateName}`
/** 结尾 */
let endCode = templateItem.templateEndType == TemplateEndTargetType.DoubleEnd ? `</${templateItem.templateName}>` : ''
node.push(startCode)
for (const propertyInfo of templateItem.propertyList) {
let propertyItem = `${propertyInfo.propertyName}="${propertyInfo.propertyValue}"`
node.push(propertyItem)
}
let endStr = ' >'
let endStr = '>'
if (templateItem.templateEndType == TemplateEndTargetType.SingleEnd) {
endStr = ' />'
}
node.push(endStr)
if (hasValue && lineType == 'line') {
node.push(templateItem.value)
}
if (lineType == 'line') {
node.push(endCode)
}
this.lines.push(node.join(' '))
if (hasValue && lineType == 'splitLine') {
this.lines.push( (tabVal + tabContent) + (templateItem.value?.toString() || ''))
}
if (Array.isArray(templateItem.children) && templateItem.children.length > 0) {
// 子节点 内容
for (const kid of templateItem.children) {
await this.doCncTemplate(kid, level + 1)
}
}
/** 结尾 */
let endCode = templateItem.templateEndType == TemplateEndTargetType.DoubleEnd ? `</ ${templateItem.templateName}>` : ''
if(endCode){
if (endCode && lineType == 'splitLine') {
this.lines.push((tabVal + endCode))
}
}
recordAction(type: CncActionType): string {
@@ -92,6 +131,13 @@ export class CncConverter implements ICncWriter {
return markContent + this.config.lineBreak
}
createTemplate() {
}
toString(){
return this.lines.join('\n')
}
}
export interface ICncWriter {
@@ -102,21 +148,30 @@ export interface CncAction {
readonly id: string;
readonly type: CncActionType;
readonly lineIndex: number;
// parent: CncAction;
// children: CncAction[]
}
export type CncActionType = string
export type CncTemplateParams = {
export class CncTemplateParams {
/** 标签名 */
templateName: string
templateName: string = ''
/** 属性列表 */
propertyList: CncTemplatePropertyType[]
propertyList: CncTemplatePropertyType[] = []
/** 子标签 */
children?: CncTemplateParams[]
children?: CncTemplateParams[] = []
/** 标签结束方式 */
templateEndType?: TemplateEndTargetType
templateEndType?: TemplateEndTargetType = TemplateEndTargetType.DoubleEnd
/** 标签内的值 */
value?: string | number | boolean
/** 添加子集 */
appendChildren(CncTemplateParams: CncTemplateParams) {
this.children?.push(CncTemplateParams)
}
/**添加属性 */
appendProperty(propertyItem: CncTemplatePropertyType) {
this.propertyList.push(propertyItem)
}
}
export interface CncTemplatePropertyType {

View File

@@ -0,0 +1,26 @@
import { CncConverter, CncTemplateParams, TemplateEndTargetType } from "./CncConverter"
/**
* XML格式(王石)
* // 对接业务口 还在构思写
*/
export class CncManager_XML_WS {
cncData: CncTemplateParams[] = []
cncWriter: CncConverter
constructor() {
this.cncWriter = new CncConverter()
this.main()
}
main(){
let mainTemplateParams = new CncTemplateParams()
mainTemplateParams.templateName = 'KDTPanelFormat'
mainTemplateParams.templateEndType = TemplateEndTargetType.DoubleEnd
}
createTemplateParams() {
let params = new CncTemplateParams()
return params
}
}

View File

@@ -0,0 +1,163 @@
"<KDTPanelFormat>
<CoordinateSystem>3</CoordinateSystem>
<Inch>0</Inch>
<Params>
<Param Value=""600.00"" Comment="""" Key=""L""/>
<Param Value=""400.00"" Comment="""" Key=""W""/>
<Param Value=""18.00"" Comment="""" Key=""T""/>
</Params>
<PANEL>
<PanelLength>600</PanelLength>
<PanelWidth>400</PanelWidth>
<PanelThickness>18</PanelThickness>
<PanelName>立板</PanelName>
<PanelOrderName>测试范例</PanelOrderName>
<PanelMaterial>颗粒板 - 暖白</PanelMaterial>
<PanelTexture>0</PanelTexture>
<PanelQuantity>1</PanelQuantity>
<PanelOutline>
<Vertex>
<X1>600.00</X1>
<Y1>0.00</Y1>
<Bulge>0.00</Bulge>
<Banding>0.60</Banding>
<Description>薄边0.6mm</Description>
<BandingColor>rgb(0,255,0)</BandingColor>
<DescriptionColor>rgb(0,255,0)</DescriptionColor>
</Vertex>
<Vertex>
<X1>600.00</X1>
<Y1>400.00</Y1>
<Bulge>0.00</Bulge>
<Banding>0.00</Banding>
<Description>不封边</Description>
<BandingColor>rgb(0,0,0)</BandingColor>
<DescriptionColor>rgb(0,0,0)</DescriptionColor>
</Vertex>
<Vertex>
<X1>0.00</X1>
<Y1>400.00</Y1>
<Bulge>0.00</Bulge>
<Banding>0.60</Banding>
<Description>薄边0.6mm</Description>
<BandingColor>rgb(0,255,0)</BandingColor>
<DescriptionColor>rgb(0,255,0)</DescriptionColor>
</Vertex>
<Vertex>
<X1>0.00</X1>
<Y1>0.00</Y1>
<Bulge>0.00</Bulge>
<Banding>1.20</Banding>
<Description>厚边1.20mm</Description>
<BandingColor>rgb(255,0,0)</BandingColor>
<DescriptionColor>rgb(255,0,0)</DescriptionColor>
</Vertex>
</PanelOutline>
</PANEL>
<CAD>
<TypeNo>1</TypeNo>
<TypeName>Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>34.00</X1>
<Y1>50.00</Y1>
<Depth>13.50</Depth>
<Diameter>15.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>1</TypeNo>
<TypeName>Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>34.00</X1>
<Y1>350.00</Y1>
<Depth>13.50</Depth>
<Diameter>15.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>8</TypeNo>
<TypeName>Back Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>350.00</X1>
<Y1>50.00</Y1>
<Depth>13.50</Depth>
<Diameter>10.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>8</TypeNo>
<TypeName>Back Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>400.00</X1>
<Y1>50.00</Y1>
<Depth>13.50</Depth>
<Diameter>10.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>8</TypeNo>
<TypeName>Back Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>450.00</X1>
<Y1>50.00</Y1>
<Depth>13.50</Depth>
<Diameter>10.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>8</TypeNo>
<TypeName>Back Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>350.00</X1>
<Y1>350.00</Y1>
<Depth>13.50</Depth>
<Diameter>10.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>8</TypeNo>
<TypeName>Back Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>400.00</X1>
<Y1>350.00</Y1>
<Depth>13.50</Depth>
<Diameter>10.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>8</TypeNo>
<TypeName>Back Vertical Hole</TypeName>
<HoleType>0</HoleType>
<X1>450.00</X1>
<Y1>350.00</Y1>
<Depth>13.50</Depth>
<Diameter>10.00</Diameter>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>2</TypeNo>
<TypeName>Horizontal Hole</TypeName>
<Quadrant>2</Quadrant>
<X1>0.00</X1>
<Y1>50.00</Y1>
<Z1>9.00</Z1>
<Depth>34.00</Depth>
<Diameter>8.00</Diameter>
<HoleNo>2</HoleNo>
<IntervalX>0.00</IntervalX>
<IntervalY>32.00</IntervalY>
<IntervalZ>0.00</IntervalZ>
<Enable>1</Enable>
</CAD>
<CAD>
<TypeNo>2</TypeNo>
<TypeName>Horizontal Hole</TypeName>
<Quadrant>2</Quadrant>
<X1>0.00</X1>
<Y1>350.00</Y1>
<Z1>9.00</Z1>
<Depth>34.00</Depth>
<Diameter>8.00</Diameter>
<Enable>1</Enable>
</CAD>
</KDTPanelFormat>

View File

@@ -0,0 +1,135 @@
/** 逻辑比较工具类 */
export class LogicHelper {
/**
* 都是 a 与 b 比较
* @param a 比较参数 a
* @param b 比较参数 B
* @param logicType 比较类型
* @returns boolean
*/
logicCompare(b: LogicInputType, a: LogicInputType, logicType: LogicalFilterType) {
let res = false
switch (logicType) {
case LogicalFilterType.equalTo:
res = this.equalTo(a, b)
break;
case LogicalFilterType.notEqualTo:
res = this.notEqualTo(a, b)
break;
case LogicalFilterType.moreThan:
if (this.isNumber(a) && this.isNumber(b)) {
res = this.moreThan(a, b)
} else {
console.warn('warn:logicCompare=>moreThan compare value is invalid;')
res = false
}
break;
case LogicalFilterType.moreThanEqualTo:
if (this.isNumber(a) && this.isNumber(b)) {
res = this.moreThanEqualTo(a, b)
} else {
console.warn('warn:logicCompare=>moreThanEqualTo compare value is invalid;')
res = false
}
break;
case LogicalFilterType.lessThan:
if (this.isNumber(a) && this.isNumber(b)) {
res = this.lessThan(a, b)
} else {
console.warn('warn:logicCompare=>lessThan compare value is invalid;')
res = false
}
break;
case LogicalFilterType.lessThanEqualTo:
if (this.isNumber(a) && this.isNumber(b)) {
res = this.lessThanEqualTo(a, b)
} else {
console.warn('warn:logicCompare=>lessThanEqualTo compare value is invalid;')
res = false
}
break;
case LogicalFilterType.include:
if (this.isString(a) && this.isString(b)) {
res = this.include(a, b)
} else {
console.warn('warn:logicCompare=>include compare value is invalid;')
res = false
}
break;
case LogicalFilterType.exclude:
if (this.isString(a) && this.isString(b)) {
res = this.exclude(a, b)
} else {
console.warn('warn:logicCompare=>exclude compare value is invalid;')
res = false
}
break;
default:
break;
}
return res
}
equalTo(a: LogicInputType, b: LogicInputType) {
return a == b
}
equalTo_strick(a: LogicInputType, b: LogicInputType) {
return a == b
}
notEqualTo(a: LogicInputType, b: LogicInputType) {
return a != b
}
notEqualTo_strick(a: LogicInputType, b: LogicInputType) {
return a !== b
}
moreThan(a: number, b: number) {
return a > b
}
moreThanEqualTo(a: number, b: number) {
return a >= b
}
lessThan(a: number, b: number) {
return a < b
}
lessThanEqualTo(a: number, b: number) {
return a <= b
}
include(a: string, b: string) {
return a.includes(b)
}
exclude(a: string, b: string) {
return !a.includes(b)
}
isNumber(val: LogicInputType) {
return typeof (val) == 'number'
}
isString(val: LogicInputType) {
return typeof (val) == 'string'
}
}
export type LogicInputType = string | number | boolean
/** 判定类型 */
export enum LogicalFilterType {
/**等于 */
equalTo = '=',
/** 不等于 */
notEqualTo = '!=',
/** 大于 */
moreThan = '>',
/** 大于等于 */
moreThanEqualTo = '>=',
/** 小于 */
lessThan = '<',
/** 小于等于 */
lessThanEqualTo = '<=',
/** 包含 */
include = 'include',
/** 不包含 */
exclude = 'exclude',
}

View File

@@ -0,0 +1,179 @@
import { KnifeSpindle, KnifeType, Knife } from "cut-abstractions";
import { LogicalFilterType, LogicHelper } from "../LogicHelper/LogicHelper";
export class ToolHelper extends LogicHelper {
tools: Tool[] = []
SpindleList: KnifeSpindle[] = []
initTools(tools: Tool[]) {
this.tools = tools
}
appendTools(tools: Tool[]) {
this.tools = this.tools.concat(tools)
}
appendKnife(knife: Tool) {
this.tools.push(knife)
}
/** 依据刀具属性 进行选刀 */
getKnife(params: KnifeParams, logical?: LogicalFilterType, tempKnifeList?: Tool[]) {
let logic = logical || LogicalFilterType.equalTo
let toolList = tempKnifeList || this.tools
let keys = Object.keys(params)
let resArr = toolList.filter(tool => {
let check = false
for (const key of keys) {
if ((params as any)[key] == undefined || (tool as any)[key] == undefined) {
check = false
} else {
if (key == 'type') {
/** 刀具类型部分的选刀 这里做个特殊处理 都用包含的 后续看情况再改 */
check = !(((tool as any)[key] & (params as any)[key]) == 0)
} else {
check = this.logicCompare((params as any)[key], (tool as any)[key], logic)
}
}
if (check == false) {
continue
}
}
return check
})
return resArr
}
}
/** 刀具参数 */
export type KnifeParams = Partial<Knife>
// export declare class Knife {
// /**刀ID */
// id: number;
// /**刀名称 */
// name?: string;
// /**轴ID旧名称axleID */
// spindleId?: number;
// private _spindle?;
// /**
// * 刀主轴
// */
// get spindle(): KnifeSpindle | undefined;
// /**
// * 设置刀主轴
// */
// set spindle(value: KnifeSpindle | undefined);
// /**
// * 刀类型,可复选
// */
// type: KnifeType[];
// /**刀直径mm */
// diameter: number;
// /**最大深度 */
// length: number;
// /**偏移X */
// offsetX: number;
// /**偏移Y */
// offsetY: number;
// /**偏移Z */
// offsetZ: number;
// /**v型刀 角度 */
// vKnifeAngle: number;
// /**刀运行速度 0为取系统默认 */
// speed: number;
// /**下刀步进,0为不启用,例加工深度12步进5。实际加工为 5,5,2 */
// depthStep: number;
// /**刀启动代码*/
// startCode: string;
// /**刀停止代码 */
// stopCode: string;
// /**板外下刀 */
// isOffBorderCut: boolean;
// }
export class Tool extends Knife {
// /**刀ID */
// id: number;
// /**刀名称 */
// name?: string;
// /**轴ID旧名称axleID */
// spindleId?: number;
// private _spindle?: KnifeSpindle;
// /**
// * 刀主轴
// */
// /**
// * 刀主轴
// */
// get spindle(): KnifeSpindle | undefined {
// return this._spindle
// }
// /**
// * 设置刀主轴
// */
// set spindle(value: KnifeSpindle | undefined) {
// this._spindle = value
// }
// /**
// * 刀类型,可复选
// */
// type: KnifeType[];
// /**刀直径mm */
// diameter: number;
// /**最大深度 */
// length: number;
// /**偏移X */
// offsetX: number;
// /**偏移Y */
// offsetY: number;
// /**偏移Z */
// offsetZ: number;
// /**v型刀 角度 */
// vKnifeAngle: number;
// /**刀运行速度 0为取系统默认 */
// speed: number;
// /**下刀步进,0为不启用,例加工深度12步进5。实际加工为 5,5,2 */
// depthStep: number;
// /**刀启动代码*/
// startCode: string;
// /**刀停止代码 */
// stopCode: string;
// /**板外下刀 */
// isOffBorderCut: boolean;
constructor(data?: any) {
super()
this.id = 0
this.diameter = 0
this.type = KnifeType.Cut //[KnifeType.Cut]
this.length = 30
this.offsetX = 0
this.offsetY = 0
this.offsetZ = 0
this.spindle = undefined
this.vKnifeAngle = 0
this.speed = 10000
this.depthStep = 0
this.startCode = ''
this.stopCode = ''
this.isOffBorderCut = false
if (data) {
for (const key in data) {
if (Reflect.has(this, key)) {
Reflect.set(this, key, data[key])
}
}
}
}
}