public class ModuleAdapter extends java.lang.Object implements EmuModule
| Modifier and Type | Class and Description | 
|---|---|
| (package private) class  | ModuleAdapter.RateCalculatorThreadThis class defines a thread that makes instantaneous rate calculations
 once every few seconds. | 
| Modifier and Type | Field and Description | 
|---|---|
| protected java.util.Map<java.lang.String,java.lang.String> | attributeMapMap containing attributes of this module given in config file. | 
| protected int | avgEventSizeAverage-sized built event in bytes. | 
| protected Emu | emuEmu this module belongs to. | 
| protected EmuEventNotify | endCallbackObject used by Emu to be notified of END event arrival. | 
| protected boolean | epThreadsSetInConfigWere the number of event producing threads explicitly set in config file? | 
| protected java.util.concurrent.atomic.AtomicReference<java.lang.String> | errorMsgPossible error message. | 
| protected long | eventCountTotalTotal number of evio events written to the outputs. | 
| protected int | eventProducingThreadsNumber of event producing threads in operation. | 
| protected float | eventRateInstantaneous event rate in Hz over the last time period of length  statGatheringPeriod. | 
| protected int | goodChunk_X_EtBufSizeFor ET output channels, a suggested value of chunk * ET-buffer-size (bytes)
  which would be a good match for the current size events being built. | 
| protected int | idID number of this module obtained from config file. | 
| protected int[] | inputChanLevelsArray containing, for each input channel, the percentage (0-100)
  of filled ring space. | 
| protected java.lang.String[] | inputChanNamesArray containing names for each input channel. | 
| protected int | inputChannelCountNumber of output channels. | 
| protected java.util.ArrayList<DataChannel> | inputChannelsArrayList of DataChannel objects for this module that are inputs. | 
| protected Logger | loggerLogger used to log messages to debug console. | 
| protected int | maxEventSizeMaximum-sized built event in bytes. | 
| protected int | minEventSizeMinimum-sized built event in bytes. | 
| protected CODAStateIF | moduleStateState of this module. | 
| protected java.lang.String | nameName of this module. | 
| protected int[] | outputChanLevelsArray containing, for each output channel, the percentage (0-100)
  of filled ring space. | 
| protected java.lang.String[] | outputChanNamesArray containing names for each output channel. | 
| protected int | outputChannelCountNumber of output channels. | 
| protected java.util.ArrayList<DataChannel> | outputChannelsArrayList of DataChannel objects that are outputs. | 
| protected java.nio.ByteOrder | outputOrderDo we produce big or little endian output in ByteBuffers? | 
| protected boolean | pausedUser hit PAUSE button if  true. | 
| protected EmuEventNotify | prestartCallbackObject used by Emu to be notified of PRESTART event arrival. | 
| protected java.lang.Thread | RateCalculatorThread to calculate event and data rates. | 
| protected boolean | representStatisticsIf  true, this module's statistics represents that of the EMU. | 
| protected static int | statGatheringPeriodTargeted time period in milliseconds over which instantaneous rates will be calculated. | 
| protected Statistics | statisticsHandle histogram of event build times. | 
| protected boolean | timeStatsOnIf true, collect statistics on event build times (performance drag). | 
| protected int[] | timeToBuildHistogram of time to build 1 event in nanoseconds
 (metadata in first 5 elements). | 
| protected long | wordCountTotalSum of the sizes, in 32-bit words, of all evio events written to the outputs. | 
| protected float | wordRateInstantaneous word rate in Hz over the last time period of length  statGatheringPeriod. | 
| Constructor and Description | 
|---|
| ModuleAdapter(java.lang.String name,
             Emu emu)Default constructor for fake TS. | 
| ModuleAdapter(java.lang.String name,
             java.util.Map<java.lang.String,java.lang.String> attributeMap,
             Emu emu)Constructor creates a new EventRecording instance. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addInputChannels(java.util.ArrayList<DataChannel> input_channels)Add the given input channels to this EmuModule object. | 
| void | addOutputChannels(java.util.ArrayList<DataChannel> output_channels)Add the given output channels to this EmuModule object. | 
| void | adjustStatistics(long eventsAdded,
                long wordsAdded)Adjust the event count and word count reported by this module to run control
 by added the given numbers. | 
| void | clearChannels()Remove all channels from this EmuModule object. | 
| void | download()This method implements the DOWNLOAD transition of the CODA run control state machine. | 
| void | end()This method implements the END transition of the CODA run control state machine. | 
| protected void | eventToOutputChannel(RingItem itemOut,
                    DataChannel channel,
                    int ringNum)This method is used to place an item onto a specified ring buffer of a
 single, specified output channel. | 
