상속: MonoBehaviour
예제 #1
0
 public void Update(Trainee trainee)
 {
     this.Update((Person)trainee);
     this.InstructorName    = trainee.InstructorName;
     this.NumDrivingLessons = trainee.NumDrivingLessons;
     this.GearBox           = trainee.GearBox;
     this.DrivingSchool     = trainee.DrivingSchool;
 }
예제 #2
0
 private void ShiftUpGears(int gearShifts, GearBox gearBox)
 {
     gearBox.DoIt(0); //from neutral to first gear
     for (int i = 1; i < gearShifts; i++)
     {
         gearBox.DoIt(int.MaxValue);
     }
 }
예제 #3
0
        }                 //CTOR without arguments- required for the xmlSerializer

        public Test(string testerId, string traineeId, DateTime date, Address address, GearBox gearBox, CarType car)
        {
            this.testerId  = testerId;
            this.traineeId = traineeId;
            this.date      = date;
            this.address   = address;
            this.gearBox   = gearBox;
            this.car       = car;
        }
예제 #4
0
        public void GearBoxCreatedWithoutDictionaryCanShiftUp()
        {
            var gearBox = new GearBox();

            gearBox.DoIt(0);
            var result = gearBox.S();

            Assert.Equal(1, result);
        }
 public ActionResult Edit([Bind(Include = "GearBoxsId,NameGearBox")] GearBox gearBox)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gearBox).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gearBox));
 }
예제 #6
0
 public virtual void Update(float amount)
 {
     if (Tank.Amount > 0.0f)
     {
         float temp = Tank.PumpFuel(amount);
         temp              = Engine.Turn(temp);
         temp              = GearBox.Turn(temp);
         DistanceTraveled += Wheels.Turn(temp);
     }
 }
예제 #7
0
        public IActionResult CreateGearBox([FromBody] GearBox gearBox)
        {
            gearBox.isDeleted = 0;
            DateTime currentDate = DateTime.Now;

            gearBox.CreateTime = currentDate;
            var result = gearBoxBUS.CreateGearBox(gearBox);

            return(Ok(result));
        }
        private void filter()
        {
            bool car     = comboBoxCarType.SelectedItem != null ? true : false;
            bool gender  = ComboBoxGender.SelectedItem != null ? true : false;
            bool gearBox = ComboBoxGearBox.SelectedItem != null ? true : false;
            bool school  = TextBoxSchoolName.Text != "" ? true : false;

            if (car || gender)  //user wants to filter by car type or gender
            {
                if (car && !gender)
                {
                    CarType c = (CarType)comboBoxCarType.SelectedItem;
                    this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => t.CarTypeTrainee == c);
                    return;
                }
                if (gender && !car)
                {
                    Gender g = (Gender)ComboBoxGender.SelectedItem;
                    this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => t.GenderTrainee == g);
                    return;
                }
                if (car && gender)
                {
                    CarType c = (CarType)comboBoxCarType.SelectedItem;
                    Gender  g = (Gender)ComboBoxGender.SelectedItem;
                    this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => (t.CarTypeTrainee == c) && (t.GenderTrainee == g));
                    return;
                }
            }

            if (gearBox || school)      //user wants to filter by gear box or by school name
            {
                if (gearBox && !school)
                {
                    GearBox g = (GearBox)ComboBoxGearBox.SelectedItem;
                    this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => t.gearBoxtrainee == g);
                    return;
                }
                if (school && !gearBox)
                {
                    string s = (TextBoxSchoolName.Text).ToString();
                    this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => t.SchoolName == s);
                    return;
                }
                if (school && gearBox)
                {
                    GearBox g = (GearBox)ComboBoxGearBox.SelectedItem;
                    string  s = (TextBoxSchoolName.Text).ToString();
                    this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => (t.SchoolName == s) && (t.gearBoxtrainee == g));

                    return;
                }
            }
            this.TraineeDataGrid.ItemsSource = bl.getTraineesList();
        }
