You are here: Elements > Frame Recognizers > Recognizer Syntax

Recognizer Syntax

Frame Recognizers are similar to methods. They may even be referred to as compound methods. A Frame Recognizer takes the following form:

RECOGNIZER name [PER_STREAM]

<stuff that appears in the class definition such as private variables>

@RESET

<code - Called when there is a reset, when first starting, and when the lowest layer in the protocol stack changes>

@CTOR

<code - Constructor>

//

// Note that the @RESET code will be called right after the

// constructor. Therefore the constructor need not and

// should not do any work that is better done is @RESET.

//

@DTOR

<code - Destructor>

@EVENT_HANDLER

<code - Called for the NOTIFY type events (defined below)>

@SIGNAL_CHANGE

<code - Called when a signal-change event happens>

@TIMER

<code - Called when a timer event occurs>

//

// Periodic calls are made to this code with the current time

// as a parameter. This gives the Frame Recognizer a chance

// to time-out.

//

@IMPLEMENTATION

<code - Anything else that needs to be defined, such as private functions.>

//

// Use "<recognizer_name>::<member_name>" when referring to

// members within this block.

//

@EACH_BYTE

<code - Called for each byte received>

@END_RECOGNIZER

[PARAM "comment" type]...

All of the code blocks are optional. If a block is omitted then its tag (e.g. @TIMER) should be omitted as well.

If PER_STREAM is present, then an instance of the recognizer is created for each stream. The instance for one stream cannot "see" another stream's instance.

Parameters are declared as for regular methods and are visible to all code blocks.