예제 #1
0
        /// <summary>
        /// Moves text from one listbox to another depending on the trucks status
        /// </summary>
        /// <param name="trk"></param>
        private void UpdateQue(Trucks trk)
        {
            switch (trk.gsStatus)
            {
            case 1:
                lbCrushQue.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus + 3));
                lbTransLoad.Items.Add(trk.gsTruckID + "\t" + trk.gsStatus);
                break;

            case 2:
                lbTransLoad.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus - 1));
                lbLoadQue.Items.Add(trk.gsTruckID + "\t" + trk.gsStatus);
                break;

            case 3:
                lbLoadQue.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus - 1));
                lbTransCrush.Items.Add(trk.gsTruckID + "\t" + trk.gsStatus);
                break;

            case 4:
                lbTransCrush.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus - 1));
                lbCrushQue.Items.Add(trk.gsTruckID + "\t" + (trk.gsStatus));
                break;

            default:
                lbTransLoad.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus + 1));
                lbCrushQue.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus + 4));
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// Displays the details of the specific truck instance by calling the Trucks
        /// class and putting the data into the appropiate text boxes and selects the
        /// corresponding radiobutton
        /// </summary>
        /// <param name="trk"></param>
        private void UpdateDetails(Trucks trk)
        {
            tbTruckID.Text      = trk.gsTruckID.ToString();
            tbLoadCapacity.Text = trk.gCapacity.ToString();
            tbTotal.Text        = trk.gsTotal.ToString();
            switch (trk.gsStatus)
            {
            case 1:
                rbTranLoad.Select();
                break;

            case 2:
                rbLoading.Select();
                break;

            case 3:
                rbTransCrush.Select();
                break;

            case 4:
                rbCrusher.Select();
                break;

            case 5:
                rbService.Select();
                break;

            default:
                rbInactive.Select();
                break;
            }
        }
예제 #3
0
 /// <summary>
 /// Puts trucks into the Service Listbox from the Queue 1 and 4, and removes
 /// any other text associated with the specific truck, also resets the Queue
 /// pointer.
 /// </summary>
 /// <param name="trk"></param>
 private void ServiceUpdate(Trucks trk)
 {
     lbInService.Items.Remove(trk.gsTruckID + "\tTo Be Serviced");
     lbInService.Items.Add(trk.gsTruckID + "\tServicing");
     lbCrushQue.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus - 1));
     lbTransLoad.Items.Remove(trk.gsTruckID + "\t" + (trk.gsStatus - 4));
     trk.gsQuePtr = 0;
 }
예제 #4
0
 /// <summary>
 /// Initializing the Trucks Arrray by adding 20 trucks with unique identifier
 /// </summary>
 private void InitializeTrucks()
 {
     for (int i = 0; i < trkMAX; i++)
     {
         truck[i]           = new Trucks();
         truck[i].gsTruckID = i + 100;
     }
     DisplayInfo();
 }
예제 #5
0
 /// <summary>
 /// Deque a truck object from the Que associated with the input parameter
 /// </summary>
 /// <param name="i"></param>
 public void DeQue(int i)
 {
     try
     {
         UpdateListQue(i + 1);
         Trucks nextTruck = allQ[i].Dequeue();
         nextTruck.StsUpdate();
         TransQue(nextTruck);
     }
     catch (InvalidOperationException InvEx)
     {
         MessageBox.Show(InvEx.Message + " Add a truck to the Queue", "Error");
     }
 }
예제 #6
0
        /// <summary>
        /// Opens binary file a puts data from the file into the Trucks Array. It is
        /// then sorted by the gsQuePtr field so that each truck gets put back into
        /// the Queue in the correct order. The Array is then reorderd back and
        /// displayed from truck 100 - 119
        /// </summary>
        private void LoadFile()
        {
            BinaryReader bReader;

            try
            {
                bReader = new BinaryReader(new FileStream("Trucks.bin", FileMode.Open));
            }
            catch (FileNotFoundException fnfe)
            {
                MessageBox.Show(fnfe.Message + "\n Cannot find file for reading", "Error");
                return;
            }
            try
            {
                for (int i = 0; i <= 19; i++)
                {
                    truck[i]            = new Trucks();
                    truck[i].gsTruckID  = bReader.ReadInt32();
                    truck[i].gsStatus   = bReader.ReadInt32();
                    truck[i].gsTotal    = bReader.ReadInt32();
                    truck[i].ToService  = bReader.ReadBoolean();
                    truck[i].gsQuePtr   = bReader.ReadDouble();
                    truck[i].ToInactive = bReader.ReadBoolean();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n Cannot load data from file", "Error");
            }
            bReader.Close();

            fLoad = true;

            Array.Sort(truck, delegate(Trucks x, Trucks y) { return(x.gsQuePtr.CompareTo(y.gsQuePtr)); });


            foreach (Trucks oldTruck in truck)
            {
                TransQue(oldTruck);
            }
            Array.Sort(truck, delegate(Trucks x, Trucks y) { return(x.gsTruckID.CompareTo(y.gsTruckID)); });
            DisplayInfo();
            fLoad = false;
        }
예제 #7
0
        /// <summary>
        /// Checks if the class objects loadded from the binary file are going to
        /// be serviced.Then checks what the Trucks status is to determine which
        /// Queue it will go in or if the truck needs to be serviced. When put into
        /// the third queue the truck increments its load.
        /// </summary>
        /// <param name="trk"></param>
        private void TransQue(Trucks trk)
        {
            if (trk.ToService && fLoad == true)
            {
                lbInService.Items.Add(trk.gsTruckID + "\tTo Be Serviced");
            }

            switch (trk.gsStatus)
            {
            case 1:
                allQ[0].Enqueue(trk);
                ListQue(trk, 0);
                break;

            case 2:
                allQ[1].Enqueue(trk);
                ListQue(trk, 1);
                break;

            case 3:
                allQ[2].Enqueue(trk);
                ListQue(trk, 2);
                break;

            case 4:
                allQ[3].Enqueue(trk);
                ListQue(trk, 3);
                break;

            case 5:
                ServiceUpdate(trk);
                break;

            default:
                break;
            }
            UpdateQue(trk);
            DisplayInfo();
            UpdateDetails(trk);
        }
예제 #8
0
 /// <summary>
 /// Gets the specified truck and gives it a unique number derived from the
 /// Queue itsin so it can be put back into the Queue when loaded from binary
 /// file
 /// </summary>
 /// <param name="trk"></param>
 /// <param name="i"></param>
 private void ListQue(Trucks trk, int i)
 {
     trk.gsQuePtr = (double)allQ[i].Count() / 100 + (i + 1);
 }