Beispiel #1
0
        public void mergeDates(ref List <CoupleDate> contain, ref int num, GatePacket gatePacket)
        {
            num = 0;
            int    curPosX = (int)(gatePacket.tag.stampPos[0] / 1000);
            int    inc     = (int)(gatePacket.tag.stampInc[0] / 1000);
            int    bin     = (int)gatePacket.head.bin;
            int    cellNum = (int)gatePacket.tag.cellNum;
            double value;

            if (bin == (int)DAQ_MEAS_MODE.TOF_PEAK)
            {
                for (int i = 0; i < cellNum && curPosX < maxPos; i++)
                {
                    value = gatePacket.measureDate[i];
                    int tmpIndex = (int)(curPosX / ConstParameter.DefaultPosInc);
                    //int index = (int)(curPosX / mergeUnit);
                    int        index  = (int)(curPosX / inc);
                    CoupleDate cpDate = source[index];
                    cpDate.index   = index;
                    cpDate.realPos = curPosX;
                    if (value < ConstParameter.CoupleThreshold)
                    {
                        cpDate.isOK = true;
                    }
                    else
                    {
                        cpDate.isOK = false;
                    }

                    if (index == lastCouple.index)
                    {
                        if (cpDate.isOK == false || lastCouple.isOK == false)
                        {
                            lastCouple.isOK = false;
                        }
                    }
                    else
                    {
                        CoupleDate date = contain[num++];
                        //date.index = lastCouple.index;
                        //date.realPos = lastCouple.realPos;
                        //date.isOK = lastCouple.isOK;

                        ////reset
                        //lastCouple.isOK = true;
                        //lastCouple.index = index;
                        ////lastCouple.realPos =
                        date.index   = cpDate.index;
                        date.realPos = cpDate.realPos;
                        date.isOK    = cpDate.isOK;

                        lastCouple.index   = cpDate.index;
                        lastCouple.realPos = cpDate.realPos;
                        lastCouple.isOK    = cpDate.isOK;
                    }
                    curPosX += inc;
                }
            }
        }
Beispiel #2
0
        private void view(GatePacket gatePacket)
        {
            int curXPos = (int)gatePacket.tag.stampPos[0];
            int curYPos = (int)gatePacket.tag.stampPos[1];
            int num     = (int)gatePacket.tag.cellNum;
            int inc     = (int)gatePacket.tag.stampInc[0];

            String a = curXPos + " " + curYPos + " " + num + " " + inc;

            data.Add(a);
        }
Beispiel #3
0
        public void add(GatePacket gatePacket, double range)
        {
            int curPos  = (int)gatePacket.tag.stampPos[0];
            int num     = (int)gatePacket.tag.cellNum;
            int realNum = (int)range * ConstParameter.ADSampleRate;

            //if (realNum <= ConstParameter.BscanPointNumPrePacket)
            addNoSamplingDates(gatePacket);
            //else
            //addSamplingDates(gatePacket, realNum);
        }
Beispiel #4
0
        private void updateCscan(MeasureQueueElement measureQueueElement)
        {
            int boardIndex = measureQueueElement.boardIndex;
            int id         = (int)measureQueueElement.gatePacket.head.id;
            int bin        = (int)measureQueueElement.gatePacket.head.bin;

            if (boardIndex == cscanCofig.AscanIndex && id == cscanCofig.SelectGate && bin == (int)DAQ_MEAS_MODE.AMP_PERCENT)
            {
                GatePacket gatePacket = measureQueueElement.gatePacket;
                cscanSeries.add(gatePacket);
                cscanSeries.updatePicture();
                showAscan(measureQueueElement);
                if (cscanCofig.IsSave)
                {
                    binarySerialize.SerializeWrite(gatePacket);
                }
            }
        }
Beispiel #5
0
        private void updateBscan(MeasureQueueElement measureQueueElement)
        {
            int boardIndex = measureQueueElement.boardIndex;
            int id         = (int)measureQueueElement.gatePacket.head.id;
            int bin        = (int)measureQueueElement.gatePacket.head.bin;

            if (boardIndex == bscanCofig.AscanIndex && id == (int)PacketId.BGate && bin == (int)DAQ_MEAS_MODE.GATEIN_DATA)
            {
                GatePacket gatePacket = measureQueueElement.gatePacket;
                bscanSeries.add(gatePacket, bscanCofig.Range);
                bscanSeries.updatePicture();
                //showAscan(measureQueueElement);
                if (bscanCofig.IsSave)
                {
                    binarySerialize.SerializeWrite(gatePacket);
                }
            }
        }
