Saarland University
Lehrstuhl für Automatisierungstechnik

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Java/Dymola Interfacing, Details of calling Java from Dymola
cadourian
post Mar 13 2011, 10:27 PM
Post #1


Newbie
*

Group: Members
Posts: 6
Joined: 19-December 07
Member No.: 5,004



Thank you. I figured it out and here are some files that may be useful to others that may face the same problem

Attached you fill find
- Example Modelica code with Java function calls
- the corresponding Java function code
- Java Compilation and installation code
- Documentation on the whole process

Cheers


Attached File(s)
Attached File  dymola_Java_Example.zip ( 90.96k ) Number of downloads: 555
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
cadourian
post Mar 13 2011, 05:39 AM
Post #2


Newbie
*

Group: Members
Posts: 6
Joined: 19-December 07
Member No.: 5,004



Hello,

I am trying to call Java code from Dymola and having problems getting it running. The error i get is:

"Failed to find Java class MyPackage/CallDymola"

I have use the following Modelica function:
-----------------------------
function Rotate90

output Real y[3,3];
external "Java" y='MyPackage.CallDymola.Rotate90'();
end Rotate90;
-----------------------------

** the following Java code with filename: CallDymola.java
-----------------------------
package MyPackage;
public class CallDymola
{

// The functions getDouble, getInt, getBoolean
// are also useful
public static double[][] Rotate90()
{
Object objs[] = new Object[3];
objs[0] = new Integer(1);
objs[1] = new Double(1.57);
objs[2] = new Double(0);
com.dynasim.record res = (com.dynasim.record)(
com.dynasim.dymola.interpretMainStatic(
"Modelica.Mechanics.MultiBody.Frames.axisRotation",
objs));
return (double[][])(res.get("T"));
}
}
-----------------------------

** Compiled java and created a jar file
javac -classpath ".;C:\tls\Dymola7.3\Modelica\Library\java" *.java
jar cf CallDymola.jar CallDymola.class

** Dymola's current directory is the same as where the jar file


I am suspecting that I am missing a java library or a dll

Anybody know what I'm missing?

Much Appreciated!

Chahé
Attached File  ExampleModelicaJava.zip ( 3.38k ) Number of downloads: 697
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 21st May 2019 - 06:55 AM