AMX IS-SPX-1000/1300 manual Sample Code, Network API, Setting the Variable, Reading the Variable

Page 94

Shared Variables

The function createSharedVariable returns a SharedVariable object that should be used to install “listeners”. Those are callbacks that will be called whenever the variable value changes.

The callback is passed a reference to the variable object and can query the value property. It is also possible to poll on the lastUpdateTime property (initially 0) to detect when the value has been updated. The set method is used to update the

value of a variable. It will trigger any callback installed on the same variable object or on other variable objects created with the same name, including remote objects if networking is enabled.

Sample Code

Setting the Variable

On the player that controls the variable

var v=createSharedVariable( 'XY' ); v.set( 'new value' );

Reading the Variable

When the same player sets and read the variable:

function onUpdate( x ) {

//Do something based on x.value

}

var v=createSharedVariable( 'XY' ); v.addUpdateListener( onUpdate );

When a player sets the variable and another player reads its content:

function onUpdate( x ) {

//Do something based on x.value

}

var v=createSharedVariable( 'XY@controller' ); v.addUpdateListener( onUpdate );

Network API

Framing

The network protocol for the distribution of notifications is based on a stream of variable length commands sent over a TCP socket. Individual commands are separated by the \r\n (0x0D 0x0A) two-byte sequence. This sequence should not

happen inside the command. When string parameters are used, they are put between double quotes. Special characters should be escaped, in a manner similar to C-string constants, with a backslash sequence. The following characters must be escaped:

newline (0x0A) with \n

carriage return (0x0D) with \r

double quote (0x22) with \" null byte (0x00) with \0

backslash itself with \\

Alternatively, the network API also supports setting shared variables via an HTTP GET request. This method does not allow persistent connections, but it is easier to access from a client scripting language supporting the XMLHttpRequest API, like JavaScript in web browsers.

Whenever a GET request is issued, the connection by the server is closed immediately after the response has been sent.

The HTTP GET interface supports only the 'UPDATE' and 'EVENT' commands.

86

Inspired XPress - Programming Guide

