Esempio n. 1
0
        /// <summary>
        /// Runs continuous measurement with the signals that were added to the measurement
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        public void RunContinuousMeasurementBt_Click(out string errormess, out double[] DoubleSignal0, out double[] DoubleSignal1, out double[] DoubleSignal2, out double[] DoubleSignal3)
        {
            errormess = "";
            List <double> Signal10 = new List <double>();
            List <double> Signal11 = new List <double>();
            List <double> Signal12 = new List <double>();
            List <double> Signal13 = new List <double>();

            DoubleSignal0 = new double[1000];
            DoubleSignal1 = new double[1000];
            DoubleSignal2 = new double[1000];
            DoubleSignal3 = new double[1000];
            try
            {
                // run continuous measurement with the signals that were added to the measurement
                Measurement.StartDaq(DataAcquisitionMode.TimestampSynchronized);
                runMeasurement = true;
                int count = 0;
                while (runMeasurement && count < 1000)
                {
                    // update measurement values of the signals that were added to the measurement:
                    Measurement.FillMeasurementValues();
                    // FillMeasurements updates the ContinuousMeasurementValues from all signals that
                    // were added to the measurement
                    // The next call of FillMeasurementValues will overwrite them again with new values....

                    // check signals that were added for measurement for new measurement values...
                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //      signalsToMeasure[0].Name,
                    //      signalsToMeasure[0].ContinuousMeasurementValues.UpdatedValueCount,
                    //      signalsToMeasure[0].ContinuousMeasurementValues.Timestamps[0],
                    //      signalsToMeasure[0].ContinuousMeasurementValues.Values[0]));
                    Signal10.Insert(count, signalsToMeasure[0].ContinuousMeasurementValues.Values[0]);
                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //      signalsToMeasure[1].Name,
                    //      signalsToMeasure[1].ContinuousMeasurementValues.UpdatedValueCount,
                    //      signalsToMeasure[1].ContinuousMeasurementValues.Timestamps[0],
                    //      signalsToMeasure[1].ContinuousMeasurementValues.Values[0]));
                    Signal11.Insert(count, signalsToMeasure[1].ContinuousMeasurementValues.Values[0]);
                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //     signalsToMeasure[2].Name,
                    //     signalsToMeasure[2].ContinuousMeasurementValues.UpdatedValueCount,
                    //     signalsToMeasure[2].ContinuousMeasurementValues.Timestamps[0],
                    //     signalsToMeasure[2].ContinuousMeasurementValues.Values[0]));
                    Signal12.Insert(count, signalsToMeasure[2].ContinuousMeasurementValues.Values[0]);
                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //     signalsToMeasure[3].Name,
                    //     signalsToMeasure[3].ContinuousMeasurementValues.UpdatedValueCount,
                    //     signalsToMeasure[3].ContinuousMeasurementValues.Timestamps[0],
                    //     signalsToMeasure[3].ContinuousMeasurementValues.Values[0]));
                    Signal13.Insert(count, signalsToMeasure[3].ContinuousMeasurementValues.Values[0]);

                    // count = signalsToMeasure[0].ContinuousMeasurementValues.UpdatedValueCount;

                    //Application.DoEvents();// respond to GUI events
                    DoubleSignal0[count] = signalsToMeasure[0].ContinuousMeasurementValues.Values[0];
                    DoubleSignal1[count] = signalsToMeasure[1].ContinuousMeasurementValues.Values[0];
                    DoubleSignal2[count] = signalsToMeasure[2].ContinuousMeasurementValues.Values[0];
                    DoubleSignal3[count] = signalsToMeasure[3].ContinuousMeasurementValues.Values[0];
                    count++;
                }
            }
            catch (Exception ex)
            {
                errormess = ex.Message;
                //MessageBox.Show(ex.Message, ex.ToString());
            }
            //DoubleSignal0= Signal10.ToArray();
            //DoubleSignal1 = Signal11.ToArray();
            //DoubleSignal2 = Signal12.ToArray();
            //DoubleSignal3 = Signal13.ToArray();
        }
