Compare commits
	
		
			14 Commits
		
	
	
		
			0.3
			...
			1d84eb0d35
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1d84eb0d35 | |||
| 0e107da21b | |||
| edc1188a2b | |||
| 8df9f5d17a | |||
| 31ae0be530 | |||
| ac1e32218b | |||
| 290bbf2b5e | |||
| f1a9a6ba5e | |||
| 3966b86256 | |||
| 7cf184f4c3 | |||
| e8cbdf0abc | |||
| 4f50e3e49e | |||
| 5872b91606 | |||
| 147df79e44 | 
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cut-abstractions",
 | 
			
		||||
  "version": "0.3.0",
 | 
			
		||||
  "version": "0.3.4",
 | 
			
		||||
  "description": "",
 | 
			
		||||
  "files": [
 | 
			
		||||
    "dist/**/*"
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@ export * from './models/file';
 | 
			
		||||
export * from './models/processors/rectLayout';
 | 
			
		||||
export * from './models/processors/cutOrder';
 | 
			
		||||
export * from './models/processItem';
 | 
			
		||||
export * from './models/processors/modelProcessPoints'
 | 
			
		||||
export * from './models/processors/cutPoint'
 | 
			
		||||
export * from './models/processors/holeToModel'
 | 
			
		||||
export * from './models/processors/modelProcessPoints';
 | 
			
		||||
export * from './models/processors/cutPoint';
 | 
			
		||||
export * from './models/processors/holeToModel';
 | 
			
		||||
export * from './nc/ncWriter';
 | 
			
		||||
@@ -10,7 +10,7 @@ import { ConfigBase } from "../config";
 | 
			
		||||
 *
 | 
			
		||||
 *  注:20250730 暂无配置 留个位置
 | 
			
		||||
 */
 | 
			
		||||
export class CutorderConfig extends ConfigBase {
 | 
			
		||||
export class CutOrderConfig extends ConfigBase {
 | 
			
		||||
    // [key:string] : any
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -20,24 +20,24 @@ export class CutorderConfig extends ConfigBase {
 | 
			
		||||
export type CutOrderInput = {
 | 
			
		||||
    /**开料大板 宽 */
 | 
			
		||||
    boardWidth: number,
 | 
			
		||||
    /** 开料大板 高 */
 | 
			
		||||
    boardHeight: number,
 | 
			
		||||
    /** 开料大板 长 */
 | 
			
		||||
    boardLength: number,
 | 
			
		||||
    /** 刀头大小(含修边)  */
 | 
			
		||||
    gap: number,
 | 
			
		||||
    /** 小板数据集合 */
 | 
			
		||||
    blocks: CutorderInputBlock[]
 | 
			
		||||
    blocks: CutOrderInputBlock[]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 处理器输出数据 开料顺序(新)  
 | 
			
		||||
 */
 | 
			
		||||
export type CutorderOutput = {
 | 
			
		||||
    blocks: CutorderoutputBlock[]
 | 
			
		||||
export type CutOrderOutput = {
 | 
			
		||||
    blocks: CutOrderoutputBlock[]
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * 小板类型 输入
 | 
			
		||||
 */
 | 
			
		||||
export type CutorderInputBlock = {
 | 
			
		||||
export type CutOrderInputBlock = {
 | 
			
		||||
    /** 小板唯一标识  */
 | 
			
		||||
    id: string | number,
 | 
			
		||||
    /** 排版长 */
 | 
			
		||||
@@ -52,6 +52,6 @@ export type CutorderInputBlock = {
 | 
			
		||||
/**
 | 
			
		||||
 * 小板类型 输出
 | 
			
		||||
 */
 | 
			
		||||
export type CutorderoutputBlock = CutorderInputBlock & {
 | 
			
		||||
    cutOrder: number
 | 
			
		||||
export type CutOrderoutputBlock = CutOrderInputBlock & {
 | 
			
		||||
    CutOrder: number
 | 
			
		||||
}
 | 
			
		||||
@@ -17,9 +17,10 @@ export type HoleToModelOutput = {
 | 
			
		||||
    /** 孔转造型 后的 造型数据 */
 | 
			
		||||
    modelData: HoleToModelProcessingItem[],
 | 
			
		||||
    /** 未处理的孔数据 以及信息 */
 | 
			
		||||
    noHandleItem: noHandleItemType[]
 | 
			
		||||
    noHandleItem: NoHandleItemType[]
 | 
			
		||||
}
 | 
			
		||||
export type noHandleItemType = {
 | 
			
		||||
/** 孔转造型 未处理的数据 */
 | 
			
		||||
export type NoHandleItemType = {
 | 
			
		||||
    /** 未处理的孔信息 */
 | 
			
		||||
    holeData: HoleToModelProcessingItem,
 | 
			
		||||
    /** 未处理 说明 */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,53 @@
 | 
			
		||||
import { Knife } from "../models/knife";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * NC代码构建器接口,实现该接口来定义一个处理器用的NC代码构建器
 | 
			
		||||
 * @author CZY
 | 
			
		||||
 * @since 0.3.0
 | 
			
		||||
 * @version 0.1.2
 | 
			
		||||
 */
 | 
			
		||||
export interface INcWriter {
 | 
			
		||||
    get ncActions(): NcAction[];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 写入G代码或解析一条自定义代码
 | 
			
		||||
     * @example
 | 
			
		||||
     * gCode('G0', { x: 0, y: 0, z: 0, f: 25000 });
 | 
			
		||||
     * gCode('CArc', { x: 0, y: 0, z: 0, b: 1, f: 25000 });
 | 
			
		||||
     */
 | 
			
		||||
    gCode<TCode extends (keyof typeof GCode | keyof typeof CCode)>(code: TCode, params: Partial<TCode extends keyof typeof GCode ? GCodeParams : CCodeParams>): void;
 | 
			
		||||
 | 
			
		||||
    /** 基于刀具实体执行换刀操作 */
 | 
			
		||||
    changeKnife(knife: Knife): void;
 | 
			
		||||
 | 
			
		||||
    /** 添加一行注释 */
 | 
			
		||||
    comment(content: string): void;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 记录一次NC加工操作
 | 
			
		||||
     * 
 | 
			
		||||
     * NC加工操作指的是一次完整的加工过程,例如一次排钻,一次造型切割,或是一次小板加工
 | 
			
		||||
     * 
 | 
			
		||||
     * 一次NC加工操作可能包含多行的GCode
 | 
			
		||||
     * 
 | 
			
		||||
     * 该方法旨在为NC文件提供记录加工步骤的能力
 | 
			
		||||
     * 
 | 
			
		||||
     * 返回本次NC操作的ID,此ID由内部生成
 | 
			
		||||
     * @param type NC操作类型
 | 
			
		||||
     * @returns 本次NC操作的ID
 | 
			
		||||
     */
 | 
			
		||||
    recordAction(type: NcActionType): string;
 | 
			
		||||
 | 
			
		||||
    /** 直接在末尾追加任意字符串 */
 | 
			
		||||
    append(str: string): void;
 | 
			
		||||
 | 
			
		||||
    /** 直接在末尾追加一行任意字符串 */
 | 
			
		||||
    appendLine(str: string): void;
 | 
			
		||||
 | 
			
		||||
    /** 返回当前构建的NC代码 */
 | 
			
		||||
    toString(): string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 基础G代码 */
 | 
			
		||||
export const GCode = {
 | 
			
		||||
    /**
 | 
			
		||||
@@ -55,7 +103,23 @@ export const GCode = {
 | 
			
		||||
    G3: 'G3',
 | 
			
		||||
} as const;
 | 
			
		||||
 | 
			
		||||
/**  */
 | 
			
		||||
/** 自定义数控代码,由内部解析并实现,不直接输出给设备 */
 | 
			
		||||
export const CCode = {
 | 
			
		||||
    /**
 | 
			
		||||
     * 自动圆弧插补
 | 
			
		||||
     * @param X X 坐标
 | 
			
		||||
     * @param Y Y 坐标
 | 
			
		||||
     * @param Z Z 坐标
 | 
			
		||||
     * @param B Bulge圆弧凸度,表示圆弧所包含角度的四分之一的正切值。当B=0时,圆弧为直线,当B>0时,圆弧为顺时针圆弧,当B<0时,圆弧为逆时针圆弧 (所谓“顺时针”和“逆时针”是指从起始点到结束点的绘制角度)
 | 
			
		||||
     * @description 使用此命令时,X, Y, Z作为圆弧的结束点,当前刀具的位置作为起始点。
 | 
			
		||||
     * @example
 | 
			
		||||
     * FROM: CArc X0 Y10 Z0 B1
 | 
			
		||||
     * TO: G2 X0 Y10 R5  
 | 
			
		||||
     */
 | 
			
		||||
    CArc: 'CArc',
 | 
			
		||||
} as const;
 | 
			
		||||
 | 
			
		||||
/** NC GCode 参数结构 */
 | 
			
		||||
export class GCodeParams {
 | 
			
		||||
    /** X坐标值 mm */
 | 
			
		||||
    x: number = 0;
 | 
			
		||||
@@ -73,6 +137,20 @@ export class GCodeParams {
 | 
			
		||||
    f: number = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** 自定义数控代码参数结构 */
 | 
			
		||||
export class CCodeParams {
 | 
			
		||||
    /** X坐标值 mm */
 | 
			
		||||
    x: number = 0;
 | 
			
		||||
    /** Y坐标值 mm */
 | 
			
		||||
    y: number = 0;
 | 
			
		||||
    /** Z坐标值 mm */
 | 
			
		||||
    z: number = 0;
 | 
			
		||||
    /** 使用自动圆弧(CArc)命令时,定义圆弧凸度 */
 | 
			
		||||
    b: number = 0;
 | 
			
		||||
    /** 给进速度(Feed Rate) mm/min */
 | 
			
		||||
    f: number = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 单次NC加工行为 */
 | 
			
		||||
export interface NcAction {
 | 
			
		||||
    readonly id: string;
 | 
			
		||||
@@ -80,47 +158,4 @@ export interface NcAction {
 | 
			
		||||
    readonly lineIndex: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type NcActionType = string;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * NC代码构建器接口,实现该接口来定义一个处理器用的NC代码构建器
 | 
			
		||||
 * @author CZY
 | 
			
		||||
 * @since 0.3.0
 | 
			
		||||
 * @version 0.1.0
 | 
			
		||||
 */
 | 
			
		||||
export interface INcWriter {
 | 
			
		||||
    get ncActions(): NcAction[];
 | 
			
		||||
 | 
			
		||||
    /** 添加G代码 */
 | 
			
		||||
    gCode(code: keyof typeof GCode, params: Partial<Pick<GCodeParams, 'x' | 'y' | 'z' | 'f'> & { bul: number; }>): void;
 | 
			
		||||
 | 
			
		||||
    /** 基于刀具实体执行换刀操作 */
 | 
			
		||||
    changeKnife(knife: Knife): void;
 | 
			
		||||
 | 
			
		||||
    /** 添加一行注释 */
 | 
			
		||||
    comment(content: string): void;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 记录一次NC加工操作
 | 
			
		||||
     * 
 | 
			
		||||
     * NC加工操作指的是一次完整的加工过程,例如一次排钻,一次造型切割,或是一次小板加工
 | 
			
		||||
     * 
 | 
			
		||||
     * 一次NC加工操作可能包含多行的GCode
 | 
			
		||||
     * 
 | 
			
		||||
     * 该方法旨在为NC文件提供记录加工步骤的能力
 | 
			
		||||
     * 
 | 
			
		||||
     * 返回本次NC操作的ID,此ID由内部生成
 | 
			
		||||
     * @param type NC操作类型
 | 
			
		||||
     * @returns 本次NC操作的ID
 | 
			
		||||
     */
 | 
			
		||||
    recordAction(type: NcActionType): string;
 | 
			
		||||
 | 
			
		||||
    /** 直接在末尾追加任意字符串 */
 | 
			
		||||
    append(str: string): void;
 | 
			
		||||
 | 
			
		||||
    /** 直接在末尾追加一行任意字符串 */
 | 
			
		||||
    appendLine(str: string): void;
 | 
			
		||||
 | 
			
		||||
    /** 返回当前构建的NC代码 */
 | 
			
		||||
    toString(): string;
 | 
			
		||||
}
 | 
			
		||||
export type NcActionType = string;
 | 
			
		||||
		Reference in New Issue
	
	Block a user