コード例 #1
0
 public AskPredict(FetchQuery fetchQuery)
 {
     centerPoint = fetchQuery.centerPoint;
     speedVec = fetchQuery.speedVec;
     viewRadius = fetchQuery.viewRadius;
     RTT = fetchQuery.RTT;
 }
コード例 #2
0
        public static void ConstantFetch()
        {
            while (stop == 0) {
                BinaryFormatter bf = new BinaryFormatter ();
                MemoryStream ms = new MemoryStream ();
                byte[] instream = new byte[100000];

                Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Connect (new IPEndPoint (IPAddress.Parse ("127.0.0.1"), 1234));
                //Random rnd = new Random ();

                FetchQuery fq = new FetchQuery (currentLoc);
                fq.objectIds=objectThere;
                float[] speedVec=new float[3];
                speedVec [0] = velocity [0];
                speedVec [1] = velocity [1];
                speedVec [2] = 0;

                bf.Serialize (ms, fq);
                socket.Send (ms.ToArray ());

                instream = new byte[100000];
                socket.Receive (instream);
                ms = new MemoryStream (instream);
                object obj2 = bf.Deserialize (ms);

                if (obj2 is ObjectResult) {
                    ObjectResult or = (ObjectResult)obj2;
                    //Console.WriteLine (or.askObjects.Length);
                    int j=0;
                    foreach (AskObject askobject in or.askObjects) {
                        if (idMap.ContainsKey(askobject.targetId)) {
                            idMap[askobject.targetId] = askobject;

                        } else {
                            idMap.Add(askobject.targetId, askobject);
                        }
                        objectThere [j] = askobject.objectId;
                        j = j + 1;

                    }
                } else {
                    Console.WriteLine ("Wrong kind of object.");
                }
                Thread.Sleep(fetchtime);
            }
        }
コード例 #3
0
 AskObject[] FetchObject(FetchQuery fetchQuery)
 {
     AskPredict predict = new AskPredict (fetchQuery);
     float[] centerPoint = predict.PredictTotal ();
     float viewRadius = fetchQuery.viewRadius;
     int[] objectIds = fetchQuery.objectIds;
     List<AskObject> askobjects = new List<AskObject> ();
     try {
         KdTreeNode<float, int>[] objects = KDTree.GetNearestNeighbours(centerPoint, 3);
         for (int i=0;i<objects.Length;i++)
         {
             int objId=objects[i].Value;
             bool present=false;
             for (int j=0;j<objectIds.Length;j++)
             {
                 if (objectIds[j]==objId)
                     present=true;
             }
             if(!present)
             {
                 askobjects.Add(idMap[objId]);
             }
         }
     }
     catch (Exception e) {
         Console.WriteLine (e.StackTrace);
     }
     return  askobjects.ToArray ();
 }