Programmer 1 & 2 PDF

Embed Size (px)

Citation preview

  • 7/22/2019 Programmer 1 & 2 PDF

    1/265

    January 2005

    Copyright

    AMX Corporation, 2005. All rights reserved. No part of this publication may be reproduced,

    transcribed, stored in a retrieval system or translated into any language in any form by any means

    without the written permission of AMX.

    Credits

    Written by AMX University.

    Printed in Dallas, Texas.

    For additional questions or suggestions, feel free to call us.

    AMX University

    3000 Research Drive

    Richardson, TX 75082

    Phone 469.624.8000

    Fax 469.624.7192

  • 7/22/2019 Programmer 1 & 2 PDF

    2/265

    Table of Contents

    iMX Programmer I & II

    Table of Contents

    Introduction .............................................................................................................................1

    Programmer I Course Objectives .........................................................................................1

    Programmer II Course Objectives ........................................................................................2

    Basics Of Control Review .......................................................................................................3

    AMX Product Review .............................................................................................................5

    Setting up a Project in NetLinx Studio .................................................................................7

    Review of User Interface ................................................................................................................. 7

    Preferences....................................................................................................................................... 8

    Device Addressing in NetLinx ............................................................................................. 15

    Device Addressing in NetLinx ...................................................................................................... 15

    DIP Switch..................................................................................................................................... 21

    Device:Port:System ....................................................................................................................... 24

    Configure and Address NetLinx System ............................................................................25

    Set the Communication Settings and Connect to the Master......................................................... 26

    Verify Devices Online ................................................................................................................... 29

    Set NetLinx Time and Date ........................................................................................................... 29

    Configure Network Settings .......................................................................................................... 30

    Programmer Software and Settings Checklist ...................................................................33

    Principles of Programming ..................................................................................................35

    Format of the Programming Language.......................................................................................... 35

    Operators........................................................................................................................................ 38

    Putting it Together ......................................................................................................................... 41

    Mainline in NetLinx....................................................................................................................... 43

    Object Oriented Programming and Events ........................................................................45

    Object Oriented Programming....................................................................................................... 45

    Event Handlers............................................................................................................................... 47

    DEFINE_EVENT.......................................................................................................................... 47

    BUTTON_EVENTs....................................................................................................................... 49

    CHANNEL_EVENTs.................................................................................................................... 51

    DATA_EVENTs............................................................................................................................ 53

    LEVEL_EVENTs.......................................................................................................................... 53

    TIMELINE_EVENTs.................................................................................................................... 53

    Channel Characteristics .......................................................................................................57

  • 7/22/2019 Programmer 1 & 2 PDF

    3/265

    ii AMX Programmer I & II

    Table of Contents

    Device-Channel Concept ............................................................................................................... 57

    Input Characteristics ...................................................................................................................... 58

    Output Characteristics.................................................................................................................... 59

    Feedback Statements...................................................................................................................... 60

    Mutually Exclusive Groups / Sets.................................................................................................. 62

    Software History & Debugging ...........................................................................................63

    Sofware History ............................................................................................................................. 63

    Debugging...................................................................................................................................... 64

    Tracking Down Errors ................................................................................................................... 65

    Resources For Debugging.............................................................................................................. 70

    Variables ................................................................................................................................77

    Data Types ..................................................................................................................................... 78

    Behavior Types .............................................................................................................................. 78

    Scope.............................................................................................................................................. 81Waits ......................................................................................................................................87

    Naming Waits ................................................................................................................................ 87

    Types of Waits ............................................................................................................................... 87

    Nesting Waits................................................................................................................................. 89

    Pausing and Restarting Waits ........................................................................................................ 89

    Canceling Waits ............................................................................................................................. 90

    Conditionals ...........................................................................................................................93

    IF Statement ................................................................................................................................... 93

    IF...ELSE Statement ...................................................................................................................... 94

    The SELECT...ACTIVE Statement ............................................................................................... 96

    SWITCHCASE.......................................................................................................................... 98

    System Calls .........................................................................................................................103

    Resource Documents ................................................................................................................... 104

    Advanced topics on SYSTEM_CALLS ...................................................................................... 104

    Instancing of SYSTEM_CALLS................................................................................................. 105

    Button Parameters........................................................................................................................ 107

    Time Outs..................................................................................................................................... 107

    FIRST Parameter ......................................................................................................................... 107

    Subroutines ..........................................................................................................................113

    Subroutines Defined..................................................................................................................... 113

    DEFINE_CALL........................................................................................................................... 114

    DEFINE_FUNCTION................................................................................................................. 115

    Modules ................................................................................................................................119

  • 7/22/2019 Programmer 1 & 2 PDF

    4/265

    Table of Contents

    iiiMX Programmer I & II

    Defining a Module....................................................................................................................... 120

    Using a Module in a Program...................................................................................................... 120

    Levels ....................................................................................................................................123

    Introduction to Levels.................................................................................................................. 123

    Creating Levels ............................................................................................................................ 126

    Using Levels ................................................................................................................................ 127

    Using Bargraphs .......................................................................................................................... 128

    DEFINE_CONNECT_LEVEL.................................................................................................... 128

    LEVEL_EVENTs........................................................................................................................ 129

    Strings & Buffers ................................................................................................................ 133

    SEND_COMMAND / SEND_STRING...................................................................................... 133

    Arrays........................................................................................................................................... 133

    Arrays as Strings.......................................................................................................................... 136

    String Literals .............................................................................................................................. 139String Expressions ....................................................................................................................... 140

    ASCII Codes ................................................................................................................................ 141

    ASCII Code Chart........................................................................................................................ 142

    DATA_EVENTs.......................................................................................................................... 145

    Buffers ......................................................................................................................................... 147

    Buffer Keywords.......................................................................................................................... 152

    Array & String Manipulation Keywords ..................................................................................... 153

    Loops ....................................................................................................................................157

    While Loops................................................................................................................................. 157

    FOR Loops................................................................................................................................... 158

    TPDesign4 & G4 Web Control .......................................................................................... 159

    Introduction to TPDesign4........................................................................................................... 159

    Connecting to a NetLinx Master.................................................................................................. 160

    Transferring Touch Panel Files to/from a NetLinx Master ......................................................... 161

    Virtual NetLinx Master TCP/IP Transfers................................................................................... 165

    Transferring Files Using a Virtual NetLinx Master TCP/IP Connection .................................... 167

    Virtual NetLinx Master USB Transfers....................................................................................... 167

    Transferring Files Using a Virtual NetLinx Master USB Connection ........................................ 168

    Transfer Status Window .............................................................................................................. 168

    Using G4 Web Control to Interact with a G4 Panel .................................................................... 169

    Multi-Dimensional Arrays, Structures, & Data Sets ....................................................... 173

    Multi-Dimensional Arrays........................................................................................................... 173

    Data Structures............................................................................................................................. 174

  • 7/22/2019 Programmer 1 & 2 PDF

    5/265

    iv AMX Programmer I & II

    Table of Contents

    Assigning Values to Multi-dimensional Arrays and Structures .................................................. 177

    Data Sets ...................................................................................................................................... 177

    Combining Devices .............................................................................................................181

    DEFINE_COMBINE in NetLinx ................................................................................................ 181

    Virtual Devices ............................................................................................................................ 181

    Combining and Uncombining Devices........................................................................................ 182

    Bitwise Operations ..............................................................................................................183

    TCP/IP Communication .....................................................................................................189

    IP Communication ....................................................................................................................... 189

    Server Programming .................................................................................................................... 190

    Client Programming..................................................................................................................... 193

    Timelines ..............................................................................................................................197

    Timeline Functions ...................................................................................................................... 197

    Timeline Keywords...................................................................................................................... 199

    TIMELINE_EVENTs .................................................................................................................. 204

    Master to Master .................................................................................................................207

    Master Routing............................................................................................................................. 208

    Design Considerations and Constraints ....................................................................................... 210

    Review Sheet - Basics of Control .......................................................................................213

    Review Sheet - Product .......................................................................................................215

    Review Sheet - Intro to Networking ..................................................................................217

    Review Sheet - Control Networks ......................................................................................219

    Appendix - Keywords .........................................................................................................221

    Appendix - Embedded Event Data Objects ...................................................................... 223

    Appendix - IR Functions .................................................................................................... 225

    Appendix: ASCII Code Chart ...........................................................................................227

    Appendix - NetLinx Security ............................................................................................. 229

    Appendix - NetLinx Ethernet Information ......................................................................255

    Appendix - Troubleshooting .............................................................................................. 259

  • 7/22/2019 Programmer 1 & 2 PDF

    6/265

    Introduction

    1MX Programmer I & II

    Introduction

    Welcome to AMX Programmer I and II. These courses, for programmers and technical support

    personnel, teach programming skills for AMX Control Systems. A programmer completing these

    courses will be able to program NetLinx Control Systems.

    This manual is designed to be both a tool to be used in the classroom and for reference on the job.

    White space is available on every page for taking notes. Good luck!

    Programmer I Course Objectives

    Upon completion of this course you will be able to:

    Utilize AMX resources to find programming requirements for AMX devices.

    Given a program that contains errors the student will debug and test the program until it

    runs correctly.

    Given a manufacturers protocol, students will implement control for such device using

    SEND_STRING & Buffer processing.

    Using AMX software, a student will create a new project, configure the AMX hardware,

    as well as program, compile, and test an AMX control system using:

    Input & output statements

    Direct feedback statements

    Object Oriented Programming

    BUTTON_EVENT

    CHANNEL_EVENT

    DATA_EVENT

    Variables

    Wait Statements

    Conditional Statements

    System calls

    Level statements

    LEVEL_EVENT

    Subroutines

    Modules

    Loop statements

    Skill level will be different from Programmer I and Programmer II.

  • 7/22/2019 Programmer 1 & 2 PDF

    7/265

    Programmer II Course Objectives

    2 AMX Programmer I & II

    Programmer II Course Objectives

    Upon Completion of this course you will be able to:

    Set up TCP/IP communication to an external TCP/IP device

    Use Master to Master to control devices on other masters

    Use AMX software and skills to configure AMX hardware, and program, compile, and

    test an AMX control system using:

    Object Oriented Programming

    BUTTON_EVENT

    CHANNEL_EVENT

    Conditional Statements

    Loop Statements

    Multi-Dimensional Arrays

    Data Structures & Sets

    String Handling Statements

    Buffers

    DATA_EVENT

    DEFINE_COMBINE

    COMBINE_DEVICES

    UNCOMBINE_DEVICES

    Timelines

    TIMELINE_EVENT

    Modules

  • 7/22/2019 Programmer 1 & 2 PDF

    8/265

    Basics Of Control Review

    3MX Programmer I & II

    Basics Of Control Review

    What are the goals of a Control System?

    What is a control link?

    What are some of the advantages and disadvantages of IR?

  • 7/22/2019 Programmer 1 & 2 PDF

    9/265

    Basics Of Control Review

    4 AMX Programmer I & II

    What are some of the advantages and disadvantages of Analog?

    What are some examples of analog control?

    Match each property to the appropriate serial control type: (some properties have more than

    one answer)

    RS-232 RS-422 RS-485

    ____uses a balanced signal to reduce interference

    ____maximum run length of 50 feet

    ____only multi-drop

    ____single-ended or multi-drop

    ____connects only one transmitter and receiver

    ____maximum run length of 4000 feet

  • 7/22/2019 Programmer 1 & 2 PDF

    10/265

    AMX Product Review

    5MX Programmer I & II

    AMX Product Review

    What are Master Processors? (Give examples)

    What are some of the different types of touch panels that AMX offers?

    What is the difference between a CardFrame and an Integrated Controller?

  • 7/22/2019 Programmer 1 & 2 PDF

    11/265

    AMX Product Review

    6 AMX Programmer I & II

    Match the software solution with its appropriate description:

    a) MeetingManager

    b) Picture Frame

    c) G4 Web Control

    d) G4 Computer Control

    ____ Allows you to transform your Modero Touch Panel into a dynamic digital photo album

    ____ Allows any Modero Touch Panel to remotely view and control any network attached

    computer

    ____ Allows you to schedule, animate, and monitor any room controlled by NetLinx

    ____ Allows a Modero Touch Panel to be remotely controlled by any computer on the control

    network

    What are the differences between a MAX MMS, AVM, and AOM?

  • 7/22/2019 Programmer 1 & 2 PDF

    12/265

    Setting up a Project in NetLinx Studio

    7MX Programmer I & II

    Setting up a Project in NetLinx Studio

    Lesson Topics

    Review of User Interface

    Preferences

    Review of User Interface

    FIG. 1 NetLinx Studio 2.2 Work Area

    Title Bar

    Menu Bar

    Toolbars

    Workspace

    Window

    Output

    Display

    Window

    Status Bar

    S

    C

    E

    W

  • 7/22/2019 Programmer 1 & 2 PDF

    13/265

    Setting up a Project in NetLinx Studio

    8 AMX Programmer I & II

    Preferences

    Select Settings > Preferencesto open the Preferences dialog, where you can set various

    application-level preferences. This dialog contains the following tabs:

    General tab- Contains options to set general program defaults

    Axcess Compiler Options tab- Contains options to set default prefefernces for theAxcess Compiler

    NetLinx Compiler Options tab- Contains options to set default prefefernces for the

    NetLinx Compiler

    Editor tab- Contains options to set default preferences for the Source Code Editor

    windows

    Diagnostics tab- Contains options to set default diagnostics preferences

    Terminal Options tab- Contains options to set default Terminal window preferences

    File Transfer tab- Contains options to set default preferences for file transfer operations

    Workspace tab- Contains options to set various display and file preferences relating to

    the Workspace Window

    Commands tab- Contains options to add/remove commands from the toolbars

    Toolbars tab- Contains options to add/delete/rename and reset the toolbars

    Tools tab- Contains optins to add a shortcut to another application in the Tools menu

    Keyboard tab- Contains options to set custom keyboard accelerators (shortcut keys/ key

    combinations) often-used commands

    Menu tab- Contains options to customize the menus and reset the menus to their original

    default state. Options tab- Contains options to set a few basic toolbar options

    We will go over a few of these tabs on the next few pages:

  • 7/22/2019 Programmer 1 & 2 PDF

    14/265

    Setting up a Project in NetLinx Studio

    9MX Programmer I & II

    Setting General Program Preferences (General Tab)

    Use the options on the Generaltab of the Preferences dialog to set general program defaults:

    Window Color Display Options- Allows you to define the Forground and Background

    Color in each window.

    Software History Application- This File Location field allows you to specify whether

    or not to close Sofware History when NetLinx Studio exits.

    Recent File List Size- This field allows you to change the size of the recent file list,

    displayed at the bottom of the File menu (range = 1-9),

  • 7/22/2019 Programmer 1 & 2 PDF

    15/265

    Setting up a Project in NetLinx Studio

    10 AMX Programmer I & II

    Setting NetLinx Compiler Preferences (NetLinx Compiler Tab)

    Use the options in the NetLinx Compiler tab of the Preferences dialog to set default preferences

    for the NetLinx compiler. The items in this tab include:

    Directories Click to open the directories menu, where you select the directories to

    point the compiler to, by file type. Once a directory type is selected, the directory list is

    populated with the directories of that type that have been mapped. There are a maximum

    of 100 directories that can be entered for each type.

    Select Include Filesto select or create the directory that the compiler will look forInclude files in.

    Select Library Filesto select or create the directory that the compiler will look for

    System Call files in.

    Compile With Debug Info Select this option to include variable symbol information in

    the compiled file. This allows the debugger to identify and validate variable symbols in

    the code. You must compile with debug info in order to debug NetLinx files.

    Build With Source Check to include the executable code and the source code to the

    Master Controller or data device when the file is sent (memory permitting). This allows

    the Receive option to retrieve the source code from the Master Controller. IfBuild with

    Sourceis disabled, only the executable code is sent, which cannot be retrieved from the

    Master Controller.

    When building with source, only the files needed for the compilation process are compressed.

    Though the APW may contain many files, if the source file only uses one AXI file, then only 2

    files will be compressed.

  • 7/22/2019 Programmer 1 & 2 PDF

    16/265

    Setting up a Project in NetLinx Studio

    11MX Programmer I & II

    Build With Password Protection Select this option to apply a password to the Source

    file. Select the Changebutton to edit the password (via the Change Password dialog). A

    password must be at least 6 characters in length (maximum of 20 characters).

    Setting Editor Preferences (Editor Options Tab)

    Use the options on the Editor Optionstab of the Preferences dialog to set default preferences for

    the Source Code Editor windows. The items in this tab include:

    Syntax Highlighting- These options allow you to customize syntax highlighting within

    the Source Code Editor windows.

    Document Type - Select the type of document that you want to set highlighting

    options for (Text Files or Source Code Files).

    Selections - This is a list of all the items that can be customized in the Source Code

    Editor Windows. The items that appear in this list depend on the Document Type

    selection.

    Background Color- This is the background color setting for the selected Item.

    Apply to All - Use this option to apply the selected background color to all items in theSelections list.

    Text Color - This is the text color setting for the selected Item. Click the down arrow

    to select a different color from a palette.

    Bold/Italic- Use these checkboxes to specify the text style setting for the selected

    Item.

  • 7/22/2019 Programmer 1 & 2 PDF

    17/265

    Setting up a Project in NetLinx Studio

    12 AMX Programmer I & II

    Display options These checkboxes offer more display-oriented options for the Source

    Code Editor window:

    Show Line Numbers - This option displays line numbers along the left-hand edge of

    the Source Code Editor window (default = enabled).

    Enable Code Folding - This option allows you to "fold-up" each section of code in

    the Source Code Editor (default = enabled).

    Enable AutoComplete/AutoSuggest- With this option enabled, the application

    examines the first few characters in a variable name, device name or a reserved

    identifier, and automatically finishes typing it for you (default = enabled).

    Auto-indent- This option automatically indents your text as you type (default =

    disabled).

    Enable Indentation Guides- This option causes the program to draw vertical lines

    indicating the tab stops in the Source Code Editor window (default = enabled).

    Tabs and Indentation Preferences - This set of options allows you to specify the

    following indentation preferences:

    Set tab stops every X characters - Use this option to specify the size (in number of

    characters) of the tab stops in the Source Code Editor window (default = 4).

    Enable Auto-Indentation - This option causes the program to automatically indent

    lines that occur after an indented line.

    Clear Text Buffer History- Clears all the clipboard text items from the list.

    Font - The Selection button opens the Font dialog, where you can select the font, font

    style (regular, italic, bold) and font size to be displayed in the Source Code Editor

    window.

    Clipboard Text Buffer- These options allow you to define the number of clip-board

    buffer entries and the maximum width to display.

    Max Items- You can have a maximum of 30 clip-board buffer items (default = 20).

    Max Display Width- You can set the maximum display width to up to 80 characters

    (default = 50).

  • 7/22/2019 Programmer 1 & 2 PDF

    18/265

    Setting up a Project in NetLinx Studio

    13MX Programmer I & II

    Setting Workspace Preferences (Workspace Tab)

    Use the options on the Workspacetab of the Preferences dialog to set various display and file

    preferences relating to the Workspace Window. The items on this tab include:

    Display Options:

    Restore Workspace On Startup- This option (on by default) automatically restores

    the workspace file upon startup of the application. With this option enabled, all files

    that were opened and the dockable windows that were displayed when you closed the

    application will be restored when you restart the program.

    Display System Configuration Setting in the Identifier- This option (off by default)

    displays the System Configuration settings as part of the System identifier (as

    displayed in the Workspace tab of the Workspace Window).

    Saving:

    Enable Auto Save- Toggles the timed auto-saving of text files and the duration of

    time between auto saves.

    Auto Save Every Minutes- This field is only enabled when the Enable Auto

    Save option is selected. The range is 1-120 minutes, the default setting is 5.

    Automatically Save Before Compile- Toggles auto-saving of code files before a

    compile.

    Automatically Stamp File with Creation and Last Modified Date-This option

    automatically stamps all Workspace files with Creation and Last Modified dates when

    the file is closed (default = enabled).

  • 7/22/2019 Programmer 1 & 2 PDF

    19/265

    Setting up a Project in NetLinx Studio

    14 AMX Programmer I & II

    Editor Window tabs- These options allow you to toggle the Source Code Editor

    Window tabs ( ), and set their style and location.

    Enable Window Tabs- This option toggles the display of the window tabs that appear

    by default along the lower edge of the Source Code Editor windows area of the GUI.

    These tabs provide easy access for each open Source Code Editor window. If this

    option is not selected, the following tab-oriented options are disabled.

    Enable File Icons In Tabs- This option toggles the file icons displayed in the Source

    Code Editor window tabs.

    Enable Window Close Button- This option toggles the Window Close button ( ).

    When Closing the Workspace- This section contains options for closing files

    associated with a Workspace that is being closed. The options are:

    Close Associated Files Without Prompting

    Always Prompt Before Closing Associated Files

    Do Not Prompt or Close Associated Files

    When Removing a File From the Workspace- This section contains various options

    for closing files when they are removed from the current Workspace. The options are:]

    Close File Without Prompting

    Always Prompt Before Closing Files

    Do Not Prompt or Close File

  • 7/22/2019 Programmer 1 & 2 PDF

    20/265

    Device Addressing in NetLinx

    15MX Programmer I & II

    Device Addressing in NetLinx

    Lesson Topics

    Device Addressing in NetLinx

    Device:Port:System

    DIP Switch

    Programmer Software and Settings Checklist

    Device Addressing in NetLinx

    The NetLinx control system communicates to other NetLinx, Axcess and Landmark control

    devices using the control networks of ICSNet, ICSHub and AXlink. A device address is assigned toeach control device so the NetLinx Master can know where to send messages, or so that the Master

    knows who is sending the message. Each message sent on these networks contains the destination

    address as well as the address of the device sending the message.

    Device numbering should remain standard. Recommendations are::

    Device: Types: Comments:

    0 Master

    1-255 Axcess Devices Use Axcess standards

    301-3072 NetLinx CardFrames Start at frame number 25 - (frame# * 12) + 1

    5001-5999 ICSNet NetLinx Devices NXI, NI Series, NXM-COM2, NXM-IRS4, etc.

    6001-6999 ICSNet Landmark Devices PLH-VS8, PLH-AS16, PLB-AS16

    7001-7999 Inconcert Devices

    8001-8999 PCLink Devices PCLink Devices are PC Programs

    10001-32000 ICSNet Panels DMS, Modero, & TPI4

    32001-32767 Dynamic Devices Actual range used by NetLinx master

    32768-36863 Virtual Devices Actual range used by NetLinx master

    Device numbers 1-255 are reserved for Axcess devices. NetLinx devices can be numbered

    between 256-32,000.

  • 7/22/2019 Programmer 1 & 2 PDF

    21/265

    Device Addressing in NetLinx

    16 AMX Programmer I & II

    Setting the Address

    The device address is set in a different manner depending upon which NetLinx device is used.

    When NetLinx devices are shipped from AMX the device address is set to use a dynamic address

    (an address between 32001 and 32767). A device receives a dynamic address when it is connected

    to a Master Processor and is powered up for the first time. This address may change each time the

    device is powered. The reason for this dynamic addressing is so no two devices connected to thesame master will have the same address. Since the dynamic address can change each time the

    system is reset these dynamic addresses should only be considered temporary addresses until a

    fixed address can be assigned.

    NetLinx Integrated Controller Addressing

    The device address of the NetLinx Integrated Controller is set using NetLinx Studio. If the NXI

    enclosure does not contain a master processor it must be connected to a master processor using

    ICSHub.

    FIG. 1 Device Addressing Dialog under the Diagnostics Menu

  • 7/22/2019 Programmer 1 & 2 PDF

    22/265

    Device Addressing in NetLinx

    17MX Programmer I & II

    There are two ways to address the NXI. First if you are certain which dynamic address has been

    assigned to the NXI you can enter that address in the Device/System Change of Address Options

    section of the dialog box. Or, if you are not sure of the dynamic address the NXI can be addressed

    using the ID Mode section. To determine that address that has been dynamically assigned you can

    look at the Online tab in the Workspace Window. (To show the Workspace Window, select

    Workspace from the View menu on the menu bar.)

    In this example the NXI has been assigned device address 32002 on System 1. This information

    should be entered in the Device to Change area of the Change Address section of the Device

    Addressing tab (See FIG. 1.) Check the boxes to indicate if you want to change the device address

    or the system ID or both. Then enter the device address and system number you want to assign to

    that device. For example if we want to change this NXI to device 5001 on System 1, we would

    check the Change Device box and enter 5001 in the adjacent field.

    This works well if there is only one NXI in the system, but what if there are several? In this case it

    may be difficult to determine which NXI is connected to which controlled devices. To make that

    easier AMX developed the ID Mode for device addressing. ID Mode sets the ICSNet devices to a

    special mode where an ICSP indicator on each device quickly flashes to indicate that it is now in ID

    mode. To address a device using the ID Mode, in the section labeled ID Mode enter the system ID

    of the system the NXI is connected to, then enter the desired Device number and System ID that

    you wish to assign to the NXI then press Start Identify Mode. A green indicator note under the

    Cancel Identify Mode button will light up, the ICSP LED on the rear of each NXI will be quickly

    flashing and the system is waiting for the device to be identified (See FIG. 3). At this time press the

    white ID button on the left rear of the NXI.

    FIG. 2 Online Tree under the Workspace area

    NXI Device Address

    System ID

  • 7/22/2019 Programmer 1 & 2 PDF

    23/265

    Device Addressing in NetLinx

    18 AMX Programmer I & II

    That will bring up a Successful Identification Made message (FIG. 4) indicating that the NXI

    address has been set. Continue this process for the remaining NXIs in the system until all have been

    given a fixed device address.

    FIG. 3 Device Addressing Dialog after the Start Identify button is pressed.

    FIG. 4 Device Addressing Dialog after Successful Identification has been Made

  • 7/22/2019 Programmer 1 & 2 PDF

    24/265

    Device Addressing in NetLinx

    19MX Programmer I & II

    NetLinx Control NetModules Addressing

    The NetLinx Control NetModules are assigned device addresses in the same way as the NetLinx

    Integrated Controller.As the example indicates the Relay device would be easy to find and address

    since it is the only one in the system, but addressing the IR and RS232 devices would be more

    difficult. For the Relay device we can use either of the two methods discussed in regard to the NXI,

    but with the IR and RS232 devices it would be easier to use the ID Mode method. The onlydifference is that the NetModules do not have an ICSP LED on the rear of the unit that flashes

    quickly to indicate ID Mode.

    NetLinx CardFrame Addressing

    Addressing the cards in the NetLinx CardFrame is different than addressing the Integrated

    Controller. On the rear of the CardFrame is an eight position DIP switch that is used to assign a

    number for that CardFrame. Each position of the DIP switch relates to a position of a binary eightbit word. If the switch is on that binary position has a value of 1, if it is off that binary position has

    a value of 0. Valid decimal values for the CardFrame number are 0-255.

    FIG. 5 NetLinx Studio Online Tree

    FIG. 6 NetLinx CardFrame/ DIP Switch

    Rear/ right view

    CardFrame Number DIP Switch

  • 7/22/2019 Programmer 1 & 2 PDF

    25/265

    Device Addressing in NetLinx

    20 AMX Programmer I & II

    Set the CardFrame Number to Assign Device Addresses to a CardFrame (NXF)

    1. Disconnect power from the CardFrame.

    2. Determine desired address range for devices in the CardFrame. AMX recommends CardFrame

    device addresses begin at 301.

    3. Turn on the appropriate switches on the CardFrame DIP Switch to set the CardFrame number.

    To use our recommended device address set the CardFrame number to 25. (Switch one on,

    switch four on, switch five on, and all others off.)

    4. Re-power the CardFrame.

    5. Insert control cards in the desired slots. Cards will be assigned an address as CardFrame

    number *12 + slot number.

    A little bit of math is required to determine the starting address. The DIP switch assigns a

    CardFrame number which is then multiplied by 12 and that result is added to the card slot number

    to get the address for that card.

    (DIP switch address x 12) + Card Slot Number (1-12) = Device Address

    For example if we have a card in slot 3 and the CardFrame number is 32 (switch 6 is on, all the

    others are off) the device address for the card is:

    (32 x 12) + 3 = 387

    The address assigned to the card in the CardFrame overrides the address stored in memory of the

    Control Card. If the Control Card in the CardFrame is removed and placed in a NetModule Shell it

    does not retain the address from the CardFrame, but reverts to the last address it received when it

    was in a NetModule, or to a dynamic address as set at the factory if a fixed address was not yet

    assigned.

  • 7/22/2019 Programmer 1 & 2 PDF

    26/265

    Device Addressing in NetLinx

    21MX Programmer I & II

    DIP Switch

    There are two kinds of configurations for an AMX Control System, hardware and software. For the

    hardware configuration a DIP switch is used. DIP stands for Dual Inline Package and is a group of

    switches mounted to the module device that plugs into a PC board. The following are all configured

    with a DIP switch:

    NetLinx Master Card (hidden behind the front panel)

    NetLinx CardFrame

    NI4000

    NXF-MINI

    DIP Switch2 is a 32-bit Windows program that graphically shows the DIP switch settings. The

    ON (down) and OFF (up) positions on the DIP switches are dynamically set when you enter device

    numbers and choose communication port options. You can also use the DIP switches to check a

    device number and/or communication setting. Set the program's DIP switches by clicking inside

    the ONor OFFswitch area so the DIP switches match the settings on the device or communication

    port or by entering a number in the CardFrame Number.

    FIG. 7 DIP Switch 2.0

  • 7/22/2019 Programmer 1 & 2 PDF

    27/265

    Device Addressing in NetLinx

    22 AMX Programmer I & II

    Configuring the DIP Switch for the NetLinx Master

    You can use the Program Port DIPSwitchto set the Master Card to Program Run Disable

    (PRD) mode according to the settings listed in the table.

    PRDmode prevents the NetLinx program stored in the Master Card, from running when you power

    up the Master Card. PRDmode should only be used when you suspect the resident NetLinx

    program is causing inadvertent communication and/or control problems. If necessary, place the

    Master Card in PRDmode and use the NetLinx Studio program to resolve the communication and/

    or control problems with the resident NetLinx program. Then, download the new NetLinx program

    and try again.

    Setting the Program Port DIP Switch

    1. Disconnect the power supply from the 2-pin PWR (green) connector on the Master Card.

    2. Remove the front faceplate and mounting screws (four) from the Master Card's front panel.

    Then, locate the Program Port DIP Switch (to the left of the Program port).

    3. Set DIP switch positions according to the information listed in the Baud Rate Settings and

    PRD Mode Settings table Card Frame above.

    4. Replace the front panel and faceplate back onto the Master Card and reconnect the 12 VDC

    power supply to the 2-pin PWR connector.

    Program Port DIP Switch - baud rate settings

    The Program Port DIP Switchis located at the front of the Master Cards. For Modules, you mustremove the front panel to access theDIP Switch. Use this DIP Switchto set the baud rate for the

    Program Port, according to the settings shown in the following table. Make sure the baud rate you

    set matches the baud rate on your PC's COM port beforeprogramming the Master Card. By

    default, the baud rate is set to 38,400 (bps). Note the orientation of the DIP Switch and the ON

    position label.

    PRD Mode Settings

    PRD Mode Position 1 Position 2Normal mode (default) OFF OFF

    PRD Mode ON OFF

    Baud Rate Settings

    Baud Rate Position 5 Position 6 Position 7 Position 8

    9600 bps OFF ON OFF ON

    38,400 bps (default) OFF ON ON ON

    57,600 bps ON OFF OFF OFF

    115,200 bps ON ON ON ON

    DIP Switch positions 3 and 4 are reserved for future features and should always be set to the

    Off (down) position.

  • 7/22/2019 Programmer 1 & 2 PDF

    28/265

    Device Addressing in NetLinx

    23MX Programmer I & II

    System ID Numbering

    Since more than 65,000 NetLinx masters can be connected together a method to identify those

    masters is needed. Each master is assigned a system number, much in the same way as the device

    number is assigned, in fact it is done from the device addressing tab of the NetLinx Diagnostics

    dialog. The Master in a NetLinx system is defined as device number 0. (Remember this, it will be

    important later.) By default the NetLinx Master Cards are shipped from AMX set to System IDnumber 1. To change the System ID of a NetLinx master instead of changing the Device ID, we

    simply change the System ID. Open the Device Addressing dialog from the Diagnostics menu.

    In the Change Address section enter 0 for the device ID and the System ID of the master you want

    to change. (The system ID is shown in the top of the Online tab of the Project Navigator.) Check the

    Change System box and enter the new System ID in the adjacent field.

    The easiest way is to disconnect the power from the master, but it can also be done from the

    Networking tab of the Diagnostics dialog and entering 0 for both the System ID and Device ID.

    Placing zeros in both fields will reboot the master that is currently connected to NetLinx Studio

    FIG. 8 Device Addressing Dialog Box under the Diagnostics Menu

  • 7/22/2019 Programmer 1 & 2 PDF

    29/265

    Device Addressing in NetLinx

    24 AMX Programmer I & II

    Device:Port:System

    In the NetLinx system a device can have multiple ports, therefore each port must be addressed.

    Additionally, since up to 65,535 NetLinx systems can be connected together, each device receives

    the system ID of the connected master. This addressing scheme is referred to as the

    Device:Port:System triplet.

    All devices in a NetLinx system are given D:P:S addresses. Since the idea of ports is new to the

    NetLinx system, all Axcess and Landmark devices have only one port. For example, you have an

    Axcess touch panel connected to a NetLinx system whose system ID is 1, it would be referred to as

    address 128:1:1 .It is this addressing scheme that will allow a single NetLinx Master to control

    more than 400,000 RS232 or IR controlled devices.

    (32000 NXIs, x (6 RS232/422/485 ports + 8 IR/S ports) = 448,000 control ports)

    D:P:S = 10001:1:0

    When assigning an address to a device you can use a "0" for the system number. A system

    number of "0" refers to the current system. When working in master to master mode you will

    need to specify the actual number.

  • 7/22/2019 Programmer 1 & 2 PDF

    30/265

    Configure and Address NetLinx System

    25MX Programmer I & II

    Configure and Address NetLinx System

    Lesson Topics

    Set the Communication Settings and Connect to the Master

    Verify Devices Online

    Set NetLinx Time and Date

    Configure Network Settings

    Set the System ID and Reboot the Master

    Connect via the Network

    Configuring a NetLinx Master

    When setting up a NetLinx system the Master card must be configured properly before anything

    can be done.

    Set the Communications Settings

    Set Networking Information

    Verify devices online

    Set System Time and Date

    Configure Network Settings

    Set the Device Addresses and System ID

  • 7/22/2019 Programmer 1 & 2 PDF

    31/265

    Configure and Address NetLinx System

    26 AMX Programmer I & II

    Set the Communication Settings and Connect to the Master

    To connect to a NetLinx master, use the options in the Master Communication Settings and

    Communication Settings dialogs to specify the TCP/IP address, serial port or modem settings,

    depending on the transport connection type specified. These instructions in these topics assume that

    the physical link between the PC running NetLinx Studio and the NetLinx master is established.

    Connecting to a NetLinx Master via TCP/IP

    To connect to a NetLinx master, use the options in the Master Communication Settings and

    Communication Settings dialogs to specify the TCP/IP address, serial port or modem settings,

    depending on the transport connection type specified. These instructions in these topics assume that

    the physical link between the PC running NetLinx Studio and the NetLinx master is established.

    1. Select Settings > Master Communication Settingsto open the Master Communication

    Settings dialog.

    2. Click Communication Settings...to access the Communication Settings dialog.

    3. Select NetLinx Master as thePlatform Selection.

    4. Select TCP/IPas the Transport Connection Option.5. Click Settingsto open the TCP/IP Settings dialog.

  • 7/22/2019 Programmer 1 & 2 PDF

    32/265

    Configure and Address NetLinx System

    27MX Programmer I & II

    6. Enter the TCP/IP Addressof the master.

    7. Click OKto return to the Communication Settings dialog.

    8. Click OKto return to the Master Communication Settings dialog.

    9. Click OKto close the Master Communications dialog.

    Connecting to a NetLinx Master via Serial Port

    To connect to a NetLinx master, use the options in the Master Communication Settings andCommunication Settings dialogs to specify the TCP/IP address, serial port or modem settings,

    depending on the transport connection type specified. These instructions in these topics assume that

    the physical link between the PC running NetLinx Studio and the NetLinx master is established.

    1. Select Settings > Master Communication Settingsto open the Master Communication

    Settings dialog.

    2. Click Communication Settings...to access the Communication Settings dialog.

    3. Select NetLinx Masteras thePlatform Selection.

    4. Select Serialas the Transport Connection Option.

    5. Click Settingsto open the Serial Port Settings dialog.

    The Port should always be set to 1319(default setting). Do not change the Port assignment.NetLinx Studio

  • 7/22/2019 Programmer 1 & 2 PDF

    33/265

    Configure and Address NetLinx System

    28 AMX Programmer I & II

    6. Select a COM port and specify the communication settings for serial port communications.

    The default settings are:

    7. Click OKto return to the Communication Settings dialog.

    8. Click OKto return to the Master Communication Settings dialog.

    9. Click OKto close the Master Communications dialog.

    Connecting to a NetLinx Master via Modem

    To connect to a NetLinx master, use the options in the Master Communication Settings and

    Communication Settings dialogs to specify the TCP/IP address, serial port or modem settings,depending on the transport connection type specified. These instructions in these topics assume that

    the physical link between the PC running NetLinx Studio and the NetLinx master is established.

    1. Select Settings > Master Communication Settingsto open the Master Communication

    Settings dialog.

    2. Click Communication Settings...to access the Communication Settings dialog.

    3. Select NetLinxMaster as thePlatform Selection.

    4. Select Modemas the Transport Connection Option.

    5. Click Settingsto open the Modem Port Settings dialog.

    Comm Port COM1

    Baud Rate 38400

    Data Bits 8

    Parity None

    Stop Bits 1

    Flow Control None

  • 7/22/2019 Programmer 1 & 2 PDF

    34/265

    Configure and Address NetLinx System

    29MX Programmer I & II

    6. Select a COM port and specify the communication settings for modem communications. The

    default settings are:

    7. Click OKto return to the Communication Settings dialog.

    8. Click OKto return to the Master Communication Settings dialog.

    9. Click OKto close the Master Communications dialog.

    Verify Devices OnlineIf you are connected to a System with online devices, you can view the online devices, device

    properties, and device port properties in the Online Tree tab of the Workspace Window.

    To view online devices:

    1. If the Workspace Window is not visible, select View > Workspace.

    2. Open the Online Treetab.

    3. Click the Displaycommand button to open the Online Tree context menu, and select Refresh

    Network.

    4. All devices currently connected to the Master are displayed in the Online Device Tree.

    Set NetLinx Time and Date

    Select Tools > Set Master Controller's Date/Timeto open the Set Master Controller's Date/Time

    dialog. Use the options in this dialog to set the time and date for a specified NetLinx Master.

    1. In the Master Controller IDtext box, enter/edit the target System number (if necessary).

    2. To retrieve the current Time/Date settings for the specified target Master, click Get Time/

    Date. The Master's current Time/Date settings are displayed in the (read-only) text field.

    3. To change the target Master's date setting, click the down arrow next to the Datefield to open

    the calendar window. To change the system's date, click to select the desired day. Use the

    forward and back arrow buttons to change the month. When you select a new date, the calendar

    closes and the new date is represented in the Date field.

    To set the system to today's date, click Todayat the bottom of the calendar.

    Comm Port COM1

    Baud Rate 38400

    Data Bits 8

    Parity None

    Stop Bits 1

    Flow Control None

    Phone Number Enter the telephone number of the master.

  • 7/22/2019 Programmer 1 & 2 PDF

    35/265

    Configure and Address NetLinx System

    30 AMX Programmer I & II

    4. To change the target Master's time setting, select a field within the time display (hours,

    minutes, seconds, or AM/PM) and click the up and down arrows to adjust the selected field.

    Alternatively, you can highlight the field in the Time display that you want to adjust and

    type the desired number in its place.

    If no field is selected within the time display, the up/down arrows affect the hours setting.

    5. To set the specified Time/Date settings for the target system click Set Time/Date.

    Configure Network Settings

    Use the options in the Networking Addresses dialog to change the network settings for a specified

    NetLinx master.

    Changing the System Number on a NetLinx Master

    Use the Systemfield in the Network Addresses dialog to change the System number for the

    connected Master:

    1. Select Diagnostics > Network Addresses(or click the toolbar button) to access the Network

    Addresses dialog.

    2. At the top of the dialog, specify a new System number in the System text box.

    3. Click theReboot Masterbutton to reboot the master and accept the new changes. Allow 20-

    30 seconds for the master to reboot.

    Changing the IP Address on a NetLinx Device Using DHCP

    Use the IP Addressoptions in the Network Addresses dialog to change the IP Address for a

    specified NetLinx Device (using DHCP):

    1. Select Diagnostics > Network Addresses(or click the toolbar button) to access the Network

    Addresses dialog.

    2. At the top of the dialog, enter the specified device's Systemand Devicenumbers in the text

    boxes. The range is 0-65535.

    3. Click the Get IP Informationbutton to populate the IP Address fields with the current Host

    Name and Gateway assignments.

    4. Click the Use DHCPradio button, and enter a new Host Name in the text box, if necessary.

    5. Click the Set IP Informationbutton to set the new Host Name assignment.

    6. Click the Reboot Masterbutton to reboot the master and accept the new changes. Allow 20-

    30 seconds for the master to reboot.

    When you change the IP Address of a master (if connected via IP), you must also change the

    communication settings to match the new IP Address in the Master Communications Settings

    dialog.

  • 7/22/2019 Programmer 1 & 2 PDF

    36/265

    Configure and Address NetLinx System

    31MX Programmer I & II

    Setting the DNS Address for a NetLinx Master

    1. Select Diagnostics > Network Addresses(or click the toolbar button) to access the Network

    Addresses dialog.

    2. Enter the specified device's System and Device values in the text boxes at the top of the dialog

    (ranges = 0-65535).

    3. Click Get DNS Informationto populate the DNS Address fields with the current Domain

    Suffix, DNS IP Address #1, DNS IP Address #2 and DNS IP Address #3 assignments (as

    applicable).

    4. Edit the DNS Address assignments and/or add new DNS address information as needed.

    5. Click Set DNS Informationto set the new DNS address assignments.

    Setting the IP Address for a NetLinx Master

    1. Select Diagnostics > Network Addresses(or click the toolbar button) to access the Network

    Addresses dialog.

    2. At the top of the dialog, enter the specified device's System and Device numbers in the text

    boxes (range = 0-65535).

    3. Click Get IP Informationto populate theIP Addressfields with the current Host Name, IP

    Address, Subnet Mask and Gateway assignments.4. Click the Specify IP Addressradio button, and enter the new IP Address, Subnet Mask and

    Gateway assignments in the text boxes, as necessary.

    5. Click Set IP Informationto set the new IP Address assignment.

    6. Click Reboot Master to reboot the master and accept the new changes. Allow 20-30 seconds

    for the master to reboot.

    Changing the IP Address on a NetLinx Master (Use DHCP)

    Use the options in the Network Addresses dialog to change the IP Address for a specified NetLinx

    device (using DHCP).

    1. Select Diagnostics > Network Addresses(or click the toolbar button) to access the NetworkAddresses dialog.

    2. At the top of the dialog, enter the specified device's System and Device numbers in the text

    boxes. The range is 0-65535.

    NetLinx Masters are always set to Device = 0.

    If you change the IP Address of a Master (if connected via IP), you must also change the

    communication settings to match the new IP Address (in the Master Communication Setting

    dialog).

    NetLinx Masters are always set to Device = 0.

    NetLinx Masters are always set to Device = 0.

  • 7/22/2019 Programmer 1 & 2 PDF

    37/265

    Configure and Address NetLinx System

    32 AMX Programmer I & II

    3. Click the Get IP Informationbutton to populate the IP Address fields with the current Host

    Name and Gateway assignments.

    4. Click the Use DHCP radio button, and enter the new Host Name in the text box, if necessary.

    5. Click the Set IP Informationbutton to set the new Host Name assignment. A message will be

    displayed indicating that the Master has accepted the new settings.

    6. Click the Reboot Masterbutton to reboot the Master and accept the new changes. Allow 20-

    30 seconds for the Master to reboot.

  • 7/22/2019 Programmer 1 & 2 PDF

    38/265

    Programmer Software and Settings Checklist

    33MX Programmer I & II

    Programmer Software and Settings Checklist

    NetLinx Master Configuration (Initial Setup):

    Connect to Master through front program port

    Set System Time & Date (Affects program references to TIME)

    Go to Tools/Set Master Controllers Date/Time to open the dialog in NetLinx Studio

    Click "Set Time/Date" to set the NetLinx master to the time / date shown

    Time shown without intervention is from the PC control panel clock

    Click "Get Time/Date" to see what the NetLinx master is already set to

    Type new time / date as required

    Set System Number ______

    Go to Diagnostics/Device Addressing in NetLinx Studio

    System Number Factory Default is 1. If multiple systems are used on the same network, unique system numbers

    are recommended. If the systems will communicate with each other (Master to Master) unique system numbers

    are REQUIRED.

    Set Device Addresses

    Go to Diagnostics/Device Addressing in NetLinx Studio

    Use left side if you know the current address and the new (desired) address

    Use right side (ID Mode) if you know the new (desired) address but not the current address

    Click Start Identify Mode

    Press button on device to change (DMS Keypad, NXI, Net Module Shell)

    Use Dip Switches to set NetLinx cardframe address (see Dip Switch 2 for settings help)

    NOTE: First card slot address = Dipswitch setting * 12 + 1

    Setup URL list (only if Master to Master communication is required)

    Your programmer may have already done this in the code. You can check Diagnostics/URL Listing and click

    "Get URL List". Any identified links to other masters will be listed.

    If not there, add the IP address of each required system. NOTE: The IP address only needs to be added to one

    side of the connection.

    Setup Networking

    From Client's Network Administrator, determine whether DHCP or Static IP addressing will be used

    Got to Diagnostics/ Network Addresses

    Select DHCP or Specify

    If Specify, enter IP, Subnet, and Gateway information obtained from Network Administrator.

    Click Set IP Information

    Click OK the Reboot

    Connect to Master over IP, using address from previous step

  • 7/22/2019 Programmer 1 & 2 PDF

    39/265

    Programmer Software and Settings Checklist

    34 AMX Programmer I & II

    System Preparation:

    Using NetLinx Studio, Workspace Wizard

    In the Workspace window, import project support files

    Program source code (.axs)

    IR files for each IR controlled device (.irl, .irv)

    Serial Protocol reference files (if available--.doc, .txt, etc.)

    Touch Panel / Keypad files (.tpd, .kpd, .ovl, etc.)

    System Drawings (.dwg, .vsd, etc.)

    Owner's Manuals (.pdf, .doc, etc.)

    Set Device Mapping for each IR, Keypad, Touch Panel, and source code file

    Compile source code, if available (there should be no compile errors at this point)

    Transfer project files to the NetLinx master or control device as appropriate

    For NetLinx masters, reboot before testing

  • 7/22/2019 Programmer 1 & 2 PDF

    40/265

    Principles of Programming

    35MX ProgrammerI & II

    Principles of Programming

    Lesson Topics:

    Format of the Programming Language

    Operators

    Putting it Together

    Mainline

    Format of the Programming Language

    The AMX programming language is a free format language. That means the source code is

    independent of tabs, additional spacing, and carriage returns. However, dont let the free format

    fool you! Utilizing tabs and carriage returns in a consistent method of code placement will make it

    easier to read, but will not cause errors when the code is compiled.

    DEFINE_EVENT

    BUTTON_EVENT[PANEL,1]

    {

    PUSH:

    {

    IF (X = 1)

    {

    Y = 2

    Z = 3 }

    }

    }

    The above program statement executes the same even if it looks like this:

    BUTTON_EVENT[PANEL,1] PUSH: {IF(X = 1) {Y = 2 Z = 3}}

    The syntax is identical, but the spacing is different. The first method is recommended because

    it is easier to read, and adheres to AMX programming conventions.

  • 7/22/2019 Programmer 1 & 2 PDF

    41/265

    Principles of Programming

    36 AMX Programmer I & II

    Language Basics

    Identifiers, Keywords and Operators are used to form a statement.

    Keywordsare reserved words that perform a specific function or operation in the AMX

    Program

    An operatoris a character that performs a specific mathematical, relational, or logical

    function

    For example, the operator used to set a variable equal to a value is '='

    The statement used to set variable X to the value 5 is X = 5

    Identifiersare used to denote a device, constant, or variable. There are certain guidelines

    for identifiers:

    Identifiers must begin with a letter followed by any combination of letters, numbers, or

    underscores. No spaces allowed.

    The identifier must have fewer than 27 characters

    Identifiers are not case-sensitive

    Each identifier must be unique. Once you define VHS3, do not choose the same name

    for a different identifier.

    Valid identifiers: T_PANEL, CD3, VCR3_SELECT

    Invalid identifiers: 3VHS, CD PLAYER, *RGB4

    A statementis a complete operation that includes keywords and its parameters

    For example, the keyword to turn a channel on is ON, and the statement to turn on a

    particular channel is ON [RELAY_CARD,RELAY]

    Statements can also involve mathematical or logical operations when operators areused.

    Compound Statementsare made up of several statements that are grouped together by a

    set of braces giving you the ability to have multiple statements within one argument.

    Compound statements are used where several statements are to be executed as a single

    event.

    The statements are executed in the sequence they are programmed

    .

    ON[RELAY_CARD,5]

    X= 5

    IdentifierStatement

    Keyword

    Operator

    The number of open and closed braces must be the same in your program. After compiling,

    NetLinx will list an error if the numbers are different. It is recommended that you insert

    braces in pairs to avoid a mismatch.

  • 7/22/2019 Programmer 1 & 2 PDF

    42/265

    Principles of Programming

    37MX ProgrammerI & II

    For an Event, when button 1 on PANEL is pressed, relay 5 on RELAY_CARD is turned on. Also,

    the variable X is assigned the value of 5. The open brace indicates the beginning of the compound

    statement, and the close brace ends it.

    BUTTON_EVENT[TP,1]

    {

    PUSH: {

    ON [RELAY_CARD,5]

    X = 5

    }

    }

    If you only need the relay to be turned on, the statement could have been written like this:

    PUSH

    ON [RELAY_CARD,5]

    Since there is only one statement after the line PUSH[PANEL,1], braces are not necessary, but

    should be used to make the program easier to read and makes for a good habit. The following table

    lists the special symbols that are used when writing code.

    Special Symbols

    Operator Name Function

    { } Braces Combine several statements into a compound statement.

    In NetLinx, Braces are also used to group "sets" of data or information.

    [ ] Brackets Enclose the device-channel set: [device, channel].

    Enclose the location of a storage space in an array: Array_Name[5]

    Enclose the instance number for use with a SYSTEM_CALL:

    SYSTEM_CALL [2] VCR1(parameters)

    ( ) Parentheses Enclose the expression after an IF statement: IF (X=1)

    Enclose a mutually exclusive set in the Define section: ([RELAY,1], [RELAY,2]) Enclose DEFINE_CALL parameter list: DEFINE_CALL TEST (parameters)

    Group a mathematical operation: NEW_VALUE = (X*Y+4)

    (**) or

    /* */

    Comments Enclose helpful descriptions or remarks that are not considered part of the program and

    have no effect on the operation of the program.

    // Comments In NetLinx, the double slash is used for a single line comment.

  • 7/22/2019 Programmer 1 & 2 PDF

    43/265

    Principles of Programming

    38 AMX Programmer I & II

    Operators

    An operator is a character (or group of characters) that performs a specific operational function.

    Each operator type is described below.

    Arithmetic Operators

    Arithmetic operators create a numeric value from one or more operations such as addition,multiplication, and division.

    Relational Operators

    A relational operator is a conditional statement and tells the program whether to execute a

    particular function or functions in the program.

    Logical Operators

    Logical operators compare two conditions or, in the case of NOT, invert one condition. A true or

    false result is produced.

    Arithmetic Operators

    Operator Function

    + Addition

    - Subtraction

    * Multiplication

    / Division

    % Modulo (remainder after division)

    Relational Operators

    Operator Function

    < Less Than

    > Greater Than

    = Equal To

    == Equal To

    = Greater Than or Equal To

    Not Equal To

    Logical Operators

    Operator Function Keyword

    && Logical And AND

    || Logical Or OR

    ^^ Logical Xor XOR

    ! Logical Not NOT

  • 7/22/2019 Programmer 1 & 2 PDF

    44/265

    Principles of Programming

    39MX ProgrammerI & II

    Bitwise Operators

    Bitwise operators are keywords or symbols that perform a bit-by-bit operation between two items.

    Shift Leftshifts the bits of a value to the left nbinary positions or effectively multiplies

    the value by 2n, where nis the number of places to shift. Shift Left is designated by a

    double less-than sign ( > )or the RSHIFT keyword.

    An example of both is shown below:

    X = 1

    Y = 8

    X = X > 3 (* Z is now equal to 1 *)

    Bitwise Operators

    Operator Function Keyword

    & Bitwise And BAND

    | Bitwise Or BOR

    ^ Bitwise Xor BXOR

    ~ Bitwise Not BNOT

    > Shift Right RSHIFT

    Bitwise will be covered in more detail in AMX Programmer II.

  • 7/22/2019 Programmer 1 & 2 PDF

    45/265

    Principles of Programming

    40 AMX Programmer I & II

    Assignment Operators

    NetLinx also includes value increment and decrement operators. These operators with variables as

    statements work just like an Assignment operator or the equal sign does. The Increment-by-One

    operator or double plus sign (++) increments the value of its variable by one. The Decrement-by-

    One operator or double minus sign (--) decrements the value of its variable by one.

    The assignment operators may appear only once in a single NetLinx statement.

    An example of value increment and decrement operators is shown below.

    X = 1

    Y = 5

    X++ // X is now equal to 2 *)

    Y-- // Y is now equal to 4 *)

    The following rules apply to the use of Direct assignment operators:

    The "=" operator may be used to assign

    Expressions to intrinsic type variables (see Data Types)

    Arrays to other array of matching size and type

    Structures to other structures of the same type

    The "++" and "--" operators are statements and cannot appear within expressions. For

    example: FOR (I=1; I

  • 7/22/2019 Programmer 1 & 2 PDF

    46/265

    Principles of Programming

    41MX ProgrammerI & II

    Operator Precedence

    The table below shows the inherent precedence assigned to the operators. As noted in the chart, the

    NOT (!) operator has the highest precedence in 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 NOT (!) and other operators.

    Putting it TogetherUsing Templates

    Section 1- you have your Definitions. For example, DEFINE_DEVICE is like the team roster, and

    the device addresses are like the players jersey numbers. DEFINE_VARIABLE is like the players

    positions

    NetLinx Operator Precedence

    Level Operators Associability

    1 (highest) ! ~ Left To Right

    2 * / % Left To Right

    3 + - Left To Right

    4 > Left To Right

    5 < >= = == Left To Right

    6 & | Left To Right

    7 (lowest) && || ^^ Left To Right

  • 7/22/2019 Programmer 1 & 2 PDF

    47/265

    Principles of Programming

    42 AMX Programmer I & II

    Section 2 & 3, DEFINE_START & DATA_EVENT; online are like the start of the game because it

    sets defaults and configuration just like a starting lineup tells the umpires what is going on.

    Section 3, DEFINE_EVENT is like when the pitcher pitches and the batter swings; hit, strike, ball,

    walk, etc. and the defense is waiting for a hit; fly, grounder, etc. Something happens based on that

    pitch just like with an Event, the program waits for a triggering mechanism for it to act.

    Section 4, DEFINE_PROGRAM which is Mainline is where you have Feedback and

    SYSTEM_CALLs; just like looking at the score board.

  • 7/22/2019 Programmer 1 & 2 PDF

    48/265

    Principles of Programming

    43MX ProgrammerI & II

    Mainline in NetLinx

    Mainline is the section of the program that is executed continuously by the NetLinx Central

    Controller. DEFINE_PROGRAMcontains the code known as Mainline that is executed continuously

    as long as the Controller has power.

    A typical NetLinx program is composed of a number of different sections. Each section defines

    some aspect of a program such as device definitions, variable declarations, channel characteristics,

    or event processing.

    In a NetLinx system, either DEFINE_PROGRAMor DEFINE_EVENTis required. Other sections are

    required only to support code in one of these two sections, although the Compiler might require

    more.

    NetLinx processes network activity through a separate thread of execution. Bus activity is serviced

    concurrently with event processing and Mainline execution.

    The DEFINE_EVENTsection provides an efficient mechanism for processing events since Mainline

    does not have to be traversed to process a single I/O request. A handler can be defined for

    processing device-specific events as well as providing feedback for the device initiating the event

    notification. If a handler is present, Mainline will not be called to process the event; the handler is

    called instead. Once the handler completes its execution, the system is ready to process the next

    input message. When there are no more messages pending, Mainline is run. In effect, Mainline

    becomes an idle timeprocess.

    Mainline will be run every 1/2 second if no other event requires it first.

  • 7/22/2019 Programmer 1 & 2 PDF

    49/265

    Principles of Programming

    44 AMX Programmer I & II

    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.

    Code ExamplesBitwise Operator - BAND Example:

    DEFINE_CALL 'NEC CHECKSUM' (CMD[20])

    LOCAL_VAR INDEX LENGTH

    {

    CHECKSUM = 0

    INDEX = 1

    LENGTH = LENGTH_STRING(CMD)

    WHILE (INDEX

  • 7/22/2019 Programmer 1 & 2 PDF

    50/265

    Object Oriented Programming and Events

    45MX Programmer I & II

    Object Oriented Programming and Events

    Lesson Topics

    Object Oriented Programming

    Event Handlers

    BUTTON_EVENTS

    CHANNEL_EVENTS

    Object Oriented Programming

    Objects can be things, like a VCR, DVD, CD, switcher, projector, etc. Objectshave Properties

    and Methods. Properties describe the object. Properties are implemented in NetLinx as variables,constants, and structures. Methods are actions that the object performs. Methods are implemented

    in NetLinx by using the various NetLinx keywords like Send_String, ON, OFF, Pulse, etc. These

    commands are enclosed within subroutines, the Push, Release, Hold sections of

    BUTTON_EVENTs, in DATA_EVENTs, etc.

    An example would be a multi-disc CD Changer. The CD Changer is the Object. Some Properties

    would be:

    Power Flag - keeps track of whether the power is on or off

    Disc number - keeps track of what disc is selected

    Function - keeps track of what transport function is active (Play, Stop, Pause, etc)

    Track - keeps track of what music track is currently selected

    Some Methods would be:

    Play

    Stop

    Pause

    Skip Forward

    Skip Reverse

    Fast Forward

    Rewind

  • 7/22/2019 Programmer 1 & 2 PDF

    51/265

    Object Oriented Programming and Events

    46 AMX Programmer I & II

    The code to implement this might look like this:

    DEFINE_VARIABLE

    INTEGER nCD_PowerFlag

    INTEGER nDiscNum

    INTEGER nFunctionINTEGER nTrack

    DEFINE_EVENT

    BUTTON_EVENT[TP,10]

    {

    PUSH:

    {

    PULSE [CD,27]//Go to Disc #2

    nDiscNum = 2

    }

    }

    BUTTON_EVENT[TP,1]

    {

    PUSH:

    {

    PULSE [CD,1]//Play

    nFunction = 1

    }

    }

    Buttons on an AMX touch panel can be considered an Objectalso. Some of the Propertiesof a

    button are:

    Associated device number

    Channel number

    Feedback type (channel, momentary, etc.)

    Variable text channel number

    Level number

    Pop Up page

    The Methodsof a button are:

    Push

    Release

    Hold

  • 7/22/2019 Programmer 1 & 2 PDF

    52/265

    Object Oriented Programming and Events

    47MX Programmer I & II

    Event Handlers

    All interactions between external devices and the master processor are handled within mainline

    code. The processor runs mainline code, services the wait and pulse queues, and checks the bus for

    any changes in device status. These interactions or changes in status are Events. There are handlers

    to support five types of events:

    BUTTON_EVENTsinclude pushes, releases, and holds, which are associated with a

    push or release on a particular device-channel.

    CHANNEL_EVENTsoccur when an output change (On/Off) is detected on a device-

    channel.

    DATA_EVENTsinclude commands, strings, status, and error messages.

    LEVEL_EVENTsare received as a result of a level change on a particular device.

    TIMELINE_EVENTstrigger events based on a sequence of times.

    DEFINE_EVENT

    NetLinx has a special program section called DEFINE_EVENT to handle the incoming events. The

    event processing that could only occur within mainline code can be handled in the

    DEFINE_EVENT section.

    NetLinx maintains a table of the defined event handlers, when a new event comes into the NetLinx

    processing queue, the event is compared against the table of events. If the event is found, only the

    code in the event definition is evaluated and executed, mainline is bypassed. If an event handler is

    not defined, mainline is run, and the event is evaluated against the mainline code. This provides a

    more efficient mechanism for processing events, since mainline is not required to process a single

    I/O request. If no events are pending, mainline is run. Mainline becomes an idle time process.

    The processing of an event associated with a given member of a device, channel, device-

    channel, level, or device-level array must be completed before processing can begin onanother event associated with the same array.

    FIG. 1 Steps Involved in Processing an Event

    Run Mainline

    Eventhandler

    available?Start

    StopRun event

    handler

    NO

    YES

    More than one handler can be defined for the same event. In this case, the handlers are

    executed in the order in which they are defined in the program.

  • 7/22/2019 Programmer 1 & 2 PDF

    53/265

    Object Oriented Programming and Events

    48 AMX Programmer I & II

    The event handler descriptions are:

    DEVICErefers to a device specification:

    CHANNELrefers to:

    LEVELrefers to:

    With the addition of the DEFINE_EVENT section for processing events, mainline becomes greatly

    diminished in NetLinx, if not totally eliminated. Programs can still be written using the traditional

    technique of processing events and providing feedback in mainline code. However, programs

    written using the event table structure will run faster and be much easier to maintain.

    DEVICE A single device number constant

    D:P:S A constant device specification such as 128:1:0

    DEV[ ] A device array

    CHANNEL A single channel number constant

    CHAN[ ] An integer array of channel numbers

    DEVCHAN[ ] A device-channel array

    LEVEL A single level number constant

    LEV[ ] An integer array of level numbers

    DEVLEV[ ] A device-level array

  • 7/22/2019 Programmer 1 & 2 PDF

    54/265

  • 7/22/2019 Programmer 1 & 2 PDF

    55/265

    Object Oriented Programming and Events

    50 AMX Programmer I & II

    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.

    NetLinx BUTTON_EVENT:

    DEFINE_EVENT

    BUTTON_EVENT[TP1,10]

    {

    PUSH:

    {

    TO[TP1,10]

    SEND_STRING KC1, A

    }

    RELEASE:

    { }

    HOLD[5,REPEAT]:

    {

    SEND_STRING KC1, A

    }

    }

    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.

  • 7/22/2019 Programmer 1 & 2 PDF

    56/265

    Object Oriented Programming and Events

    51MX Programmer I & II

    CHANNEL_EVENTs

    Channel_Events are similar to Button_Events. Channel_Events are generated by an ON, OFF,

    PULSE, TO, or MIN_TO. CHANNEL_EVENT are very simple and only have two conditions:

    What happens when the channel turns on

    What happens when the channel turns off

    The format for a CHANNEL_EVENT is shown below:

    CHANNEL_EVENT[,]

    {

    ON:

    {

    //on event handler code

    }

    OFF:

    {

    //off event handler code

    }

    }

    Like BUTTON_EVENTs, the [, ] declaration can contain a DEV device set, or

    a DEVCHAN device-channel set in addition to individual device and channel declarations.

    What information describes a CHANNEL_EVENT?

    Channel number of the device

    The D:P:S Device number of the relay card that contains the relay

    The individual Device number, Port and System ID of the D:P:S device number

    In the following example, a CHANNEL_EVENT is defined to turn off a video projector every time

    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

    the relay or pulsing the relay does not produce a push, a BUTTON_EVENT is not generated.

  • 7/22/2019 Programmer 1 & 2 PDF

    57/265

    Object Oriented Programming and Events

    52 AMX Programmer I & II

    NetLinx Button and CHANNEL_EVENTs:

    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

    {

    ON:

    {

    PULSE[VPROJ,VP_POWER_OFF]

    }

    }

  • 7/22/2019 Programmer 1 & 2 PDF

    58/265

    Object Oriented Programming and Events

    53MX Programmer I & II

    DATA_EVENTs

    This keyword defines a DATA_EVENT handler. This type of handler processes COMMAND,

    STRING, ONLINE, OFFLINE and ONERROR even