Beispiel #6
0
        public void mergeDates(ref List <PictureDate> contain, ref int num, GatePacket gatePacket)
        {
            int constNum = ConstParameter.BscanPointNumPrePacket;
            int index    = 0;
            int curPosX  = (int)(gatePacket.tag.stampPos[0] / 1000);
            int inc      = (int)(gatePacket.tag.stampInc[0] / 1000);
            int cellNum  = (int)gatePacket.tag.cellNum;
            int pktNum   = cellNum / constNum;

            for (int k = 0; k < pktNum && curPosX < maxPos; k++)
            {
                int start = k * constNum;

                int sourceIndex = (int)(curPosX / ConstParameter.DefaultPosInc);

                //Add
                PictureDate cur = source[sourceIndex];
                cur.realPos = curPosX;
                Array.Copy(gatePacket.measureDate, start, cur.dates, 0, constNum);

                //merge
                index = (int)(curPosX / mergeUnit);
                if (index == lastIndex)
                {
                    for (int i = 0; i < cur.dates.Length; i++)
                    {
                        lastDate[i] = Math.Max(lastDate[i], cur.dates[i]);
                    }
                }
                else
                {
                    PictureDate date = contain[num++];
                    //date[0] is the index
                    date.index = lastIndex;
                    Array.Copy(lastDate, 0, date.dates, 0, lastDate.Length);

                    lastIndex = index;
                    Array.Clear(lastDate, 0, lastDate.Length);
                }
                curPosX += inc;
            }
        }
Beispiel #7
0
        public double add(GatePacket gatePacket, int boardIndex)
        {
            if (stripSeries == null)
            {
                return(0);
            }

            if (delay == -1 || delay == 0 || range == -1 || range == 0)
            {
                int         port;
                int         userIndex = SessionHardWare.getUserIndex(assignName);
                SessionInfo info      = SessionHardWare.getSessionAttr(userIndex);
                //SessionHardWare.getInfo(assignName, out port);
                GetGateDAQ.Delay((uint)info.sessionIndex, (uint)info.port, GateType.B, ref delay);
                GetGateDAQ.Width((uint)info.sessionIndex, (uint)info.port, GateType.B, ref range);
            }

            double max = stripSeries.add(gatePacket, boardIndex, delay, range);

            return(max);
        }
