Class DelayedStatusUpdateEvent

java.lang.Object
java.util.EventObject
jpos.events.JposEvent
jpos.events.StatusUpdateEvent
de.gmxhome.conrad.jpos.jpos_base.JposStatusUpdateEvent
de.gmxhome.conrad.jpos.jpos_base.DelayedStatusUpdateEvent
All Implemented Interfaces:
Serializable, Runnable
Direct Known Subclasses:
MotionSensorStatusUpdateEvent

public class DelayedStatusUpdateEvent extends JposStatusUpdateEvent implements Runnable
This class provides additional methods that allow firing StatusUpdateEvents with a specific delay. In this implementation, only one event can be buffered for delayed firing per enabled device. Subsequent delayed status update events will overwrite previously buffered events (only the last one will be fired after the delay).
This kind of event has been implemented for MotionSensor functionality, but can be used for other device classes as well if delaying status update events shall be used.
See Also:
Serialized Form
  • Field Details

    • CANCEL_ONLY

      public static final long CANCEL_ONLY
      Return value for handleDelay. If an event has been buffered for delayed firing, both events (this and the buffered event) will be silently ignored. If no event has been buffered, the event will be fired immediately.
      See Also:
      Constant Field Values
    • CANCEL_FIRE

      public static final long CANCEL_FIRE
      Return value for handleDelay. If an event has been buffered for delayed firing, the buffered event will be removed without firing it. The event itself will be fired immediately.
      See Also:
      Constant Field Values
  • Constructor Details

    • DelayedStatusUpdateEvent

      public DelayedStatusUpdateEvent(JposBase source, int state)
      Constructor, Parameters passed to base class unchanged.
      Parameters:
      source - Source, for services implemented with this framework, the (deviceclass.)DeviceClassService object.
      state - Status, see UPOS specification.
  • Method Details

    • handleDelay

      public long handleDelay()
      This method must be implemented in derived classes. It specifies how delayed events shall be handled.
      Returns:
      0 if event shall be fired immediately without affecting any delayed event.
      Any value > 0 specifies the delay (in milliseconds) for firing this event (any previously buffered delayed event will not be fired).
      CANCEL_ONLY specifies that this event shall only be fired immediately if no delayed event has been buffered previously. Otherwise, neither the buffered nor this event shall be fired.
      CANCEL_FIRE specify that any buffered event shall not be fired. This event will be fired immediately.
    • copyEvent

      public JposStatusUpdateEvent copyEvent(JposBase o)
      Description copied from class: JposStatusUpdateEvent
      Creates copy of given event for a different property set. Needed for shareable devices only.
      Overrides:
      copyEvent in class JposStatusUpdateEvent
      Parameters:
      o - Source (JposDevice) of the event
      Returns:
      Copy of the event to be handled by the given source.
    • block

      public boolean block()
      For delayed status update events, block must return true to avoid firing the event immediately. If delayed, firing occurs in a completely different place.
      Overrides:
      block in class JposStatusUpdateEvent
      Returns:
      If firing shall be delayed or if event firing shall be blocked due to different reason.
    • run

      public void run()
      Specified by:
      run in interface Runnable