Пример #1
0
 private void channel_values_Click(object sender, EventArgs e)
 {
     ECLib.CurrentValues cv  = default(ECLib.CurrentValues);
     ECLib.ErrorCode     err = ECLib.BL_GetCurrentValues(conn_id, selected_channel, ref cv);
     if (err != ECLib.ErrorCode.ERR_NOERROR)
     {
         MessageBox.Show("Get channel info failed: " + err.ToString());
     }
     else
     {
         MessageBox.Show(struct_dump(cv, typeof(ECLib.CurrentValues)));
     }
 }
Пример #2
0
        private void data_worker_task(object sender, DoWorkEventArgs e)
        {
            ECLib.ErrorCode err = ECLib.ErrorCode.ERR_NOERROR;
            try
            {
                BackgroundWorker bw   = sender as BackgroundWorker;
                ECLibThreadWork  work = e.Argument as ECLibThreadWork;

                bool                stop  = false;
                ECLib.DataInfos     infos = default(ECLib.DataInfos);
                ECLib.CurrentValues curr  = default(ECLib.CurrentValues);
                while (!bw.CancellationPending && !stop)
                {
                    int[] buf = new int[1000]; // needed for each iteration
                    err = ECLib.BL_GetData(work.id, work.channel, buf, ref infos, ref curr);
                    if (err == ECLib.ErrorCode.ERR_NOERROR)
                    {
                        if (infos.NbRows != 0 && infos.NbCols != 0)
                        {
                            bw.ReportProgress(0, new ECLibData {
                                Infos = infos, Curr = curr, Buf = buf
                            });
                        }
                        if (curr.State != ECLib.ChannelState.KBIO_STATE_RUN)
                        {
                            stop = true;
                        }
                    }
                    else
                    {
                        bw.ReportProgress((int)err);
                        stop = true;
                    }
                }
            }
            finally
            {
                e.Result = err;
                data_done.Set();
            }
        }