Participant

This document describes the main entry point to the SIL Kit simulation, the participant. By creating a participant with a given configuration, a connection to a simulation is established, and the configured participant joins the simulation.

Creating the Participant

To create an IParticipant you have to include the silkit/SilKit.hpp and call the Participant API factory function:

auto config = SilKit::Config::ParticipantConfigurationFromFile("my_config.yaml");
auto participant = SilKit::CreateParticipant(config, "ParticipantName", registryUri);

To take part in the simulation, the participant needs to be initialized with a proper configuration, a participant name and optionally the URI of the registry:

auto SilKit::CreateParticipant(std::shared_ptr<SilKit::Config::IParticipantConfiguration> participantConfig, const std::string &participantName) -> std::unique_ptr<IParticipant>

Create a participant and join the simulation.

Become a participant based on the the given configuration options.

Parameters
  • participantConfig – Configuration of the participant

  • participantName – Name of the participant (UTF-8)

Throws
  • SilKit::ConfigurationError – if the config has errors

  • SilKit::SilKitError – The participant could not be created.

Returns

Instance of the communication adapter

auto SilKit::CreateParticipant(std::shared_ptr<SilKit::Config::IParticipantConfiguration> participantConfig, const std::string &participantName, const std::string &registryUri) -> std::unique_ptr<IParticipant>

Create a participant and join the simulation.

Become a participant based on the the given configuration options.

Parameters
  • participantConfig – Configuration of the participant

  • participantName – Name of the participant (UTF-8)

  • registryUri – The URI of the registry

Throws
  • SilKit::ConfigurationError – if the config has errors

  • SilKit::SilKitError – The participant could not be created.

Returns

Instance of the communication adapter

IParticipant API

The instantiated IParticipant can then be used to create and access services of the SIL Kit. A controller name (the canonicalName given in Create*-Calls) must be unique within a controller type, using the same name twice results in a ConfigurationError.

Warning.

Services must NOT be created in callbacks. E.g., it is an error to call CreateCanController() in a CommunicationReadyHandler or even SimulationStepHandler.

class IParticipant

Communication interface to be used by SIL Kit participants.

Public Functions

virtual ~IParticipant() = default
virtual auto CreateCanController(const std::string &canonicalName, const std::string &networkName) -> Services::Can::ICanController* = 0

Create a CAN controller at this SIL Kit participant.

virtual auto CreateEthernetController(const std::string &canonicalName, const std::string &networkName) -> Services::Ethernet::IEthernetController* = 0

Create an Ethernet controller at this SIL Kit participant.

virtual auto CreateFlexrayController(const std::string &canonicalName, const std::string &networkName) -> Services::Flexray::IFlexrayController* = 0

Create an FlexRay controller at this SIL Kit participant.

virtual auto CreateLinController(const std::string &canonicalName, const std::string &networkName) -> Services::Lin::ILinController* = 0

Create a LIN controller at this SIL Kit participant.

virtual auto CreateDataPublisher(const std::string &canonicalName, const SilKit::Services::PubSub::PubSubSpec &dataSpec, size_t history = 0) -> Services::PubSub::IDataPublisher* = 0

Create a data publisher at this SIL Kit participant.

virtual auto CreateDataSubscriber(const std::string &canonicalName, const SilKit::Services::PubSub::PubSubSpec &dataSpec, Services::PubSub::DataMessageHandler dataMessageHandler) -> Services::PubSub::IDataSubscriber* = 0

Create a data subscriber at this SIL Kit participant.

virtual auto CreateRpcClient(const std::string &canonicalName, const SilKit::Services::Rpc::RpcSpec &dataSpec, Services::Rpc::RpcCallResultHandler handler) -> Services::Rpc::IRpcClient* = 0

Create a Rpc client at this SIL Kit participant.

virtual auto CreateRpcServer(const std::string &canonicalName, const SilKit::Services::Rpc::RpcSpec &dataSpec, Services::Rpc::RpcCallHandler handler) -> Services::Rpc::IRpcServer* = 0

Create a Rpc server at this SIL Kit participant.

virtual auto CreateLifecycleService(Services::Orchestration::LifecycleConfiguration startConfiguration) -> Services::Orchestration::ILifecycleService* = 0

Return the ILifecycleService at this SIL Kit participant.

virtual auto CreateSystemMonitor() -> Services::Orchestration::ISystemMonitor* = 0

Return the ISystemMonitor at this SIL Kit participant.

virtual auto GetLogger() -> Services::Logging::ILogger* = 0

Return the ILogger at this SIL Kit participant.

SIL Kit Version

Version information about the currently running SIL Kit instance can be queried using the following functions:

auto SilKit::Version::Major() -> uint32_t

This release’s major version number.

auto SilKit::Version::Minor() -> uint32_t

This release’s minor version number.

auto SilKit::Version::Patch() -> uint32_t

This release’s patch version number.

auto SilKit::Version::String() -> const char*

Retrieve the API version identifier “<Major>.<Minor>.<Patch>” of this release.

auto SilKit::Version::BuildNumber() -> uint32_t

Retrieve this release’s build number on the master branch.

auto SilKit::Version::VersionSuffix() -> const char*

Retrieve additional version information of this release.

auto SilKit::Version::GitHash() -> const char*

Retrieve the full git hash of this release.