在MATLAB中调用用户定义的Java类

时间:2014-06-14 17:17:41

标签: java matlab function undefined

您好我试图从MATLAB调用JAVA中定义的类文件。但是我得到错误未定义的函数或变量。我正在粘贴我尝试使用的类文件的源代码:

package fbdk.socket;

import fb.rt.FBRManagementException;
import fb.rt.EventServer;
import fb.rt.AbstractEvent;
import fb.datatype.REAL;
import fb.datatype.WSTRING;
import fb.datatype.ANY;
import fb.rt.net.SERVER;
import fb.datatype.FBDataTypeException;

public class SENDER {

/* initializing the server FB and the variable to be used.*/
final SERVER server2= new SERVER(1,0);
REAL sd1= new REAL();
public static String CHANNEL_ID;
public float x;

public SENDER()
{
/*Initialize the service*/
try
{
 server2.QI.value= true;
 server2.ID.value= CHANNEL_ID;
 server2.INIT.serviceEvent(null);
}

catch(Exception e1)
{
e1.getMessage();    
}
/* connecting the I/O*/
 try
    {
       server2.connectIV("SD_1", sd1);
        }
         catch (FBRManagementException e)
         {
             System.out.println(e);
         }


 /* Define handling for the INITO event*/
        final EventServer initoServer= new AbstractEvent(){
            public void serviceEvent(EventServer e){
        /*print in IEC 61499 service primitive format*/
    System.out.println("INITO(QO="+server2.QO+",STATUS="+server2.STATUS);
    }
        };
        server2.INITO.connectTo(initoServer);

/* define handling for the IND event. */             
final EventServer indServer= new AbstractEvent(){

public void serviceEvent(EventServer e){
    initoServer.serviceEvent(e);

    sd1.value=x;
/* print in IEC 61499 service primitive format*/
System.out.println("IND(QO="+server2.QO+",STATUS="+server2.STATUS);
server2.RSP.serviceEvent(null);
server2.QI.value= false;
server2.INIT.serviceEvent(null);

}
};
server2.IND.connectTo(indServer);




}       




}

只是简单介绍一下:此代码中使用的对象和方法是从另一个用户定义的库(fbrt.jar)导入的。我可以在MATLAB中导入它,但不能导入程序SENDER的类文件。我创建了一个用户定义类的JAR文件并将其放在动态路径中,但它仍然无法识别类SENDER的对象。我已经被困在这几天了,而且无法弄清楚我哪里出错了。

0 个答案:

没有答案