GSP:使用JSP Servlet技术扩展G代码外文翻译资料

 2022-12-16 19:54:48

GSP: Extending G-Code Using JSP Servlet Technologies

Sean Nagle and Jeff Wiegley

Abstract: The G-Code Programming Language, introduced in the early 1960rsquo;s, continues to be used to program motions for modern Computer Numerical Controlled (CNC) Machines. Vendors augment the motion control commands with various macro languages and other rudimentary programming languages to provide for parametric and flexible CNC programming. More modern programming languages promise greater capability, standardization and better programming architectures. This paper introduces a method for combining standard G-Code commands with the programming power and features provided by the Java programming language in a vendor neutral solution. Java Servlet Technologies, such as Java Server Pages (JSP) and the Tomcat container, are adapted in order to provide advanced G-Code programming capability. Other work has been done to integrate internet technologies and CNC programming but use of Java Servlet Technology to generate dynamic G-Code and transmit it to a CNC controller is the authorrsquo;s innovation [1], [2], [3].

Index Terms: GSP, G-Code, servlets, JavaServer Pages

I. INTRODUCTION

This paper describes the development of G-CodeServer Pages (GSP). G-Code is the language of Computer Numerical Controlled (CNC) Machines. JavaServer Pages (JSP) is an extension of Java Servlet Technology to dynamically generate HTML. GSP uses JSP-like features to produce Servlets capable of generating dynamic G-Code. The resulting G-Code can be transmitted to any CNC controlled machine for execution.

Techniques for part programming on CNC include manual programming, proprietary macro programming languages, Automated Programming Tool (APT) and graphical CAD/CAM systems. Each style has its advantages and disadvantages.

Manual G-Code programming involves specifying each movement of the machine-tool as individual G-Code commands. This method is time-consuming, error prone and difficult to maintain. The G-Code programming language is not especially readable by humans. Its instructions are words cryptically encoded as a letter followed by one or more numbers. The G-Code instruction set is not Turingcomplete; lacking both conditional branching and arbitrary loop repetition. This prevents the implementation of advanced programming architectures which rely on loops, conditional branching, recursion and general arithmetic.

S. Nagle is a Masterrsquo;s student in the College of Engineering and Computer Science California State University, Northridge CA, 91330, USA sean.nagle.833@csun.edu.

J. Wiegley is an Assistant Professor with the Department of Computer Science, California State University Northridge, Northridge, CA 913308281, USA jeffw@csun.edu.

Vendors implement proprietary macro languages that are interpreted by their controls during G-Code execution to control program flow. These hybrid languages are an improvement by providing capabilities for loops, conditions, reusable subroutines and general arithmetic capabilities. Programming complicated or repetitive operations is made easier. The disadvantage to such hybrid languages are that they vary by manufacturer. Thus, the resulting programs lack portability.

Parametric programming techniques have a number of interesting and useful applications. This style of part programming uses a general purpose approach compared to manual programming. Developers write functions that accept a list of arguments. The arguments control the execution of these functions to produce variation in machining output. This is especially useful when a company produces a so called family of parts.

All of these styles of part programming suffer from language limitations or vendor independence. G-Code lacks the expressive quality of a modern programming language such as C, C or Java. Programmers are hindered by the lack of meaningful variable names and in many cases the number of variables that they have at their disposal.

APT is a part programming language that is nearly as old as NC machining itself. It was developed in the late 1950rsquo;s and early 1960rsquo;s at MIT [4]. The pioneers of NC machining realized that the programming of NC machines was going to be a difficult task and a major obstacle to the acceptance and development of the technology. Therefore,APT was developed in an attempt to overcome the limitations of G-Code difficulties.

In many ways, the designers of APT were very successful; much of their work is still in use in a slightly different form today. Many of todayrsquo;s graphical CAD/CAM systems use an APT-like back end. Almost all of these systems output data in the CLDATA format that was specified by the APT developers. The CLDATA is further processed by an application known as a post-processor that writes GCode specifically for the machine tool that will produce the parts [5].

The graphical nature of CAD/CAM is very well suited to the process of part design and fabrication. Using the data from a digital model to create tool paths is highly accurate and fast. Graphical displays can indicate potential errors in a virtual setting that can help avoid costly and dangerous accidents. CAM systems use post-processors to produce GCode suited to a particular vendorrsquo;s equipment. The expense, complexity and skill required of such systems is a drawback for such applications.