예제 #9
0
        /// <summary>
        /// This initializer is called when we are making a new copy of a locomotive already
        /// loaded in memory.  We use this one to speed up loading by eliminating the
        /// need to parse the wag file multiple times.
        /// NOTE:  you must initialize all the same variables as you parsed above
        /// </summary>
        public override void Copy(MSTSWagon copy)
        {
            base.Copy(copy);  // each derived level initializes its own variables

            MSTSDieselLocomotive locoCopy = (MSTSDieselLocomotive)copy;

            EngineRPM                     = locoCopy.EngineRPM;
            IdleRPM                       = locoCopy.IdleRPM;
            MaxRPM                        = locoCopy.MaxRPM;
            MaxRPMChangeRate              = locoCopy.MaxRPMChangeRate;
            MaximumDieselEnginePowerW     = locoCopy.MaximumDieselEnginePowerW;
            PercentChangePerSec           = locoCopy.PercentChangePerSec;
            LocomotiveMaxRailOutputPowerW = locoCopy.LocomotiveMaxRailOutputPowerW;

            EngineRPMderivation = locoCopy.EngineRPMderivation;
            EngineRPMold        = locoCopy.EngineRPMold;

            MaxDieselLevelL = locoCopy.MaxDieselLevelL;
            DieselUsedPerHourAtMaxPowerL = locoCopy.DieselUsedPerHourAtMaxPowerL;
            DieselUsedPerHourAtIdleL     = locoCopy.DieselUsedPerHourAtIdleL;

            DieselFlowLps = 0.0f;
            InitialMassKg = MassKG;

            if (this.CarID.StartsWith("0"))
            {
                DieselLevelL = locoCopy.DieselLevelL;
            }
            else
            {
                DieselLevelL = locoCopy.MaxDieselLevelL;
            }

            if (locoCopy.GearBoxController != null)
            {
                GearBoxController = new MSTSNotchController(locoCopy.GearBoxController);
            }

            DieselEngines = new DieselEngines(locoCopy.DieselEngines, this);
            if (DieselEngines[0].GearBox != null)
            {
                GearBox = DieselEngines[0].GearBox;
            }
            for (int i = 1; i < DieselEngines.Count; i++)
            {
                if (DieselEngines[i].GearBox == null && locoCopy.DieselEngines[i].GearBox != null)
                {
                    DieselEngines[i].GearBox = new GearBox(GearBox, DieselEngines[i]);
                }
            }
            foreach (DieselEngine de in DieselEngines)
            {
                de.Initialize(true);
            }
        }
        public ActionResult Create([Bind(Include = "GearBoxsId,NameGearBox")] GearBox gearBox)
        {
            if (ModelState.IsValid)
            {
                db.GearBoxs.Add(gearBox);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gearBox));
        }
        private static void observerPatternDemo()
        {
            Speedometer  myspeedometer = new Speedometer();
            SpeedMonitor monitor       = new SpeedMonitor(myspeedometer);
            GearBox      gearbox       = new GearBox(myspeedometer);

            myspeedometer.CurrentSpeed = 10;
            myspeedometer.CurrentSpeed = 20;
            myspeedometer.CurrentSpeed = 25;
            myspeedometer.CurrentSpeed = 30;
            myspeedometer.CurrentSpeed = 35;
        }
예제 #12
0
        private static void ObserverPatternDemo()
        {
            Speedometer  mySpeedometer = new Speedometer();
            SpeedMonitor monitor       = new SpeedMonitor(mySpeedometer);
            GearBox      gearbox       = new GearBox(mySpeedometer);

            //Set current speed property to a value
            mySpeedometer.CurrentSpeed = 10;
            mySpeedometer.CurrentSpeed = 20;
            mySpeedometer.CurrentSpeed = 25;
            mySpeedometer.CurrentSpeed = 30;
            mySpeedometer.CurrentSpeed = 35;
        }
        // GET: GearBoxes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GearBox gearBox = db.GearBoxs.Find(id);

            if (gearBox == null)
            {
                return(HttpNotFound());
            }
            return(View(gearBox));
        }
