Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As a basis for discussion, the Demos/Can folder has been modified in several ways. If we agree on the changes there, we can use the same structure for the other demos.
TL;DR
Central modifications / guidelines
std::cout
,std::cerr
except printing command line argument usageThe splitted demos (CanReaderDemo, CanWriterDemo)
ApplicationBase
that provides all functionality that is not related to CAN (e.g. sync/async behvior)Frame*Handler
). Participant specific code (here:SendFrame
) is implemented in the participant specific demo.Minimal demo SimpleCan
The SimpleCan demo is not using the
ApplicationBase
to showcase basic SIL Kit usage. It is sync-only, only takes a participant name as command line argument and sends/receives CAN frames. Focus here is on minimizing lines of code. Such a simple demo could be unique for CAN and is not necessary for each bus system.The
ApplicationBase
--network
which is an extension provided by the CAN Demo) :AddCommandLineArgs()
: Inject additional demo args. Here, the CAN demo adds a--network
arg to set a network name.EvaluateCommandLineArgs()
: Evaluate the additional args after parsing. Here, the--network
is evaluated and used in the controller creationCreateControllers()
: Called before lifecycle setupInitControllers()
: Called inCommunicationReadyHandler()
DoWorkAsync()
: Called in the worker thread in async modeDoWorkSync(std::chrono::nanoseconds now)
: Called in theSimulationStepHandler
SetupCommandLineArgs(int argc, char** argv, std::unordered_set<DefaultArg> excludedCommandLineArgs = {})
: To split command line arg setup and the simulation run. Optionally, a set of default args can be excluded.Run()
: The actual simulation run. The workflow is:Functional changes of the CAN Demo itself
userContext
paramter when sending a frame. This is actually not needed for the C++-API, as the context can always be captured when setting up the handlers. Also, the original CAN Demo used the userContext for data transport, which was misleading.