LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
engine_app.h File Reference
Include dependency graph for engine_app.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ENGINE_CMD_MSG_PIPE_DEPTH   (1)
 

Typedefs

typedef struct ENGINE_APP_TAG ENGINE_APP_T
 

Functions

struct ENGINE_APP_TAG JUNO_MODULE_DERIVE (JUNO_APP_ROOT_T, const JUNO_LOG_ROOT_T *ptLogger;const JUNO_TIME_ROOT_T *ptTime;JUNO_SB_BROKER_ROOT_T *ptBroker;ENGINE_CMD_MSG_T ptArrCmdBuffer[ENGINE_CMD_MSG_PIPE_DEPTH];ENGINE_CMD_MSG_ARRAY_T tCmdArray;JUNO_SB_PIPE_T tCmdPipe;float fCurrentRpm;)
 
JUNO_STATUS_T EngineApp_Init (ENGINE_APP_T *ptEngineApp, const JUNO_LOG_ROOT_T *ptLogger, const JUNO_TIME_ROOT_T *ptTime, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData)
 

Macro Definition Documentation

◆ ENGINE_CMD_MSG_PIPE_DEPTH

#define ENGINE_CMD_MSG_PIPE_DEPTH   (1)

Typedef Documentation

◆ ENGINE_APP_T

typedef struct ENGINE_APP_TAG ENGINE_APP_T

This API has been generated by LibJuno: https://www.robinonsay.com/libjuno/ This header contains the engine_app library API

Author
Robin Onsay DOC

The Engine Application

Next we will be going over a typical LibJuno application. For this tutorial project we are defining an engine application that manages the engine hardware for our car. In this example the engine needs to receive a command for the RPM and telemeter the actual RPM of the engine.

Deriving an Application

Applications in LibJuno are derived from the application root. This provides a common API for applications to utilize. A standard application has three lifecycle functions:

  1. OnStart: The first function called in the application. It is called only once at the beginning of the application lifecycle. This is where developers would initialize resources that will be utilized by the application
  2. OnProcess: This is the "main run-loop" function of the application. This function is called by the main run-time in a loop and is the primary run function of the app.
  3. OnExit: This is the last function called by the application. This is where developers would clean up resources allocated by the application. A typical runtime would call application exit functions when the software is closing.

The Application Structure

Within the derived application users are expected to place pointers to dependencies they require from the main runtime and hold resources the application needs to own and pass from one lifecycle event to the next. In this case the engine app needs the following from the runtime: Logger Time Broker

And the application needs to allocate: A command buffer for engine commands. This is a memory allocation for commands that will be received by the application A command pipe. This is the module that manages the command buffer The current RPM. This is the current state of our engine.

Function Documentation

◆ EngineApp_Init()

JUNO_STATUS_T EngineApp_Init ( ENGINE_APP_T ptJunoApp,
const JUNO_LOG_ROOT_T ptLogger,
const JUNO_TIME_ROOT_T ptTime,
JUNO_SB_BROKER_ROOT_T ptBroker,
JUNO_FAILURE_HANDLER_T  pfcnFailureHandler,
JUNO_USER_DATA_T pvFailureUserData 
)

DOC

The App Init Function

The application also needs to provide a concrete application initialization function. This function sets dependencies and the API pointers within the application. The application has an internal "Verify" function that checks if any of these dependencies are null.

DOC

The Application Init Function

The init function's primary responsibility is to assign dependencies. This function enables the main.c project composition root to pass application dependencies to the application. This function is a concrete implementation because it depends entirely on application specifics.

This function asserts the module pointer exists, assigns the dependency pointers, and finally calls the verification function. The verification function is called last because it assumes the pointers have been instantiated.

◆ JUNO_MODULE_DERIVE()

struct ENGINE_APP_TAG JUNO_MODULE_DERIVE ( JUNO_APP_ROOT_T  ,
const JUNO_LOG_ROOT_T *ptLogger;const JUNO_TIME_ROOT_T *ptTime;JUNO_SB_BROKER_ROOT_T *ptBroker;ENGINE_CMD_MSG_T ptArrCmdBuffer;ENGINE_CMD_MSG_ARRAY_T tCmdArray;JUNO_SB_PIPE_T tCmdPipe;float fCurrentRpm;  [ENGINE_CMD_MSG_PIPE_DEPTH] 
)