Free Fuzzy Logic Library


Home | License | History | Class Hierarchy | API | Code Details | FCL | Developers | Downloads | A SourceForge.net Project


API

This page contains notes about the FFLL API functions.

Unicode Support

All strings in the FFLL library use the wide character datatype wchar_t. This provides the ability to use FFLL in double-byte languages and avoids using Microsoft specific macros such as TCHAR that produce different code dependent on the values defined during compilation

Any function that requires strings as parameters (such as ffll_get_msg_text) will have both an ASCII and wide character version. If _UNICODE is defined when you compile your application, the wide character version is called, otherwise the ASCII version is called.

back to table of contents

Model/Child Relationship

One or more “objects” can use a FFLL model at the same time. These “objects” are referred to as children of the FFLL model. For example, a racing game may use one model and each AI controlled car would be a child of the model. Any child specific information, such as input and output values, are part of the child. The API encapsulates this information to ease coding.

back to table of contents

Multithread Support

Since all the classes in FFLL hold information (such as the rules) that is shared among children, and each child maintains its own input values, each child can safely be in a separate thread. Note that at the time of this printing, the children themselves are not thread-safe.

back to table of contents

Common Parameters

You may have noticed that every API function (with the exception of ffll_new_model) has a "model index" passed in as a parameter. Since multiple FFLL models can be open at the same time, this parameter is needed to know which FFLL model you are referring to. 

Many of the API functions also require a "child index" parameter. This is required because a single FFLL model can have multiple "children" all using the same model.

back to table of contents

API Functions

back to table of contents

ffll_new_model

Prototype:

int ffll_new_model()

Purpose:

Create a model object that contains the fuzzy logic model.

Parameters:

none

Returns:

int: The index of the model created or –1 if error.

back to function list

ffll_close_model

Prototype:

int ffll_close_model(int model_idx)

Purpose:

Closes the FFLL model (and all it's children)

Parameters:

  • model_idx – Index of the model to load the file into.

Returns:

int: 0 if success or –1 if error.

back to function list

ffll_load_fcl_file

Prototype:

int ffll_load_fcl_file(int model_idx, const char* file)

Purpose:

Creates a fuzzy model from a file in the IEC 61131-7 Fuzzy Control Language (FCL) format.

Parameters:

  • model_idx – Index of the model to load the file into.

  • file - Path and name of the file to load.

Returns:

int: The index of the model loaded if success or -1 if error.

back to function list

ffll_get_msg_text

Prototypes:

Wide character version:
        const wchar_t* ffll_get_msg_textW(int model_idx)
ASCII character version:
        const char* ffll_get_msg_textA(int model_idx)

Purpose:

This function returns the text of the "current message" associated with the model index passsed in. The message may be an error or warning. This function should be called when an API function returns an error.

Parameters:

  • model_idx – Index of the model to load the file into.

Returns:

Text of the message, or NULL if no message

Notes:

While you are free to call either the wide character or ASCII version of this function explicitly, the version that's called by ffll_get_msg_text() depends on if _UNICODE is defined or not. If _UNICODE is defined when you compile your application, the wide character version is called, otherwise the ASCII version is called.

 back to function list

ffll_new_child

Prototype:

int ffll_new_child(int model_idx)

Purpose:

Create a child for the model.

Parameters:

  • model_idx - Index of the model to create the child for.

Returns:

int: The index of the child if success or -1 if error.

back to function list

ffll_set_value

Prototype:

int ffll_set_value(int model_idx, int child_idx, int var_idx, double value)

Purpose:

Sets the value for an input variable in a child.

Parameters:

  • model_idx - Index of the model the child belongs to.

  • child_idx - Index of the child to set the value for.

  • var_idx - Index of the variable to set the value for.

  • value - Value to set the variable to.

Returns:

int: Zero if success or -1 if error.

 back to function list

ffll_get_output_value

Prototype:

double ffll_get_output_value(int model_idx, int child_idx)

Purpose:

Gets the defuzzified output value for a child.

Parameters:

  • model_idx - Index of the model the child belongs to.

  • child_idx - Index of the child to get the output value for.

Returns:

double : The defuzzified value for the child, if no rules fired FLT_MIN is returned.

back to function list

back to table of contents

 


Copyright © 2002-2003 Louder Than A Bomb! Software