示例#1
0
 public ArrivalBundle(BusStop stop, BusRoute bus, bool live)
 {
     this.Stop = stop;
     this.Bus = bus;
     this.Live = live;
     this.CommonDestination=bus.Long_Name;
 }
        public BusStopDetails(ClientCredentials clientCredentials)
        {
            InitializeComponent();
            ActualBusStop = new BusStop();

            busStopService = new BusStopServiceClient();

            busStopSecureService = new BusStopSecureServiceClient();
            busStopSecureService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopSecureService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            busStopTypeService = new BusStopTypeServiceClient();
            busStopTypeService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopTypeService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            busStopTypeSecureService = new BusStopTypeSecureServiceClient();
            busStopTypeSecureService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopTypeSecureService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            BusStopTypeComboBox.ItemsSource = busStopTypeService.GetAll();

            OpenAllTextBoxes();
            SaveButton.IsEnabled = true;
            EditButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;

            IsAddingNewObject = true;
        }
示例#3
0
 public ArrivalBundle(BusStop stop, BusRoute bus, List<DateTime> times, bool live=false)
 {
     this.Stop = stop;
     this.Bus = bus;
     this.Times = times;
     this.Live = live;
     this.CommonDestination=bus.Long_Name;
 }
示例#4
0
 /// <summary>
 /// Get data from NOW including LIVE data (when network online)
 /// </summary>
 public ArrivalMonitor(BusStop stop)
     : this(stop, DateTime.Now)
 {
     liveMode = true;
     db = BusDB_GTFS_SQL.Instance;
     fetcher = new LiveArrivalFetcher (myStop);
     fetcher.ArrivalsUpdated += new LiveArrivalFetcher.ArrivalObserver (receiveLiveResults);
 }
示例#5
0
 public ArrivalBundle(Arrival firstArrival)
 {
     this.Bus=firstArrival.Bus;
     this.Stop=firstArrival.Stop;
     this.Live=firstArrival.Live;
     Times=new List<DateTime>();
     Times.Add(firstArrival.Time);
     this.CommonDestination=firstArrival.Destination;
 }
示例#6
0
        /// <summary>
        /// Use schedules only
        /// </summary>
        public ArrivalMonitor(BusStop stop, DateTime afterTime)
        {
            myStop = stop;
            this.afterTime = afterTime;
            this.aheadTime = new TimeSpan (2, 0, 0);//default look ahead to 2 hrs
            db = BusDB_GTFS_SQL.Instance;

            //future time is close enough to now that RTS may have data
            //			if (afterTime.Subtract (DateTime.Now) < new TimeSpan (2, 0, 0))
            //				startLiveFetcher ();
        }
        public BusStop GenerateBusStop(string stopCode)
        {
            BusStop busStop = new BusStop();
            //Convert to stop id
            string stopId = GetStopId(stopCode);

            //Get the routes that run by each id
            List<Route> routes = GetRoutes(stopId);

            //Get the shapes.
            //List<Shape> shapes = GetShapes(shape_id);

            return busStop;
        }
示例#8
0
        public BusStop GetBusStop(string busAtcocode)
        {
            string baseUrl = @"http://transportapi.com/v3/uk/bus/stop/"+busAtcocode+@"/live.json?group=route";
            String json = _provider.GetData(baseUrl);
            BusStop busStop = new BusStop();

            var bus = JObject.Parse(json);
            foreach (JToken child in bus.Children())
            {
                foreach (JToken grandChild in child.Children())
                {
                    foreach (JToken grandGrandChild in grandChild.Children())
                    {
                        var property = grandGrandChild as JProperty;
                        foreach (JToken grandGrandGrandChild in grandGrandChild.Children())
                        {
                            var departures = new DeparturesJson();
                            departures.Line = int.Parse(property.Name);

                            foreach (var grandGrandGrandGrandChild in grandGrandGrandChild.Children())
                            {
                                var departure =
                                JsonConvert.DeserializeObject<Departure>(grandGrandGrandGrandChild.ToString());

                                departures.Departures.Add(departure);
                            }

                            busStop.Departures.Add(departures);
                        }
                    }
                }
            }

            busStop.AtcoCode = bus["atcocode"].ToString();
            busStop.SmsCode = bus["smscode"].ToString();
            if (bus["request_time"] != null)
            {
                busStop.RequestTime = bus["request_time"].ToObject<DateTime>();
            }

            return busStop;
        }
        private void OnDepartureTimeRecieved(BusStop busStop, ICollection<BusStopTime> busStopTimes)
        {
            Dispatcher.BeginInvoke(() =>
                                       {
                                           var now = DateTime.Now;
                                           var mainViewModel = (MainViewModel)DataContext;
                                           var pivotViewModel = mainViewModel.PivotViewModels.Single(pvm => pvm.BusStop.Equals(busStop));
                                           var routes = (from bst in busStopTimes select bst.Route).Distinct().ToArray();
                                           var oldTimes = pivotViewModel.BusStopTimes.Where(bst => bst.Time < now || routes.Contains(bst.Route)).ToArray();
                                           foreach (var oldTime in oldTimes)
                                           {
                                               pivotViewModel.BusStopTimes.Remove(oldTime);
                                           }

                                           foreach (var busStopTime in busStopTimes)
                                           {
                                               pivotViewModel.BusStopTimes.Add(busStopTime);
                                           }
                                       });
        }
        public BusStopDetails(ClientCredentials clientCredentials, BusStop busStop)
        {
            InitializeComponent();
            ActualBusStop = busStop;

            busStopService = new BusStopServiceClient();

            busStopSecureService = new BusStopSecureServiceClient();
            busStopSecureService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopSecureService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            busStopTypeService = new BusStopTypeServiceClient();
            busStopTypeService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopTypeService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            busStopTypeSecureService = new BusStopTypeSecureServiceClient();
            busStopTypeSecureService.ClientCredentials.UserName.UserName = clientCredentials.UserName.UserName;
            busStopTypeSecureService.ClientCredentials.UserName.Password = clientCredentials.UserName.Password;

            BusStopTypeComboBox.ItemsSource = busStopTypeService.GetAll();
            FillData();
            SaveButton.IsEnabled = false;
        }
