Пример #1
0
        /// <summary>
        /// 创建预制体
        /// </summary>
        /// <param name="Prefab">预制体</param>
        /// <param name="m_transPerfab">预制体父物体的transform</param>
        /// <returns></returns>
        public GameObject CreatePreObj(GameObject Prefab, Transform m_transPerfab)
        {
            GameObject obj = null;

            if (m_queue_gPreObj.Count > 0)
            {
                obj = m_queue_gPreObj.Dequeue();
            }
            else
            {
                Transform trans = null;
                trans = GameObject.Instantiate(Prefab, m_transPerfab).transform;
                //trans.localPosition = Vector3.zero;
                trans.localRotation = Quaternion.identity;
                trans.localScale    = Vector3.one;
                obj = trans.gameObject;
                obj.SetActive(false);
            }
            return(obj);
        }
        public string ToStringByLevel()
        {
            if (root == null)
            {
                return("[]");
            }

            System.Collections.Generic.Queue <BinarySearchTreeNode <T> > queue = new System.Collections.Generic.Queue <BinarySearchTreeNode <T> >(count);
            string[] arr = new string[count];
            queue.Enqueue(root);
            queue.Enqueue(null);
            BinarySearchTreeNode <T> current;
            int pos = 0;

            while (true)
            {
                current = queue.Dequeue();
                if (current != null)
                {
                    arr[pos++] = current.Value.ToString();
                    if (current.Left != null)
                    {
                        queue.Enqueue(current.Left);
                    }
                    if (current.Right != null)
                    {
                        queue.Enqueue(current.Right);
                    }
                }
                else
                {
                    if (queue.Count == 0)
                    {
                        break;
                    }
                    queue.Enqueue(null);
                }
            }

            return($"[{string.Join(",", arr)}]");
        }
Пример #3
0
        public int MinDepth(Node Root)
        {
            /*
             * Level Order traversal
             * Maintain level.
             * When find first leaf return
             */

            System.Collections.Generic.Queue <Node> queue  = new System.Collections.Generic.Queue <Node>();
            System.Collections.Generic.Queue <int>  levels = new System.Collections.Generic.Queue <int>();

            queue.Enqueue(Root);
            levels.Enqueue(1);

            int min = int.MaxValue;

            while (queue.Count > 0)
            {
                Node node  = queue.Dequeue();
                int  level = levels.Dequeue();

                if (node.Left == null && node.Right == null)
                {
                    return(level);
                }

                if (node.Left != null)
                {
                    queue.Enqueue(node.Left);
                    levels.Enqueue(level + 1);
                }

                if (node.Right != null)
                {
                    queue.Enqueue(node.Right);
                    levels.Enqueue(level + 1);
                }
            }

            return(min);
        }
Пример #4
0
        //BFS, three methods:
        // 2 queues
        // 1 queue + dummy node
        // 1 queue (best)

        //Maintain one queue
        public IEnumerable <Node <T, U> > BFS()
        {
            var queue       = new System.Collections.Generic.Queue <Node <T, U> >();
            var currentNode = _root;

            queue.Enqueue(currentNode);
            while (queue.Count != 0)
            {
                currentNode = queue.Dequeue();
                yield return(currentNode);

                if (currentNode.HasLeftChild())
                {
                    queue.Enqueue(currentNode.LeftChild);
                }
                if (currentNode.HasRightChild())
                {
                    queue.Enqueue(currentNode.RightChild);
                }
            }
        }
Пример #5
0
    /// <summary>
    /// Writes data from the waitingPoints queue to disk.  The waitingPoints queue will be automatically updated whenever reporters report data.
    ///
    /// DoWrite() will also be automatically be called periodically according to the settings in the component inspector window, but you can invoke this manually if desired.
    /// </summary>
    public void DoWrite()
    {
        while (waitingPoints.Count > 0)
        {
            string directory = UnityEPL.GetDataPath();
            System.IO.Directory.CreateDirectory(directory);
            string filePath = System.IO.Path.Combine(directory, "unnamed_file");

            DataPoint dataPoint             = waitingPoints.Dequeue();
            string    writeMe               = "unrecognized type";
            string    extensionlessFileName = "session";//DataReporter.GetStartTime ().ToString("yyyy-MM-dd HH mm ss");
            switch (outputFormat)
            {
            case FORMAT.JSON_LINES:
                writeMe  = dataPoint.ToJSON();
                filePath = System.IO.Path.Combine(directory, extensionlessFileName + ".jsonl");
                break;
            }
            System.IO.File.AppendAllText(filePath, writeMe + System.Environment.NewLine);
        }
    }
Пример #6
0
        public static IEnumerable <GraphNode> BreadthSearch(GraphNode startGraphNode)
        {
            var visited = new HashSet <GraphNode>();
            var queue   = new System.Collections.Generic.Queue <GraphNode>();

            queue.Enqueue(startGraphNode);
            while (queue.Count != 0)
            {
                var node = queue.Dequeue();
                if (visited.Contains(node))
                {
                    continue;
                }
                visited.Add(node);
                yield return(node);

                foreach (var incidentNode in node.Edges)
                {
                    queue.Enqueue(incidentNode);
                }
            }
        }
Пример #7
0
        public void process()
        {
            Calc myCalc = new Calc();
            FSM  myFSM  = new FSM();

            int        count = _q.Count;
            Input_Data tmpData;

            for (int i = 0; i < count; i++)
            {
                tmpData = _q.Dequeue();
                System.Console.Write("SeqNum: {0}  ", tmpData.seqNum);
                if (tmpData.type.Equals(typeof(Calc_Data)))
                {
                    myCalc.doWork((Calc_Data)tmpData.data);
                }
                else if (tmpData.type.Equals(typeof(FSM_Data)))
                {
                    myFSM.doWork((FSM_Data)tmpData.data);
                }
            }
        }
Пример #8
0
        public List <GraphNode <T> > Flatten()
        {
            System.Collections.Generic.Queue <GraphNode <T> > q = new System.Collections.Generic.Queue <GraphNode <T> >();
            HashSet <GraphNode <T> > visited = new HashSet <GraphNode <T> >();

            q.Enqueue(this);

            while (q.Count != 0)
            {
                GraphNode <T> node = q.Dequeue();

                if (!visited.Contains(node))
                {
                    visited.Add(node);
                    foreach (GraphNode <T> n in node.Neighbours)
                    {
                        q.Enqueue(n);
                    }
                }
            }
            return(visited.ToList());
        }
Пример #9
0
        public bool TryDequeue(out LoggingEvent msg)
        {
            // If the queue is empty, wait for an item to be added
            // Note that this is a while loop, as we may be pulsed
            // but not wake up before another thread has come in and
            // consumed the newly added object. In that case, we'll
            // have to wait for another pulse.
            msg = null;
            var result = false;

            if (queue.Count > 0)
            {
                using (locker.Using()) {
                    if (queue.Count > 0)
                    {
                        msg    = queue.Dequeue();
                        result = true;
                    }
                }
            }
            return(result);
        }
Пример #10
0
        public List <List <T> > LevelOrderArrayByLevels()
        {
            System.Collections.Generic.Queue <Node> queue = new System.Collections.Generic.Queue <Node>();
            List <List <T> > res = new List <List <T> >();

            queue.Enqueue(Root);

            while (true)
            {
                if (queue.Count == 0)
                {
                    break;
                }

                int nodeCount = queue.Count;

                List <T> level = new List <T>();
                while (nodeCount > 0)
                {
                    Node node = queue.Dequeue();
                    level.Add(node.Value);
                    if (node.Left != null)
                    {
                        queue.Enqueue(node.Left);
                    }
                    if (node.Right != null)
                    {
                        queue.Enqueue(node.Right);
                    }

                    nodeCount--;
                }

                res.Add(level);
            }

            return(res);
        }
