예제 #1
0
        public Station Add(Station station) //add station
        {
            if (station == null)
            {
                throw new ArgumentNullException("station");
            }
            if (station.StationName == "")
            {
                throw new ArgumentException("station");
            }

            Station s = FindStation(station.StationName);

            if (s == null)
            {
                Stations.Add(station); //add to list

                if (OnStationUpdate != null)
                {
                    OnStationUpdate(this, station, true);
                }
                return(station);
            }
            return(s);
        }
예제 #2
0
        public void Add()
        {
            switch (CurrentOption)
            {
            case Options.Station:
                var newStation = new Station {
                    Name = string.Empty, Description = string.Empty, EcpCode = 0, RailwayStations = new List <RailwayStation> {
                        RailwayStation
                    }
                };
                Stations.Add(newStation);
                CountLine = Stations.Count;
                break;

            case Options.OperativeSchedule:
                var newOperSh = new OperativeSchedule {
                    ArrivalTime = DateTime.Now, DepartureTime = DateTime.Now, RouteName = string.Empty, NumberOfTrain = string.Empty, ListOfStops = new ObservableCollection <Station>(), ListWithoutStops = new ObservableCollection <Station>()
                };
                OperativeSchedules.Add(newOperSh);
                CountLine = OperativeSchedules.Count;
                break;

            case Options.RegulatorySchedule:
                var newRegSh = new RegulatorySchedule {
                    ArrivalTime = DateTime.Now, DepartureTime = DateTime.Now, RouteName = string.Empty, NumberOfTrain = string.Empty, DaysFollowings = null, ListOfStops = new ObservableCollection <Station>(), ListWithoutStops = new ObservableCollection <Station>()
                };
                RegulatorySchedules.Add(newRegSh);
                CountLine = RegulatorySchedules.Count;
                break;
            }
        }
예제 #3
0
        public static void AddStation(int _id, int idNode)
        {
            Station st = new Station(_id, Graph.FindNodeById(idNode));

            Stations.Add(st);
            OnCreateStation?.Invoke(st);
        }
        private void __InitializeStations()
        {
            if (Stations == null)
            {
                Stations = new ObservableCollection <ESTWSelectionStationViewModel>();
            }
            else
            {
                Stations.Clear();
            }

            foreach (var Station in m_Estw.Stations)
            {
                if (!Station.HasScheduleFile)
                {
                    continue;
                }

                var VM = new ESTWSelectionStationViewModel(Station);
                VM.IsSelected       = Runtime.VisibleStations.Contains(Station);
                VM.PropertyChanged += __Station_PropertyChanged;
                Stations.Add(VM);
            }

            __RefreshSelection();
        }
예제 #5
0
        public static async Task RefreshStations()
        {
            XmlDocument stationXml = new XmlDocument();

            stationXml.LoadXml(await Http.Client.GetStringAsync(WeatherStationDataXmlUrl));

            Stations.Add(new WeatherStation(stationXml.DocumentElement));
        }
예제 #6
0
 public void AddStation(string stationName, double x, double y, bool isTransfer)
 {
     if (!HasStation(stationName))
     {
         Station station = new Station(stationName, x, y, isTransfer);
         Stations.Add(station);
     }
 }
예제 #7
0
 /// <summary>
 /// Adds a Station object to the list
 /// </summary>
 /// <param name="station"></param>
 public void AddStation(Station station)
 {
     Stations.Add(station);
     if (PlayingStation == null)
     {
         PlayingStation = station;
     }
 }
예제 #8
0
        public void AddStation(Station station)
        {
            if (station == null)
            {
                throw new System.ArgumentNullException("Station is equal to null while trying to add to the train {0}", Name);
            }

            Stations.Add(station);
        }
예제 #9
0
 public static void StationMapper()
 {
     string[] stationData = FetchData(stationDataPath);
     for (int i = 1; i < stationData.Length; i++)
     {
         string[] splitline = stationData[i].Split(';', ',', ':', '|');
         Stations.Add(new Station(int.Parse(splitline[0]), splitline[1], bool.Parse(splitline[2])));
     }
 }
 public void Add(Station station)
 {
     if (HasStation(station))
     {
         throw new TrackLayoutException(string.Format(CultureInfo.CurrentCulture, Resources.Strings.DuplicateAddOfStation, station));
     }
     station.Layout = this;
     Stations.Add(station);
 }
        private void GetStation(AudioAnalyzerConfigurationMonitorIDStation station)
        {
            Station stationSend = new Station();

            stationSend.StationID    = station.StationID;
            stationSend.StationName  = station.StationName;
            stationSend.ListOfMeters = new List <Meter>();
            GetMeters(station, stationSend, station.MeterID.Count());
            Stations.Add(stationSend);
        }
