
NetLinx Programming Overview
25
NetLinx Programming Language Reference Guide
upon receipt of another chunk of data, and is only done when data is received. For example,
DATA.TEXT
may equal
{'over the lazy brown dog',ETX}
and the
DATA_BUFFER[500]
might equal
{STX,'The quick gray fox jumps over the lazy brown dog',ETX}
. By evaluating the
buffer value, you can evaluate the entire string at once.
Two other important aspects of the
DATA_EVENT
are the
ONLINE
and
OFFLINE
event handlers.
ONLINE
and
OFFLINE
events are triggered when the master recognizes a device has come on the bus or
has dropped off the bus.
In Axcess, device initialization is primarily handled with the
DEFINE_START
section of code. The other
alternative was to evaluate the
DEVICE_ID
on each pass through mainline. If the
DEVICE_ID(<device>)
equaled the
DEVICE_ID
of the device, the device was online. If
DEVICE_ID(<device>)
equaled 0, the device was offline. Within the conditional statements, the
device could be initialized or a warning could be sent. The downfall of these approaches is that
DEFINE_START
initializations are only run when the master is reset, and evaluations of the
DEVICE_ID
must run with each pass of mainline and are dependent on the speed of mainline.
NetLinx handles all device initializations and offline warning through the
DATA_EVENT
. Since every
device triggers an
ONLINE
event when the master is reset, this not only ensures that the device will be
initialized on startup, but also insures that the device will be initialized any time the device comes online.
The
DATA_EVENT
is also evaluated on a need to know basis, rather than on each pass through mainline.
The following example shows basic code for tracking a touch panel page in Axcess. Assume that the
variables have been properly defined in the
DEFINE_VARIABLE
section. The
DEFINE_START
section
contains the creation of the buffer and the
DEFINE_PROGRAM
section contains the string evaluation.
Existing Axcess code:
DEFINE_START
.
.
CREATE_BUFFER TP1, TP1_BUFFER
SEND_COMMAND TP1, 'TPAGEON'
.
.
DEFINE_PROGRAM
.
.
IF (LENGTH_STRING (TP1_BUFFER))
{
SELECT
{
ACTIVE (FIND_STRING (TP1_BUFFER,'PAGE-',1)):
{
JUNK = REMOVE_STRING (TP1_BUFFER,'PAGE-',1)
CUR_PAGE = TP1_BUFFER
}
ACTIVE (FIND_STRING (TP1_BUFFER,'KEYP-',1)):
{
(* keypad code *)
}
ACTIVE (FIND_STRING (TP1_BUFFER,'KEYB-',1)):
{
(* keyboard code *)
Continued
Summary of Contents for NETLINX PROGRAMMING LANGUAGE
Page 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Page 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Page 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Page 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Page 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Page 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Page 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Page 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Page 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Page 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...