Пример #11
0
        public bool TryFindValue(T value, out GetIndex <K> point)
        {
            if (_root == null)
            {
                point = null;
                return(false);
            }

            // First-in, First-out list of nodes to search
            var nodesToSearch = new System.Collections.Generic.Queue <Node>();

            nodesToSearch.Enqueue(_root);

            while (nodesToSearch.Count > 0)
            {
                var nodeToSearch = nodesToSearch.Dequeue();

                if (nodeToSearch.Value.Equals(value))
                {
                    point = this._locate(nodeToSearch.Value);
                    return(true);
                }
                else
                {
                    if (nodeToSearch.LeftChild != null)
                    {
                        nodesToSearch.Enqueue(nodeToSearch.LeftChild);
                    }
                    if (nodeToSearch.RightChild != null)
                    {
                        nodesToSearch.Enqueue(nodeToSearch.RightChild);
                    }
                }
            }

            point = null;
            return(false);
        }
Пример #12
0
        private void NextInQueue()
        {
            lock (LockPoint)
            {
                bool stop;
                do
                {
                    if (_lockQueue.Count > 0)
                    {
                        var result = _lockQueue.Dequeue();
                        stop = result.TrySetResult(true);
                    }
                    else
                    {
                        stop = true;
                    }

                    if (_lockQueue.Count == 0 && !_keepQueueIfEmpty) // clear queue
                    {
                        LockPointsDictionary.Remove(_lockPointObject);
                    }
                } while (!stop);
            }
        }
Пример #13
0
        /// <summary>
        /// // to refresh your mind check video # 75, 76 in Mosh data-structure course part II
        /// </summary>
        /// <param name="label"></param>
        /// <returns></returns>
        public IList <string> TraverseBreadthFirst(string label)
        {
            var values = new List <string>();

            if (!_nodes.TryGetValue(label, out Node node))
            {
                return(values);
            }

            var visitedNodes = new HashSet <Node>();
            var queue        = new System.Collections.Generic.Queue <Node>();

            queue.Enqueue(node);
            while (queue.Count > 0)
            {
                var current = queue.Dequeue();
                if (visitedNodes.Contains(current))
                {
                    continue;
                }

                values.Add(current.Label);
                visitedNodes.Add(current);

                foreach (var neighbor in _adjacencyList[current])
                {
                    // we traverse a node only if it is not visited before
                    if (!visitedNodes.Contains(neighbor))
                    {
                        queue.Enqueue(neighbor);
                    }
                }
            }

            return(values);
        }
Пример #14
0
        void worker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            ImageDetail[] iconImgs = e.Result as ImageDetail[];

            if (iconImgs.Length > 0)
            {
                if (screen.SelectedCamera.ID == -1 ||
                    screen.SelectedCamera.ID == iconImgs[0].FromCamera)
                {
                    screen.ShowImages(iconImgs);
                }
            }


            if (imgsQueue.Count > 0)
            {
                screen.ShowProgress = true;
                worker.RunWorkerAsync(imgsQueue.Dequeue());
            }
            else
            {
                screen.ShowProgress = false;
            }
        }
Пример #15
0
        /// <summary>
        /// BFS provides us with the ability to return the same results as DFS but with the added guarantee to return the shortest-path first, based on number of edges being the cost factor. This algorithm us queue instead of stack.
        /// </summary>
        /// <param name="start"></param>
        /// <returns></returns>
        public IEnumerable <Vertex <T> > BFS_Visit(T start)
        {
            var startVert = GetVertex(start);
            var visited   = new HashSet <Vertex <T> >();
            //change stack to queue
            var queue = new System.Collections.Generic.Queue <Vertex <T> >();

            queue.Enqueue(startVert);

            while (queue.Count != 0)
            {
                var currentVert = queue.Dequeue();
                if (!visited.Add(currentVert))
                {
                    continue;
                }
                var unvisitNbr = currentVert.GetConnections().Where(n => !visited.Contains(n));
                foreach (var next in unvisitNbr.Reverse())
                {
                    queue.Enqueue(next);
                }
            }
            return(visited);
        }
Пример #16
0
        public List <GraphNode <T> > FindPath(GraphNode <T> start, GraphNode <T> end)
        {
            var path = new Dictionary <GraphNode <T>, GraphNode <T> > {
                [start] = null
            };
            var queue = new System.Collections.Generic.Queue <GraphNode <T> >();

            queue.Enqueue(start);
            while (queue.Count != 0)
            {
                var node = queue.Dequeue();
                foreach (var next in node._incidentNodes)
                {
                    if (path.ContainsKey(next))
                    {
                        continue;
                    }
                    path[next] = node;
                    queue.Enqueue(next);
                }
                if (path.ContainsKey(end))
                {
                    break;
                }
            }
            var pathItem = end;
            var result   = new List <GraphNode <T> >();

            while (pathItem != null)
            {
                result.Add(pathItem);
                pathItem = path[pathItem];
            }
            result.Reverse();
            return(result);
        }
Пример #17
0
        private Message GetNextMessage(int millis)
        {
            if (forwarder != null)
            {
                throw new InvalidOperationException("Invokeable has a task attached");
            }

            if (thread == null)
            {
                AttachCurrentThread();
            }

            if (sem.WaitOne(millis, false))
            {
                lock (queue)
                {
                    return(queue.Dequeue());
                }
            }
            else
            {
                return(null);
            }
        }
