Example #1
0
        public static void Main()
        {
            // Build a collection of all vehicles that fly
            var cessna = new Cessna();
            var archer = new PiperArcher();

            var airVehicles = new List <IAircraft> {
                cessna, archer
            };

            // With a single `foreach`, have each vehicle Fly()

            foreach (var aircraft in airVehicles)
            {
                aircraft.Start();
                aircraft.Fly();
                aircraft.Stop();
                Console.ReadLine();
            }



            // Build a collection of all vehicles that operate on roads
            var motorcycle = new Motorcycle();
            var ambulance  = new Ambulance();

            var landVehicles = new List <ILandCraft> {
                motorcycle, ambulance
            };

            // With a single `foreach`, have each road vehicle Drive()

            foreach (var vehicle in landVehicles)
            {
                vehicle.Start();
                vehicle.Drive();
                vehicle.Stop();
                Console.ReadLine();
            }



            // Build a collection of all vehicles that operate on water
            var jetSki = new JetSki();
            var ferry  = new Ferry();

            var waterVehicles = new List <IWaterCraft> {
                ferry, jetSki
            };

            // With a single `foreach`, have each water vehicle Drive()

            foreach (var waterCraft in waterVehicles)
            {
                waterCraft.Start();
                waterCraft.Drive();
                waterCraft.Stop();
                Console.ReadLine();
            }
        }
Example #2
0
        public ActionResult SaveAmbulance(string massage, Ambulance ambulance)
        {
            if (!ModelState.IsValid)
            {
                return(View("NewAmbulance", ambulance));
            }

            if (ambulance.Id == 0)
            {
                if (User.IsInRole(UserRoles.CanApproveAndDeleteRecord))
                {
                    ambulance.IsApproved = true;
                }

                _context.Ambulances.Add(ambulance);
            }
            else
            {
                var ambulanceInDb = _context.Ambulances.SingleOrDefault(a => a.Id == ambulance.Id);
                Mapper.Map(ambulance, ambulanceInDb);
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", new { massage = massage }));
        }
Example #3
0
    }//end HasGreen property

    /* drive function
     * pulls a car out of the waiting queue, queries it for next direction, then sends it down the road */
    public bool drive()
    {
        if (this.waitingVehicles.Empty())
        {
            return(false);
        }

        Vehicle v = waitingVehicles.pop();
        int     d = v.getDirection((int)this.dir);

        /* handle preemptive light switching for ambulances */
        if (v.GetType().ToString() == "Ambulance")
        {//clear future intersections and reset current intesection
            Ambulance a = (Ambulance)v;

            for (int i = 0; i < Simulation.NUM_PREEMPTIVE_GREENS; i++)
            {
                if (a.pathDirs.Count > i)
                {
                    to.outgoing[a.getFuturePath(i)].resetLights();
                }
            }
        }//end if vehicle is an ambulance

        /* drive the car through */
        if (0 <= d && d < 4)                                                                   //ambulances will return -1 if they are done
        {
            Road r = this.to.outgoing[d];                                                      //get the road to drive onto
            Simulation.futureEvents.Add(new EndOfRoadEvent(Simulation.time + r.length, r, v)); //send it down that road
            this.to.block(Simulation.CLEARING_TIME);                                           //block the intersection briefly
            return(true);
        }
        return(false);
    }
Example #4
0
 protected override void DeleteInternal()
 {
     if (Ambulance)
     {
         Ambulance.Dismiss();
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("Amb_id,Amb_num,Capacity")] Ambulance ambulance)
        {
            if (id != ambulance.Amb_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ambulance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AmbulanceExists(ambulance.Amb_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ambulance));
        }
        void GetClosestAmbulance(RouterPoint incidentPoint,
                                 ref Ambulance closestAmbulance,
                                 ref float timing,
                                 IEnumerable <Ambulance> ambulances)
        {
            foreach (var ambulance in ambulances)
            {
                RouterPoint ambulancePoint;
                try {
                    ambulancePoint = mapService.ResolvePoint(ambulance.Latitude, ambulance.Longitude);
                } catch (ResolveFailedException) {
                    logger.Info("Ambulance position cannot be resolved.");
                    continue;
                }

                Route route;
                try {
                    route = mapService.Calculate(ambulancePoint, incidentPoint);
                } catch (RouteNotFoundException) {
                    continue;
                }

                if (!(timing > 0) || route.TotalTime < timing)
                {
                    closestAmbulance = ambulance;
                    timing           = route.TotalTime;
                }
            }
        }