Beispiel #8
0
        public void add(GatePacket gatePacket)
        {
            int    sourceID = (int)gatePacket.head.id;
            int    curXPos = (int)gatePacket.tag.stampPos[0];
            int    curYPos = (int)gatePacket.tag.stampPos[1];
            int    num = (int)gatePacket.tag.cellNum;
            byte   r = 0, g = 0, b = 0;
            double amp = 0;
            int    index;
            int    flag;

            //        if (gatePacket.tag.stampPos[0] == 0)
            //             clear();

            /*if (gatePacket.tag.stampPos[0] <= 1000 && gatePacket.tag.stampInc[0] == 1000)
             * {
             *  flag = 0;
             * }
             * else if (gatePacket.tag.stampPos[0] >= 98000 && gatePacket.tag.stampInc[0] == -1000)
             * {
             *  flag = 1;
             * }*/
            //int[] pos = new int[8192];

            if (this.rcdCnt < 500)
            {
                rcd_posx[this.rcdCnt] = (int)gatePacket.tag.stampPos[0];
                rcd_posy[this.rcdCnt] = (int)gatePacket.tag.stampPos[1];
                rcd_inc[this.rcdCnt]  = (int)gatePacket.tag.stampInc[0];

                rcd_cell[this.rcdCnt] = (int)gatePacket.tag.cellNum;

                this.rcdCnt++;
            }
            else
            {
                flag = 1;
            }


            int X;
            int Y;

            //int X = (int)Math.Round(curXPos / cscanCofig.XResolution);//X轴坐标规整
            //int Y = (int)Math.Round(curYPos / cscanCofig.YResolution);//Y轴坐标规整
            //view(gatePacket);
            for (int k = 0; k < num; k++)
            {
                amp = gatePacket.measureDate[k];
                if (cscanCofig.ScanAxisIndex == (int)ScanAxis.X)//扫描轴为X轴
                {
                    int inc = (int)((gatePacket.tag.stampInc[0] / (cscanCofig.XResolution * 1000)) * cscanCofig.XResolution * 1000);
                    X = (int)Math.Round((double)(curXPos + inc * k) / (cscanCofig.XResolution * 1000)) - 1;
                    Y = (int)Math.Round((double)curYPos / (cscanCofig.YResolution * 1000));
                }
                else //扫描轴为Y轴
                {
                    int inc = (int)(gatePacket.tag.stampInc[1] / (cscanCofig.YResolution * 1000) * cscanCofig.YResolution * 1000);
                    X = (int)Math.Round((double)curXPos / (cscanCofig.XResolution * 1000)) - 1;
                    Y = (int)Math.Round((double)(curYPos + inc * k) / (cscanCofig.YResolution * 1000));
                }


                if (X > (XSampleNum - 1))
                {
                    X = XSampleNum - 1;
                }

                if (Y > (YSampleNum - 1))
                {
                    Y = YSampleNum - 1;
                }

                if (this.rcdCnt < 500)
                {
                    rcd_X[this.rcdCnt] = X;
                    rcd_Y[this.rcdCnt] = Y;
                    this.rcdCnt++;
                }
                else
                {
                    flag = 1;
                }
                if (X >= 0 && X <= (XSampleNum - 1) && Y >= 0 && Y <= (YSampleNum - 1))
                {
                    if (RGBImage.getRGB((double)amp, ref r, ref g, ref b))
                    {
                        for (int i = 0; i < xScale; i++)
                        {
                            for (int j = 0; j < yScale; j++)
                            {
                                index                = 3 * ((Y * yScale + j) * bitmapWidth + X * xScale + i);
                                dateArray[index]     = b;
                                dateArray[index + 1] = g;
                                dateArray[index + 2] = r;
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
        public void addSamplingDates(GatePacket gatePacket, int realNum)
        {
            int constNum = ConstParameter.BscanPointNumPrePacket;
            int sourceID = (int)gatePacket.head.id;

            int curPos;
            int inc;

            if (bscanCofig.AscanIndex == (int)ScanAxis.X)
            {
                curPos = (int)gatePacket.tag.stampPos[0];
                inc    = (int)((gatePacket.tag.stampInc[0] / (bscanCofig.Resolution * 1000)) * bscanCofig.Resolution * 1000);
            }
            else
            {
                curPos = (int)gatePacket.tag.stampPos[1];
                inc    = (int)((gatePacket.tag.stampInc[1] / (bscanCofig.Resolution * 1000)) * bscanCofig.Resolution * 1000);
            }
            //int inc = (int)gatePacket.tag.stampInc[0];
            int    num = (int)gatePacket.tag.cellNum;
            int    pktNum = num / constNum;
            byte   r = 0, g = 0, b = 0;
            double amp        = 0;
            int    index      = 0;
            int    preUnit    = realNum / constNum;
            int    postUnit   = preUnit + 1;
            int    preNum     = constNum - realNum % constNum;
            int    changPoint = preNum * preUnit;


            //X = (int)Math.Round((curXPos + inc * k) / (cscanCofig.XResolution * 1000));
            //Y = (int)Math.Round(curYPos / (cscanCofig.YResolution * 1000));

            for (int k = 0; k < pktNum; k++)
            {
                int start = k * constNum;
                //int pos = curPos + inc * k;
                int pos = (int)Math.Round((curPos + inc * k) / (bscanCofig.Resolution * 1000));

                if (pos > bscanCofig.ScanLength)
                {
                    return;
                }

                for (int i = 0; i < pictureWidth; i++)
                {
                    index = (int)(i * realNum / pictureWidth);
                    if (index < changPoint)
                    {
                        amp = gatePacket.measureDate[start + index / preUnit];
                    }
                    else
                    {
                        int count = preNum + (index - changPoint) / postUnit;
                        amp = gatePacket.measureDate[start + count];
                    }

                    if (RGBImage.getRGB((double)amp, ref r, ref g, ref b))
                    {
                        if (bitmapHeight > sampleNum)//画布的高度大于采样个数
                        {
                            for (int j = (int)(pos * bitmapHeight / bscanCofig.ScanLength); j < (pos + bscanCofig.Resolution) * bitmapHeight / bscanCofig.ScanLength; j++)
                            {
                                index                = j * stride + 3 * i;
                                dateArray[index]     = b;
                                dateArray[index + 1] = g;
                                dateArray[index + 2] = r;
                            }
                        }
                        else
                        {
                            int j = (int)Math.Round(pos / bscanCofig.Resolution);//坐标规整
                            index                = j * stride + 3 * i;
                            dateArray[index]     = b;
                            dateArray[index + 1] = g;
                            dateArray[index + 2] = r;
                        }
                    }
                }
            }
        }
Beispiel #10
0
        public void addNoSamplingDates(GatePacket gatePacket)
        {
            int constNum = ConstParameter.BscanPointNumPrePacket;
            int sourceID = (int)gatePacket.head.id;
            int curPos;
            int inc;

            if (bscanCofig.AscanIndex == (int)ScanAxis.X)
            {
                curPos = (int)gatePacket.tag.stampPos[0];
                inc    = (int)((gatePacket.tag.stampInc[0] / (bscanCofig.Resolution * 1000)) * bscanCofig.Resolution * 1000);
            }
            else
            {
                curPos = (int)gatePacket.tag.stampPos[1];
                inc    = (int)((gatePacket.tag.stampInc[1] / (bscanCofig.Resolution * 1000)) * bscanCofig.Resolution * 1000);
            }
            int    num = (int)gatePacket.tag.cellNum;
            int    pktNum = num / constNum;
            byte   r = 0, g = 0, b = 0;
            double amp = 0;
            int    index;

            for (int k = 0; k < pktNum; k++)
            {
                int start = k * constNum;
                int pos   = (int)Math.Round((curPos + inc * k) / (bscanCofig.Resolution * 1000)) - 2;
                //int pos = curPos + inc * k;

                //if (pos > bscanCofig.ScanLength)
                //    return;


                position = pos;

                for (int i = 0; i < pictureHeight; i++)
                {
                    index = i * constNum / pictureHeight;
                    if (index < num)
                    {
                        amp = gatePacket.measureDate[start + index];
                    }
                    else
                    {
                        amp = 0;
                    }

                    if (RGBImage.getRGB((double)amp, ref r, ref g, ref b))
                    {
                        if (bitmapWidth > sampleNum)    //画布的高度大于采样个数
                        {
                            if (pos >= 0 && pos <= (sampleNum - 1))
                            {
                                for (int j = (int)(pos * bitmapWidth / bscanCofig.ScanLength); j < (pos + bscanCofig.Resolution) * bitmapWidth / bscanCofig.ScanLength; j++)
                                {
                                    index                = i * stride + 3 * j;
                                    dateArray[index]     = b;
                                    dateArray[index + 1] = g;
                                    dateArray[index + 2] = r;
                                }
                            }
                        }
                        else
                        {
                            int j = (int)Math.Round(curPos / bscanCofig.Resolution);    //坐标规整
                            index                = i * stride + 3 * (j - 1);
                            dateArray[index]     = b;
                            dateArray[index + 1] = g;
                            dateArray[index + 2] = r;
                        }
                    }
                }
            }
        }
Beispiel #11
0
 public double add(GatePacket gatePacket, int boardIndex)
 {
     return(0);
 }
Beispiel #12
0
        public void mergeDates(ref List <StripDate> contain, ref int num, GatePacket gatePacket)
        {
            num = 0;
            int    curPosX  = (int)(gatePacket.tag.stampPos[0] / 1000);
            int    inc      = (int)(gatePacket.tag.stampInc[0] / 1000);
            int    bin      = (int)gatePacket.head.bin;
            int    cellNum  = (int)gatePacket.tag.cellNum;
            int    numIndex = 0;
            double value;

            if (inc < 0)            //暂时解决方案,由于PosInc一直为负,DSP需解决
            {
                inc = inc * (-1);
            }

            if (bin == (int)DAQ_MEAS_MODE.TOF_PEAK)
            {
                for (int i = 0; i < cellNum && curPosX < maxPos; i++)
                {
                    value = gatePacket.measureDate[i];
                    //int tofIndex = (int)(curPosX / ConstParameter.DefaultPosInc) / ConstParameter.BufferCapacity;
                    //int arrayIndex = (int)(curPosX / ConstParameter.DefaultPosInc) % ConstParameter.BufferCapacity;
                    int tofIndex   = (int)(curPosX / inc) / ConstParameter.BufferCapacity;  //把DefaultPosInc改为inc
                    int arrayIndex = (int)(curPosX / inc) % ConstParameter.BufferCapacity;
                    while (source.Count <= tofIndex)
                    {
                        StripDate[] arrays = new StripDate[ConstParameter.BufferCapacity];
                        for (int j = 0; j < arrays.Length; j++)
                        {
                            arrays[j] = new StripDate(-1, -1);
                        }
                        source.Add(arrays);
                    }

                    StripDate[] curArray = source[tofIndex];
                    curArray[arrayIndex].tof           = value;
                    curArray[arrayIndex].isTofReceived = true;

                    if (curArray[arrayIndex].isAmpReceived && curArray[arrayIndex].isMaxInMerge)
                    {
                        StripDate date = contain[num++];
                        date.tof   = curArray[arrayIndex].tof;
                        date.amp   = curArray[arrayIndex].amp;
                        date.index = curArray[arrayIndex].index;
                    }

                    curPosX += inc;
                }
                endRealPos = Math.Max(endRealPos, curPosX - inc);
            }
            else if (bin == (int)DAQ_MEAS_MODE.AMP_PERCENT)
            {
                for (int i = 0; i < cellNum && curPosX < maxPos; i++)
                {
                    //add to the source
                    value = gatePacket.measureDate[numIndex++];

                    //int ampIndex = (int)(curPosX / ConstParameter.DefaultPosInc) / ConstParameter.BufferCapacity;
                    //int arrayIndex = (int)(curPosX / ConstParameter.DefaultPosInc) % ConstParameter.BufferCapacity;
                    int ampIndex   = (int)(curPosX / inc) / ConstParameter.BufferCapacity;  //把DefaultPosInc改为inc
                    int arrayIndex = (int)(curPosX / inc) % ConstParameter.BufferCapacity;
                    while (source.Count <= ampIndex)
                    {
                        StripDate[] arrays = new StripDate[ConstParameter.BufferCapacity];
                        for (int j = 0; j < arrays.Length; j++)
                        {
                            arrays[j] = new StripDate(-1, -1);
                        }
                        source.Add(arrays);
                    }

                    StripDate[] curArray = source[ampIndex];
                    curArray[arrayIndex].realPos       = curPosX;
                    curArray[arrayIndex].amp           = value;
                    curArray[arrayIndex].isAmpReceived = true;

                    //merge
                    //int index = (int)(curPosX / mergeUnit);
                    int index = (int)(curPosX / inc);   //把mergeUnit改为inc
                    curArray[arrayIndex].index = index;
                    if (arrayIndex == 64)
                    {
                        int dd = index;
                    }
                    if (index == lastIndex)
                    {
                        if (value > lastDate.amp)
                        {
                            lastDate.isMaxInMerge = false;
                            lastDate = curArray[arrayIndex];
                            lastDate.isMaxInMerge = true;
                        }
                    }
                    else
                    {
                        //is tof not arrive, just make a note
                        if (!lastDate.isTofReceived)
                        {
                            lastDate.index = lastIndex;
                        }

                        //arrive, just update
                        else
                        {
                            StripDate date = contain[num++];
                            date.tof     = lastDate.tof;
                            date.amp     = lastDate.amp;
                            date.index   = lastIndex;
                            date.realPos = lastDate.realPos;
                        }

                        lastIndex             = index;
                        lastDate              = curArray[arrayIndex];
                        lastDate.isMaxInMerge = true;
                    }

                    curPosX += (int)inc;
                }
                endRealPos = Math.Max(endRealPos, curPosX - (int)inc);
            }
        }