Пример #18
0
        private static IEnumerable <Point> GetPath(Labyrint labyrint,
                                                   Point from,
                                                   Point to,
                                                   int bombCount)
        {
            var visited = new HashSet <Point>();
            var queue   = new System.Collections.Generic.Queue <State>();
            var ways    = new Dictionary <Point, Point>();

            queue.Enqueue(new State(from, null, bombCount));
            while (queue.Count != 0)
            {
                var currentState = queue.Dequeue();
                visited.Add(currentState.Point);
                var neighbours = GetNeighbours(currentState.Point)
                                 .Where(x => !visited.Contains(x) && BelongsToLabyrint(labyrint, x));
                foreach (var point in neighbours)
                {
                    ways[point] = currentState.Point;
                    if (!labyrint.IsWall(point))
                    {
                        queue.Enqueue(new State(point, currentState, currentState.BombCount));
                    }
                    else if (currentState.BombCount > 0)
                    {
                        queue.Enqueue(new State(point, currentState, currentState.BombCount - 1));
                    }
                    if (point.Equals(to))
                    {
                        return(BuildPath(currentState));
                    }
                }
            }

            return(null);
        }
        private void EmitPendingBuffers(bool doAll, bool mustWait)
        {
            // When combining parallel deflation with a ZipSegmentedStream, it's
            // possible for the ZSS to throw from within this method.  In that
            // case, Close/Dispose will be called on this stream, if this stream
            // is employed within a using or try/finally pair as required. But
            // this stream is unaware of the pending exception, so the Close()
            // method invokes this method AGAIN.  This can lead to a deadlock.
            // Therefore, failfast if re-entering.

            if (emitting)
            {
                return;
            }
            emitting = true;
            if ((doAll && (_latestCompressed != _lastFilled)) || mustWait)
            {
                _newlyCompressedBlob.WaitOne();
            }

            do
            {
                int firstSkip          = -1;
                int millisecondsToWait = doAll ? 200 : (mustWait ? -1 : 0);
                int nextToWrite        = -1;

                do
                {
                    if (Monitor.TryEnter(_toWrite, millisecondsToWait))
                    {
                        nextToWrite = -1;
                        try
                        {
                            if (_toWrite.Count > 0)
                            {
                                nextToWrite = _toWrite.Dequeue();
                            }
                        }
                        finally
                        {
                            Monitor.Exit(_toWrite);
                        }

                        if (nextToWrite >= 0)
                        {
                            WorkItem workitem = _pool[nextToWrite];
                            if (workitem.ordinal != _lastWritten + 1)
                            {
                                // out of order. requeue and try again.
                                TraceOutput(TraceBits.EmitSkip,
                                            "Emit     skip     wi({0}) ord({1}) lw({2}) fs({3})",
                                            workitem.index,
                                            workitem.ordinal,
                                            _lastWritten,
                                            firstSkip);

                                lock (_toWrite)
                                {
                                    _toWrite.Enqueue(nextToWrite);
                                }

                                if (firstSkip == nextToWrite)
                                {
                                    // We went around the list once.
                                    // None of the items in the list is the one we want.
                                    // Now wait for a compressor to signal again.
                                    _newlyCompressedBlob.WaitOne();
                                    firstSkip = -1;
                                }
                                else if (firstSkip == -1)
                                {
                                    firstSkip = nextToWrite;
                                }

                                continue;
                            }

                            firstSkip = -1;

                            TraceOutput(TraceBits.EmitBegin,
                                        "Emit     begin    wi({0}) ord({1})              cba({2})",
                                        workitem.index,
                                        workitem.ordinal,
                                        workitem.compressedBytesAvailable);

                            _outStream.Write(workitem.compressed, 0, workitem.compressedBytesAvailable);
                            _runningCrc.Combine(workitem.crc, workitem.inputBytesAvailable);
                            _totalBytesProcessed        += workitem.inputBytesAvailable;
                            workitem.inputBytesAvailable = 0;

                            TraceOutput(TraceBits.EmitDone,
                                        "Emit     done     wi({0}) ord({1})              cba({2}) mtw({3})",
                                        workitem.index,
                                        workitem.ordinal,
                                        workitem.compressedBytesAvailable,
                                        millisecondsToWait);

                            _lastWritten = workitem.ordinal;
                            _toFill.Enqueue(workitem.index);

                            // don't wait next time through
                            if (millisecondsToWait == -1)
                            {
                                millisecondsToWait = 0;
                            }
                        }
                    }
                    else
                    {
                        nextToWrite = -1;
                    }
                } while (nextToWrite >= 0);
            } while (doAll && (_lastWritten != _latestCompressed || _lastWritten != _lastFilled));

            emitting = false;
        }
Пример #20
0
 /** @return the next smallest number */
 public int Next()
 {
     return(heap.Dequeue());
 }
Пример #21
0
        public void mosy_alg()
        {
            lbl_info.Text = "Working...";
            ///////iniate S /////////////
            ArrayList S            = new ArrayList();
            ArrayList S2           = new ArrayList();
            ArrayList mymeans      = new ArrayList();
            ArrayList border_point = new ArrayList();

            S.AddRange(datapoints);
            r            = int.Parse(txt_r.Text);
            nighbour_min = int.Parse(txt_neigh.Text);
            //// initiate queue
            Queue <data> q = new System.Collections.Generic.Queue <data>();

            //////Start of algorithm
            int ci = 1;

            while (S.Count != 0)
            {
                ///// take a data point randomly
                data dp            = take_data_point(S, S2, ci);
                int  cluster_count = 1;
                int  sum_x         = 0;
                int  sum_y         = 0;
                if (neigh_count(dp, r) > nighbour_min)
                {
                    sum_x = dp.point.X;
                    sum_y = dp.point.Y;
                    q.Enqueue(dp);
                }
                else
                {
                    border_point.Add(dp);
                }
                while (q.Count != 0)
                {
                    dp = q.Dequeue();
                    ArrayList remove_list = new ArrayList();
                    Boolean   nth         = false;
                    //if (neigh_count(dp, r) > nighbour_min) nth = true;

                    for (int ii = 0; ii < S.Count; ii++)
                    {
                        try
                        {
                            if (distance(dp.point, ((data)S[ii]).point) <= r)      // check the distance from point picked of queue  to point in S
                            {
                                // put the point in the queue
                                if (/*nth &&*/ neigh_count((data)S[ii], r) > nighbour_min)
                                {
                                    q.Enqueue(((data)S[ii]));
                                    //set point's set
                                    ((data)S[ii]).set = ci;
                                    Graphics gf = pic_pln.CreateGraphics();
                                    Thread.Sleep((5000 - trk_speed.Value) / 5);
                                    gf.DrawEllipse(new Pen(colors[(((data)S[ii]).set - 1) % 32], 2f), ((data)S[ii]).point.X - 1, ((data)S[ii]).point.Y - 1, 2, 2);
                                    sum_x += ((data)S[ii]).point.X;
                                    sum_y += ((data)S[ii]).point.Y;
                                    cluster_count++;
                                }
                                else
                                {
                                    border_point.Add((data)S[ii]);
                                }
                                // remove from S
                                S2.Add(((data)S[ii]));
                                remove_list.Add(ii);     //S.RemoveAt(ii);//S.Remove(((data)S[ii]));
                            }
                        }
                        catch (Exception ee)
                        {
                            MessageBox.Show("error  " + ee.Message);
                        }
                    }

                    remove_points_from_S(S, remove_list);
                }
                data mi = new data(new Point(sum_x / cluster_count, sum_y / cluster_count), ci);
                mymeans.Add(mi);
                ci++;
            }
            //clearboard();
            Border_coloring(border_point, S2);
            draw_points(S2, mymeans);
            lbl_info.Text = "Finished";
        }