예제 #14
0
 public void Init()
 {
     _gearBox                                 = new GearBox();
     _gearBox.Efficency                       = 0.9f;
     _gearBox.Gears                           = 3;
     _gearBox.Transmissions[0]                = 10;
     _gearBox.Transmissions[1]                = 5;
     _gearBox.Transmissions[2]                = 1;
     EngineOutput.LastCalculation             = new EngineOutput();
     EngineOutput.LastCalculation.Torque      = 100;
     _expectedValues                          = new[] { 0, 900f, 450f, 90f };
     SecondaryDriveOutput.LastCalculation.Rpm = 1000;
     CalculationController.Instance.SecondaryDrive.Transmission = 10;
     InputData.UsedInputData = new InputData(0, 0, 0, 0);
 }
예제 #15
0
        public IActionResult UpdateGearBox([FromBody] GearBox gearBox)
        {
            DateTime currentDate = DateTime.Now;

            gearBox.UpdateTime = currentDate;
            try
            {
                var result = gearBoxBUS.UpdateGearBox(gearBox);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #16
0
        private void ShiftsDownWithRpmLowerThanThreshold(IDictionary <int, int> downDictionary, int startingGear)
        {
            //arrange
            var upDictionary = DefaultUpDict();
            var gearBox      = new GearBox(upDictionary, downDictionary);

            ShiftUpGears(startingGear, gearBox);

            //action
            gearBox.DoIt(downDictionary[startingGear] - 1);
            var result       = gearBox.S();
            var expectedGear = startingGear - 1;

            Assert.Equal(expectedGear, result);
        }
예제 #17
0
 public Trainee(string id, string firstName, string lastName, DateTime birthDay, string schoolName, string teacherName, int numberOfLesson, string phoneNumber, Address address, Gender gender = Gender.MALE, CarType carType = CarType.PrivetCar, GearBox gearBox = GearBox.Manual)
 {
     Id                = id;
     FirstName         = firstName;
     LastName          = lastName;
     BirthDate         = birthDay;
     Gender            = gender;
     PhoneNumber       = phoneNumber;
     Address           = address;
     CarType           = carType;
     GearBox           = gearBox;
     SchoolName        = schoolName;
     TeacherName       = teacherName;
     NumberOfLesson    = numberOfLesson;
     Registration_date = DateTime.Now;
 }
예제 #18
0
 public Trainee(int id, string lastName, string firstName, DateTime dateOfBirth, Gender gndr, string phone, Address addrs, VehicleType carType, GearBox gearBoxType, string drivingSchoolName, string teacherName, int numberOfLessons, List <TraineeTest> tests)
 {
     ID                = id;
     Address           = addrs;
     CarType           = carType;
     DateOfBirth       = dateOfBirth;
     DrivingSchoolName = drivingSchoolName;
     FirstName         = firstName;
     GearBoxType       = gearBoxType;
     Gender            = gndr;
     LastName          = lastName;
     NumberOfLessons   = numberOfLessons;
     Phone             = phone;
     TeacherName       = teacherName;
     Tests             = new List <TraineeTest> (tests);
 }
        public async Task <ActionResult <GearBox> > PostGearBox([FromBody] GearBox gearBox)
        {
            try
            {
                await _unitOfWork.GearBoxRepo.AddAsync(gearBox).ConfigureAwait(false);

                _unitOfWork.Commit();

                return(Ok());
            }

            catch (Exception e)
            {
                return(BadRequest());
            }
        }
 //user choose specific gear box
 private void ComboBoxGearBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ComboBoxGearBox.SelectedItem != null)
     {
         GearBox w = (GearBox)ComboBoxGearBox.SelectedItem;
         gearBoxClear.Visibility         = Visibility.Visible;
         comboBoxCarType.SelectedItem    = null;
         ComboBoxGender.SelectedItem     = null;
         CheckBoxIsHandicapped.IsChecked = false;
         handicappedClear.Visibility     = Visibility.Hidden;
     }
     else
     {
         gearBoxClear.Visibility = Visibility.Hidden;
     }
     filter(); //this.TraineeDataGrid.ItemsSource = bl.getTraineesList(t => t.GearBox == w);
 }