Image 94
Contents Inspired Signage XPress WARRANTY, Disclaimer and License Table of Contents Remote Control Synchronized Content Interactivity Serial Protocol File Editor Table of Contents Inspired XPress Programming Guide Installing Inspired Signage XPress for the First Time InstallationWhen to use XPress Authoring Features? IntroductionMinimum Recommended PC Requirements XPress must be restarted to complete the activationInspired Signage XPress UI Installation LocationXPress Removal XPress Projects Learning XPress Authoring FeaturesXPress Main Interface Creating a New Project My Projects folderBrowsing Panel New Project dialog TargetImporting Images Importing Multi-Media FilesImporting Video Creating and Editing SVG Files Importing PowerPoint PresentationsImporting Flash SWF Files Editing an Existing SVG Document Template Document ParametersEdit a Media Property Media description dialog lets you changeInteractive Editing Interactively Editing SVG FilesEditing Media Elements Layout Demonstration of Media ElementsEditing Media Links Editing TextComposing a Scene Multi-Layered SVG TemplatesCustomizing a Multi-Layer SVG Document Example Editing Playlist TemplateHow to Customize a Playlist SVG Document Composing a playlist SVG documentPlaylist Tab Layout Templates Special News TemplatesComposing a Live News Document Format HelpersNewsticker.svg Customizing a News SVG DocumentNews.svg Newscrawler.svgBouncingtext.svg Using Format HelpersSwitch.svg Fittext.svgScalable Content and Aspect Ratio of Your Display Example of 169 content169 templates as shows on a 43 screen Multimedia Effects Configuring EffectsAdding Effects Preview XPress Content PreviewingUsing Quick Publish PublishingMonitoring Manually Add Devices to XPressCheck the Status of the Devices Scheduling the Content Displayed by an IS-SPX PlayerScheduling Open a DeviceCreate a New Schedule Open a ScheduleAdd Events To a Schedule Calendar viewDefine a Default Animation Define Default Events and RecurrencesModify the Scheduling Properties of an Event Define Recurring Events Edit recurrence rulePreview Scheduled Content Data Polling RatesHow To Use Remote Control Remote Control of ContentWhen To Use Remote Control OverviewID table Triggering a Content Switch Over IP PlaylistExample Testing Settings menu Enable Network APISwitching Content With the Serial Port Switching Content With a USB HID DeviceSwitching Content From Another Device Key Identifiers tabWhen To Use Remote Control of Playback Remote Control of PlaybackHow To Use Remote Control of Playback Interactive Pause/Resume Using Http GET Interactive Pause/Resume Over TCPInteractive Pause/Resume From a Device GET Embedded In an HtmlTimed pause/seek/resume Getting Feedback On the Playback Progress Knowing the Current Position With Extra AccuracyRemote Triggers Triggering an Alternative ContentTriggering a Text or Image Overlay Triggering of SVG Animations Multiscreen Displays Application ExamplesDesigning Basic Projects for Multiscreen Layouts Creating a Configurable Multiscreen Project New Project menuMultiscreen Properties Creating a Multiscreen Project from Templates Finding the multiscreen templatesNew multiscreen project can now be Saved and Edited Editing Multiscreen Content Multiscreen layout drop down optionsConfigure the Multiscreen ID Configuring XPress and the IS-SPX PlayerCreate a Virtual Device Publish Your Project To Your Device SynchronizationSynchronizing Devices Configure NTP Through the Http Interface Administration Date/TimeUsing an IS-SPX Player as an NTP Server Advanced ConfigurationConfiguration Configuration of the IS-SPX Player Acting as Master Master/Server Architecture ExamplesCanvas and Viewbox Concepts Syntax for Multiscreen Synchronized ContentSynchronization Elements Multiscreen ElementsExtension of the SVG switch Element Additional Syntax for Multiscreen ContentSpxbegin Element Extension of JavaScript Example Screen Layout With Six ScreensExample switch SVG Element Example Screen Layout With Spread DisplaysNTP Synchronization TroubleshootingExample JavaScript Project CreationSynchronized Content Synchronized Content Inspired XPress Programming Guide Creating Interactive Content Interactivity Template FilesCreating a Touch Screen Menu Creating ButtonsControlling Media Adding an Action IDTesting the Project Enter Interactive ModeCreating a Keyboard Menu Creating the MenuConfiguring the menu Button Action IDsRGB values Hexadecimal value Eyedropper tool Controlling the Menu Color Selection greenKeystrokes Interactive controlsControlling Media Layers tab keystroke.svgPlayback Projects Testing the ProjectSuggestions for Further Projects Playback Template New ProjectPlayback Position Controlling the MediaExample Media player Playback.svg details Slider.svg placement IS-SPX Player Configuration Interactivity SettingsCalibration For Touch Screens Calibration of a Touchscreen Through the IS-SPX PlayerManual Calibration Procedure TroubleshootingSerial Protocol File Editor Adding a List VariableAdding a Range Variable Edit Variable Page List variableExporting the Finished File Edit Variable page Range variablePage Javascript API Concepts Behind Shared VariablesInterface Network API Setting the VariableSample Code Reading the VariableList of Commands Network API CommandsEnabling the Network API Sample CodeRestarting XPress will reset all the shared variables API EmulationShared Variables Inspired XPress Programming Guide Serial Protocol Commands Text Gathering Display Serial Protocol CommandsSerial Control Serial Protocol Commands Hex Creating a Serial Protocol FileManual Command Text Entries HexVolume Control Variable Variable ListMute On Sound Screen Mute Picture OnScreen Mute Picture Off Mute Off SoundUnder the Administration section, select RS232 / USB IO Uploading the Serial Protocol FileCreating New Templates XPress My Templates FolderCreating and updating a new calendar file XML Tree with new attribute param1New.ics file Adding Additional Templates to Inspired Signage XPress Power commandSerial Control From NetLinx Commonly Used Terms FSMIncrease Your Revenue through education + knowledge