Example #1
0
        private void cmdStopConvert_Click(object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat;

            ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);

            cmdStartBgnd.Enabled   = true;
            cmdStartBgnd.Visible   = true;
            cmdStopConvert.Enabled = false;
            cmdStopConvert.Visible = false;
            cmdQuit.Enabled        = true;
            tmrCheckStatus.Enabled = false;

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            if (Status == MccDaq.MccBoard.Idle)
            {
                lblShowStat.Text = "Idle";
            }
            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");
        }
Example #2
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrCheckStatus.Tick */
        {
            tmrCheckStatus.Stop();

            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DiFunction);


            lblShowStat.Text  = Status.ToString("0");
            lblShowCount.Text = CurCount.ToString("0");
            lblShowIndex.Text = CurIndex.ToString("0");
            if (Status == MccDaq.MccBoard.Running)
            {
                lblBGStat.Text = "Background operation running";
            }
            else
            {
                lblBGStat.Text = "Background operation idle";
            }

            if ((CurCount == NumPoints || Status == 0) || (Force == 1))
            {
                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.DiFunction);

                ShowData();
            }
            else
            {
                tmrCheckStatus.Start();
            }
        }
Example #3
0
        private void cmdStartBgnd_Click(object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo   ULStat;
            MccDaq.ScanOptions Options;
            int  Rate;
            int  Count;
            bool ValidChan;

            cmdStartBgnd.Enabled   = false;
            cmdStartBgnd.Visible   = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;
            cmdQuit.Enabled        = false;

            //  Collect the values by calling MccDaq.MccBoard.AInScan
            //   Parameters:
            //     LowChan    :the first channel of the scan
            //     HighChan   :the last channel of the scan
            //     Count      :the total number of A/D samples to collect
            //     Rate       :sample rate
            //     Range      :the range for the board
            //     MemHandle  :Handle for Windows buffer to store data in
            //     Options    :data collection options

            ValidChan = int.TryParse(txtHighChan.Text, out HighChan);
            if (ValidChan)
            {
                if (HighChan > MaxChan)
                {
                    HighChan = MaxChan;
                }
                txtHighChan.Text = HighChan.ToString();
            }

            Count = NumPoints;     //  total number of data points to collect

            //  per channel sampling rate ((samples per second) per channel)
            Rate    = 1000 / ((HighChan - LowChan) + 1);
            Options = MccDaq.ScanOptions.Background
                      | MccDaq.ScanOptions.Continuous;

            //  collect data in background continuously
            ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options);

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text  = "Running";
                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");
            }

            tmrCheckStatus.Enabled = true;
        }
Example #4
0
        private void cmdStartBgnd_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat;
            int Rate;

            MccDaq.ScanOptions Options;
            int Count;
            int PretrigCount;

            cmdStartBgnd.Enabled   = false;
            cmdStartBgnd.Visible   = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;
            cmdQuit.Enabled        = false;
            UserTerm = 0;             // initialize user terminate flag

            MccDaq.DigitalPortDirection Direction;
            MccDaq.DigitalPortType      PortNum;

            //configure FirstPortA for digital input
            PortNum   = (MccDaq.DigitalPortType)ChanArray[1];
            Direction = MccDaq.DigitalPortDirection.DigitalIn;
            ULStat    = DaqBoard.DConfigPort(PortNum, Direction);

            // Collect the values with cbDaqInScan()
            //  Parameters:
            //    BoardNum        :the number used by CB.CFG to describe this board
            //    ChanArray[]     :array of channel values
            //    ChanTypeArray[] : array of channel types
            //    GainArray[]     :array of gain values
            //    ChansCount        :the number of elements in the arrays (0=disable queue)
            //    PretrigCount    :number of pre-trigger A/D samples to collect
            //    Count         :the total number of A/D samples to collect
            //    Rate          :sample rate in samples per second
            //    ADData[]        :the array for the collected data values
            //    Options          :data collection options

            PretrigCount = 0;
            Count        = NumElements; // Number of data points to collect
            Options      = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.Background | MccDaq.ScanOptions.Continuous;
            Rate         = 100;         // Acquire data at 100 Hz

            ULStat = DaqBoard.DaqInScan(ChanArray, ChanTypeArray, GainArray, ChanCount, ref Rate, ref PretrigCount, ref Count, MemHandle, Options);

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqiFunction);

            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text  = "Running";
                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");
            }

            tmrCheckStatus.Enabled = true;
        }
