TApxComPort.OnTriggerOutbuffUsed

TApxComPort

property OnTriggerOutbuffUsed : TNotifyEvent

Defines an event handler that is called whenever the dispatcher detects that used space in its output buffer has dropped below a certain level.

This event handler is called in a subset of the cases where the more general OnTriggerStatus handler is called. OnTriggerStatus is called first when used space drops below a particular level, even if an OnTriggerOutbuffUsed handler is installed. If the output buffer already contains fewer bytes than the specified level when the trigger is activated, an OnTriggerOutbuffUsed event is generated as soon as the internal dispatcher gains control.

The parameter passed to the TNotifyEvent is the TApxComPort component that generated the trigger.

Note that status triggers are not self-restarting. The event handler must call SetStatusTrigger again to reactivate the trigger as needed.

The following example adds and activates a status trigger for an OnTriggerOutbuffUsed event; when the output buffer used level drops below 100 bytes ApxComPortTriggerOutbuffUsed is called and transmits additional data:

TrigOBU : Word;
...
TrigOBU := ApxComPort.AddStatusTrigger(stOutBuffUsed);
ApxComPort.SetStatusTrigger(TrigOBU, 100, True);
...
procedure TMyForm.ApxComPortTriggerOutbuffUsed(CP : TObject);
begin
  {buffer almost empty, start filling up again}
  ApxComPort.Output := Stuff;
  ApxComPort.Output := MoreStuff;
  ApxComPort.Output := EvenMoreStuff;
  ...
end;

See also: OnTriggerStatus, OnTriggerOutbuffFree