Class JMadKernelImpl
- java.lang.Object
-
- cern.accsoft.steering.jmad.kernel.JMadKernelImpl
-
- All Implemented Interfaces:
JMadKernel,JMadKernelConfig
public class JMadKernelImpl extends java.lang.Object implements JMadKernel, JMadKernelConfig
this is the implementation of theJMadKernelwhich controls one MadX-Process.
-
-
Constructor Summary
Constructors Constructor Description JMadKernelImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(JMadKernelListener listener)Resultexecute(JMadExecutable executable)executes a Command or Task, waits for completion (our timeout if set), and returns result, if command/task provides one.protected voidfinalize()When the class is destroyed it takes care, that MadX is closed in a proper way.java.io.FilegetOutputFile()java.lang.LonggetTimeout()booleanisCleanupDirs()booleanisKeepOutputFile()booleanisMadxRunning()voidremoveListener(JMadKernelListener listener)voidsetCleanupDirs(boolean cleanupDirs)enable automatic deletion of JMadKernel tmpDir during shutdownvoidsetFileUtil(TempFileUtil fileUtil)voidsetKeepOutputFile(boolean keepOutputFile)sets the flag, if the output-file shall be kept or deleted after task/command execution.voidsetMadxBin(MadxBin madxBin)voidsetPreferences(JMadPreferences preferences)voidsetTimeout(java.lang.Long timeout)sets the actual timeout in ms.voidstart()starts madx as a separate thread and configures the needed streams.intstop()stops the madx-thread
-
-
-
Method Detail
-
start
public void start() throws JMadExceptionDescription copied from interface:JMadKernelstarts madx as a separate thread and configures the needed streams.- Specified by:
startin interfaceJMadKernel- Throws:
JMadException- if the starting of the MadX process fails
-
stop
public int stop() throws JMadExceptionDescription copied from interface:JMadKernelstops the madx-thread- Specified by:
stopin interfaceJMadKernel- Returns:
- the exit-value of madx
- Throws:
JMadException- if the stopping of the MadX process fails
-
execute
public Result execute(JMadExecutable executable) throws JMadException
Description copied from interface:JMadKernelexecutes a Command or Task, waits for completion (our timeout if set), and returns result, if command/task provides one.- Specified by:
executein interfaceJMadKernel- Parameters:
executable- the command or task to execute- Returns:
- the result, if available, otherwise null
- Throws:
JMadException- if the execution fails
-
isMadxRunning
public boolean isMadxRunning()
- Specified by:
isMadxRunningin interfaceJMadKernel- Returns:
- true, if madx was started before, false otherwise
-
finalize
protected void finalize() throws java.lang.ThrowableWhen the class is destroyed it takes care, that MadX is closed in a proper way.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable- if the finalization fails
-
addListener
public void addListener(JMadKernelListener listener)
- Specified by:
addListenerin interfaceJMadKernel- Parameters:
listener- the listener to add
-
removeListener
public void removeListener(JMadKernelListener listener)
- Specified by:
removeListenerin interfaceJMadKernel- Parameters:
listener- the listener to remove
-
getTimeout
public java.lang.Long getTimeout()
- Specified by:
getTimeoutin interfaceJMadKernelConfig- Returns:
- the actual set timeout
-
setTimeout
public void setTimeout(java.lang.Long timeout)
sets the actual timeout in ms. If null then the kernel waits forever for Madx.- Specified by:
setTimeoutin interfaceJMadKernelConfig- Parameters:
timeout- the timeout to set
-
setKeepOutputFile
public void setKeepOutputFile(boolean keepOutputFile)
sets the flag, if the output-file shall be kept or deleted after task/command execution.- Specified by:
setKeepOutputFilein interfaceJMadKernelConfig- Parameters:
keepOutputFile- true if the output-file shall be kept, false otherwise
-
isKeepOutputFile
public boolean isKeepOutputFile()
- Specified by:
isKeepOutputFilein interfaceJMadKernelConfig- Returns:
- true, if the outputfile shall be kept or false if it shall be deleted after command/task execution.
-
setCleanupDirs
public void setCleanupDirs(boolean cleanupDirs)
Description copied from interface:JMadKernelConfigenable automatic deletion of JMadKernel tmpDir during shutdown- Specified by:
setCleanupDirsin interfaceJMadKernelConfig- Parameters:
cleanupDirs- true if tempDirectory should be deleted
-
isCleanupDirs
public boolean isCleanupDirs()
- Specified by:
isCleanupDirsin interfaceJMadKernelConfig- Returns:
- true if the JMadKernel tempDirectory is going to be deleted on Shutdown
-
getOutputFile
public java.io.File getOutputFile()
- Specified by:
getOutputFilein interfaceJMadKernel- Returns:
- the JMadKernel OutputFile
-
setPreferences
public void setPreferences(JMadPreferences preferences)
-
setFileUtil
public void setFileUtil(TempFileUtil fileUtil)
-
setMadxBin
public void setMadxBin(MadxBin madxBin)
-
-