Пример #22
0
        private void AcquireMarks()
        {
            int  i;
            Mark CurrentMark = new Mark();

            CurrentMark.Id = -1;
            EnterState(State.Idle);
            while (m_State != State.Invalid)
            {
                MessageType msg = MessageType.Null;
                lock (m_Messages)
                    if (m_Messages.Count == 0)
                    {
                        System.Threading.Thread.Sleep(200);
                        if (m_Messages.Count == 0)
                        {
                            msg = MessageType.Null;
                        }
                        else
                        {
                            msg = m_Messages.Dequeue();
                        }
                    }
                    else
                    {
                        msg = m_Messages.Dequeue();
                    }

                switch (m_State)
                {
                case State.Idle:
                    if (IsEnteringState)
                    {
                    }
                    switch (msg)
                    {
                    case MessageType.Stop: EnterState(State.Failed); continue;
                    }
                    IEnumerable <Mark> nextmarks = m_Marks.Where(m => m.NotFound == false && (m.XValid == false || m.YValid == false));
                    if (nextmarks.Count() == 0)
                    {
                        EnterState((m_Marks.Where(m => m.NotFound == false).Count() >= 2) ? State.Done : State.Failed);
                    }
                    else
                    {
                        CurrentMark = nextmarks.First();
                        SyncCurrentMark(CurrentMark);
                        iStage.PosMove(SySal.StageControl.Axis.X, CurrentMark.ExpectedPos.X, C.XYSpeed, C.XYAcceleration, C.XYAcceleration);
                        iStage.PosMove(SySal.StageControl.Axis.Y, CurrentMark.ExpectedPos.Y, C.XYSpeed, C.XYAcceleration, C.XYAcceleration);
                        EnterState(State.Moving);
                    }
                    break;

                case State.Moving:
                    if (IsEnteringState)
                    {
                    }
                    switch (msg)
                    {
                    case MessageType.Stop: EnterState(State.Failed); continue;

                    case MessageType.Pause:
                    {
                        iStage.Stop(StageControl.Axis.X);
                        iStage.Stop(StageControl.Axis.Y);
                        iStage.Stop(StageControl.Axis.Z);
                        EnterState(State.PauseMoving);
                    }
                        continue;
                    }
                    {
                        if (Math.Abs(iStage.GetPos(SySal.StageControl.Axis.X) - CurrentMark.ExpectedPos.X) < C.XYPosTolerance &&
                            Math.Abs(iStage.GetPos(SySal.StageControl.Axis.Y) - CurrentMark.ExpectedPos.Y) < C.XYPosTolerance)
                        {
                            EnterState(State.Acquiring);
                        }
                    }
                    break;

                case State.Acquiring:
                    if (IsEnteringState)
                    {
                    }
                    switch (msg)
                    {
                    case MessageType.Stop: EnterState(State.Failed); continue;

                    case MessageType.Pause: EnterState(State.PauseMoving); continue;

                    case MessageType.SetX:
                    {
                        CurrentMark.FoundPos.X = iStage.GetPos(SySal.StageControl.Axis.X);
                        SetText(txtFoundX, CurrentMark.FoundPos.X.ToString("F0", System.Globalization.CultureInfo.InvariantCulture));
                        CurrentMark.XValid   = true;
                        CurrentMark.NotFound = false;
                        SetText(txtFlag, (CurrentMark.XValid && CurrentMark.YValid) ? "Found" : "Not searched");
                        if (CurrentMark.YValid)
                        {
                            EnterState(State.Idle);
                        }
                    }
                    break;

                    case MessageType.SetY:
                    {
                        CurrentMark.FoundPos.Y = iStage.GetPos(SySal.StageControl.Axis.Y);
                        SetText(txtFoundY, CurrentMark.FoundPos.Y.ToString("F0", System.Globalization.CultureInfo.InvariantCulture));
                        CurrentMark.YValid   = true;
                        CurrentMark.NotFound = false;
                        SetText(txtFlag, (CurrentMark.XValid && CurrentMark.YValid) ? "Found" : "Not searched");
                        if (CurrentMark.XValid)
                        {
                            EnterState(State.Idle);
                        }
                    }
                    break;

                    case MessageType.SetNotFound:
                    {
                        CurrentMark.XValid   = CurrentMark.YValid = false;
                        CurrentMark.NotFound = true;
                        SetText(txtFlag, "Not Found");
                        EnterState(State.Idle);
                    }
                    break;

                    case MessageType.SetNotSearched:
                    {
                        CurrentMark.XValid = CurrentMark.YValid = false;
                        SetText(txtFlag, "Not Searched");
                    }
                    break;
                    }
                    {
                        /* no action here */
                    }
                    break;

                case State.PauseMoving:
                    if (IsEnteringState)
                    {
                    }
                    switch (msg)
                    {
                    case MessageType.Continue:
                    {
                        if (CurrentMark.NotFound || (CurrentMark.XValid == true && CurrentMark.YValid == true))
                        {
                            EnterState(State.Idle);
                        }
                        else
                        {
                            iStage.PosMove(SySal.StageControl.Axis.X, CurrentMark.ExpectedPos.X, C.XYSpeed, C.XYAcceleration, C.XYAcceleration);
                            iStage.PosMove(SySal.StageControl.Axis.Y, CurrentMark.ExpectedPos.Y, C.XYSpeed, C.XYAcceleration, C.XYAcceleration);
                            EnterState(State.Moving);
                        }
                    }
                        continue;

                    case MessageType.Stop: EnterState(State.Failed); continue;

                    case MessageType.SetX:
                    {
                        CurrentMark.FoundPos.X = iStage.GetPos(SySal.StageControl.Axis.X);
                        SetText(txtFoundX, CurrentMark.FoundPos.X.ToString("F0", System.Globalization.CultureInfo.InvariantCulture));
                        CurrentMark.XValid   = true;
                        CurrentMark.NotFound = false;
                        SetText(txtFlag, (CurrentMark.XValid && CurrentMark.YValid) ? "Found" : "Not searched");
                        if (CurrentMark.YValid)
                        {
                            EnterState(State.Idle);
                        }
                    }
                    break;

                    case MessageType.SetY:
                    {
                        CurrentMark.FoundPos.Y = iStage.GetPos(SySal.StageControl.Axis.Y);
                        SetText(txtFoundY, CurrentMark.FoundPos.Y.ToString("F0", System.Globalization.CultureInfo.InvariantCulture));
                        CurrentMark.YValid   = true;
                        CurrentMark.NotFound = false;
                        SetText(txtFlag, (CurrentMark.XValid && CurrentMark.YValid) ? "Found" : "Not searched");
                        if (CurrentMark.XValid)
                        {
                            EnterState(State.Idle);
                        }
                    }
                    break;

                    case MessageType.SetNotFound:
                    {
                        CurrentMark.XValid   = CurrentMark.YValid = false;
                        CurrentMark.NotFound = true;
                        SetText(txtFlag, "Not Found");
                        EnterState(State.Idle);
                    }
                    break;

                    case MessageType.SetNotSearched:
                    {
                        CurrentMark.XValid = CurrentMark.YValid = false;
                        SetText(txtFlag, "Not Searched");
                    }
                    break;

                    case MessageType.Next:
                    {
                        int im;
                        for (im = 0; m_Marks[im] != CurrentMark; im++)
                        {
                            ;
                        }
                        if (im < m_Marks.Length - 1)
                        {
                            CurrentMark = m_Marks[im + 1];
                            SyncCurrentMark(CurrentMark);
                        }
                    }
                    break;

                    case MessageType.Previous:
                    {
                        int im;
                        for (im = 0; m_Marks[im] != CurrentMark; im++)
                        {
                            ;
                        }
                        if (im > 0)
                        {
                            CurrentMark = m_Marks[im - 1];
                            SyncCurrentMark(CurrentMark);
                        }
                    }
                    break;
                    }
                    {
                        /* no action here */
                    }
                    break;

                case State.PauseAcquiring:
                    if (IsEnteringState)
                    {
                    }
                    switch (msg)
                    {
                    case MessageType.Stop: EnterState(State.Failed); continue;
                    }
                    EnterState(State.Acquiring);
                    break;

                case State.Done:
                    if (IsEnteringState)
                    {
                        iCamDisp.EnableCross = false;
                    }
                    return;

                case State.Failed:
                    if (IsEnteringState)
                    {
                        iCamDisp.EnableCross = false;
                    }
                    return;

                default:
                    m_State = State.Invalid;
                    iCamDisp.EnableCross = false;
                    return;
                }
            }
        }
