public void clear() { lastIndex = 0; lastDate = new double[ConstParameter.BscanPointNumPrePacket]; source = null; GC.Collect(); source = new List <PictureDate>(); while (source.Count < maxNum) { PictureDate pictureDate = new PictureDate(); source.Add(pictureDate); } }
public void rebuildDates(ref List <PictureDate> contain, ref int count, ref int sourceIndex, ref bool toEnd) { int maxNum = contain.Count; int tmpIndex = 0; if (sourceIndex == 0) { lastIndex = 0; lastDate = new double[ConstParameter.BscanPointNumPrePacket]; } while (tmpIndex < maxNum) { if (sourceIndex < source.Count) { PictureDate cur = source[sourceIndex]; int index = (int)(cur.realPos / 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[tmpIndex++]; date.index = lastIndex; Array.Copy(lastDate, 0, date.dates, 0, lastDate.Length); lastIndex = index; Array.Clear(lastDate, 0, lastDate.Length); } } else { toEnd = true; break; } sourceIndex++; } count = tmpIndex; }
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; } }
/**The constructor * @param diameter the diameter of the pipeline, mm * .*/ public PictureDateService(double diameter) { double l = 2 * 3.14 * diameter; mergeUnit = l / 360 * ConstParameter.AnglePreUnit; //distantce for 2° maxPos = l; source = new List <PictureDate>(); lastIndex = 0; lastDate = new double[ConstParameter.BscanPointNumPrePacket]; int maxHeight = (int)(l / ConstParameter.DefaultPosInc * 1.2); //the max num of the array the stroge the datas maxNum = maxHeight + 1; while (source.Count < maxNum) { PictureDate pictureDate = new PictureDate(); source.Add(pictureDate); } }