procedure SetStatusTrigger(
const Handle : Word; const Value : Word;
const Activate : Boolean);
Activates or deactivates a status trigger.
Status triggers are activated in two steps. The trigger is added using AddStatusTrigger, then the trigger is activated using SetStatusTrigger. The trigger type is specified when the trigger is added, and the exact trigger condition is specified when the trigger is activated.
Handle is the value that was returned by the call to AddStatusTrigger. The interpretation of Value varies between the trigger types, as described below. Set Activate is to True to activate the trigger, False to deactivate it. When Activate is False, the Value parameter is ignored.
For triggers of type stModem, Value is a bit mask that contains one or more of the following options:
|
|
|
|
|
|
|
|
|
|
For the msCTSDelta, msDSRDelta, and msDCDDelta options SetStatusTrigger saves the current state of the corresponding modem signals and checks for changes to those signals. When a change from the original state is detected an OnTriggerStatus event is generated. If a single trigger is used to monitor multiple signals, the message response routine must check the appropriate modem status properties to determine which signal actually changed state. Alternatively, a separate trigger can be added for each modem signal. Once a trigger message is sent the trigger is disabled, even if some of the monitored signals did not change state.
The msRingDelta option triggers an OnTriggerStatus event at the end of the next incoming ring signal, immediately after the audible termination of the ring. In order to receive another OnTriggerStatus event using msRingDelta, the application must not only call SetStatusTrigger again, but it must also read the DeltaRI property to clear the ring condition in the modem status register.
An stModem trigger also generates an OnTriggerModemStatus event. Note, however, that no trigger handle is passed to the OnTriggerModemStatus event handler, so it cannot distinguish among multiple different triggers. If you need to do this, use an OnTriggerStatus event handler instead.
For triggers of type stLine, Value is a bit mask that contains one or more of the following options:
Width1Width3Width1890 Width3Width3637 |
|
Width1Width3Width1890 Width3Width3637 |
|
|
|
|
|
Width1Width3Width1890 Width3Width3637 |
|
If a single trigger is used to monitor multiple line status signals, the OnTriggerStatus event handler must read the LineError property to determine the most severe error. When lsBreak is combined with other options the response routine must read both LineError and LineBreak to determine whether the trigger was caused by an error or by a received line break.
An stLine trigger also generates an OnTriggerLineError event, which passes the current values of LineError and LineBreak as parameters to its handler.
For triggers of type stOutBuffFree, an OnTriggerStatus event is generated when the number of bytes free in the output buffer is greater than or equal to Value. An OnTriggerOutbuffFree event is also generated by the trigger.
For triggers of type stOutBuffUsed, an OnTriggerStatus event is generated when the number of bytes used in the output buffer is less than or equal to Value. An OnTriggerOutbuffUsed event is also generated by the trigger.
For triggers of type stOutSent, Value is not used. Here, an OnTriggerStatus event is generated whenever PutChar, PutString, or PutBlock is called. However, the event is not generated directly from these routines, but is instead generated the next time the dispatcher gains control. Only one event is generated even if multiple PutXxx calls were made or the Output property was assigned since the last time the dispatcher ran.
All status triggers except stOutSent must be restarted within the message handler. That is, the triggers generate a single message and do not restart themselves automatically.
The following example adds an stOutBuffFree status trigger and
activates it to send a message when at least 100 bytes are free in
the output buffer:
var
MyHandle : Word;
...
MyHandle := ApxComPort.AddStatusTrigger(stOutBuffFree);
ApxComPort.SetStatusTrigger(MyHandle, 100, True);
The following example adds an stModem trigger and activates it to
send a message when either the DSR or CTS signal changes from its
current state:
var
MyHandle : Word;
...
MyHandle := ApxComPort.AddStatusTrigger(stModem);
ApxComPort.SetStatusTrigger(MyHandle, msDSRDelta or
msCTSDelta, True);
See also: AddStatusTrigger, OnTriggerStatus