Example #5
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrCheckStatus.Tick */
        {
            int j;
            int i;
            int FirstPoint;

            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;

            tmrCheckStatus.Stop();

            //  Check the status of the background data collection

            //  Parameters:
            //    Status      :current status of the background data collection
            //    CurCount    :current number of samples collected
            //    CurIndex    :index to the data buffer pointing to the start of the
            //                 most recently collected scan
            //    FunctionType: A/D operation (MccDaq.FunctionType.AiFunction)
            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);


            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text = "Running";
            }
            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");
            if (CurCount > HighChan)
            {
                FirstPoint = CurIndex;                 // start of latest channel scan in MemHandle buffer
                ULStat     = MccDaq.MccService.WinBufToArray(MemHandle, out ADData[0], FirstPoint, 8);



                //  Use MccDaq.MccBoard.AConvertData() to convert the 16-bit values
                //  in ADData() to 12-bit values
                //  Parameters:
                //    NumPoints   :the number of data values to convert
                //    ADData     :the array holding the 16-bit data values to be converted
                //    ChanTags   :the array in which the channel information will be stored
                //ULStat = DaqBoard.AConvertData( NumPoints, ref ADData[0], out ChanTags[0]);


                for (i = 0; i <= HighChan; ++i)
                {
                    lblADData[i].Text = ADData[i].ToString("D");
                }

                for (j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }
            }

            tmrCheckStatus.Start();
        }
Example #6
0
        private void cmdStartBgnd_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat;
            int CBRate;

            MccDaq.ScanOptions Options;

            MccDaq.DigitalPortDirection Direction;
            MccDaq.DigitalPortType      PortNum;

            cmdStartBgnd.Enabled   = false;
            cmdStartBgnd.Visible   = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;
            cmdQuit.Enabled        = false;
            UserTerm = 0;             // initialize user terminate flag

            //FirstPortA is treated as a 16-bit port; therefore FirtstPortA and FirstPortB must be configured for digital output
            PortNum   = MccDaq.DigitalPortType.FirstPortA;
            Direction = MccDaq.DigitalPortDirection.DigitalOut;
            ULStat    = DaqBoard.DConfigPort(PortNum, Direction);

            PortNum   = MccDaq.DigitalPortType.FirstPortB;
            Direction = MccDaq.DigitalPortDirection.DigitalOut;
            ULStat    = DaqBoard.DConfigPort(PortNum, Direction);

            // Collect the values with cbDaqInScan()
            //  Parameters:
            //    BoardNum        :the number used by CB.CFG to describe this board
            //    ChanArray[]     :array of channel values
            //    ChanTypeArray[] : array of channel types
            //    GainArray[]     :array of gain values
            //    ChansCount      :the number of elements in the arrays (0=disable queue)
            //    Count           :the total number of A/D samples to collect
            //    CBRate          :sample rate in samples per second
            //    ADData[]        :the array for the collected data values
            //    Options         :data collection options

            Options = MccDaq.ScanOptions.Background | MccDaq.ScanOptions.Continuous | MccDaq.ScanOptions.NonStreamedIO;
            CBRate  = 1000;            // Generate data at 1000 Hz

            ULStat = DaqBoard.DaqOutScan(ChanArray, ChanTypeArray, GainArray, ChanCount, ref CBRate, Count, MemHandle, Options);

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqoFunction);

            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text  = "Running";
                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");
            }

            tmrCheckStatus.Enabled = true;
        }
Example #7
0
        private void FormClose()
        {
            //卸载快捷键
            keyList.ForEach(m => HotKey.UnregisterHotKey(Handle, m.id));

            //记录当前阅读行数
            ini.IniWriteValue(section, "ReadIndex", CurIndex.ToString().Trim());
            //记录当前透明度
            ini.IniWriteValue(section, "Opacity", Opacity.ToString());
            Close();
        }
        private void trackBarEx1_ValueChangedByMouse(object sender, EventArgs e)
        {
            lock (lockObj)
            {
                CurIndex = (int)trackBarEx1.Value + 1;
            }
            //Update info
            playIndex.Text = CurIndex.ToString() + "/" + Count.ToString();
            CrowdInfo curInfo = m_ListInfo[CurIndex - 1];

            curInfo.CameraID = cameraName;
            m_singleCrowdInfo.RefreshInfo(curInfo);
            LabelTime.Text = DataModel.Common.ConvertLinuxTime(curInfo.TimeSec).ToString();
        }
