这是我自学程序以来在博客园的第一篇博客,如有不好的地方请大家指正,谢谢!
这边文章的目的是给予那些在PCB使用Genesis2000程序脚本开发的人员提供.net平台下的开发方法。
目前genesis脚本的开发的语言主要为cshell,perl和tcl,相对于学过c#的人需要学习成本,我打听过用C#开发脚本的接口的价格最少都需要1000块钱,本着开源的思想我吧这几天研究的成果公布发表给大家!
1.genesis脚本的运行机制(这里拿cshell来说),(以我的电脑来举例子)首先程序要运行c:\genesis\e100\all\scr_start.csh,然后运行c:\genesis\sys\hooks\script_start.csh,最后再运行脚本;
详细看附件
2.不管怎么样子的脚本都是基于命令行的,如windows上的cmd;
知道了这两个条件下面我们开始编写genesis辅助类
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
public class Genesis
{
public string prefix, lmc, msg;
public string READANS, COMANS, PAUSANS, MOUSEANS;
public int STATUS=0;
public System.IO.StreamReader conv;
public System.IO.StreamReader @in;
public Genesis()
{
//exe程序发送指令需要以这个字符串开头,genesis才会识别
this.prefix = "@%#%@";
this.blank();
return;
}
public virtual void blank()
{
this.STATUS = 0;
this.READANS = "";
this.COMANS = "";
this.PAUSANS = "";
this.MOUSEANS = "";
return;
}
/// <summary>
/// 执行指令
/// </summary>
/// <param name="cmd"></param>
/// <param name="arg"></param>
/// <returns></returns>
public virtual int sendCmd(string cmd, string arg)
{
this.blank();
this.lmc = this.prefix + cmd + " " + arg + "\n";
Console.Write(this.lmc);
return 0;
}
/// <summary>
/// 执行genesis2000 line mode command动作
/// </summary>
/// <param name="arg">指令</param>
/// <returns></returns>
public virtual int COM(string arg)
{
this.sendCmd("COM", arg);
try
{
int.TryParse(Console.ReadLine(),out STATUS);
this.COMANS = Console.ReadLine();
this.READANS = this.COMANS;
}
catch (IOException e)
{
Console.WriteLine("IO Error: " + e.Message);
}
return this.STATUS;
}
/// <summary>
/// 用于暂停当前运行程序,等待用户做其它动作后继续执行程序或无条件退出程序。
/// </summary>
/// <param name="msg"></param>