예제 #1
0
 public void TestTramOnRail()
 {
     Rail rail = new Rail(1, true, false, 1, "Combino");
     User user = new User(2323, "test", "test", 1);
     Tram tram = new Tram(1, "test", rail, user, 1, false);
     tram.OnRail = true;
     Assert.AreEqual(true, tram.OnRail, "Tram on rail");
 }
예제 #2
0
 /// <summary>
 /// Creation of a new tram
 /// </summary>
 /// <param name="id">id of the tram</param>
 /// <param name="type">tram type</param>
 /// <param name="rail">rail on which the tram should be placed on</param>
 /// <param name="driver">the driver of the tram</param>
 /// <param name="status">1= OK 2= Dirty 3= Defect 4= DirtyAndDefect</param>
 public Tram(int id, string type, Rail rail, User driver, int status, bool onRail)
 {
     this.Id = id;
     this.Type = type;
     this.Rail = rail;
     this.Driver = driver;
     Status = (Status)status;
     OnRail = onRail;
 }
예제 #3
0
 public void TestMoveTram()
 {
     Rail rail = new Rail(1, true, false, 1, "Combino");
     Rail rail2 = new Rail(2, true, false, 1, "Combino");
     User user = new User(2323, "test", "test", 1);
     Tram tram = new Tram(1, "test", rail, user, 1, true);/*
     tram.AddTram(1, 1, 1, 1);
     tram.MoveTram(2, 1, 1);
     Assert.AreEqual(2, rail2.Id, "rail 2");*/
     Assert.AreEqual(1,1);
 }
예제 #4
0
 public void TestTramProperties()
 {
     Rail rail = new Rail(1, true, false, 1, "Combino");
     User user = new User(2323, "test", "test", 1);
     Tram tram = new Tram(1, "test", rail, user, 1, true);
     Assert.AreEqual(tram.Id, 1, "TramID");
     Assert.AreEqual(tram.Type, "test", "tramID");
     Assert.AreEqual(tram.Rail, rail, "tram rail");
     Assert.AreEqual(tram.Driver, user, "tram driver");
     Assert.AreEqual(tram.OnRail, true, "tram onrail");
     Assert.AreEqual(tram._Status, 1, "tram status");
 }
 /// <summary>
 /// not implemented
 /// </summary>
 /// <param name="rail"></param>
 /// <returns></returns>
 public bool BlockRail(Rail rail)
 {
     throw new NotImplementedException();
 }
        public void UpdateRailList()
        {
            GetRailList.Clear();
            foreach (Dictionary<string, object> R in addatabase.GetAllRails())
            {
                bool status = false;
                bool taken = false;
                if (Convert.ToInt32(R["blokkeer"]) == 0)
                {
                    status = false;
                }
                else
                {
                    status = true;
                }
                if (Convert.ToInt32(R["taken"]) == 0)
                {
                    taken = false;
                }
                else
                {
                    taken = true;
                }

                Rail r = new Rail(Convert.ToInt32(R["spoorid"]), status, taken, Convert.ToInt32(R["remiseid"]), Convert.ToString(R["type"]));
                GetRailList.Add(r);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public List<Rail> GetRailsOfType(string type)
        {
            List<Rail> railSStoAuswitch = new List<Rail>();
            foreach (Dictionary<string, object> R in addatabase.GetAllRailsOfType(type))
            {
                bool status = false;
                bool taken = false;
                if (Convert.ToInt32(R["blokkeer"]) == 0)
                {
                    status = false;
                }
                else
                {
                    status = true;
                }
                if (Convert.ToInt32(R["taken"]) == 0)
                {
                    taken = false;
                }
                else
                {
                    taken = true;
                }

                Rail r = new Rail(Convert.ToInt32(R["spoorid"]), status, taken, Convert.ToInt32(R["remiseid"]), Convert.ToString(R["type"]));
                railSStoAuswitch.Add(r);
            }
            return railSStoAuswitch;
        }
예제 #8
0
        /// <summary>
        /// blocks or unblocks a rail
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnStatus_Click(object sender, EventArgs e)
        {
            Rail rail = new Rail(Convert.ToInt32(ddlStatusTrack.SelectedItem.Text), false, false, 1, "Combino");
            if (ddlStatusStatus.SelectedItem.Text == "Blokkeer")
            {
                //if rail is already blocked, go to else
                if (!rail.IsRailBlocked(Convert.ToInt32(ddlStatusTrack.SelectedItem.Text)))
                {
                    //blocks the rail
                    if (rail.BlockRail(Convert.ToInt32(ddlStatusTrack.SelectedItem.Text), 1))
                    {
                        refreshGUI(); //refresh GUI
                    }

                    else
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Spoor is al geblokkeerd');", true);
                        //ClientScript.RegisterStartupScript(GetType(), "myalert", "alert('Spoor is al geblokkeerd')", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Spoor is al geblokkeerd');", true);
                    //ClientScript.RegisterStartupScript(GetType(), "myalert", "alert('Spoor is al geblokkeerd')", true);
                }
            }
            else if (ddlStatusStatus.SelectedItem.Text == "Deblokkeer")
            {
                //check if rail is already unblocked
                if (rail.IsRailBlocked(Convert.ToInt32(ddlStatusTrack.SelectedItem.Text)))
                {
                    //unblock rail
                    if (rail.BlockRail(Convert.ToInt32(ddlStatusTrack.SelectedItem.Text), 0))
                    {
                        refreshGUI();   //refresh GUI
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Spoor is al gedeblokkeerd');", true);
                        //ClientScript.RegisterStartupScript(GetType(), "myalert", "alert('Spoor is al gedeblokkeerd')", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Spoor is al gedeblokkeerd');", true);
                    //ClientScript.RegisterStartupScript(GetType(), "myalert", "alert('Spoor is al gedeblokkeerd')", true);
                }
            }
            refreshGUI();
        }