Beispiele/Applikationen
10.2 Anwenderapplikation RF182C
}
SetConnectionState(false);
}
else
{
//Try to connect the socket as client.
if (Connect() == true)
{
}
}
}
/* This function en- / 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 colours, texts and the serviceability of the
* controls.
* */
private void SetConnectionState(bool state)
{
if (state == true)
{
ConnectionState = true;
// Visualisation
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
94
//not connected --> connect
// Connection was established sucessfully
SetConnectionState(true);
Kommunikationsmodul RF182C
Betriebsanleitung, 10/2010, J31069-D0204-U001-A2-0018