/**Copy the datas to the queue of measurement.*/ private void copyToMeasurement(GatePacket gatePacket, UniSetPacket setPacket) { //DEFINATION ItemHeader head; UploadTagHeader tag; //INIT head = gatePacket.head; tag = gatePacket.tag; //PROCESSING //head head.port = setPacket.port; head.id = setPacket.id; head.bin = setPacket.bin; head.size = setPacket.size; //tag tag.stampMode = setPacket.stampMode; Array.Copy(setPacket.stampPos, tag.stampPos, 3); Array.Copy(setPacket.stampInc, tag.stampInc, 3); tag.cellNum = setPacket.cellNum; if (tag.cellNum > ConstParameter.MaxMeasureDataLength) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Cell number is larger than max measure data length!", st); tag.cellNum = ConstParameter.MaxMeasureDataLength; } Array.Copy(setPacket.fd, gatePacket.measureDate, tag.cellNum); }
/**Add points which are get from measureUIThread.*/ public override void updataFastLine(GatePacket gatePacket, int boardIndex) { if (!tchart.InvokeRequired) { updatePoints(gatePacket, boardIndex); } else { if (updatePointsFunc == null) { updatePointsFunc = new updatePointsCallback(updataFastLine); } tchart.Invoke(updatePointsFunc, gatePacket, boardIndex); } }
public MeasureQueueElement() { isEnd = false; boardIndex = -1; gatePacket = new GatePacket(); }
private void updatePoints(GatePacket gatePacket, int boardIndex) { int sourceID = (int)gatePacket.head.id; int bin = (int)gatePacket.head.bin; int port = (int)gatePacket.head.port; int curPosX = (int)gatePacket.tag.stampPos[0] + boardIndex * 20; int num = (int)gatePacket.tag.cellNum; double tmpYValue, preYValue; int index; bool isFinded; bool isGood; bool isMax; TChartFastLine ft; MapPoints points; if (bin == (int)DGateMeasMode.ThicknessMax) { ft = this.maxFt; points = this.maxPoints; isMax = true; } else if (bin == (int)DGateMeasMode.ThicknessMin) { ft = this.minFt; points = this.minPoints; isMax = false; } else { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("The bin for double gates is unrecognized!", st); return; } if (points == null) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("The class for storaging the points is null!", st); return; } if (num >= ConstParameter.MaxMeasureDataLength) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("The cell num in measurement package is large than " + ConstParameter.MaxMeasureDataLength, st); return; } //Weather the boardIndex, port and sourceID are matched. isFinded = matchConfig(boardIndex, port, sourceID); if (!isFinded) { return; } if (gatePacket.tag.stampPos[0] == 0) { clear(); } for (int i = 0; i < num; i++) { index = ft.XValues.IndexOf(curPosX); tmpYValue = gatePacket.measureDate[i]; if (tmpYValue <= 0) { continue; } //A new point. if (index < 0) { isGood = addPoint(curPosX, tmpYValue, bin); ft.Add(curPosX, tmpYValue); points.addPoint(curPosX, tmpYValue, boardIndex, isGood); } //An old point, need to check. else { preYValue = ft.YValues[index]; if (isMax) { if (tmpYValue > preYValue) { deletePoint(curPosX, preYValue, bin); ft.Delete(index); isGood = addPoint(curPosX, tmpYValue, bin); ft.Add(curPosX, tmpYValue); points.addPoint(curPosX, tmpYValue, boardIndex, isGood); } } else { if (tmpYValue < preYValue) { deletePoint(curPosX, preYValue, bin); ft.Delete(index); isGood = addPoint(curPosX, tmpYValue, bin); ft.Add(curPosX, tmpYValue); points.addPoint(curPosX, tmpYValue, boardIndex, isGood); } } } curPosX += (int)gatePacket.tag.stampInc[0]; maxAllowFt.Add(tchart.Axes.Bottom.MaxXValue, AscanMeasureMap.MaxDoubleGatesValue); minAllowFt.Add(tchart.Axes.Bottom.MaxXValue, AscanMeasureMap.MinDoubleGatesValue); } }
private void updatePoints(GatePacket gatePacket, int boardIndex) { int sourceID = (int)gatePacket.head.id; int curPosX = (int)gatePacket.tag.stampPos[0] + boardIndex * 20; int port = (int)gatePacket.head.port; int num = (int)gatePacket.tag.cellNum; double tmpYValue, preYValue; int index; bool isFinded; bool isGood; if (points == null) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("The class for stroging the points is null!", st); return; } //Weather the boardIndex and sourceID are matched. isFinded = matchConfig(boardIndex, port, sourceID); if (!isFinded) { return; } if (gatePacket.tag.stampPos[0] == 0) { clear(); } for (int i = 0; i < num; i++) { index = ft.XValues.IndexOf(curPosX); tmpYValue = gatePacket.measureDate[i]; //A new point. if (index < 0) { isGood = addPoint(curPosX, tmpYValue); ft.Add(curPosX, tmpYValue); points.addPoint(curPosX, tmpYValue, boardIndex, isGood); } //An old point, need to check. else { preYValue = ft.YValues[index]; if (Math.Abs(tmpYValue) > Math.Abs(preYValue)) { deletePoint(curPosX, preYValue); ft.Delete(index); isGood = addPoint(curPosX, tmpYValue); ft.Add(curPosX, tmpYValue); points.addPoint(curPosX, tmpYValue, boardIndex, isGood); } } curPosX += (int)gatePacket.tag.stampInc[0]; maxAllowFt.Add(tchart.Axes.Bottom.MaxXValue, AscanMeasureMap.MaxSingleGateValue); minAllowFt.Add(tchart.Axes.Bottom.MaxXValue, AscanMeasureMap.MinSingleGateValue); } }
/**Add points which are get from measureUIThread.*/ public virtual void updataFastLine(GatePacket gatePacket, int boardIndex) { }