Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
proforma | 2013-09-04 | ||
Type299.dll | 2013-09-04 | 28.8 kB | |
ITrnsysJavaCoupler.java | 2013-09-04 | 507 Bytes | |
Totals: 3 Items | 29.4 kB | 0 |
Table of Contents
- Overview
- Usage & Java Interface
- Java Version Requirements
- Required DLL Files
- C Libraries Required for Re-compiling
- Folder Structure
1. Overview
This TRNSYS type allows for a bi-directional communication between TRNSYS and Java. After specifying the number of inputs and outputs of the type within the TRNSYS environment, respective links to other components can be established. In every simulation step, the type consumes a certain amount of inputs and sends the values to Java. Based on this, a certain amount of outputs is generated in Java, send back to TRNSYS and used as the type's output for the current simulation step. The communication between the TRNSYS type and the Java class is based on the Java Native Interface (JNI).
2. Usage & Java Interface
In order to make a Java class capable to receive values from and send values to TRNSYS, the Java interface ITrnsysJavaCoupler
with three methods has to be implemented:
void init()
double[] process(double[])
void destroy()
The methods init()
and destroy()
are called before the first and after the last step during a TRNSYS simulation run. Their usage is optional, examples may be opening or closing database connections. The method process()
is called in every simulation step. It receives a double array with all input values and returns a double array with all output values of the current simulation step. The amount of input and output values as well as their order is specified in the type's configuration within the TRNSYS environment. It has to be noted that the amount of input values accessed and output values generated in Java must match to the amount of input/output values specified in TRNSYS.
The path to a compiled Java class implementing this interface is pre-defined in the type's C++ code. The compiled DLL file offered as download (usage/Type299.dll
) points to C:/TrnsysJavaCoupler/TrnsysJavaCoupler.class
and can be used without re-compiling as long as this location is used.
3. Java Version Requirements
You must use a 32-bit version of Java Runtime Environment (JRE) in order to guarantee compatibility with TRNSYS. If you usually run a 64-bit version of the JRE, you can temporarily switch to a 32-bit version.
4. Required DLL Files
In order to use the type, the subsequent DLL libraries are required:
-
TRNDLL.DLL
:Shipped with your TRNSYS installation, located in the TRNSYS folder. As TRNSYS is started from this folder, it will automatically be found by Windows.
-
JVM.DLL
:Shipped with your 32-bit JRE installation, located in
%JRE%/bin/client/
. In order to be found by Windows, take care that this path is listed in your Windows environment variablePATH
. Again, please note that in order to keep compatibility with TRNSYS, you must use a 32-bit version of the JRE. -
LIBGCC_S_DW2-1.DLL
,LIBSTDC++-6.DLL
:Both DLL libraries are part of the MinGW C compiler used to compile the type. If you do not have installed MinGW on your system, you can download these files (see
usage/third-party-DLLs/
). Locate them in your%TRNSYS%/Exe/
folder in order to allow Windows to find them.
5. C Libraries Required for Re-Compiling
This section is only of interest if you want to modify and re-compile the C++ code. Then, your compiler must links towards two import libraries. The first is %TRNSYS%/Exe/TRNDll.lib
from the TRNSYS installation folder which allows to access TRNSYS functions. The second is %JDK%/lib/jvm.lib
from the 32-bit Java Development Kit (JDK) which allows to communicate via the Java Native Interface (JNI). Please note that in order to keep compatibility with TRNSYS, you must use the 32-bit version of jvm.lib
.
6. Folder Structure & Files
usage/
- Contains all you need to use the type
Type299.dll
: The compiled TRNSYS type which has to be placed in%TRNSYS%/UserLib/ReleaseDLLs/
.ITrnsysJavaCoupler.java
: The Java interface which has to be implemented by the Java class.proforma/
: The type definition (Type299.tmf
,Type299.bmp
) which has to be placed in%TRNSYS%/Studio/Proformas/Utility/TRNSYS-Java Coupler/
.third-party-DLLs/
: Required third-party DLLs which have to be placed in%TRNSYS%/Exe/
.
demo/
- Demonstration of the type's usage
TrnsysJavaCouplerDemo.tpf
: A TRNSYS deck that uses different data sources and a visualizer for demonstrating the type's usage.TrnsysJavaCoupler.java
: Example implementation of the Java interface demonstrating its usage.
dev/
- If you want to modify the type's code
Type299.cpp
: The C++ code for the TRNSYS type.