Package org.goplanit.output
Class OutputManager
- java.lang.Object
-
- org.goplanit.output.OutputManager
-
public class OutputManager extends Object
Base class for output writers containing basic functionality regarding all things output- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description OutputManager()
Base constructor of Output writer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OutputTypeConfiguration
createAndRegisterOutputTypeConfiguration(OutputType outputType)
Factory method to create an output configuration for a given typevoid
deregisterOutputTypeAdapter(OutputType outputType)
Deregister the output adapter for a specified output type (if it exists)void
deregisterOutputTypeConfiguration(OutputType outputType)
Remove the output type configuration for a specified output typevoid
finaliseAfterSimulation()
Allows the output manager to finalise itself and any of its registered output formatters to after the simulation endedOutputConfiguration
getOutputConfiguration()
Get the OutputConfiguration objectList<OutputFormatter>
getOutputFormatters()
Returns the list of currently registered OutputFormatter objects for a specified output typeOutputTypeConfiguration
getOutputTypeConfiguration(OutputType outputType)
Collect the output type configuration for the given typeCollection<OutputTypeConfiguration>
getRegisteredOutputTypeConfigurations()
Returns a List of registered output type configuration objectsSet<OutputType>
getRegisteredOutputTypes()
Returns a List of registered output typesvoid
initialiseBeforeSimulation(long runId)
Allows the output manager to initialize itself and any of its registered output formatters to prepare before the simulation startsvoid
initialiseOutputAdapters(TrafficAssignment trafficAssignment)
Based on the passed in assignment, create the necessary output adaptersboolean
isAnyOutputPersisted(TimePeriod timePeriod, Set<Mode> modes, boolean converged)
Verify if anything is actually persisted whenpersistOutputData(TimePeriod, Set, boolean)
is invoked given the underlying configurationboolean
isOutputTypeActive(OutputType outputType)
Verify if the given output type is already activated or notvoid
persistOutputData(TimePeriod timePeriod, Set<Mode> modes, boolean converged)
Persist the output data for all registered output typesvoid
registerOutputFormatter(OutputFormatter outputFormatter)
Register the output formatter on the output manager.void
registerOutputTypeAdapter(OutputTypeAdapter outputTypeAdapter)
Register the OutputTypeAdapter for a given output typevoid
reset()
Remove all registered formatters and adapters, only retain the configurationvoid
unregisterOutputFormatter(OutputFormatter outputFormatter)
Remove an output formatter which has previously been registered
-
-
-
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 savedmodes
- Set of modes for the current assignmentconverged
- 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 whenpersistOutputData(TimePeriod, Set, boolean)
is invoked given the underlying configuration- Parameters:
timePeriod
- to verify formodes
- to verify forconverged
- 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
-
-