G-CodeServer Pages fits somewhere between the paramet ric programming style and the use of modern CAD/CAM systems. G-CodeServer Pages can be used directly by operators with programming skill to build reusable operations and rapid prototypes. G-CodeServer Pages can be used by CAM programs to produce more compact output in a vendor independent language. The post-processing for any single vendor or machine can be written as modules in the G-CodeServer Pages language using technolo

剩余内容已隐藏,支付完成后下载完整资料


GSP:使用JSP Servlet技术扩展G代码

Sean Nagle,Jeff Wiegley

摘要:20世纪60年代早期引入的G代码编程语言继续被用于编程现代计算机数控(CNC)机器的运动。供应商使用各种宏语言和其他基本编程语言来增强运动控制命令,以提供参数化和灵活的CNC编程。更现代的编程语言承诺提供更强大的功能,标准化和更好的编程架构。本文介绍了一种在供应商中立解决方案中将标准G代码命令与Java编程语言提供的编程能力和功能相结合的方法。 Java Servlet技术(例如Java Server Pages(JSP)和Tomcat容器)经过调整,以提供高级G代码编程功能。其他工作已经完成整合互联网技术和CNC编程,但使用Java Servlet技术生成动态G代码并将其传输到CNC控制器是作者的创新[1],[2],[3]。

索引术语:GSP,G代码,servlet,JavaServer Pages

1,导言

本文介绍了G-CodeServer Pages(GSP)的开发。 G-Code是计算机数控(CNC)机器的语言。 JavaServer Pages(JSP)是Java Servlet技术的扩展,用于动态生成HTML。 GSP使用类似JSP的功能来生成能够生成动态G代码的Servlet。 生成的G代码可以传输到任何CNC控制的机器上执行。

CNC上的零件编程技术包括手动编程,专有宏编程语言,自动编程工具(APT)和图形CAD / CAM系统。 每种风格都有其优点和缺点。

手动G代码编程涉及将机床的每个运动指定为单独的G代码命令。 该方法耗时,容易出错并且难以维护。 G-Code编程语言不是人类特别可读的。 其指令是密码编码为字母后跟一个或多个数字的单词。 G代码指令集不是Turingcomplete; 缺少条件分支和任意循环重复。 这阻止了依赖于循环,条件分支,递归和通用算法的高级编程体系结构的实现。

S. Nagle是加州州立大学工程与计算机科学学院的硕士生,美国加利福尼亚州Northridge,91330,sean.nagle.833 @ csi.edu。

J. Wiegley是加利福尼亚州立大学北岭分校计算机科学系助理教授,北岭,加利福尼亚州913308281,邮编:jeffw@csun.edu

供应商实施专有的宏语言,在G代码执行期间由其控件解释以控制程序流。 这些混合语言是一种改进,它提供了循环,条件,可重用子程序和通用算术功能的能力。 编写复杂或重复的操作变得更容易。 这种混合语言的缺点在于它们因制造商而异。 因此,由此产生的程序缺乏可移植性。

参数化编程技术具有许多有趣且有用的应用。 与手动编程相比,这种类型的零件编程使用通用方法。 开发人员编写接受参数列表的函数。 参数控制这些函数的执行以产生加工输出的变化。 当公司生产所谓的零件系列时,这尤其有用。

所有这些样式的零件编程都受到语言限制或供应商独立性的影响。 G-Code缺乏现代编程语言(如C,C 或Java)的表现力。 程序员受到缺乏有意义的变量名称的阻碍,并且在许多情况下,他们拥有的变量数量受到阻碍。

APT是一种零件编程语言,几乎与NC加工本身一样古老。 它是在20世纪50年代末和1960年代早期在麻省理工学院开发的[4]。 数控加工的先驱们意识到数控机床的编程将是一项艰巨的任务,也是技术接受和发展的主要障碍。 因此,开发APT是为了克服G-Code困难的局限性。

在许多方面,APT的设计者非常成功; 他们的大部分工作今天仍以略微不同的形式使用。 今天的许多图形CAD / CAM系统都使用类似APT的后端。 几乎所有这些系统都以APD开发人员指定的CLDATA格式输出数据。 CLDATA由称为后处理器的应用程序进一步处理,该应用程序专门为将生成部件的机床编写GCode [5]。

CAD / CAM的图形特性非常适合零件设计和制造过程。 使用来自数字模型的数据来创建工具路径非常准确且快速。 图形显示可以指示虚拟设置中的潜在错误,可以帮助避免代价高昂且危险的事故。 CAM系统使用后处理器来生成适合特定供应商设备的GCode。 这种系统所需的费用,复杂性和技能是这种应用的缺点。