| protected void | eventToOutputChannel(RingItem itemOut,
                    int channelNum,
                    int ringNum)This method is used to place an item onto a specified ring buffer of a
 single, specified output channel. | 
| java.lang.String | getAttr(java.lang.String name)Get the named attribute from the config file of this module. | 
| EmuEventNotify | getEndCallback()This method gets the callback object previously registered by the caller
 used to notify upon the arrival of an END event. | 
| java.lang.String | getError()Get any available error information. | 
| int | getEventProducingThreadCount()Get the number of threads which produce events to be placed in output channels. | 
| java.util.ArrayList<DataChannel> | getInputChannels()Get the input channels of this EmuModule object. | 
| int[] | getInputLevels()Get array containing the relative fill level (0-100) of each input channel's ring. | 
| java.lang.String[] | getInputNames()Get the names of the input channels of this EmuModule object. | 
| int | getIntAttr(java.lang.String name)Get the named attribute, as an integer, from the config file of this module. | 
| int | getInternalRingCount()Get the number of items this EmuModule object has in its internal rings. | 
| java.util.ArrayList<DataChannel> | getOutputChannels()Get the output channels of this EmuModule object. | 
| int[] | getOutputLevels()Get array containing the relative fill level (0-100) of each output channel's ring(s). | 
| java.lang.String[] | getOutputNames()Get the names of the output channels of this EmuModule object. | 
| java.nio.ByteOrder | getOutputOrder()Get the byte order of the module's output. | 
| EmuEventNotify | getPrestartCallback()This method gets the callback object previously registered by the caller
 used to notify upon the arrival of a PRESTART event. | 
| java.lang.Object[] | getStatistics()Get the output statistics of this EmuModule object. | 
| void | go()This method implements the GO transition of the CODA run control state machine. | 
| java.lang.String | name()Get the name of the module | 
| void | pause()This method implements the PAUSE transition of the CODA run control state machine. | 
| void | prestart()This method implements the PRESTART transition of the CODA run control state machine. | 
| void | registerEndCallback(EmuEventNotify callback)This method allows for setting a object used to notify the caller when an END event
 has arrived (or any other occurrence for that matter). | 
| void | registerPrestartCallback(EmuEventNotify callback)This method allows for setting a object used to notify the caller when a PRESTART event
 has arrived (or any other occurrence for that matter). | 
| boolean | representsEmuStatistics()If an EMU has more than one module, which module's statistics represent the EMU
 as a whole needs to be determined. | 
| void | reset()This method implements the RESET transition of the CODA run control state machine. | 
| CODAStateIF | state()Get the state of this object. | 
protected int id
protected int eventProducingThreads
protected boolean epThreadsSetInConfig
protected final java.lang.String name
protected java.util.concurrent.atomic.AtomicReference<java.lang.String> errorMsg
protected final Emu emu
protected final Logger logger
protected volatile CODAStateIF moduleState
protected final java.util.Map<java.lang.String,java.lang.String> attributeMap
protected java.util.ArrayList<DataChannel> inputChannels
addInputChannels(ArrayList) and
 clearChannels() methods and then only by the main EMU thread
 in prestart. However, other threads (such as the EMU's statistics reporting
 thread) call methods which use its iterator or getters.protected java.util.ArrayList<DataChannel> outputChannels
protected int inputChannelCount
protected int outputChannelCount
protected boolean paused
true.protected EmuEventNotify endCallback
protected EmuEventNotify prestartCallback
protected java.nio.ByteOrder outputOrder
protected int[] inputChanLevels
protected int[] outputChanLevels
protected java.lang.String[] inputChanNames
protected java.lang.String[] outputChanNames
protected long eventCountTotal
protected long wordCountTotal
protected float eventRate
statGatheringPeriod.protected float wordRate
statGatheringPeriod.protected int maxEventSize
protected int minEventSize
protected int avgEventSize
protected int goodChunk_X_EtBufSize
protected int[] timeToBuild
protected static final int statGatheringPeriod
protected boolean representStatistics
true, this module's statistics represents that of the EMU.protected boolean timeStatsOn
protected Statistics statistics
protected java.lang.Thread RateCalculator
public ModuleAdapter(java.lang.String name,
                     Emu emu)
name - name of module.emu - Emu this module belongs to.public ModuleAdapter(java.lang.String name,
                     java.util.Map<java.lang.String,java.lang.String> attributeMap,
                     Emu emu)
