Class OutputManager


  • public class OutputManager
    extends Object
    Base class for output writers containing basic functionality regarding all things output
    Author:
    markr
    • Constructor Detail

      • OutputManager

        public OutputManager()
        Base constructor of Output writer
    • Method Detail

      • initialiseBeforeSimulation

        public void initialiseBeforeSimulation​(long runId)
                                        throws PlanItException
        Allows the output manager to initialize itself and any of its registered output formatters to prepare before the simulation starts
        Parameters:
        runId - traffic assignment run id
        Throws:
        PlanItException - thrown if there is an error
      • finaliseAfterSimulation

        public void finaliseAfterSimulation()
                                     throws PlanItException
        Allows the output manager to finalise itself and any of its registered output formatters to after the simulation ended
        Throws:
        PlanItException - thrown if there is an error
      • persistOutputData

        public void persistOutputData​(TimePeriod timePeriod,
                                      Set<Mode> modes,
                                      boolean converged)
                               throws PlanItException
        Persist the output data for all registered output types
        Parameters:
        timePeriod - the current time period whose results are being saved
        modes - Set of modes for the current assignment
        converged - true if the assignment has converged
        Throws:
        PlanItException - thrown if there is an error
      • isAnyOutputPersisted

        public boolean isAnyOutputPersisted​(TimePeriod timePeriod,
                                            Set<Mode> modes,
                                            boolean converged)
        Verify if anything is actually persisted when persistOutputData(TimePeriod, Set, boolean) is invoked given the underlying configuration
        Parameters:
        timePeriod - to verify for
        modes - to verify for
        converged - true if the assignment has converged
        Returns:
        true when anything is persisted, false otherwise
      • createAndRegisterOutputTypeConfiguration

        public OutputTypeConfiguration createAndRegisterOutputTypeConfiguration​(OutputType outputType)
                                                                         throws PlanItException
        Factory method to create an output configuration for a given type
        Parameters:
        outputType - the output type to register the configuration for
        Returns:
        outputTypeconfiguration the output type configuration that has been newly registered
        Throws:
        PlanItException - thrown if there is an error
      • deregisterOutputTypeConfiguration

        public void deregisterOutputTypeConfiguration​(OutputType outputType)
        Remove the output type configuration for a specified output type
        Parameters:
        outputType - the output type whose configuration is to be deregistered
      • registerOutputTypeAdapter

        public void registerOutputTypeAdapter​(OutputTypeAdapter outputTypeAdapter)
        Register the OutputTypeAdapter for a given output type
        Parameters:
        outputTypeAdapter - the OutputTypeAdapte to be registered
      • deregisterOutputTypeAdapter

        public void deregisterOutputTypeAdapter​(OutputType outputType)
        Deregister the output adapter for a specified output type (if it exists)
        Parameters:
        outputType - the output type whose adapter is to be deregistered
      • getOutputConfiguration

        public OutputConfiguration getOutputConfiguration()
        Get the OutputConfiguration object
        Returns:
        the OutputConfiguration object being used
      • registerOutputFormatter

        public void registerOutputFormatter​(OutputFormatter outputFormatter)
        Register the output formatter on the output manager. Whenever something is persisted it will be delegated to the registered formatters
        Parameters:
        outputFormatter - OutputFormatter to be registered
      • unregisterOutputFormatter

        public void unregisterOutputFormatter​(OutputFormatter outputFormatter)
        Remove an output formatter which has previously been registered
        Parameters:
        outputFormatter - output formatter to be removed
      • getOutputFormatters

        public List<OutputFormatter> getOutputFormatters()
        Returns the list of currently registered OutputFormatter objects for a specified output type
        Returns:
        List of registered OutputFormatter objects
      • isOutputTypeActive

        public boolean isOutputTypeActive​(OutputType outputType)
        Verify if the given output type is already activated or not
        Parameters:
        outputType - OutputType object to be checked
        Returns:
        true if active false otherwise
      • getOutputTypeConfiguration

        public OutputTypeConfiguration getOutputTypeConfiguration​(OutputType outputType)
        Collect the output type configuration for the given type
        Parameters:
        outputType - OutputType to collect the output type configuration for
        Returns:
        output type configuration registered, if not registered null is returned and a warning is logged
      • getRegisteredOutputTypeConfigurations

        public Collection<OutputTypeConfiguration> getRegisteredOutputTypeConfigurations()
        Returns a List of registered output type configuration objects
        Returns:
        a List of registered output type configuration objects
      • getRegisteredOutputTypes

        public Set<OutputType> getRegisteredOutputTypes()
        Returns a List of registered output types
        Returns:
        a List of registered output types
      • initialiseOutputAdapters

        public void initialiseOutputAdapters​(TrafficAssignment trafficAssignment)
        Based on the passed in assignment, create the necessary output adapters
        Parameters:
        trafficAssignment - we are creating adapters for
      • reset

        public void reset()
        Remove all registered formatters and adapters, only retain the configuration