foxBMS  1.0.0
The foxBMS Battery Management System API Documentation
database.h File Reference

Database module header. More...

#include "database_cfg.h"
#include "FreeRTOS.h"
#include "queue.h"
#include "os.h"
Include dependency graph for database.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GET_MACRO(_1, _2, _3, _4, NAME, ...)   NAME
 
#define DATA_READ_DATA(...)
 
#define DATA_WRITE_DATA(...)
 

Typedefs

typedef enum DATA_BLOCK_ACCESS_TYPE DATA_BLOCK_ACCESS_TYPE_e
 data block access types (read or write) More...
 

Enumerations

enum  DATA_BLOCK_ACCESS_TYPE { DATA_WRITE_ACCESS, DATA_READ_ACCESS }
 data block access types (read or write) More...
 

Functions

void DATA_DummyFunction (void)
 Dummy void function of the database module. More...
 
STD_RETURN_TYPE_e DATA_Init (void)
 Initialization of database manager. More...
 
void DATA_Task (void)
 trigger of database manager More...
 
STD_RETURN_TYPE_e DATA_Write_1_DataBlock (void *pDataFromSender0)
 Stores a datablock in database. More...
 
STD_RETURN_TYPE_e DATA_Write_2_DataBlocks (void *pDataFromSender0, void *pDataFromSender1)
 Stores a datablock in database. More...
 
STD_RETURN_TYPE_e DATA_Write_3_DataBlocks (void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2)
 Stores a datablock in database. More...
 
STD_RETURN_TYPE_e DATA_Write_4_DataBlocks (void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2, void *pDataFromSender3)
 Stores a datablock in database. More...
 
STD_RETURN_TYPE_e DATA_Read_1_DataBlock (void *pDataToReceiver0)
 Reads a datablock in database by value. More...
 
STD_RETURN_TYPE_e DATA_Read_2_DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1)
 Reads a datablock in database by value. More...
 
STD_RETURN_TYPE_e DATA_Read_3_DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2)
 Reads a datablock in database by value. More...
 
STD_RETURN_TYPE_e DATA_Read_4_DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2, void *pDataToReceiver3)
 Reads a datablock in database by value. More...
 
bool DATA_DatabaseEntryUpdatedAtLeastOnce (void *pDatabaseEntry)
 Checks if passed database entry has been updated at least once. More...
 
bool DATA_DatabaseEntryUpdatedRecently (void *pDatabaseEntry, uint32_t timeInterval)
 Checks if passed database entry has been updated within the last time interval. More...
 
bool DATA_DatabaseEntryUpdatedWithinInterval (void *pDatabaseEntry, uint32_t timeInterval)
 Checks if passed database entry has been periodically updated within the time interval. More...
 

Detailed Description

Database module header.

BSD 3-Clause License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

″This product uses parts of foxBMS®″

″This product includes parts of foxBMS®″

″This product is derived from foxBMS®″

Author
foxBMS Team
Date
2015-08-18 (date of creation)
Updated
2019-11-21 (date of last update)
Prefix
DATA

Provides interfaces to database module

Definition in file database.h.

Macro Definition Documentation

◆ DATA_READ_DATA

#define DATA_READ_DATA (   ...)
Value:

variadic macro for read access to the database

Definition at line 72 of file database.h.

◆ DATA_WRITE_DATA

#define DATA_WRITE_DATA (   ...)
Value:

variadic macro for write access to the database

Definition at line 82 of file database.h.

◆ GET_MACRO

#define GET_MACRO (   _1,
  _2,
  _3,
  _4,
  NAME,
  ... 
)    NAME

helper macro for the variadic macros for read and write functions

Definition at line 70 of file database.h.

Typedef Documentation

◆ DATA_BLOCK_ACCESS_TYPE_e

data block access types (read or write)

Enumeration Type Documentation

◆ DATA_BLOCK_ACCESS_TYPE

data block access types (read or write)

Enumerator
DATA_WRITE_ACCESS 

write access to data block

DATA_READ_ACCESS 

read access to data block

Definition at line 95 of file database.h.

Function Documentation

◆ DATA_DatabaseEntryUpdatedAtLeastOnce()

bool DATA_DatabaseEntryUpdatedAtLeastOnce ( void *  pDatabaseEntry)

