예제 #1
0
        private void button19_Click(object sender, EventArgs e)
        {
            timer3.Enabled = false;

            if (vtab != null)
            {
                vtab.Dispose();
                vtab = null;
            }
        }
        private void button19_Click(object sender, EventArgs e)
        {
            timer3.Enabled = false;

            if (vtab != null)
            {
                vtab.Dispose();
                vtab = null;
            }
        }
 private void button18_Click(object sender, EventArgs e)
 {
     vtab = myConn.ReadValuesWithVarTabFunctions(myValues, PLCTriggerVarTab.EndOfCycle);
     vtab.RequestData();
     timer3.Enabled = true;
 }
예제 #4
0
        private void BackgroundReadingProc()
        {
            CancellationTokenSource cts = new CancellationTokenSource();
            ParallelOptions         po  = new ParallelOptions();

            po.CancellationToken = cts.Token;

            try
            {
                Parallel.ForEach(_connectionDictionary, po, itm =>
                {
                    try
                    {
                        var conn = itm.Value;

                        var values = from rw in varTabRows
                                     where
                                     rw.Connection == conn &&
                                     rw.LibNoDaveValue != null
                                     select rw.LibNoDaveValue;

                        PLCConnection.VarTabReadData rq = null;

                        while (true)
                        {
                            if (readFresh && ReadTagsConfig != 0 &&
                                rq != null)
                            {
                                readFresh = false;
                                rq.Dispose();
                                rq = null;
                            }

                            if (rq == null && ReadTagsConfig != 0)
                            {
                                rq =
                                    conn.ReadValuesWithVarTabFunctions(
                                        values,
                                        (PLCTriggerVarTab)
                                        ReadTagsConfig + 1);
                            }

                            if (ReadTagsConfig == 0)
                            {
                                conn.ReadValues(values);
                            }
                            else
                            {
                                if (rq != null)
                                {
                                    rq.RequestData();
                                }
                            }

                            po.CancellationToken.ThrowIfCancellationRequested();
                        }
                    }
                    catch (ThreadAbortException ex)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                    }
                });
            }
            catch (ThreadAbortException ex)
            {
                cts.Cancel();
            }
            catch (Exception ex)
            {
            }
            cts.Cancel();
        }
예제 #5
0
 private void button18_Click(object sender, EventArgs e)
 {
     vtab = myConn.ReadValuesWithVarTabFunctions(myValues, PLCTriggerVarTab.EndOfCycle);
     vtab.RequestData();
     timer3.Enabled = true;
 }