示例#11
0
        private static void AddTrip(List <ResultRecord> records, int paraBusNo, BusStop paraBoardStop, BusStop paraAlightStop)
        {
            TripRecord tripRecord = new TripRecord()
            {
                boardStop = paraBoardStop, alightStop = paraAlightStop
            };

            if (records.FindIndex(item => item.busNo == paraBusNo) < 0)
            {
                ResultRecord resultRecord = new ResultRecord()
                {
                    busNo = paraBusNo, trips = new HashSet <TripRecord>()
                };
                resultRecord.trips.Add(tripRecord);
                records.Add(resultRecord);
            }
            else
            {
                HashSet <TripRecord> trips = records.Find(item => item.busNo == paraBusNo).trips;
                trips.Add(tripRecord);
            }
        }
        private bool CheckSearchedText(string text, BusStop busStop)
        {
            try
            {
                for (int i = 0; i < text.Length; i++)
                {
                    if (text[i] != busStop.Name[i])
                        return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }

        }
        public MainWindow()
        {
            InitializeComponent();

            bool IsMySQLDB = true;

            DataSet busDataSet      = AccessEngine.Get("SELECT DISTINCT(bus_id) FROM [IntervalData2014-2015]");
            DataSet intervalDataSet = AccessEngine.Get("SELECT * FROM [IntervalData2014-2015]");
            DataSet routeDataSet    = AccessEngine.Get("SELECT * FROM [Route ID]");
            DataSet stopDataSet     = AccessEngine.Get("SELECT * FROM [Stop ID]");
            DataSet weatherDataSet  = AccessEngine.Get("SELECT * FROM [Weather Data]");

            List <Bus> buses = new List <Bus>();

            foreach (DataRow row in busDataSet.Tables[0].Rows)
            {
                Bus bus = new Bus();
                bus.ID          = SQLUtil.ParseID(row[0]);
                bus.Description = string.Empty;
                buses.Add(bus);
            }

            List <Route> routes = new List <Route>();

            foreach (DataRow row in routeDataSet.Tables[0].Rows)
            {
                Route route = new Route();
                route.ID = SQLUtil.ParseID(row["ID"]);
                string   info      = SQLUtil.ParseString(row["Route ID"]);
                string[] infoArray = info.Split(' ');
                if (infoArray.Length > 1 && infoArray[0].Length == 1)
                {
                    route.Name = infoArray[0];
                }
                else
                {
                    route.Name = info;
                }

                route.RouteDetail = info;

                if (route.RouteDetail.Contains("M-R"))
                {
                    route.IsMtoR = true;
                }
                else
                {
                    route.IsMtoR = false;
                }

                routes.Add(route);
            }

            List <RouteDetail> routeDetails = new List <RouteDetail>();
            List <string>      lines        = new List <string>();

            //Build each route.
            lines = CSVUtil.ReadCSV("A.csv");
            int ARouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = ARouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            lines.Clear();
            lines = CSVUtil.ReadCSV("B.csv");
            int BRouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = BRouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            lines.Clear();
            lines = CSVUtil.ReadCSV("E.csv");
            int ERouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = ERouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            lines.Clear();
            lines = CSVUtil.ReadCSV("X.csv");
            int XRouteID = routes.First(o => o.Name == lines[0].Substring(0, 1) && o.IsMtoR == true).ID.Value;

            for (int i = 2; i < lines.Count; i++) // Line 0 is route name and Line 1 is header
            {
                string[]    line = lines[i].Split(',');
                RouteDetail rd   = new RouteDetail();
                rd.RouteID       = ERouteID;
                rd.Sequence      = i - 1;
                rd.FromBusStopID = int.Parse(line[0]);
                rd.ToBusStopID   = int.Parse(line[1]);
                if (rd.FromBusStopID == rd.ToBusStopID)
                {
                    rd.IsStationary = true;
                }
                else
                {
                    rd.IsStationary = false;
                }

                rd.Distance            = double.Parse(line[2]);
                rd.IdealTravelTime     = int.Parse(line[3]);
                rd.ScheduledTravelTime = int.Parse(line[3]);
                if (rd.IsStationary)
                {
                    rd.ScheduledStopTime = int.Parse(line[3]);
                }

                routeDetails.Add(rd);
            }

            List <BusStop> busStops = new List <BusStop>();

            //foreach (DataRow row in stopDataSet.Tables[0].Rows)
            //{
            //    BusStop busStop = new BusStop();
            //    busStop.ID = SQLUtil.ParseID(row["ID"]);
            //    busStop.Name = SQLUtil.ParseString(row["Stop"]);
            //    busStop.IsMajorStop = false;

            //    busStops.Add(busStop);
            //}

            lines.Clear();
            lines = CSVUtil.ReadCSV("Combined GPS Data.csv");
            for (int i = 1; i < lines.Count; i++) // Line 0 is header
            {
                string[] line    = lines[i].Split(',');
                BusStop  busStop = new BusStop();
                busStop.ID        = int.Parse(line[0]);
                busStop.Name      = line[1];
                busStop.Latitude  = double.Parse(line[2]);
                busStop.Longitude = double.Parse(line[3]);
                busStop.Buddy     = line[4];
                if (line[5].ToLower() == "yes")
                {
                    busStop.Visible = true;
                }
                else
                {
                    busStop.Visible = false;
                }

                if (line[6].ToLower() == "yes")
                {
                    busStop.Announce = true;
                }
                else
                {
                    busStop.Announce = false;
                }

                busStops.Add(busStop);
            }


            List <Weather> weathers = new List <Weather>();

            foreach (DataRow row in weatherDataSet.Tables[0].Rows)
            {
                Weather weather = new Weather();
                weather.ID            = SQLUtil.ParseID(row["ID"]);
                weather.Date          = SQLUtil.ParseDateTime(row["EDT"]);
                weather.MinTemp       = SQLUtil.ParseInt(row["MinTemp"]);
                weather.Precipitation = SQLUtil.ParseString(row["Precipitation"]);
                weather.Events        = SQLUtil.ParseString(row["Events"]);

                weathers.Add(weather);
            }

            List <Interval> intervals = new List <Interval>();

            foreach (DataRow row in intervalDataSet.Tables[0].Rows)
            {
                Interval interval = new Interval();
                //interval.ID = SQLUtil.ParseID(row["ID1"]);
                interval.BusID = SQLUtil.ParseInt(row["bus_id"]);
                string routeName = SQLUtil.ParseString(row["route_id"]);
                if (routeName == "354")
                {
                    routeName = "A";
                }
                interval.RouteObj      = routes.First(o => o.Name == routeName && o.IsMtoR == true);
                interval.FromBusStopID = SQLUtil.ParseInt(row["from"]);
                string toBusStop = SQLUtil.ParseString(row["to"]);
                interval.ToBusStopID = busStops.First(o => o.Name.ToLower().Contains(toBusStop.ToLower())).ID.Value;

                if (interval.FromBusStopID == interval.ToBusStopID)
                {
                    interval.IsStationary = true;
                }
                else
                {
                    interval.IsStationary = false;
                }

                interval.TimeInterval = SQLUtil.ParseInt(row["time"]);
                interval.Timestamp    = SQLUtil.ParseDateTime(row["when"]);

                Weather temp = weathers.FirstOrDefault(o => o.DateString == interval.Timestamp.ToShortDateString());
                if (temp != null)
                {
                    interval.MinTemp       = temp.MinTemp;
                    interval.Precipitation = temp.Precipitation;
                    interval.Events        = temp.Events;
                }

                intervals.Add(interval);
            }

            DataTable rdDataTable;

            if (IsMySQLDB)
            {
                MySQLEngine.OpenDBConnection();
                MySqlCommand myCmd = new MySqlCommand();

                foreach (Bus bus in buses)
                {
                    myCmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (Bus bus in buses)
                {
                    myCmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (BusStop busStop in busStops)
                {
                    myCmd.CommandText = "INSERT INTO TBL_BusStop(ID, Name, IsMajorStop, Latitude, Longitude, Buddy, Visible, Announce) VALUES ("
                                        + busStop.ID + ", '" + busStop.Name.Replace("'", "''") + "', '" + busStop.IsMajorStop + "', "
                                        + busStop.Latitude + ", " + busStop.Longitude + ", '" + busStop.Buddy + "', '"
                                        + busStop.Visible + "', '" + busStop.Announce + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (Route route in routes)
                {
                    myCmd.CommandText = "INSERT INTO TBL_Route(ID, Name, RouteDetail, IsMtoR) VALUES (" + route.ID + ", '"
                                        + route.Name + "', '" + route.RouteDetail + "', '" + route.IsMtoR.ToString() + "')";

                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                foreach (RouteDetail rd in routeDetails)
                {
                    myCmd.CommandText = "INSERT INTO TBL_RouteDetail(RouteID, Sequence, FromBusStopID, ToBusStopID, IsStationary, "
                                        + "Distance, IdealTravelTime, ScheduleStopTime, ScheduleTravelTime) VALUES ("
                                        + rd.RouteID + ", " + rd.Sequence + ", " + rd.FromBusStopID + ", " + rd.ToBusStopID
                                        + ", '" + rd.IsStationary + "', " + rd.Distance + ", " + rd.IdealTravelTime
                                        + ", " + rd.ScheduledStopTime + ", " + rd.ScheduledTravelTime + ")";

                    MySQLEngine.ExecuteCommandText(myCmd);
                    myCmd.CommandText = "SELECT MAX(ID) FROM TBL_RouteDetail";
                    rdDataTable       = MySQLEngine.GetDataTableCommandText(myCmd);
                    rd.ID             = SQLUtil.ParseID(rdDataTable.Rows[0][0]);
                }

                foreach (Interval interval in intervals)
                {
                    interval.RouteDetailObj = routeDetails.FirstOrDefault(o => o.FromBusStopID == interval.FromBusStopID &&
                                                                          o.ToBusStopID == interval.ToBusStopID && o.RouteID == interval.RouteID);
                    myCmd.CommandText = "INSERT INTO TBL_Interval(BusID, RouteID, RouteDetailID, FromBusStopID, ToBusStopID, "
                                        + "IsStationary, TimeInterval, Timestamp, Day, MinTemp, Precipitation, Events) VALUES ("
                                        + interval.BusID + ", " + interval.RouteID + ", " + interval.RouteDetailID + ", "
                                        + interval.FromBusStopID + ", " + interval.ToBusStopID + ", '" + interval.IsStationary + "', "
                                        + interval.TimeInterval + ", '" + interval.Timestamp.ToString() + "', '" + interval.Day + "', "
                                        + interval.MinTemp + ", '" + interval.Precipitation + "', '" + interval.Events + "')";
                    MySQLEngine.ExecuteCommandText(myCmd);
                }

                MySQLEngine.CloseDBConnection();
            }
            else
            {
                SQLEngine.OpenDBConnection();
                SqlCommand cmd = new SqlCommand();

                foreach (Bus bus in buses)
                {
                    cmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (Bus bus in buses)
                {
                    cmd.CommandText = "INSERT INTO TBL_Bus(ID, Description) VALUES (" + bus.ID + ", '" + bus.Description + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (BusStop busStop in busStops)
                {
                    cmd.CommandText = "INSERT INTO TBL_BusStop(ID, Name, IsMajorStop, Latitude, Longitude, Buddy, Visible, Announce) VALUES ("
                                      + busStop.ID + ", '" + busStop.Name.Replace("'", "''") + "', '" + busStop.IsMajorStop + "', "
                                      + busStop.Latitude + ", " + busStop.Longitude + ", '" + busStop.Buddy + "', '"
                                      + busStop.Visible + "', '" + busStop.Announce + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (Route route in routes)
                {
                    cmd.CommandText = "INSERT INTO TBL_Route(ID, Name, RouteDetail, IsMtoR) VALUES (" + route.ID + ", '"
                                      + route.Name + "', '" + route.RouteDetail + "', '" + route.IsMtoR.ToString() + "')";

                    SQLEngine.ExecuteCommandText(cmd);
                }

                foreach (RouteDetail rd in routeDetails)
                {
                    cmd.CommandText = "INSERT INTO TBL_RouteDetail(RouteID, Sequence, FromBusStopID, ToBusStopID, IsStationary, "
                                      + "Distance, IdealTravelTime, ScheduleStopTime, ScheduleTravelTime) VALUES ("
                                      + rd.RouteID + ", " + rd.Sequence + ", " + rd.FromBusStopID + ", " + rd.ToBusStopID
                                      + ", '" + rd.IsStationary + "', " + rd.Distance + ", " + rd.IdealTravelTime
                                      + ", " + rd.ScheduledStopTime + ", " + rd.ScheduledTravelTime + ")";

                    SQLEngine.ExecuteCommandText(cmd);
                    cmd.CommandText = "SELECT MAX(ID) FROM TBL_RouteDetail";
                    rdDataTable     = SQLEngine.GetDataTableCommandText(cmd);
                    rd.ID           = SQLUtil.ParseID(rdDataTable.Rows[0][0]);
                }

                foreach (Interval interval in intervals)
                {
                    interval.RouteDetailObj = routeDetails.FirstOrDefault(o => o.FromBusStopID == interval.FromBusStopID &&
                                                                          o.ToBusStopID == interval.ToBusStopID && o.RouteID == interval.RouteID);
                    cmd.CommandText = "INSERT INTO TBL_Interval(BusID, RouteID, RouteDetailID, FromBusStopID, ToBusStopID, "
                                      + "IsStationary, TimeInterval, Timestamp, Day, MinTemp, Precipitation, Events) VALUES ("
                                      + interval.BusID + ", " + interval.RouteID + ", " + interval.RouteDetailID + ", "
                                      + interval.FromBusStopID + ", " + interval.ToBusStopID + ", '" + interval.IsStationary + "', "
                                      + interval.TimeInterval + ", '" + interval.Timestamp.ToString() + "', '" + interval.Day + "', "
                                      + interval.MinTemp + ", '" + interval.Precipitation + "', '" + interval.Events + "')";
                    SQLEngine.ExecuteCommandText(cmd);
                }

                SQLEngine.CloseDBConnection();
            }
        }
示例#14
0
    IEnumerator GetOnBus(BusStop BS, PlayerController Bus, int SeatID)
    {
        TB = GameObject.FindWithTag("TextBox").GetComponent <TextBox>();

        yield return(new WaitForSeconds(1f));    //WAIT FOR A SECOND

        Busy = true;
        StartCoroutine(GoTo(Bus.Door.position, Bus.Door.rotation)); //GO TO BUS DOOR
        while (Busy)
        {
            yield return(null);
        }

        this.transform.SetParent(Bus.transform);

        yield return(new WaitForSeconds(0.25f));

        Busy = true;
        StartCoroutine(GoTo(Bus.Stand.position, Bus.Stand.rotation));   //GO UP TO DRIVER
        while (Busy)
        {
            yield return(null);
        }

        while (TB.isActive)      //WAIT TILL DRIVER IS FREE TO SPEAK
        {
            yield return(null);
        }

        isSpeaking       = true; //SPEAK TO DRIVER
        TB.CurrentVoice  = P.V;
        TB.CurrentSource = ASC;
        ASC.SetVolume(1f);

        int Index = 0;

        while (Index < C.IntroLines.Count)
        {
            TB.DisplayText(C.IntroLines[Index]);
            while (TB.isPrinting)
            {
                yield return(null);
            }
            Index++;
        }

        GameObject Documents = Instantiate(DocumentPrefab, DocumentLocation.position, DocumentLocation.rotation);   //SPAWN DOCUMENT

        Documents.transform.SetParent(DocumentLocation);
        Documents.GetComponent <Document>().P = this;
        Bus.TalkingTo = this;

        while (CurrentStatus == Status.Waiting) //WAIT FOR APPROVAL OR DENIAL
        {
            yield return(null);
        }

        TB.Toggle();
        isSpeaking = false;
        Documents.GetComponent <DashObject>().Delete();

        if (CurrentStatus == Status.Approved) //IF APPROVED
        {
            isSpeaking       = true;          //SPEAK TO DRIVER AFTER DENIAL
            TB.CurrentVoice  = P.V;
            TB.CurrentSource = ASC;
            ASC.SetVolume(1f);
            if (Faked == Document.FakedPart.None)
            {
                GameSettings.SC.SetMoney(GameSettings.SC.GetMoney() + GameSettings.PassengerIncome);
            }
            else
            {
                M.MUI.Fines++;
                Bus.B.ShowWarning(true);
            }

            Index = 0;
            while (Index < C.AcceptedLines.Count)
            {
                TB.DisplayText(C.AcceptedLines[Index]);
                while (TB.isPrinting)
                {
                    yield return(null);
                }
                Index++;
            }

            while (TB.isPrinting) //WAIT TO DISABLE TEXT BOX
            {
                yield return(null);
            }

            BS.PaidCount++;     //ALERT BUS STOP TO SEND NEXT PERSON

            Busy = true;
            StartCoroutine(GoTo(Bus.Seats[SeatID].position, Bus.Seats[SeatID].rotation));   //FIND A SEAT AND GO TO IT
            while (Busy)
            {
                yield return(null);
            }

            TB.Toggle();
            isSpeaking = false;

            yield return(new WaitForSeconds(0.5f));

            Bus.CurrentPassengers.Add(this);
            BS.LoadedAmount++;
        }
        else
        {
            isSpeaking       = true; //SPEAK TO DRIVER AFTER DENIAL
            TB.CurrentVoice  = P.V;
            TB.CurrentSource = ASC;
            ASC.SetVolume(1f);
            if (Faked == Document.FakedPart.None)
            {
                M.MUI.Fines++;
                Bus.B.ShowWarning(false);
            }

            Index = 0;
            while (Index < C.DenialLines.Count)
            {
                TB.DisplayText(C.DenialLines[Index]);
                while (TB.isPrinting)
                {
                    yield return(null);
                }
                Index++;
            }

            while (TB.isPrinting) //WAIT TO DISABLE TEXT BOX
            {
                yield return(null);
            }

            Busy = true;
            StartCoroutine(GoTo(Bus.Door.position, Bus.Door.rotation));        //GO TO DOOR
            while (Busy)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(0.25f));

            TB.Toggle();
            isSpeaking = false;

            Busy = true;
            StartCoroutine(GoTo(BS.GetOff.position, BS.GetOff.rotation));      //GO TO BUS STOP EXIT
            while (Busy)
            {
                yield return(null);
            }

            this.transform.SetParent(null);

            BS.PaidCount++;    //ALERT BUS STOP TO SEND NEXT PERSON

            BS.LoadedAmount++; //tell bus person had been dealt with

            Busy = true;
            StartCoroutine(GoTo(BS.DeleteLocation.position, BS.DeleteLocation.rotation));   //GO BEHIND BUS STOP
            while (Busy)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(1f));

            Destroy(this.gameObject);           //DESPAWN BEHIND BUS STOP
        }
    }
示例#15
0
        private static void InitialDb(IServiceProvider provider)
        {
            var context = provider.GetService <TravelActiveContext>();

            if (context.Busses.Any())
            {
                return;
            }

            var busB1Meden = new Bus()
            {
                BusName = "Б1-Меден рудник"
            };
            var busB1Izgrev = new Bus()
            {
                BusName = "Б1-Изгрев"
            };
            var busB2Meden = new Bus()
            {
                BusName = "Б2-Меден рудник"
            };
            var busB2Izgrev = new Bus()
            {
                BusName = "Б2-Изгрев"
            };
            var bus15 = new Bus()
            {
                BusName = "15"
            };

            context.Busses.Add(busB1Meden);
            context.Busses.Add(busB1Izgrev);
            context.Busses.Add(busB2Meden);
            context.Busses.Add(busB2Izgrev);
            context.Busses.Add(bus15);
            Dictionary <string, LatLng> stops = new Dictionary <string, LatLng>()
            {
                { "Терминал Меден рудник", new LatLng(42.451615, 27.418778) },
                { "Бадемите [1]", new LatLng(42.455449, 27.418526) },
                { "Бадемите [2]", new LatLng(42.455397, 27.418306) },
                { "Резвая [1]", new LatLng(42.459098, 27.415704) },
                { "Резвая [2]", new LatLng(42.459063, 27.415526) },
                { "Захари Стоянов [1]", new LatLng(42.463218, 27.413655) },
                { "Захари Стоянов [2]", new LatLng(42.463280, 27.413479) },
                { "Езеро Вая [1]", new LatLng(42.472438, 27.429584) },
                { "Езеро Вая [2]", new LatLng(42.472794, 27.429548) },
                { "Спортна [1]", new LatLng(42.490874, 27.454128) },
                { "Спортна [2]", new LatLng(42.490935, 27.454168) },
                { "Терминал Юг", new LatLng(42.490531, 27.474512) },
                { "Тройката", new LatLng(42.497840, 27.468901) },
                { "Александровска [1]", new LatLng(42.502627, 27.468655) },
                { "Александровска [2]", new LatLng(42.502650, 27.468665) },
                { "Стефан Стамболов [1]", new LatLng(42.507712, 27.468465) },
                { "Стефан Стамболов [2]", new LatLng(42.507728, 27.468368) },
                { "Зорница [1]", new LatLng(42.514388, 27.463446) },
                { "Зорница [2]", new LatLng(42.514356, 27.463103) },
                { "Никола Петков [1]", new LatLng(42.520566, 27.464800) },
                { "Никола Петков [2]", new LatLng(42.520744, 27.464712) },
                { "Велека [1]", new LatLng(42.524874, 27.464061) },
                { "Велека [2]", new LatLng(42.524893, 27.464009) },
                { "Добри Чинтулов [1]", new LatLng(42.527304, 27.464507) },
                { "Добри Чинтулов [2]", new LatLng(42.527292, 27.464445) },
                { "Аква Калиде [1]", new LatLng(42.529975, 27.463051) },
                { "Аква Калиде [2]", new LatLng(42.530000, 27.462967) },
                { "Терминал Изгрев", new LatLng(42.529203, 27.458839) },
                { "Опера", new LatLng(42.494592, 27.470038) },
                { "Младост [1]", new LatLng(42.519912, 27.458724) },
                { "Младост [2]", new LatLng(42.519880, 27.458317) },
                { "Тракия- разделителна [1]", new LatLng(42.521220, 27.454248) },
                { "Тракия- разделителна [2]", new LatLng(42.521191, 27.454271) },
                { "Антон Страшимиров [1]", new LatLng(42.518347, 27.449436) },
                { "Антон Страшимиров [2]", new LatLng(42.518357, 27.449499) },
                { "Янко Комитов [1]", new LatLng(42.518481, 27.444311) },
                { "Янко Комитов [2]", new LatLng(42.518394, 27.444165) },
                { "Терминал Славейков", new LatLng(42.519698, 27.438370) },
                { "Автогара Юг", new LatLng(42.490250, 27.473698) },
                { "Булаир [1]", new LatLng(42.492076, 27.478651) },
                { "Булаир [2]", new LatLng(42.492105, 27.478631) },
                { "Ген. Гурко [1]", new LatLng(42.503570, 27.475069) },
                { "Ген. Гурко [2]", new LatLng(42.503504, 27.474847) },
                { "Сан Стефано [1]", new LatLng(42.503880, 27.474717) },
                { "Сан Стефано [2]", new LatLng(42.503847, 27.474514) },
                { "Дунав [1]", new LatLng(42.506781, 27.471640) },
                { "Дунав [2]", new LatLng(42.506784, 27.471401) },
                { "Демокрация [1]", new LatLng(42.509890, 27.468494) },
                { "Демокрация [2]", new LatLng(42.509894, 27.468265) },
                { "Изгрев, бл. 3", new LatLng(42.525161, 27.454216) },
                { "Транспортна [1]", new LatLng(42.529222, 27.457778) },
                { "Транспортна [2]", new LatLng(42.529364, 27.457711) },
                { "Гробищен парк [1]", new LatLng(42.531238, 27.464396) },
                { "Гробищен парк [2]", new LatLng(42.531399, 27.464294) },
                { "Летище Бургас", new LatLng(42.564910, 27.516607) },
                { "Сарафово, Октомври", new LatLng(42.561951, 27.520317) },
                { "Сарафово, Драва", new LatLng(42.559065, 27.518771) },
                { "Сарафово, Брацигово", new LatLng(42.561022, 27.522365) },
                { "Сарафово, Ради Николов", new LatLng(42.561022, 27.522365) },
                { "Р. Летище Бургас", new LatLng(42.564592, 27.518624) },
                { "Атанасовско езеро", new LatLng(42.544832, 27.473335) },
                { "Славейков, бл. 55", new LatLng(42.525125, 27.453712) },
                { "Тракия", new LatLng(42.522543, 27.456067) },
            };
            Dictionary <string, BusStop> busStops = new Dictionary <string, BusStop>();

            foreach (var item in stops)
            {
                BusStop busStop = new BusStop()
                {
                    Latitude  = item.Value.Latitude.ToString(),
                    Longitude = item.Value.Longitude.ToString(),
                    StopName  = item.Key
                };
                busStops.Add(item.Key, busStop);
                context.BusStops.Add(busStop);
            }
            context.SaveChanges();
            var busB1MedenStops = new List <string>()
            {
                "Терминал Меден рудник", "Бадемите [1]", "Резвая [1]", "Захари Стоянов [1]", "Езеро Вая [1]", "Спортна [1]", "Терминал Юг", "Тройката", "Александровска [1]", "Стефан Стамболов [1]", "Зорница [1]", "Никола Петков [1]", "Велека [1]", "Добри Чинтулов [1]", "Аква Калиде [1]", "Терминал Изгрев"
            };
            var busB1IzgrevStops = new List <string>()
            {
                "Терминал Изгрев", "Аква Калиде [2]", "Добри Чинтулов [2]", "Велека [2]", "Никола Петков [2]", "Зорница [2]", "Стефан Стамболов [2]", "Александровска [2]", "Опера", "Терминал Юг", "Спортна [2]", "Езеро Вая [2]", "Захари Стоянов [2]", "Резвая [2]", "Бадемите [2]", "Терминал Меден рудник"
            };
            var busB2MedenStops = new List <string>()
            {
                "Терминал Меден рудник", "Бадемите [1]", "Резвая [1]", "Захари Стоянов [1]", "Езеро Вая [1]", "Спортна [1]", "Терминал Юг", "Тройката", "Александровска [1]", "Стефан Стамболов [1]", "Зорница [1]", "Младост [1]", "Тракия- разделителна [1]", "Антон Страшимиров [1]", "Янко Комитов [1]", "Терминал Славейков"
            };
            var busB2IzgrevStops = new List <string>()
            {
                "Терминал Славейков", "Янко Комитов [2]", "Антон Страшимиров [2]", "Тракия- разделителна [2]", "Младост [2]", "Зорница [2]", "Стефан Стамболов [2]", "Александровска [2]", "Опера", "Терминал Юг", "Спортна [2]", "Езеро Вая [2]", "Захари Стоянов [2]", "Резвая [2]", "Бадемите [2]", "Терминал Меден рудник"
            };
            var bus15Stops = new List <string>()
            {
                "Автогара Юг", "Булаир [1]", "Ген. Гурко [1]", "Сан Стефано [1]", "Дунав [1]", "Демокрация [1]", "Зорница [1]", "Младост [1]", "Изгрев, бл. 3", "Транспортна [1]", "Гробищен парк [1]", "Летище Бургас", "Сарафово, Октомври", "Сарафово, Драва", "Сарафово, Брацигово", "Сарафово, Ради Николов", "Р. Летище Бургас", "Атанасовско езеро", "Гробищен парк [2]", "Транспортна [2]", "Славейков, бл. 55", "Тракия", "Младост [2]", "Зорница [2]", "Демокрация [2]", "Дунав [2]", "Сан Стефано [2]", "Ген. Гурко [2]", "Булаир [2]", "Автогара Юг"
            };

            AddBusStopsToBus(context, busB1Meden, busStops, busB1MedenStops);
            AddBusStopsToBus(context, busB1Izgrev, busStops, busB1IzgrevStops);
            AddBusStopsToBus(context, busB2Meden, busStops, busB2MedenStops);
            AddBusStopsToBus(context, busB2Izgrev, busStops, busB2IzgrevStops);
            AddBusStopsToBus(context, bus15, busStops, bus15Stops);
        }
示例#16
0
 public void Add(BusStop entity)
 {
     throw new NotImplementedException();
 }
示例#17
0
 public void UnLoad(BusStop BS, PlayerController Bus)
 {
     StartCoroutine(GetOffBus(BS, Bus));
 }
示例#18
0
        public scheduling()
        {
            if (File.Exists(path: @"input.txt"))
            {
                using (StreamReader fs = new StreamReader(path: @"input.txt"))
                {
                    Console.WriteLine("File is loading");
                    string iterat    = fs.ReadLine();
                    int    iteratInt = Int32.Parse(iterat);
                    for (int i = 0; i < iteratInt; i++)
                    {
                        string   temp      = fs.ReadLine();
                        string[] array     = temp.Split(' ');
                        string   temp2     = fs.ReadLine();
                        string[] array2    = temp2.Split(' ');
                        string   temp3     = fs.ReadLine();
                        string[] array3    = temp3.Split(' ');
                        string[] array21   = array[0].Split(':');
                        string[] array22   = array[1].Split(':');
                        int      timebegin = Int32.Parse(array21[0]) * 60 + Int32.Parse(array21[1]);
                        int      timeend   = Int32.Parse(array22[0]) * 60 + Int32.Parse(array22[1]);
                        if (timebegin >= timeend)
                        {
                            timeend += 1440;
                        }
                        int timebegin1 = timebegin;

                        int sum = 0;
                        for (int j = 0; j < array3.Length; j++)
                        {
                            sum += Int32.Parse(array3[j]);
                        }
                        int timebegin2 = timebegin + sum;
                        for (int j = 0; j < array2.Length; j++)
                        {
                            Route        route1 = new Route(array[3], timebegin1, timebegin2, Int32.Parse(array[2]), timeend);
                            List <Route> list1  = new List <Route>();
                            list1.Add(route1);
                            BusStop stop1 = new BusStop(array2[j], list1);
                            if (j != array3.Length)
                            {
                                timebegin1 += Int32.Parse(array3[j]);
                                timebegin2 -= Int32.Parse(array3[j]);
                            }
                            road.Add(stop1);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("File is not loading");
                Route        route1 = new Route("Route 437", 310, 314, 5, 1500);
                List <Route> list1  = new List <Route>();
                list1.Add(route1);
                BusStop stop1 = new BusStop("E", list1);

                Route        route2 = new Route("Route 104", 200, 308, 10, 1530);
                List <Route> list2  = new List <Route>();
                list2.Add(route2);
                Route route3 = new Route("Route 437", 310, 322, 5, 1500);
                list2.Add(route3);
                BusStop stop2 = new BusStop("A", list2);

                Route        route4 = new Route("Route 437", 319, 315, 5, 1500);
                List <Route> list3  = new List <Route>();
                list3.Add(route4);
                Route route5 = new Route("Route 104", 303, 309, 10, 1530);
                list3.Add(route5);
                BusStop stop3 = new BusStop("B", list3);

                Route        route6 = new Route("Route 437", 314, 300, 5, 1500);
                List <Route> list4  = new List <Route>();
                list4.Add(route6);
                BusStop stop4 = new BusStop("F", list4);

                Route        route7 = new Route("Route 104", 318, 314, 10, 1530);
                List <Route> list5  = new List <Route>();
                list5.Add(route7);
                BusStop stop5 = new BusStop("C", list5);

                Route        route8 = new Route("Route 104", 322, 310, 10, 1530);
                List <Route> list6  = new List <Route>();
                list6.Add(route8);
                BusStop stop6 = new BusStop("D", list6);

                road.Add(stop1);
                road.Add(stop2);
                road.Add(stop3);
                road.Add(stop4);
                road.Add(stop5);
                road.Add(stop6);
            }
            while (this.processing())
            {
            }
        }
 public StopAnnotation(BusStop stop)
 {
     this.Stop = stop;
 }
示例#20
0
 public ArrivalEvent(List<Arrival> arrivals, BusStop stop)
 {
     this.Arrivals = arrivals;
     this.Stop = stop;
     Error=false;
 }
 private bool CheckTimeTableForBusStop(BusStop busStop)
 {
     return(!busStop.RouteStops.Any(a => a.Route.TimeTables.Any()));
 }
示例#22
0
 public Task AddAsync(BusStop busStop)
 {
     busStop.Departures = null;
     return(_connection.InsertAsync(busStop));
 }
示例#23
0
 public Passenger(BusStop destination, int patience)
 {
     Destination   = destination;
     this.patience = patience;
     Mood          = Mood.Happy;
 }
 public DepartureTimeService(BusStop busStop)
 {
     BusStop = busStop;
 }
示例#25
0
 public void AddBusStop(BusStop busStop)
 {
     BusStops.Add(busStop);
 }
示例#26
0
 /// <summary>
 /// Creates an object which continuously checks the WMB website at interval and reports to observer
 /// </summary>
 /// <param name='stopId'>
 /// Stop identifier.
 /// </param>
 /// <param name='observer'>
 /// Will be notified when there may be changes
 /// </param>
 /// <param name='interval'>
 /// Interval frequency in seconds or -1 to just run once
 /// </param>
 public LiveArrivalFetcher(BusStop stop)
 {
     this.myStop = stop;
 }
示例#27
0
        private async Task SeedAgencyDataAsync(NextbusAgency nxtbAgency)
        {
            var nxtbRoutes = (await _nextBusClient.GetRoutesForAgency(nxtbAgency.Tag).ConfigureAwait(false)).ToArray();

            Agency agency = (Agency)nxtbAgency;

            {
                // Populate first agency coords
                var routeConfig = await _nextBusClient.GetRouteConfig(nxtbAgency.Tag, nxtbRoutes[0].Tag)
                                  .ConfigureAwait(false);

                agency.MinLatitude  = (double)routeConfig.LatMin;
                agency.MaxLatitude  = (double)routeConfig.LatMax;
                agency.MinLongitude = (double)routeConfig.LonMin;
                agency.MaxLongitude = (double)routeConfig.LonMax;
            }

            List <AgencyRoute> routes = new List <AgencyRoute>(90);

            foreach (var nxtbRoute in nxtbRoutes)
            {
                // for testing
                //if (
                //    (agency.Tag == "ttc" && !new[] { "57", "85", "190" }.Contains(nxtbRoute.Tag))
                //    || (agency.Tag == "jtafla" && !new[] { "53" }.Contains(nxtbRoute.Tag))
                //    )
                //{
                //    continue;
                //}

                var routeConfig = await _nextBusClient.GetRouteConfig(nxtbAgency.Tag, nxtbRoute.Tag)
                                  .ConfigureAwait(false);

                AgencyRoute route = (AgencyRoute)routeConfig;

                UpdateAgencyMinMaxCoordinates(ref agency,
                                              route.MaxLatitude,
                                              route.MinLatitude,
                                              route.MaxLongitude,
                                              route.MinLongitude);

                BusStop[] busStops = GetAllBusStopsPersistNew(routeConfig.Stops);

                List <RouteDirection> directions = new List <RouteDirection>(routeConfig.Directions.Length);

                foreach (NextbusDirection nextbusDir in routeConfig.Directions)
                {
                    RouteDirection dir = (RouteDirection)nextbusDir;
                    dir.RouteDirectionBusStops.Capacity = nextbusDir.StopTags.Length;

                    foreach (string stopTag in nextbusDir.StopTags)
                    {
//                        try
//                        {
                        BusStop stop = busStops.Single(s => s.Tag == stopTag);
                        dir.RouteDirectionBusStops.Add(new RouteDirectionBusStop(dir, stop));
//                        }
//                        catch (Exception e)
//                        {
//                            Console.WriteLine(e);
//                            throw;
//                        }
                    }
                    directions.Add(dir);
                }

                route.Directions = directions;
                routes.Add(route);
            }

            agency.Routes = routes;

            if (agency.Tag.Equals(TestAgencyTag, StringComparison.OrdinalIgnoreCase))
            {
                agency.Country = TestAgencyTag;
            }

            _dbContext.Agencies.Add(agency);

            await _dbContext.SaveChangesAsync().ConfigureAwait(false);
        }
示例#28
0
 public Task AddToFavoritesAsync(BusStop busStop)
 {
     busStop.IsFavorite = true;
     return(_connection.UpdateAsync(busStop));
 }
示例#29
0
 public void Load(BusStop BS, PlayerController Bus, int SeatID)
 {
     Debug.Log("Seat ID :" + SeatID);
     StartCoroutine(GetOnBus(BS, Bus, SeatID));
 }
示例#30
0
	void SpawnNewBusStop ()
	{
		myPooledBusStop = GameObjectPool.GetPool ("BusStopPool").GetInstance ();
		busStop_Obj = myPooledBusStop.GetComponent<BusStop> ();
		Console.Log (busStop_Obj);
		int randomSide = Random.Range (0, 2);
		if (randomSide == 0) {
			busStop_Obj.transform.position = new Vector3 (-1.3f, 7, -3);

		} else {
			busStop_Obj.transform.position = new Vector3 (1.5f, 7, -3);
		}

		Console.Log ("BusStop Spawned");
	}
示例#31
0
 public Task RemoveFromFavoritesAsync(BusStop busStop)
 {
     busStop.IsFavorite = false;
     return(_connection.UpdateAsync(busStop));
 }
示例#32
0
 /// <summary>
 /// Create a model which only displays the given stop and doesn't touch preferences or use location
 /// </summary>
 /// <param name='stop'>
 /// A valid stop to display
 /// </param>
 public BusTableModel(BusStop? stop)
 {
     MonoTouch.Foundation.NSTimer.CreateRepeatingScheduledTimer (TimeSpan.FromSeconds (INTERVAL), Refresh);
     DisplayedStop = stop;
 }
示例#33
0
 public Task RenameAsync(BusStop busStop, string newName)
 {
     busStop.CustomName = newName;
     return(_connection.UpdateAsync(busStop));
 }
 private void SetDefaultStyle(BusStop busStop)
 {
     BusStopNameTextBlock.Foreground = new SolidColorBrush(Colors.White);
     BusStopNameTextBlock.FontWeight = FontWeights.Normal;
     UpdateFavouriteStyle(busStop);
 }
示例#35
0
 private void ChangeCoordinates(BusStop busStop, BusStop newBusStop)
 {
     busStop.X = newBusStop.X;
     busStop.Y = newBusStop.Y;
 }
 private void FillListView(BusStop[] bsolArray, ListView listView)
 {
     foreach (var item in bsolArray)
     {
         listView.Items.Add(item);
     }
 }
示例#37
0
 public async Task AddBusStopAsync(BusStop busStop)
 => await _repository.AddBusStopAsync(busStop);