Exemple #1
0
    //Staircase assumes that a value is valid until we get a new value.
    //In this case missalighed data not inside the range of the other series will be discared.
    public BasicDataSeries GetStaircaseSumOfSeries()
    {
        BasicDataSeries points;
        BasicDataSeries result = new BasicDataSeries();

        points = GetNextPoints();

        while (points != null)
        {
            DataPoint Sum = new DataPoint();

            foreach (DataPoint point in points.Data)
            {
                //if (point == null) {
                //	Sum = null;
                //	break;
                //}

                Sum = Sum.Add(point);
            }

            if (Sum != null && Sum.Values != null)
            {
                Sum.Timestamp = At;
                result.Data.Add(Sum);
            }

            points = GetNextPoints();
        }

        return(result);
    }
Exemple #2
0
    //
    public DataPoint SumSources(double At)
    {
        DataPoint point = null;
        double    LastTimeStamp;
        double    Values;

        foreach (Subscription conn in Sources)
        {
            if (conn.Source == null)
            {
                continue;
            }
            if (conn.LastTransmission == null)
            {
                continue;
            }
            if (conn.LastTransmission.Timestamp > At)
            {
                continue;
            }

            if (point == null)
            {
                point = conn.LastTransmission.Clone();
                continue;
            }

            point = point.Add(conn.LastTransmission);
        }

        point.Timestamp = At;

        return(point);
    }
Exemple #3
0
    public DataPoint Operation(int type)
    {
        DataPoint Res = null, FirstValid = null;
        int       nValues = 0;

        //Get the first valid point as well as the width
        foreach (DataPoint data in Data)
        {
            if (data == null)
            {
                continue;
            }

            //if (FirstValid == null)
            //    FirstValid = data;

            if (data.Values.Length > nValues)
            {
                nValues = data.Values.Length;
            }
        }

        if (nValues == 0)
        {
            return(null);
        }

        //Sum = FirstValid.Clone();
        Res        = new DataPoint();
        Res.Values = new double[nValues];


        foreach (DataPoint data in Data)
        {
            if (data == null)
            {
                continue;
            }
            if (type == 0)
            {
                Res = Res.Add(data);
            }
            else if (type == 1)
            {
                Res = Res.Div(data);
            }
        }

        return(Res);
    }
        public DataPoint SetupAndAcquire(double scanParameterValue)
        {
            DataPoint p = new DataPoint(parameters.ScanParams.ScanParameterName, scanParameterValue);

            //This is where the parameter is sent to DDS.
            dds.SetFrequency(scanParameterValue);

            //Interval between measurements. Want the sleep to be between 'frequency change' command and acquisition
            // (for the laser to settle at new frequency and lock-in to average inputs)
            Thread.Sleep(parameters.ScanParams.Sleep);

            //Reading AIs for this position in scan.
            //Note! No matter how many measurements are performed in daq.ReadAI, this only takes one number per channel.
            //Any averaging has to happen before getting added to d.
            p.Add(parameters.DAQmx.AINames, daq.ReadAI());

            return(p);
        }
Exemple #5
0
        public DataPoint SetupAndAcquire(double scanParameterValue)
        {
            DataPoint p = new DataPoint(parameters.ScanParams.ScanParameterName, scanParameterValue);

            //Interval between measurements. Want the sleep to be between 'frequency change' command and acquisition
            // (for the laser to settle at new frequency and lock-in to average inputs)
            Thread.Sleep(parameters.ScanParams.Sleep);

            //Generates an array of 0 as data.
            Random r = new Random();

            double[] emptyData = new double[parameters.DAQmx.AINames.Length];
            for (int i = 0; i < emptyData.Length; i++)
            {
                emptyData[i] = r.Next();
            }
            p.Add(parameters.DAQmx.AINames, emptyData);

            return(p);
        }