Table of Contents

Class ConnectorBase<T>

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

Base class for simulator connectors. Implements heartbeat reporting. The connector information is stored in the simulator integration resource in CDF.

public abstract class ConnectorBase<T> where T : BaseConfig

Type Parameters

T
Inheritance
ConnectorBase<T>
Derived
Inherited Members

Constructors

ConnectorBase(CogniteDestination, ConnectorConfig, SimulatorCreate, ILogger<ConnectorBase<T>>, RemoteConfigManager<T>, ScopedRemoteApiSink)

Initialize the connector with the given parameters

public ConnectorBase(CogniteDestination cdf, ConnectorConfig config, SimulatorCreate simulatorDefinition, ILogger<ConnectorBase<T>> logger, RemoteConfigManager<T> remoteConfigManager, ScopedRemoteApiSink remoteSink)

Parameters

cdf CogniteDestination

CDF client wrapper

config ConnectorConfig

Connector configuration

simulatorDefinition SimulatorCreate

Simulator definition

logger ILogger<ConnectorBase<T>>

Logger

remoteConfigManager RemoteConfigManager<T>
remoteSink ScopedRemoteApiSink

Remote API sink for the logger

Properties

Cdf

CDF client wrapper

protected CogniteDestination Cdf { get; }

Property Value

CogniteDestination

RemoteSimulatorIntegration

Simulator integration resource in CDF

public SimulatorIntegration RemoteSimulatorIntegration { get; }

Property Value

SimulatorIntegration

SimulatorDefinition

Simulator definition, containing the simulator name, supported units, etc.

protected SimulatorCreate SimulatorDefinition { get; }

Property Value

SimulatorCreate

Methods

GetConnectorName()

Returns the connector name.This is reported periodically to CDF

public string GetConnectorName()

Returns

string

Connector name

GetConnectorVersion(CancellationToken)

Returns the connector version. This is reported periodically to CDF

public abstract string GetConnectorVersion(CancellationToken token)

Parameters

token CancellationToken

Returns

string

Connector version

GetHeartbeatInterval()

How often to report the connector information back to CDF (Heartbeat)

public TimeSpan GetHeartbeatInterval()

Returns

TimeSpan

Time interval

GetLicenseCheckInterval()

How often to report the simulator license status information back to CDF (Heartbeat)

public TimeSpan GetLicenseCheckInterval()

Returns

TimeSpan

Time interval

GetLicenseStatus()

This method should be overridden in each specific Connector class.

public LicenseStatus GetLicenseStatus()

Returns

LicenseStatus

True if the simulator has a valid license, false otherwise.

GetSimulatorVersion(string, CancellationToken)

Returns the version of the given simulator. The connector reads the version and report it back to CDF

public abstract string GetSimulatorVersion(string simulator, CancellationToken token)

Parameters

simulator string

Name of the simulator

token CancellationToken

Cancellation token

Returns

string

Version

HeartbeatLoop(CancellationToken)

Task that runs in a loop, reporting the connector information to CDF periodically (with the interval defined in GetHeartbeatInterval())

public Task HeartbeatLoop(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

Init(CancellationToken)

Initialize the connector. Should include any initialization tasks to be performed before the connector loop. This should include a call to InitRemoteSimulatorIntegration(CancellationToken)

public abstract Task Init(CancellationToken token)

Parameters

token CancellationToken

Cancellation token

Returns

Task

InitRemoteSimulatorIntegration(CancellationToken)

Create a simulator integration in CDF containing the simulator name, connector name, data set id, connector version, etc. These parameters will be updated periodically by the connector, and indicate the status of the currently running connector to applications consuming this simulation integration data.

protected Task InitRemoteSimulatorIntegration(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

LicenseCheckLoop(CancellationToken)

Task that runs in a loop, reporting the connector license status to CDF periodically (with the interval defined in GetLicenseCheckInterval())

public Task LicenseCheckLoop(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

RestartOnNewRemoteConfigLoop(CancellationToken)

Task that runs in a loop, checking for new config in extraction pipelines

public Task RestartOnNewRemoteConfigLoop(CancellationToken token)

Parameters

token CancellationToken

Returns

Task

Run(CancellationToken)

Implements the connector loop. Should call the HeartbeatLoop(CancellationToken) method and any other thats that are done periodically by the connector

public abstract Task Run(CancellationToken token)

Parameters

token CancellationToken

Cancellation token

Returns

Task

ShouldLicenseCheck()

If the connector should check and report the license status back to CDF

public bool ShouldLicenseCheck()

Returns

bool

UpdateRemoteSimulatorIntegration(bool, CancellationToken)

Update the heartbeat, data set id and connector version in CDF. Data set id and connector version are not expected to change while the connector is running, and are only set during initialization.

protected Task UpdateRemoteSimulatorIntegration(bool init, CancellationToken token)

Parameters

init bool
token CancellationToken

Returns

Task