property OnTrigger : TTriggerEvent
TTriggerEvent = procedure(
CP : TObject; Msg, TriggerHandle, Data : Word) of object;
Defines an event handler that is called whenever any serial data trigger occurs.
OnTrigger can be used to handle all kinds of trigger events in one location. Normally it is easier to use the more specific kinds of serial data triggers. The OnTrigger event handler is always called first, then the more specific event handlers are also called if they are assigned.
CP is the TApxComPort component that generated the trigger. Msg is the message that specifies the kind of trigger.
|
|
|
|
|
|
|
|
|
|
TriggerHandle is the handle number returned when the trigger was added. Data is a numeric value that is relevant for the APX_TRIGGERAVAIL, APX_TRIGGERDATA, and APX_TRIGGERSTATUS events. See the corresponding event handlers for more information.
The following example waits for and responds to a login prompt, processing APX_TRIGGERDATA, APX_TRIGGERAVAIL, and APX_TRIGGERTIMER messages in a single routine:
DataTrig := ApxComPort.AddDataTrigger('login:', True);
TimerTrig := ApxComPort.AddTimerTrigger;
ApxComPort.SetTimerTrigger(TimerTrig, 10000, True);
...
procedure TMyForm.ApxComPortTrigger(
CP : TObject; Msg, TriggerHandle, Data : Word);
var
I : Word;
C : Char;
begin
case Msg of
APX_TRIGGERDATA :
{got 'login', send response}
ApxComPort.PutString('myname');
APX_TRIGGERAVAIL :
{extract and display/process the data}
for I := 1 to Data do begin
C := ApxComPort.GetChar;
...process data
end;
APX_TRIGGERTIMER :
{timed out waiting for login prompt, handle error}
...
end;
end;
See also: OnTriggerAvail, OnTriggerData, OnTriggerStatus, OnTriggerTimer