Package org.jlab.coda.emu
Class Emu
java.lang.Object
org.jlab.coda.emu.Emu
- All Implemented Interfaces:
CODAComponent,StatedObject,CommandAcceptor
This is the main class of the EMU (Event Management Unit) program.
It implements the CODAComponent interface which allows communication
with Run Control and implements a state machine.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddOutputDestination(String outputDestination) Add a single output destination name, like a file or et system name, or a string like "cMsg", to the array of destinations names.voidClear output destination names.Get the configuration of this CODA component in the form of a parsed XML document object that is loaded from a file when the configure command is executed.voidThis method takes a Command object and attempts to execute it.intGet the smallest number of evio-events/et-buffer that connected DC/PEB found.Get the cmsgPortal object of this emu.Get the UDL used to connect to the cMsg server by this CODA component.Get the class of this CODA component (e.g.Get the CODAClass of this emu.intGet the id of this CODA component.intGet the total number of data streams in the configuration which contains this emu.intGet the id number of the data stream this emu is a part of.longThis method gets the amount of milliseconds to wait for an END command to succeed before going to an ERROR state.getError()Get any available error information.getExpid()Get the experiment id (expid) of this CODA component.intGet the number of file output channels in this emu.Get the debug GUI object.Get the name of the host this CODA component is running on.Get list of input channels.intGet out the number of input channels to the first module.Get the Logger this emu uses.Get list of output channels.String[]Get the rc platform's IP addresses as dot-decimal strings.intGet the platform's cMsg domain server's TCP port.intGet the run number of this CODA component.Get the runType of this CODA component.intGet the numeric code representing the run type of this CODA component.Get the session of this CODA component.getState()This method gets the state of this Emu.Get the ThreadGroup this emu's threads are part of.longgetTime()Get the time from System.currentTimeMillis(), but it's updated only every second or thereabouts.booleanSet the flag to tell file output channel to actually write the file or not.name()Get the name of this CODA component.Get the configuration of this CODA component in the form of a parsed XML document object that is loaded when the configure command is executed.voidpostCommand(Command cmd) This method puts a command object into a mailbox of a CODA component that is periodically checked by that component.This method returns the previous state of the modules in this Emu.voidreset()This method executes a RESET command.voidsendRcErrorMessage(String error) Send run control an error message which gets displayed in its GUI.voidsendRcInfoMessage(String msg) Send run control a informational message which gets displayed in its GUI.voidsendRcSevereMessage(String error) Send run control a severe error message which gets displayed in its GUI.voidSend run control a warning message which gets displayed in its GUI.voidAllow the "out-of-band" sending of a status message to run control.voidsetBufferLevel(int bufferLevel) Set the smallest number of evio-events/et-buffer that connected DC/PEB found.voidsetCodaClass(CODAClass codaClass) Method to set the CODAClass member.voidsetCodaid(int codaid) Set the id of this CODA component.voidsetErrorState(String errorCause) This method sets the state of this Emu to ERROR, but not if the emu is currently resetting in which case it immediately returns.voidsetOutputDestination(int index, String outputDestination) Change an existing single output destination name in the array of names.voidsetRunNumber(int runNumber) Set the run number of this CODA component.voidsetRunType(String runType) Set the runType of this CODA component.voidsetRunTypeId(int runTypeId) Set the numeric code representing the run type of this CODA component.voidsetState(CODAStateIF state) This method sets the state of this Emu, but not if emu is currently resetting in which case it immediately returns.state()Get the state of this object.booleanGet whether END button has been pushed.
-
Constructor Details
-
Emu
Constructor.This class is not executable. To create and run an Emu, use the
A thread is started to monitor the state. The emu loads local.xml which contains a specification of status parameters. The emu starts up a connection to the cMsg server. By the end of the constructor several threads have been started.EmuFactoryclass.- Parameters:
name- name of Emutype- CODA component type of EmudebugUI- start a debug GUIdebug- turn on debug printout- Throws:
EmuException- if name is null, or cannot connect to rc server
-
-
Method Details
-
name
Get the name of this CODA component.- Specified by:
namein interfaceCODAComponent- Returns:
- the name of this CODA component
-
getCodaid
public int getCodaid()Get the id of this CODA component.- Specified by:
getCodaidin interfaceCODAComponent- Returns:
- the id of this CODA component.
-
setCodaid
public void setCodaid(int codaid) Set the id of this CODA component.- Specified by:
setCodaidin interfaceCODAComponent- Parameters:
codaid- the coda id of this CODA component- See Also:
-
getSession
Get the session of this CODA component.- Specified by:
getSessionin interfaceCODAComponent- Returns:
- the session of this CODA component
-
getExpid
Get the experiment id (expid) of this CODA component.- Specified by:
getExpidin interfaceCODAComponent- Returns:
- the experiment id (expid) of this CODA component
-
getHostName
Get the name of the host this CODA component is running on.- Specified by:
getHostNamein interfaceCODAComponent- Returns:
- the hostName of this CODAComponent object.
-
getCodaClass
Get the class of this CODA component (e.g. "EMU", "ROC", "ER").- Specified by:
getCodaClassin interfaceCODAComponent- Returns:
- the class of this CODA component (e.g. "EMU", "ROC", "ER")
-
getRunNumber
public int getRunNumber()Get the run number of this CODA component.- Specified by:
getRunNumberin interfaceCODAComponent- Returns:
- the run number of this CODA component
-
getRunTypeId
public int getRunTypeId()Get the numeric code representing the run type of this CODA component.- Specified by:
getRunTypeIdin interfaceCODAComponent- Returns:
- the numeric code representing the run type of this CODA component.
-
getRunType
Get the runType of this CODA component.- Specified by:
getRunTypein interfaceCODAComponent- Returns:
- the runType of this CODA component
-
getCmsgUDL
Get the UDL used to connect to the cMsg server by this CODA component.- Specified by:
getCmsgUDLin interfaceCODAComponent- Returns:
- the UDL used to connect to the cMsg server by this CODA component
-
getPlatformIpAddresses
Get the rc platform's IP addresses as dot-decimal strings.- Returns:
- rc platform's IP addresses as dot-decimal strings, null if none.
-
getPlatformTcpPort
public int getPlatformTcpPort()Get the platform's cMsg domain server's TCP port.- Returns:
- platform's cMsg domain server's TCP port, 0 if none.
-
getBufferLevel
public int getBufferLevel()Get the smallest number of evio-events/et-buffer that connected DC/PEB found. Meaningful only for a ROC.- Returns:
- smallest number of evio-events/et-buffer that connected DC/PEB found.
-
setBufferLevel
public void setBufferLevel(int bufferLevel) Set the smallest number of evio-events/et-buffer that connected DC/PEB found. Meaningful only for a ROC.- Parameters:
bufferLevel- smallest number of evio-events/et-buffer that connected DC/PEB found.
-
configuration
Get the configuration of this CODA component in the form of a parsed XML document object that is loaded from a file when the configure command is executed. It may change from run to run and tells the Emu which modules to load, which data transports to start and what data channels to open.- Specified by:
configurationin interfaceCODAComponent- Returns:
- the CODA component configuration object as a parsed XML document
-
parameters
Get the configuration of this CODA component in the form of a parsed XML document object that is loaded when the configure command is executed. It contains all of the status variables that change from run to run.- Specified by:
parametersin interfaceCODAComponent- Returns:
- the CODA component configuration object as a parsed XML document that contains all of the status variables that change from run to run
-
setRunNumber
public void setRunNumber(int runNumber) Set the run number of this CODA component.- Specified by:
setRunNumberin interfaceCODAComponent- Parameters:
runNumber- the run number of this CODA component- See Also:
-
setRunTypeId
public void setRunTypeId(int runTypeId) Set the numeric code representing the run type of this CODA component.- Specified by:
setRunTypeIdin interfaceCODAComponent- Parameters:
runTypeId- the numeric code representing the runType of this CODA component- See Also:
-
setRunType
Set the runType of this CODA component.- Specified by:
setRunTypein interfaceCODAComponent- Parameters:
runType- the runType of this CODA component- See Also:
-
getCodaClassObject
Get the CODAClass of this emu.- Returns:
- CODAClass of this emu.
-
setCodaClass
Method to set the CODAClass member.- Parameters:
codaClass- type of CODA component such as ROC, EMU, or ER.
-
isFileWritingOn
public boolean isFileWritingOn()Set the flag to tell file output channel to actually write the file or not.- Returns:
trueif file output channel will actually write the file, elsefalse.
-
getFramework
Get the debug GUI object.- Returns:
- debug gui.
-
getThreadGroup
Get the ThreadGroup this emu's threads are part of.- Returns:
- ThreadGroup this emu's threads are part of.
-
getLogger
Get the Logger this emu uses.- Returns:
- Logger this emu uses.
-
getCmsgPortal
Get the cmsgPortal object of this emu.- Returns:
- cmsgPortal object of this emu.
-
getEndingTimeLimit
public long getEndingTimeLimit()This method gets the amount of milliseconds to wait for an END command to succeed before going to an ERROR state.- Returns:
- amount of milliseconds to wait for an END command to succeed before going to an ERROR state.
-
getInputChannelCount
public int getInputChannelCount()Get out the number of input channels to the first module. This is determined when initially receiving the configure command.- Returns:
- number of input channels to the first module.
-
getInChannels
Get list of input channels.- Returns:
- list of input channels
-
getOutChannels
Get list of output channels.- Returns:
- list of output channels
-
getDataStreamId
public int getDataStreamId()Get the id number of the data stream this emu is a part of. Only relevant if this emu is an EB which outputs to a single ER, or has an output file channel.- Returns:
- data stream id.
-
getDataStreamCount
public int getDataStreamCount()Get the total number of data streams in the configuration which contains this emu.- Returns:
- total number of data streams in this configuration.
-
getFileOutputCount
public int getFileOutputCount()Get the number of file output channels in this emu.- Returns:
- number of file output channels in this emu.
-
theEndIsNigh
public boolean theEndIsNigh()Get whether END button has been pushed. If true, someone hit the END button, but the END event has not necessarily come through yet and the END command may not have been received yet. This allows the file channel (in ER) to cleanup if disk is full and END button was pushed.Only to be used internally to the emu.
- Returns:
- true if someone hit the END button (until END transition finished).
-
previousState
This method returns the previous state of the modules in this Emu. If the Emu has not undergone any transitions yet, it returns null.- Returns:
- state before last transition
-
getError
Get any available error information.- Specified by:
getErrorin interfaceStatedObject- Returns:
- any available error information; null if none
-
setState
This method sets the state of this Emu, but not if emu is currently resetting in which case it immediately returns. Setting the state is synchronized on the emu object to ensure that the state does not change while it's being read.- Parameters:
state- desired state of this Emu.
-
getState
This method gets the state of this Emu.- Returns:
- state of this Emu.
-
setErrorState
This method sets the state of this Emu to ERROR, but not if the emu is currently resetting in which case it immediately returns. It sends an error message to run control if not already done. Setting the state is synchronized on the emu object to ensure that the state does not change while it's being read.- Parameters:
errorCause- description of error's cause.
-
state
Get the state of this object.- Specified by:
statein interfaceStatedObject- Returns:
- the state of this object
-
sendRcInfoMessage
Send run control a informational message which gets displayed in its GUI.- Parameters:
msg- info message
-
sendRcWarningMessage
Send run control a warning message which gets displayed in its GUI.- Parameters:
msg- warning message
-
sendRcErrorMessage
Send run control an error message which gets displayed in its GUI.- Parameters:
error- error message
-
sendRcSevereMessage
Send run control a severe error message which gets displayed in its GUI.- Parameters:
error- severe message
-
addOutputDestination
Add a single output destination name, like a file or et system name, or a string like "cMsg", to the array of destinations names. Call this when setting a destination for the first time. Do NOT call this if resetting an existing output destination file name to the next split file name.- Parameters:
outputDestination- name of an output data destination of this emu- Returns:
- number of already existing output destinations.
-
setOutputDestination
Change an existing single output destination name in the array of names. Call this if resetting an existing output destination file name to the next split file name.- Parameters:
index- index in array of name to be changed.outputDestination- name of an output destination.
-
clearOutputDestinations
public void clearOutputDestinations()Clear output destination names. -
sendStatusMessage
public void sendStatusMessage()Allow the "out-of-band" sending of a status message to run control. -
getTime
public long getTime()Get the time from System.currentTimeMillis(), but it's updated only every second or thereabouts.- Returns:
- time from System.currentTimeMillis()
-
postCommand
This method puts a command object into a mailbox of a CODA component that is periodically checked by that component.- Specified by:
postCommandin interfaceCommandAcceptor- Parameters:
cmd- of type Command (eg. start transition, control run variables, control session)- Throws:
InterruptedException- if thread interrupted while in method.
-
reset
public void reset()This method executes a RESET command. We don't queued it up and possibly have it wait like a transition command. RESET must always have top priority and is executed in the cMsg callback. Synchronized on emu.- Specified by:
resetin interfaceCODAComponent
-
execute
This method takes a Command object and attempts to execute it.- Parameters:
cmd- of type Command
-