2个不稳定版本

0.2.0 2024年4月20日
0.1.0 2024年4月18日

#288编程语言

每月46次下载

MIT 许可证

21KB
423

开发者信息

什么是Genesis2000?

  • Genesis2000是PCB行业的一款CAM软件,由以色列公司Frontline开发。
  • Genesis2000提供了一个丰富的二次开发接口,帮助我们自动化CAM操作,其中包括脚本开发支持。具体详情请参考官方Genesis2000脚本开发文档。

为什么提供Rust包?

  • Genesis2000官方提供的脚本开发接口只支持三种shell语言:csh、perl和tcl。许多不熟悉这些shell的开发者可能需要花费大量时间重新学习。
  • 用csh和perl等语言编写的脚本为纯文本,无法满足保密要求。如果使用原生的编译语言如Rust,可以保护源代码不被暴露。

如何使用?

使用

使用cargo创建一个新的脚本项目,例如,项目名称为demo

cargo new --bin demo

从命令行终端进入demo项目目录。

cd demo

将genesis2000依赖包添加到demo项目,在项目目录下运行以下Cargo命令

cargo add genesis2000

使用编辑器打开src/main.rs文件,并按以下方式编写代码

use std::collections::HashMap;

use genesis2000::{Genesis, InfoParamType};

fn main() {
    // Create a structure instance object of Genesis.
    let mut f = Genesis::new();
    // Demonstrate how to use the COM interface.
    f.COM("units,type=mm");
    // print results of COM
    println!("status: {}\ncomans: {}", f.STATUS, f.COMANS);
    f.COM("get_affect_layer");
    println!("status: {}\ncomans: {}", f.STATUS, f.COMANS);
    // Demonstrate how to get the coordinates of the point clicked by the mouse in the main graphic area.
    f.MOUSE("p Select a point on the screen");
    // f.MOUSEANS is a coordinate point
    println!("status: {}\nmouse: {}", f.STATUS, f.MOUSEANS);
    // Demonstrate how to get the coordinates of two diagonal points of a rectangular area selected by the mouse in the main graphic area.
    f.MOUSE("r Select an rectangle area on the screen");
    // f.MOUSEANS is two coordinate points
    println!("status: {}\nmouse: {}", f.STATUS, f.MOUSEANS);

    let params: HashMap<InfoParamType, String> = HashMap::<InfoParamType, String>::from([
        (InfoParamType::EntityType, String::from("matrix")),
        (InfoParamType::EntityPath, String::from("000/matrix")),
    ]);
    // Info is essentially a COM command. It is a powerful and complex command interface, so a separate encapsulation has been made. Here is a demonstration of how to use info.
    f.INFO(&params);
    // The results of info are divided into two categories, here we view all single-value results.
    f.print_doinfo_single_values();
    // The results of info are divided into two categories, here we view all array results.
    f.print_doinfo_array_values();
}

接口介绍

公共函数有

VON, VOF, SU_ON, SU_OFF, PAUSE, MOUSE, COM, AUX, and INFO

有关其他脚本开发帮助,请参阅官方Genesis2000帮助文档:0204.pdf。

依赖项

~2.2–3.5MB
~55K SLoC