Class 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:
    1. OTSNetwork is somehow constructed and then a Publisher for that network is constructed.
    2. Sim0MQ master requests names of all available subscription handlers
    3. 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
    4. 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.
    5. Sim0MQ master requests publisher to list all the elements of the GTUs_in_network SubscriptionHandler
    6. 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
    7. 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.
    8. 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 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 retrieve
        returnWrapper - 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 fails
        SerializationException - 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 fields
        returnWrapper - 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 index addressLevel can not be obtained through a TransceiverInterface object
        Throws:
        Sim0MQException - when the ReturnWrapper fails
        SerializationException - 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 destined
        command - SubscriptionHandler.Command; the operation to perform
        address - Object[]; the address on which to perform the operation
        returnWrapper - ReturnWrapper; to transmit the result
        Throws:
        java.rmi.RemoteException - on RMI network failure
        SerializationException - on illegal type in serialization
        Sim0MQException - 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 destined
        commandString - String; the operation to perform
        address - Object[]; the address on which to perform the operation
        returnWrapper - ReturnWrapper; to transmit the result
        Throws:
        java.rmi.RemoteException - on RMI network failure
        SerializationException - on illegal type in serialization
        Sim0MQException - on communication error