Samples WPF 7. Writing the method: A method that does not exist yet was referred to above. This method ('tcClient_OnNotification') is written next. The method is called if one of the PLC variables has changed.
//------------------------------------------------// wird bei Дnderung einer SPS- Variablen aufgerufen// is activated when a PLC variable changes//----------------------------------- -------------private void tcClient_OnNotification(object sender, AdsNotificationEventArgs e) { try { // Setzen der Position von e.DataStream auf die des aktuellen benцtigten Wertes// Setting the po sition of e.DataStream to the position of the current needed value e.DataStream.Position = e.Offset; // Ermittlung welche Variable sich geдndert hat// Detecting which variable has changedif(e.Notif icationHandle == hDeviceUp) { // Die Farben der Grafiken entsprechened der Variablen anpassen// Adapt colors of graphice a ccording to the variablesif (binReader.ReadBoolean() == true) { DeviceUp_LED.Foreground = newSolidColorBrush(Colors.Red); } else { DeviceUp_LED.Foreground = newSolidColorBrush(Colors.White); } } else if(e.NotificationHandle == hDeviceDown) { if (binReader.ReadBoolean() == true) { DeviceDown_LED.Foreground = newSolidColorBrush(Colors.Red); } else { DeviceDown_LED.Foreground = newSolidColorBrush(Colors.White); } } else if(e.NotificationHandle == hSteps) { // Einstellen der ProgressBar auf den aktuellen Schritt// Setting the ProgressBar to the cur rent step prgSteps.Value = binReader.ReadByte(); } else if(e.NotificationHandle == hCount) { // Anzeigen des 'Zдhler'-Wertes// Displaying the 'count' value lblCount.Text = binReader.ReadUInt16().ToString(); } else if(e.NotificationHandle == hSwitchNotify) { // Markieren des korrekten RadioButtons// Checking the correct RadioButtonif (binReader.Read Boolean() == true) { optSpeedFast.IsChecked = true; } else { optSpeedSlow.IsChecked = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } There are still two methods missing for setting the speed of the machine.
They are used to switch a virtual switch by writing a value to the PLC variable 'switch'. //------------------------------------------------------// wird aufgerufen, wenn das Feld 'schnell' markiert wird// is activated when the 'fast' field is marked//-------------------------------------- ----------------private void optSpeedFast_Click(object sender, EventArgs e) { try TX1000 34 Version: 1.2