public class NumericMonitorProbe extends NumericProbeBase implements CopyableComponent
DataFunction
to generate the data;
generateData(maspack.matrix.VectorNd, double, double)
method;
apply(double)
method.
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
static PropertyList |
myProps |
useOldSaveMethod, writeStartStopTimeInSeconds
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
COPY_REFERENCES
Constructor and Description |
---|
NumericMonitorProbe() |
NumericMonitorProbe(int vsize,
double interval) |
NumericMonitorProbe(int vsize,
java.lang.String fileName,
double startTime,
double stopTime,
double interval) |
Modifier and Type | Method and Description |
---|---|
void |
apply(double t)
Called when the probe is being applied to a model
|
java.lang.Object |
clone() |
ModelComponent |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap)
Create a copy of this component.
|
ComponentState |
createState(ComponentState prevState)
Factory routine to create a state object for this component, which can
then be used as an argument for
HasState.setState(artisynth.core.modelbase.ComponentState) and HasState.getState(artisynth.core.modelbase.ComponentState) . |
void |
generateData(VectorNd vec,
double t,
double trel)
Generates data for this probe by evaluating a vectored-valued function of
time and storing the result in
vec . |
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
boolean |
getCopyReferences(java.util.List<ModelComponent> refs,
ModelComponent ancestor)
Collects external references which must also be copied in order to
duplicate this component.
|
DataFunction |
getDataFunction()
Returns the data function, if any, that is used by this probe's
apply(double) method to generate data for this probe. |
void |
getInitialState(ComponentState newstate,
ComponentState oldstate)
Gets an initial state for this component and returns the value in
state . |
NumericList |
getOutput() |
boolean |
getShowHeader() |
boolean |
getShowTime() |
void |
getState(ComponentState state)
Get the current state of this component.
|
boolean |
hasState()
Queries if this component has state.
|
boolean |
isCloneable() |
boolean |
isDuplicatable()
Returns true if this component can be duplicated.
|
void |
save()
When called (perhaps by the Artsynth timeline), causes information about
this probe to be written to its attached file.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
boolean |
scanItem(ReaderTokenizer rtok,
java.util.Deque<ScanToken> tokens) |
void |
setAttachedFileName(java.lang.String fileName,
java.lang.String fmtStr) |
void |
setAttachedFileName(java.lang.String fileName,
java.lang.String fmtStr,
boolean showTime,
boolean showHeader) |
void |
setDataFunction(DataFunction func)
Sets a data function to be used by this probe's
generateData(maspack.matrix.VectorNd, double, double)
method to generate data for this probe. |
void |
setShowHeader(boolean enable) |
void |
setShowTime(boolean enable) |
void |
setState(ComponentState state)
Set the state of this component.
|
void |
setVsize(int vsize) |
void |
setVsize(int vsize,
PlotTraceInfo[] traceInfos) |
void |
write(java.io.PrintWriter pw,
java.lang.String fmtStr,
boolean showTime)
Writes the start and stop times, scale value, and data for this probe to a
PrintWriter, using the format described for
NumericInputProbe.read(File) . |
void |
writeData(java.io.PrintWriter pw,
java.lang.String fmtStr,
boolean showTime) |
void |
writeItems(java.io.PrintWriter pw,
NumberFormat fmt,
CompositeComponent ancestor)
Write probe attributes to a PrintWriter
|
applyDefaultDisplayRanges, createNumericList, decreaseDisplayRanges, dispose, getAttachedProperties, getData, getDefaultDisplayMax, getDefaultDisplayMin, getDefaultDisplayRange, getDisplay, getDrivers, getFormat, getInterpolation, getInterpolationOrder, getLegend, getMatlabName, getMinMaxValues, getNumericList, getOrderedTraceIndex, getPlotTraceInfo, getRange, getRangeHints, getTraceColor, getTraceLabel, getValues, getVariables, getVsize, increaseDisplayRanges, isEmpty, isPrintable, isSmallDisplayVisible, isTraceVisible, isValidVariableName, loadFromMatlab, print, removeDisplay, removeLegend, resetTraceColors, resetTraceOrder, saveToMatlab, scaleNumericList, setDefaultDisplayRange, setDefaultDisplayRange, setFormat, setInterpolation, setInterpolationOrder, setLegendLabels, setRangeHints, setScale, setSmallDisplayVisible, setTraceColor, setTraceLabel, setTraceOrder, setTraceVisible, setValues, swapPlotTraceOrder, updateDisplays, updateDisplays, updateDisplaysForPropertyChanges, updateDisplaysWithoutAutoRanging
getAttachedFile, getAttachedFileName, getChildren, getDefaultScale, getDefaultStartTime, getDefaultStopTime, getDefaultUpdateInterval, getDuration, getProperty, getScale, getStartTime, getStopTime, getTimelineTime, getTrack, getUpdateInterval, getVirtualTime, hasAttachedFile, hasChildren, isAttachedFileRelative, isEventTime, isInput, isScalable, isSettable, load, nextEventTime, setAttachedFileName, setData, setInterval, setName, setScalable, setStartStopTimes, setStartTime, setStopTime, setTrack, setUpdateInterval
finalize, getModel, initialize, isActive, setActive, setModel, setModelFromComponent, write
checkFlag, checkName, checkNameUniqueness, clearFlag, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getSoftReferences, isConnectedToHierarchy, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
getProperty
getChildren, hasChildren
isWritable, write
public static PropertyList myProps
public NumericMonitorProbe()
public NumericMonitorProbe(int vsize, double interval)
public NumericMonitorProbe(int vsize, java.lang.String fileName, double startTime, double stopTime, double interval)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class NumericProbeBase
public void setDataFunction(DataFunction func)
generateData(maspack.matrix.VectorNd, double, double)
method to generate data for this probe. If the data function is set to
null
, then this probe's data is simply set to zero. If the
generateData(maspack.matrix.VectorNd, double, double)
method is overridden by a subclass, then the data
generation is determined instead by the overriding method.getDataFunction()
public DataFunction getDataFunction()
apply(double)
method to generate data for this probe.public boolean getShowTime()
public void setShowTime(boolean enable)
public boolean getShowHeader()
public void setShowHeader(boolean enable)
public void write(java.io.PrintWriter pw, java.lang.String fmtStr, boolean showTime) throws java.io.IOException
NumericInputProbe.read(File)
. The format used for producing floating
point numbers can be controlled using a printf-style format string,
details of which are described in NumberFormat
.pw
- writer which accepts the outputfmtStr
- printf-style format string (if set to null then "%g" will be assumed,
which will produce full precision output).showTime
- if true, then time values are written explicitly. Otherwise, an implicit
step size corresponding to the value returned by getUpdateInterval
will be specified.java.io.IOException
- if an I/O error occurs.public void setAttachedFileName(java.lang.String fileName, java.lang.String fmtStr)
public void setAttachedFileName(java.lang.String fileName, java.lang.String fmtStr, boolean showTime, boolean showHeader)
public void save() throws java.io.IOException
save
in class Probe
java.io.IOException
write(java.io.PrintWriter, java.lang.String, boolean)
public void writeData(java.io.PrintWriter pw, java.lang.String fmtStr, boolean showTime)
public void generateData(VectorNd vec, double t, double trel)
vec
. The size of
vec
will equal the vector size of the probe (as returned by
NumericProbeBase.getVsize()
. The function may generate the data using either
absolute time t
or relative time trel
, where
relative time is determined from the probe's start time and scale factor
using trel = (t - startTime)/scale
vec
- returns the generated data.t
- absolute time (seconds)trel
- probe relative timepublic void apply(double t)
Probe
apply
in class NumericProbeBase
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class NumericProbeBase
java.lang.CloneNotSupportedException
public NumericList getOutput()
public boolean scanItem(ReaderTokenizer rtok, java.util.Deque<ScanToken> tokens) throws java.io.IOException
java.io.IOException
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
write
.scan
in interface ModelComponent
scan
in interface Scannable
scan
in class Probe
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objectsjava.io.IOException
- if an I/O or formatting error occuredpublic void writeItems(java.io.PrintWriter pw, NumberFormat fmt, CompositeComponent ancestor) throws java.io.IOException
Probe
pw
- writer to which components are writtenfmt
- format for floating point numbersancestor
- ancestor component which respect to which references are
expressedjava.io.IOException
- if an I/O error occurredpublic void setVsize(int vsize)
public void setVsize(int vsize, PlotTraceInfo[] traceInfos)
public boolean hasState()
ModelComponent
hasState
in interface ModelComponent
hasState
in class Probe
true
if this component has statepublic ComponentState createState(ComponentState prevState)
HasState
HasState.setState(artisynth.core.modelbase.ComponentState)
and HasState.getState(artisynth.core.modelbase.ComponentState)
. The state object does not have to be set to the component's
current state. If the component does not have any state information,
this method should return an instance of
EmptyState
.createState
in interface HasState
createState
in class Probe
prevState
- If non-null, supplies a previous state that
was created by this component and which can be used to provide
pre-sizing hints.public void getState(ComponentState state)
HasState
public void setState(ComponentState state)
HasState
public void getInitialState(ComponentState newstate, ComponentState oldstate)
HasState
state
. If prevstate
is non-null, then it is
assumed to contain a previous initial state value returned by this
method, and state
should be set to be as consistent with
this previous state as possible. For example, suppose that this component
currently contains subcomponents A, B, and C, while the
prevstate
contains the state from a previous time when it
had components B, C, and D. Then state
should contain
substate values for B and C that are taken from
prevstate
. To facilitate this, the information returned in
state
should contain additional information such as the
identities of all the (current) sub-components.getInitialState
in interface HasState
getInitialState
in class Probe
newstate
- receives the state informationoldstate
- previous state information; may be null
.public boolean isDuplicatable()
true
if and only if CopyableComponent.getCopyReferences(java.util.List<artisynth.core.modelbase.ModelComponent>, artisynth.core.modelbase.ModelComponent)
returns true.
This method is not currently used. It is intended to provide a faster
way of determining if a component can be duplicated, without having to
use CopyableComponent.getCopyReferences(java.util.List<artisynth.core.modelbase.ModelComponent>, artisynth.core.modelbase.ModelComponent)
to build the list of copy references.
isDuplicatable
in interface CopyableComponent
true
if this component can be duplicated.public boolean isCloneable()
isCloneable
in class NumericProbeBase
public boolean getCopyReferences(java.util.List<ModelComponent> refs, ModelComponent ancestor)
true
if and only if CopyableComponent.isDuplicatable()
returns
true.getCopyReferences
in interface CopyableComponent
refs
- list to which references are appendedancestor
- root node of the hierarchy from which references are to be excludedpublic ModelComponent copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
CopyableComponent
COPY_REFERENCES
is set in flags
, then any component referenced
by this component should itself be set to a copy. This
should be done first checking copyMap
for an
existing copy of the referenced component. If there is no existing
copy, then a copy should be created by calling copy
recursively and adding the new copy to copyMap
.copy
in interface CopyableComponent
copy
in class ModelComponentBase
flags
- flags to control the copyingcopyMap
- map to possible existing instances of referenced
components