Beispiel #1
0
        private void cmdConnect_Click(object sender, RoutedEventArgs e)
        {
            cmdConnect.IsEnabled = false;
            cmdStop.IsEnabled    = true;

            //Alle Tags in eine Liste packen
            List <PLCTag> Tags = new List <PLCTag>();

            foreach (DictionaryEntry dictionaryEntry in this.Resources)
            {
                if (dictionaryEntry.Value is PLCTag)
                {
                    Tags.Add((PLCTag)dictionaryEntry.Value);
                }
            }

            try
            {
                //Verbindungskonfig laden und Verbinden
                myConn = new PLCConnection("ExampleWPFVisualization");
                myConn.Connect();
            }
            catch (Exception ex)
            {
                lblStatus.Content = ex.Message;
            }
            //Tags im Hintergrund laden
            if (worker != null)
            {
                worker.Dispose();
            }



            //Uncomment this line, to use the VarTab Functions for Read
            //PLCConnection.VarTabData vtab = myConn.ReadValuesWithVarTabFunctions(Tags, PLCReadTriggerVarTab.EndOfCycle);

            worker = new BackgroundWorker();
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                while (!worker.CancellationPending)
                {
                    try
                    {
                        myConn.ReadValues(Tags);
                        //Uncomment this line, to use the Vartab Functions for read, and comment the line above!
                        //vtab.RequestData();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            };

            worker.RunWorkerAsync();
        }
        private void cmdConnect_Click(object sender, RoutedEventArgs e)
        {
            cmdConnect.IsEnabled = false;
            cmdStop.IsEnabled = true;

            //Alle Tags in eine Liste packen
            List<PLCTag> Tags = new List<PLCTag>();
            foreach (DictionaryEntry dictionaryEntry in this.Resources)
            {
                if (dictionaryEntry.Value is PLCTag)
                    Tags.Add((PLCTag) dictionaryEntry.Value);
            }

            try
            {
                //Verbindungskonfig laden und Verbinden
                myConn = new PLCConnection("ExampleWPFVisualization");
                myConn.Connect();
            }
            catch (Exception ex)
            {
                lblStatus.Content = ex.Message;
            }
            //Tags im Hintergrund laden
            if (worker != null)
            {
                worker.Dispose();
            }


            
            //Uncomment this line, to use the VarTab Functions for Read
            //PLCConnection.VarTabData vtab = myConn.ReadValuesWithVarTabFunctions(Tags, PLCReadTriggerVarTab.EndOfCycle);

            worker = new BackgroundWorker();
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += delegate(object s, DoWorkEventArgs args)
                                 {
                                     while (!worker.CancellationPending)
                                     {
                                         try
                                         {
                                             myConn.ReadValues(Tags);
                                             //Uncomment this line, to use the Vartab Functions for read, and comment the line above!
                                             //vtab.RequestData();                                             
                                         }
                                         catch (Exception ex)
                                         {
                                         }
                                     }
                                 };

            worker.RunWorkerAsync();
        }
Beispiel #3
0
 private void DoConnect()
 {
     try
     {
         lblStatus.Text = "";
         myConn         = new PLCConnection("Toolreader");
         myConn.Connect();
         lblStatus.Text = "Connected!";
     }
     catch (Exception ex)
     {
         lblStatus.Text = ex.Message;
     }
 }
Beispiel #4
0
 private void cmdConnect_Click(object sender, EventArgs e)
 {
     try
     {
         lblStatus.Text = "";
         myConn         = new PLCConnection("ReadSpeedTest");
         myConn.Connect();
         lblStatus.Text = "Connected!";
     }
     catch (Exception ex)
     {
         lblStatus.Text = ex.Message;
     }
 }
Beispiel #5
0
 private void cmdConnect_Click(object sender, EventArgs e)
 {
     try
     {
         lblStatus.Text = "";
         myConn = new PLCConnection("ReadSpeedTest");
         myConn.Connect();
         lblStatus.Text = "Connected!";
     }
     catch (Exception ex)
     {
         lblStatus.Text = ex.Message;
     }
 }