Skip to content

Functions in the Library

Cristian Gallardo edited this page Dec 8, 2020 · 2 revisions

The following are the functions found in the dynamic link library:

int openMemory(char memoryName, int typeCode);

Description:

This function opens a memory with a specific name (memoryName) and a specified type (typeCode):

Parameters:

 - memoryName : We specify the name of the memory we wish to open
 - typeCode   : We specify the code of the type of memory we want to open, it can be:
                1 = Integer
                2 = Float
                3 = Double
                4 = String (max 64 character), you can change this limit in the implementation code.

Return:

  - 0 = If it runs correctly
  - 1 = if there was an error

int getInt(char memoryName, int valuePosition);

Description:

This function returns the value type Integer stored in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to read the value

Return:

Returns the integer type value stored in position (valuePosition) belonging to memory with the name (memoryName).

void setInt(char memoryName, int valuePosition,int dValue);

Description:

This function stores a integer type value (dValue) in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to write the value
- dValue        : The integer type value that will be stored

void setFloat(char memoryName, int valuePosition, float fValue);

Description:

This function stores a float type value (fValue) in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to write the value
- fValue	: The float type value that will be stored

float getFloat(char memoryName, int valuePosition);

Description:

This function returns the float type value stored in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to read the value

Return:

returns the float type value stored in position (valuePosition) belonging to memory with the name (memoryName).

void setDouble(char memoryName, int valuePosition, double lfValue);

Description:

This function stores a double type value (lfValue) in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to write the value
- lfValue       : The double type value that will be stored

double getDouble(char memoryName, int valuePosition);

Description:

This function returns the double type value stored in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to read the value

Return:

Returns the double type value stored in position (valuePosition) belonging to memory with the name (memoryName).

*void setString(char memoryName, int valuePosition, char strValue);

Description:

This function stores a string type value (strValue) in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with.
- valuePosition : We specify the position we want to write the value.
- strValue	: The string value that will be stored.

*void getString(char memoryName, int valuePosition, char strRetValue);

Description

This function returns the string of characters stored in position (valuePosition) belonging to memory with the name (memoryName).

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to read the value
- strRetValue	: This pointer will point to the character string stored in the (valuePosition) position in the shared memory.

*void getStringMatlab(char *memoryName, int valuePosition, char strRetValue);

** Description:**

This function returns the string of characters stored in position (valuePosition) belonging to memory with the name (memoryName).

This function is special for matlab, since matlab requires a double pointer.

Parameters:

- memoryName    : We specify the name of the memory we wish to work with
- valuePosition : We specify the position we want to read the value
- strRetValue	: This pointer will point to the character string stored in the (valuePosition) position in the shared memory.

int createMemory(char memoryName, int quantity, int typeCode);

Description:

This function creates a shared memory labeled with the name specified in (memoryName), which may contain a quantity of values specified in (quantity), and the values will be of the type specified in (typeCode).

Parameters:

- memoryName : We specify the name of the memory we want to create
- quantity   : We specify the maximum amount of values that we can store in this memory
- typeCode   : We specify the code of the type of memory we want to create, it can be:
           1 = Integer
           2 = Float
           3 = Double
           4 = String (max 13 character), you can change this limit in the implementation code.

Return

- 0 = If it runs correctly
- 1 = if there was an error

void freeMemories();

Description:

This function releases the memory spaces created by the createMemory () function.

void freeViews();

Description:

This function frees the separate memory space for the creation of views to the named shared memories, the views that were created by the openMemory () function.