private void Diag_Click(object sender, RoutedEventArgs e)
        {
            errors.Content = "";

            S7FunctionBlockRow.SelectedStatusValues tmp = 0;
            tmp |= (bool)stw.IsChecked ? S7FunctionBlockRow.SelectedStatusValues.STW : 0;
            tmp |= (bool)akku1.IsChecked ? S7FunctionBlockRow.SelectedStatusValues.Akku1 : 0;
            tmp |= (bool)akku2.IsChecked ? S7FunctionBlockRow.SelectedStatusValues.Akku2 : 0;
            tmp |= (bool)ar1.IsChecked ? S7FunctionBlockRow.SelectedStatusValues.AR1 : 0;
            tmp |= (bool)ar2.IsChecked ? S7FunctionBlockRow.SelectedStatusValues.AR2 : 0;
            tmp |= (bool)db.IsChecked ? S7FunctionBlockRow.SelectedStatusValues.DB : 0;

            if (myDiag == null)
            {
                try
                {
                    if (myDiag == null)
                    {
                        myDiag = _myconn.startRequestDiagnosticData((S7FunctionBlock)myBlock,
                                                                    Int32.Parse(startRow.Text), tmp);
                    }
                    myDiag.RequestDiagnosticData();
                    textEditor.Text = myBlock.ToString();
                }
                catch (Exception ex)
                {
                    errors.Content = ex.Message;
                    if (myDiag != null)
                    {
                        myDiag.Close();
                        myDiag.RemoveDiagnosticData();
                    }
                    textEditor.Text = myBlock.ToString();
                    myDiag          = null;
                }

                if (myDiag != null)
                {
                    dispatcherTimer          = new DispatcherTimer();
                    dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
                    dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
                    dispatcherTimer.Start();
                }
            }
            else
            {
                dispatcherTimer.Stop();
                myDiag.Close();
                myDiag.RemoveDiagnosticData();
                textEditor.Text = myBlock.ToString();
                myDiag          = null;
            }
        }
Ejemplo n.º 2
0
 void diagTimer_Tick(object sender, EventArgs e)
 {
     diagTimer.Stop();
     MyDiagnosticData.RequestDiagnosticData();
     diagTimer.Start();
 }