示例#1
0
        public void ImportSensors(SensorTransferCollection stc)
        {
            collection = new List <Sensor>();

            foreach (var st in stc.sensors)
            {
                Sensor s = Sensor.CreateFromTransfer(st);
                s.transform.SetParent(container);
                s.gameObject.name = s.TypeName + "-" + s.Id;
                collection.Add(s);
            }
        }
示例#2
0
        public IEnumerator QueryForBuildingByName(string buildingName, System.Action <Building> callBack)
        {
            //Get Buildings
            BuildingTransferCollection buildingCollection = null;

            yield return(StartCoroutine(GetBuildingsByStreetName(buildingName, (BuildingTransferCollection b) => {
                buildingCollection = b;
            })));

            Building buildingGo = null;

            if (buildingCollection == null)
            {
                UIManager.Instance.QueryError();
            }
            else if (buildingCollection != null && buildingCollection.buildings.Length > 0)
            {
                buildingGo = Building.CreateFromTransfer(buildingCollection.buildings [0]);

                //Get Floors for every building
                foreach (BuildingTransfer building in buildingCollection.buildings)
                {
                    FloorTransferCollection tempftc = null;
                    yield return(StartCoroutine(GetFloorsByBuildingId(building.id, (FloorTransferCollection ftc) => {
                        tempftc = ftc;
                    })));

                    foreach (FloorTransfer floor in tempftc.floors)
                    {
                        //Get sensors per floor
                        SensorTransferCollection tempSTC = null;
                        yield return(StartCoroutine(GetSensorByFloorId(floor.id, (SensorTransferCollection stc) => {
                            tempSTC = stc;
                        })));

                        PolygonQueryTransfer tempPQT = null;
                        yield return(StartCoroutine(GetPolygonByFloorId(floor.id, (PolygonQueryTransfer pqt) => {
                            tempPQT = pqt;
                        })));

                        //Merge the floor,sensor and polygon transfer object into the Building obj.
                        Floor tempFloor = Floor.CreateFromTransfer(floor);
                        tempFloor.ImportSensors(tempSTC);
                        tempFloor.ImportPolygons(tempPQT);
                        buildingGo.ImportFloor(tempFloor);
                    }
                }
            }
            callBack(buildingGo);
        }
示例#3
0
        private IEnumerator GetSensorByFloorId(int floorId, System.Action <SensorTransferCollection> callBack)
        {
            string url = string.Format(APIUrls.SENSOR_BY_FLOOR_ID, floorId.ToString());

            WWW www = new WWW(url, null, headers);

            yield return(www);

            if (string.IsNullOrEmpty(www.error))
            {
                string response             = www.text;
                SensorTransferCollection sc = JsonUtility.FromJson <SensorTransferCollection> (
                    RequestUtils.ArrayFormatter(ArrayFormatterType.sensors, response));
                callBack(sc);
            }
        }
示例#4
0
 public void ImportSensors(SensorTransferCollection stc)
 {
     sensors.ImportSensors(stc);
 }