public class OMIThread
extends java.lang.Thread
OMIThread runs key modules of OMI: Transfer and Client modules.
Transfer module tries to get simulation results from a result manager and sends them to the Ptolemy II immediately after starting a simulation.
The Control module is the interface between OMI and Ptolemy II. It is implemented as a single thread to support parallel tasks and independent reactivity. As the main controlling and communication instance at simulation initialization phase and while simulation is running it manages simulation properties and also behavior. A client can permanently send operations as messages to the Control unit, it can react at any time to feedback from the other internal OMI components and it also sends messages to a client, for example error or status messages.
The network communication technology TCP/IPv4 is used for sending and receiving messages. The above modules are designated for a communication over TCP/IP.
Prior to running the Transfer and Control module by starting the OMIThread, client and servers are created ,the IP and ports of the servers are set and streams for transferring information between OMI and Ptolemy II are sets up.
Constructor and Description |
---|
OMIThread(java.lang.String parameterFilter,
java.lang.String stopTime,
TypedIOPort outputPort)
Construct client and servers, set the IP and ports of the servers and set up streams for transferring information
between client and servers.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
The simulation result is displayed step by step according to the start time, stop time and number
of intervals of the OpenModelica actor.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public OMIThread(java.lang.String parameterFilter, java.lang.String stopTime, TypedIOPort outputPort) throws java.io.IOException
parameterFilter
- Filter for showing the result of the simulation..stopTime
- Stop time of the simulation.outputPort
- The output port that the result of simulation should be sent to.java.io.IOException
- If I/O error occurs while creating sockets and streams.public void run()
The simulation result is displayed step by step according to the start time, stop time and number of intervals of the OpenModelica actor. The formula for calculating the step time is step time = (stop time - start time) / number of intervals. There is one issue, the simulation does not stop automatically at the stop time that is selected as one of the OpenModelica actors' parameters. So during reading the result back from Transfer server, one condition is set up to check if the stop time is reached. The simulation result according to the parameter's of the OpenModelica actor is sent in the string format to the output port of the OpenModelica actor to be displayed by Display actor.
In addition, the Control module runs prior to running the Transfer one to get the confirmation to run the Transfer module and following running the Transfer module to get the confirmation that the simulation is shut down.
run
in interface java.lang.Runnable
run
in class java.lang.Thread