예제 #12
0
 public void AddStations(ICollection <ServiceStation> stations)
 {
     foreach (ServiceStation station in stations)
     {
         if (StationExistsByName(station) == null)
         {
             Stations.Add(new RouteStationMapper().MapFrom(station));
         }
     }
 }
예제 #13
0
파일: Util.cs 프로젝트: Balonich/Railways
 public static void AddStation(Station newStation)
 {
     if (UniqueStation(newStation, out Station foundStation))
     {
         Stations.Add(newStation);
     }
     else
     {
         Console.WriteLine($"Станция с именем {newStation.Name} уже существует. Её номер - №{foundStation.ID}");
     }
 }
예제 #14
0
 public async void LoadStationsAsync(SynchronizationContext uiContext)
 {
     foreach (var station in await _simulator.GetStations())
     {
         uiContext.Send(x => {
             Stations.Add(new StationVM(station, _simulator));
             _stationsLoaded = true;
             UpdateSimulationReady();
         }, null);
     }
 }
예제 #15
0
파일: World.cs 프로젝트: taurus790/Qatar-4
        public void AddStation(string name, int level, double posX, double posY)
        {
            Station station = new Station(Stations.Count, name, level, posX, posY);

            Stations.Add(station);

            //HACK Delete this code from here. Add Route if Station selected.
            if (Transports.Count > 0)
            {
                Transports.ElementAt(0).Route.Add(station);
            }
        }
예제 #16
0
        public void AddStation()
        {
            if (Stations == null)
            {
                Stations = new List <PowerCoreDockingStation>();
            }

            if (!Stations.Contains(this))
            {
                Stations.Add(this);
            }
        }
예제 #17
0
        public Savegame(string fileLoc)
        {
            this._playerShips = new ObservableCollection <Ship>();
            this._shipyards   = new ObservableCollection <Shipyard>();
            this._stations    = new ObservableCollection <Station>();

            Path = fileLoc;
            Data = XElement.Load(_path, LoadOptions.PreserveWhitespace);

            IEnumerable <XElement> ships = from ship in _data.Descendants().Elements("component")
                                           where (string)ship.Attribute("owner") == "player" && (string)ship.Attribute("state") != "wreck" && ((string)ship.Attribute("class") == "ship_xl" | (string)ship.Attribute("class") == "ship_l" | (string)ship.Attribute("class") == "ship_s" | (string)ship.Attribute("class") == "ship_xs")
                                           orderby(string) ship.Attribute("name")
                                           select ship;

            foreach (XElement ship in ships)
            {
                PlayerShips.Add(new Ship(ship));
            }

            IEnumerable <XElement> shipyards = this._data.Descendants().Elements("component").Where(delegate(XElement shipyard)
            {
                bool result = false;
                if (shipyard.Attribute("macro") != null && shipyard.Attribute("macro").Value.ToString().EndsWith("yard_macro"))
                {
                    result = true;
                }
                return(result);
            }
                                                                                                    );

            foreach (XElement shipyard in shipyards)
            {
                Shipyards.Add(new Shipyard(shipyard));
            }


            IEnumerable <XElement> stations = this._data.Descendants().Elements("component").Where(delegate(XElement ele)
            {
                bool result = false;
                if (ele.Attribute("owner") != null && ele.Attribute("class") != null && (ele.Attribute("owner").Value.ToString() == "player") && ele.Attribute("class").Value.Contains("station"))
                {
                    result = true;
                }

                return(result);
            });

            foreach (XElement station in stations)
            {
                Stations.Add(new Station(station));
            }
        }
예제 #18
0
파일: Pandora.cs 프로젝트: wade1990/Elpis
        public Station CreateStationFromSearch(string token)
        {
            JObject req = new JObject();

            req["musicToken"] = token;
            var result = CallRPC("station.createStation", req);

            var station = new Station(this, result.Result);

            Stations.Add(station);

            return(station);
        }
예제 #19
0
 public void AddStation(int station)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         var newStation = Stations.FirstOrDefault(s => s.StationNumber == station);
         if (newStation is null)
         {
             Stations.Add(new Station {
                 StationNumber = station
             });
         }
     });
 }
예제 #20
0
 /// <summary>
 /// Adds a Station object to the list
 /// </summary>
 /// <param name="station"></param>
 public bool AddStation(Station station)
 {
     if (station.IsPlayable())
     {
         Stations.Add(station);
         if (PlayingStation == null)
         {
             PlayingStation = station;
         }
         return(true);
     }
     return(false);
 }