Пример #23
0
        private void HandleEvents()
        {
            lock (pendingActions)
            {
                while (pendingActions.Count > 0)
                {
                    var action = pendingActions.Dequeue();
                    if (action.type == ActionData.Type.Added)
                    {
                        GameObject qrCodeObject = Instantiate(qrCodePrefab, new Vector3(0, 0, 0), Quaternion.identity);
                        qrCodeObject.GetComponent <SpatialGraphNodeTracker>().Id = action.qrCode.SpatialGraphNodeId;
                        qrCodeObject.GetComponent <QRCode>().qrCode = action.qrCode;
                        qrCodesObjectsList.Add(action.qrCode.Id, qrCodeObject);

                        //AROA EDIT - Assign object to QRCode script
                        Debug.Log("Action.qrCode.Data = " + action.qrCode.Data);
                        qrCodeObject.GetComponent <QRCode>().textToSpeech    = textToSpeech;
                        qrCodeObject.GetComponent <QRCode>().obstacleManager = obstacleManager;

                        if (action.qrCode.Data == "QR Code 1")
                        {
                            layout = "Layout 1";
                        }

                        else if (action.qrCode.Data == "QR Code 2")
                        {
                            layout = "Layout 2";
                        }

                        else if (action.qrCode.Data == "QR Code 3")
                        {
                            layout = "Layout 3";
                        }

                        else if (action.qrCode.Data == "QR Code 4")
                        {
                            layout = "Layout 4";
                        }

                        else if (action.qrCode.Data == "QR Code 5")
                        {
                            layout = "Layout 5";
                        }

                        else if (action.qrCode.Data == "QR Code 6")
                        {
                            layout = "Layout 6";
                        }

                        else if (action.qrCode.Data == "QR Code 7")
                        {
                            layout = "Layout 7";
                        }

                        else if (action.qrCode.Data == "QR Code 8")
                        {
                            layout = "Layout 8";
                        }

                        else if (action.qrCode.Data == "Demo")
                        {
                            layout = "Demo Layout";
                        }

                        else
                        {
                            layout = "Unrecognized Layout";
                        }

                        experimentLogger.layout = layout;
                        qrCodeObject.GetComponent <QRCode>().layout           = layout;
                        qrCodeObject.GetComponent <QRCode>().trackedObject    = obstacleCollection;
                        qrCodeObject.GetComponent <QRCode>().experimentLogger = experimentLogger;

                        //Assign obstacles to QR Code object
                        qrCodeObject.GetComponent <QRCode>().obstLow1  = obstLow1;
                        qrCodeObject.GetComponent <QRCode>().obstLow2  = obstLow2;
                        qrCodeObject.GetComponent <QRCode>().obstHigh1 = obstHigh1;
                        qrCodeObject.GetComponent <QRCode>().obstHigh2 = obstHigh2;
                        qrCodeObject.GetComponent <QRCode>().obstWide1 = obstWide1;
                        qrCodeObject.GetComponent <QRCode>().obstWide2 = obstWide2;
                    }
                    else if (action.type == ActionData.Type.Updated)
                    {
                        if (!qrCodesObjectsList.ContainsKey(action.qrCode.Id))
                        {
                            GameObject qrCodeObject = Instantiate(qrCodePrefab, new Vector3(0, 0, 0), Quaternion.identity);
                            qrCodeObject.GetComponent <SpatialGraphNodeTracker>().Id = action.qrCode.SpatialGraphNodeId;
                            qrCodeObject.GetComponent <QRCode>().qrCode = action.qrCode;
                            qrCodesObjectsList.Add(action.qrCode.Id, qrCodeObject);

                            //AROA EDIT
                            //QR codes created using https://www.qr-code-generator.com/
                            Debug.Log("Action.qrCode.Data = " + action.qrCode.Data);
                            qrCodeObject.GetComponent <QRCode>().textToSpeech    = textToSpeech;
                            qrCodeObject.GetComponent <QRCode>().obstacleManager = obstacleManager;


                            if (action.qrCode.Data == "QR Code 1")
                            {
                                layout = "Layout 1";
                            }

                            else if (action.qrCode.Data == "QR Code 2")
                            {
                                layout = "Layout 2";
                            }

                            else if (action.qrCode.Data == "QR Code 3")
                            {
                                layout = "Layout 3";
                            }

                            else if (action.qrCode.Data == "QR Code 4")
                            {
                                layout = "Layout 4";
                            }

                            else if (action.qrCode.Data == "QR Code 5")
                            {
                                layout = "Layout 5";
                            }

                            else if (action.qrCode.Data == "QR Code 6")
                            {
                                layout = "Layout 6";
                            }

                            else if (action.qrCode.Data == "QR Code 7")
                            {
                                layout = "Layout 7";
                            }

                            else if (action.qrCode.Data == "QR Code 8")
                            {
                                layout = "Layout 8";
                            }

                            else if (action.qrCode.Data == "Demo")
                            {
                                layout = "Demo Layout";
                            }

                            else
                            {
                                layout = "Unrecognized Layout";
                            }

                            qrCodeObject.GetComponent <QRCode>().layout           = layout;
                            qrCodeObject.GetComponent <QRCode>().trackedObject    = obstacleCollection;
                            qrCodeObject.GetComponent <QRCode>().experimentLogger = experimentLogger;

                            //Assign obstacles to QR Code object
                            qrCodeObject.GetComponent <QRCode>().obstLow1  = obstLow1;
                            qrCodeObject.GetComponent <QRCode>().obstLow2  = obstLow2;
                            qrCodeObject.GetComponent <QRCode>().obstHigh1 = obstHigh1;
                            qrCodeObject.GetComponent <QRCode>().obstHigh2 = obstHigh2;
                            qrCodeObject.GetComponent <QRCode>().obstWide1 = obstWide1;
                            qrCodeObject.GetComponent <QRCode>().obstWide2 = obstWide2;
                        }
                    }
                    else if (action.type == ActionData.Type.Removed)
                    {
                        if (qrCodesObjectsList.ContainsKey(action.qrCode.Id))
                        {
                            Destroy(qrCodesObjectsList[action.qrCode.Id]);
                            qrCodesObjectsList.Remove(action.qrCode.Id);
                        }
                    }
                }
            }
            if (clearExisting)
            {
                clearExisting = false;
                foreach (var obj in qrCodesObjectsList)
                {
                    Destroy(obj.Value);
                }
                qrCodesObjectsList.Clear();
            }
        }
Пример #24
0
 public IValue Dequeue()
 {
     return(_queue.Dequeue());
 }
