Class PubSubIMBMessageHandler
java.lang.Object
org.opentrafficsim.imb.transceiver.PubSubIMBMessageHandler
- All Implemented Interfaces:
Serializable,org.opentrafficsim.imb.transceiver.IMBMessageHandler
public class PubSubIMBMessageHandler extends 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.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description PubSubIMBMessageHandler(String imbEventName, EventType eventType, IMBToOTSTransformer imbToOTSTransformer, DEVSSimulatorInterface.TimeDoubleUnit simulator)Construct a new PubSubIMBMessageHandler. -
Method Summary
Modifier and Type Method Description StringgetIMBEventName()voidhandle(nl.tno.imb.TByteBuffer imbPayload)Handle the event by notifying the EventListener that was identified by the imbPayload through the imbToOTSTransformer.
-
Constructor Details
-
PubSubIMBMessageHandler
public PubSubIMBMessageHandler(String imbEventName, EventType eventType, IMBToOTSTransformer imbToOTSTransformer, DEVSSimulatorInterface.TimeDoubleUnit simulator) throws org.opentrafficsim.imb.IMBExceptionConstruct 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 eventeventType- EventType; the event type that the listener subscribes toimbToOTSTransformer- 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 payloadsimulator- DEVSSimulatorInterface.TimeDoubleUnit; The simulator to schedule the incoming notifications on- Throws:
org.opentrafficsim.imb.IMBException- in case the construction fails
-
-
Method Details
-
handle
public void handle(nl.tno.imb.TByteBuffer imbPayload) throws org.opentrafficsim.imb.IMBExceptionHandle 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:
handlein interfaceorg.opentrafficsim.imb.transceiver.IMBMessageHandler- Parameters:
imbPayload- TByteBuffer; the IMB payload- Throws:
org.opentrafficsim.imb.IMBException- in case the message cannot be handled
-
getIMBEventName
- Specified by:
getIMBEventNamein interfaceorg.opentrafficsim.imb.transceiver.IMBMessageHandler
-