Ejemplo n.º 1
0
 public static extern uint SetChannel(
     short handle,
     Channel channel,
     short enabled,
     CouplingType couplingType,
     Range range,
     float analogueOffset);
Ejemplo n.º 2
0
        /// <summary>Assigns default values to project variables.</summary>
        public void SetDefaults()
        {
            this.Title   = "";
            this.Rptflag = false;

            for (int i = 0; i < (int)ObjectTypes.MAX_OBJECTS; i++)
            {
                this.Nobjects[i] = 0;
            }

            this.Unitsflag = UnitSystemType.US;
            this.Flowflag  = FlowUnitsType.GPM;
            this.Statflag  = TstatType.SERIES;
            this.DefRtol   = 0.001;
            this.DefAtol   = 0.01;
            this.Solver    = SolverType.EUL;
            this.Coupling  = CouplingType.NO_COUPLING;
            this.AreaUnits = AreaUnitsType.FT2;
            this.RateUnits = RateUnitsType.DAYS;
            this.Qstep     = 300;
            this.Rstep     = 3600;
            this.Rstart    = 0;
            this.Dur       = 0;
            this.Node      = null;
            this.Link      = null;
            this.Tank      = null;
            this.D         = null;
            this.Q         = null;
            this.H         = null;
            this.Species   = null;
            this.Term      = null;
            this.Const     = null;
            this.Pattern   = null;
        }
