public void TwinCat3Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
 {
     Application.Current.Dispatcher.Invoke
         (new Action(() =>
     {
         if (e.UserData == ReferenceHandler.GetReferenceObject("controll"))
         {
             if ((Boolean)e.Value)
             {
             }
         }
         if (e.UserData == ReferenceHandler.GetReferenceObject("mode"))
         {
             Screens[0].IsEnabled = !(bool)e.Value;
             Screens[1].IsEnabled = !(bool)e.Value;
             Screens[2].IsEnabled = (bool)e.Value;
             Screens[3].IsEnabled = !(bool)e.Value;
         }
     }));
 }
Esempio n. 2
0
        public void TwinCat3Client_AdsNotificationEx(object sender, AdsNotificationExEventArgs e)
        {
            Application.Current.Dispatcher.Invoke
                (new Action(() =>
            {
                if (e.UserData == ReferenceHandler.GetReferenceObject("controll"))
                {
                    if ((bool)e.Value)
                    {
                        btnControl.Background = (SolidColorBrush)FindResource("BaseGreenBrush");
                    }
                    else
                    {
                        btnControl.Background = (SolidColorBrush)FindResource("BaseRedBrush");
                    }
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("mode"))
                {
                    if ((bool)e.Value)
                    {
                        btnMode.Background  = (SolidColorBrush)FindResource("BaseGreenBrush");
                        btnModeContent.Text = "A";
                    }
                    else
                    {
                        btnMode.Background  = (SolidColorBrush)FindResource("BaseYellowBrush");
                        btnModeContent.Text = "M";
                    }
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_status"))
                {
                    mainPage.tbStatus.Text = e.Value.ToString();
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_step"))
                {
                    mainPage.tbStepNr.Text = e.Value.ToString();
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("result_torque"))
                {
                    mainPage.tbTorque.Text = Math.Round((Single)e.Value, 3).ToString();
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("result_angle"))
                {
                    mainPage.tbAngle.Text = e.Value.ToString();
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_program"))
                {
                    mainPage.tbProgramNumber.Text = e.Value.ToString();
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("deprag_CycleTime"))
                {
                    mainPage.tbProcessTime.Text = Math.Round((Single)e.Value, 3).ToString();
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("Override"))
                {
                    SpeedBar.Value = (Double)e.Value;
                    SpeedBox.Text  = Math.Round((decimal)(Double)e.Value, 0).ToString() + " %";
                }
                if (e.UserData == ReferenceHandler.GetReferenceObject("message_number"))
                {
                    if (int.Parse(e.Value.ToString()) != 0)
                    {
                        AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("confirm"), false);
                        AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("ClearNotifi"), false);
                        DisplayError(int.Parse(e.Value.ToString()));
                    }
                }

                if (e.UserData == ReferenceHandler.GetReferenceObject("ClearNotifi") && AdsCommunication.ReadInt(ReferenceHandler.GetReferenceAdress("message_number")) == 0 && NotifiSlot.Children.Count != 0)
                {
                    CloseNotification();
                    AdsCommunication.WriteAny(ReferenceHandler.GetReferenceAdress("confirm"), false);
                }
            }));
        }