Checks if passed database entry has been updated at least once.

Parameters
[in]pDatabaseEntry(type: void *)
Returns
true if database entry has been updated at least once, otherwise false

Definition at line 328 of file database.c.

◆ DATA_DatabaseEntryUpdatedRecently()

bool DATA_DatabaseEntryUpdatedRecently ( void *  pDatabaseEntry,
uint32_t  timeInterval 
)

Checks if passed database entry has been updated within the last time interval.

Parameters
[in]pDatabaseEntry(type: void *)
[in]timeIntervalin systicks (type: uint32_t)
Returns
true if database entry has been updated within the time interval, otherwise false

Definition at line 340 of file database.c.

Here is the call graph for this function:

◆ DATA_DatabaseEntryUpdatedWithinInterval()

bool DATA_DatabaseEntryUpdatedWithinInterval ( void *  pDatabaseEntry,
uint32_t  timeInterval 
)

Checks if passed database entry has been periodically updated within the time interval.

Checks if the last update timestamp is not older than time interval and if the difference between previous timestamp and timestamp is smaller than time interval

Parameters
[in]pDatabaseEntry(type: void *)
[in]timeIntervalin systicks (type: uint32_t)
Returns
true if database entry has been periodically updated within the time interval, otherwise false

Definition at line 356 of file database.c.

Here is the call graph for this function:

◆ DATA_DummyFunction()

void DATA_DummyFunction ( void  )

Dummy void function of the database module.

This function is needed in the database module in order to implement the DATA_READ_DATA() and DATA_WRITE_DATA() in a ISO C99 standard compatible way. The invocation of a macro that accepts a variable number of arguments (and this is the case for DATA_READ_DATA() and DATA_WRITE_DATA()) needs more arguments in the invocation than there are parameters in the macro definition. For the most simple case, that DATA_READ_DATA() and DATA_WRITE_DATA() are only called with one argument, a violation of the standard would appear if the DATA_DummyFunction() would be omitted: GET_MACRO(databaseVaribale, DATA_Read_4_DataBlocks, DATA_Read_3_DataBlocks, DATA_Read_2_DataBlocks, DATA_Read_2_DataBlocks, DATA_Read_1_DataBlock)(databaseVaribale) So the macro invocation has six parameters, but it needs seven and an ISO C99 violation would appear. Adding the DATA_DummyFunction() fixes this violation. For details see 6.10.3 (paragraph 4) of the ISO C99 standard.

Definition at line 237 of file database.c.

◆ DATA_Init()

STD_RETURN_TYPE_e DATA_Init ( void  )

Initialization of database manager.

Returns
STD_OK if initialization successful, otherwise STD_NOT_OK

Definition at line 138 of file database.c.

◆ DATA_Read_1_DataBlock()

STD_RETURN_TYPE_e DATA_Read_1_DataBlock ( void *  pDataToReceiver0)

Reads a datablock in database by value.

