private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (_myconn == null)
            {
                _myconn = new PLCConnection(_connname);
                _myconn.Connect();

                foreach (string itm in _myconn.PLCListBlocks(PLCBlockType.AllEditableBlocks))
                {
                    BlockList.Items.Add(itm);
                }
            }
            else
            {
                if (dispatcherTimer != null)
                {
                    dispatcherTimer.Stop();
                }
                if (myDiag != null)
                {
                    myDiag.Close();
                    myDiag.RemoveDiagnosticData();
                    textEditor.Text = myBlock.ToString();
                }
                _myconn.Dispose();
                _myconn = null;
                myDiag  = null;
                BlockList.Items.Clear();
                blockName.Content  = "FCxx";
                Upload.IsEnabled   = false;
                Optimize.IsEnabled = false;
                Diag.IsEnabled     = false;
            }
        }
 public override void Dispose()
 {
     if (myThread != null)
     {
         myThread.Abort();
     }
     if (_plcConnection != null)
     {
         _plcConnection.Dispose();
     }
 }
        private void tryConnect_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            PLCConnection tmpConn = null;

            try
            {
                var backup = myConfig.ConfigurationType;
                myConfig.ConfigurationType = LibNodaveConnectionConfigurationType.ObjectSavedConfiguration;
                tmpConn = new PLCConnection(myConfig);
                myConfig.ConfigurationType = backup;

                tmpConn.Connect();
                changeStatusLabel("Connected!");
                try
                {
                    var szlDat = tmpConn.PLCGetSZL(0x0111, 1);
                    if (szlDat.SZLDaten.Length > 0)
                    {
                        xy11Dataset xy11Szl = szlDat.SZLDaten[0] as xy11Dataset;
                        if (xy11Szl != null)
                        {
                            changeStatusLabel("Connected! (MLFB:" + xy11Szl.MlfB + ")");
                        }
                    }
                }
                catch (Exception ex)
                { }
                tmpConn.Dispose();
            }
            catch (Exception ex)
            {
                changeStatusLabel(ex.Message);
                tmpConn.Dispose();
            }
            finally
            {
                enableCmdTest();
            }
        }
Beispiel #4
0
 private void watchToolStripMenuItem_Click(object sender, EventArgs e)
 {
     lblStatus.Text = "";
     try
     {
         if (myConn != null)
         {
             myConn.Dispose();
         }
         myConn = new PLCConnection((string)lstConnections.SelectedItem);
         myConn.Connect();
         fetchPLCData.Enabled = true;
     }
     catch (Exception ex)
     {
         lblStatus.Text = ex.Message;
     }
     //myConn.Disconnect();
 }
Beispiel #5
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            timer2.Enabled = false;

            if (backgroundWorker1.IsBusy)
            {
                backgroundWorker1.CancelAsync();
            }
            myConn.Dispose();


            button2.Enabled = true;
            lblConn.Visible = false;
            timer1.Enabled  = false;
            button7.Enabled = true;
            button6.Enabled = true;
            button4.Enabled = false;

            label2.Text     = "Not Connected";
            button6.Enabled = false;
        }
 private void DownloadBlock_FormClosing(object sender, FormClosingEventArgs e)
 {
     myConn.Dispose();
 }
        private void tryConnect_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            PLCConnection tmpConn = null;
            try
            {
                var backup = myConfig.ConfigurationType;
                myConfig.ConfigurationType = LibNodaveConnectionConfigurationType.ObjectSavedConfiguration;
                tmpConn = new PLCConnection(myConfig);
                myConfig.ConfigurationType = backup;

                tmpConn.Connect();
                changeStatusLabel("Connected!");
                try
                {
                    var szlDat = tmpConn.PLCGetSZL(0x0111, 1);
                    if (szlDat.SZLDaten.Length > 0)
                    {
                        xy11Dataset xy11Szl = szlDat.SZLDaten[0] as xy11Dataset;
                        if (xy11Szl != null)
                            changeStatusLabel("Connected! (MLFB:" + xy11Szl.MlfB + ")");
                    }
                }
                catch (Exception ex)
                { }
                tmpConn.Dispose();
                
            }
            catch (Exception ex)
            {
                changeStatusLabel(ex.Message);
                tmpConn.Dispose();
            }
            finally
            {
                enableCmdTest();
            }
        }