Exemplo n.º 1
0
        public void AddVehicleType(string vehicleTypeName, int index, string value)
        {
            var vehicleType = new VehicleType(vehicleTypeName);

            vehicleType.AddCapacityDimension(index, value);
            VehicleTypes.Add(vehicleType);
        }
Exemplo n.º 2
0
        public void Init(bool isEditMode, string vehicleId, string plateNumber, string type)
        {
            IsEditMode  = isEditMode;
            Title       = isEditMode ? "Edit Event" : "Add Event";
            ButtonTitle = isEditMode ? "Edit" : "Add";

            //demo data
            VehicleTypes.Add(new VehicleTypeItemViewModel()
            {
                Type = "compact",
            });
            VehicleTypes.Add(new VehicleTypeItemViewModel()
            {
                Type = "sedan"
            });

            PlateNumber = !string.IsNullOrEmpty(plateNumber) ? plateNumber : string.Empty;
            if (!string.IsNullOrEmpty(type))
            {
                var vehicleType = VehicleTypes.FirstOrDefault(x => x.Type.Equals(type));
                if (vehicleType != null)
                {
                    vehicleType.IsChecked = true;
                }
            }

            VehicleId = vehicleId;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Moped()
        {
            AccessibleTags.Remove("motorway");
            AccessibleTags.Remove("motorway_link");

            VehicleTypes.Add("moped");
        }
Exemplo n.º 4
0
 private void LoadModes()
 {
     AllModes       = new List <ITashaMode>();
     NonSharedModes = new List <ITashaMode>();
     AllModes.Add(AutoMode);
     NonSharedModes.Add(AutoMode);
     foreach (var mode in OtherModes)
     {
         AllModes.Add(mode);
         NonSharedModes.Add(mode);
     }
     foreach (var mode in SharedModes)
     {
         AllModes.Add(mode);
     }
     VehicleTypes.Add(AutoType);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Bicycle()
        {
            AccessibleTags.Add("cycleway", string.Empty);
            AccessibleTags.Add("path", string.Empty);
            AccessibleTags.Add("road", string.Empty);
            AccessibleTags.Add("track", string.Empty);
            AccessibleTags.Add("living_street", string.Empty);
            AccessibleTags.Add("residential", string.Empty);
            AccessibleTags.Add("unclassified", string.Empty);
            AccessibleTags.Add("secondary", string.Empty);
            AccessibleTags.Add("secondary_link", string.Empty);
            AccessibleTags.Add("primary", string.Empty);
            AccessibleTags.Add("primary_link", string.Empty);
            AccessibleTags.Add("tertiary", string.Empty);
            AccessibleTags.Add("tertiary_link", string.Empty);

            VehicleTypes.Add("bicycle");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        protected MotorVehicle()
        {
            AccessibleTags.Add("road", string.Empty);
            AccessibleTags.Add("living_street", string.Empty);
            AccessibleTags.Add("residential", string.Empty);
            AccessibleTags.Add("unclassified", string.Empty);
            AccessibleTags.Add("secondary", string.Empty);
            AccessibleTags.Add("secondary_link", string.Empty);
            AccessibleTags.Add("primary", string.Empty);
            AccessibleTags.Add("primary_link", string.Empty);
            AccessibleTags.Add("tertiary", string.Empty);
            AccessibleTags.Add("tertiary_link", string.Empty);
            AccessibleTags.Add("trunk", string.Empty);
            AccessibleTags.Add("trunk_link", string.Empty);
            AccessibleTags.Add("motorway", string.Empty);
            AccessibleTags.Add("motorway_link", string.Empty);

            VehicleTypes.Add("vehicle");       // a motor vehicle is a generic vehicle.
            VehicleTypes.Add("motor_vehicle"); // ... and also a generic motor vehicle.
        }
 public void Init(string type)
 {
     VehicleTypes.Add(new VehicleTypeItemViewModel()
     {
         Type = "compact"
     });
     VehicleTypes.Add(new VehicleTypeItemViewModel()
     {
         Type = "sedan"
     });
     if (!string.IsNullOrEmpty(type))
     {
         foreach (var item in VehicleTypes)
         {
             if (item.Type.Equals(type))
             {
                 item.IsChecked = true;
             }
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Bicycle()
        {
            AccessibleTags.Add("steps", string.Empty); // only when there is a ramp.
            AccessibleTags.Add("service", string.Empty);
            AccessibleTags.Add("cycleway", string.Empty);
            AccessibleTags.Add("path", string.Empty);
            AccessibleTags.Add("road", string.Empty);
            AccessibleTags.Add("track", string.Empty);
            AccessibleTags.Add("living_street", string.Empty);
            AccessibleTags.Add("residential", string.Empty);
            AccessibleTags.Add("unclassified", string.Empty);
            AccessibleTags.Add("secondary", string.Empty);
            AccessibleTags.Add("secondary_link", string.Empty);
            AccessibleTags.Add("primary", string.Empty);
            AccessibleTags.Add("primary_link", string.Empty);
            AccessibleTags.Add("tertiary", string.Empty);
            AccessibleTags.Add("tertiary_link", string.Empty);

            VehicleTypes.Add("vehicle"); // a bicycle is a generic vehicle.
            VehicleTypes.Add("bicycle");
        }
Exemplo n.º 9
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Pedestrian()
        {
            AccessibleTags.Add("services", string.Empty);
            AccessibleTags.Add("steps", string.Empty);
            AccessibleTags.Add("footway", string.Empty);
            AccessibleTags.Add("cycleway", string.Empty);
            AccessibleTags.Add("path", string.Empty);
            AccessibleTags.Add("road", string.Empty);
            AccessibleTags.Add("track", string.Empty);
            AccessibleTags.Add("pedestrian", string.Empty);
            AccessibleTags.Add("living_street", string.Empty);
            AccessibleTags.Add("residential", string.Empty);
            AccessibleTags.Add("unclassified", string.Empty);
            AccessibleTags.Add("secondary", string.Empty);
            AccessibleTags.Add("secondary_link", string.Empty);
            AccessibleTags.Add("primary", string.Empty);
            AccessibleTags.Add("primary_link", string.Empty);
            AccessibleTags.Add("tertiary", string.Empty);
            AccessibleTags.Add("tertiary_link", string.Empty);

            VehicleTypes.Add("pedestrian");
        }
Exemplo n.º 10
0
        private void GetTypesOfVehcile()
        {
            using SqlConnection openConnection = new SqlConnection(connectionString);

            string selectQuery = "SELECT ID, Code, Name FROM TypeOfVehicle";

            using SqlCommand selectCommand = new SqlCommand(selectQuery);
            selectCommand.Connection       = openConnection;

            try
            {
                openConnection.Open();

                using SqlDataReader reader = selectCommand.ExecuteReader();
                logger.Info("Getting type of vehicles data from database..");

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        VehicleTypes.Add(new TypeOfVehicle((Guid)reader["ID"], (string)reader["Code"], (string)reader["Name"]));
                    }
                    logger.Info("Type of vehicle data is successfuly retieved.");
                }
                else
                {
                    logger.Info("There is no types of vehicle data in database.");
                }

                reader.Close();
                openConnection.Close();
            }
            catch (Exception ex)
            {
                logger.Error("The type of vehicles data retrieval did not succeed.");
                logger.Error(ex.Message);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public BigTruck()
 {
     // http://wiki.openstreetmap.org/wiki/Key:hgv#Land-based_transportation
     VehicleTypes.Add("hgv");
 }
Exemplo n.º 12
0
        public void Start()
        {
            // setup the status to be initializing
            _Status          = null;
            _Progress        = () => 0f;
            CurrentIteration = 0;
            if (!VehicleTypes.Contains(AutoType))
            {
                VehicleTypes.Add(AutoType);
            }
            ZoneSystem.LoadData();
            if (PreRun != null)
            {
                foreach (var module in PreRun)
                {
                    module.Start();
                }
            }
            IterationPercentage = 1f / TotalIterations;
            if (PostScheduler != null)
            {
                foreach (var module in PostScheduler)
                {
                    module.Load(TotalIterations);
                }
            }
            if (PostHousehold != null)
            {
                foreach (var module in PostHousehold)
                {
                    module.Load(TotalIterations);
                }
            }

            if (OverrideModeParameters)
            {
                InitializeParameters();
            }
            LoadNetworkData(0);
            if (Scheduler != null)
            {
                Scheduler.LoadOneTimeLocalData();
            }

            if (ModeChoice != null)
            {
                ModeChoice.LoadOneTimeLocalData();
            }

            for (int i = 0; i < TotalIterations; i++)
            {
                if (!_ExitRequested)
                {
                    CurrentHousehold             = 0;
                    CurrentIteration             = i;
                    CompletedIterationPercentage = i * IterationPercentage;
                    if (LoadAllHouseholds)
                    {
                        if (!SkipLoadingHouseholds)
                        {
                            HouseholdLoader.LoadData();
                        }
                    }
                    RunIteration(i);
                }
            }
            if (PostRun != null)
            {
                foreach (var module in PostRun)
                {
                    module.Start();
                }
            }
            ZoneSystem.UnloadData();
        }
Exemplo n.º 13
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public MotorCycle()
 {
     VehicleTypes.Add("motorcycle");
 }
Exemplo n.º 14
0
        private void BuildHouseholdData()
        {
            // We actually don't need to startup the networks since we don't need their data.
            // We just need them so we know that the modes will be satisfied when running
            ZoneSystem.LoadData();
            HouseholdLoader.LoadData();
            var households = HouseholdLoader.ToArray();

            VehicleTypes.Add(AutoType);
            using (MemoryStream mem = new MemoryStream())
            {
                BinaryWriter writer = new BinaryWriter(mem);
                writer.Write(households.Length);
                var numberOfVehicleTypes = VehicleTypes.Count;
                writer.Write(numberOfVehicleTypes);
                for (int i = 0; i < numberOfVehicleTypes; i++)
                {
                    writer.Write(VehicleTypes[i].VehicleName);
                }
                foreach (var household in households)
                {
                    // write out all of the household attributes
                    writer.Write(household.HouseholdId);
                    writer.Write(household.Persons.Length);
                    for (int i = 0; i < numberOfVehicleTypes; i++)
                    {
                        writer.Write(household.Vehicles.Count((v) => v.VehicleType.VehicleName == VehicleTypes[i].VehicleName));
                    }
                    writer.Write(household.HomeZone.ZoneNumber);
                    SendAttached(writer, household);
                    foreach (var person in household.Persons)
                    {
                        // Send the person's information
                        writer.Write(person.Age);
                        writer.Write(person.Female);
                        writer.Write((Int32)person.EmploymentStatus);
                        writer.Write((Int32)person.Occupation);
                        if (person.EmploymentZone == null)
                        {
                            writer.Write(-1);
                        }
                        else
                        {
                            writer.Write(person.EmploymentZone.ZoneNumber);
                        }
                        writer.Write((Int32)person.StudentStatus);
                        if (person.SchoolZone == null)
                        {
                            writer.Write(-1);
                        }
                        else
                        {
                            writer.Write(person.SchoolZone.ZoneNumber);
                        }
                        writer.Write(person.Licence);

                        writer.Write(person.FreeParking);
                        SendAttached(writer, person);
                        // Start sending the trip chains
                        writer.Write(person.TripChains.Count);
                        foreach (var tripChain in person.TripChains)
                        {
                            writer.Write(tripChain.JointTripID);
                            writer.Write(tripChain.JointTripRep);
                            SendAttached(writer, tripChain);
                            writer.Write(tripChain.Trips.Count);
                            foreach (var trip in tripChain.Trips)
                            {
                                writer.Write(trip.OriginalZone.ZoneNumber);
                                writer.Write(trip.DestinationZone.ZoneNumber);
                                writer.Write((Int32)trip.Purpose);
                                writer.Write(trip.ActivityStartTime.Hours);
                                writer.Write(trip.ActivityStartTime.Minutes);
                                writer.Write(trip.ActivityStartTime.Seconds);
                                var mode = ((ITashaMode)trip[ObservedMode]);
                                if (mode == null)
                                {
                                    throw new XTMFRuntimeException(this, "In household #" + household.HouseholdId
                                                                   + " for Person #" + person.Id + " for Trip #" + trip.TripNumber + " there was no observed mode stored!");
                                }
                                writer.Write(mode.ModeName);
                                SendAttached(writer, trip);
                            }
                        }
                    }
                }
                writer.Flush();
                HouseholdData = mem.ToArray();
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public Car()
 {
     VehicleTypes.Add("motorcar");
 }
Exemplo n.º 16
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Bus()
 {
     // http://wiki.openstreetmap.org/wiki/Key:tourist_bus
     VehicleTypes.Add("tourist_bus");
 }
Exemplo n.º 17
0
 public bool AddNewVehicleType(VehicleType vehicleType)
 {
     return(vehicleTypes.Add(vehicleType));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public SmallTruck()
 {
     // http://wiki.openstreetmap.org/wiki/Key:goods
     VehicleTypes.Add("goods");
 }