This function reads data from database and copy this content in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[out]pDataToReceiver0(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 240 of file database.c.

Here is the call graph for this function:

◆ DATA_Read_2_DataBlocks()

STD_RETURN_TYPE_e DATA_Read_2_DataBlocks ( void *  pDataToReceiver0,
void *  pDataToReceiver1 
)

Reads a datablock in database by value.

This function reads data from database and copy this content in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[out]pDataToReceiver0(type: void *)
[out]pDataToReceiver1(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 245 of file database.c.

Here is the call graph for this function:

◆ DATA_Read_3_DataBlocks()

STD_RETURN_TYPE_e DATA_Read_3_DataBlocks ( void *  pDataToReceiver0,
void *  pDataToReceiver1,
void *  pDataToReceiver2 
)

Reads a datablock in database by value.

This function reads data from database and copy this content in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[out]pDataToReceiver0(type: void *)
[out]pDataToReceiver1(type: void *)
[out]pDataToReceiver2(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 250 of file database.c.

Here is the call graph for this function:

◆ DATA_Read_4_DataBlocks()

STD_RETURN_TYPE_e DATA_Read_4_DataBlocks ( void *  pDataToReceiver0,
void *  pDataToReceiver1,
void *  pDataToReceiver2,
void *  pDataToReceiver3 
)

Reads a datablock in database by value.

This function reads data from database and copy this content in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[out]pDataToReceiver0(type: void *)
[out]pDataToReceiver1(type: void *)
[out]pDataToReceiver2(type: void *)
[out]pDataToReceiver3(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 255 of file database.c.

◆ DATA_Task()

void DATA_Task ( void  )

trigger of database manager

TODO

Definition at line 189 of file database.c.

Here is the call graph for this function:

◆ DATA_Write_1_DataBlock()

STD_RETURN_TYPE_e DATA_Write_1_DataBlock ( void *  pDataFromSender0)

Stores a datablock in database.

This function stores passed data in database and updates timestamp and previous timestamp in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[in,out]pDataFromSender0(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 284 of file database.c.

Here is the call graph for this function:

◆ DATA_Write_2_DataBlocks()

STD_RETURN_TYPE_e DATA_Write_2_DataBlocks ( void *  pDataFromSender0,
void *  pDataFromSender1 
)

Stores a datablock in database.

This function stores passed data in database and updates timestamp and previous timestamp in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[in,out]pDataFromSender0(type: void *)
[in,out]pDataFromSender1(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 289 of file database.c.

Here is the call graph for this function:

◆ DATA_Write_3_DataBlocks()

STD_RETURN_TYPE_e DATA_Write_3_DataBlocks ( void *  pDataFromSender0,
void *  pDataFromSender1,
void *  pDataFromSender2 
)

Stores a datablock in database.

This function stores passed data in database and updates timestamp and previous timestamp in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[in,out]pDataFromSender0(type: void *)
[in,out]pDataFromSender1(type: void *)
[in,out]pDataFromSender2(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 294 of file database.c.

Here is the call graph for this function:

◆ DATA_Write_4_DataBlocks()

STD_RETURN_TYPE_e DATA_Write_4_DataBlocks ( void *  pDataFromSender0,
void *  pDataFromSender1,
void *  pDataFromSender2,
void *  pDataFromSender3 
)

Stores a datablock in database.

This function stores passed data in database and updates timestamp and previous timestamp in passed struct

Warning
Do not call this function from inside a critical section, as it is computationally complex.
Parameters
[in,out]pDataFromSender0(type: void *)
[in,out]pDataFromSender1(type: void *)
[in,out]pDataFromSender2(type: void *)
[in,out]pDataFromSender3(type: void *)
Returns
STD_OK if access was successful, otherwise STD_NOT_OK

Definition at line 299 of file database.c.

DATA_Read_4_DataBlocks
STD_RETURN_TYPE_e DATA_Read_4_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2, void *pDataToReceiver3)
Reads a datablock in database by value.
Definition: database.c:255
DATA_Read_2_DataBlocks
STD_RETURN_TYPE_e DATA_Read_2_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1)
Reads a datablock in database by value.
Definition: database.c:245
DATA_Write_2_DataBlocks
STD_RETURN_TYPE_e DATA_Write_2_DataBlocks(void *pDataFromSender0, void *pDataFromSender1)
Stores a datablock in database.
Definition: database.c:289
DATA_Write_4_DataBlocks
STD_RETURN_TYPE_e DATA_Write_4_DataBlocks(void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2, void *pDataFromSender3)
Stores a datablock in database.
Definition: database.c:299
DATA_Write_1_DataBlock
STD_RETURN_TYPE_e DATA_Write_1_DataBlock(void *pDataFromSender0)
Stores a datablock in database.
Definition: database.c:284
DATA_Read_1_DataBlock
STD_RETURN_TYPE_e DATA_Read_1_DataBlock(void *pDataToReceiver0)
Reads a datablock in database by value.
Definition: database.c:240
DATA_DummyFunction
void DATA_DummyFunction(void)
Dummy void function of the database module.
Definition: database.c:237
DATA_Write_3_DataBlocks
STD_RETURN_TYPE_e DATA_Write_3_DataBlocks(void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2)
Stores a datablock in database.
Definition: database.c:294
GET_MACRO
#define GET_MACRO(_1, _2, _3, _4, NAME,...)
Definition: database.h:70
DATA_Read_3_DataBlocks
STD_RETURN_TYPE_e DATA_Read_3_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2)
Reads a datablock in database by value.
Definition: database.c:250