Examples/applications
10.2 RF182C user application
RF182C communication module
88
Operating Instructions, 10/2010
}
SetConnectionState(false);
}
else //not connected --> connect
{
//Try to connect the socket as client.
if (Connect() == true)
{
// Connection was established successfully
SetConnectionState(true);
}
}
}
/* This function enables/disables controls needed to set up
* the connection and those needed to communicate separately from
* each other.
* */
private void Enable(bool enableConnectionData, bool enableCommunicationData)
{
editIP.Enabled = enableConnectionData;
editPort.Enabled = enableConnectionData;
editMessage.Enabled = enableCommunicationData;
buttonSend.Enabled = enableCommunicationData;
}
/* Sets the connection state to true (connected) or false
* (not connected) with all necessary consequences (starting/stopping
* timers, changing colors, texts and the serviceability of the
* controls.
* */
private void SetConnectionState(bool state)
{
if (state == true)
{
ConnectionState = true;
// Visualization
Enable(false, true);
labelConnectionState.Text = "CONNECTED";
labelConnectionState.BackColor = Color.Green;
buttonConnect.Text = "Disconnect";
// Start UpdateTimer
UpdateTimer.Start();
}
else
{
ConnectionState = false;
//Stop UpdateTimer
UpdateTimer.Stop();
//Now, we don't know anything about tags in the field