示例#1
0
        IEnumerator Start()
        {
            yield return(null);

            ActiveStation = StartStation;
            ActiveStation.Activate();
        }
示例#2
0
 public WirelessNode(uint nodeAddress, BaseStation basestation) : this(msclPINVOKE.new_WirelessNode(nodeAddress, BaseStation.getCPtr(basestation)), true)
 {
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public SyncSamplingNetwork(BaseStation networkBaseStation) : this(msclPINVOKE.new_SyncSamplingNetwork(BaseStation.getCPtr(networkBaseStation)), true)
 {
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            var client = new TcpClient();

            client.Connect("192.168.191.99", 30003);

            var stream = client.GetStream();

            var spt = new SimplePlaneTracker();

            var sle = new StreamLineEmitter(stream);

            sle.Line += (sender, s) =>
            {
                var message = BaseStation.Parse(s);
                spt.Consume(message);
                spt.Heartbeat();
                Print(spt);
            };

            sle.Start();

            var mres = new ManualResetEventSlim();

            mres.Wait();
        }
示例#5
0
        // please god let no one see this code
        Path CalcPath(BaseStation startStation, BaseStation endStation)
        {
            Assert.IsNotNull(startStation);
            Assert.IsNotNull(endStation);
            Assert.AreNotEqual(startStation, endStation);
            Path result = null;

            void TryFindPathRecursive(BaseStation curNode, List <BaseStation> curPath)
            {
                curPath.Add(curNode);
                if (curNode == endStation)
                {
                    result = new Path(curPath);
                    return;
                }
                foreach (var neighbour in curNode.Neighbours)
                {
                    if (curPath.Contains(neighbour))
                    {
                        continue;
                    }
                    TryFindPathRecursive(neighbour, new List <BaseStation>(curPath));
                    if (result != null)
                    {
                        return;
                    }
                }
            }

            TryFindPathRecursive(startStation, new List <BaseStation>());
            Assert.IsNotNull(result);
            return(result);
        }
示例#6
0
    static void SaveStationsAndLines()
    {
        var sgos = GameObject.FindGameObjectsWithTag("TransStation");

        if (sgos.Length < 1)
        {
            Debug.Log("no stations to save.");
            return;
        }
        var lgos = GameObject.FindGameObjectsWithTag("TransLine");

        if (lgos.Length < 1)
        {
            Debug.Log("no lines to save.");
            return;
        }

        var path = EditorUtility.SaveFilePanel("Save XML Data", "Assets/Transportations", "", "xml");

        if (path.Length == 0)
        {
            EditorUtility.DisplayDialog("Saving Cancelled", "No file was provided", "OK");
            return;
        }

        List <BaseStation> stations = new List <BaseStation>();

        foreach (var go in sgos)
        {
            var sc = go.GetComponent <StationController>();
            var bs = new BaseStation
            {
                id   = int.Parse(sc.name),
                x    = go.transform.position.x,
                y    = go.transform.position.y,
                z    = go.transform.position.z,
                name = sc.stationName,
            };
            stations.Add(bs);
        }

        List <BaseLine> lines = new List <BaseLine>();

        foreach (var go in lgos)
        {
            var lc = go.GetComponent <LineController>();
            var bl = LineController.CreateBaseLine(lc);
            lines.Add(bl);
        }

        var container = new TrafficContainer();

        container.stations = stations;
        container.lines    = lines;
        container.Save(path);
        string stationStats = string.Format("{0} stations saved.", container.stations.Count);
        string lineStats    = string.Format("{0} lines saved.", container.lines.Count);

        EditorUtility.DisplayDialog("Saving Finished", stationStats + "\n" + lineStats + "\n to: " + path, "OK");
    }
示例#7
0
 public ArmedDataloggingNetwork(BaseStation networkBaseStation) : this(msclPINVOKE.new_ArmedDataloggingNetwork(BaseStation.getCPtr(networkBaseStation)), true)
 {
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#8
0
 public void setBaseStation(BaseStation basestation)
 {
     msclPINVOKE.WirelessNode_setBaseStation(swigCPtr, BaseStation.getCPtr(basestation));
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#9
0
        public ActionResult DeleteConfirmed(int id)
        {
            BaseStation baseStation = db.BaseStations.Find(id);

            db.BaseStations.Remove(baseStation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#10
0
        public RESTRequestStatus Put(string appkey,
                                     string sessionid,
                                     Int64 cloudid,
                                     string syncitems,
                                     string devicetoken

                                     )
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            Account account   = null;
            Int64   accountNo = 0;

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;
            string op       = fullpath.Substring("/fluid/sync/".Length, fullpath.Length - "/fluid/sync/".Length);

            switch (op)
            {
            case Constants.basestation:


                //IDictionary<string , string> baseStationSyncItemsDic = JsonConvert.DeserializeObject<Dictionary<string , string>>( syncitems );


                accountNo = DataLayer.GetAccountNoUsingSessionId(sessionid);

                account = DataLayer.GetAccount(accountNo);

                BaseStation baseStation = DataLayer.GetBaseStation(response, cloudid, account);

                if (baseStation.CloudId == cloudid)
                {
                    SyncBaseStation(response, baseStation, syncitems, devicetoken);
                }

                break;

            case Constants.sensor:

                Sensor sensor = DataLayer.GetSensor(response, cloudid);


                if (sensor.CloudId.Equals(cloudid))
                {
                    SyncSensor(response, sensor, syncitems, devicetoken);
                }

                break;
            }

            return(response);
        }
示例#11
0
        public RESTRequestStatus Post(string appkey,
                                      string sessionid,
                                      Int64 cloudId,
                                      Int64 totalTimeStampSync
                                      )
        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            Account account   = null;
            Int64   accountNo = 0;


            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;
            string op       = fullpath.Substring("/fluid/sync/".Length, fullpath.Length - "/fluid/sync/".Length);

            switch (op)
            {
            case Constants.basestation:

                accountNo = DataLayer.GetAccountNoUsingSessionId(sessionid);

                account = DataLayer.GetAccount(accountNo);

                BaseStation baseStation = DataLayer.GetBaseStation(response, cloudId, account);

                if (baseStation.CloudId == cloudId)
                {
                    Int64 totalTimeStamps;

                    response.statuscode = RESTRequestStatusCode.success;
                    response.status     = RESTRequestStatusCode.success.ToString( );

                    totalTimeStamps = baseStation.NameTimeStamp +
                                      baseStation.TempUnitTimeStamp +
                                      baseStation.UserDescriptionTimeStamp;

                    if (totalTimeStampSync != totalTimeStamps)
                    {
                        response.response = Constants.needsSyncing;
                    }
                    else
                    {
                        response.response = Constants.synced;
                    }
                }

                break;
            }

            return(response);
        }
示例#12
0
        public static WirelessNode Mock(uint nodeAddress, BaseStation basestation, NodeInfo info, EepromMap initialEepromCache)
        {
            WirelessNode ret = new WirelessNode(msclPINVOKE.WirelessNode_Mock__SWIG_1(nodeAddress, BaseStation.getCPtr(basestation), NodeInfo.getCPtr(info), EepromMap.getCPtr(initialEepromCache)), true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#13
0
        public bool hasBaseStation(BaseStation basestation)
        {
            bool ret = msclPINVOKE.WirelessNode_hasBaseStation(swigCPtr, BaseStation.getCPtr(basestation));

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#14
0
        public static BaseStation Mock()
        {
            BaseStation ret = new BaseStation(msclPINVOKE.BaseStation_Mock__SWIG_1(), true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#15
0
        public BaseStation getBaseStation()
        {
            BaseStation ret = new BaseStation(msclPINVOKE.WirelessNode_getBaseStation(swigCPtr), false);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#16
0
        public static BaseStation Mock(BaseStationInfo info)
        {
            BaseStation ret = new BaseStation(msclPINVOKE.BaseStation_Mock__SWIG_0(BaseStationInfo.getCPtr(info)), true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#17
0
        public ActionResult Create([Bind(Include = "ID,Name,Location")] BaseStation baseStation)
        {
            if (ModelState.IsValid)
            {
                db.BaseStations.Add(baseStation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(baseStation));
        }
    public static GameObject CreateGameObject(BaseStation station, bool loadStationWithLOD = true)
    {
        var controller = CreateStation(station.id, new Vector3(station.x, station.y, station.z), station.name, loadStationWithLOD);

        if (controller == null)
        {
            return(null);
        }
        else
        {
            return(controller.gameObject);
        }
    }
示例#19
0
        public void TestBaseStationBuffer()
        {
            var station = new BaseStation(1);

            Assert.AreEqual(station.GetSizeBuffer(), 0);
            var packet = new Packet(1, 1.2);

            station.AddPacket(packet);
            Assert.AreEqual(station.GetSizeBuffer(), 1);
            var packet2 = station.GetPacket();

            Assert.AreEqual(station.GetSizeBuffer(), 0);
        }
示例#20
0
        // GET: BaseStation/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BaseStation baseStation = db.BaseStations.Find(id);

            if (baseStation == null)
            {
                return(HttpNotFound());
            }
            return(View(baseStation));
        }
示例#21
0
 Path GetPath(BaseStation startStation, BaseStation endStation)
 {
     foreach (var path in _paths)
     {
         if ((path.StartStation == startStation) && (path.EndStation == endStation))
         {
             return(path);
         }
         if ((path.StartStation == endStation) && (path.EndStation == startStation))
         {
             return(path.Reversed);
         }
     }
     Debug.LogErrorFormat("{0}.{1}: no path found between '{2}' and '{3}'", nameof(StationsManager),
                          nameof(GetPath), startStation.gameObject.name, endStation.gameObject.name);
     return(null);
 }
示例#22
0
    //Get universe pitch & roll from lighthousedb.json
    double[] GetUniverseOffset()
    {
        StreamReader reader = new StreamReader(filePath);
        string       json   = reader.ReadToEnd();
        var          data   = JSON.Parse(json);

        double[] universeTiltData = new double[3];

        Tilt universeTilt = Universe.GetTilt(data ["known_universes"], currentUniverseID);
        Tilt baseTilt     = BaseStation.GetTilt(data["base_stations"]);

        universeTiltData [0] = universeTilt.pitch;
        universeTiltData [1] = universeTilt.roll;
        universeTiltData [2] = universeTilt.variance;

        return(universeTiltData);
    }
示例#23
0
 public ActionResult Edit([Bind(Include = "ID,Name,Location,Destination")] BaseStation baseStation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(baseStation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     if (baseStation is SpawnerStation)
     {
         return(View("EditSpawn", baseStation));
     }
     else
     {
         return(View(baseStation));
     }
 }
示例#24
0
        public void TryActivateStation(BaseStation station)
        {
            if (!Submarine.IsAlive || (ActiveStation == station) || (_activationAnim != null))
            {
                return;
            }
            _activationAnim?.Kill();
            var path          = GetPath(ActiveStation, station);
            var pathRaw       = path.Nodes.Select(x => x.transform.position).ToArray();
            var activeStation = ActiveStation;

            _activationAnim = DOTween.Sequence()
                              .AppendCallback(() => activeStation.Deactivate())
                              .Append(PlayerTransform.DOPath(pathRaw, path.Length / PlayerMovementSpeed).SetEase(Ease.Linear));
            _activationAnim.onComplete += () => {
                station.Activate();
                ActiveStation   = station;
                _activationAnim = null;
            };
        }
示例#25
0
        // GET: BaseStation/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BaseStation baseStation = db.BaseStations.Find(id);

            if (baseStation == null)
            {
                return(HttpNotFound());
            }
            if (baseStation is SpawnerStation)
            {
                return(View("EditSpawn", baseStation));
            }
            else
            {
                return(View(baseStation));
            }
        }
        public JsonResult Edit(BaseStation model)
        {
            try
            {
                if (model.BaseStationId > 0)
                {
                    var entity = _baseStationService.GetById(model.BaseStationId);

                    //修改
                    entity.BaseAreaId = model.BaseAreaId;
                    entity.BaseLineId = model.BaseLineId;
                    entity.Name       = model.Name;
                    entity.EditTime   = DateTime.Now;

                    _baseStationService.Update(model);
                }
                else
                {
                    //if (_baseAreaService.CheckName(model.Name) > 0)
                    //    return Json(new { Status = Successed.Repeat }, JsonRequestBehavior.AllowGet);
                    //添加
                    model.Status     = (int)OrderingSystem.Domain.EnumHelp.EnabledEnum.效;
                    model.IsDelete   = (int)OrderingSystem.Domain.EnumHelp.IsDeleteEnum.效;
                    model.CreateTime = DateTime.Now;
                    model.EditTime   = DateTime.Now;

                    _baseStationService.Insert(model);
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
        }
示例#27
0
        public RESTRequestStatus Post(
            string sessionid,
            string appkey,
            string macaddress,
            string status,
            string hwversion,
            string fwversion,
            string name,
            string description,
            string tempunit,
            string devicetoken,

            Int64 cloudId,
            Int64 descriptiontimestamp,
            Int64 nametimestamp,
            Int64 tempunittimestamp

            )

        {
            RESTRequestStatus response = new RESTRequestStatus(RESTRequestStatusCode.unknown);

            BaseStation baseStation = null;
            Account     account     = null;
            Int64       accountNo;

            if (AppController.ProceedWithRequest(response, appkey, sessionid, Request) == false)
            {
                return(response);
            }

            string fullpath = Request.Path;

            string op = fullpath.Substring("/fluid/basestation/".Length, fullpath.Length - "/fluid/basestation/".Length);

            switch (op)
            {
            case Constants.basestations:

                GetBaseStationsForAccount(response, sessionid);

                break;


            case Constants.associateBasestation:


                baseStation = new BaseStation(macaddress,
                                              hwversion,
                                              fwversion,
                                              name,
                                              status,
                                              nametimestamp,
                                              description,
                                              descriptiontimestamp,
                                              tempunit,
                                              tempunittimestamp);

                AssociateBaseStationWithAccount(response, sessionid, baseStation, devicetoken);

                break;

            case Constants.delete:

                accountNo = DataLayer.GetAccountNoUsingSessionId(sessionid);

                account = DataLayer.GetAccount(accountNo);

                baseStation = DataLayer.GetBaseStation(response, cloudId, account);

                baseStation.Status = status;

                DeleteBaseStationFromAccount(response, sessionid, baseStation, devicetoken);

                break;
            }

            DataLayer.CloseConnection( );

            return(response);
        }
示例#28
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BaseStation obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
示例#29
0
        private void DeleteBaseStationFromAccount(RESTRequestStatus response, String sessionid, BaseStation baseStation, string devicetoken)
        {
            SilentNotification notification = null;

            List <string> devicesTokens;

            if (DataLayer.DeleteBaseStation(response, baseStation))
            {
                if (DataLayer.GetBaseStationsWithSessionId(response, sessionid))
                {
                    response.statuscode = RESTRequestStatusCode.success;
                    response.status     = RESTRequestStatusCode.success.ToString( );

                    notification = new SilentNotification(baseStation);

                    notification.NotificationType = Constants.delete;

                    DataLayer.GetDeviceTokensForAccount(baseStation.AccountNo, out devicesTokens);

                    devicesTokens.Remove(devicetoken);

                    if (devicesTokens.Count > 0)
                    {
                        Task.Factory.StartNew(() => { NotificationController.PushNotification(notification, devicesTokens); });
                    }
                }
            }
        }
示例#30
0
 public Path(List <BaseStation> nodes)
 {
     Nodes        = nodes;
     StartStation = Nodes[0];
     EndStation   = Nodes[Nodes.Count - 1];
 }