Jess功能扩展函数加载方法及应用

一一收稿日期:2014-10-17

基金项目:2010年度甘肃省属高校基本科研业务费专项资金资

助 往复式压缩机状态监测及RCM 技术研究 (甘财教[2010]176);流程工业企业级仿真及优化技术平台(2007AA04Z191)

作者简介:陈宏希(1970),男,陕西岐山人,2002年毕业于兰州大学信息科学与工程学院,硕士,副教授,主要研究方向为图像处理,模式识别,专家系统三

Jess 功能扩展函数加载方法及应用

陈宏希

(兰州石化职业技术学院电子电气工程系,兰州730060)

一一摘要:Jess 功能函数的扩展是使用Java 语言实现Userfunction 接口来完成的三实现该接口的Java 类的构造函数有默认或空参数的,也有带参数的三针对load -function 命令不能向Jess 中加载带参数构造函数的Java 类,且在加载多个默认或空参数构造函数的Java 类时略显冗繁的问题,提出无论实现Userfunction 接口的Java 类是何种构造函数,都可通过先期实现Jess 提供的Userpack-age 接口,再使用命令load -package 来完成Jess 功能扩展函数的加载,这为Jess 功能扩展函数提供了通用的二一次性整体加载的高效方法三该方法被应用在楼宇温度控制仿真系统的应用开发中三

关键词:Jess ;Java ;构造函数;功能扩展函数;加载

中图分类号:TP312一一文献标志码:A一一文章编号:1000-0682(2015)02-0108-04Methods and application of installing Jess extending functions into Jess

CHEN Hongxi

(Department of Electric &Electronic Engineering ,Lanzhou Petrochemical College of Vocational Technology ,Lanzhou 730060,China )

Abstract :The Java class which implements the Jess Userfunction interface can extend Jess function.

Some of these classes require constructor arguments,although the others don t require.If the method which installing the Java class into Jess is the Jess function call of load-function,then the Java class

which it requires constructor arguments will not be installed into Jess.At the same time,it will be tire-

some when many Java class installed into Jess by calling the Jess function load-function,even if these Ja-va classes don t require constructor arguments.In order to solve this problem,this paper proposes a uni-versal method which can install the Java classes into Jess.This method is composed of two parts:the first is implement the Jess interface of load-package,the second is calling Jess function load-package.This

method can install the Java classes together into Jess one at a time.This method is also applied in a building temperature control simulated system.

Key words :Jess;Java;constructor;extending function;install

0一引言

构造函数是类在创建对象时对对象进行初始化的;若构造函数含有参数,同一个类就可以创建初始状态或初始值不同的多个对象[1]三使用Java 语言实现Jess 对外提供的Userfunction 接口,可以扩展Jess 的功能函数三扩展的功能函数可以在Jess 命令

行提示符下,或者在Eclipse 开发环境中,使用Jess 命令load-function 进行加载三此种加载方式仅适用于实现Userfunction 接口的类中构造函数是默认构造函数,或者构造函数是空参数的情形[2-3]三当一个实现了Userfunction 接口的Java 类含有带参数的构造函数时,使用load-function 装载该类进入Jess 就行不通;另外,即使是默认构造函数或空参数构造函数的Java 类,当需要加载的Jess 功能扩展函数数量较多时,使用load-function 命令逐一进行加载,此做法固然可行,但效率不高且略显冗繁三针对此问题,该文提出通过使用Rete 类对象的addUserfunc-tion 方法,首先实现Jess 提供的Userpackage 接口,最后使用Jess 命令load-package 将多个Jess 功能扩展函数一次性整体加载进Jess 的方法,且无论实现接口Userfunction 的Java 类中构造函数是何种形

801四工业仪表与自动化装置一一一一一一一一一一一一一一一一2015年第2期

相关主题
相关文档
最新文档