G-CodeServer Pages介于参数编程风格和现代CAD / CAM系统之间。 G-CodeServer Pages可以由具有编程技能的操作员直接使用,以构建可重复使用的操作和快速原型。 CAM程序可以使用G-CodeServer Pages以独立于供应商的语言生成更紧凑的输出。 任何单个供应商或机器的后处理都可以使用JavaBeans等技术以G-CodeServer Pages语言编写为模块。 这使得生成的G-CodeServer Pages程序可移植。 另一个优点是,G-Code语言的灵活性提高使得手动编程更容易,可重复使用,并且对于那些缺乏昂贵的自动CAM程序的操作员而言不易出错。 供应商通过功能齐全的开源语言而不是维护自己的语言扩展的成本而受益。

2,java servlet技术

Servlet是在Java平台上开发的技术,用于扩展和改进Web服务器。 Servlet提供类似于CGI程序的功能。 Servlet旨在提供动态Web内容[6]。

还有其他现有技术能够执行类似于servlet的任务。 其中包括通用网关接口(CGI)和专有服务器扩展。 Netscape Server API和Apache Modules是后者的例子[6]。
与其他解决方案相比,Servlet具有几个明显的优势。 使用servlet的Web应用程序往往比使用CGI的Web应用程序更快。 Servlet倾向于使用多线程,这通常比使用CGI [7]通常使用的fork()范例更有效地使用系统资源。

servlet编程的另一个优点是servlet使用许多可用Web服务器支持的标准API。 CGI通常使用C和PERL编程的组合。 虽然这些也得到广泛支持,但这些程序通常不是标准化的。 此外,servlet程序员可以使用丰富的API来进行应用程序开发[7]。
由于servlet是使用Java编程的,因此servlet本身与平台无关。 这种可移植性是servlet相对于CGI和专有服务器扩展的另一个优势[7]。

术语“ServletTechnology”包含以下领域:

bull;JavaServer Pages:用于表示动态生成所需内容所需的步骤和决策的编程语言。
bull;Servlets:由容器执行的已编译的代码包,用于生成内容。 它们可以编程为执行各种任务,例如查询数据库或跟踪在线购物车。 它们特别有用,擅长创建动态的交互式网页。
bull;Web容器:管理servlet执行的程序或服务。 Web容器可以作为Web服务器的一部分内置,也可以作为附加应用程序安装[6]。
bull;Web服务器:与客户端交互以传递容器和请求的servlet生成的内容的应用程序。 根据最近的一项调查[8],Apache和Microsoft IIS是最受欢迎的服务器应用程序之一。

JavaServer Pages是一种技术,可以使servlet的编程更简单。 JavaServer Pages是源文件的高级编程语言结构,使servlet的规范,体系结构和创建变得容易。 JavaServer Pages用于将动态内容和模板文本一起提供给请求资源的客户端[9]。
JSP源文件由模板文本,scriptlet,表达式,usebean或include等标记组成。 JSP和PHP通常被认为是内容和表示分离的良好示例。内容的操作由Java语言和有能力的程序员处理,而演示文稿由Web设计者以HTML编码。可以将Java编程代码与HTML代码混合。 Java代码提供动态执行和内容生成,而HTML代码以浏览器理解的方式提供表示层[9]。
G-Code和CNC机器似乎呈现出类似的环境。这些机器只能理解G-Code,但是需要具备全功能的编程功能和生成动态执行的能力。创建一种新类型的servlet是有意义的,它允许程序员以与JSP使用的方式相同的方式将Java编程语言与G-Code命令混合以解决HTML生成。依赖Tomcat服务器/容器的存在提供了一个强大的基础,可以通过修改来解析和处理G-CodeServer Pages文件。由于与CNC机器的交互不同于为HTML浏览器和服务器定义的交互,因此新行为被定义为处理G代码程序的输入和输出要求。