예제 #21
0
        public void JSONGearboxRepository_GetById_Test()
        {
            //Arrange
            var gearboxRepo = new JSONBaseRepository <GearBox>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\gearboxes_tests.json");

            var gearboxToAdd = new GearBox {
                Type = Enums.GearBoxTypeEnum.Manual
            };

            gearboxRepo.AddEntity(gearboxToAdd);
            var engine = gearboxRepo.GetById(gearboxToAdd.Id.ToString());
            //Act
            var retrievedGearbox = gearboxRepo.GetById(gearboxToAdd.Id.ToString());

            //Assert
            Assert.True(engine.Equals(retrievedGearbox));
        }
        public void SQLGearboxRepository_GetById_Test()
        {
            //Arrange
            RegisterTypes();
            var gearboxRepo  = container.Resolve <SQLBaseRepository <GearBox> >();
            var gearboxToAdd = new GearBox {
                Type = Enums.GearBoxTypeEnum.Manual
            };

            gearboxRepo.AddEntity(gearboxToAdd);
            var customer = gearboxRepo.GetById(gearboxToAdd.Id.ToString());
            //Act
            var retrievedGearbox = gearboxRepo.GetById(gearboxToAdd.Id.ToString());

            //Assert
            Assert.True(customer.Equals(retrievedGearbox));
        }
예제 #23
0
 public Test(string testerId, string traineeId, GearBox gear, CarType car, DateTime date, Address address, bool?test1_ReverseParking, bool?test2_KeepingSafeDistance, bool?test3_UsingMirrors, bool?test4_UsingTurnSignals, bool?test5_LegalSpeed, bool?succeeded, string notes)
 {
     id                             = null;
     this.testerId                  = testerId;
     this.traineeId                 = traineeId;
     this.car                       = car;
     this.date                      = date;
     this.address                   = address;
     this.test1_ReverseParking      = test1_ReverseParking;
     this.test2_KeepingSafeDistance = test2_KeepingSafeDistance;
     this.test3_UsingMirrors        = test3_UsingMirrors;
     this.test4_UsingTurnSignals    = test4_UsingTurnSignals;
     this.test5_LegalSpeed          = test5_LegalSpeed;
     this.succeeded                 = succeeded;
     this.notes                     = notes;
     GearBox                        = gear;
 }
        public void SQLGearboxRepository_Insert_Test()
        {
            //Arrange
            RegisterTypes();
            var gearboxRepo = container.Resolve <SQLBaseRepository <GearBox> >();
            var gearbox     = new GearBox {
                Type = Enums.GearBoxTypeEnum.Automatic
            };

            //Act
            gearboxRepo.AddEntity(gearbox);

            //retrieve from db
            var retrievedGearbox = gearboxRepo.GetById(gearbox.Id.ToString());

            //Assert
            Assert.True(gearbox.Equals(retrievedGearbox));
        }
예제 #25
0
        }                   //CTOR without arguments- required for the xmlSerializer

        public Tester(string name, int age, Gender gender, string phoneNumber, Address address, int expYears, int maxTestInWeek, CarType carType, GearBox gearBox, bool[][] workHour, double distance)
        {
            //make from one string first and last name, if there are only one word enter " " to the last name
            string[] seperator = { " " };
            string[] names     = name.Split(seperator, 2, StringSplitOptions.RemoveEmptyEntries);
            FirstName     = names[0];
            LastName      = names[1] != null ? names[1] : " ";
            Age           = age;
            Gender        = gender;
            PhoneNumber   = phoneNumber;
            Address       = address;
            ExpYears      = expYears;
            MaxTestInWeek = maxTestInWeek;
            CarType       = carType;
            GearBox       = gearBox;
            WorkHour      = workHour;
            Distance      = distance;
        }
예제 #26
0
        public override void Initialize()
        {
            if (GearBox != null && !GearBox.IsInitialized)
            {
                GearBox = null;
            }

            DieselEngines.Initialize(false);

            base.Initialize();

            // If DrvWheelWeight is not in ENG file, then calculate drivewheel weight freom FoA

            if (DrvWheelWeightKg == 0)     // if DrvWheelWeightKg not in ENG file.
            {
                DrvWheelWeightKg = MassKG; // set Drive wheel weight to total wagon mass if not in ENG file
            }
        }