Example #7
0
 public ReservationController(IHttpContextAccessor httpContextAccessor, Patient patient, VetAmbulance.BL.Models.Vet vet, Ambulance ambulance, Reservation reservation)
 {
     this.httpContextAccessor = httpContextAccessor;
     this.patien      = patient;
     this.vet         = vet;
     this.ambulance   = ambulance;
     this.reservation = reservation;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Ambulance ambulance = db.Ambulances.Find(id);

            db.Ambulances.Remove(ambulance);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #9
0
        public Ambulances()
        {
            InitializeComponent();

            ambulance = Container.Get().Resolve <Ambulance>();


            GetAmbulances();
        }
Example #10
0
        public Ambulances(AmbulanceDTO amb)
        {
            InitializeComponent();

            ambulance = Container.Get().Resolve <Ambulance>();
            ambulance.Insert(amb);

            GetAmbulances();
        }
Example #11
0
    public TileMap(TileType[] tileTypes, GameManager gm, Fireman selectedUnit, Engine enG, Ambulance amB, int loadGame)
    {
        this.tileTypes    = tileTypes;
        this.gm           = gm;
        this.selectedUnit = selectedUnit;
        this.engine       = enG;
        this.ambulance    = amB;

        StartTileMap(loadGame);
    }
Example #12
0
        public virtual IActionResult CreateAmbulanceDetails([FromBody] Ambulance body, [FromRoute][Required] string ambulanceId)
        {
            //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(200);

            //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(403);

            throw new NotImplementedException();
        }
Example #13
0
        public void Edit(Ambulance ambulance)
        {
            var edit = dbContext.Ambulances.Find(ambulance.Id);

            edit.Address     = ambulance.Address;
            edit.OpeningHour = ambulance.OpeningHour;
            edit.ClosingHour = ambulance.ClosingHour;

            dbContext.SaveChanges();
        }
Example #14
0
 public EmergencyCall(double latitude, double longitude, DateTime date,
                      Patient patient, Ambulance ambulance, Hospital hospital, Symptom symptom) : this()
 {
     this.latitude  = latitude;
     this.longitude = longitude;
     this.date      = date;
     this.patient   = patient;
     this.ambulance = ambulance;
     this.hospital  = hopsital;
     symptoms.Add(symptom);
 }
Example #15
0
    private void Finish(int score)
    {
        if (state == State.playing)
        {
            Level.GetInstance().ChangeScore(score);
            Ambulance.GetInstance().PersonEnter();
            state = State.finsihed;
        }

        Destroy(gameObject);
    }
        public async Task <IActionResult> Create([Bind("Amb_id,Amb_num,Capacity")] Ambulance ambulance)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ambulance);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ambulance));
        }
        protected override void Initialize()
        {
            _hospital      = new Hospital(this, 15);
            _ambulance     = new Ambulance(this, 15);
            _callCenter    = new EmergencyCallCenter(this);
            disaster       = new Disaster(this, 5);
            _emsVehicle    = new EMSVehicle(this);
            _rescueVehicle = new RescueVehicle(this);

            //SetPatients(10);
            savedPatients = new List <Patient>();
        }
 public ActionResult Edit([Bind(Include = "Id,DriverName,CityId,SubCityId,Phone,CarNumber,Hospital")] Ambulance ambulance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ambulance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CityId    = new SelectList(db.Cities, "Id", "Name", ambulance.CityId);
     ViewBag.SubCityId = new SelectList(db.SubCities, "Id", "Name", ambulance.SubCityId);
     return(View(ambulance));
 }
