Class MqttLight
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractLight
-
- jmri.implementation.AbstractVariableLight
-
- jmri.jmrix.mqtt.MqttLight
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>,java.util.EventListener,AnalogIO,PropertyChangeProvider,DigitalIO,MqttEventListener,Light,NamedBean,VariableLight
public class MqttLight extends AbstractVariableLight implements MqttEventListener
MQTT implementation of the Light interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.AnalogIO
AnalogIO.AbsoluteOrRelative
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringintensityText(package private) MqttContentParser<Light>parser-
Fields inherited from class jmri.implementation.AbstractVariableLight
alarmSyncUpdate, internalClock, minuteChangeListener, mLastTransitionDate, mNextTransitionTs, mTransitionDuration, mTransitionTargetIntensity
-
Fields inherited from class jmri.implementation.AbstractLight
lightControlList, mActive, mCurrentIntensity, mEnabled, mMaxIntensity, mMinIntensity, mState
-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.Light
FAST_CLOCK_CONTROL, INTERMEDIATE, NO_CONTROL, PROPERTY_TARGET_INTENSITY, SENSOR_CONTROL, TIMED_ON_CONTROL, TRANSITIONING, TRANSITIONINGHIGHER, TRANSITIONINGLOWER, TRANSITIONINGTOFULLOFF, TRANSITIONINGTOFULLON, TURNOUT_STATUS_CONTROL, TWO_SENSOR_CONTROL
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN
-
Fields inherited from interface jmri.VariableLight
PROPERTY_CURRENT_INTENSITY, PROPERTY_MAX_INTENSITY, PROPERTY_MIN_INTENSITY
-
-
Constructor Summary
Constructors Constructor Description MqttLight(MqttAdapter ma, java.lang.String systemName, java.lang.String userName, java.lang.String sendTopic, java.lang.String rcvTopic)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Deactivate this object, so that it releases as many resources as possible and no longer effects others.protected voiddoNewState(int oldState, int newState)Implement the specific change of state needed by hardware.protected intgetNumberOfSteps()Provide the number of steps available between min and max intensityvoidnotifyMqttMessage(java.lang.String receivedTopic, java.lang.String message)voidrequestUpdateFromLayout()Request an update from the layout soft/hardware.protected voidsendIntensity(double intensity)Send a Dim/Bright commands to the hardware to reach a specific intensity.protected voidsendOnOffCommand(int newState)Send a On/Off Command to the hardwarevoidsetParser(MqttContentParser<Light> parser)voidsetState(int newState)Handle a request for a state change.-
Methods inherited from class jmri.implementation.AbstractVariableLight
describeState, getAbsoluteOrRelative, getCommandedAnalogValue, getCurrentIntensity, getMax, getMaxIntensity, getMin, getMinIntensity, getResolution, getState, getTargetIntensity, getTransitionTime, isTransitionAvailable, isTransitioning, newInternalMinute, notifyTargetIntensityChange, setCommandedAnalogValue, setMaxIntensity, setMinIntensity, setObservedAnalogValue, setState, setTargetIntensity, setTransitionTime, startTransition
-
Methods inherited from class jmri.implementation.AbstractLight
activateLight, addLightControl, clearLightControls, deactivateLight, getBeanType, getEnabled, getLightControlList, getState, getUsageReport, notifyStateChange, setEnabled
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChange
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.AnalogIO
getKnownAnalogValue
-
Methods inherited from interface jmri.Light
activateLight, addLightControl, clearLightControls, deactivateLight, getCommandedState, getEnabled, getKnownState, getLightControlList, getState, setCommandedState, setEnabled
-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.VariableLight
isConsistentState, isConsistentValue
-
-
-
-
Field Detail
-
intensityText
public static java.lang.String intensityText
-
parser
MqttContentParser<Light> parser
-
-
Constructor Detail
-
MqttLight
public MqttLight(MqttAdapter ma, java.lang.String systemName, java.lang.String userName, java.lang.String sendTopic, java.lang.String rcvTopic)
-
-
Method Detail
-
setParser
public void setParser(MqttContentParser<Light> parser)
-
getNumberOfSteps
protected int getNumberOfSteps()
Description copied from class:AbstractVariableLightProvide the number of steps available between min and max intensity- Specified by:
getNumberOfStepsin classAbstractVariableLight- Returns:
- number of steps
-
sendIntensity
protected void sendIntensity(double intensity)
Description copied from class:AbstractVariableLightSend a Dim/Bright commands to the hardware to reach a specific intensity.- Specified by:
sendIntensityin classAbstractVariableLight- Parameters:
intensity- new intensity
-
sendOnOffCommand
protected void sendOnOffCommand(int newState)
Description copied from class:AbstractVariableLightSend a On/Off Command to the hardware- Specified by:
sendOnOffCommandin classAbstractVariableLight- Parameters:
newState- new state
-
doNewState
protected void doNewState(int oldState, int newState)
Description copied from class:AbstractLightImplement the specific change of state needed by hardware.- Overrides:
doNewStatein classAbstractLight- Parameters:
oldState- old statenewState- new state
-
setState
public void setState(int newState)
Description copied from class:AbstractVariableLightHandle a request for a state change. ON and OFF go to the MaxIntensity and MinIntensity, specifically, and all others are not permittedON and OFF avoid use of variable intensity if MaxIntensity = 1.0 or MinIntensity = 0.0, and no transition is being used.
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
Description copied from interface:VariableLightRequest an update from the layout soft/hardware. May not even happen, and if it does it will happen later; listen for the result.- Specified by:
requestUpdateFromLayoutin interfaceAnalogIO- Specified by:
requestUpdateFromLayoutin interfaceDigitalIO- Specified by:
requestUpdateFromLayoutin interfaceLight- Specified by:
requestUpdateFromLayoutin interfaceVariableLight
-
notifyMqttMessage
public void notifyMqttMessage(java.lang.String receivedTopic, java.lang.String message)
- Specified by:
notifyMqttMessagein interfaceMqttEventListener
-
dispose
public void 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.
- Specified by:
disposein interfaceNamedBean- Overrides:
disposein classAbstractNamedBean
-
-