Example #9
0
        private void tmrCheckStatus_Tick(System.Object eventSender, System.EventArgs eventArgs)
        {
            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;

            // This timer will check the status of the background data collection

            // Parameters:
            //   BoardNum    :the number used by CB.CFG to describe this board
            //   Status     :current status of the background data collection
            //   CurCount   :current number of samples collected
            //   CurIndex   :index to the data buffer pointing to the start of the
            //                most recently collected scan
            //   FunctionType: A/D operation (MccDaq.FunctionType.DaqoFunction)

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqoFunction);

            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");

            // Check if the background operation has finished. If it has, then
            // transfer the data from the memory buffer set up by Windows to an
            // array for use by Visual Basic
            // The BACKGROUND operation must be explicitly stopped

            if (Status == MccDaq.MccBoard.Running && UserTerm == 0)
            {
                lblShowStat.Text = "Running";
                ULStat           = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqoFunction);

                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");
            }
            else if (Status == MccDaq.MccBoard.Idle || UserTerm == 1)
            {
                lblShowStat.Text       = "Idle";
                tmrCheckStatus.Enabled = false;

                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.DaqoFunction);

                cmdStartBgnd.Enabled   = true;
                cmdStartBgnd.Visible   = true;
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdQuit.Enabled        = true;
            }
        }
Example #10
0
        private void cmdStartBgnd_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo   ULStat;
            MccDaq.ScanOptions Options;

            cmdStartBgnd.Enabled   = false;
            cmdStartBgnd.Visible   = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;
            cmdQuit.Enabled        = false;
            UserTerm = 0;             // initialize user terminate flag

            //  Parameters:
            //    LowChan    :the lower channel of the scan
            //    HighChan   :the upper channel of the scan
            //    Count      :the number of D/A values to send
            //    Rate       :per channel sampling rate ((samples per second) per channel)
            //    DAData     :array of values to send to the scanned channels
            //    Options    :data send options
            FirstPoint = 0;
            int LowChan  = 0;                           // First analog output channel
            int HighChan = 1;                           // Last analog output channel
            int Rate     = 1000;                        // Rate of data update (ignored if board does not support timed analog output)

            MccDaq.Range Gain = MccDaq.Range.Bip5Volts; // Ignored if gain is not programmable
            Options = MccDaq.ScanOptions.Background | MccDaq.ScanOptions.Continuous | MccDaq.ScanOptions.ScaleData;
            ULStat  = DaqBoard.AOutScan(LowChan, HighChan, Count, ref Rate, Gain, MemHandle, Options);

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AoFunction);

            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text  = "Running";
                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");
            }

            tmrCheckStatus.Enabled = true;
        }
        private void tmrCheckStatus_Tick(System.Object eventSender, System.EventArgs eventArgs)
        {
            int FirstPoint;

            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;
            float EngUnits = 0;

            tmrCheckStatus.Stop();

            // This timer will check the status of the background data collection

            // Parameters:
            //   BoardNum   :the number used by CB.CFG to describe this board
            //   Status     :current status of the background data collection
            //   CurCount   :current number of samples collected
            //   CurIndex   :index to the data buffer pointing to the start of the
            //                most recently collected scan
            //   FunctionType: A/D operation (DAQIFUNCTION)

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqiFunction);

            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");

            // Check if the background operation has finished. If it has, then
            // transfer the data from the memory buffer set up by Windows to an
            // array for use by Visual Basic
            // The BACKGROUND operation must be explicitly stopped

            if (Status == MccDaq.MccBoard.Running && UserTerm == 0)
            {
                lblShowStat.Text = "Running";
                ULStat           = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqiFunction);

                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");

                FirstPoint = CurIndex;
                if (FirstPoint >= 0)
                {
                    ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, ChanCount);

                    DaqBoard.ToEngUnits(GainArray[0], ADData[0], out EngUnits);
                    lblADData[0].Text = String.Format("{0:f4}", EngUnits) + " Volts";
                    DaqBoard.ToEngUnits(GainArray[1], ADData[1], out EngUnits);
                    lblADData[1].Text = String.Format("{0:f4}", EngUnits) + " Volts";
                    lblADData[2].Text = "0x" + String.Format("{0:X2}", ADData[2]);
                    lblADData[3].Text = "0x" + String.Format("{0:X4}", ADData[3]);
                }
                tmrCheckStatus.Start();
            }
            else if (Status == MccDaq.MccBoard.Idle || UserTerm == 1)
            {
                lblShowStat.Text = "Idle";
                tmrCheckStatus.Stop();

                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.DaqiFunction);

                cmdStartBgnd.Enabled   = true;
                cmdStartBgnd.Visible   = true;
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdQuit.Enabled        = true;
            }
        }
