public class ModuleAdapter extends java.lang.Object implements EmuModule
Modifier and Type | Class and Description |
---|---|
(package private) class |
ModuleAdapter.RateCalculatorThread
This 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> |
attributeMap
Map containing attributes of this module given in config file.
|
protected int |
avgEventSize
Average-sized built event in bytes.
|
protected Emu |
emu
Emu this module belongs to.
|
protected EmuEventNotify |
endCallback
Object used by Emu to be notified of END event arrival.
|
protected boolean |
epThreadsSetInConfig
Were the number of event producing threads explicitly set in config file?
|
protected java.util.concurrent.atomic.AtomicReference<java.lang.String> |
errorMsg
Possible error message.
|
protected long |
eventCountTotal
Total number of evio events written to the outputs.
|
protected int |
eventProducingThreads
Number of event producing threads in operation.
|
protected float |
eventRate
Instantaneous event rate in Hz over the last time period of length
statGatheringPeriod . |
protected int |
goodChunk_X_EtBufSize
For 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 |
id
ID number of this module obtained from config file.
|
protected int[] |
inputChanLevels
Array containing, for each input channel, the percentage (0-100)
of filled ring space.
|
protected java.lang.String[] |
inputChanNames
Array containing names for each input channel.
|
protected int |
inputChannelCount
Number of output channels.
|
protected java.util.ArrayList<DataChannel> |
inputChannels
ArrayList of DataChannel objects for this module that are inputs.
|
protected Logger |
logger
Logger used to log messages to debug console.
|
protected int |
maxEventSize
Maximum-sized built event in bytes.
|
protected int |
minEventSize
Minimum-sized built event in bytes.
|
protected CODAStateIF |
moduleState
State of this module.
|
protected java.lang.String |
name
Name of this module.
|
protected int[] |
outputChanLevels
Array containing, for each output channel, the percentage (0-100)
of filled ring space.
|
protected java.lang.String[] |
outputChanNames
Array containing names for each output channel.
|
protected int |
outputChannelCount
Number of output channels.
|
protected java.util.ArrayList<DataChannel> |
outputChannels
ArrayList of DataChannel objects that are outputs.
|
protected java.nio.ByteOrder |
outputOrder
Do we produce big or little endian output in ByteBuffers?
|
protected boolean |
paused
User hit PAUSE button if
true . |
protected EmuEventNotify |
prestartCallback
Object used by Emu to be notified of PRESTART event arrival.
|
protected java.lang.Thread |
RateCalculator
Thread to calculate event and data rates.
|
protected boolean |
representStatistics
If
true , this module's statistics represents that of the EMU. |
protected static int |
statGatheringPeriod
Targeted time period in milliseconds over which instantaneous rates will be calculated.
|
protected Statistics |
statistics
Handle histogram of event build times.
|
protected boolean |
timeStatsOn
If true, collect statistics on event build times (performance drag).
|
protected int[] |
timeToBuild
Histogram of time to build 1 event in nanoseconds
(metadata in first 5 elements).
|
protected long |
wordCountTotal
Sum of the sizes, in 32-bit words, of all evio events written to the outputs.
|
protected float |
wordRate
Instantaneous 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 EmuModule
public java.lang.String[] getOutputNames()
getOutputNames
in interface EmuModule
public int[] getOutputLevels()
getOutputLevels
in interface EmuModule
public int[] getInputLevels()
getInputLevels
in interface EmuModule
public void go() throws CmdExecException
go
in interface CODAStateMachine
CmdExecException
- if error during command execution.public void end() throws CmdExecException
end
in interface CODAStateMachine
CmdExecException
- if error during command execution.public void pause()
pause
in interface CODAStateMachine
public void prestart() throws CmdExecException
prestart
in interface CODAStateMachine
CmdExecException
- if error during command execution.public void download() throws CmdExecException
download
in interface CODAStateMachine
CmdExecException
- if error during command execution.public void reset()
reset
in interface CODAStateMachine
public void registerEndCallback(EmuEventNotify callback)
registerEndCallback
in interface CODAStateMachine
callback
- object used for notifying caller.public EmuEventNotify getEndCallback()
getEndCallback
in interface CODAStateMachine
public void registerPrestartCallback(EmuEventNotify callback)
registerPrestartCallback
in interface CODAStateMachine
callback
- object used for notifying caller.public EmuEventNotify getPrestartCallback()
getPrestartCallback
in interface CODAStateMachine
public CODAStateIF state()
state
in interface StatedObject
public java.lang.String getError()
getError
in interface StatedObject
public java.lang.String getAttr(java.lang.String name) throws DataNotFoundException
getAttr
in interface EmuModule
name
- 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 EmuModule
name
- 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 EmuModule
public boolean representsEmuStatistics()
representsEmuStatistics
in interface EmuModule
true
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 EmuModule
public void adjustStatistics(long eventsAdded, long wordsAdded)
adjustStatistics
in interface EmuModule
eventsAdded
- 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 EmuModule
input_channels
- the input channels to add to this EmuModule objectpublic void addOutputChannels(java.util.ArrayList<DataChannel> output_channels)
addOutputChannels
in interface EmuModule
output_channels
- the output channels to add to this EmuModule objectpublic java.util.ArrayList<DataChannel> getInputChannels()
getInputChannels
in interface EmuModule
public java.util.ArrayList<DataChannel> getOutputChannels()
getOutputChannels
in interface EmuModule
public void clearChannels()
clearChannels
in interface EmuModule
public int getEventProducingThreadCount()
getEventProducingThreadCount
in interface EmuModule
public java.nio.ByteOrder getOutputOrder()
getOutputOrder
in interface EmuModule