name - name of moduleattributeMap - map containing attributes of moduleemu - Emu this module belongs to.protected void eventToOutputChannel(RingItem itemOut, int channelNum, int ringNum) throws java.lang.InterruptedException
itemOut - the event to place on output channelchannelNum - index of output channel to place item onringNum - index of output channel ring buffer to place item onjava.lang.InterruptedException - it thread interrupted.protected void eventToOutputChannel(RingItem itemOut, DataChannel channel, int ringNum) throws java.lang.InterruptedException
itemOut - the event to place on output channelchannel - which output channel to place item onringNum - index of output channel ring buffer to place item onjava.lang.InterruptedException - it thread interrupted.public java.lang.String[] getInputNames()
getInputNames in interface EmuModulepublic java.lang.String[] getOutputNames()
getOutputNames in interface EmuModulepublic int[] getOutputLevels()
getOutputLevels in interface EmuModulepublic int[] getInputLevels()
getInputLevels in interface EmuModulepublic void go()
        throws CmdExecException
go in interface CODAStateMachineCmdExecException - if error during command execution.public void end()
         throws CmdExecException
end in interface CODAStateMachineCmdExecException - if error during command execution.public void pause()
pause in interface CODAStateMachinepublic void prestart()
              throws CmdExecException
prestart in interface CODAStateMachineCmdExecException - if error during command execution.public void download()
              throws CmdExecException
download in interface CODAStateMachineCmdExecException - if error during command execution.public void reset()
reset in interface CODAStateMachinepublic void registerEndCallback(EmuEventNotify callback)
registerEndCallback in interface CODAStateMachinecallback - object used for notifying caller.public EmuEventNotify getEndCallback()
getEndCallback in interface CODAStateMachinepublic void registerPrestartCallback(EmuEventNotify callback)
registerPrestartCallback in interface CODAStateMachinecallback - object used for notifying caller.public EmuEventNotify getPrestartCallback()
getPrestartCallback in interface CODAStateMachinepublic CODAStateIF state()
state in interface StatedObjectpublic java.lang.String getError()
getError in interface StatedObjectpublic java.lang.String getAttr(java.lang.String name)
                         throws DataNotFoundException
getAttr in interface EmuModulename - name of the module's config file attribute.DataNotFoundException - if attribute not found.public int getIntAttr(java.lang.String name)
               throws DataNotFoundException,
                      java.lang.NumberFormatException
getIntAttr in interface EmuModulename - name of the module's config file attribute.DataNotFoundException - if attribute not found.java.lang.NumberFormatException - if attribute cannot be interpreted as an integerpublic java.lang.String name()
public int getInternalRingCount()
getInternalRingCount in interface EmuModulepublic boolean representsEmuStatistics()
representsEmuStatistics in interface EmuModuletrue if this module's statistics represents the EMU, else false.public java.lang.Object[] getStatistics()
Get the output statistics of this EmuModule object. The output statistics consists of an array of 2 Longs, 2 Floats, 4 Integers, and 1 int array:
event count (Long)
word count (Long)
event rate in Hz (Float
data rate in kBytes/sec (Float)
max event size in bytes (Integer) if module is an EB
min event size in bytes (Integer) if module is an EB
avg event size in bytes (Integer) if module is an EB
suggested value for chunk*EtBufSize (Integer) if have ET output channel
if EB and switched on, histogram of time to build 1 event in nanoseconds (int array)
getStatistics in interface EmuModulepublic void adjustStatistics(long eventsAdded,
                             long wordsAdded)
adjustStatistics in interface EmuModuleeventsAdded - number of events to be added the event countwordsAdded - number of words to be added the word countpublic void addInputChannels(java.util.ArrayList<DataChannel> input_channels)
addInputChannels in interface EmuModuleinput_channels - the input channels to add to this EmuModule objectpublic void addOutputChannels(java.util.ArrayList<DataChannel> output_channels)
addOutputChannels in interface EmuModuleoutput_channels - the output channels to add to this EmuModule objectpublic java.util.ArrayList<DataChannel> getInputChannels()
getInputChannels in interface EmuModulepublic java.util.ArrayList<DataChannel> getOutputChannels()
getOutputChannels in interface EmuModulepublic void clearChannels()
clearChannels in interface EmuModulepublic int getEventProducingThreadCount()
getEventProducingThreadCount in interface EmuModulepublic java.nio.ByteOrder getOutputOrder()
getOutputOrder in interface EmuModule