예제 #21
0
파일: Pandora.cs 프로젝트: wade1990/Elpis
        private Station CreateStation(Song song, string type)
        {
            JObject req = new JObject();

            req["trackToken"] = song.TrackToken;
            req["musicType"]  = type;
            var result = CallRPC("station.createStation", req);

            var station = new Station(this, result.Result);

            Stations.Add(station);

            return(station);
        }
        private async Task LoadInformationAsync()
        {
            var stations = await Task.Run(() => _repository.Stations.GetRangeAsync());

            foreach (var station in stations)
            {
                Stations.Add(new StationModel(station, _repository));
            }

            SelectedStationMap = Stations.FirstOrDefault();


            timer.Interval = new TimeSpan(0, 0, 10);
            timer.Tick    += timer_Tick;
            timer.Start();
        }
예제 #23
0
        public Station AddStation(Line line, string name)
        {
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var result = new Station(Stations.Count, name, line);

            Stations.Add(result);

            return(result);
        }
예제 #24
0
        /// <summary>
        /// Метод возвращает экземпляр класса <see cref="Station"/> или, если в таблице нет такой записи, создаёт её
        /// </summary>
        /// <param name="name">Название станции</param>
        /// <param name="railRoadName">Название железной дороги</param>
        /// <param name="stateName">Название региона</param>
        /// <param name="countryName">Название страны</param>
        /// <returns>Экземпляр класса <see cref="Station"/></returns>
        public Station GetStation(string name, string railRoadName, string stateName, string countryName)
        {
            var station = Stations.FirstOrDefault(s => s.Name.Equals(name) &&
                                                  s.State.Name.Equals(stateName) &&
                                                  s.RailRoad.Name.Equals(railRoadName));

            if (station == null)
            {
                station = new Station
                {
                    Name     = name,
                    State    = GetState(stateName, countryName),
                    RailRoad = GetRailRoad(railRoadName, countryName)
                };
                Stations.Add(station);
                SaveChanges();
            }

            return(station);
        }
        private async Task UpdateList(RecordChangedEventArgs <Station> e)
        {
            await Task.Delay(1);

            if (e.ChangeType == ChangeType.None)
            {
                return;
            }

            if (e.ChangeType == ChangeType.Delete)
            {
                var s = Stations.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId);
                if (s == null)
                {
                    return;
                }

                Stations.Remove(s);
            }
            if (e.ChangeType == ChangeType.Insert)
            {
                if (Stations.Contains(new StationModel(e.Entity, _repository)))
                {
                    return;
                }
                Stations.Add(new StationModel(e.Entity, _repository));
            }
            if (e.ChangeType == ChangeType.Update)
            {
                var s = Stations.FirstOrDefault(c => c.Model.StationId == e.Entity.StationId);
                if (s == null)
                {
                    return;
                }
                var i = Stations.IndexOf(s);
                Stations.Remove(s);
                Stations.Insert(i, new StationModel(e.Entity, _repository));
            }
        }
예제 #26
0
        public void CreateStation(Stop a)
        {
            String las = a.Gps_X;

            las.Replace(',', '.');
            String lons = a.Gps_Y;

            lons.Replace(',', '.');

            Boolean existeStop = false;
            Station existente  = null;

            ICollection keyStop = Stations.Keys;

            foreach (String key in keyStop)
            {
                if (nameStop(((Station)stations[key]).ShortName).Equals(nameStop(a.ShortName)))
                {
                    existeStop = true;
                    existente  = ((Station)stations[key]);
                    break;
                }
            }

            if (existeStop == true)
            {
                (existente).addStop(a.ShortName, a);
            }
            else
            {
                Ubication ubi = new Ubication(lons, las);
                Station   b   = new Station(a.StopId, a.PlanVersionId, a.ShortName, a.LongName, ubi);

                b.addStop(a.ShortName, a);

                Stations.Add(a.StopId, b);
            }
        }
예제 #27
0
        public MainViewModel()
        {
            RawIn_Command    = new RelayCommand(OnRawIn_Command);
            EmptyOut_Command = new RelayCommand(OnEmptyOut_Command);
            EmptyIn_Command  = new RelayCommand(OnEmptyIn_Command);
            FinOut_Command   = new RelayCommand(OnFinOut_Command);
            Reset_Command    = new RelayCommand(OnReset_Command);
            Start_Command    = new RelayCommand(OnStart_Command);

            Stations.Add(new StationIdItem {
                Station_Id = AgvStationEnum.RX07, Station_Name = "工业实训单元"
            });
            Stations.Add(new StationIdItem {
                Station_Id = AgvStationEnum.RX08, Station_Name = "汽车刹车盘单元"
            });
            Stations.Add(new StationIdItem {
                Station_Id = AgvStationEnum.RX09, Station_Name = "3C加工单元单元"
            });


            //测试用
            //TestStationDevice 替换成 AgvStationClient\AllenBradleyClientDevice(RX07) 或者AgvStationClient\FanucRobotClientDevice(RX08/RX09)
            _Client = new TestStationCient <TestStationDevice>(AgvStationEnum.RX08, new TestStationDevice());

            _Client.SendStationClientStateMessageEvent += (s) => {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Messages.Add(new MessageItem {
                        State = s.State, Message = s.Message, CreateDateTime = DateTime.Now
                    });
                });
            };

            m_static_BackgroundWorker.WorkerReportsProgress      = false;
            m_static_BackgroundWorker.WorkerSupportsCancellation = true;
            m_static_BackgroundWorker.DoWork += ScannerStaticFunc;
            m_static_BackgroundWorker.RunWorkerAsync();
        }
