NetLinx Programming Overview
22
NetLinx Programming Language Reference Guide
The following is an example of how a block of existing Axcess code can be rewritten using the NetLinx
BUTTON_EVENT handler. The code below will send an 'A' to an RS-232 port defined as KC1 upon a
button push and will repeat the 'A' string every 0.5 seconds until the button is released.
In addition to evaluating the push within the event handler structure, you can see the simplified logic for
creating the repeating 'A' string using the
HOLD event handler.
Channel Events
Channel Events are similar to Button Events. Channel Events are generated by ON, OFF, PULSE, TO, or
MIN_TO. The format for a Channel Event is shown below:
CHANNEL_EVENT[<device>,<channel>]
{
ON:
{
(* on event handler code *)
}
OFF:
{
(* off event handler code *)
}
}
Like Button Events, the [<device>, <channel>] declaration can contain a DEV device set, or a
DEVCHAN device-channel set in addition to individual device and channel declarations.
In the following example, a Channel Event is defined to turn off a video projector every time the
projector lift is raised. In Axcess, you need to include the code to turn off the projector whenever the
projector lift is raised. In NetLinx, you define a Channel Event for the 'Projector Lift Up' relay and tell
the system to turn off the projector every time this relay is turned on. Since turning on or pulsing the
relay does not produce a push, a Button Event is not generated.
Axcess Language NetLinx Language
DEFINE_PROGRAM
.
.
PUSH[TP1,10]
{
SEND_STRING KC1, 'A'
ON[REPEAT_KC]
}
RELEASE[TP1,10]
{
CANCEL_WAIT 'REPEAT KC'
OFF[REPEAT_KC]
}
IF (REPEAT_KC)
{
WAIT 5 'REPEAT KC'
SEND_STRING KC1, 'A'
}
[TP1,10] = REPEAT_KC
.
.
DEFINE_EVENT
.
.
BUTTON_EVENT[TP1,10]
{
PUSH:
{
TO[TP1,10]
SEND_STRING KC1, 'A'
}
RELEASE:
{
}
HOLD[5,REPEAT]:
{
SEND_STRING KC1, 'A'
}
}
.
.
DEFINE_PROGRAM
.
.