Example #19
0
    private Ambulance CreateAmbulance()
    {
        Vector3 pos = this.transform.position;

        pos.y = 1;
        GameObject am = Instantiate(AmbulanceObject, pos, Quaternion.Euler(new Vector3(0f, 0f, 0f)));
        Ambulance  a  = am.GetComponent <Ambulance>();

        a.myERC         = this;
        a.Decentralized = Decentralized;
        return(a);
    }
Example #20
0
        public VetMain(VetAmbulance.BL.Models.Vet vet)
        {
            InitializeComponent();

            ambulance = Container.Get().Resolve <VetAmbulance.BL.Models.Ambulance>();
            this.vet  = Container.Get().Resolve <VetAmbulance.BL.Models.Vet>();
            patient   = Container.Get().Resolve <Patient>();
            diagnosis = Container.Get().Resolve <Diagnosis>();
            drug      = Container.Get().Resolve <Drug>();

            this.vet.GetById(this.vet.Id);
            ambulance.GetById(this.vet.AmbulanceId);
        }
Example #21
0
        public void PatientBeforeOpeningHours_WillNotEnterBeforeOpeningAmbulance(Ambulance ambulance)
        {
            // given
            var ambulanceOpeningTime = new TimeSpan(8, 0, 0);

            // when
            ambulance.EstimateAndSortWaitingListEntries();
            var result = ambulance.WaitingList;

            // then
            Assert.IsTrue(
                ambulance.WaitingList[0].Estimated >= ambulance.WaitingList[0].Since,
                "patient cannot enter ambulance before his arrival");
        }
Example #22
0
        // GET: Ambulances/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ambulance ambulance = db.Ambulances.Find(id);

            if (ambulance == null)
            {
                return(HttpNotFound());
            }
            return(View(ambulance));
        }
Example #23
0
    private void sendRandomResources(Emergency medEm, Emergency disEm)
    {
        if ((availableAmbulances > 0 || Multiple) && medEm != null)
        {
            int ambulancesNeeded = Random.Range(0, availableAmbulances + 1);
            ambulancesNeeded = Mathf.Min(ambulancesNeeded, availableAmbulances);

            for (int i = 0; i < ambulancesNeeded; i++)
            {
                Ambulance am = ambulances[0]; // CreateAmbulance();
                ambulances.RemoveAt(0);
                am.SendAmbulance(medEm);
                availableAmbulances--;
            }

            if (ambulancesNeeded > 0)
            {
                medEm.SendResources(ambulancesNeeded, 0);
                MedicalEmergenciesWaiting.Remove(medEm);
                if (!EmergenciesBeingTreated.Contains(medEm))
                {
                    EmergenciesBeingTreated.Add(medEm);
                }
            }
        }

        if ((availableFiretrucks > 0 || Multiple) && disEm != null)
        {
            int firetrucksNeeded = Random.Range(0, availableFiretrucks + 1);
            firetrucksNeeded = Mathf.Min(firetrucksNeeded, availableFiretrucks);

            for (int i = 0; i < firetrucksNeeded; i++)
            {
                Firetruck am = firetrucks[0]; // CreateFiretruck();
                firetrucks.RemoveAt(0);
                am.SendFiretruck(disEm);
                availableFiretrucks--;
            }

            if (firetrucksNeeded > 0)
            {
                disEm.SendResources(0, firetrucksNeeded);
                DisasterEmergenciesWaiting.Remove(disEm);
                if (!EmergenciesBeingTreated.Contains(disEm))
                {
                    EmergenciesBeingTreated.Add(disEm);
                }
            }
        }
    }
Example #24
0
        public Ambulance AddAmbulance(string identifier, float latitude, float longitude, AmbulanceStatus status, string listeningPort)
        {
            var amb = new Ambulance(identifier)
            {
                Latitude           = latitude,
                Longitude          = longitude,
                LastPositionUpdate = DateTime.Now,
                Status             = status,
                Port = listeningPort
            };

            db.Insert(amb);
            return(amb);
        }
