Package jmri.jmrix.openlcb
Class OlcbSensor
java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.implementation.AbstractSensor
jmri.jmrix.openlcb.OlcbSensor
- All Implemented Interfaces:
Comparable<NamedBean>,PropertyChangeProvider,DigitalIO,NamedBean,Sensor
Extend jmri.AbstractSensor for OpenLCB controls.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameExceptionNested classes/interfaces inherited from interface jmri.Sensor
Sensor.PullResistance -
Field Summary
FieldsModifier and TypeFieldDescription(package private) EventTable.EventTableEntryHolder(package private) OlcbAddress(package private) OlcbAddress(package private) EventTable.EventTableEntryHolder(package private) static final int(package private) BitProducerConsumer(package private) VersionedValueListener<Boolean>Fields inherited from class jmri.implementation.AbstractSensor
_inverted, _knownState, _rawState, r, sensorDebounceGoingActive, sensorDebounceGoingInActive, thr, useDefaultTimerSettingsFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWNFields inherited from interface jmri.Sensor
ACTIVE, INACTIVE, MAX_DEBOUNCE, PROPERTY_ACTIVE_TIMER, PROPERTY_GLOBAL_TIMER, PROPERTY_INACTIVE_TIMER, PROPERTY_SENSOR_INVERTED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanBy default, all implementations based on this can invertintcompareSystemNameSuffix(String suffix1, String suffix2, NamedBean n) Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)operation.voiddispose()Deactivate this object, so that it releases as many resources as possible and no longer effects others.(package private) voidHelper function that will be invoked after construction once the properties have been loaded.getEventID(boolean isActive) getEventName(boolean isActive) Computes the display name of a given event to be entered into the Event Table.Get a recommended text for a tooltip when displaying the NamedBean, e.g. in a list or table.booleanbooleanvoidRequest an update on status by sending an OpenLCB message.voidsetAuthoritative(boolean authoritative) Changes how the sensor reacts to inquire state events.voidsetKnownState(int s) User request to set the state, which means that we broadcast that to all listeners by putting it out on CBUS.voidsetListeningToStateMessages(boolean listen) Changes how the sensor reacts to state declaration messages.voidsetProperty(String key, Object value) Attach a key/value pair to the NamedBean, which can be retrieved later.(package private) voidHave sensor return to inactive after delay, used if no inactive event was specifiedvoidUpdates event table entries when the user name changes.Methods inherited from class jmri.implementation.AbstractSensor
describeState, getBeanType, getInverted, getKnownState, getPullResistance, getRawState, getReporter, getSensorDebounceGoingActiveTimer, getSensorDebounceGoingInActiveTimer, getState, getUseDefaultTimerSettings, sensorDebounce, setInverted, setOwnState, setPullResistance, setReporter, setSensorDebounceGoingActiveTimer, setSensorDebounceGoingInActiveTimer, setState, setUseDefaultTimerSettings, stateChangeCheckMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, toString, toStringSuffix, updateListenerRef, vetoableChangeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareTo, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUsageReport, getUserName, removeProperty, setComment, toString, updateListenerRef, vetoableChangeMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.Sensor
getCommandedState, isConsistentState, setCommandedState
-
Field Details
-
ON_TIME
- See Also:
-
addrActive
-
addrInactive
-
sensorListener
-
pc
-
activeEventTableEntryHolder
-
inactiveEventTableEntryHolder
-
-
Constructor Details
-
OlcbSensor
-
-
Method Details
-
finishLoad
void finishLoad()Helper function that will be invoked after construction once the properties have been loaded. Used specifically for preventing double initialization when loading sensors from XML. -
getEventName
Computes the display name of a given event to be entered into the Event Table.- Parameters:
isActive- true for sensor active, false for inactive.- Returns:
- user-visible string to represent this event.
-
getEventID
-
getRecommendedToolTip
Description copied from interface:NamedBeanGet a recommended text for a tooltip when displaying the NamedBean, e.g. in a list or table. By default, this is the comment from the NamedBean, on the theory that the system name and/or user name are being displayed directly. Specific system implementations may override that.- Returns:
- empty String if no recommendation.
-
setUserName
@OverridingMethodsMustInvokeSuper public void setUserName(String s) throws NamedBean.BadUserNameException Updates event table entries when the user name changes.- Specified by:
setUserNamein interfaceNamedBean- Overrides:
setUserNamein classAbstractNamedBean- Parameters:
s- new user name- Throws:
NamedBean.BadUserNameException- seeNamedBean
-
requestUpdateFromLayout
Request an update on status by sending an OpenLCB message. -
setKnownState
User request to set the state, which means that we broadcast that to all listeners by putting it out on CBUS. In turn, the code in this class should use setOwnState to handle internal sets and bean notifies.- Specified by:
setKnownStatein interfaceSensor- Overrides:
setKnownStatein classAbstractSensor- Parameters:
s- the state to set
-
setTimeout
void setTimeout()Have sensor return to inactive after delay, used if no inactive event was specified -
setAuthoritative
Changes how the sensor reacts to inquire state events. With authoritative == false the state will always be reported as UNKNOWN to the layout when queried.- Parameters:
authoritative- whether we should respond true state or unknown to the layout event state inquiries.
-
isAuthoritative
- Returns:
- whether this producer/consumer is enabled to return state to the layout upon queries.
-
setProperty
Description copied from class:AbstractNamedBeanAttach a key/value pair to the NamedBean, which can be retrieved later. These are not bound properties as yet, and don't throw events on modification. Key must not be null.The key is constrained to String to make these behave like normal Java Beans.
- Specified by:
setPropertyin interfaceNamedBean- Overrides:
setPropertyin classAbstractNamedBean- Parameters:
key- the property to setvalue- the value of the property
-
isListeningToStateMessages
- Returns:
- whether this producer/consumer is always listening to state declaration messages.
-
setListeningToStateMessages
Changes how the sensor reacts to state declaration messages. With listen == true state declarations will update local state at all times. With listen == false state declarations will update local state only if local state is unknown.- Parameters:
listen- whether we should always listen to state declaration messages.
-
canInvert
Description copied from class:AbstractSensorBy default, all implementations based on this can invert- Specified by:
canInvertin interfaceSensor- Overrides:
canInvertin classAbstractSensor- Returns:
- true if can be inverted; false otherwise
-
dispose
Description copied from class:AbstractNamedBeanDeactivate this object, so that it releases as many resources as possible and no longer effects others.For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.
It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.
Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.
-
compareSystemNameSuffix
@CheckReturnValue public int compareSystemNameSuffix(@Nonnull String suffix1, @Nonnull String suffix2, @Nonnull NamedBean n) Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)operation. This is intended to be a system-specific comparison that understands the various formats, etc. By default, does an alphanumeric-by-chunks comparison. Sorts by decoded EventID(s)- Specified by:
compareSystemNameSuffixin interfaceNamedBean- Overrides:
compareSystemNameSuffixin classAbstractNamedBean- Parameters:
suffix1- The suffix for the 1st bean in the comparisonsuffix2- The suffix for the 2nd bean in the comparisonn- The other (second) NamedBean in the comparison- Returns:
- -1,0,+1 for ordering if the names are well-formed; may not provide proper ordering if the names are not well-formed.
-