add_exception_function, add_echo_function

add_exception_function, add_echo_function -- assign functions for exceptions or echoes on a point.

Syntax

add_exception_function (symbol, s_exp);
add_echo_function (symbol, s_exp);

		

Arguments

symbol

A point name, as a symbol.

s_exp

Any Gamma or Lisp expression.

Returns

t

Description

When a Gamma or Lisp program is run in conjunction with the real-time datahub, process points may change at any time, causing point change events to occur. A point change event is referred to as an exception. It is possible to bind any Gamma or Lisp expression to a symbol to be evaluated when an exception occurs. If a program can both write a point on the datahub and react to exceptions on that point, it is possible that the datahub will "echo" a point written by the program itself. If this is not handled, an infinite loop between the program and the datahub could occur. The datahub tags point echoes so that a different function can be called in the program when that echo arrives back at its origin. Only the originating task will see a point exception as an echo. All other tasks will see a normal exception.

When an exception handler (the s_exp argument) is being evaluated the special variables this, value and previous are all bound:

Example

    Gamma> add_exception_function(#temp, #princ("temp change\n"));
    (princ "temp change\n")
    Gamma> add_echo_function(#temp,nil);
    nil
    Gamma> next_event();
    temp change
    (t)
    Gamma> read_point(#temp);
    30
    Gamma> write_point(#temp,25);
    t
    Gamma> next_event();
    (nil)
    Gamma> 
    		

See the Automatically Change SP Value section of the PID Emulator chapter, or The Monitor Window section in the GTK Functions chapter, or The Monitor Window section in the Photon Functions chapter of the Cogent Tools Demo and Tutorials book for examples of this function used in context.

See Also

register_point, when_echo_fns, when_exception_fns, remove_echo_function, remove_exception_function

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.