Spark! Fuzzy Logic Editor Help


Variables | Sets | Rules | API | Integration | Tutorial


get_var_notification()

Returns a handle which is used to receive notification of a change to a variable.

void* get_var_notification(int var_idx)

Parameters

int var_idx index of the variable to get the value for

Return Value

The handle to an event that signals when the variable changes or NULL if an output or invalid variable index is passed in.

Remarks

The index of the variable should be from the .h file exported from the Spark! model.  The variable's index may not coincide with the screen position of the variable.

Note:  Output variables do NOT send notifications.  Output values are calculated when requested (via get_cog_output() and get_mom_output()) so signaling that the value changed would be of little use.

See also wait()Export .h File  

Example


void wait_for_change(SparkModel* model)
{
       HANDLE set_1_event = model->get_var_notification(SET_1_IDX)

        // loop forever reporting on changes to "Set 1"
    while (1)
        {
        if (model->wait(set_1_event
, 0))
            {
            cout << "Value for Set 1 changed. ";
            cout << "Current value is: ";
            cout << model->get_value(SET_1_IDX) << endl;
            }

        } // end forever loop

} // end
wait_for_change()