
Crestron SDK for Microsoft
®
.NET Component Software
Introduction & Tutorial – DOC. 6718A Software: Crestron SDK for Microsoft
®
.NET
Component • 19
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.ActiveCNXConnectionEventHandler(acnxConnection_onConnect);
this.acnxConnection.onDisconnect +=new
Crestron.ActiveCNX.ActiveCNXConnectionEventHandler(acnxConnection_onDisconnect);
this.acnxConnection.onError += new
Crestron.ActiveCNX.ActiveCNXErrorEventHandler(acnxConnection_onError);
this.acnxConnection.onAnalog +=new
Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onAnalog);
this.acnxConnection.onDigital += new
Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onDigital);
this.acnxConnection.onSerial += new
Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onSerial);
this.acnxConnection.onCertVerification += new
Crestron.ActiveCNX.ActiveCNXCertificateEventHandler(acnxConnection_onCertVerificati
on);
Control.CheckForIllegalCrossThreadCalls = false;
}
Connecting to a Control System
All connection and interaction with a control system is accomplished via the buttons,
selections and text entries on a compiled interface such as the example program. The
actions they generate are controlled by event handlers.
In order to make a connection to a control system the IP address, IP ID and IP port
must be declared by selections on the interface. Once this is done, the Connect
button can be clicked which will attempt the connection.
NOTE: Adding an event handler for a acnxConnection_onDisconnect at the same
time helps monitor the connection.
1. The btnConnect_Click handler will establish the IP address and IP ID
as well as validate the user name, password, IP port and whether SSL is
being used.
2. When the connection is established, the acnxConnection_onConnect
handler is triggered. This prints update request information to the
Received from Control System field and flips the states of the Connect
and Disconnect buttons appropriately.
Comentarios a estos manuales