优化NCWriter参数格式和用法 #15
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cut-abstractions",
 | 
			
		||||
  "version": "0.3.2",
 | 
			
		||||
  "version": "0.3.3",
 | 
			
		||||
  "description": "",
 | 
			
		||||
  "files": [
 | 
			
		||||
    "dist/**/*"
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,18 @@ import { Knife } from "../models/knife";
 | 
			
		||||
 * NC代码构建器接口,实现该接口来定义一个处理器用的NC代码构建器
 | 
			
		||||
 * @author CZY
 | 
			
		||||
 * @since 0.3.0
 | 
			
		||||
 * @version 0.1.1
 | 
			
		||||
 * @version 0.1.2
 | 
			
		||||
 */
 | 
			
		||||
export interface INcWriter {
 | 
			
		||||
    get ncActions(): NcAction[];
 | 
			
		||||
 | 
			
		||||
    /** 添加G代码 */
 | 
			
		||||
    gCode<TCode extends keyof typeof GCode & keyof typeof CCode>(code: TCode, params: Partial<TCode extends keyof typeof GCode ? GCodeParams : CCodeParams>): void;
 | 
			
		||||
    /**
 | 
			
		||||
     * 写入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;
 | 
			
		||||
@@ -106,9 +111,13 @@ export const CCode = {
 | 
			
		||||
     * @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 {
 | 
			
		||||
@@ -138,6 +147,8 @@ export class CCodeParams {
 | 
			
		||||
    z: number = 0;
 | 
			
		||||
    /** 使用自动圆弧(CArc)命令时,定义圆弧凸度 */
 | 
			
		||||
    b: number = 0;
 | 
			
		||||
    /** 给进速度(Feed Rate) mm/min */
 | 
			
		||||
    f: number = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** 单次NC加工行为 */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user