Ejemplo n.º 3
0
        private void StartAcquisitionBtn_Click(object sender, EventArgs e)
        {
            try
            {
                _log.Info("Starts to Data acquisition.");
                string deviceDescription = DeviceIDtextBox.Text;
                waveformAiCtrl.SelectedDevice = new DeviceInformation(deviceDescription);

                if (BioFailed(errorCode))
                {
                    throw new Exception();
                }
                string DAQinputrange   = InputrangecomboBox.Text;
                string DAQaisignaltype = ConnecttypecomboBox.Text;
                string DAQCoupletype   = CoupletypecomboBox.Text;
                convertClkRate = int.Parse(SamplingTextbox.Text);
                int sectionLength = int.Parse(DataLengthtextBox.Text);
                int startChannel  = int.Parse(ChanneltextBox.Text);
                int Freqrange     = int.Parse(FreqrangetextBox.Text);
                int Minxlength    = int.Parse(FreqMintextBox.Text);
                int Maxxlength    = int.Parse(FreqMaxtextBox.Text);
                lowcutoff  = int.Parse(Lowcutoffbox.Text);
                highcutoff = int.Parse(highcutoffbox.Text);
                //Load parameter
                Conversion conversion = waveformAiCtrl.Conversion;
                conversion.ChannelStart = startChannel;
                conversion.ChannelCount = channelCount;
                conversion.ClockRate    = convertClkRate;
                Record record = waveformAiCtrl.Record;
                record.SectionCount  = sectionCount;// 'streaming' mode.
                record.SectionLength = sectionLength;
                //initial Draw parameter
                DrawClass DC = DrawClass.GetInstance();
                DC.Sampling = convertClkRate;
                DrawFFTChart DFC = DrawFFTChart.GetInstance();
                DFC.DataLength = sectionLength;
                DFC.Freqrange  = Freqrange;
                DFC.FreqMax    = Maxxlength;
                DFC.FreqMin    = Minxlength;
                DFC.Sampling   = convertClkRate;
                DrawMaxChart DMC = DrawMaxChart.GetInstance();
                DMC.DataLength = sectionLength;
                DMC.Freqrange  = Freqrange;
                DMC.FreqMax    = Maxxlength;
                DMC.FreqMin    = Minxlength;
                DMC.Sampling   = convertClkRate;
                try
                {
                    _log.Info("Load DAQ parameter");
                    //mapping inputrange - 5 to 5 V // -10 to 10 V // -1 to 1 V // 4 to 20 mA
                    switch (DAQinputrange)
                    {
                    case "-1 to 1 V":
                        inputrange = ValueRange.V_Neg1To1;
                        break;

                    case "-1.25 to 1.25 V":
                        inputrange = ValueRange.V_Neg1pt25To1pt25;
                        break;

                    case "-5 to 5 V":
                        inputrange = ValueRange.V_Neg5To5;
                        break;

                    case "-10 to 10 V":
                        inputrange = ValueRange.V_Neg10To10;
                        break;

                    case "4 to 20 mA":
                        inputrange = ValueRange.mA_4To20;
                        break;

                    default:
                        break;
                    }

                    //mapping DAQ Signal Type // Differential // SingleEnded
                    switch (DAQaisignaltype)
                    {
                    case "Differential":
                        aisignaltype = AiSignalType.Differential;
                        break;

                    case "PsuedoDifferential":
                        aisignaltype = AiSignalType.PseudoDifferential;
                        break;

                    case "SingleEnded":
                        aisignaltype = AiSignalType.SingleEnded;
                        break;

                    default:
                        break;
                    }

                    switch (DAQCoupletype)
                    {
                    case "ACCouple":
                        coupletype = CouplingType.ACCoupling;
                        break;

                    case "DCCouple":
                        coupletype = CouplingType.DCCoupling;
                        break;

                    default:
                        break;
                    }


                    foreach (AnalogInputChannel ai in waveformAiCtrl.Channels)
                    {
                        if (DAQCoupletype != "None")
                        {
                            try
                            {
                                ai.CouplingType = coupletype;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("This DAQ do not support AC/DC Couple" + ex);
                            }
                        }
                        ai.ValueRange = inputrange;
                        ai.SignalType = aisignaltype;
                        if (IEPEcheckbox.Checked == true)
                        {
                            ai.IepeType = IepeType.IEPE4mA;
                        }
                    }
                }
                catch (Exception err)
                {
                    _log.Error("Faile to Load DAQ parameter message is---" + err.Message);
                }

                // prepare the Streaming AI.
                errorCode = waveformAiCtrl.Prepare();
                if (BioFailed(errorCode))
                {
                    throw new Exception();
                }

                // The operation has been started
                // We can get samples via event handlers.
                errorCode = waveformAiCtrl.Start();
                if (BioFailed(errorCode))
                {
                    throw new Exception();
                }

                // The device is acquiring data.

                // Stop the operation if it is running.
                SamplingTextbox.Enabled     = false;
                DataLengthtextBox.Enabled   = false;
                ChanneltextBox.Enabled      = false;
                FreqrangetextBox.Enabled    = false;
                DeviceIDtextBox.Enabled     = false;
                FreqMintextBox.Enabled      = false;
                FreqMaxtextBox.Enabled      = false;
                StartAcquisitionBtn.Enabled = false;
                StopAcquisitionBtn.Enabled  = true;
                acquisitionstatus.Text      = "Status : Start reading";
                acquisitionbar.Style        = System.Windows.Forms.ProgressBarStyle.Marquee;
                _log.Info("Start Data Collection");
            }
            catch (Exception err)
            {
                errorCode = waveformAiCtrl.Stop();
                if (BioFailed(errorCode))
                {
                    throw new Exception();
                }
                waveformAiCtrl.Dispose();
                SamplingTextbox.Enabled     = true;
                DataLengthtextBox.Enabled   = true;
                ChanneltextBox.Enabled      = true;
                FreqrangetextBox.Enabled    = true;
                DeviceIDtextBox.Enabled     = true;
                FreqMintextBox.Enabled      = true;
                FreqMaxtextBox.Enabled      = true;
                StartAcquisitionBtn.Enabled = true;
                StopAcquisitionBtn.Enabled  = false;
                acquisitionstatus.Text      = "Status : Stop";
                acquisitionbar.Style        = System.Windows.Forms.ProgressBarStyle.Blocks;
                _log.Error("Start acquisition failed---" + err.Message);
                // If something wrong in this execution, print the error code on screen for tracking.
                string errStr = BioFailed(errorCode) ? " Some error occurred. And the last error code is " + errorCode.ToString()
                                                        : err.Message;
                MessageBox.Show(errStr);
            }
        }