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 theJMadKernel
which controls one MadX-Process.
-
-
Constructor Summary
Constructors Constructor Description JMadKernelImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(JMadKernelListener listener)
Result
execute(JMadExecutable executable)
executes a Command or Task, waits for completion (our timeout if set), and returns result, if command/task provides one.protected void
finalize()
When the class is destroyed it takes care, that MadX is closed in a proper way.java.io.File
getOutputFile()
java.lang.Long
getTimeout()
boolean
isCleanupDirs()
boolean
isKeepOutputFile()
boolean
isMadxRunning()
void
removeListener(JMadKernelListener listener)
void
setCleanupDirs(boolean cleanupDirs)
enable automatic deletion of JMadKernel tmpDir during shutdownvoid
setFileUtil(TempFileUtil fileUtil)
void
setKeepOutputFile(boolean keepOutputFile)
sets the flag, if the output-file shall be kept or deleted after task/command execution.void
setMadxBin(MadxBin madxBin)
void
setPreferences(JMadPreferences preferences)
void
setTimeout(java.lang.Long timeout)
sets the actual timeout in ms.void
start()
starts madx as a separate thread and configures the needed streams.int
stop()
stops the madx-thread
-
-
-
Method Detail
-
start
public void start() throws JMadException
Description copied from interface:JMadKernel
starts madx as a separate thread and configures the needed streams.- Specified by:
start
in interfaceJMadKernel
- Throws:
JMadException
- if the starting of the MadX process fails
-
stop
public int stop() throws JMadException
Description copied from interface:JMadKernel
stops the madx-thread- Specified by:
stop
in 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:JMadKernel
executes a Command or Task, waits for completion (our timeout if set), and returns result, if command/task provides one.- Specified by:
execute
in 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:
isMadxRunning
in interfaceJMadKernel
- Returns:
- true, if madx was started before, false otherwise
-
finalize
protected void finalize() throws java.lang.Throwable
When the class is destroyed it takes care, that MadX is closed in a proper way.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- if the finalization fails
-
addListener
public void addListener(JMadKernelListener listener)
- Specified by:
addListener
in interfaceJMadKernel
- Parameters:
listener
- the listener to add
-
removeListener
public void removeListener(JMadKernelListener listener)
- Specified by:
removeListener
in interfaceJMadKernel
- Parameters:
listener
- the listener to remove
-
getTimeout
public java.lang.Long getTimeout()
- Specified by:
getTimeout
in 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:
setTimeout
in 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:
setKeepOutputFile
in interfaceJMadKernelConfig
- Parameters:
keepOutputFile
- true if the output-file shall be kept, false otherwise
-
isKeepOutputFile
public boolean isKeepOutputFile()
- Specified by:
isKeepOutputFile
in 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:JMadKernelConfig
enable automatic deletion of JMadKernel tmpDir during shutdown- Specified by:
setCleanupDirs
in interfaceJMadKernelConfig
- Parameters:
cleanupDirs
- true if tempDirectory should be deleted
-
isCleanupDirs
public boolean isCleanupDirs()
- Specified by:
isCleanupDirs
in interfaceJMadKernelConfig
- Returns:
- true if the JMadKernel tempDirectory is going to be deleted on Shutdown
-
getOutputFile
public java.io.File getOutputFile()
- Specified by:
getOutputFile
in interfaceJMadKernel
- Returns:
- the JMadKernel OutputFile
-
setPreferences
public void setPreferences(JMadPreferences preferences)
-
setFileUtil
public void setFileUtil(TempFileUtil fileUtil)
-
setMadxBin
public void setMadxBin(MadxBin madxBin)
-
-