Transmission Processing Customization Point

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

Creating the Class

To use custom logic for scheduling activities we will need to create a new class that inherits from TransmissionHandling. This customization class is located at: PT.Scheduler.Simulation.Customizations.TransmissionHandling

Here is what a basic class should look like:

class TransmissionProcessing : TransmissionHandling
{
//Declare any objects for the customization here

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

//Customizations must have a description
public override string Description => "Change activities before/after transmission is processed";

/// <summary>
/// This function is called by the scheduler before a transmission is processed
/// It is useful to override this function if a change in an activity needs to be made
/// before a transmission is processed
/// </summary>
protected override TransmissionHandlingResult Preprocessing(Transmission a_t, ScenarioDetail a_sd)
{
//Create a transmission handling result to send back the activity changes
TransmissionHandlingResult result = new TransmissionHandlingResult();

//Use a_sd to get one or more activities to change
//Add change to the result
TransmissionHandlingResult.ActivityChange change = new TransmissionHandlingResult.ActivityChange(activity);
change.Anchored = false;
result.ActivityUpdateList.Add(change);

return result;
}

/// <summary>
/// This function is called by the scheduler after a transmission is processed
/// It is useful to override this function if a change in an activity needs to be made
/// after a transmission is processed
/// </summary>
protected override TransmissionHandlingResult Postprocessing(Transmission a_t, ScenarioDetail a_sd)
{
//Create a transmission handling result to send back the activity changes
TransmissionHandlingResult result = new TransmissionHandlingResult();

//Use a_sd to get one or more activities to change
//Add change to the result
TransmissionHandlingResult.ActivityChange change = new TransmissionHandlingResult.ActivityChange(activity);
change.Anchored = false;
result.ActivityUpdateList.Add(change);

return result;
}
}

 

Here we have two functions to override to begin customizing at the Transmission Processing customization point:

Preprocessing can be used to make changes on one or more activities before a transmission is processed.

Postprocessing can be used to make changes on one or more activities after a transmission is processed.

Both functions return a TransmissionHandlingResult object, which contains the changes to be made.

For each activity to change, we must create a TrasmissionHandlingResult.ActivityChange object and add it to the TranissionHandlingResult ActivityUpdateList. The ActivityChange object currently allows us to change the activity's Anchored, Locked and ProductionStatus properties. More properties could be added in the future.

Now let's take a look at the parameters for both  Preprocessing and Postprocessing:

  • Transmission a_t: The transmission being processed.
  • ScenarioDetail a_sd: Via the various manager objects in this top level object, all other data objects can be accessed.

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...