예제 #27
0
 /// <summary>
 /// בנאי לטסט
 /// </summary>
 public Test(string myTraineeID, VehicleType myVehicleType, GearBox myGearBox, DateTime myTestTime, Address myDepartureAddress)
 {
     traineeID             = myTraineeID;
     vehicleType           = myVehicleType;
     gearBox               = myGearBox;
     testTime              = myTestTime;
     departureAddress      = myDepartureAddress;
     destinationAddress    = myDepartureAddress;
     keepingDistance       = false;
     reverseParking        = false;
     lookingAtMirrors      = false;
     signaling             = false;
     stopingForPedestrians = false;
     intersection          = false;
     rightOfWay            = false;
     appropriateSpeed      = false;
     controlOfGearBox      = false;
     result = false;
 }
        /// <summary>
        /// controls the calculation process
        /// </summary>
        private CalculationController()
        {
            _calculationEwh      = new EventWaitHandle(false, EventResetMode.AutoReset);
            _continueThreadEwh   = new EventWaitHandle(true, EventResetMode.AutoReset);
            _threadEndedEwh      = new EventWaitHandle(false, EventResetMode.AutoReset);
            _threadInterrupedEwh = new EventWaitHandle(false, EventResetMode.AutoReset);

            Aerodynamic    = new Aerodynamic();
            Brake          = new Brake();
            Engine         = new Engine();
            GearBox        = new GearBox();
            OverallCar     = new OverallCar();
            SecondaryDrive = new SecondaryDrive();
            Steering       = new Steering();
            Suspension     = new Suspension();
            Wheels         = new Wheels();

            _workerThread = new Thread(WorkerFunction);
        }
예제 #29
0
        }                    //CTOR without arguments- required for the xmlSerializer

        public Trainee(string id, string name, int age, Address address, string schoolName = "", string teacherName = "", int numberOfLesson = 0, string phoneNumber = "00000", Gender gender = Gender.MALE, CarType carType = CarType.PrivetCar, GearBox gearBox = GearBox.Manual)
        {
            this.id = id;
            //make from one string first and last name, if there are only one word enter " " to the last name
            string[] seperator = { " " };
            string[] names     = name.Split(seperator, 2, StringSplitOptions.RemoveEmptyEntries);
            FirstName      = names[0];
            LastName       = names[1] != null ? names[1] : " ";
            Age            = age;
            Gender         = gender;
            PhoneNumber    = phoneNumber;
            Address        = address;
            CarType        = carType;
            GearBox        = gearBox;
            SchoolName     = schoolName;
            TeacherName    = teacherName;
            NumberOfLesson = numberOfLesson;
            //       AmountOfTests = 0;
        }
예제 #30
0
    public virtual void ParametrizeUnityFromModel()
    {
        // Set mass and inertia
        body.mass = (float)model.Mass;
        Vector3 inertia = (model.Inertia * Vector <double> .Build.DenseOfArray(new double[] { 1, 1, 1 })).ToUnity();

        inertia.y         *= -1; // all inertia tensor components must be positive
        body.inertiaTensor = inertia;
        Debug.Log("Inertia tensor " + body.inertiaTensor);
        // TODO what about body.inertiaTensorRotation ?

        fcs      = model.FCS;
        engine   = model.Engine;
        gearBox  = model.GearBox;
        fuselage = model.Fuselage;

        foreach (var submodelName in submodelTransforms.Keys)
        {
            var submodel       = model.SubModels[submodelName];
            var childTransform = submodelTransforms[submodelName];
            Debug.Log("Transform from submodel: " + childTransform.name);
            childTransform.localPosition = submodel.Translation.ToUnity();
            childTransform.localRotation = submodel.Rotation.ToUnity();

            if (submodel is Rotor)
            {
                BoxCollider collider = childTransform.GetComponent <BoxCollider> ();
                var         sizey    = 0.1f;
                if (collider == null)
                {
                    collider = childTransform.gameObject.AddComponent <BoxCollider> ();
                }
                else
                {
                    sizey = collider.size.y;
                }
                var radius = (float)((Rotor)submodel).radius;
                var size   = Mathf.Sqrt(2 * radius * radius);
                collider.size = new Vector3(size, sizey, size);
            }
        }
    }
예제 #31
0
        public override void AddImages()
        {
            base.AddImages();

            fGearBox = new GearBox("gearbox", 49, 593, 166, 115);
            AddGraphic(fGearBox);
        }