Example #12
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)
        {
            int j;
            int i;
            int FirstPoint, NumChans;

            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;

            tmrCheckStatus.Stop();

            //  Check the status of the background data collection

            //  Parameters:
            //    Status      :current status of the background data collection
            //    CurCount    :current number of samples collected
            //    CurIndex    :index to the data buffer pointing to the start of the
            //                 most recently collected scan
            //    FunctionType: A/D operation (MccDaq.FunctionType.AiFunction)

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text = "Running";
            }
            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");
            NumChans          = (HighChan - LowChan) + 1;
            if (CurCount > HighChan)
            {
                FirstPoint = CurIndex; // start of latest channel scan in MemHandle buffer

                if (ADResolution > 16)
                {
                    ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, NumChans);

                    for (i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData32[i].ToString("D");
                    }
                }
                else
                {
                    ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, NumChans);

                    for (i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData[i].ToString("D");
                    }
                }

                for (j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }
            }

            tmrCheckStatus.Start();
        }
Example #13
0
        private void cmdStartBgnd_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat;
            int    CBRate;
            object Options;
            int    CBCount;
            int    PretrigCount;

            MccDaq.TriggerSource      TrigSource;
            MccDaq.TriggerSensitivity TrigSense;
            int TrigChan;

            MccDaq.ChannelType ChanType;
            MccDaq.Range       Gain;
            float Variance;
            float Level;

            MccDaq.TriggerEvent TrigEvent;

            int Direction;
            int PortNum;

            cmdStartBgnd.Enabled   = false;
            cmdStartBgnd.Visible   = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;
            cmdQuit.Enabled        = false;
            UserTerm = 0;             // initialize user terminate flag

            lblADData[0].Text = "";
            lblADData[1].Text = "";
            lblADData[2].Text = "";

            //configure FirstPortA for digital input
            PortNum   = ChanArray[1];
            Direction = System.Convert.ToInt32(MccDaq.DigitalPortDirection.DigitalIn);
            ULStat    = DaqBoard.DConfigPort((MccDaq.DigitalPortType)PortNum, (MccDaq.DigitalPortDirection)Direction);


            //Set Triggers
            //Parameters:
            //BoardNum    :the number used by CB.CFG to describe this board
            //TrigSource  :trigger source
            //TrigSense   :trigger sensitivity
            //TrigChan    :trigger channel
            //ChanType    :trigger channel type
            //Gain        :trigger channel gain
            //Level       :trigger Level
            //Variance    :trigger Variance
            //TrigEvent   :trigger event type

            //Start trigger settings
            //     AD conversions are enabled when analog channel 0 makes a transition from below 2 V to above.*/
            TrigSource = MccDaq.TriggerSource.TrigAnalogSW;
            TrigSense  = MccDaq.TriggerSensitivity.RisingEdge;
            TrigChan   = ChanArray[0];
            ChanType   = ChanTypeArray[0];
            Gain       = GainArray[0];
            Level      = 2;
            Variance   = 0;
            TrigEvent  = MccDaq.TriggerEvent.Start;

            //Set start trigger
            ULStat = DaqBoard.DaqSetTrigger(TrigSource, TrigSense, TrigChan, ChanType, Gain, Level, Variance, TrigEvent);

            //Stop trigger settings
            //  AD conversions are terminated when counter 0 reaches 100 counts.*/
            TrigSource = MccDaq.TriggerSource.TrigCounter;
            TrigSense  = MccDaq.TriggerSensitivity.AboveLevel;
            TrigChan   = ChanArray[2];
            ChanType   = ChanTypeArray[2];
            Gain       = GainArray[2];
            Level      = 100;
            Variance   = 0;
            TrigEvent  = MccDaq.TriggerEvent.Stop;

            //Set stop trigger
            ULStat = DaqBoard.DaqSetTrigger(TrigSource, TrigSense, TrigChan, ChanType, Gain, Level, Variance, TrigEvent);

            // Collect the values with cbDaqInScan()
            //  Parameters:
            //    BoardNum        :the number used by CB.CFG to describe this board
            //    ChanArray[]     :array of channel values
            //    ChanTypeArray[] : array of channel types
            //    GainArra[]      :array of gain values
            //    ChansCount      :the number of elements in the arrays (0=disable queue)
            //    PretrigCount    :number of pre-trigger A/D samples to collect
            //    CBCount         :the total number of A/D samples to collect
            //    CBRate          :sample rate in samples per second
            //    ADData[]        :the array for the collected data values
            //    Options         :data collection options

            PretrigCount = 0;
            CBCount      = NumElements;        // Number of data points to collect

            Options = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.Background | MccDaq.ScanOptions.Continuous | MccDaq.ScanOptions.ExtTrigger;
            CBRate  = 100;            // Acquire data at 100 Hz

            ULStat = DaqBoard.DaqInScan(ChanArray, ChanTypeArray, GainArray, ChanCount, ref CBRate, ref PretrigCount, ref CBCount, MemHandle, (MccDaq.ScanOptions)Options);

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DaqiFunction);

            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStartTrig.Text = "Waiting for trigger...";
                lblShowStopTrig.Text  = "";
                lblShowStat.Text      = "Running";
                lblShowCount.Text     = CurCount.ToString("D");
                lblShowIndex.Text     = CurIndex.ToString("D");
            }

            tmrCheckStatus.Enabled = true;
        }
