Class PubSubIMBMessageHandler

  • All Implemented Interfaces:
    java.io.Serializable, org.opentrafficsim.imb.transceiver.IMBMessageHandler

    public class PubSubIMBMessageHandler
    extends java.lang.Object
    implements org.opentrafficsim.imb.transceiver.IMBMessageHandler
    The PubSubIMBMessageHandler handles the IMB message by transforming it into a DSOL Event and sending it to an EventListener at the current simulation time through a simulation event. The EventListener is identified by the OTSToIMBTransformer and stored in an IMBTransformResult after parsing the IMB message.

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Sep 11, 2016
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    See Also:
    Serialized Form
    • Constructor Detail

      • PubSubIMBMessageHandler

        public PubSubIMBMessageHandler​(java.lang.String imbEventName,
                                       TimedEventType eventType,
                                       IMBToOTSTransformer imbToOTSTransformer,
                                       DEVSSimulatorInterface.TimeDoubleUnit simulator)
                                throws org.opentrafficsim.imb.IMBException
        Construct a new PubSubIMBMessageHandler. The PubSubIMBMessageHandler handles the IMB message by transforming it into a DSOL Event and sending it to the EventListener at the current simulation time through a simulation event.
        Parameters:
        imbEventName - String; the name of the IMB event
        eventType - TimedEventType; the event type that the listener subscribes to
        imbToOTSTransformer - IMBToOTSTransformer; the transformer that creates the event content and identifies the exact listener on the basis of the IBM event payload, e.g., on the basis of an id within the payload
        simulator - DEVSSimulatorInterface.TimeDoubleUnit; The simulator to schedule the incoming notifications on
        Throws:
        org.opentrafficsim.imb.IMBException - in case the construction fails
    • Method Detail

      • handle

        public void handle​(nl.tno.imb.TByteBuffer imbPayload)
                    throws org.opentrafficsim.imb.IMBException
        Handle the event by notifying the EventListener that was identified by the imbPayload through the imbToOTSTransformer. The notification is scheduled on the simulator to make sure that the separate thread that receives events from IMB does not interfere with the execution of the OTS simulation.
        Specified by:
        handle in interface org.opentrafficsim.imb.transceiver.IMBMessageHandler
        Parameters:
        imbPayload - TByteBuffer; the IMB payload
        Throws:
        org.opentrafficsim.imb.IMBException - in case the message cannot be handled
      • getIMBEventName

        public final java.lang.String getIMBEventName()
        Specified by:
        getIMBEventName in interface org.opentrafficsim.imb.transceiver.IMBMessageHandler