Beispiel #1
0
        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;
            }
        }
Beispiel #2
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 #3
0
        /**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);
        }