Пример #25
0
    public static void Initialize(string signingIdentity, string instanceId)
    {
        if (libraryCallbackDelegate == null)
        {
            libraryCallbackDelegate = new NdnRtcLibLogHandler(ndnrtcLogHandler);
        }

        bool res;

        try {
            string version = Marshal.PtrToStringAnsi(NdnRtcWrapper.ndnrtc_getVersion());
            Debug.Log("NDN-RTC version " + version);

            res = NdnRtcWrapper.ndnrtc_init("localhost", Application.persistentDataPath, signingIdentity,
                                            instanceId, libraryCallbackDelegate);

            if (res)
            {
                LocalStreamParams p = new LocalStreamParams();

                p.basePrefix     = signingIdentity + "/" + instanceId;
                p.signingOn      = 1;
                p.dropFrames     = 1;
                p.fecOn          = 1;
                p.frameHeight    = 180;
                p.frameWidth     = 320;
                p.gop            = 30;
                p.startBitrate   = 300;
                p.maxBitrate     = 7000;
                p.ndnSegmentSize = 8000;
                p.typeIsVideo    = 1;
                p.streamName     = "back_camera";
                p.threadName     = "vp9";
                p.storagePath    = Application.persistentDataPath + "/ndnrtc_storage";

                videoStream = new LocalVideoStream(p);

                runFrameFetching_       = true;
                queueSem_               = new Semaphore(0, 30); // up to 30 requests. why not?...
                activeTasks_            = new HashSet <FrameFetchingTask>();
                frameFetchingTaskQueue_ = new System.Collections.Generic.Queue <FrameFetchingTask>();
                frameFetchingThread_    = new Thread(new ThreadStart(delegate() {
                    while (runFrameFetching_)
                    {
                        Debug.Log("[ff-task-worker]: waiting for new tasks...");
                        // lock on semaphore / event
                        queueSem_.WaitOne();

                        // deque
                        FrameFetchingTask ffTask = frameFetchingTaskQueue_.Dequeue();

                        Debug.Log("[ff-task-worker]: running task for " + ffTask.frameName_);
                        activeTasks_.Add(ffTask);
                        ffTask.run(delegate(FrameFetchingTask fft){
                            Debug.Log("[ff-task-worker]: task completed: " + fft.frameName_);
                            // cleanup when we are done
                            activeTasks_.Remove(fft);
                        });
                    } // while
                }));
                frameFetchingThread_.Start();
            }
        } catch (System.Exception e) {
            Debug.LogError("Error initializing NDN-RTC: " + e.Message);
        }
    }
        public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
        {
            if (activity == null)
                throw new ArgumentNullException("activity");

            if (action == null)
                throw new ArgumentNullException("action");

            AddedActivityAction addedAction = action as AddedActivityAction;

            if (addedAction != null)
            {
                //Check existence of nested PersistOnClose/ICompensatable/SupportsTransaction nested anywhere
                //in the added activity branch
                System.Collections.Generic.Queue<Activity> childrenQueue = new System.Collections.Generic.Queue<Activity>();
                childrenQueue.Enqueue(addedAction.AddedActivity);

                while (childrenQueue.Count != 0)
                {
                    Activity childActivity = childrenQueue.Dequeue();

                    if (childActivity.SupportsTransaction)
                        return new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT);

                    if (childActivity.PersistOnClose)
                        return new ValidationError(SR.GetString(SR.Error_NestedPersistOnClose, activity.QualifiedName), ErrorNumbers.Error_NestedPersistOnClose);

                    if (childActivity is ICompensatableActivity)
                        return new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, activity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity);

                    CompositeActivity compositeActivity = childActivity as CompositeActivity;

                    if (compositeActivity != null)
                    {
                        foreach (Activity grandChild in compositeActivity.EnabledActivities)
                        {
                            childrenQueue.Enqueue(grandChild);
                        }
                    }
                }
            }
            return base.ValidateActivityChange(activity, action);
        }
Пример #27
0
        public void pushToNetwork(LocalNetworkGamer localGamer)
        {
            int icount = outQ.Count;

            for (int i = 0; i < icount; i++)
            {
                qHeader pHead = outQ.Dequeue();

                switch (pHead.type)
                {
                case QueueType.ship_rot_anti:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_rot_anti, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_rot_clock:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_rot_clock, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_bomb:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_bomb, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_missile:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_missile, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_impulse:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_impulse, pHead.outseq, pHead.packetOwner);
                    }

                    break;


                case QueueType.EventMessage:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.EventMessage, pHead.outseq, pHead.packetOwner);
                    }

                    break;
                }
            }
        }
Пример #28
0
        // PacketWriter packetWriter2 = new PacketWriter();

        public static void PushToNetwork()
        {
            PacketWriter packetWriter2 = new PacketWriter();

            int count = outQ.Count;

            for (int i = 0; i < count; i++)
            {
                // Read the header
                QueueHdr qH = outQ.Dequeue();

                switch (qH.type)
                {
                case Queue_type.QUEUE_SHIP_BOMB:

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);
                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }

                        if (Game1.networkSession.IsHost)
                        {
                            LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                            server.SendData(packetWriter2, SendDataOptions.InOrder);
                        }
                    }
                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            // packetWriter2.Write((int)qH.data);

                            // Send our input data to the server.//
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }

                    break;

                case Queue_type.QUEUE_SHIP_MISSILE:

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }

                        if (Game1.networkSession.IsHost)
                        {
                            LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                            server.SendData(packetWriter2, SendDataOptions.InOrder);
                        }
                    }
                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            // packetWriter2.Write((int)qH.data);

                            // Send our input data to the server.
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }

                    break;

                case Queue_type.QUEUE_SHIP_IMPULSE:

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);

                    Ship_Impulse_Message sim = (Ship_Impulse_Message)qH.data;

                    packetWriter2.Write((Vector2)sim.impulse);
                    Debug.WriteLine("Outputq - sim.impulse = " + sim.impulse);
                    Debug.WriteLine("Outputq - sim.X = " + sim.impulse.X);
                    Debug.WriteLine("Outputq - sim.Y = " + sim.impulse.Y);

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }

                        if (Game1.networkSession.IsHost)
                        {
                            LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                            server.SendData(packetWriter2, SendDataOptions.InOrder);
                        }
                    }
                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);    ///just added 207pm
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            //Ship_Impulse_Message sim = (Ship_Impulse_Message)qH.data;

                            //packetWriter2.Write((Vector2)sim.impulse);



                            // Send our input data to the server.
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }
                    break;

                case Queue_type.QUEUE_SHIP_ROT:
                    //send to input queue

                    //packetWriter2.Write(qH.inSeqNum);
                    //        packetWriter2.Write(qH.outSeqNum);
                    //        packetWriter2.Write((int)qH.type);

                    //        Ship_Impulse_Message sim = (Ship_Impulse_Message)qH.data;

                    //        packetWriter2.Write((Vector2)sim.impulse);

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);
                    Ship_Rot_Message rotMessage = (Ship_Rot_Message)qH.data;
                    packetWriter2.Write(rotMessage.rotation);
                    Debug.WriteLine(" OutputQ - rotMessage.rotation = " + rotMessage.rotation);


                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }
                    }

                    if (Game1.networkSession.IsHost)
                    {
                        LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                        server.SendData(packetWriter2, SendDataOptions.InOrder);
                    }

                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            //Ship_Rot_Message rotMessage = (Ship_Rot_Message)qH.data;
                            //packetWriter2.Write(rotMessage.rotation);
                            //  packetWriter2.Write((Vector2)qH.data);

                            // Send our input data to the server.
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }
                    break;

                case Queue_type.QUEUE_PHYSICS_BUFFER:

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }
                    }

                    if (Game1.networkSession != null)
                    {
                        // packetWriter2.Write(gamer.Id);
                        packetWriter2.Write(qH.inSeqNum);
                        packetWriter2.Write(qH.outSeqNum);
                        packetWriter2.Write((int)qH.type);
                        //Debug.WriteLine("qH.inSeqNum from PushToNetwork = " + qH.inSeqNum);
                        //Debug.WriteLine("qH.outSeqNum from PushToNetwork = " + qH.outSeqNum);
                        //Debug.WriteLine("qH.type from PushToNetwork = " + qH.type);
                        //PhysicsBuffer[] localPhysicsBuff = new PhysicsBuffer[];
                        PhysicsBuffer_Message PhysicsBuff_MessageInQueueHdr = new PhysicsBuffer_Message((PhysicsBuffer_Message)qH.data);

                        //get the count from the buffer
                        packetWriter2.Write(PhysicsBuff_MessageInQueueHdr.count);
                        //Debug.WriteLine("PhysicsBuff_MessageInQueueHdr.count = " + PhysicsBuff_MessageInQueueHdr.count);
                        PhysicsBuffer[] localPhysicsBuff = new PhysicsBuffer[PhysicsBuff_MessageInQueueHdr.count];
                        //get the the physics buffer struct of id, position , rotation out
                        localPhysicsBuff = PhysicsBuff_MessageInQueueHdr.pBuff;

                        for (int j = 0; j < PhysicsBuff_MessageInQueueHdr.count; j++)
                        {
                            PhysicsBuffer myPhysicsBuffer = new PhysicsBuffer();

                            myPhysicsBuffer.id       = localPhysicsBuff[j].id;
                            myPhysicsBuffer.position = localPhysicsBuff[j].position;
                            myPhysicsBuffer.rotation = localPhysicsBuff[j].rotation;
                            packetWriter2.Write(myPhysicsBuffer.id);
                            packetWriter2.Write(myPhysicsBuffer.position);
                            packetWriter2.Write(myPhysicsBuffer.rotation);
                            //Debug.WriteLine("myPhysicsBuffer.id = " + myPhysicsBuffer.id);
                            //Debug.WriteLine("myPhysicsBuffer.position = " + myPhysicsBuffer.position);
                            //Debug.WriteLine("myPhysicsBuffer.rotation = " + myPhysicsBuffer.rotation);
                        }



                        if (Game1.networkSession != null)
                        {
                            if (Game1.networkSession.IsHost)
                            {
                                LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                                server.SendData(packetWriter2, SendDataOptions.InOrder);
                            }
                        }

                        // if this is the client machine, need to send to server
                    }

                    // Send our input data to the server.
                    //if (Game1.networkSession != null)
                    //{
                    //    if (Game1.networkSession.IsHost)
                    //    {
                    //        foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    //        {
                    //            gamer.SendData(packetWriter2,
                    //                        SendDataOptions.InOrder, Game1.networkSession.);
                    //        }
                    //    }
                    //}



                    break;

                case Queue_type.QUEUE_EVENT:

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }
                    }
                    if (Game1.networkSession != null)
                    {
                        // Write our latest input state into a network packet.
                        packetWriter2.Write(qH.inSeqNum);
                        packetWriter2.Write(qH.outSeqNum);
                        packetWriter2.Write((int)qH.type);
                        // packetWriter2.Write((int)qH.data);
                        Event_Message eventMsg = new Event_Message((Event_Message)qH.data);
                        packetWriter2.Write(eventMsg.GameID_A);
                        //   Debug.WriteLine("eventMsg " + eventMsg.GameID_A);
                        packetWriter2.Write(eventMsg.GameID_B);
                        //  Debug.WriteLine("eventMsg " + eventMsg.GameID_B);
                        packetWriter2.Write(eventMsg.collision_pt);
                        //   Debug.WriteLine("eventMsg " + eventMsg.collision_pt);


                        if (Game1.networkSession != null)
                        {
                            if (Game1.networkSession.IsHost)
                            {
                                LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                                server.SendData(packetWriter2, SendDataOptions.InOrder);
                            }
                        }

                        // Send our input data to the server.
                        // gamer.SendData(packetWriter2,
                        //              SendDataOptions.InOrder, Game1.networkSession.Host);
                    }


                    //foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    //{

                    //    if (!Game1.networkSession.IsHost)
                    //    {
                    //        // Write our latest input state into a network packet.
                    //        packetWriter2.Write(qH.inSeqNum);
                    //        packetWriter2.Write(qH.outSeqNum);
                    //        packetWriter2.Write((int)qH.type);
                    //       // Ship_Rot_Message rotMessage = (Ship_Rot_Message)qH.data;
                    //       // packetWriter2.Write(rotMessage.rotation);
                    //      //  packetWriter2.Write((Vector2)qH.data);

                    //        // Send our input data to the server.
                    //        gamer.SendData(packetWriter2,
                    //                       SendDataOptions.InOrder, Game1.networkSession.Host);
                    //    }
                    //}
                    break;

                default:
                    break;
                }
            }
        }
