Class VehicleSubscribe

  • All Implemented Interfaces:
    VehicleSubscribe

    public class VehicleSubscribe
    extends AbstractTraciCommand<Void>
    implements VehicleSubscribe
    This class represents the SUMO command which allows to subscribe the vehicle to the application. Several options for vehicle subscription are implemented in this class.
    • Constructor Detail

      • VehicleSubscribe

        public VehicleSubscribe​(Bridge bridge)
        Creates a new VehicleSubscribe object. Access needs to be public, because command is called using Reflection.
        Parameters:
        bridge - Connection to Traci.
        See Also:
        Variable Subscription
      • VehicleSubscribe

        public VehicleSubscribe​(Bridge bridge,
                                CSumo sumoConfiguration)
        Creates a new VehicleSubscribe object.
        Parameters:
        bridge - Connection to Traci.
        sumoConfiguration - The sumo configuration file.
      • VehicleSubscribe

        public VehicleSubscribe​(Bridge bridge,
                                Collection<SumoVar> subscriptionCodes)
        Creates a new VehicleSubscribe object. Access needs to be public, because command is called using Reflection.
        Parameters:
        bridge - Connection to Traci.
        subscriptionCodes - The parameters for an applicable configuration.
    • Method Detail

      • execute

        public void execute​(Bridge bridge,
                            String vehicleId,
                            long startTime,
                            long endTime)
                     throws CommandException,
                            InternalFederateException
        This method executes the command with the given arguments in order to subscribe the vehicle to the application.
        Specified by:
        execute in interface VehicleSubscribe
        Parameters:
        bridge - Connection to SUMO.
        vehicleId - The Id of the Vehicle.
        startTime - The time to subscribe the vehicle.
        endTime - The end time of the subscription of the vehicle in the application.
        Throws:
        CommandException - if the status code of the response is ERROR. The connection to SUMO is still available.
        InternalFederateException - if some serious error occurs during writing or reading. The TraCI connection is shut down.
      • constructResult

        protected Void constructResult​(Status status,
                                       Object... objects)
        Description copied from class: AbstractTraciCommand
        This method is called during reading the command response when all readers have been executed. The results of the readers are passed to this method.
        Specified by:
        constructResult in class AbstractTraciCommand<Void>
        Parameters:
        status - the status of the response
        objects - the objects created by the configured readers
        Returns:
        the final result constructed from the passed objects