Class Publisher
- java.lang.Object
-
- org.opentrafficsim.sim0mq.publisher.AbstractTransceiver
-
- org.opentrafficsim.sim0mq.publisher.Publisher
-
- All Implemented Interfaces:
Identifiable
,TransceiverInterface
public class Publisher extends AbstractTransceiver
Publish all available transceivers for an OTS network to a Sim0MQ master and handle its requests.
Example sequence of events:
- OTSNetwork is somehow constructed and then a Publisher for that network is constructed.
- Sim0MQ master requests names of all available subscription handlers
- Sim0MQ master decides that it wants all GTU MOVE events of all GTUs. To do that it needs to know about all GTUs when they are created and about all GTUs that have already been created. The Sim0MQ master issues to the publisher a request to subscribe to all NETWORK.GTU_ADD_EVENTs of the GTUs_in_network SubscriptionHandler
- This Publisher requests the GTUs_in_network SubscriptionHandler to subscribe to the add events. From now on, the GTUs_in_network SubscriptionHandler will receive these events generated by the OTSNetwork and transcribe those into a Sim0MQ events which are transmitted to the Sim0MQ master.
- Sim0MQ master requests publisher to list all the elements of the GTUs_in_network SubscriptionHandler
- This Publisher calls the list method of the GTUs_in_network SubscriptionHandler which results in a list of all active GTUs being sent to the Sim0MQ master
- The Sim0MQ master requests this Publisher to create a subscription for the update events of the GTU_move SubscriptionHandler, providing the GTU id as address. It does that once for every GTU id.
- This Publishers creates the subscriptions. From now on any GTU.MOVE_EVENT event is transcribed by the GTU_move SubscriptionHandler in to a corresponding Sim0MQ event and sent to the Sim0MQ master.
Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate: 2020-02-13 11:08:16 +0100 (Thu, 13 Feb 2020) $, @version $Revision: 6383 $, by $Author: pknoppers $,
- Author:
- Alexander Verbraeck, Peter Knoppers
-
-
Constructor Summary
Constructors Constructor Description Publisher(OTSNetwork network)
Construct a Publisher for an OTS network.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeCommand(java.lang.String subscriptionHandlerName, java.lang.String commandString, java.lang.Object[] address, ReturnWrapperImpl returnWrapper)
Execute one command.void
executeCommand(java.lang.String subscriptionHandlerName, SubscriptionHandler.Command command, java.lang.Object[] address, ReturnWrapper returnWrapper)
Execute one command.java.lang.Object[]
get(java.lang.Object[] address, ReturnWrapper returnWrapper)
Retrieve the data.TransceiverInterface
getIdSource(int addressLevel, ReturnWrapper returnWrapper)
Retrieve the TransceiverInterface that can be used to get detailed information about a single object.boolean
hasIdSource()
Report if this transceiver has an id source.-
Methods inherited from class org.opentrafficsim.sim0mq.publisher.AbstractTransceiver
getAddressFields, getId, getResultFields, toString, verifyMetaData
-
-
-
-
Constructor Detail
-
Publisher
public Publisher(OTSNetwork network) throws java.rmi.RemoteException
Construct a Publisher for an OTS network.- Parameters:
network
- OTSNetwork; the OTS network- Throws:
java.rmi.RemoteException
- ...
-
-
Method Detail
-
get
public java.lang.Object[] get(java.lang.Object[] address, ReturnWrapper returnWrapper) throws Sim0MQException, SerializationException
Retrieve the data.- Parameters:
address
- Object[]; the address of the data to retrievereturnWrapper
- ReturnWrapper; to be used to report problems- Returns:
- Object[]; the retrieved data, or null when no object with the address could be found
- Throws:
Sim0MQException
- when encoding an error message failsSerializationException
- when encoding an error message fails
-
getIdSource
public TransceiverInterface getIdSource(int addressLevel, ReturnWrapper returnWrapper) throws Sim0MQException, SerializationException
Retrieve the TransceiverInterface that can be used to get detailed information about a single object.- Parameters:
addressLevel
- int; index of the argument in the address fieldsreturnWrapper
- ReturnWrapper; to be used to report problems- Returns:
- TransceiverInterface; to be used to get valid values for argument
addressLevel
, or null if valid values for the argument at indexaddressLevel
can not be obtained through a TransceiverInterface object - Throws:
Sim0MQException
- when the ReturnWrapper failsSerializationException
- when the ReturnWrapper fails
-
hasIdSource
public boolean hasIdSource()
Report if this transceiver has an id source.- Returns:
- boolean; true if this transceiver has an id source; false if this transceiver does not have an id source
-
executeCommand
public void executeCommand(java.lang.String subscriptionHandlerName, SubscriptionHandler.Command command, java.lang.Object[] address, ReturnWrapper returnWrapper) throws java.rmi.RemoteException, Sim0MQException, SerializationException
Execute one command.- Parameters:
subscriptionHandlerName
- String; name of the SubscriptionHandler for which the command is destinedcommand
- SubscriptionHandler.Command; the operation to performaddress
- Object[]; the address on which to perform the operationreturnWrapper
- ReturnWrapper; to transmit the result- Throws:
java.rmi.RemoteException
- on RMI network failureSerializationException
- on illegal type in serializationSim0MQException
- on communication error
-
executeCommand
public void executeCommand(java.lang.String subscriptionHandlerName, java.lang.String commandString, java.lang.Object[] address, ReturnWrapperImpl returnWrapper) throws java.rmi.RemoteException, Sim0MQException, SerializationException
Execute one command.- Parameters:
subscriptionHandlerName
- String; name of the SubscriptionHandler for which the command is destinedcommandString
- String; the operation to performaddress
- Object[]; the address on which to perform the operationreturnWrapper
- ReturnWrapper; to transmit the result- Throws:
java.rmi.RemoteException
- on RMI network failureSerializationException
- on illegal type in serializationSim0MQException
- on communication error
-
-