public class OMCCommand extends java.lang.Object implements IOMCCommand
OMCCommand is composed of the implementation of the commands for initializing the communication with the OpenModelica compiler(OMC) server, building the Modelica model, fetching the error-information of current run, loading the Modelica file and library and modifying parameter(s) and variable(s) of the Modelica model before building the Modelica model in both interactive and non-interactive processing mode. In addition to executing all these Modelica commands, it plots the result file of the simulation that is generated in plt format.
Modifier and Type | Field and Description |
---|---|
boolean |
hasInitialized
Check if the communication with OpenModelica Compiler(OMC) is set up.
|
OmcCommunication |
omcCommunication
The CORBA object for OpenModelica Compiler(OMC) communication.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getInheritanceCount(java.lang.String modelName)
Check if the (base-)model inherits from other classes.
|
static OMCCommand |
getInstance()
Create an instance of OMCCommand object in order to provide a global point of access to the instance.
|
java.util.HashMap |
getModelComponent(java.lang.String modelName)
Return the list of component declarations within (base-)model.
|
static ptolemy.domains.openmodelica.lib.omc.OMCCommand._osType |
getOs()
Fetch the type of Operating System(OS).
|
void |
initializeServer()
Initialize the communication with the OpenModelica compiler(OMC) server.
|
boolean |
isError(java.lang.String retval)
Check if there is an error in the return value of sendCommand("command") method and
fetch the error-information of current run.
|
void |
loadModelicaFile(java.lang.String fileName,
java.lang.String modelName)
load the Modelica file and library.
|
void |
modifyComponents(java.lang.String values,
java.lang.String modelName,
java.lang.String components)
Modify parameter(s) and variable(s) of the Modelica model before building the model.
|
void |
plotPltFile(java.lang.String modelName)
Plot the plt file by calling PxgraphApplication.main(modelName).
|
void |
runModel(java.lang.String fileName,
java.lang.String modelName,
java.lang.String startTime,
java.lang.String stopTime,
int numberOfIntervals,
java.lang.String outputFormat,
java.lang.String processingMode)
Build the Modelica model.
|
CompilerResult |
sendCommand(java.lang.String modelicaCommand)
Send a command to the OpenModelica Compiler(OMC) server and fetches the string result.
|
void |
stopServer()
Leave OpenModelica environment, destroy the OMC process and
deallocate OMCCommand object.
|
public boolean hasInitialized
public OmcCommunication omcCommunication
public boolean getInheritanceCount(java.lang.String modelName)
getInheritanceCount
in interface IOMCCommand
modelName
- The (base-)model that should be built.public static OMCCommand getInstance()
public java.util.HashMap getModelComponent(java.lang.String modelName)
getModelComponent
in interface IOMCCommand
modelName
- The (base-)model that should be built.public static ptolemy.domains.openmodelica.lib.omc.OMCCommand._osType getOs()
public void initializeServer() throws ConnectException
initializeServer
in interface IOMCCommand
ConnectException
- If we're unable to start communicating with
the server.public boolean isError(java.lang.String retval)
isError
in interface IOMCCommand
retval
- The string returned by the OpenModelica Compiler(OMC).public void loadModelicaFile(java.lang.String fileName, java.lang.String modelName) throws ConnectException
loadModelicaFile
in interface IOMCCommand
fileName
- File that the (base-)model should be loaded from.modelName
- Name of the (base-)model that should be built.ConnectException
- If commands couldn't
be sent to the (OpenModelic Compiler)OMC.ConnectException
- If no file found at the selective path for loading.public void modifyComponents(java.lang.String values, java.lang.String modelName, java.lang.String components) throws IllegalActionException, ConnectException
modifyComponents
in interface IOMCCommand
values
- The new values to change the value of the components.modelName
- The (base-)model that should be built.components
- The name of the components to change.ConnectException
- If commands couldn't
be sent to the (OpenModelica Compiler)OMC.IllegalActionException
public void plotPltFile(java.lang.String modelName) throws ConnectException
plotPltFile
in interface IOMCCommand
modelName
- Name of the model which should be built.ConnectException
- If commands could not be sent to the OMC.public void runModel(java.lang.String fileName, java.lang.String modelName, java.lang.String startTime, java.lang.String stopTime, int numberOfIntervals, java.lang.String outputFormat, java.lang.String processingMode) throws ConnectException, java.io.IOException, IllegalActionException
runModel
in interface IOMCCommand
fileName
- File which the model should be loaded from.modelName
- Name of the (base-)model which should be built.startTime
- The start time of simulation.stopTime
- The stop time of simulation.numberOfIntervals
- Number of intervals in the result file.outputFormat
- Format of the result file.processingMode
- The mode of processing for running the executable result file of building the Modelica model.ConnectException
- If commands couldn't
be sent to the (OpenModelic Compiler)OMC.java.io.IOException
- If the executable result file of buildModel()
couldn't be executed.IllegalActionException
public CompilerResult sendCommand(java.lang.String modelicaCommand) throws ConnectException
modelicaCommand
- The command which should be sent to the OMC.ConnectException
- If commands couldn't be sent to the OMC.public void stopServer() throws ConnectException
stopServer
in interface IOMCCommand
ConnectException
- If quit command couldn't be sent to OMC.