Esempio n. 2
0
        /// <summary>
        /// Runs continuous measurement with the signals that were added to the measurement
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        public void RunContinuousMeasurement(int length, int waittime, out string error)
        {
            error = "";
            try
            {
                // run continuous measurement with the signals that were added to the measurement
                Measurement.StartDaq(DataAcquisitionMode.HardwareSynchronized, 5000);
                runMeasurement = true;
                int count    = 0;
                int countsum = 0;
                while (runMeasurement && countsum < length)
                {
                    // update measurement values of the signals that were added to the measurement:
                    Measurement.FillMeasurementValues();
                    // FillMeasurements updates the ContinuousMeasurementValues from all signals that
                    // were added to the measurement
                    // The next call of FillMeasurementValues will overwrite them again with new values....

                    // check signals that were added for measurement for new measurement values...
                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //      signalsToMeasure[0].Name,
                    //  signalsToMeasure[0].ContinuousMeasurementValues.Values.Count
                    //      signalsToMeasure[0].ContinuousMeasurementValues.Timestamps[0],
                    //      signalsToMeasure[0].ContinuousMeasurementValues.Values[0]));

                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //      signalsToMeasure[1].Name,
                    //      signalsToMeasure[1].ContinuousMeasurementValues.UpdatedValueCount,
                    //      signalsToMeasure[1].ContinuousMeasurementValues.Timestamps[0],
                    //      signalsToMeasure[1].ContinuousMeasurementValues.Values[0]));

                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //     signalsToMeasure[2].Name,
                    //     signalsToMeasure[2].ContinuousMeasurementValues.UpdatedValueCount,
                    //     signalsToMeasure[2].ContinuousMeasurementValues.Timestamps[0],
                    //     signalsToMeasure[2].ContinuousMeasurementValues.Values[0]));

                    //AddToLog(string.Format("Signal {0} has {1} new measurement values \tFirst timestamp={2} \tFirst measval={3}",
                    //     signalsToMeasure[3].Name,
                    //     signalsToMeasure[3].ContinuousMeasurementValues.UpdatedValueCount,
                    //     signalsToMeasure[3].ContinuousMeasurementValues.Timestamps[0],
                    //     signalsToMeasure[3].ContinuousMeasurementValues.Values[0]));
                    if (signalsToMeasure[3].ContinuousMeasurementValues.UpdatedValueCount > 0)
                    {
                        Signal0.Add(signalsToMeasure[0].ContinuousMeasurementValues.Values[0]);
                        Signal1.Add(signalsToMeasure[1].ContinuousMeasurementValues.Values[0]);
                        Signal2.Add(signalsToMeasure[2].ContinuousMeasurementValues.Values[0]);
                        Signal3.Add(signalsToMeasure[3].ContinuousMeasurementValues.Values[0]);

                        // count = signalsToMeasure[0].ContinuousMeasurementValues.UpdatedValueCount;
                        count++;
                        countsum++;
                    }
                    //  File.AppendAllText("C:\\Users\\aliu2197\\Desktop\\11.txt", signalsToMeasure[0].ContinuousMeasurementValues.Values[0].ToString() + "\r\n",Encoding.Default);
                    //   File.AppendAllText("C:\\Users\\aliu2197\\Desktop\\12.txt", signalsToMeasure[1].ContinuousMeasurementValues.Values[0].ToString() + "\r\n", Encoding.Default);
                    //   File.AppendAllText("C:\\Users\\aliu2197\\Desktop\\13.txt", signalsToMeasure[2].ContinuousMeasurementValues.Values[0].ToString() + "\r\n", Encoding.Default);
                    //   File.AppendAllText("C:\\Users\\aliu2197\\Desktop\\14.txt", signalsToMeasure[3].ContinuousMeasurementValues.Values[0].ToString() + "\r\n", Encoding.Default);
                    System.Threading.Thread.Sleep(waittime);
                    if (signalsToMeasure[0].ContinuousMeasurementValues.Values.Count() <= count)
                    {
                        count = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;

                //    MessageBox.Show(ex.Message, ex.ToString());
            }
            //  连续采集.Click += new EventHandler(设置触发_Click);
        }