Table of Contents

Class SimulationSchedulerBase<V>

Namespace
Cognite.Simulator.Utils
Assembly
Cognite.Simulator.Utils.dll

This class implements a basic simulation scheduler. It runs a loop on a configurable interval. Each iteration, it checks the schedules for all configurations and determine if the simulation should be triggered. It is assumed that the simulator can only run one simulation at a time, and therefore there is no need to schedule parallel simulation runs. Alternatives to this implementation include libraries such as Quartz, but the added complexity of a full fledged scheduling library in not necessary at this point. Also, at some point scheduling the creation of CDF simulation runs should be done by a cloud service, instead of doing it in the connector.

public class SimulationSchedulerBase<V> where V : SimulatorRoutineRevision

Type Parameters

V
Inheritance
SimulationSchedulerBase<V>
Derived
Inherited Members

Constructors

SimulationSchedulerBase(ConnectorConfig, IRoutineProvider<V>, ILogger, IEnumerable<SimulatorConfig>, CogniteDestination, ITimeManager)

Creates a new instance of a simulation scheduler

public SimulationSchedulerBase(ConnectorConfig config, IRoutineProvider<V> configLib, ILogger logger, IEnumerable<SimulatorConfig> simulators, CogniteDestination cdf, ITimeManager timeManager = null)

Parameters

config ConnectorConfig

Connector configuration

configLib IRoutineProvider<V>

Simulation configuration library

logger ILogger

Logger

simulators IEnumerable<SimulatorConfig>

List of simulators

cdf CogniteDestination

CDF client

timeManager ITimeManager

Time manager. Not required, will default to TimeManager

Methods

GetNextJobDelayAndRunTimeMs(CrontabSchedule)

Gets the next job delay and run time in milliseconds. Delay is the actual time until the next job should run. Run time is the "official" time job is considered to run at (used for inputs data sampling, etc). Run time is floored to the nearest minute.

public static (TimeSpan, long) GetNextJobDelayAndRunTimeMs(CrontabSchedule schedule)

Parameters

schedule CrontabSchedule

Returns

(TimeSpan, long)

Run(CancellationToken)

Starts the scheduler loop. For the existing simulation configuration files, check the schedule and create simulation runs in CDF accordingly

public Task Run(CancellationToken token)

Parameters

token CancellationToken

Cancellation token

Returns

Task