예제 #28
0
        public void AddStation(string address, double latitude, double longitude, string stationId)
        {
            Station station = new Station(address, stationId, latitude, longitude);

            Stations.Add(station);
        }
예제 #29
0
        /// <summary>
        /// Initialize the view model
        /// </summary>
        private void Init()
        {
            Log("Initializing ..");

            //First task who gets the stations state
            var t1 = new Task(async() =>
            {
                HttpClient httpClient        = new HttpClient();
                httpClient.Timeout           = TimeSpan.FromSeconds(30);
                Task <HttpResponseMessage> t = null;
                try
                {
                    //IMPORTANT !!
                    //If the link above doesn't work , it's because the free azure account doesn't work anymore , so you need to run it locally
                    t = httpClient.GetAsync("https://finalprojectsela.azurewebsites.net/api/airport/GetCurrentStationsState");
                    t.Wait();
                }

                catch (Exception exc)
                {
                    OnError(exc.Message);
                }
                if (t.Result.StatusCode == System.Net.HttpStatusCode.BadRequest || t.Result.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    OnError(t.Result.Content.ReadAsStringAsync().Result);
                }
                else
                {
                    var result = JsonConvert.DeserializeObject <List <Common.Station> >(t.Result.Content.ReadAsStringAsync().Result);
                    foreach (var station in result)
                    {
                        await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                        {
                            if (station.Plane != null)
                            {
                                Planes.Add(new Models.Plane(station.Plane.Name, station.Plane.ActionDate, station.Plane.waitingTime, station.Plane.flightState));
                                Stations.Add(new Models.Station(station.Number)
                                {
                                    Plane = station.Plane.Name
                                });
                            }

                            else
                            {
                                Stations.Add(new Models.Station(station.Number));
                            }
                        });
                    }
                }
            });

            //Second Task who get the future departures and arrivals
            var t2 = new Task(async() =>
            {
                HttpClient httpClient        = new HttpClient();
                httpClient.Timeout           = TimeSpan.FromSeconds(30);
                Task <HttpResponseMessage> t = null;
                try
                {
                    //IMPORTANT !!
                    //If the link above doesn't work , it's because the free azure account doesn't work anymore , so you need to run it locally
                    t = httpClient.GetAsync("https://finalprojectsela.azurewebsites.net/api/airport/GetFutureDeparturesAndArrivals");
                    t.Wait();
                }
                catch (Exception exc)
                {
                    OnError(exc.Message);
                }

                if (t.Result.StatusCode == System.Net.HttpStatusCode.BadRequest || t.Result.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    OnError(t.Result.Content.ReadAsStringAsync().Result);
                }
                else
                {
                    var result = JsonConvert.DeserializeObject <List <Common.Plane> >(t.Result.Content.ReadAsStringAsync().Result);
                    foreach (var plane in result)
                    {
                        await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                        {
                            FutureFlights.Add(new Models.Plane(plane.Name, plane.ActionDate, plane.waitingTime, plane.flightState));
                        });
                    }
                }
            });

            //Third task who open the hub connection
            var t3 = new Task(() =>
            {
                try
                {
                    //IMPORTANT !!
                    //If the link above doesn't work , it's because the free azure account doesn't work anymore , so you need to run it locally
                    HubConnection hubConnection = new HubConnection("https://finalprojectsela.azurewebsites.net");
                    var proxy = hubConnection.CreateHubProxy("AirportHub");
                    proxy.On <Common.Plane>("departureOrArrival", DepartureOrArrival);
                    proxy.On <Common.Plane>("moved", Moved);
                    proxy.On <string>("onerror", OnError);
                    hubConnection.Start();
                }
                catch (Exception exc)
                {
                    OnError(exc.Message);
                    throw;
                }
            });

            t1.Start();
            t2.Start();
            t3.Start();

            Task.WhenAll(t1, t2, t3).ContinueWith((t) => { Log("Finished initialization ! "); });
        }
예제 #30
0
        public async Task AddStationAsync(RadioStation station)
        {
            await _sqlService.InsertAsync(station);

            Stations.Add(station);
        }