public class MonitorField extends Object
Instances can be registered as default handlers for data channel attribute keys.
Equality and hash code are based on object identity.
| Modifier and Type | Class and Description |
|---|---|
static class |
MonitorField.Average |
| Constructor and Description |
|---|
MonitorField(MonitorField other)
Deep copy constructor.
|
MonitorField(String key,
String title,
FormattedValue template)
Constructs an instance without specifying the set of affecting keys.
|
MonitorField(String key,
String title,
FormattedValue template,
Set<String> keys)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected FormattedValue |
colorConfigurationParameter(FormattedValue fv,
AgentChannel channel)
Applies configuration parameter specific formatting.
|
protected FormattedValue |
defaultFormat(AgentChannel channel,
FormattedValue fv)
Applies standard formatting, without overwriting fields already set on the provided
FormattedValue. |
static String |
fieldToString(MonitorField field)
Converts
MonitorField to its string representation. |
FormattedValue |
format(AgentChannel channel)
Computes the current formatted value of this field in the specified data channel.
|
FormattedValue |
format(List<AgentChannel> channels)
Computes the current formatted value of this field for the specified list of channels.
|
static List<MonitorField> |
getAffectedFields(Collection<String> keys) |
static List<MonitorField> |
getAffectedFields(Collection<String> keys,
Collection<MonitorField> fields) |
static List<MonitorField> |
getDefaultFields(Collection<String> keys) |
static MonitorField |
getInstance(String key)
Returns an instance identified by the specified string.
|
String |
getKey()
Returns a unique key of this field.
|
Set<String> |
getKeys()
Returns a set of keys of data channel attributes that might effect the value of this field or its formatting.
|
static MonitorField |
getRegisteredInstance(String key)
Returns an instance registered as the default handler for the attribute identified
by the specified key, or
null if no such instance exists. |
String |
getTitle()
Returns human readable title associated with this field.
|
Object |
getValue(AgentChannel channel)
Returns the current value of this field in the specified data channel, or
null
if the channel does not contain a value for this field. |
boolean |
isUpdatable() |
FormattedValue |
merge(List<FormattedValue> values)
Merges zero or more formatted values.
|
Color |
mergeConfigColor(Color c1,
Color c2)
Merges colors used to indicate a state of a configurable parameter.
|
Color |
mergeStateColor(Color c1,
Color c2)
Merges colors used to indicate the channel state.
|
static void |
registerInstance(MonitorField field)
Registers the specified instance as the default handler for the attribute
identified by the key returned by its
getKey() method. |
static MonitorField |
stringToField(String field)
Returns
MonitorField given its string representation. |
String |
toString()
Returns the human readable title of this field.
|
public static final Color COLOR_FG
public static final Color COLOR_BG
public static final Color COLOR_CHANGED
public static final Color COLOR_GOOD
public static final Color COLOR_WARN
public static final Color COLOR_ERR
public static final Color COLOR_DISABLED
public static final Color COLOR_OFF
public static final Color COLOR_POPUP
public static final Color COLOR_MULTI
public static final Color COLOR_NA
public static final EnumMap<org.lsst.ccs.bus.states.DataProviderState,Color> COLOR_STATE
public static final String TEXT_MULTI
public static final int HA_MULTI
public static final MonitorField NULL
public static final MonitorField NAME
public static final MonitorField VALUE
public static final MonitorField UNITS
public static final MonitorField LOW_ALARM
public static final MonitorField LOW_WARN
public static final MonitorField ALERT_LOW
public static final MonitorField HIGH_ALARM
public static final MonitorField HIGH_WARN
public static final MonitorField ALERT_HIGH
public static final MonitorField DESCR
public static final MonitorField AVERAGE_VALUE
public static final MonitorField MAX_VALUE
public static final MonitorField MIN_VALUE
public static final MonitorField MEDIAN_VALUE
public static final MonitorField HOST
public static final MonitorField DEFAULT_GROUP_FIELD
MonitorField to be used for displaying a value corresponding to a group of display channels.public static final MonitorField[] GROUP_FIELDS
MonitorField constants for displaying a value corresponding to a group of display channels.protected String DEFAULT_FLOAT_FORMAT
protected String DEFAULT_INT_FORMAT
protected String DEFAULT_DT_FORMAT
protected int LENGTH_LIMIT
protected final String key
protected final String title
protected final FormattedValue template
public MonitorField(String key, String title, FormattedValue template, Set<String> keys)
key - Attribute key. Unless overridden, getKey() will return this key. The getValue(channel)
method will return the value of the data channel attribute identified by this key.title - Human readable title.template - Formatted value template.keys - Keys of attributes that might affect this field. If null, the field is assumed to be affected
by the attribute specified by the key argument. If that argument is null as well,
the field is not affected by any parameters.public MonitorField(String key, String title, FormattedValue template)
MonitorField(key, title, template, null).key - Attribute key. Unless overridden, getKey() and getKeys()
methods will return this key and a singleton set containing this key, respectively.
The getValue(channel) method will return the value of the data channel attribute
identified by this key.title - Human readable title.template - Formatted value template.public MonitorField(MonitorField other)
other - Field to be cloned.public static void registerInstance(MonitorField field)
getKey() method.field - Instance to register.IllegalArgumentException - if an instance with this key already registered.public static MonitorField getInstance(String key)
new MonitorField(key, key, null), and registered as the default handler for the key.key - Attribute key.public static MonitorField getRegisteredInstance(String key)
null if no such instance exists.key - Attribute key.null if no such instance exists.public static List<MonitorField> getDefaultFields(Collection<String> keys)
public static List<MonitorField> getAffectedFields(Collection<String> keys, Collection<MonitorField> fields)
public static List<MonitorField> getAffectedFields(Collection<String> keys)
public Object getValue(AgentChannel channel)
null
if the channel does not contain a value for this field.channel - Data channel.public String getKey()
public String getTitle()
public Set<String> getKeys()
public boolean isUpdatable()
public FormattedValue format(AgentChannel channel)
template and passes it to defaultFormat(...).
Subclasses may add processing before or after the call to defaultFormat(...) (or re-implement this method from scratch).channel - Data channel.public FormattedValue format(List<AgentChannel> channels)
channels - List of channels.FormattedValue.NA if this field does not support formatting multiple channels).protected FormattedValue defaultFormat(AgentChannel channel, FormattedValue fv)
FormattedValue.channel - Data channel.fv - Partially formatted value.protected FormattedValue colorConfigurationParameter(FormattedValue fv, AgentChannel channel)
fv - Original formatted value. fv.value should be an instance of ConfigurationParameterInfo.channel - Data channel.public FormattedValue merge(List<FormattedValue> values)
values - Formatted values to merge.public Color mergeConfigColor(Color c1, Color c2)
#merge(MonitorField field, List formattedValues).c1 - First color.c2 - Second color.public Color mergeStateColor(Color c1, Color c2)
#merge(MonitorField field, List formattedValues).c1 - First color.c2 - Second color.public String toString()
public static MonitorField stringToField(String field)
MonitorField given its string representation.
The default implementation selects from #AVAILABLE_GROUP_FIELDS, and returns DEFAULT_GROUP_FIELD if none matches.field - String representation of MonitorField.MonitorField corresponding to the provided string.public static String fieldToString(MonitorField field)
MonitorField to its string representation.
The default implementation uses toString().field - MonitorField constant to convert.Copyright © 2023 LSST. All rights reserved.