/**Copy the datas to the queue of boardStatus.*/ private void copyToStatusPacket(BoardStatusSetPacket statusPacket, UniSetPacket setPacket) { //DEFINATION ItemHeader head; UploadTagHeader tag; BoardStatus status; int uintOffset; //INIT head = statusPacket.head; tag = statusPacket.tag; status = statusPacket.status; uintOffset = 0; //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; //status status.status = setPacket.ud[uintOffset++]; status.errCode = (int)setPacket.ud[uintOffset++]; status.beatHeart = setPacket.ud[uintOffset++]; }
/**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); }
public static int daqRead(uint index, ref UniSetPacket setPacket) { int error_code; const uint DOBLOCK = 1; error_code = DAQ.USCOMM_Read(index, ref setPacket, DOBLOCK); return(error_code); }
/**Copy the datas to the queue of ascanStatus.*/ private void copyToAscanPacket(AscanSetPacket ascanPacket, UniSetPacket setPacket) { //DEFINATION ItemHeader head; UploadTagHeader tag; AscanVideo ascan; int uintOffset; int floatOffset; //INIT head = ascanPacket.head; tag = ascanPacket.tag; ascan = ascanPacket.ascan; uintOffset = 0; floatOffset = 0; //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; //ascan uint ascan.len = setPacket.ud[uintOffset++]; ascan.ifStart = setPacket.ud[uintOffset++]; ascan.tofUnit = setPacket.ud[uintOffset++]; ascan.ampUnit = setPacket.ud[uintOffset++]; ascan.echoMax = setPacket.ud[uintOffset++]; ascan.waveDetectMode = setPacket.ud[uintOffset++]; ascan.envelopStart = setPacket.ud[uintOffset++]; Array.Copy(setPacket.ud, uintOffset, ascan.led, 0, 8); uintOffset += 8; //ascan double ascan.delay = setPacket.fd[floatOffset++]; ascan.width = setPacket.fd[floatOffset++]; ascan.gain = setPacket.fd[floatOffset++]; ascan.bea = setPacket.fd[floatOffset++]; ascan.decayFactor = setPacket.fd[floatOffset++]; Array.Copy(setPacket.fd, floatOffset, ascan.ascanGateAmp, 0, 4); floatOffset += 4; Array.Copy(setPacket.fd, floatOffset, ascan.ascanGateTof, 0, 4); floatOffset += 4; Array.Copy(setPacket.fd, floatOffset, ascan.wave, 0, ascan.len); floatOffset += (int)ascan.len; Array.Copy(setPacket.fd, floatOffset, ascan.maxEnvelop, 0, ascan.len); floatOffset += (int)ascan.len; Array.Copy(setPacket.fd, floatOffset, ascan.minEnvelop, 0, ascan.len); floatOffset += (int)ascan.len; }
public MergeInQueueElement() { isEnd = false; setPacket = new UniSetPacket(); setPacket.start = new uint[2]; setPacket.stampPos = new int[3]; setPacket.stampInc = new int[3]; setPacket.ud = new uint[ConstParameter.MaxUintArrayCount]; setPacket.fd = new float[ConstParameter.MaxFloatArrayCount]; setPacket.stop = new uint[2]; }
/**Get the datas ande enqueue.*/ private bool parsePacket(UniSetPacket setPacket, int boardIndex) { //DEFINATION uint tmpId; bool isEnqueSuccess; //INIT tmpId = setPacket.id; isEnqueSuccess = false; //PROCESSING //Check start if (setPacket.start[0] != ConstParameter.StartLowFlag || setPacket.start[1] != ConstParameter.StartHighFlag) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Check code of start unmatched!", st); return(false); } //Check stop if (setPacket.stop[0] != ConstParameter.StopLowFlag || setPacket.stop[1] != ConstParameter.StopHighFlag) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Check code of stop unmatched!", st); return(false); } //Check the id if (!Enum.IsDefined(typeof(PacketId), (int)setPacket.id)) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Packet ID is not defined!", st); return(false); } if (tmpId == (uint)PacketId.none) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Packet ID is 0!", st); return(false); } else if (tmpId <= (uint)PacketId.CI2Gate || tmpId == (uint)PacketId.couple || tmpId == (uint)PacketId.eventId) { measureQueueElement.boardIndex = boardIndex; copyToMeasurement(measureQueueElement.gatePacket, setPacket); isEnqueSuccess = measureQueue.Enqueue(measureQueueElement); if (!isEnqueSuccess) { return(false); } } else if (tmpId == (uint)PacketId.alarmDisp) { //Alarm return(true); } else { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Packet ID is large than 256!", st); return(false); } return(isEnqueSuccess); }
/**Get the datas ande enqueue.*/ private bool parsePacket(UniSetPacket setPacket) { //DEFINATION uint tmpId; bool isEnqueSuccess; //INIT tmpId = setPacket.id; isEnqueSuccess = false; //PROCESSING //Check start if (setPacket.start[0] != ConstParameter.StartLowFlag || setPacket.start[1] != ConstParameter.StartHighFlag) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Check code of start unmatched!", st); return(false); } //Check stop if (setPacket.stop[0] != ConstParameter.StopLowFlag || setPacket.stop[1] != ConstParameter.StopHighFlag) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Check code of stop unmatched!", st); return(false); } //Check the id if (!Enum.IsDefined(typeof(PacketId), (int)setPacket.id)) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Packet ID is not defined!", st); return(false); } if (tmpId == (uint)PacketId.none) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Packet ID is 0!", st); return(false); } else if (tmpId <= (uint)PacketId.alarmDisp || tmpId == (uint)PacketId.couple || tmpId == (uint)PacketId.eventId) { if (tmpId == (uint)PacketId.eventId) { tmpId = (uint)PacketId.eventId; } //Gate, Gate2, Alarm, just forward mergeInQueueElement.setPacket = setPacket; isEnqueSuccess = mergeInQueue.EnqueueWithSemaphor(mergeInQueueElement); if (!isEnqueSuccess) { return(false); } } else if (tmpId == (uint)PacketId.ascanVedio) { //AsacnVedio copyToAscanPacket(ascanQueueElement.ascanPacket, setPacket); SessionInfo sessionAttr = SessionHardWare.getSessionAttr((int)SelectAscan.userIndex); if (!MainForm.IsToStop) { if ((int)ascanQueueElement.getPort() == sessionAttr.myHardInfo.upPort) { FormList.MDIChild.enqueue(ascanQueueElement); //FormList.MDIChild.BeginInvoke(updateCallBack); /*count++; * if (count >= 5) * { * FormList.MDIChild.BeginInvoke(updateCallBack); * count = 0; * }*/ //FormList.MDIChild.updateAscan(ascanQueueElement); //ascanUpdate.Execute(ascanQueueElement); } //Sector Scan if (FormList.Formsscan.isStart) { if (((int)ascanQueueElement.getPort() <= 512 + FormList.Formsscan.passNum - 1) && ((int)ascanQueueElement.getPort() >= 512)) { FormList.Formsscan.enqueue(ascanQueueElement, (int)ascanQueueElement.getPort() - 512); } } } return(true); //isEnqueSuccess = ascanQueue.EnqueueWithSemaphor(ascanQueueElement); //if (!isEnqueSuccess) //return false; } else if (tmpId == (uint)PacketId.status) { //Status copyToStatusPacket(boardStatusPacket, setPacket); uint status = boardStatusPacket.status.status; switch (status) { case 0x0: case 0x1: case 0x3: isBoardStatusOK = false; break; case 0x2: isBoardStatusOK = true; break; default: isBoardStatusOK = false; break; } return(true); } return(isEnqueSuccess); }
public static extern int USCOMM_Read(uint index, ref UniSetPacket setPacket, uint boolBlock);