/**Add the assignedNames of all the boards.*/ private void initializeCycleBox() { string controlName; string assignName; for (int i = 1; i <= MAXROWCOUNT; i++) { controlName = "cbCycle" + i; Control[] controls = this.Controls.Find(controlName, true); foreach (Control control in controls) { if (control is ComboBox) { (control as ComboBox).Items.Clear(); for (int j = 0; j < SessionInfo.portNum; j++) { assignName = SessionHardWare.getSessionName(j); if (assignName != null) { (control as ComboBox).Items.Add(assignName); } } } } } }
public static void setDelayDictionary(uint ascanNum, uint ascanPort, GateType type, double delay) { SessionInfo info = SessionHardWare.getSessionAttr((int)ascanNum); if (info == null) { return; } int classNum = (int)info.myHardInfo.ClassicNum; int slotNum = (int)info.myHardInfo.SlotNum; int upPort = (classNum << 16) + (slotNum << 8) + (int)ascanPort; switch (type) { case GateType.I: delayForGateI[upPort] = delay; break; case GateType.A: delayForGateA[upPort] = delay; break; case GateType.B: delayForGateB[upPort] = delay; break; case GateType.C: delayForGateC[upPort] = delay; break; } }
/**Check the cycel name of MeasurementData.*/ //Sometimes we get the datas from file, but the cycles'name are not the same with those we set. public override bool isBoardNameInMeasureCorrect() { int index; if ((measurementDataList == null) || (measurementDataList.Count == 0)) { return(true); } foreach (MeasurementData data in measurementDataList) { foreach (RowData rowData in data.rowDataList) { if (rowData.activity) { index = SessionHardWare.getUserIndex(rowData.Cycle); if (index == -1) { return(false); } } } } return(true); }
private void init() { ascanIndex = 0; txtSessionName.Text = SessionHardWare.getSessionName((int)ascanIndex); cmbSelectGate.SelectedIndex = 2; cmbScanAxis.SelectedIndex = 0; }
private int setNewGain() { int error_code = 0; bool isGainExceeds = false; List <string> worrySessionList = new List <string>(); if (isGainSetDown == true) //if Gain is already set down,then just return; { return(1); } foreach (CalibResultInfo calibResultInfo in calibResultInfoList) { double newGain = 0; double oldgain = 0; int sessionIndex; int port; if (calibResultInfo.isCalibrated == true) { SessionHardWare.getIndexPort(calibResultInfo.sessionName, out sessionIndex, out port); if (sessionIndex == -1 || port == -1) { return(error_code = -1); } error_code = GetRecieverDAQ.AnalogGain((uint)sessionIndex, (uint)port, ref oldgain); if (error_code != 0) { return(error_code); } newGain = 20 * Math.Log10(stardedAmpValue / calibResultInfo.maxValue) + oldgain; if (newGain > 84) //gain can not larger than 84 { isGainExceeds = true; worrySessionList.Add(calibResultInfo.sessionName); continue; } error_code = SetReceiverDAQ.AnalogGain((uint)sessionIndex, (uint)port, newGain); if (error_code != 0) { return(error_code); } } } if (isGainExceeds == true) { string errsession = null; foreach (string str in worrySessionList) { errsession += str + " "; } MessageBox.Show("以下通道增益值超出范围,请重新校准增益!" + errsession); } isGainSetDown = true; return(error_code); }
/// <summary> /// to identify weather the port is matched with this calibTofdColumn /// </summary> /// <param name="port"></param> /// <returns></returns> public bool isMatched(int port) { int upPort; SessionHardWare.getInfo(assignName, out upPort); if (upPort == -1) { return(false); } if (upPort == port) { return(true); } else { return(false); } }
/**Add a point. * If the point is already exist, we update it. * If the point is not exist, just set it. */ public void updatePoint(double y, int boardId, bool isGood) { string name; name = SessionHardWare.getSessionName(boardId); if (name == null) { StackTrace st = new StackTrace(new StackFrame(true)); LogHelper.WriteLog("Can not find the name of board! Board id is " + boardId, st); return; } yValue = y; isUsed = true; this.boardId = boardId; this.boardName = name; this.isGood = isGood; }
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); }
/**Set the sourceList and bind to the cycleList.*/ public override void bindToList(List <RowData> rowDataList, List <List <SingleGateSeries> > singleList, List <List <DoubleGatesSeries> > doubleList) { int cycelIndex; if (doubleList.Count == 0) { return; } if (matchList.Count != 0) { matchList.Clear(); } foreach (RowData rowData in rowDataList) { if (rowData.activity) { int port; SessionHardWare.getInfo(rowData.Cycle, out cycelIndex, out port); if ((cycelIndex < 0) || (port < 0) || (cycelIndex >= singleList.Count)) { continue; } MeasureFastMatch fastMatch = new MeasureFastMatch(cycelIndex, port, rowData.Source); if (!matchList.Contains(fastMatch)) { matchList.Add(fastMatch); } if (!doubleList[cycelIndex].Contains(this)) { doubleList[cycelIndex].Add(this); } } } }
private void addCycelItems() { if (cycel == null) { return; } if (cycel.Items.Count != 0) { cycel.Items.Clear(); } string assignName; for (int i = 0; i < SessionInfo.portNum; i++) { assignName = SessionHardWare.getSessionName(i); if (assignName != null) { cycel.Items.Add(assignName); } } }
/**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); }