在Tomcat中,存在一个名为Jasper的包。 Jasper由一组类组成,这些类处理JSP源文件到Java程序源文件的转换,编译和执行。如果转换完成且没有错误,Jasper会尝试将JavaServer Pages编译为servlet。如果编译成功,Jasper会在编译的servlet中调用一个方法来执行它,并将结果输出传递回客户端的浏览器。
JavaServer Pages的一个重要方面是它能够使用JavaBeans。 JavaBeans是特殊的Java程序,必须遵守关于它们如何提供对它们包含的数据的访问的某些规则。它们提供了一种强大,灵活的方式来生成模块化,可重用的代码[9]。
GSP是使用Apache Tomcat servlet容器[10]开发的.Tomcat包含几个项目或包,包括Catalina,Coyote和Jasper。 Catalina是Web容器,Coyote是HTTP连接器,用于处理与客户端之间的请求传输,Jasper负责将JSP文件动态转换为servlet以供Catalina处理。
有关安装和运行Tomcat的详细说明与本文无关,但可以从The Apache Software Foundation [10]获得。但是,有一些安装细节将有助于理解。这些都是在这里描述的简洁。
Web应用程序是Tomcat可能收到请求的资源集合。资源包括HTML网页,JavaServer Pages和图像文件等项目。 Web应用程序部署在安装Tomcat的目录下的特定目录结构中。

部署在Tomcat中的Web应用程序位于webapps子目录中。 webapps的子目录称为Web应用程序的Context根。
在Web应用程序的上下文根中是名为WEB-INF的文件夹。在这里,开发人员可以在称为部署描述符的特殊文件中为应用程序指定自定义配置选项。组成应用程序的已编译Java类文件存储在WEB-INF目录中名为classes的目录中。
每个Web应用程序都需要具有部署描述符。这是一个名为web.xml的文件。在这个文件中,开发人员可以指定应用程序如何响应不同类型的请求。当Tomcat启动时,它会读取所有部署的应用程序的所有部署描述符。当收到的请求与其中一个部署描述符中指定的模式匹配时,Tomcat会实例化一个请求和响应对象,并将它们传递给相应的Web应用程序进行处理。

3, GSP

到目前为止,已经讨论过CNC技术以及Java Servlet技术。 以下部分描述了如何合并这两种技术以生成G-CodeServer Pages(GSP)。
G-CodeServer Pages基于JavaServer Pages。 JavaServer Pages的行为与CNC机器的G代码宏/脚本语言之间存在关联。 JavaServer Pages的一个好处是HTML的“内容”和“逻辑”之间的分离。 G代码命令对应于JSP的固定模板文本(HTML)。 G-Code字的值部分对应于JSP的动态内容。

G-CodeServer Pages的目标之一是为G-Code程序的开发提供更灵活,更强大,通用的编程环境。 每个NC控件都可以拥有自己专有的宏语言。 这使得混合G代码语言不可移植。 G-CodeServer Pages由主机生成,并作为标准G代码送入NC机器。 由于结果不包含宏或混合语言命令,并且机器相关命令可以编码为G-CodeServer Pages模块或JavaBeans,因此G-CodeServer Pages程序是可移植的。 例如,程序员希望机床从当前刀具位置到点(5,2.1,-3.2)执行线性解释。 执行此操作的标准G代码指令将是G1 X5. Y2.1 Z-3.2。使用G-CodeServer Pages,操作员可以使用清单1中的代码。清单1. G-CodeServer页面代码示例,

lt;%

double myx = 5;

double myy = 2.1;

double myz = -3.2;

%gt;

G1 Xlt;%=myx%gt; Ylt;%=myy%gt; Zlt;%=myz%gt;

执行GSP后,无论机器执行的是什么,其输出都将读取G1 X5.0 Y2.1 Z-3.2。其他依赖于机器的命令(例如工具或夹具更改)可以作为JavaBean类库来解释。由此产生的机器特定指令将通过RS-232电缆或磁存储器发送到机床,并执行。
尽管这个例子可能是微不足道的,但可以想象类似的代码作为较大程序的一部分,其中分配给变量的值不是硬编码的,因为它们在这里,而是由一些编程逻辑动态计算。稍后,将介绍GSP的更详细示例。
G-CodeServer Pages的处理应该允许参数能够动态地改变。 RS274 / NGC提供了5400个参数的编号表,其中一些参数可供程序员用作程序中的变量。但是,变量的名称是表[11]中的数字。将变量名称限制为数字会鼓励令人困惑,有限且容易出错的编程。良好编程的原则之一是使用描述性变量名来使代码更具可读性。

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[19627],资料为PDF文档或Word文档,PDF文档可免费转换为Word

您需要先支付 30元 才能查看全部内容!立即支付

发小红书推广免费获取该资料资格。点击链接进入获取推广文案即可: Ai一键组稿 | 降AI率 | 降重复率 | 论文一键排版