Operation Scheduled Customization Point

Handling custom logic after the scheduling of an activity

This guide will step through the process of coding a Operation Scheduled customization. If you are just getting started, you can learn about getting started with customizations

Creating the Class

To use custom logic the scheduling of an activity we will need to create a new class that inherits from OperationScheduled. This customization class is located at: PT.Scheduler.Simulation.Customizations.OperationScheduled

Here is what a basic class should look like:

internal class OperationScheduled : PT.Scheduler.Simulation.Customizations.OperationScheduled
{
//Declare any objects for the customization here

//Customizations must have a name
public override string Name => "OperationScheduled";

//Customizations must have a description
public override string Description => "Performs custom logic after an operation schedules";


/// <summary>
/// This function is called by the scheduler before starting the simulation
/// </summary>
protected override void SimulationInitialization(ScenarioDetail a_sd)
{
//Create some mapping or initialize other classes here
}

/// <summary>
/// This function is called by the scheduler after completing the scheduling of an activity
/// </summary>
protected override void Scheduled(InternalActivity a_act, ScenarioDetail a_sd, long a_simClock)
{
//Perform custom logic related to scheduled activity here
}
}

 

Here we have two functions to override to begin customizing at the schedulability point:

SimulationInitialization can be used to override the Simulation Initialization as the name implies. This is useful for building a data mapping or to initialize other classes that are part of the customization project.

Scheduled can be used to perform custom logic using the information from the scheduled activity such as updating a mapping or a custom class from the customization project.

 

First let's take a look at the parameter for SimulationInitialization:

  • ScenarioDetail a_sd: Via the various manager objects in this top level object, all other data objects can be accessed.

Now let's take a look at the parameters for Scheduled:

  • InternalActivity a_act: The activity that just scheduled
  • ScenarioDetail a_sd: Via the various manager objects in this top level object, all other data objects can be accessed.
  • long a_simClock: The date time ticks of the simulation clock at this time.

Next Steps

Explore the following articles to see an example of how this customization point can be used,  meet other types of scheduling requirements or to learn how to better navigate the PlanetTogether data objects explore the following articles:

 

Coming Soon...