AMX NETLINX PROGRAMMING LANGUAGE Manual
AMX NETLINX PROGRAMMING LANGUAGE Manual

AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Language Reference Guide
NetLinx
Programming Language
D o c u m e n t I D : 0 3 3 - 0 0 4 - 2 2 5 5
N e t L i n x P r o g r a m m i n g
L a s t R e v i s e d : 1 0 / 0 5 / 2 0 0 6

Advertisement

Table of Contents
loading

Summary of Contents for AMX NETLINX PROGRAMMING LANGUAGE

  • Page 1 Language Reference Guide NetLinx Programming Language D o c u m e n t I D : 0 3 3 - 0 0 4 - 2 2 5 5 N e t L i n x P r o g r a m m i n g L a s t R e v i s e d : 1 0 / 0 5 / 2 0 0 6...
  • Page 2 AMX's entire liability and Licensee's exclusive remedy shall be repair or replacement of the AMX Software that does not meet AMX's Limited Warranty and which is returned to AMX. This Limited Warranty is void if failure of the AMX Software has resulted from accident, abuse, or misapplication.
  • Page 3: Table Of Contents

    Channel Events......................22 Data Events ........................24 Level Events ........................27 Combining Devices, Channels and Levels ............... 28 Virtual devices, levels and device/channel sets ............. 28 Combining and uncombining devices................28 Combining and uncombining levels................28 NetLinx Programming Language Reference Guide...
  • Page 4 Bitwise operators ......................40 Assignment operators ....................40 Operator precedence ....................41 Identifiers........................ 41 Devices .......................... 41 Device arrays ......................... 42 Device array examples ....................43 Device-channels and device-channel arrays ..............43 Device-level arrays ......................44 NetLinx Programming Language Reference Guide...
  • Page 5 TIMELINE example ......................74 TIMELINE IDs ........................ 78 Combining Devices, Levels, and Channels ............79 Combining and Un-Combining Devices..............79 Combining devices ......................79 Un-combining devices ....................81 Combining and Un-Combining Levels ..............82 Combining levels......................83 NetLinx Programming Language Reference Guide...
  • Page 6 BOR (|) ..........................102 BREAK ..........................103 BUTTON_EVENT ........................ 103 BXOR (^) ..........................103 CALL ............................ 103 CANCEL_ALL_WAIT ......................103 CANCEL_ALL_WAIT_UNTIL ....................103 CANCEL_WAIT ........................103 CANCEL_WAIT_UNTIL ....................... 104 CASE ........................... 104 CHANNEL_EVENT ......................104 NetLinx Programming Language Reference Guide...
  • Page 7 DEFINE_COMBINE ......................113 DEFINE_CONNECT_LEVEL ....................113 DEFINE_CONSTANT ......................113 DEFINE_DEVICE ......................... 114 DEFINE_EVENT ........................114 DEFINE_FUNCTION ......................114 DEFINE_LATCHING ......................114 DEFINE_MODULE ....................... 114 DEFINE_MUTUALLY_EXCLUSIVE ..................115 DEFINE_PROGRAM ......................115 DEFINE_START ........................115 DEFINE_TOGGLING ......................115 NetLinx Programming Language Reference Guide...
  • Page 8 GET_LAST ........................... 130 GET_MULTI_BUFFER_STRING ..................131 GET_PULSE_TIME ......................131 GET_SERIAL_NUMBER ..................... 131 GET_SYSTEM_NUMBER ....................131 GET_TIMER ......................... 131 GET_UNIQUE_ID ........................ 131 GET_URL_LIST ........................132 HEXTOI ..........................133 HOLD ........................... 134 IF ............................134 INCLUDE ..........................134 NetLinx Programming Language Reference Guide...
  • Page 9 PROGRAM_NAME ......................143 PULSE ..........................143 PUSH ........................... 143 PUSH_CHANNEL ........................ 143 PUSH_DEVCHAN ........................ 143 PUSH_DEVICE ........................143 RANDOM_NUMBER ......................143 RAW_BE ..........................143 RAW_LE ..........................143 REBOOT ..........................144 REBUILD_EVENT() ......................144 REDIRECT_STRING ......................146 NetLinx Programming Language Reference Guide...
  • Page 10 TIMELINE_EVENT ....................... 155 TIMELINE_GET ........................155 TIMELINE_KILL ........................155 TIMELINE_PAUSE ......................155 TIMELINE_RELOAD ......................156 TIMELINE_RESTART ......................156 TIMELINE_SET ........................156 TO ............................157 TOTAL_OFF ........................157 TRUE ........................... 157 TYPE_CAST ........................157 UNCOMBINE_CHANNELS ....................157 viii NetLinx Programming Language Reference Guide...
  • Page 11 Identifier is not an array type ..................169 Include file not found ....................169 Invalid include file name....................169 Library file not found ....................169 Maximum string length exceeded................169 Must be char array reference ..................169 NetLinx Programming Language Reference Guide...
  • Page 12 Bad element assign..................... 172 Bad Off... Bad On... Bad To..................172 Bad re-assign Call......................172 Bad run token......................172 Bad Set_Length......................172 Bad While ........................172 NetLinx UniCode Functions ................173 Overview ......................173 NetLinx Programming Language Reference Guide...
  • Page 13 Send strings to a User Interface .................. 186 Right-to-Left Unicode Strings..................186 Compiler Errors ......................187 IP Communication ..................189 Client Programming....................189 Initiating a conversation ....................189 Terminating a conversation ..................190 Sending data ....................... 190 Receiving data......................190 NetLinx Programming Language Reference Guide...
  • Page 14 Marshalled Stream Format ..................215 Marshalling Protocol (Variables) ................217 Marshalled Stream format ................... 217 Encoding notes:......................219 String encoding ......................219 Binary array encoding....................219 Binary Encoding Result....................221 XML Encoding Result ....................223 Appendix B: Glossary ..................225 NetLinx Programming Language Reference Guide...
  • Page 15 Table of Contents NetLinx Programming Language Reference Guide xiii...
  • Page 16 Table of Contents NetLinx Programming Language Reference Guide...
  • Page 17: Introduction

    DEFINE_FUNCTION [<return type>] <name> [(Param1, Param2, …)] (* body of subroutine *) Related Instruction Manuals These instruction manuals contain additional information that relates to the NetLinx Programming Language: Axcess Programming Language Instruction Manual NetLinx Studio Program Instruction Manual NetLinx Programming Language Reference Guide...
  • Page 18 Introduction NetLinx Programming Language Reference Guide...
  • Page 19: Netlinx Programming Overview

    NetLinx and operate like mini-mainlines. They contain far less code and run faster than mainline. If an event occurs, and an event handler has been defined for that event, NetLinx bypasses mainline and runs the event handler. NetLinx Programming Language Reference Guide...
  • Page 20: Netlinx Vs. Axcess - Comparison By Structure

    ASCII, Decimal, or Hexadecimal. DEFINE_CONSTANT DEFINE_CONSTANT VALUE_MIN = 40 VALUE_MAX = 140 DEFAULT_NAME = 'Axcess' DEFAULT_NAME = 'Axcess' ETX [] = {$FE,$FF} = "$FE,$FF" VALUE_MAX = VALUE_MIN + 100 VALUE_MAX = VALUE_MIN + 100 NetLinx Programming Language Reference Guide...
  • Page 21: Define_Variables

    Variables are Non-Volatile (the variable loses its SLONG SIGNED2 value when the program is loaded, but retains its FLOAT DECIMAL value if the controller is reset). DOUBLE VERYBIGVALUE DEFINE_VARIABLE INTEGER ARRAY[3][3][3] VALUE VOLATILE INTEGER RESET_VAR ARRAY[3] ARRAY_2DIM[4][6] INTEGER INT_ARRAY[6] NetLinx Programming Language Reference Guide...
  • Page 22: Define_Call (Subroutines)

    • The function name is not enclosed with quotes or case • SYSTEM_CALL is an externally defined subroutine sensitive. with a '.LIB' extension. SYSTEM_CALL programs DEFINE_CALL 'SWITCH' (CARD,IN,OUT) are produced by AMX and are available on CD-ROM and on the Tech Support Web site at www.amx.com. SEND_STRING CARD, "ITOA(IN),'*',ITOA(OUT),'!'"...
  • Page 23: Define_Start

    There are five different types of events: Button Events, Channel Events, Data Events, Level Events, and Time- line Events. DEFINE_EVENT BUTTON_EVENT[TP,21] (* KC REPEAT 'A' *) PUSH: {SEND_STRING KC, 'A' RELEASE: HOLD[5,REPEAT]: SEND_STRING KC, 'A' NetLinx Programming Language Reference Guide...
  • Page 24: Define_Program

    An example of value increment and decrement operators is shown below. X = 1 Y = 5 (* X is now equal to 2 *) (* Y is now equal to 4 *)X = Y++(* This is not a legal statement *) NetLinx Programming Language Reference Guide...
  • Page 25: Axcess/Netlinx Incompatibility

    B && !A !B && !A The problem applies whether A and B are channels, variables, or expressions, and for as well as To solve the problem, AMX always recommends the use of instead of ; however, (!A) && B !A &&...
  • Page 26: Data Types

    $DE60 Binary Integer 000b 01110011b Floating Point 000.0 924.5 Exponential Notation 0.0e0 .5e-12 Character 'c' or <char code> 'R' or 255 String Literal 'ssss’ 'Reverse' The standard format for DEFINE_CONSTANT <constant name> = <constant expression> NetLinx Programming Language Reference Guide...
  • Page 27: Variables

    The structure for variables include: LOCAL_VAR STACK_VAR LOCAL_VAR [NON_VOLATILE | VOLATILE] [CONSTANT] [<type>] name [= <value>]STACK_VAR [<type>] name [= <value>] NetLinx Programming Language Reference Guide...
  • Page 28: Persistent Variables

    NetLinx handles arrays similar to C++, except that the first index value of the array is 1 rather than an index of 0 used by C++. With array initialization you don't need to count how many items are initialized. These definitions are functionally the same: NetLinx Programming Language Reference Guide...
  • Page 29 For example: AMX has three domestic locations; each location has a sales team, a professional services team and a tech support team; each team has a maximum of ten employees; each employee has the ability to store 10 preset names;...
  • Page 30: Structures

    DEFINE_VARIABLE The standard format for structures is: STRUCTURE <name> [<type>] <data1> [<type>] <data2> Using this format, we define our 'employee' structure in the section: DEFINE_TYPE NetLinx Programming Language Reference Guide...
  • Page 31: Data Sets

    You have already seen the structure structure in the section. If we were to define DEFINE_DEVICE the structure in the section, it would look like this: DEFINE_TYPE STRUCTURE DEV INTEGER DEVICE INTEGER PORT INTEGER SYSTEM NetLinx Programming Language Reference Guide...
  • Page 32 PUSH[MSP3, 1] [RELAY, 1] = ![RELAY, 1] [MSP1, 1] = [RELAY, 1] [MSP2, 1] = [RELAY, 1] [MSP3, 1] = [RELAY, 1] You can use device sets or channel sets to accomplish the same functionality: NetLinx Programming Language Reference Guide...
  • Page 33: Conditionals & Loops

    All other statements are ignored. If CASE CASE no match is found, the case statements (if any) are executed. The expression is DEFAULT SWITCH evaluated only once. The following rules apply to statements: SWITCH...CASE NetLinx Programming Language Reference Guide...
  • Page 34: For Loops

    Functionally they do the same thing, but loops are more readable. loops, like loops, do not process input changes from the message buffer. The WHILE structure for a loop is shown below: FOR (<INITIAL>;<condition>;<after pass>) (* loop statements *) NetLinx Programming Language Reference Guide...
  • Page 35: Functions

    Preset 1. The subroutine executes three commands and no values are returned to the program. DEFINE_CALL 'PRESENTATION MACRO' SYSTEM_CALL [1] 'SCREEN1' (0, 0, 1, 0, SCREEN, 1, 2, 3, 0) SEND_STRING VPROJ, "'PON',$0D,$0A" SEND_STRING RADIA, "'1B',$0D" NetLinx Programming Language Reference Guide...
  • Page 36: Define_Function

    DEFINE_FUNCTION LONG value: DEFINE_FUNCTION LONG CUBEIT (LONG VALUE) STACK_VAR RESULT RESULT = VALUE * VALUE * VALUE RETURN RESULT DEFINE_PROGRAM PUSH[TP1, 1] CUBED_VAL = CUBEIT ( 3 ) (* CUBED_VAL = 27 *) NetLinx Programming Language Reference Guide...
  • Page 37: Events

    The event specifies the HOLD actions to be performed when a button is pressed and held for a minimum length of time indicated by the parameter, which is specified in tenth seconds. <time> NetLinx Programming Language Reference Guide...
  • Page 38: Channel Events

    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. NetLinx Programming Language Reference Guide...
  • Page 39 (* SYSTEM OFF BUTTON *) PULSE[RELAY,RACK_OFF] PULSE[RELAY,LIFT_UP] PULSE[VPROJ,VP_POWER_OFF] NetLinx Channel Event: DEFINE_EVENT BUTTON_EVENT[TP1,21] (* LIFT UP BUTTON *) PUSH: PULSE[RELAY,LIFT_UP] BUTTON_EVENT[TP1,22] (* SYSTEM OFF BUTTON *) PUSH: PULSE[RELAY,RACK_OFF] PULSE[RELAY,LIFT_UP] CHANNEL_EVENT[RELAY,LIFT_UP] (* LIFT UP RELAY EVENT *) PULSE[VPROJ,VP_POWER_OFF] NetLinx Programming Language Reference Guide...
  • Page 40: Data Events

    This becomes a factor when receiving large strings, or when receiving strings with an embedded string length or start and end characters. then evaluates the buffer to see DATA_EVENT if the entire string has been received before processing it; however, the evaluation is done immediately NetLinx Programming Language Reference Guide...
  • Page 41 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 NetLinx Programming Language Reference Guide...
  • Page 42 ACTIVE (FIND_STRING (DATA.TEXT,'PAGE-',1)): JUNK = REMOVE_STRING (DATA.TEXT,'PAGE-',1) CUR_PAGE = DATA.TEXT ACTIVE (FIND_STRING (DATA.TEXT,'KEYP-',1)): (* keypad code *) ACTIVE (FIND_STRING (DATA.TEXT,'KEYB-',1)): (* keyboard code *) ACTIVE (1): (* default code *) CLEAR_BUFFER TP1_BUFFER ONLINE: SEND_COMMAND TP1, 'TPAGEON' Continued NetLinx Programming Language Reference Guide...
  • Page 43: Level Events

    IF (LEVEL.VALUE >= COOL_POINT) ON[RELAY,FAN] ELSE IF (LEVEL.VALUE <= HEAT_POINT) OFF[RELAY,FAN] is an embedded object value in the statement. The LEVEL.VALUE LEVEL_EVENT LEVEL.VALUE object eliminates the need to create a level for the device. TEMP NetLinx Programming Language Reference Guide...
  • Page 44: Combining Devices, Channels And Levels

    UNCOMBINE_LEVELS are connected to each other. It is also recommended that a Virtual set be used as the first DEVLEV set in the function. The format for DEVLEV COMBINE_LEVELS COMBINE_LEVELS UNCOMBINE_LEVELS NetLinx Programming Language Reference Guide...
  • Page 45: Combining And Uncombining Channels

    Module. The code in the Module is local, or is restricted to use only within the Module. This means that functions and subroutines defined with Module cannot be directly used with the main NetLinx code. NetLinx Programming Language Reference Guide...
  • Page 46 DEFINE_MODULE DEFINE_PROGRAM DEFINE_EVENTS section. In order to use a module, the module must be compiled with the Source Code, and the Master must be rebooted to run the new module. NetLinx Programming Language Reference Guide...
  • Page 47: Language Elements

    This type of statement is typically used for feedback. It sends an output change to the specified channel on the given device. An example is: [Device, Channel] = <expression> The expression is evaluated as follows: NetLinx Programming Language Reference Guide...
  • Page 48: Conditionals

    An example is: SELECT ACTIVE (<condition 1>) : (* statements for condition 1*) ACTIVE (<condition 2>) : (* statements for condition 2*) ACTIVE (<condition n>) : ACTIVE (1) (* statements for condition n*) NetLinx Programming Language Reference Guide...
  • Page 49: Switch

    . It takes execution to the end of the BREAK SWITCH SWITCH Unlike the C language, cases do not fall through to the next case if a break is not used. s are recommended between cases. For example: BREAK NetLinx Programming Language Reference Guide...
  • Page 50: Loops

    NetLinx Central Controller handles bus updates through a separate execution thread, thereby eliminating this potential problem. MEDIUM_WHILE statements statement is obsolete in NetLinx. The compiler accepts the statement but converts MEDIUM_WHILE it internally to a statement. For example: WHILE NetLinx Programming Language Reference Guide...
  • Page 51: Long_While Statements

    <after pass> One or more statements that are executed after each pass through the state- ments. Each statement must be separated with a comma. This is typically a statement that increments the FOR loop index. NetLinx Programming Language Reference Guide...
  • Page 52: Waits

    If greater precision is required, the time parameter can be expressed as a dec- imal fraction, for example 0.1 to specify a wait time of 1/100th of a second. The range is from 0.1 to 0.9. WAIT 50 'FIRST WAIT' (* wait statements *) Continued NetLinx Programming Language Reference Guide...
  • Page 53: Nesting Waits

    (* SECOND WAIT statements *) To execute the inner wait of a nested conditional wait, the conditions must be met in the order specified (condition 1, then condition 2) but not necessarily at the same time. NetLinx Programming Language Reference Guide...
  • Page 54: Pausing And Restarting Waits

    WAIT cannot appear within a if it takes execution out of the scope of BREAK CONTINUE WAIT WAIT The code within a cannot reference a function or subroutine array parameter whose WAIT bounds are unspecified. NetLinx Programming Language Reference Guide...
  • Page 55: Comments

    A relational operator is a conditional statement; it tells NetLinx whether to execute a particular function(s) in the program. Relational Operators Operator Function Less Than < Greater Than > Equal To Equal To Less Than or Equal To <= Greater Than or Equal To >= Not Equal To <> NetLinx Programming Language Reference Guide...
  • Page 56: Logical Operators

    " and " " operators are statements and cannot appear within expressions. For example: FOR (I=1; I<10; I++) // Legal I = j++; // Illegal Refer to the Structures section on page 55 for information on structures. NetLinx Programming Language Reference Guide...
  • Page 57: Operator Precedence

    NetLinx systems but the lowest precedence in Axcess systems. Axcess programs that are converted to NetLinx may exhibit logic problems if they use statements that combine and other operators. Contact AMX Technical Support for help NOT (!) resolving these issues.
  • Page 58: Device Arrays

    The individual elements of a device array can be referenced by their defined names ( , etc.) Dev1 Dev2 or by using array notation with the device array name. For example, the 3rd device in the device array, , would be referenced by MyDeviceSet MyDeviceSet[3] NetLinx Programming Language Reference Guide...
  • Page 59: Device Array Examples

    IF ( [dc1] || [128:1:0, 2] ) // evaluation of 2 devchans [dc1] = 1 // feedback dc1 = {129:1:0, 2} // assigns a new value to dc1 [dc1] = {129:1:0, 2} // Syntax Error! NetLinx Programming Language Reference Guide...
  • Page 60: Device-Level Arrays

    The DEFINE_DEVICE second component is the level number on the device. The level number is expressed as an integer constant. array is declared in the section in one of two DEVLEV DEFINE_VARIABLE DEFINE_CONSTANT ways: NetLinx Programming Language Reference Guide...
  • Page 61: Variables

    To provide compatibility with the Axcess language, local variables may be declared right before the opening brace declarations only. For example, both formats shown below are legal in the NetLinx DEFINE_CALL language: NetLinx Programming Language Reference Guide...
  • Page 62 A name assigned to a local variable must be unique within the statement block in which it is declared and any statement block enclosing that block. Therefore, non-nested statement blocks can define the same local variable name without conflict. For example: NetLinx Programming Language Reference Guide...
  • Page 63: Global Variables

    A global variable is accessible throughout the module or program in which it is defined. Global variables retain their value as long as the program runs. They may retain their value after powering down or reloading the system, depending on the variable's persistence attributes ( VOLATILE PERSISTENT NetLinx Programming Language Reference Guide...
  • Page 64: Constancy

    Without persistent variables, an update to the NetLinx program would zero out all of the presets that the user had NetLinx Programming Language Reference Guide...
  • Page 65: Constants

    Valid Formats for Constants Type Format Example Decimal Integer 0000 1500 Hexadecimal Integer $000 $DE60 Floating Point 000.0 924.5 Exponential Notation 0.0e0 1.5e-12 Character 'c' or <char code> 'R' or 255 String Literal 'ssss' 'Reverse' NetLinx Programming Language Reference Guide...
  • Page 66: Data Types

    This may involve truncating the high order bytes(s) when converting to a smaller size variable, or sign conversion when converting signed values to unsigned or vice versa. NetLinx Programming Language Reference Guide...
  • Page 67: Strings

    It maintains a length field that can be retrieved using and set using . Here's an LENGTH_STRING SET_LENGTH_STRING example: WIDECHAR StrExp[6] INTEGER StrLen StrExp = {STOP, 500, 'OFF', X} StrLen = LENGTH_STRING(StrExp) NetLinx Programming Language Reference Guide...
  • Page 68: Arrays

    In the case of a multidimensional character string, the strings in the initialization statement are separated by commas and enclosed in braces. In order to populate the array, for example: NetLinx Programming Language Reference Guide...
  • Page 69: Multi-Dimensional Arrays

    INTEGER Num3D[2][5][10] // [Table][Row][Column] One way to view these arrays is to think of as being a collection of five Num2D Num1D's Num3D being a collection of two Num2D's When referencing elements of the above arrays: NetLinx Programming Language Reference Guide...
  • Page 70 (* Len = 2, number of tables *) Len = LENGTH_ARRAY(My3Darray[2]) (* Len = 1, number of rows in table 2 *) Len = LENGTH_ARRAY(My3Darray[1][3]) (* Len = 3, number of columns in table 1, row 3 *) NetLinx Programming Language Reference Guide...
  • Page 71: Structures

    A syntax sample for a structure definition is shown below: STRUCTURE <name> [<type>] <Data1> [<type>] <Data2> [<type>] <DataN> The attributes , and do not apply to the individual members of a VOLATILE PERSISTENT CONSTANT structure. NetLinx Programming Language Reference Guide...
  • Page 72: Subroutines

    SYSTEM_CALL calling parameters, as shown below: SYSTEM_CALL 'COSX' (45) System calls are resolved automatically at compile time, without requiring an instruction to INCLUDE include the system call source file. NetLinx Programming Language Reference Guide...
  • Page 73: Function Subroutines

    When it is a NetLinx function, a syntax where there appears a ([ ]), the ( ) are NOT OPTIONAL but the [ ] are optional. The DEFINE_FUNCTION subroutine can be called as a single programming statement. For example, the following syntax: NetLinx Programming Language Reference Guide...
  • Page 74 Count = ReadBuffer(Buffer,BufSize) ReadBuffer(Buffer,BufSize) // return value is ignored The return type may only be one of the 8 intrinsic types (see Data Types). Strings, arrays, structures, classes and other user-defined types may not be returned. NetLinx Programming Language Reference Guide...
  • Page 75: Calling Parameters

    If dimensions are specified in the call statement, the compiler will interpret that as specifying a subset of the array. For example, suppose were defined as a 3-dimensional array. The third table of that Array dimensional array could be passed to as follows: 'Process Array' CHAR Buffer[5][5][10] CALL 'Process Array' (Array [3]) NetLinx Programming Language Reference Guide...
  • Page 76 Language Elements NetLinx Programming Language Reference Guide...
  • Page 77: Event Handlers

    The event handler descriptions are: refers to a device specification: DEVICE DEVICE A single device number constant A constant device specification such as 128:1:0 D:P:S DEV[ ] A device array NetLinx Programming Language Reference Guide...
  • Page 78: Button Events

    REPEAT TIME increments as long as the button is held. object is available to the button event handler as a local variable. The following table lists BUTTON the information contained in Button Objects. NetLinx Programming Language Reference Guide...
  • Page 79: Channel Events

    // Channel ON event handler OFF: // Channel OFF event handler The Channel object is available to the channel event handler as a local variable. The following table lists the information contained in Channel events: NetLinx Programming Language Reference Guide...
  • Page 80: Data Events

    The data object is available to the data event handler as a local variable. An example data event is: DATA_EVENT[DEVICE] or DATA_EVENT[DEV[ ]] COMMAND: // COMMAND event handler STRING: // STRING event handler ONLINE: // ONLINE event handler OFFLINE: // OFFLINE event handler ONERROR: // ONERROR event handler NetLinx Programming Language Reference Guide...
  • Page 81: Level Events

    This eliminates having to constantly evaluate a level against a previous value. In Axcess, a level needs to be created in the section and then a DEVICE_START conditional statement appears in the mainline to evaluate and update the level. The format of the LEVEL_EVENT NetLinx Programming Language Reference Guide...
  • Page 82 The numeric value is stored either as a floating-point number or integer, as appropriate; but the value can be assigned to a variable of any numeric type. Existing Axcess code: DEFINE_START CREATE_LEVEL TEMP, 1, TEMP_LEVEL DEFINE_PROGRAM IF (TEMP_LEVEL >= COOL_POINT) ON[RELAY,FAN] ELSE IF (TEMP_LEVEL <= HEAT_POINT) OFF[RELAY,FAN] NetLinx Programming Language Reference Guide...
  • Page 83: Custom Events

    Text associated with the event Custom.Encode CHAR[] A string encoded with VARIABLE_TO_STRING encoding for complex data types. Custom.SourceDev Source device of custom event Custom.SourceDev.Number INTEGER Source device number Custom.SourceDev.Port INTEGER Source device port Custom.SourceDev.System INTEGER Source device system. NetLinx Programming Language Reference Guide...
  • Page 84: Event Parameters

    Let's take another example: Example 2: DEFINE_DEVICE dvTp = 128:1:0 DEFINE_VARIABLE Integer nMyChannel DEFINE_START nMyChannel = 1 DEFINE_EVENT BUTTON_EVENT[dvTp,nMyChannel] PUSH: Send_String 0,"'Button ',ITOA(nMyChannel),' of dvTp was pushed'" NetLinx Programming Language Reference Guide...
  • Page 85 (system) variable. At compile time, the values are defined and contain a value of 0. So the following code: Example 4: DEFINE_EVENT BUTTON_EVENT[dvTp,PUSH_CHANNEL] PUSH: Send_String 0,"'Button ',ITOA(BUTTON.INPUT.CHANNEL),' of dvTp was pushed'" RELEASE: Send_String 0,"'Button ',ITOA(BUTTON.INPUT.CHANNEL),' of dvTp was released'" NetLinx Programming Language Reference Guide...
  • Page 86 = 131:1:0 dvPanel5 = 132:1:0 dvPanel6 = 133:1:0 DEFINE_VARIABLE DEV dvMyPanels[] = { dvPanel1, dvPanel2, dvPanel3, dvPanel4, dvPanel5, dvPanel6 INTEGER nMyButtons[] = { 4, 3, 2, 1 } INTEGER nPanelIndex INTEGER nButtonIndex DEFINE_EVENT Continued NetLinx Programming Language Reference Guide...
  • Page 87: Timeline Functions

    TIMELINE STRUCTURE TIMELINE INTEGER //user supplied ID INTEGER SEQUENCE //index in Times array LONG TIME //time since start of timeline INTEGER RELATIVE //0=absolute 1=relative LONG REPETITION //# of loops for repeating timeline Continued NetLinx Programming Language Reference Guide...
  • Page 88 2 Specified array is not an array of LONGs 3 Specified length is greater than the length of the passed array 4 Out of memory Example: DEFINE_VARIABLE LONG TimeArray[100] DEFINE_CONSTANT TL1 = 1 TL2 = 2 DEFINE_EVENT Continued NetLinx Programming Language Reference Guide...
  • Page 89 TimeArray[2] = 1000 TimeArray[3] = 1000 TimeArray[4] = 1000 TimeArray[5] = 1000 TIMELINE_CREATE(TL2, TimeArray, 5, TIMELINE_RELATIVE, TIMELINE_ONCE) The example above creates two timelines ( ) that trigger events at the same rate (once per second). NetLinx Programming Language Reference Guide...
  • Page 90: Timeline Example

    (***********************************************************) DEVICE NUMBER DEFINITIONS GO BELOW (***********************************************************) DEFINE_DEVICE dvPanel = 128:1:0 dvDebug = 0:0:0 (***********************************************************) CONSTANT DEFINITIONS GO BELOW (***********************************************************) DEFINE_CONSTANT MY_LINE_1 = 1 MY_LINE_2 = 2 (***********************************************************) VARIABLE DEFINITIONS GO BELOW (***********************************************************) DEFINE_VARIABLE Continued NetLinx Programming Language Reference Guide...
  • Page 91 4: { SEND_COMMAND dvPanel,"'TEXT2-2 4'" case 5: { SEND_COMMAND dvPanel,"'TEXT2-2 5'" SEND_STRING dvDebug,"'Timer ',ITOA(Timeline.ID),' Event ',ITOA(Timeline.Sequence), ' Time = ',ITOA(Timeline.Time), ' Repetition = ',ITOA(Timeline.Repetition),' Relative = ',ITOA(Timeline.Relative)" (***********************************************************) THE ACTUAL PROGRAM GOES BELOW (***********************************************************) Continued NetLinx Programming Language Reference Guide...
  • Page 92 TimeArray[1] = 1000 TimeArray[2] = 2000 TimeArray[3] = 3000 TimeArray[4] = 4000 TimeArray[5] = 5000 TIMELINE_CREATE(MY_LINE_2,TimeArray,5,TIMELINE_ABSOLUTE,TIMELINE_REPEAT) (***********************************************************) (* Modify the timeline my kill, pause and restarting (***********************************************************) PUSH[dvPanel,3] IF(TIMELINE_ACTIVE(MY_LINE_1))TIMELINE_KILL(MY_LINE_1) IF(TIMELINE_ACTIVE(MY_LINE_2))TIMELINE_KILL(MY_LINE_2) PUSH[dvPanel,4] IF(TIMELINE_ACTIVE(MY_LINE_1))TIMELINE_PAUSE(MY_LINE_1) IF(TIMELINE_ACTIVE(MY_LINE_2))TIMELINE_PAUSE(MY_LINE_2) PUSH[dvPanel,5] IF(TIMELINE_ACTIVE(MY_LINE_1))TIMELINE_RESTART(MY_LINE_1) IF(TIMELINE_ACTIVE(MY_LINE_2))TIMELINE_RESTART(MY_LINE_2) Continued NetLinx Programming Language Reference Guide...
  • Page 93 SEND_COMMAND dvPanel,"'TEXT4-','Timer 2 Time is ',ITOA(TIMELINE_GET(MY_LINE_2))" (***********************************************************) (* Pause and restart the timeline at new locations (***********************************************************) PUSH[dvPanel,8] TIMELINE_PAUSE(MY_LINE_1) TIMELINE_PAUSE(MY_LINE_2) TIMELINE_SET(MY_LINE_1,0) TIMELINE_SET(MY_LINE_2,0) TIMELINE_RESTART(MY_LINE_1) TIMELINE_RESTART(MY_LINE_2) (***********************************************************) END OF PROGRAM DO NOT PUT ANY CODE BELOW THIS COMMENT (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 94: Timeline Ids

    TIMELINE_EVENT[TimelineID_2] // capture all events for Timeline 2 TIMELINE_EVENT[TimelineID_3] // capture all events for Timeline 3 TIMELINE_EVENT[TimelineID_4] // capture all events for Timeline 4 SEND_STRING 0,"'TL ID = ', itoa(timeline.id),', sequence = ',itoa(timeline.sequence)" // end NetLinx Programming Language Reference Guide...
  • Page 95: Combining Devices, Levels, And Channels

    Axcess sees the input as coming only from the first device in the list ( If button is pressed, Axcess will see the input coming from due to the [TP2,12] [TP1,12] combination. Likewise, any output change sent to any device in the list will automatically be sent to all NetLinx Programming Language Reference Guide...
  • Page 96 Here's a syntax example: COMBINE_DEVICES (VIRTUAL1, TP1, TP2, TP3) In addition to virtual devices and device arrays, the NetLinx language contains several new keywords for combine and un-combine operations: COMBINE_DEVICES, UNCOMBINE_DEVICES COMBINE_LEVELS, UNCOMBINE_LEVELS COMBINE_CHANNELS, UNCOMBINE_CHANNELS NetLinx Programming Language Reference Guide...
  • Page 97: Un-Combining Devices

    TP2 = 129 TP3 = 130 TP4 = 131 DEFINE_PROGRAM (* Activate dynamic device combine*) RELEASE[TP4,1] COMBINE_DEVICES(VIRTUAL1, TP1, TP2, TP3) (*Remove dynamic device combine*) RELEASE[TP4,1] UNCOMBINE_DEVICES(VIRTUAL1) (*Pushes come here when a combine is active*) Continued NetLinx Programming Language Reference Guide...
  • Page 98: Combining And Un-Combining Levels

    ), instead of specifying the individual Dev[ ] devices ( , and ). Device arrays further simplify code and allow you to dynamically combine/un-combine levels. Any input events for any device in the array will appear to the program as NetLinx Programming Language Reference Guide...
  • Page 99: Combining Levels

    The NetLinx code example below illustrates how to dynamically combine and un-combine levels. Input and output changes occurring on non-combined panels will not affect combined panels, and vice versa. DEFINE_DEVICE VIRTUAL1 = 33000 TP1 = 128 TP2 = 129 TP3 = 130 Continued NetLinx Programming Language Reference Guide...
  • Page 100: Combining And Un-Combining Channels

    Un-combining channels reverses the effect of . All combines related to the UNCOMBINE_CHANNELS COMBINE_CHANNELS specified virtual device-channel are disabled. UNCOMBINE_CHANNELS (DEVCHAN VDC) Parameters: The virtual device-channel passed to COMBINE_CHANNELS. UNCOMBINE_CHANNELS (VDC) NetLinx Programming Language Reference Guide...
  • Page 101 BUTTON_EVENT[vdvControl,1] // this will work when the combine_channels above is invoked PUSH: TO[BUTTON.INPUT] // example of combining individual DEVCHANs to a virtual [DEV,CHAN] pair DEFINE_VARIABLE DEVCHAN dc2[] = {{dvIO10,2},{dvREL10,2},{dvTP,2}} DEFINE_EVENT BUTTON_EVENT[dvTP,13] // combine_channels 2 RELEASE: COMBINE_CHANNELS (vdvControl,2,dc2[1],dc2[2],dc2[3]) Continued NetLinx Programming Language Reference Guide...
  • Page 102 DEVCHAN dc3[] = {{dvIO10,3},{dvREL10,3},{dvTP,3}} DEFINE_EVENT BUTTON_EVENT[dvTP,15] // combine_channels 3 RELEASE: COMBINE_CHANNELS (vdvControl,3, dc3[1].DEVICE, dc3[1].CHANNEL, dc3[2].DEVICE, dc3[2].CHANNEL, dc3[3].DEVICE, dc3[3].CHANNEL) BUTTON_EVENT[dvTP,16] // uncombine_channels 3 RELEASE: UNCOMBINE_CHANNELS (vdvControl,3) BUTTON_EVENT[vdvControl,3] // this will work when the combine_channels above is invoked Continued NetLinx Programming Language Reference Guide...
  • Page 103 BUTTON_EVENT[vdc4] // this will work when the combine_channels above is invoked PUSH: TO[BUTTON.INPUT] // example of combining individual DEVCHANs to a virtual DEVCHAN DEFINE_VARIABLE DEVCHAN vdc5 = {vdvControl,5} DEVCHAN dc5[] = {{dvIO10,5},{dvREL10,5},{dvTP,5}} DEFINE_EVENT BUTTON_EVENT[dvTP,19] // combine_channels 5 Continued NetLinx Programming Language Reference Guide...
  • Page 104 // example of combining individual [DEV,CHAN] pairs to a virtual DEVCHAN DEFINE_VARIABLE DEVCHAN vdc6 = {vdvControl,6} DEVCHAN dc6[] = {{dvIO10,6},{dvREL10,6},{dvTP,6}} DEFINE_EVENT BUTTON_EVENT[dvTP,21] // combine_channels 6 RELEASE: COMBINE_CHANNELS (vdc6, dc6[1].DEVICE, dc6[1].CHANNEL, dc6[2].DEVICE, dc6[2].CHANNEL, dc6[3].DEVICE, dc6[3].CHANNEL) BUTTON_EVENT[dvTP,16] // uncombine_channels 6 RELEASE: UNCOMBINE_CHANNELS (vdc6) Continued NetLinx Programming Language Reference Guide...
  • Page 105 Combining Devices, Levels, and Channels BUTTON_EVENT[vdc6] // this will work when the combine_channels above is invoked PUSH: TO[BUTTON.INPUT] // end NetLinx Programming Language Reference Guide...
  • Page 106 Combining Devices, Levels, and Channels NetLinx Programming Language Reference Guide...
  • Page 107: Master-To-Master (M2M)

    The top portion of the illustration shows the physical connections and the devices represented. The bottom portion shows the logical connections that have been assigned. FIG. 1 Physical and logical connections NetLinx Programming Language Reference Guide...
  • Page 108: Master Routing

    NetLinx system is depicted in FIG. . >show route System Route Metric PhyAddress ----------------------------------------- TCP Socket=18 IP=192.168.12.76 Index=3 TCP Socket=18 IP=192.168.12.76 Index=3 TCP Socket=18 IP=192.168.12.76 Index=3 TCP Socket=16 IP=192.168.12.80 Index=1 ->5 AXlink TCP Socket=19 IP=192.168.12.106 Index=2 TCP Socket=19 IP=192.168.12.106 Index=2 NetLinx Programming Language Reference Guide...
  • Page 109: Design Considerations And Constraints

    FIG. 4 expands FIG. 3 into two dimensions and takes advantage of the fact that each NetLinx master supports multiple connections to masters. FIG. 4 Two-dimensional view of the maximum number of interconnected NetLinx masters NetLinx Programming Language Reference Guide...
  • Page 110 2 systems that share devices, control, or information, they should be side-by-side in the topology, not at opposite ends of the connection Matrix where each message is forced to pass through several NetLinx Masters. NetLinx Programming Language Reference Guide...
  • Page 111: Control/Netlinx Language Support

    When NetLinx Studio connects to a single master, yet allows the user to access all other system masters, some confusion will occur. Therefore, it is a good idea to document each system's, number and the topology of the interconnections. NetLinx Programming Language Reference Guide...
  • Page 112 Master-To-Master (M2M) NetLinx Programming Language Reference Guide...
  • Page 113: Mainline

    FIG. 1 illustrates message and mainline processing as it appears in the NetLinx system. Note that bus servicing is taken care of by a separate process thread (Connection Manager & Message Dispatcher) and, therefore, is not a task that must follow mainline. NetLinx Programming Language Reference Guide...
  • Page 114 Mainline FIG. 1 Message and Mainline Processing in the NetLinx System NetLinx Programming Language Reference Guide...
  • Page 115: Reserved Identifiers

    #ELSE is not present) is compiled only if symbol is not defined (see #DEFINE above). If a symbol is defined and the #ELSE directive is present, the code fol- lowing #ELSE and before #END_IF is compiled instead. #IF_NOT_DEFINED symbol // code block #ELSE // code block #END_IF NetLinx Programming Language Reference Guide...
  • Page 116: Keywords & Run-Time Library Functions

    ABS_VALUE provides the absolute value of a variable. It will take any intrinsic ABS_VALUE variable type and return the same type. AbsVal ABS_VALUE (Value) DEFINE_VARIABLE SLONG Var1, Var2 DEFINE_START Var1 = -1 DEFINE_PROGRAM Var2 = ABS_VALUE(Var1) // Var2 = 1 See SELECT...ACTIVE on page 148. ACTIVE NetLinx Programming Language Reference Guide...
  • Page 117: Add_Url_Entry

    • Sunset: Value gets filled in by the function in mm/dd/yyyy format. Result: • 0: Success • -1: Latitude entry error • -2: Longitude entry error • -3: Hours entry error • -4: Date entry error NetLinx Programming Language Reference Guide...
  • Page 118: Atoi

    BAND (&) or variables. This operator performs a bitwise NOT on a constant or variable. BNOT (~) This operator performs a bitwise OR on two data items, which can be constants BOR (|) or variables. NetLinx Programming Language Reference Guide...
  • Page 119: Break

    This keyword cancels all WAITs (named or unnamed) in the WAIT list. CANCEL_ALL_WAIT This keyword cancels all (named or unnamed) WAIT_UNTIL and CANCEL_ALL_WAIT_ TIMED_WAIT_UNTIL commands. UNTIL This keyword cancels a specified wait. Only named waits can be canceled. CANCEL_WAIT CANCEL_WAIT '<wait name>' NetLinx Programming Language Reference Guide...
  • Page 120: Cancel_Wait_Until

    GET_BUFFER_CHAR calls will not return anything. The CLEAR_BUFFER command does not modify the data in the buffer, just the inter- nal length value. CLEAR_BUFFER Buffer CLEAR_BUFFER does not delete the data in the buffer; it only sets the length to zero. NetLinx Programming Language Reference Guide...
  • Page 121: Clkmgr_Add_Userdefined_Timeserver

    The Occurrence-Of-Day rules ave the form: "occurence:OCCURENCE, DAY-OF-WEEK,MONTH,HH:MM:SS" with all fields as numeric except for the word "occurence". DAY-OF-WEEK translates as: • 1=Sunday • 2=Monday • 3=Tuesday • 4=Wednsday • 5=Thursday • 6=Friday • 7=Saturday NetLinx Programming Language Reference Guide...
  • Page 122: Clkmgr_Get_End_Daylightsavings_Rule

    "occurence" DAY-OF-WEEK translates as: • 1=Sunday • 2=Monday • 3=Tuesday • 4=Wednsday • 5=Thursday • 6=Friday • 7=Saturday (e.g.: "occurence:3,1,10,02:00:00" ===> 3rd Sunday in October @ 02:00:00AM). NetLinx Programming Language Reference Guide...
  • Page 123: Clkmgr_Set_Resync_Period

    COMBINE_CHANNELS (DEVCHAN VDC, DEVCHAN[ ] DCSets) Parameters: • VDC: Virtual device-channel that represents one device-channel combine group. • DCSets: Device-channel array containing the device-channel pairs to combine. Each element in each set is combined with the virtual device-channel. NetLinx Programming Language Reference Guide...
  • Page 124: Combine_Devices

    • DLSETS: Device-level sets containing the device-level pairs to combine. Corresponding elements in each set are combined with the corresponding element in the virtual device-level array. This keyword defines a section in a DATA event handler for processing COMMAND SEND_COMMAND instructions. NetLinx Programming Language Reference Guide...
  • Page 125: Compare_String

    If the buffer is full, all bytes in the buffer are shifted to make room for the new string. A buffer can be manipulated in the same way as a character array. NetLinx Programming Language Reference Guide...
  • Page 126: Create_Level

    • For the second form of the command, using DeviceSet, only 255 devices will be allowed in the array. This is required since only one byte is used to represent the DeviceSet index in the return string so it has an upper limit of 255. NetLinx Programming Language Reference Guide...
  • Page 127: Data_Event

    // String processing goes here ONLINE: // OnLine processing goes here OFFLINE: // OffLine processing goes here ONERROR: // OnError processing goes here See the Event Handlers section on page 61 for more information on DATA_EVENT handlers. NetLinx Programming Language Reference Guide...
  • Page 128: Date

    This function returns an sinteger representing the day of the week (1 = Sunday, 2 = Monday, etc.). SINTEGER nDay = DAY_OF_WEEK ('2/13/1999') // nDay = 7 (Saturday) This keyword specifies the default case in a SWITCH…CASE statement. DEFAULT See SWITCH...CASE on page 153. NetLinx Programming Language Reference Guide...
  • Page 129: Define_Call

    (a virtual device) cannot be taken off-line or removed from the system. This keyword defines program constants; the value of a constant cannot be DEFINE_CONSTANT changed within the program. DEFINE_CONSTANT PLAY = 1 STOP = 2 STRING='HELLO' NetLinx Programming Language Reference Guide...
  • Page 130: Define_Device

    • <module name>: The name of the module as specified in the MODULE_NAME statement in the module implementation file. • InstanceName: The name to assign to the instance of the module. • <parameter list>: The list of parameters available to the module. NetLinx Programming Language Reference Guide...
  • Page 131: Define_Mutually_Exclusive

    This keyword section defines custom data types such as structures and arrays. DEFINE_TYPE An example DEFINE_TYPE section is shown below. DEFINE_TYPE STRUCTURE MyStruct LONG Num CHAR Name[30] See the Data Types section on page 10 for a discussion of structures. NetLinx Programming Language Reference Guide...
  • Page 132: Define_Variable

    DeviceID = DEVICE_ID(Device) For example: IF (DEVICE_ID(55:1:0) <> 0) // device 55 exists in the system This keyword returns a string description/model number for the specified DEVICE_ID_STRING device. DeviceString = DEVICE_ID_STRING(55:1:0) NetLinx Programming Language Reference Guide...
  • Page 133: Device_Info

    $20 (SOURCE_TYPE_INTERNAL) - This device is internal to the NetLinx controlled. • Info. SOURCE_STRING - A string identifying the source address. Normally, this contains only useful information when Info.SOURCE_TYPE is $02 (IP), in which case this contains the IP address of the device. NetLinx Programming Language Reference Guide...
  • Page 134: Devlev

    This keyword defines a data type (structure) containing fields used to represent DEVLEV a specific device number, port, system, and level. This structure is used to implement an array DEVLEV[ ]. STRUCTURE DEVLEV Device INTEGER Level NetLinx Programming Language Reference Guide...
  • Page 135: Do_Push

    If the corresponding IF statement is false, the program will jump to the ELSE ELSE section of the IF…ELSE set of statements. This keyword is a CHAR constant contains the value 0. FALSE While NetLinx does not support a BOOLEAN data type, zero is consider false conditional expressions. NetLinx Programming Language Reference Guide...
  • Page 136: File_Close

    Result = File_Copy('OLDFILE.TXT', 'NEWFILE.TXT') CHAR Buffer[1024] SLONG NumFiles = 1 LONG Entry = 1 WHILE (NumFiles > 0) NumFiles = FILE_DIR ('AAA:', Buffer, Entry) Entry = Entry + 1 // add code to display contents of Buffer NetLinx Programming Language Reference Guide...
  • Page 137: File_Createdir

    • -12: Directory not loaded Note: The LONG command cannot pass negative numbers, so if you have errors these will never be recognized. SLONG must be assigned or errors will be type- cast to positive numbers. NetLinx Programming Language Reference Guide...
  • Page 138: File_Getdir

    If the file is opened successfully, it must be closed after all reading or writing is completed, by calling FILE_CLOSE. If files are not closed, subsequent file open operations may fail due to the limited number of file handles available. // Open MYFILE.TXT for reading hFile = FILE_OPEN('MYFILE.TXT', FILE_READ_ONLY) NetLinx Programming Language Reference Guide...
  • Page 139: File_Read

    If a complete line is read, the file pointer is advanced to the next character in the file after the <CR> or <CR><LF> pair or to the EOF if the last line was read. CHAR Buffer[80]nBytes = FILE_READ_LINE (hFile, Buffer, NetLinx Programming Language Reference Guide...
  • Page 140: File_Removedir

    After FILE_SEEK is successfully called, subsequent read or write operations begin at the byte number specified by Pos. Sets the file pointer to byte number 1000. Subsequent read or write operations will begin at byte number 1000.Result = FILE_SEEK (hFile, 1000) NetLinx Programming Language Reference Guide...
  • Page 141: File_Setdir

    • -5: Disk I/O error • -6: Invalid parameter (LineLen must be greater than zero) • -11: Disk full A <CR><LF> character pair is automatically appended to the end of the line. CHAR Line[80]Result = FILE_WRITE_LINE (hFile, Line, 80) NetLinx Programming Language Reference Guide...
  • Page 142: Find_String

    If the condition evaluates to true, another pass is made; otherwise the loop is terminated. FOR (<initial>; <condition>; <after pass>) (* for loop statements *) See the FOR loops section on page 18 for more information. NetLinx Programming Language Reference Guide...
  • Page 143: Format

    // Displays "The current temperature is 98.65" The table below shows some examples of the output of FORMAT for several dif- ferent format lines and values: FORMAT Statement Result of FORMAT function FORMAT('%-5.2f',123.234) '123.23' FORMAT('%5.2f',3.234) '3.23' FORMAT('%+4d',6) '+6' NetLinx Programming Language Reference Guide...
  • Page 144: Ftoa

    Result is a CHAR or WIDECHAR value depending on the variable type of Array. GET_BUFFER_STRING has a two-part operation: 1. Retrieve <length> number of characters from the buffer. 2. Remove the retrieved character from the buffer and shift the remaining characters up to fill the gap. NetLinx Programming Language Reference Guide...
  • Page 145: Get_Dns_List

    • -3: Busy The function requires a DNS_STRUCT. The DNS_STRUCT is predefined as fol- lows: STRUCTURE DNS_STRUCT CHAR DomainName[68] // domain suffix (e.g. amx.com) CHAR DNS1[15] // IP address of 1st DNS server CHAR DNS2[15] // IP address of 2nd DNS server...
  • Page 146: Get_Last

    Note: GET_LAST works with BUTTON_EVENTS and CHANNEL_EVENTS, but not with LEVEL_EVENTS. NetLinx Programming Language Reference Guide...
  • Page 147: Get_Multi_Buffer_String

    CHAR[6] GET_UNIQUE_ID ( ) The result is a 48-bit constant returned as a 6-element character array. SYSID = GET_UNIQUE_ID() // get the master's h/w ID IF(sysID = "$00,$01,$09,$73,$25,$01") // allow system to operate normally NetLinx Programming Language Reference Guide...
  • Page 148: Get_Url_List

    CONSTANT CHAR URL_Flg_Stat_Mask = $C0 // status mask CONSTANT CHAR URL_Flg_Stat_Lookup = $00 // Looking up CONSTANT CHAR URL_Flg_Stat_Connecting = $40 // connecting CONSTANT CHAR URL_Flg_Stat_Waiting = $80 // waiting CONSTANT CHAR URL_Flg_Stat_Connected = $C0 // connected NetLinx Programming Language Reference Guide...
  • Page 149: Hextoi

    Valid characters are "0" through "9", "A" through "F" and "a" through "f". If no valid characters are found, zero is returned as a result. Num = HEXTOI('126EC') // Num = 75500 NetLinx Programming Language Reference Guide...
  • Page 150: Hold

    Result: This function always returns 0. Errors are returned via the DATA_EVENT ONERROR method. The following error may be returned: 9: Already closed See the IP Communication section on page 189 or more information. NetLinx Programming Language Reference Guide...
  • Page 151: Ip_Client_Open

    7: Connection timed out 8: Unknown connection error 14: Local port already used 16: Too many open sockets 17: Local Port Not Open Example: IP_CLIENT_OPEN(PORT1, SvAddr, SvPort, IP_TCP) Seethe IP Communication section on page 189 for more information. NetLinx Programming Language Reference Guide...
  • Page 152: Ip_Mc_Server_Open

    Result: This function always returns 0. Errors are returned via the DATA_EVENT ONERROR method. The following error may be returned: 9: Already closed Example: IP_Server_Close(PORT1) See the IP Communication section on page 189 for more information. NetLinx Programming Language Reference Guide...
  • Page 153: Ip_Server_Open

    A character string that contains the hexadecimal representation of the speci- fied integer. STRING = ITOHEX(1000) // STRING = '3E8' The system variable LDATE returns the current date in (mm/dd/yyyy) string for- LDATE mat. IF (LDATE = '12/25/2000'){} NetLinx Programming Language Reference Guide...
  • Page 154: Left_String

    (* Len = 1, the number of rows in table 2 *) Len = LENGTH_ARRAY(My3Darray[1][3]) (* Len = 3, the number of columns in table 1, row 3 *) See SET_LENGTH_ARRAY, on page 150, for more information. NetLinx Programming Language Reference Guide...
  • Page 155: Length_String

    If neither the LOCAL_VAR nor the STACK_VAR keyword is specified, STACK_VAR is assumed. See the Variables section on page 11 for more information. This keyword defines an intrinsic data type representing a 32-bit unsigned LONG value. NetLinx Programming Language Reference Guide...
  • Page 156: Long_While

    The length of the specified dimension of Array. FLOAT FPArray[10] LONG NumArray[5][3][4] Len = MAX_LENGTH_ARRAY(FPArray) // Len = 10 Len = MAX_LENGTH_ARRAY(NumArray) // Len = 5 Len = MAX_LENGTH_ARRAY(NumArray[1]) // Len = 3 Len = MAX_LENGTH_ARRAY(NumArray[1][1]) // Len = 4 NetLinx Programming Language Reference Guide...
  • Page 157: Max_Length_String

    The minimum length of time is set by SET_PULSE_TIME. MIN_TO follows the same conditions of operation as the TO keyword. See SET_PULSE_TIME, on page 150, for more information. NetLinx Programming Language Reference Guide...
  • Page 158: Mod (%)

    This keyword suspends all WAITs currently in effect. PAUSE_ALL_WAIT This keyword suspends the specified (named) WAIT until a RESTART_WAIT, PAUSE_WAIT RESTART_ALL_WAIT, CANCEL_WAIT, or CANCEL_ALL_WAIT command is issued. PAUSE_WAIT '<wait name>' NetLinx Programming Language Reference Guide...
  • Page 159: Persistent

    This routine takes an intrinsic variable and converts it into a Character Array in RAW_BE Big Endian Format representing the variable. CHAR[] RAW_BE(IntrinsicVariable) This routine takes an intrinsic variable and converts it into a Character Array in RAW_LE Little Endian Format representing the variable. CHAR[] RAW_LBE(IntrinsicVariable) NetLinx Programming Language Reference Guide...
  • Page 160: Reboot

    (*----------------------------------------------------*) DEFINE_CONSTANT DEV panel[] = {dvApoc1,dvApoc2} (*----------------------------------------------------*) (* DEFINE TYPE DEFINITIONS GO BELOW *) (*----------------------------------------------------*) DEFINE_TYPE (*----------------------------------------------------*) (* VARIABLE DEFINITIONS GO BELOW *) (*----------------------------------------------------*) DEFINE_VARIABLE DEV curModApoc (*----------------------------------------------------*) (* EVENT DEFINITIONS GO BELOW *) (*----------------------------------------------------*) NetLinx Programming Language Reference Guide...
  • Page 161 INTEGER X // loop counter INTEGER nBTNS[4000] DEFINE_START FOR (X = 1; X <= 4000; X++) nBtns[X] = X // the braces below enclose a variable update and // rebuild_event statement in a single block NetLinx Programming Language Reference Guide...
  • Page 162: Redirect_String

    This system variable contains the number of the device associated with the RELEASE_DEVICE channel that was just turned off due to an input change. The value remains valid for one pass through mainline. The inactive state of this variable is all fields equal to zero. NetLinx Programming Language Reference Guide...
  • Page 163: Remove_String

    • Count: The number of character to copy from the end of the string. The return is a string containing a copy of the last Count characters from STRING. STRING = 'ABCDEFG' Substr = RIGHT_STRING(STRING, 3) // Substr = 'EFG' NetLinx Programming Language Reference Guide...
  • Page 164: Rshift

    When sending to an IP socket, you may receive the following error (via ONERROR event): 17 Local Port Not Open This error means you are trying to send a string to a local port on which IP_CLIENT_OPEN or IP_SERVER_OPEN has not been called. NetLinx Programming Language Reference Guide...
  • Page 165: Set_Dns_List

    The IP_ADDRESS_STRUCT is predefined as follows: STRUCTURE IP_ADDRESS_STRUCT CHAR Flags // Configuration flags CHAR HostName[128] // Host name CHAR IPAddress[15] // IP address unit CHAR SubnetMask[15] // subnet mask CHAR Gateway[15] // IP address of gateway NetLinx Programming Language Reference Guide...
  • Page 166: Set_Length_Array

    Celsius or Fahrenheit. SET_OUTDOOR_TEMPERATURE (32) // show 32 degrees This function sets the PULSE time in 1/10th second units. The default PULSE SET_PULSE_TIME time is 5 (0.5 seconds). SET_PULSE_TIME (TIME) NetLinx Programming Language Reference Guide...
  • Page 167: Set_System_Number

    • Count: The number of ports that the specified virtual device should maintain. SET_VIRTUAL_PORT_COUNT (dvVirtual,2) // 2 ports This keyword defines an intrinsic data type representing a 16-bit signed SINTEGER integer. This keyword defines an intrinsic data type representing a 32-bit signed SLONG integer. NetLinx Programming Language Reference Guide...
  • Page 168: Stack_Var

    • 0: Decoded OK • -1: Decode variable type mismatch • -2: Decode data too small, decoder ran out of data This keyword introduces the declaration of a STRUCTURE data type. STRUCTURE STRUCTURE <name> [<type>] <data1> [<type>] <data2> NetLinx Programming Language Reference Guide...
  • Page 169: Switch

    If successful, this function returns an integer (0-59) representing the minute portion of the time string. If the specified time is invalid, this function returns -1. CHAR TimeStr[ ] = '9:30:08' SINTEGER nMinute nMinute = TIME_TO_MINUTE (TimeStr) // nMinute = 30 NetLinx Programming Language Reference Guide...
  • Page 170: Time_To_Second

    (i.e. the time delay in between the triggered events). Absolute indicates that each time given is absolute with respect to the start of the timeline. • Repeat: Indicates whether the timeline should automatically start over again when Length events have been triggered. NetLinx Programming Language Reference Guide...
  • Page 171: Timeline_Event

    • Id: A user defined value that uniquely identifies this timeline. Each timeline must be assigned a unique identifier starting with number one. Result: • 0: Successful • 1: Specified timeline ID invalid TIMELINE_PAUSE(TL1) // momentarily suspend the timeline NetLinx Programming Language Reference Guide...
  • Page 172: Timeline_Reload

    • Timer: The new value for the timeline's internal timer. Result: • 0: Successful • 1: Specified timeline ID invalid • 2: Specified timer value out of range TIMELINE_SET (TL1,0) // start it over again NetLinx Programming Language Reference Guide...
  • Page 173: Total_Off

    SLONG UNCOMBINE_DEVICES VD Parameters: • VD: The virtual device passed to COMBINE_DEVICES. Result: • 0: Operation was successful. • -1: Invalid virtual device. Result = COMBINE_DEVICES VD, DEVSetResult = UNCOMBINE_DEVICES VD NetLinx Programming Language Reference Guide...
  • Page 174: Uncombine_Levels

    Position should be set to one on the first call. Result: 0: Encoded OK -1: Encoded variable unrecognized type -2: Encoded data would not fit into buffer; the buffer is too small. Result = VARIABLE_TO_STRING (MyStruct, Buffer, Pos) NetLinx Programming Language Reference Guide...
  • Page 175: Variable_To_Xml

    MyAlbumStruct[1].sArtist = ‘Buffet, Jimmy’ MyAlbumStruct[1].sTitle = ‘Living & Dying in ¾ Time’ MyAlbumStruct[2].lTtleID = 11101012 MyAlbumStruct[2].sArtist = ‘Sinatra, Frank’ MyAlbumStruct[2].sTitle = ‘Come Fly With Me’ MyAlbumStruct[3].lTtleID = 33101000 MyAlbumStruct[3].sArtist = ‘Holiday, Billie’ MyAlbumStruct[3].sTitle = ‘Lady in satin’ NetLinx Programming Language Reference Guide...
  • Page 176 BUTTON_EVENT[TP,2] // Read and Decode PUSH: // Read Binary File slFile = FILE_OPEN(‘BinaryEncode.xml’,1) slResult = FILE_READ(slFile, sBinaryString, MAX_LENGTH_STRING(sBinaryString) slResult = FILE_CLOSE (slFile) // Read XML File slFile = FILE_OPEN(‘XMLEncode.xml’,1) slResult = FILE_READ(slFile, sXMLString, MAX_LENGTH_STRING(sXMLString)) slResult = FILE_CLOSE (slFile) NetLinx Programming Language Reference Guide...
  • Page 177: Volatile

    Refer to the discussion on programming loop constructs under the Language Elements section on page 31 for more information. This keyword is an intrinsic data type representing a 16-bit unsigned integer. WIDECHAR This data type is intended for use with Unicode character strings. NetLinx Programming Language Reference Guide...
  • Page 178: Xml_To_Variable

    MyAlbumStruct[1].sTitle = ‘Living & Dying in ¾ Time’ MyAlbumStruct[2].lTtleID = 11101012 MyAlbumStruct[2].sArtist = ‘Sinatra, Frank’ MyAlbumStruct[2].sTitle = ‘Come Fly With Me’ MyAlbumStruct[3].lTtleID = 33101000 MyAlbumStruct[3].sArtist = ‘Holiday, Billie’ MyAlbumStruct[3].sTitle = ‘Lady in satin’ DEFINE_EVENT BUTTON_EVENT[TP,1] / /Convert And Save NetLinx Programming Language Reference Guide...
  • Page 179 = FILE_READ(slFile, sXMLString, MAX_LENGTH_STRING(sXMLString)) slResult = FILE_CLOSE (slFile) // Convert To Binary lPos = 1 slReturn = STRING_TO_VARIABLE(MyAlbumStruct, sBinaryString, slPos) // OR Convert To XML slPos = 1 slReturn = XML_TO_VARIABLE (MyAlbumStruct, sXMLString, slPos, 0) RELEASE: NetLinx Programming Language Reference Guide...
  • Page 180: Send_Commands

    WAIT 20 x++; IF (x > 4) x = 1; var[x] = x // This will not invoke the mutually exclusive magic In the NetLinx code example above, all elements of var will eventually be non-zero. NetLinx Programming Language Reference Guide...
  • Page 181 ON[dvRelay,x] // This works as expected: only 1 relay of relays 1 to 4 will be on at a time [dvRelay,x + 4] = x // This works as expected: only 1 relay of relays 5 to 8 will be on at a time NetLinx Programming Language Reference Guide...
  • Page 182 Reserved Identifiers NetLinx Programming Language Reference Guide...
  • Page 183: Compiler Messages

    Assigning the result of a function that returns a non-array type to a one- or two-dimensional array variable (for example, X = ATOI('AMX'), where X is a one- or two-dimensional array variable) This message is a warning and not an error, because X = ITOA(12) works correctly when X is a simple variable, since the result is a single value between Ø...
  • Page 184: (W) Variable Is Not Used

    In a range specification, the devices (or their defined identifiers) must be equal. For example, ([1,1]..[1,5] ) is valid; ([1,1]..[2,5] ) is not. Duplicate symbol Duplicate definitions of variables or constants are found. All variables and constants must have unique identifiers. NetLinx Programming Language Reference Guide...
  • Page 185: Evaluation Stack Overflow

    A PUSH or RELEASE statement was found within a block of code headed by a PUSH or RELEASE statement. Push/Release not allowed within Wait These keywords are not allowed in a section of code which will be executed due to a WAIT keyword. NetLinx Programming Language Reference Guide...
  • Page 186: Push_Channel Not Allowed Within Wait

    It is an intractable problem to check for misplacement of <any possible function name> and <any possible call name>, so TO outside of PUSH'es will not generate an error, just a warning. NetLinx Programming Language Reference Guide...
  • Page 187: Too Few Parameters In Call

    Central Controller, usually when it could not perform a particular operation in the program. Bad assign 2dim... These errors occur if an attempt is made to assign a two-dimensional array to a different type (such as a variable or one-dimensional array), and vice versa. NetLinx Programming Language Reference Guide...
  • Page 188: Bad Assign Call

    These errors occur if the SET_LENGTH_STRING keyword tries to set the length value of an array to a value greater than the array's storage capacity. Bad While This error occurs whenever a WHILE loop terminates due to the half-second timeout imposed on WHILE loops. NetLinx Programming Language Reference Guide...
  • Page 189: Netlinx Unicode Functions

    WIDECHAR[] WD_CONCAT_STRING(WIDECHAR STR1[], WIDECHAR STR2[]) Parameters: • STR1 - the first widechar string to be concatenated. • STR2 - the first widechar string to be concatenated. Result: A widechar string which concatenates STR1 and STR2 wcMyString = WC_CONCAT_STRING(wcString1,wcString2) NetLinx Programming Language Reference Guide...
  • Page 190: Wc_Decode

    WC_FORMAT_TP is defined as a value of 4 for specifying this format. • Stat: Position in STRING from which to start reading Result: Result is a CHAR array containing the encoded Unicode data. cData = WC_ENCODE(wcMyString, WC_FORMAT_UNICODE,1) NetLinx Programming Language Reference Guide...
  • Page 191: Wc_File_Close

    • -7: File already closed There is a limit to the number of file handles available from the system. If files are not closed, it may not be possible to open a file. Result = WC_FILE_CLOSE (hFile) NetLinx Programming Language Reference Guide...
  • Page 192: Wc_File_Open

    WC_FILE_CLOSE. If files are not closed, subsequent file open operations may fail due to the limited number of file handles avail- able. // Open MYFILE.TXT for readingINTEGER nFormatSLONG hFilehFile = WC_FILE_OPEN('MYFILE.TXT', FILE_READ_ONLY,nFormat) // nFormat will be set to detected file type NetLinx Programming Language Reference Guide...
  • Page 193: Wc_File_Read

    Buffer. If a complete line is read, the file pointer is advanced to the next char- acter in the file after the <CR> or <CR><LF> pair or to the EOF if the last line was read. WIDECHAR wcBuffer[80]nBytes = WC_FILE_READ_LINE (hFile, wcBuffer,80) NetLinx Programming Language Reference Guide...
  • Page 194: Wc_File_Write

    A 16-bit unsigned integer representing the character location of Seq in STRING. If the character string is found at the beginning of the string, this function returns 1; any error condition returns 0. POS = WC_FIND_STRING(STRING, _WC('ABC'), 1) NetLinx Programming Language Reference Guide...
  • Page 195: Wc_Get_Buffer_Char

    Result: The result is the length of STRING. The string length can be set implicitly through a literal or variable string assignment or explicitly by calling SET_LENGTH_STRING. For example: IF (WC_LENGTH_STRING(wcSTRING) > 0){// process string} NetLinx Programming Language Reference Guide...
  • Page 196: Wc_Lower_String

    Result: The result is a string containing the removed characters. If the character sequence was not found, an empty string is returned. wcSTRING = _WC('ABCDEF')wcSubstr = WC_REMOVE_STRING(wcSTRING, _WC('BC'), 1)// wcSubstr = 'ABC'// wcSTRING = 'DEF' NetLinx Programming Language Reference Guide...
  • Page 197: Wc_Right_String

    Unicode.org. WIDECHAR[ ] WC_UPPER_STRING (WIDECHAR wcSTRING[ ]) Parameters: • STRING: The widechar string to convert to upper case. Result: The result is the converted widechar string. wcUCString = WC_UPPER_STRING(wcSTRING) NetLinx Programming Language Reference Guide...
  • Page 198: Working With Unicode In Netlinx Studio V2.4

    Editor tab of the Preferences dialog 3. Under Display, check the Enable UTF-8 format checkbox. 4. Close the Preferences dialog. To enable Unicode Compiling in NetLinx Studio: 1. Choose Settings > Preferences from the menu bar NetLinx Programming Language Reference Guide...
  • Page 199: Including The Unicode Library

    To enter Unicode characters into your program, enclose the characters in single quotes, like you would any other string, and wrap the string literal in the Unicode macro _WC. Here is an example: _WC('Your string goes here') NetLinx Programming Language Reference Guide...
  • Page 200: Storing A Unicode String

    You will find that most other function work exactly as their CHAR counterpart do except they work on and return WIDECHAR arrays. The list of Unicode compatible functions is: WC_COMPARE_STRING WC_GET_BUFFER_CHAR WC_GET_BUFFER_STRING WC_LEFT_STRING WC_FIND_STRING WC_LENGTH_STRING WC_LOWER_STRING WC_MAX_LENGTH_STRING WC_MID_STRING WC_REMOVE_STRING WC_RIGHT_STRING WC_SET_LENGTH_STRING WC_UPPER_STRING NetLinx Programming Language Reference Guide...
  • Page 201: Character Case Mappings

    WC_CONCAT_STRING to combine the result with an existing WIDECHAR array. The following two syntaxes are functionality equivalent: fTemperature = 98.652 cMyString = FORMAT('The current temperature is %3.2f',fTemperature) fTemperature = 98.652 cTempString = FORMAT('%3.2f',fTemperature) wcMyString = _WC('The current temperature is ') wcMyString = WC_CONCAT_STRING(wcMyString,CH_TO_WC(cTempString)) NetLinx Programming Language Reference Guide...
  • Page 202: Right-To-Left Unicode Strings

    Right-to-Left Unicode languages are stored in memory the same way left-to-right language are. The first memory position of an array contains the first logical character. You can access the right-most character of a Right-to-Left Unicode string using this notation: wchChar = wcString[1] NetLinx Programming Language Reference Guide...
  • Page 203: Compiler Errors

    If you try to pass a WIDECHAR array to a function that expects a CHAR array, expect to see the following compiler error: On the line where the function call is made C10585: Dimension mismatch: [1] vs. [0] and Type mismatch in call for parameter [A] Parameter names might not match those listed above. NetLinx Programming Language Reference Guide...
  • Page 204 NetLinx UniCode Functions NetLinx Programming Language Reference Guide...
  • Page 205: Ip Communication

    A local port number may not be used in another call to until IP_CLIENT_OPEN is called for that port number. The syntax is shown below: IP_CLIENT_CLOSE IP_Client_Open(LocalPort, ServerAddress, ServerPort, Protocol) Parameters: NetLinx Programming Language Reference Guide...
  • Page 206: Terminating A Conversation

    Netlinx has an important behavior than can affect the performance of IP socket code. This is not a bug but a feature. If you are aware of it, you can write your code to take maximum advantage of the speed NetLinx offers. NetLinx Programming Language Reference Guide...
  • Page 207: Server Programming

    LocalPort: The local port number to open. This port number must be passed to to close the conversation. IP_CLIENT_CLOSE ServerPort: The port number on the server identifies the program or service the client is requesting. NetLinx Programming Language Reference Guide...
  • Page 208: Multiple Client Connections

    The server receives the following notifications when a client connects or disconnects. The protocol in this case must be TCP. DATA[0:LocalPort:0] ONLINE: // client has connected OFFLINE: // client has disconnected Parameters: Device is (or contains as part of an array) the device representing the conversation (0:LocalPort:0). NetLinx Programming Language Reference Guide...
  • Page 209: Receiving Data

    UDP message to 192.168.0.1 on UDP/IP port 6000, is: IP_CLIENT_OPEN(dvUDPClient,'192.168.0.1',6000, IP_UDP_2WAY) Now, if you were also writing the code for 192.168.0.1, you would need to have opened a UDP server using the following: IP_SERVER_OPEN(dvUDPServer,6000,IP_UDP) NetLinx Programming Language Reference Guide...
  • Page 210: Multicast

    (***********************************************************) CONSTANT DEFINITIONS GO BELOW (***********************************************************) DEFINE_CONSTANT nIPPort = 8000 (***********************************************************) VARIABLE DEFINITIONS GO BELOW (***********************************************************) DEFINE_VARIABLE IP_ADDRESS_STRUCT MyIPAddress (* .Flags (* .HostName (* .IPAddress (* .SubnetMask (* .Gateway (***********************************************************) STARTUP CODE GOES BELOW (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 211 ONERROR: SEND_STRING 0,"'error: server=',ITOA(Data.Number)" ONLINE: SEND_STRING 0,"'online: server'" OFFLINE: SEND_STRING 0,"'offline: server'" STRING: SEND_STRING 0,"'string: client=',Data.Text" IF (FIND_STRING(Data.Text,'ping',1)) SEND_STRING 0:2:0,"'pong',13" (* Client Data Handler *) DATA_EVENT[dvIPClient] ONERROR: SEND_STRING 0,"'error: client=',ITOA(Data.Number)" ONLINE: SEND_STRING 0,"'online: client'" OFFLINE: NetLinx Programming Language Reference Guide...
  • Page 212 STRING: SEND_STRING 0,"'string: client=',Data.Text" (***********************************************************) THE ACTUAL PROGRAM GOES BELOW (***********************************************************) DEFINE_PROGRAM (* Send Ping To Server *) WAIT 50 SEND_STRING dvIPClient,"'ping',13" (***********************************************************) END OF PROGRAM DO NOT PUT ANY CODE BELOW THIS COMMENT (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 213: Netlinx Modules

    DEVLEV MODULE_NAME='ModuleExample'(DEV dvDECK, DEVCHAN dcTRANPORTS[], INTEGER nFIRST) (*{{PS_SOURCE_INFO(PROGRAM STATS) (***********************************************************) ORPHAN_FILE_PLATFORM: 1 (***********************************************************) (*}}PS_SOURCE_INFO (***********************************************************) DEVICE NUMBER DEFINITIONS GO BELOW (***********************************************************) DEFINE_DEVICE (***********************************************************) CONSTANT DEFINITIONS GO BELOW (***********************************************************) DEFINE_CONSTANT NO_BUTTON NO_FUNCTION = 256 PLAY STOP NetLinx Programming Language Reference Guide...
  • Page 214 VARIABLE DEFINITIONS GO BELOW (***********************************************************) DEFINE_VARIABLE VOLATILE INTEGER nOFFSET_FN (* FUNCTION OFFSET *) VOLATILE INTEGER nOFFSET_FB (* FEEDBACK OFFSET *) VOLATILE INTEGER nFUNC (* FUNCTION THAT WAS PRESSED *) (***********************************************************) SUBROUTINE DEFINITIONS GO BELOW (***********************************************************) DEFINE_CALL 'ALL OFF' NetLinx Programming Language Reference Guide...
  • Page 215 (* SELECT OFFSETS IF ANY *) IF (nFIRST BAND $00FF) nOFFSET_FN=(nFIRST BAND $00FF)-PLAY ELSE nOFFSET_FN=0 IF (nFIRST BAND $FF00) nOFFSET_FB=((nFIRST BAND $FF00)/$FF)-PLAY_FB ELSE nOFFSET_FB=0 (***********************************************************) EVENT PROCESSING ROUTINES BELOW (***********************************************************) DEFINE_EVENT (***********************************************************) (* dcTRANPORTS - TRANSPORT CONTROLS (***********************************************************) BUTTON_EVENT[dcTRANPORTS] PUSH: NetLinx Programming Language Reference Guide...
  • Page 216 CASE PAUSE: SELECT ACTIVE ([dvDECK,nOFFSET_FB+PAUSE_FB] AND [dvDECK,nOFFSET_FB+REC_FB] AND dcTRANPORTS[8].CHANNEL<NO_FUNCTION): CANCEL_WAIT 'VCR1 REW TO STOP' CANCEL_WAIT 'VCR1 PAUSE TO STOP' CANCEL_WAIT 'VCR1 SREV TO STOP' CALL 'ALL OFF' MIN_TO [dvDECK,nOFFSET_FN+REC] CALL 'FEEDBACK' (REC) ACTIVE ([dvDECK,nOFFSET_FB+PAUSE_FB] AND dcTRANPORTS[1].CHANNEL<NO_FUNCTION): NetLinx Programming Language Reference Guide...
  • Page 217 CALL 'ALL OFF' MIN_TO [dvDECK,nOFFSET_FN+PAUSE] CALL 'FEEDBACK' (PAUSE) ON [dvDECK,nOFFSET_FB+REC_FB] CASE FFWD: SELECT ACTIVE ([dvDECK,nOFFSET_FB+STOP_FB] OR [dvDECK,nOFFSET_FB+FFWD_FB] OR [dvDECK,nOFFSET_FB+REW_FB] OR (dcTRANPORTS[6].CHANNEL AND ([dvDECK,nOFFSET_FB+PLAY_FB] OR [dvDECK,nOFFSET_FB+SREV_FB] OR [dvDECK,nOFFSET_FB+SFWD_FB]))): CANCEL_WAIT 'VCR1 REW TO STOP' CANCEL_WAIT 'VCR1 PAUSE TO STOP' NetLinx Programming Language Reference Guide...
  • Page 218 CANCEL_WAIT 'VCR1 REW TO STOP' CANCEL_WAIT 'VCR1 PAUSE TO STOP' CANCEL_WAIT 'VCR1 SREV TO STOP' CALL 'ALL OFF' MIN_TO [dvDECK,nOFFSET_FN+SFWD] CALL 'FEEDBACK' (SFWD) CASE REW: SELECT ACTIVE ([dvDECK,nOFFSET_FB+STOP_FB] OR [dvDECK,nOFFSET_FB+FFWD_FB] OR [dvDECK,nOFFSET_FB+REW_FB] OR (dcTRANPORTS[7].CHANNEL AND ([dvDECK,nOFFSET_FB+PLAY_FB] OR [dvDECK,nOFFSET_FB+SREV_FB] NetLinx Programming Language Reference Guide...
  • Page 219 OR [dvDECK,nOFFSET_FB+SFWD_FB]) CANCEL_WAIT 'VCR1 REW TO STOP' CANCEL_WAIT 'VCR1 PAUSE TO STOP' CANCEL_WAIT 'VCR1 SREV TO STOP' WAIT VCR1_SREV_TO_STOP 'VCR1 SREV TO STOP' SYSTEM_CALL 'FUNCTION' (dvDECK,STOP,nFIRST) CALL 'ALL OFF' MIN_TO [dvDECK,nOFFSET_FN+SREV] CALL 'FEEDBACK' (SREV) Continued NetLinx Programming Language Reference Guide...
  • Page 220: Using A Module In A Program

    (or module). In other words, the program will have one event table and one mainline routine consisting of code from the main program and all modules declared using the statement. DEFINE_MODULE NetLinx Programming Language Reference Guide...
  • Page 221 DEFINE_VARIABLE VOLATILE DEVCHAN dcTRANPORTS[] = { { dvTP,1 }, { dvTP,2 }, { dvTP,3 }, { dvTP,4 }, { dvTP,5 }, { dvTP,6 }, { dvTP,7 }, { dvTP,8 } VOLATILE INTEGER nVCR_FIRST = 0 NetLinx Programming Language Reference Guide...
  • Page 222 NetLinx Modules (***********************************************************) MODULE CODE GOES BELOW (***********************************************************) DEFINE_MODULE 'ModuleExample' mdlVCR(dvVCR,dcTRANPORTS,nVCR_FIRST) (***********************************************************) END OF PROGRAM DO NOT PUT ANY CODE BELOW THIS COMMENT (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 223: Internet Inside

    NetLinx master allows a web browser to retrieve web pages directly from the master. The web pages provide a user interface that mimics the look and feel of an AMX touch panel. In fact, TPDesign generates the web pages.
  • Page 224: Wdm Configuration

    The WDM listens on a single TCP port; every web user interface and WDM MUST have the same TCP port setting. If you manually change the TCP port configuration of one, you must change the TCP port configuration on all of them (WDM and all INDEX.HTM files). NetLinx Programming Language Reference Guide...
  • Page 225: Encoding And Decoding: Binary And Xml

    Below are some examples of how to use these encoding routines: PROGRAM_NAME='ConversionExample' (*{{PS_SOURCE_INFO(PROGRAM STATS) (***********************************************************) FILE CREATED ON: 05/22/2001 AT: 11:09:27 (***********************************************************) FILE_LAST_MODIFIED_ON: 05/22/2001 AT: 11:26:44 (***********************************************************) ORPHAN_FILE_PLATFORM: 1 (***********************************************************) (*!!FILE REVISION: REVISION DATE: 05/22/2001 COMMENTS: (***********************************************************) (*}}PS_SOURCE_INFO NetLinx Programming Language Reference Guide...
  • Page 226 DEFINE_TYPE STRUCTURE _AlbumStruct LONG lTitleID CHAR sArtist[100] CHAR sTitle[100] CHAR sCopyright[100] CHAR sLabel[100] CHAR sReleaseDate[100] INTEGER nNumTracks CHAR sCode[100] INTEGER nDiscNumber STRUCTURE _AlbumStruct2 CHAR sArtist[100] CHAR sTitle[100] INTEGER nNumTracks} (***********************************************************) VARIABLE DEFINITIONS GO BELOW (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 227 AlbumStruct[2].nDiscNumber = 105 AlbumStruct[3].lTitleID = 12328612 AlbumStruct[3].sArtist = 'Buffet, Jimmy' AlbumStruct[3].sTitle = 'A-1-A' AlbumStruct[3].sCopyright = 'MCA' AlbumStruct[3].sLabel = 'MCA' AlbumStruct[3].sReleaseDate = '1974' AlbumStruct[3].nNumTracks = 11 AlbumStruct[3].sCode = '3132333437' AlbumStruct[3].nDiscNumber = 189 (***********************************************************) THE EVENTS GO BELOW (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 228 IF (slReturn < 0) SEND_STRING 0,"'FILE WRITE FAIL RETURN=',ITOA(slReturn)" slReturn = FILE_CLOSE(slFile) IF (slReturn < 0) SEND_STRING 0,"'FILE CLOSE FAIL RETURN=',ITOA(slReturn)" (* Clear string *) sBinaryString = "" sXMLString = "" (* READ AND DECODE *) BUTTON_EVENT[dvTP,2] NetLinx Programming Language Reference Guide...
  • Page 229 (* THE XML WILL NOT FAIL SINCE IT DOES NOT REQUIRE DATA TO BE THE SEQUENTIAL *) BUTTON_EVENT[dvTP,3] PUSH: (* NOW WE CAN SAVE THESE BOTH TO DISCS *) slFile = FILE_OPEN('BinaryEncode.xml',nFileRead) IF (slFile > 0) NetLinx Programming Language Reference Guide...
  • Page 230 (* CONVERT TO XML *) lPos = 1 slReturn = XML_TO_VARIABLE (AlbumStruct2,sXMLString,lPos,0) SEND_STRING 0,"'POSITION=',ITOA(lPos),'; RETURN=',ITOA(slReturn)" (***********************************************************) THE ACTUAL PROGRAM GOES BELOW (***********************************************************) DEFINE_PROGRAM (***********************************************************) END OF PROGRAM DO NOT PUT ANY CODE BELOW THIS COMMENT (***********************************************************) NetLinx Programming Language Reference Guide...
  • Page 231: Appendix A: Marshalling Protocol

    <DWORD LSB> QWORD 8-byte value (could be an unsigned Quad-word or a double). 0xE4 <QWORD MSB> <QWORD LSB> BYTESTR Sequence of BYTE's whose element count is <= 64K. 0xE5 Length Hi Length Lo <BYTE Sequence> NetLinx Programming Language Reference Guide...
  • Page 232 Length LSB <Array Element 1> SKIP Byte indicator for space to be skipped in the input and 0xED NULL'ed in the marshalled output. This can be viewed as a NULL data type prefix. NetLinx Programming Language Reference Guide...
  • Page 233: Marshalling Protocol (Variables)

    4-byte IEEE 754 float value. If var is an element of an <var> array, name is replaced with <index></index>. The <name>MyName</name> index value, and the type are optional. Typically, only <type>float.IEEE.754.32</type> <var><data>Data</data></var> is needed. <data>1.23</data> </var> NetLinx Programming Language Reference Guide...
  • Page 234 ... or... <array> <name><MyName></name> <type>Type</type> <curLength>100</curLength> <array> <index>1</index>… </array> </array> Array - Array of unsigned characters. Data is encoded using <array> String String encoding. Type and length are optional. <name><MyName></name> encoding <type>Type</type> (Strings) <curLength>100</curLength> <string>MyString</string> </array> NetLinx Programming Language Reference Guide...
  • Page 235: Encoding Notes

    The HEX letters may appear as upper or lower case and are by default upper case. Any example of a 2-byte (signed or unsigned) array containing the value 1,2,3,4,1,12,13,14 NetLinx Programming Language Reference Guide...
  • Page 236 <encoded> <style>BE</ style > <size>2</size> <data>010203040B0C0D0E</data> </encoded> This is the default type of encoding for non- CHAR arrays but can be used to encode/decode char arrays as well. The data section must contain BytesSize*Elements nibbles. NetLinx Programming Language Reference Guide...
  • Page 237: Binary Encoding Result

    $4F $66 $66 $20 $74 $6F $20 $53 $65 $65 $20 $74 $68 $65 $20 $4C $69 Data: 'Off to See the Lizard' $7A $61 $72 $64 Start of CHAR Array (String) $00 $03 Length of Array: 3 $4D $43 $41 Data: 'MCA' Start of CHAR Array (String) NetLinx Programming Language Reference Guide...
  • Page 238 Data: 11 Start of CHAR Array (String) $00 $0A Length of Array: 10 $33 $31 $33 $32 $33 $33 $33 $34 $33 $37 Data: '3132333437' WORD: INTEGER or SINTEGER $00 $BD Data: 189 End of Structure NetLinx Programming Language Reference Guide...
  • Page 239: Xml Encoding Result

    <array> <name>STITLE</name> <curLength>26</curLength> <string>Living &amp; Dying in 3/4 Time</string> </array> <array> <name>SCOPYRIGHT</name> <curLength>3</curLength> <string>MCA</string> </array> <array> <name>SLABEL</name> <curLength>3</curLength> <string>MCA</string> </array> <array> <name>SRELEASEDATE</name> <curLength>4</curLength> <string>1974</string> </array> <var> <name>NNUMTRACKS</name> <data>11</data> </var> <array> <name>SCODE</name> <curLength>10</curLength> <string>3132333435</string> </array> <var> NetLinx Programming Language Reference Guide...
  • Page 240 Appendix A: Marshalling Protocol <name>NDISCNUMBER</name> <data>91</data> </var> </struct> <struct> <index>2</index> <var> <name>LTITLEID</name> <data>17248229</data> </var> ..<var> <name>NDISCNUMBER</name> <data>105</data> </var> </struct> <struct> <index>3</index> <var> <name>LTITLEID</name> <data>12328612</data> </var> <var> <name>NDISCNUMBER</name> <data>189</data> </var> </struct> </array> NetLinx Programming Language Reference Guide...
  • Page 241: Appendix B: Glossary

    Button Events, Channel events, Data Events, Level Events, and Timeline Events. Expression: Sub-component of a programming statement, such as the conditional portion of an IF statement or the right-hand side of an arithmetic assignment statement. NetLinx Programming Language Reference Guide...
  • Page 242 Data variables are stored in non- volatile memory by default. Wait list: A list containing unexpired WAIT statements. After each pass through mainline, the Central Controller scans this list to see if any have come due. NetLinx Programming Language Reference Guide...
  • Page 243 Appendix B: Glossary Wildcard character: In NetLinx, the question mark (?) can only be used in a COMPARE_STRING operation (unlike Axcess, which uses the question mark to compare dates and times). NetLinx Programming Language Reference Guide...
  • Page 244 Appendix B: Glossary NetLinx Programming Language Reference Guide...
  • Page 245 Appendix B: Glossary NetLinx Programming Language Reference Guide...
  • Page 246 It’s Your World - Take Control™ 3000 RESEARCH DRIVE, RICHARDSON, TX 75082 USA • 800.222.0193 • 469.624.8000 • 469-624-7153 fax • 800.932.6993 technical support • www.amx.com...

This manual is also suitable for:

Netlinx studio 2

Table of Contents