Пример #29
0
        static public void FSMTest()
        {
            System.Console.WriteLine("\n------------ FSM Phase 1: Explicit Calls ---------------\n");

            FSM myFSM = new FSM();

            myFSM.advance(0);  //a
            myFSM.advance(1);  //b
            myFSM.advance(0);  //e
            myFSM.advance(1);  //a

            myFSM.advance(1);  //b
            myFSM.advance(0);  //e
            myFSM.advance(0);  //c
            myFSM.advance(1);  //e
            myFSM.advance(1);  //a

            myFSM.advance(1);  //b
            myFSM.advance(1);  //c
            myFSM.advance(0);  //d
            myFSM.advance(0);  //d
            myFSM.advance(1);  //b

            myFSM.set(FSM_StateEnum.STATE_C);
            myFSM.advance(0);
            myFSM.advance(0);
            myFSM.advance(0);

            myFSM.set(FSM_StateEnum.STATE_C);
            myFSM.advance(1);
            myFSM.advance(0);
            myFSM.advance(0);

            myFSM.set(FSM_StateEnum.STATE_B);
            myFSM.advance(1);
            myFSM.advance(1);
            myFSM.advance(0);

            myFSM.set(FSM_StateEnum.STATE_D);
            myFSM.advance(1);
            myFSM.advance(0);
            myFSM.advance(1);

            System.Console.WriteLine("\n------------ FSM Phase 2: Data Driven ---------------\n");

            FSM_Data myData;

            myData.input = 0;
            myData.state = FSM_StateEnum.STATE_A;
            myData.type  = FSM_Type.FSM_ADV;

            //myFSM.advance(0);  //a
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(0);  //e
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //a
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(0);  //e
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(0);  //c
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //e
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //a
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //c
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(0);  //d
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(0);  //d
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.set(FSM_StateEnum.STATE_C);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_C;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.set(FSM_StateEnum.STATE_C);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_C;
            myFSM.doWork(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.set(FSM_StateEnum.STATE_B);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_B;
            myFSM.doWork(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.set(FSM_StateEnum.STATE_D);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_D;
            myFSM.doWork(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myFSM.doWork(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myFSM.doWork(myData);


            System.Console.WriteLine("\n------------ FSM Phase 3: Queued Data Driven ---------------\n");

            System.Collections.Generic.Queue <FSM_Data> myQ_FSM = new System.Collections.Generic.Queue <FSM_Data>();


            myData.input = 0;
            myData.state = FSM_StateEnum.STATE_A;
            myData.type  = FSM_Type.FSM_ADV;

            //myFSM.advance(0);  //a
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);  //e
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //a
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);  //e
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);  //c
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //e
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //a
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //c
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);  //d
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);  //d
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);  //b
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.set(FSM_StateEnum.STATE_C);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_C;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.set(FSM_StateEnum.STATE_C);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_C;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.set(FSM_StateEnum.STATE_B);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_B;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.set(FSM_StateEnum.STATE_D);
            myData.type  = FSM_Type.FSM_SET;
            myData.state = FSM_StateEnum.STATE_D;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(0);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 0;
            myQ_FSM.Enqueue(myData);

            //myFSM.advance(1);
            myData.type  = FSM_Type.FSM_ADV;
            myData.input = 1;
            myQ_FSM.Enqueue(myData);


            // Now the queue is NOW filled
            // print the contents
            int count = myQ_FSM.Count;

            for (int i = 0; i < count; i++)
            {
                FSM_Data tmpData = myQ_FSM.Dequeue();
                myFSM.doWork(tmpData);
            }
        }
