Crestron SDK for Microsoft® .
This document was prepared and written by the Technical Documentation department at: Crestron Electronics, Inc. 15 Volvo Drive Rockleigh, NJ 07647 1-888-CRESTRON All brand names, product names and trademarks are the property of their respective owners. ©2008 Crestron Electronics, Inc.
Crestron SDK for Microsoft®.NET Component Software Contents Software: SDK for Microsoft® .NET Component 1 Introduction ............................................................................................................................... 1 Installing the SDK for Microsoft .NET Component.................................................................. 1 Automatic Installation ................................................................................................. 1 Getting Started.....
Crestron SDK for Microsoft®.NET Component Software: SDK for Microsoft .NET Component Software ® Introduction NOTE: This document assumes that the user has a proficient working knowledge of Microsoft Visual Studio, the .NET framework and associated languages, and is familiar with Crestron® control systems and their functions. The Crestron Software Development Kit (SDK) for Microsoft® .NET Component is designed to allow developers to create .
Crestron SDK for Microsoft®.NET Component Software Crestron SDK for Microsoft .NET Component “Setup Welcome” Window 1. Click Next to display the “License Agreement” window where you will be prompted to accept (or not) the license agreement governing the .NET component. Accept the agreement (if you want to continue) by clicking the appropriate radio button. You can also use the Print button to retain a copy for your records. Click Next to continue.
Crestron SDK for Microsoft®.NET Component 2. Software The “Choose Destination” window allows you to select the destination of the install. It is recommended that you accept the default unless your installation has other requirements. “Choose Destination” Window 3. Click Next to complete the installation. Getting Started 1. Introduction & Tutorial – DOC. 6718A Start Microsoft Visual Studio, select Open Project from the File menu and browse to the file: SDK for Microsoft .NET Component Test Program.
Software Crestron SDK for Microsoft®.NET Component ActiveCNX.NET SDK Component Reference The methods and events are all part of the class known as ActiveCNX. NOTE: There may be additional parameters, events and return types for any given method. Refer to the Microsoft Visual Studio help file for more information. Class ActiveCNX Package: Crestron Class: ActiveCNX Member of: Crestron.ActiveCNX Language: C# for .
Crestron SDK for Microsoft®.NET Component Method Details Software Connect() public void Connect() Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .NET This is the default connect method. If you have set the connection related properties of this object (either via the constructor, or direct assignment,) this version can be used. If the properties are not defined, one of the other connect methods must be used.
Crestron SDK for Microsoft®.NET Component Software Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .NET This connect method is used when the string, long and Boolean properties are not defined in the ActiveCNX class, such as when ActiveCNX() is used. Arguments: string strIPAddress — The IP Address of the control system expressed as a string. long lIPID — The Crestron Internet Protocol ID (IPID) expressed as a string. The default is 03. bool boolSSL — Status of SSL expressed as a Boolean.
Crestron SDK for Microsoft®.NET Component Software int iHeartBeatTimeOut — The number of milliseconds where no heartbeat response is received before causing an "onError" event. The displayed message will read: "Heartbeat timeout occurred". NOTE: The iHeartBeatTimeOut number must be larger than the iHeartBeatInterval. Return Type: void Events: onConnect — Triggered when a connection is established with the control system. onError — Triggered when an error is generated by the connection.
Crestron SDK for Microsoft®.NET Component Software Return Type: boolean — True equals Success. False equals Fail. Events: onAnalog — Triggered when SendAnalog() is initiated. onError — Triggered when the analog value fails to send. SendAnalog(int, int, int) public bool SendAnalog(int iSlot, int iJoin, int iValue) Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .
Crestron SDK for Microsoft®.NET Component Software Return Type: boolean — True equals Success. False equals Fail. Events: onDigital — Triggered when SendDigital() is initiated. onError — Triggered when sending a digital fails. SendDigital(int, int, bool) public bool SendDigital(int iSlot, int iJoin, bool boolValue) Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .
Crestron SDK for Microsoft®.NET Component Software Argument: int iJoin — The join number sent to the control system, expressed as an integer. Return Type: boolean — True equals Success. False equals Fail. Events: onDigital — Triggered when StartRepeatingDigital() is initiated. onError — Triggered if the repeating digital fails to start. StartRepeatingDigital(int, int) public bool StartRepeatingDigital(int iSlot, int iJoin) Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .
Crestron SDK for Microsoft®.NET Component Software Argument: int iJoin — The join number sent to the control system, expressed as an integer. Return Type: boolean — True equals Success. False equals Fail. Events: onDigital — Triggered when StopRepeatingDigital() is initiated. onError — Triggered if it fails to stop the repeating digital. StopRepeatingDigital(int, int) public bool StopRepeatingDigital(int iSlot, int iJoin) Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .
Crestron SDK for Microsoft®.NET Component Software Arguments: int iJoin — The join number sent to the control system, expressed as an integer. string strValue — A string passed to the control system. Return Type: boolean — True equals Success. False equals Fail. Events: onSerial — Triggered when SendSerial() is initiated. onError — Triggered if SendSerial fails. SendSerial(int, int, string) public bool SendSerial(int iSlot, int iJoin, string strValue) Member of: Crestron.ActiveCNX.
Crestron SDK for Microsoft®.NET Component Software NOTE: Defined member variables tied to attribute values should be zeroed out to avoid invalid values. Return Type void Events: onConnect — Triggered when a connection is established with the control system. onError — Triggered when an error is generated by the connection. Event Details onAnalog public event Crestron.ActiveCNX.ActiveCNXEventHandler onAnalog Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .
Crestron SDK for Microsoft®.NET Component Software onConnect public event Crestron.ActiveCNX.ActiveCNXConnectionEventHandler onConnect Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .NET Triggered when a connection is made with a control system. onDigital public event Crestron.ActiveCNX.ActiveCNXEventHandler onDigital Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .NET Triggered when a digital join is received from the control system.
Crestron SDK for Microsoft®.NET Component Software PROPERTY VALUE String—The error message received from the control system. ErrorMessage onSerial public event Crestron.ActiveCNX.ActiveCNXEventHandler onSerial Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .NET Triggered when a serial join is received from the control system. PROPERTY Properties Details VALUE Slot Integer—The slot for a sub-slotted symbol. Join Integer—The join number.
Software Crestron SDK for Microsoft®.NET Component Member of: Crestron.ActiveCNX.ActiveCNX Language Version: C# for .NET Reads and returns the connection status of the control system. EventArg Classes ActiveCNXEventArgs() public class ActiveCNXEventArgs : System.EventArgs Member of: Crestron.ActiveCNX Language Version: C# for .NET This is the base ActiveCNXEventArg class. ActiveCNXEventArgs(int, int, bool) public ActiveCNXEventArgs(int iSlot, int iJoin, bool boolDigitalValue) Member of: Crestron.
Crestron SDK for Microsoft®.NET Component Software ActiveCNXErrorEventArgs(int, string) public ActiveCNXErrorEventArgs(int iNumber, string strMessage) Member of: Crestron.ActiveCNX.ActiveCNXErrorEventArgs Language Version: C# for .NET Initializes the properties corresponding to the listed arguments. ActiveCNXConnectionEventArgs() public class ActiveCNXConnectionEventArgs : System.EventArgs Member of: Crestron.ActiveCNX Language Version: C# for .NET This is the base ActiveCNXConnectionEventArgs class.
Crestron SDK for Microsoft®.NET Component Software How to Use the Code The following examples show how the code can be used to initialize the ActiveCNX component to connect to a device, handle join events and show connection issues. These examples are taken from the example project opened in “Getting Started” on page 3 of this manual. They are representative only and may not apply to your situation. Initialization 1. Establish your base classes (or libraries or namespaces) with the using directive.
Crestron SDK for Microsoft®.NET Component Software Example Program Code public Form1() { InitializeComponent(); this.ddlLogging.SelectedIndex = 0; for (int x = 3; x < 255; x++) { this.cbIPID.Items.Add(string.Format("{0:X2}",x)); } this.cbIPID.SelectedIndex = 0; this.cbValue.SelectedIndex = 0; this.cbSlot.SelectedIndex = 0; this.acnxConnection = new ActiveCNX(); this.cbValue.Hide(); this.tbValue.Hide(); this.lblValue.Hide(); this.acnxConnection.onConnect += new Crestron.ActiveCNX.
Crestron SDK for Microsoft®.NET Component Software 3. Implement the acnxConnection_onDisconnect handler as one way of monitoring the connection. NOTE: The acnxConnection_onError handler can also be implemented to monitor error events generated by ActiveCNX. Handling Join Events The acnxConnection_onAnalog, acnxConnection_onDigital, acnxConnection_onSerial and btnSend_Click event handlers enable the ActiveCNX SDK for .NET to both send and receive join information.
Crestron SDK for Microsoft®.NET Component Software The Example Program The ActiveCNX for .NET Example Program is available from the Crestron website and shows one possible way to use the ActiveCNX for .NET SDK to create an interface to a 2-Series or X-Gen control system. Opening the example program in Microsoft Visual Studio will provide you with insight regarding the creation and implementation of a C# .NET project suitable for your needs.
Crestron SDK for Microsoft®.NET Component Software system, enter a username and password in the text boxes by the same names and click Connect. 3. When the connection is made, the Connect button is grayed out and the Disconnect button takes focus. Any messages that result are displayed in the Received from Control System field. 4.
Crestron SDK for Microsoft®.NET Component Software Software License Agreement This License Agreement (“Agreement”) is a legal contract between you (either an individual or a single business entity) and Crestron Electronics, Inc. (“Crestron”) for software referenced in this guide, which includes computer software and as applicable, associated media, printed materials and “online” or electronic documentation (the “Software”).
Software Crestron SDK for Microsoft®.NET Component If You are a business or organization, You agree that upon request from Crestron or its authorized agent, You will within thirty (30) days fully document and certify that use of any and all Software at the time of the request is in conformity with Your valid licenses from Crestron of its authorized agent.
Crestron SDK for Microsoft®.NET Component Software This page is intentionally left blank. Introduction & Tutorial – DOC. 6718A Software: Crestron SDK for Microsoft®.
Crestron Electronics, Inc. 15 Volvo Drive Rockleigh, NJ 07647 Tel: 888.CRESTRON Fax: 201.767.7576 www.crestron.com Introduction & Tutorial – DOC. 6718A (2022313) 12.08 Specifications subject to change without notice.