Example #25
0
        public ActionResult Book(int id)
        {
            ApplicationUser user             = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
            string          strCurrentUserId = user.Id;

            if (id != null)
            {
                Ambulance amb = db.Ambulances.Find(id);
                if (amb == null)
                {
                    return(HttpNotFound());
                }

                /*
                 * var _amb = new Ambulance
                 * {
                 *  id = id,
                 *  aType_id = amb.aType_id,
                 *  Driver_id = amb.Driver_id,
                 *  Color = amb.Color,
                 *  Plate = amb.Plate,
                 *  Station_id = amb.Station_id,
                 *  Available = false
                 * };
                 */


                Booking bk = new Booking
                {
                    Date            = DateTime.Now,
                    Ambulance_id    = amb.id,
                    User__id        = strCurrentUserId,
                    CurrentlyActive = true
                };
                amb.Available = false; db.SaveChanges();

                /*
                 *              db.Ambulances.Attach(_amb);
                 *              db.Entry(_amb).Property(X => X.Available).IsModified = true;
                 */
                db.Bookings.Add(bk);
                db.SaveChanges();
                return(RedirectToAction("Index", "Bookings"));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Example #26
0
 private void manageEvent()
 {
     if (EvenObject is Rain)
     {
     }
     if (EvenObject is Fire)
     {
         int       ambulanceStreet;
         Ambulance amb = new Ambulance();
         ambulanceStreet = amb.search();
         Vehicle ambulance = new Vehicle(MapClass.Streets[ambulanceStreet].GetStartPoint(), amb);
         ambulance.navigation(MapClass.Streets[ambulanceStreet].GetStartPoint(), this.EvenObject.Point); //sina will add
         ambulance.movement();
     }
 }
Example #27
0
        public NewTown(string name, int buildings, int days)
        {
            townName        = name;
            this.buildings  = buildings;
            this.days       = days;
            fireProbability = 1e-3;

            policeman    = new Police(this);
            ambulanceman = new Ambulance(this);
            fireman      = new FireDetect(this);

            policeman.On();
            ambulanceman.On();
            fireman.On();
        }
Example #28
0
    private IEnumerator ambulance()
    {
        Ambulance s = new Ambulance(new Rect(SCREEN_SIZE.x + 100, SCREEN_SIZE.y - ambulanceSize, ambulanceSize, ambulanceSize), ambulances[Random.Range(0, ambulances.Length)], ambulancesPerSheet, ambulanceSize);

        ambulance_list.Add(s);
        float delta = 0.0f;

        while (delta < ambulanceDuration)
        {
            delta   += Time.deltaTime;
            s.rect.x = (1 - ambulanceSpeedCurve.Evaluate(delta / ambulanceDuration)) * (SCREEN_SIZE.x + ambulanceSize) - ambulanceSize;
            s.rect.y = ambulanceHopCurve.Evaluate(delta / ambulanceDuration) * ambulanceSize + SCREEN_SIZE.y - ambulanceSize;
            yield return(null);
        }
        s.die();
    }
Example #29
0
 // GET: Search/AmbulanceDetails/5
 public ActionResult AmbulanceDetails(int?id)
 {
     if (id != null)
     {
         Ambulance ambulance = db.Ambulances.Find(id);
         if (ambulance == null)
         {
             return(HttpNotFound());
         }
         return(View(ambulance));
     }
     else
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
 }
Example #30
0
        public Ambulance AddAmbulance(string id,
                                      float lat,
                                      float lon,
                                      AmbulanceStatus status)
        {
            var amb = new Ambulance(id)
            {
                Latitude           = lat,
                Longitude          = lon,
                LastPositionUpdate = DateTime.Now,
                Status             = status
            };

            db.Insert(amb);
            return(amb);
        }