Example #14
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)
        {
            int j;
            int i;

            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;

            tmrCheckStatus.Stop();

            //  This timer will check the status of the background data collection

            //  Parameters:
            //    Status     :current status of the background data collection
            //    CurCount   :current number of samples collected
            //    CurIndex   :index to the data buffer pointing to the start of the
            //                most recently collected scan
            //    FunctionType: A/D operation (AiFunction)

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");

            //  Check if the background operation has finished. If it has, then
            //  transfer the data from the memory buffer set up by Windows to an
            //  array for use by Visual this program
            //  The background operation must be explicitly stopped

            if ((Status == MccDaq.MccBoard.Running) && (UserTerm == 0))
            {
                lblShowStat.Text = "Running";
                tmrCheckStatus.Start();
            }
            else if ((Status == MccDaq.MccBoard.Idle) || (UserTerm == 1))
            {
                lblShowStat.Text = "Idle";
                ULStat           = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

                lblShowCount.Text      = CurCount.ToString("D");
                lblShowIndex.Text      = CurIndex.ToString("D");
                tmrCheckStatus.Enabled = false;

                if (ADResolution > 16)
                {
                    ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, NumPoints);

                    for (i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData32[i].ToString("D");
                    }
                }
                else
                {
                    ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, NumPoints);

                    for (i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData[i].ToString("D");
                    }
                }

                for (j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }

                // always call StopBackground upon completion...
                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);

                cmdStartBgnd.Enabled   = true;
                cmdStartBgnd.Visible   = true;
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdQuit.Enabled        = true;
            }
        }
Example #15
0
        private void cmdStartBgnd_Click(object eventSender, System.EventArgs eventArgs) /* Handles cmdStartBgnd.Click */
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo   ULStat;
            MccDaq.Range       Range;
            MccDaq.ScanOptions Options;
            int Rate;
            int Count;
            int LowChan;

            cmdStartBgnd.Enabled   = false;
            cmdStartBgnd.Visible   = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;
            cmdQuit.Enabled        = false;
            UserTerm = 0; //  initialize user terminate flag

            //  Collect the values by calling MccDaq.MccBoard.AInScan function
            //   Parameters:
            //     LowChan    :the first channel of the scan
            //     HighChan   :the last channel of the scan
            //     Count      :the total number of A/D samples to collect
            //     Rate       :sample rate
            //     Range      :the range for the board
            //     MemHandle  :Handle for Windows buffer to store data in
            //     Options    :data collection options
            LowChan  = 0;                           //  first channel to acquire
            HighChan = int.Parse(txtHighChan.Text); //  last channel to acquire
            if ((HighChan > 7))
            {
                HighChan = 7;
            }
            txtHighChan.Text = HighChan.ToString();

            Count = NumPoints; //  total number of data points to collect
            Rate  = 390;       //  per channel sampling rate ((samples per second) per channel)

            Options = MccDaq.ScanOptions.ConvertData | MccDaq.ScanOptions.Background | MccDaq.ScanOptions.SingleIo;

            Range = MccDaq.Range.Bip5Volts; //  set the range


            ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options);



            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);



            if (Status == MccDaq.MccBoard.Running)
            {
                lblShowStat.Text  = "Running";
                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");
            }

            tmrCheckStatus.Enabled = true;
        }