Package nl.tno.imb

Class TEventEntry


  • public class TEventEntry
    extends java.lang.Object
    This class implements the events that can be send and received over the IMB framework.
    Handlers can be attached to events that get called when specified events are received.
    Author:
    hans.cornelissen@tno.nl
    • Field Detail

      • EK_CHANGE_OBJECT_EVENT

        public static final int EK_CHANGE_OBJECT_EVENT
        event kind: change object
        See Also:
        Constant Field Values
      • EK_STREAM_HEADER

        public static final int EK_STREAM_HEADER
        event kind: header of a stream
        See Also:
        Constant Field Values
      • EK_STREAM_BODY

        public static final int EK_STREAM_BODY
        event kind: body of a stream
        See Also:
        Constant Field Values
      • EK_STREAM_TAIL

        public static final int EK_STREAM_TAIL
        event kind: end of a stream
        See Also:
        Constant Field Values
      • EK_NORMAL_EVENT

        public static final int EK_NORMAL_EVENT
        event kind: normal event
        See Also:
        Constant Field Values
      • EK_CHANGE_OBJECT_DATA_EVENT

        public static final int EK_CHANGE_OBJECT_DATA_EVENT
        event kind: change object including changed data
        See Also:
        Constant Field Values
      • EK_CHILD_EVENT_ADD

        public static final int EK_CHILD_EVENT_ADD
        event kind: a child event was created
        See Also:
        Constant Field Values
      • EK_CHILD_EVENT_REMOVE

        public static final int EK_CHILD_EVENT_REMOVE
        event kind: a child event was removed
        See Also:
        Constant Field Values
      • EK_LOG_WRITELN

        public static final int EK_LOG_WRITELN
        event kind: send a line to the log
        See Also:
        Constant Field Values
      • EK_TIMER_CANCEL

        public static final int EK_TIMER_CANCEL
        event kind: cancel/remove a running timer
        See Also:
        Constant Field Values
      • EK_TIMER_PREPARE

        public static final int EK_TIMER_PREPARE
        event kind: reset a timer
        See Also:
        Constant Field Values
      • EK_TIMER_START

        public static final int EK_TIMER_START
        event kind: start or continue a timer
        See Also:
        Constant Field Values
      • EK_TIMER_STOP

        public static final int EK_TIMER_STOP
        event kind: stop a running timer
        See Also:
        Constant Field Values
      • EK_TIMER_ACKNOWLEDGE_LIST_ADD

        public static final int EK_TIMER_ACKNOWLEDGE_LIST_ADD
        event kind: add client to the acknowledge list of a timer
        See Also:
        Constant Field Values
      • EK_TIMER_ACKNOWLEDGE_LIST_REMOVE

        public static final int EK_TIMER_ACKNOWLEDGE_LIST_REMOVE
        event kind: remove client from the acknowledge list of a timer
        See Also:
        Constant Field Values
      • EK_TIMER_SET_SPEED

        public static final int EK_TIMER_SET_SPEED
        event kind: set the relative speed of the timer
        See Also:
        Constant Field Values
      • EK_TIMER_TICK

        public static final int EK_TIMER_TICK
        event kind: timer tick
        See Also:
        Constant Field Values
      • EK_TIMER_ACKNOWLEDGE

        public static final int EK_TIMER_ACKNOWLEDGE
        event kind: acknowledge timer tick
        See Also:
        Constant Field Values
      • EK_TIMER_STATUS_REQUEST

        public static final int EK_TIMER_STATUS_REQUEST
        event kind: request status update of a timer
        See Also:
        Constant Field Values
      • TRC_INFINITE

        public static final int TRC_INFINITE
        no limit on the number of timer events to send
        See Also:
        Constant Field Values
      • ID

        public final int ID
        The local ID related to this event
      • onTimerCmd

        public TEventEntry.TOnTimerCmd onTimerCmd
        Handler to be called on receive of a timer command reset/start/stop
      • ACTION_NEW

        public static final int ACTION_NEW
        signal an object change: a new object is created
        See Also:
        Constant Field Values
      • ACTION_DELETE

        public static final int ACTION_DELETE
        signal an object change: an object is deleted
        See Also:
        Constant Field Values
      • ACTION_CHANGE

        public static final int ACTION_CHANGE
        signal an object change: an existing object has changed
        See Also:
        Constant Field Values
    • Method Detail

      • subscribers

        public boolean subscribers()
      • publishers

        public boolean publishers()
      • getEventName

        public java.lang.String getEventName()
        Returns the fully qualified name of this event
      • getShortEventName

        public java.lang.String getShortEventName()
      • isPublished

        public boolean isPublished()
        Returns true if this event is published
      • isSubscribed

        public boolean isSubscribed()
        Returns true if this event is subscribed
      • copyHandlersFrom

        public void copyHandlersFrom​(TEventEntry aEventEntry)
      • signalEvent

        public int signalEvent​(int aEventKind,
                               byte[] aEventPayload)
        Send an event to the framework
        Parameters:
        aEventKind - int;
        aEventPayload - byte[];
        Returns:
        status of the request (TConnection.ICE_* constants)
      • signalBuffer

        public int signalBuffer​(int aBufferID,
                                byte[] aBuffer)
        Send a buffer event to the framework
        Parameters:
        aBufferID - int; self chosen ID to separate streams of buffer events
        aBuffer - byte[];
        Returns:
        status of the request (TConnection.ICE_* constants)
      • signalBuffer

        public int signalBuffer​(int aBufferID,
                                byte[] aBuffer,
                                int aEventFlags)
        Send a buffer event to the framework
        Parameters:
        aBufferID - int; self chosen ID to separate streams of buffer events
        aBuffer - byte[];
        aEventFlags - flags for special processing within the hub; not fully implemented, use 0
        Returns:
        status of the request (TConnection.ICE_* constants)
      • signalStream

        public int signalStream​(java.lang.String aStreamName,
                                java.io.InputStream aStream)
        Send a stream to the framework
        Parameters:
        aStreamName - String;
        aStream - InputStream;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • signalChangeObject

        public int signalChangeObject​(int aAction,
                                      int aObjectID,
                                      java.lang.String aAttribute)
        Send a change object event to the framework
        Parameters:
        aAction - int; see ACTION_* constants
        aObjectID - int; ID of the object that has changed
        aAttribute - String; optional name of the attribute that has changed
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerCreate

        public int timerCreate​(java.lang.String aTimerName,
                               long aStartTimeUTCorRelFT,
                               int aResolutionms,
                               double aSpeedFactor)
        Create a timer on the connected HUB
        Parameters:
        aTimerName - String; unique name of the timer within this event
        aStartTimeUTCorRelFT - long; 0 means now<br> larger than 0 means in absolute system time (UTC)
        less than 0 means system timer relative to now
        aResolutionms - int; the resolution of a timer tick (step) in milliseconds
        aSpeedFactor - double; 1 means same speed as real time, 0 means the timer runs in simulation time
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerCreate

        public int timerCreate​(java.lang.String aTimerName,
                               long aStartTimeUTCorRelFT,
                               int aResolutionms,
                               double aSpeedFactor,
                               int aRepeatCount)
        Create a timer on the connected HUB
        Parameters:
        aTimerName - String; unique name of the timer within this event
        aStartTimeUTCorRelFT - long; 0 means now<br> larger than 0 means in absolute system time (UTC)
        less than 0 means system timer relative to now
        aResolutionms - int; the resolution of a timer tick (step) in milliseconds
        aSpeedFactor - double; 1 means same speed as real time, 0 means the timer runs in simulation time
        aRepeatCount - int; number of timer the timer must send a timer tick (TRC_INFINITE for infinite)
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerCancel

        public int timerCancel​(java.lang.String aTimerName)
        Cancel a running timer; the timer is destroyed.
        Parameters:
        aTimerName - String;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerPrepare

        public int timerPrepare​(java.lang.String aTimerName)
        Prepare a timer; the timer is stopped and reset to an initial state
        Parameters:
        aTimerName - String;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerStart

        public int timerStart​(java.lang.String aTimerName)
        Start or continue the timer
        Parameters:
        aTimerName - String;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerStop

        public int timerStop​(java.lang.String aTimerName)
        Stop or pause the timer
        Parameters:
        aTimerName - String;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerSetSpeed

        public int timerSetSpeed​(java.lang.String aTimerName,
                                 double aSpeedFactor)
        Set the relative running speed of the timer
        Parameters:
        aTimerName - String;
        aSpeedFactor - double; 1 means the timer is running in real time, 0 means the timer runs in simulation time
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerAcknowledgeAdd

        public int timerAcknowledgeAdd​(java.lang.String aTimerName,
                                       java.lang.String aClientName)
        Add a client name to the acknowledge list of a timer.
        All entries in this list must send an acknowledge on each timer tick for the timer to advance.
        Parameters:
        aTimerName - String;
        aClientName - String;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerAcknowledgeRemove

        public int timerAcknowledgeRemove​(java.lang.String aTimerName,
                                          java.lang.String aClientName)
        Remove a client name from the acknowledge list of a timer.
        All entries in this list must send an acknowledge on each timer tick for the timer to advance.
        Parameters:
        aTimerName - String;
        aClientName - String;
        Returns:
        status of the request (TConnection.ICE_* constants)
      • timerAcknowledge

        public int timerAcknowledge​(java.lang.String aTimerName,
                                    java.lang.String aClientName,
                                    int aProposedTimeStep)
        Acknowledge a timer tick.
        All clients on the timer acknowledge list must send an acknowledge on each timer tick for the timer to advance.
        Parameters:
        aTimerName - String;
        aClientName - String;
        aProposedTimeStep - int; clients can specify the next step that they wish. The overall lowest next step is used if the timer is not running in real time
        Returns:
        status of the request (TConnection.ICE_* constants)
      • logWriteLn

        public int logWriteLn​(java.lang.String aLine,
                              TEventEntry.TLogLevel aLevel)
        Send a line to the central framework log
        Parameters:
        aLine - String; text to enter into the log
        aLevel - TLogLevel; severity of the entry to log. See TLogLevel for values.
        Returns:
        status of the request (TConnection.ICE_* constants)