Пример #30
0
        static public void CalcTest()
        {
            Calc myCalc = new Calc();

            System.Console.WriteLine("\n------------ Calc Phase 1: Explicit Calls ---------------\n");

            myCalc.set(3);
            myCalc.add(2);
            myCalc.sub(8);
            myCalc.mult(2);
            myCalc.sub(5);
            myCalc.add(4);
            myCalc.add(22);
            myCalc.sub(4);
            myCalc.mult(2);
            myCalc.sub(5);
            myCalc.set(11);
            myCalc.add(2);
            myCalc.sub(7);
            myCalc.mult(3);
            myCalc.sub(5);

            System.Console.WriteLine("\n------------ Calc Phase 2: Data Driven ---------------\n");

            Calc_Data data;

            // myCalc.set(3);
            data.type  = Calc_Type.CALC_SET;
            data.value = 3;
            myCalc.doWork(data);

            // myCalc.add(2);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 2;
            myCalc.doWork(data);

            // myCalc.sub(8);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 8;
            myCalc.doWork(data);

            // myCalc.mult(2);
            data.type  = Calc_Type.CALC_MULT;
            data.value = 2;
            myCalc.doWork(data);

            // myCalc.sub(5);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 5;
            myCalc.doWork(data);

            // myCalc.add(4);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 4;
            myCalc.doWork(data);

            // myCalc.add(22);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 22;
            myCalc.doWork(data);

            // myCalc.sub(4);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 4;
            myCalc.doWork(data);

            // myCalc.mult(2);
            data.type  = Calc_Type.CALC_MULT;
            data.value = 2;
            myCalc.doWork(data);

            // myCalc.sub(5);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 5;
            myCalc.doWork(data);

            // myCalc.set(11);
            data.type  = Calc_Type.CALC_SET;
            data.value = 11;
            myCalc.doWork(data);

            // myCalc.add(2);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 2;
            myCalc.doWork(data);

            // myCalc.sub(7);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 7;
            myCalc.doWork(data);

            // myCalc.mult(3);
            data.type  = Calc_Type.CALC_MULT;
            data.value = 3;
            myCalc.doWork(data);

            // myCalc.sub(5);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 5;
            myCalc.doWork(data);

            System.Console.WriteLine("\n------------ Calc Phase 3: Queued Data Driven ---------------\n");

            // Creates and initializes a new Queue.
            System.Collections.Generic.Queue <Calc_Data> myQ = new System.Collections.Generic.Queue <Calc_Data>();

            // myCalc.set(3);
            data.type  = Calc_Type.CALC_SET;
            data.value = 3;
            myQ.Enqueue(data);

            // myCalc.add(2);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 2;
            myQ.Enqueue(data);

            // myCalc.sub(8);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 8;
            myQ.Enqueue(data);

            // myCalc.mult(2);
            data.type  = Calc_Type.CALC_MULT;
            data.value = 2;
            myQ.Enqueue(data);

            // myCalc.sub(5);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 5;
            myQ.Enqueue(data);

            // myCalc.add(4);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 4;
            myQ.Enqueue(data);

            // myCalc.add(22);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 22;
            myQ.Enqueue(data);

            // myCalc.sub(4);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 4;
            myQ.Enqueue(data);

            // myCalc.mult(2);
            data.type  = Calc_Type.CALC_MULT;
            data.value = 2;
            myQ.Enqueue(data);

            // myCalc.sub(5);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 5;
            myQ.Enqueue(data);

            // myCalc.set(11);
            data.type  = Calc_Type.CALC_SET;
            data.value = 11;
            myQ.Enqueue(data);

            // myCalc.add(2);
            data.type  = Calc_Type.CALC_ADD;
            data.value = 2;
            myQ.Enqueue(data);

            // myCalc.sub(7);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 7;
            myQ.Enqueue(data);

            // myCalc.mult(3);
            data.type  = Calc_Type.CALC_MULT;
            data.value = 3;
            myQ.Enqueue(data);

            // myCalc.sub(5);
            data.type  = Calc_Type.CALC_SUB;
            data.value = 5;
            myQ.Enqueue(data);


            // Now the queue is NOW filled
            // print the contents
            int count = myQ.Count;

            for (int i = 0; i < count; i++)
            {
                Calc_Data tmpData = myQ.Dequeue();
                myCalc.doWork(tmpData);
            }
        }
        public override void Write(byte[] buffer, int offset, int count)
        {
            bool mustWait = false;

            // This method does this:
            //   0. handles any pending exceptions
            //   1. write any buffers that are ready to be written,
            //   2. fills a work buffer; when full, flip state to 'Filled',
            //   3. if more data to be written,  goto step 1

            if (_isClosed)
            {
                throw new InvalidOperationException();
            }

            // dispense any exceptions that occurred on the BG threads
            if (_pendingException != null)
            {
                _handlingException = true;
                var pe = _pendingException;
                _pendingException = null;
                throw pe;
            }

            if (count == 0)
            {
                return;
            }

            if (!_firstWriteDone)
            {
                // Want to do this on first Write, first session, and not in the
                // constructor.  We want to allow MaxBufferPairs to
                // change after construction, but before first Write.
                _InitializePoolOfWorkItems();
                _firstWriteDone = true;
            }


            do
            {
                // may need to make buffers available
                EmitPendingBuffers(false, mustWait);

                mustWait = false;
                // use current buffer, or get a new buffer to fill
                int ix = -1;
                if (_currentlyFilling >= 0)
                {
                    ix = _currentlyFilling;
                    TraceOutput(TraceBits.WriteTake,
                                "Write    notake   wi({0}) lf({1})",
                                ix,
                                _lastFilled);
                }
                else
                {
                    TraceOutput(TraceBits.WriteTake, "Write    take?");
                    if (_toFill.Count == 0)
                    {
                        // no available buffers, so... need to emit
                        // compressed buffers.
                        mustWait = true;
                        continue;
                    }

                    ix = _toFill.Dequeue();
                    TraceOutput(TraceBits.WriteTake,
                                "Write    take     wi({0}) lf({1})",
                                ix,
                                _lastFilled);
                    ++_lastFilled; // TODO: consider rollover?
                }

                WorkItem workitem = _pool[ix];

                int limit = ((workitem.buffer.Length - workitem.inputBytesAvailable) > count)
                    ? count
                    : (workitem.buffer.Length - workitem.inputBytesAvailable);

                workitem.ordinal = _lastFilled;

                TraceOutput(TraceBits.Write,
                            "Write    lock     wi({0}) ord({1}) iba({2})",
                            workitem.index,
                            workitem.ordinal,
                            workitem.inputBytesAvailable
                            );

                // copy from the provided buffer to our workitem, starting at
                // the tail end of whatever data we might have in there currently.
                Buffer.BlockCopy(buffer,
                                 offset,
                                 workitem.buffer,
                                 workitem.inputBytesAvailable,
                                 limit);

                count  -= limit;
                offset += limit;
                workitem.inputBytesAvailable += limit;
                if (workitem.inputBytesAvailable == workitem.buffer.Length)
                {
                    // No need for interlocked.increment: the Write()
                    // method is documented as not multi-thread safe, so
                    // we can assume Write() calls come in from only one
                    // thread.
                    TraceOutput(TraceBits.Write,
                                "Write    QUWI     wi({0}) ord({1}) iba({2}) nf({3})",
                                workitem.index,
                                workitem.ordinal,
                                workitem.inputBytesAvailable);

#if !PCL
                    if (!ThreadPool.QueueUserWorkItem(_DeflateOne, workitem))
                    {
                        throw new Exception("Cannot enqueue workitem");
                    }
#else
                    System.Threading.Tasks.Task.Run(() => _DeflateOne(workitem));
#endif

                    _currentlyFilling = -1; // will get a new buffer next time
                }
                else
                {
                    _currentlyFilling = ix;
                }

                if (count > 0)
                {
                    TraceOutput(TraceBits.WriteEnter, "Write    more");
                }
            }while (count > 0);  // until no more to write

            TraceOutput(TraceBits.WriteEnter, "Write    exit");
            return;
        }