Exemplo n.º 1
0
        private void PrintStateRow(DataGridView dgv, StateRow stateRow)
        {
            dgv.Rows.Add(
                stateRow.IterationNum,
                DifferentToZero(stateRow.Watch),
                stateRow.Event,
                DifferentToZero(stateRow.LoadRnd),
                DifferentToZero(stateRow.TimeEndLoad),
                DifferentToZero(stateRow.NextEndLoad),
                DifferentToZero(stateRow.TravelRnd),
                DifferentToZero(stateRow.TimeEndTravel),
                DifferentToZero(stateRow.NextEndTravel),
                ShovelStatusToString(stateRow.Shovel.Status),
                stateRow.Shovel.TruckQueue.Count,
                TruncateToFour(stateRow.Stat1),
                TruncateToFour(stateRow.Stat2),
                TruncateToFour(stateRow.Stat3)
                );

            int rowCount = dgv.Rows.Count;
            int c        = 0;

            for (int i = 0; i < stateRow.Trucks.Count; i++)
            {
                dgv.Rows[rowCount - 1].Cells[14 + c].Value     = TruckStatusToString(stateRow.Trucks[i].Status);
                dgv.Rows[rowCount - 1].Cells[14 + c + 1].Value = DifferentToZero(stateRow.Trucks[i].TimeTravel);
                c += 2;
            }
        }
Exemplo n.º 2
0
        static CsvReader()
        {
            s_parseTable = new Dictionary <enReadState, StateRow>();

            StateRow table = new StateRow(enReadState.NonQuotesField, true);

            s_parseTable[enReadState.FieldStart] = table;
            table[',']  = new StateCol(enReadState.FieldStart);
            table['"']  = new StateCol(enReadState.QuotesField);
            table['\r'] = new StateCol();
            table['\n'] = new StateCol(true);

            table = new StateRow();
            s_parseTable[enReadState.NonQuotesField] = table;
            table[',']  = new StateCol(enReadState.FieldStart);
            table['"']  = new StateCol(enReadState.Error);
            table['\r'] = new StateCol();
            table['\n'] = new StateCol(true);

            table = new StateRow();
            s_parseTable[enReadState.QuotesField] = table;
            table['"'] = new StateCol(enReadState.QuoteInQuotesField);

            table = new StateRow(enReadState.Error);
            s_parseTable[enReadState.QuoteInQuotesField] = table;
            table[',']  = new StateCol(enReadState.FieldStart);
            table['"']  = new StateCol(enReadState.QuotesField, true);
            table['\r'] = new StateCol();
            table['\n'] = new StateCol(true);
        }
 public AddOrUpdateStatusDialog(int id)
 {
     InitializeComponent();
     state         = stateTableAdapter1.GetData().FirstOrDefault(p => p.ID == id);
     txtDescp.Text = state.Description;
     txtName.Text  = state.Name;
     clrpick.Text  = state.Color;
     isNew         = false;
 }
Exemplo n.º 4
0
        public void AddAlternativeRow(object target)
        {
            var                 window = StateWindow.Get();
            StateRow            row    = (StateRow)target;
            List <StateRowData> data   = new List <StateRowData>(row.requirements);

            data.Add(new StateRowData());
            row.requirements = data.ToArray();
            window.target.Refresh();
            window.rowIndex[row] = row.requirements.Length - 1;
            window.BuildTable();
        }
Exemplo n.º 5
0
        public void RemoveAlternativeRow(object target)
        {
            var                 window   = StateWindow.Get();
            StateRow            row      = (StateRow)target;
            int                 rowIndex = window.rowIndex[row];
            List <StateRowData> data     = new List <StateRowData>(row.requirements);

            data.RemoveAt(rowIndex);
            row.requirements     = data.ToArray();
            window.rowIndex[row] = rowIndex - 1;
            window.BuildTable();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates one or more destination orders.
        /// </summary>
        /// <param name="destinationOrders"></param>
        internal static void CreateDestinationOrders(DestinationOrderInfo[] destinationOrders)
        {
            // An instance of the shared data model is required to use its methods.
            DataModel dataModel = new DataModel();

            // Business logic: provide the current time and the user identifier for the new destination order.
            DateTime dateTime = DateTime.UtcNow;
            Guid     userId   = TradingSupport.UserId;

            DataModelTransaction dataModelTransaction = DataModelTransaction.Current;

            StatusRow statusNewRow = DataModel.Status.StatusKeyStatusCode.Find(Status.New);

            statusNewRow.AcquireReaderLock(dataModelTransaction);

            StateRow stateIntialRow = DataModel.State.StateKeyStateCode.Find(State.Initial);

            stateIntialRow.AcquireReaderLock(dataModelTransaction);

            // The entire collection of destination orders is added or rejected as a single transaction.
            foreach (DestinationOrderInfo destinationOrderInfo in destinationOrders)
            {
                Guid destinationOrderId = Guid.NewGuid();
                dataModel.CreateDestinationOrder(
                    destinationOrderInfo.BlotterId,
                    0.0M,
                    null,
                    dateTime,
                    userId,
                    destinationOrderInfo.DestinationId,
                    destinationOrderId,
                    null,
                    null,
                    false,
                    false,
                    null,
                    dateTime,
                    userId,
                    destinationOrderInfo.OrderedQuantity,
                    destinationOrderInfo.OrderTypeId,
                    destinationOrderInfo.SecurityId,
                    dateTime,
                    destinationOrderInfo.SettlementId,
                    destinationOrderInfo.SideCodeId,
                    stateIntialRow.StateId,
                    statusNewRow.StatusId,
                    null,
                    destinationOrderInfo.TimeInForceCodeId,
                    dateTime,
                    null,
                    destinationOrderInfo.WorkingOrderId);
            }
        }
Exemplo n.º 7
0
        public StateRow NextStateRow(StateRow previous, int i)
        {
            StateRow current = new StateRow();

            Dictionary <string, double> times = new Dictionary <string, double>();
            var nextEvent = this.GetNextEvent(times, previous);

            switch (nextEvent.Key)
            {
            case "EndLoad":
                current = CreateStateRowEndLoad(previous, nextEvent.Value);
                break;

            case var val when new Regex(@"EndTravel_*").IsMatch(val):
                truck   = Convert.ToInt32(nextEvent.Key.Split('_')[1]);
                current = CreateStateRowEndTravel(previous, nextEvent.Value, truck);
                break;
            }

            return(current);
        }
Exemplo n.º 8
0
        private StateRow CreateStateRowEndTravel(StateRow previous, double time, int id)
        {
            StateRow newStateRow = new StateRow();

            newStateRow.Event = "Fin viaje (" + id + ")";
            newStateRow.Watch = time;

            if (previous.Shovel.Status == ShovelStatus.Free)
            {
                newStateRow.Shovel            = new Shovel();
                newStateRow.Shovel.Status     = ShovelStatus.Busy;
                newStateRow.Shovel.TruckQueue = new Queue <Truck>();

                // Load
                newStateRow.LoadRnd     = GetRandom();
                newStateRow.TimeEndLoad = this.UniformGeneratorLoad.Generate(newStateRow.LoadRnd);
                newStateRow.NextEndLoad = newStateRow.TimeEndLoad + newStateRow.Watch;

                newStateRow.Trucks = new List <Truck>();
                foreach (Truck t in previous.Trucks)
                {
                    if (t.Id == id)
                    {
                        t.Status     = TruckStatus.InLoad;
                        t.TimeTravel = 0;
                    }
                    newStateRow.Trucks.Add(t);
                }
            }
            else
            {
                newStateRow.NextEndLoad = previous.NextEndLoad;

                newStateRow.Shovel            = new Shovel();
                newStateRow.Shovel.Status     = ShovelStatus.Busy;
                newStateRow.Shovel.TruckQueue = new Queue <Truck>(previous.Shovel.TruckQueue);
                newStateRow.Shovel.TruckQueue.Enqueue(new Truck()
                {
                    Id = id, Status = TruckStatus.Waiting, TimeTravel = 0
                });

                newStateRow.Trucks = new List <Truck>();
                foreach (Truck t in previous.Trucks)
                {
                    if (t.Id == id)
                    {
                        t.Status     = TruckStatus.Waiting;
                        t.TimeTravel = 0;
                    }
                    newStateRow.Trucks.Add(t);
                }
            }

            newStateRow.Stat1 = previous.Stat1 + 1;
            if (previous.Shovel.Status == ShovelStatus.Free)
            {
                newStateRow.Stat2 = newStateRow.Watch - previous.Watch;
                newStateRow.Stat3 = previous.Stat3 + newStateRow.Stat2;
            }
            else
            {
                newStateRow.Stat2 = 0;
                newStateRow.Stat3 = previous.Stat3;
            }

            return(newStateRow);
        }
Exemplo n.º 9
0
        private void btnSimulate_Click(object sender, EventArgs e)
        {
            if (!ValidateInputs())
            {
                MessageBox.Show("Ingrese parámetros válidos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int           quantity          = Convert.ToInt32(this.txtQuantity.Text);
            int           from              = Convert.ToInt32(this.txtFrom.Text);
            int           to                = Convert.ToInt32(this.txtTo.Text);
            int           truckQuantitySim1 = Convert.ToInt32(this.txtTruckQuantitySim1.Text);
            int           truckQuantitySim2 = Convert.ToInt32(this.txtTruckQuantitySim2.Text);
            int           truckQuantitySim3 = Convert.ToInt32(this.txtTruckQuantitySim3.Text);
            GeneratorType generatorType;

            if (this.cmbGenerator.SelectedIndex == 0)
            {
                generatorType = GeneratorType.Congruential;
            }
            else
            {
                generatorType = GeneratorType.Language;
            }

            this.dgvResultsSim1.Rows.Clear();
            this.dgvResultsSim1.ColumnCount = 14;
            this.dgvResultsSim2.Rows.Clear();
            this.dgvResultsSim2.ColumnCount = 14;
            this.dgvResultsSim3.Rows.Clear();
            this.dgvResultsSim3.ColumnCount = 14;

            LoadTrucksColumns(truckQuantitySim1, truckQuantitySim2, truckQuantitySim3);

            Simulator sim1 = new Simulator(generatorType);
            Simulator sim2 = new Simulator(generatorType);
            Simulator sim3 = new Simulator(generatorType);

            #region Init Sim 1
            Queue <Truck> trucksQueueSim1 = CreateTruckQueue(truckQuantitySim1);
            StateRow      previousSim1    = new StateRow();
            previousSim1.IterationNum = 0;
            previousSim1.Watch        = 0;
            previousSim1.Event        = "Init";
            previousSim1.Shovel       = new Shovel()
            {
                Status = ShovelStatus.Busy, TruckQueue = trucksQueueSim1
            };
            previousSim1.LoadRnd     = sim1.GetRandom();
            previousSim1.TimeEndLoad = sim1.UniformGeneratorLoad.Generate(previousSim1.LoadRnd);
            previousSim1.NextEndLoad = previousSim1.Watch + previousSim1.TimeEndLoad;
            previousSim1.Trucks      = trucksQueueSim1.ToList();
            previousSim1.Trucks.Insert(0, new Truck()
            {
                Id = 1, Status = TruckStatus.InLoad, TimeTravel = 0
            });
            #endregion
            #region Init Sim 2
            Queue <Truck> trucksQueueSim2 = CreateTruckQueue(truckQuantitySim2);
            StateRow      previousSim2    = new StateRow();
            previousSim2.IterationNum = 0;
            previousSim2.Watch        = 0;
            previousSim2.Event        = "Init";
            previousSim2.Shovel       = new Shovel()
            {
                Status = ShovelStatus.Busy, TruckQueue = trucksQueueSim2
            };
            previousSim2.LoadRnd     = sim2.GetRandom();
            previousSim2.TimeEndLoad = sim2.UniformGeneratorLoad.Generate(previousSim2.LoadRnd);
            previousSim2.NextEndLoad = previousSim2.Watch + previousSim2.TimeEndLoad;
            previousSim2.Trucks      = trucksQueueSim2.ToList();
            previousSim2.Trucks.Insert(0, new Truck()
            {
                Id = 1, Status = TruckStatus.InLoad, TimeTravel = 0
            });
            #endregion
            #region Init Sim 3
            Queue <Truck> trucksQueueSim3 = CreateTruckQueue(truckQuantitySim3);
            StateRow      previousSim3    = new StateRow();
            previousSim3.IterationNum = 0;
            previousSim3.Watch        = 0;
            previousSim3.Event        = "Init";
            previousSim3.Shovel       = new Shovel()
            {
                Status = ShovelStatus.Busy, TruckQueue = trucksQueueSim3
            };
            previousSim3.LoadRnd     = sim3.GetRandom();
            previousSim3.TimeEndLoad = sim3.UniformGeneratorLoad.Generate(previousSim3.LoadRnd);
            previousSim3.NextEndLoad = previousSim3.Watch + previousSim3.TimeEndLoad;
            previousSim3.Trucks      = trucksQueueSim3.ToList();
            previousSim3.Trucks.Insert(0, new Truck()
            {
                Id = 1, Status = TruckStatus.InLoad, TimeTravel = 0
            });
            #endregion

            if (from == 0)
            {
                PrintStateRow(this.dgvResultsSim1, previousSim1);
                PrintStateRow(this.dgvResultsSim2, previousSim2);
                PrintStateRow(this.dgvResultsSim3, previousSim3);
            }

            for (int i = 0; i < quantity; i++)
            {
                StateRow currentSim1 = sim1.NextStateRow(previousSim1, i);
                StateRow currentSim2 = sim2.NextStateRow(previousSim2, i);
                StateRow currentSim3 = sim3.NextStateRow(previousSim3, i);
                currentSim1.IterationNum = i + 1;
                currentSim2.IterationNum = i + 1;
                currentSim3.IterationNum = i + 1;

                if (i >= from - 1 && i < to)
                {
                    PrintStateRow(this.dgvResultsSim1, currentSim1);
                    PrintStateRow(this.dgvResultsSim2, currentSim2);
                    PrintStateRow(this.dgvResultsSim3, currentSim3);
                }

                previousSim1 = currentSim1;
                previousSim2 = currentSim2;
                previousSim3 = currentSim3;
            }

            double percentageInactivyTimeSim1 = ((previousSim1.Stat3 * 100) / previousSim1.Watch);
            this.txtInactivityPercentageSim1.Text = TruncateToFour(percentageInactivyTimeSim1).ToString();
            this.txtTravelsSim1.Text    = previousSim1.Stat1.ToString();
            this.lblFinalWatchSim1.Text = "en " + TruncateToFour(previousSim1.Watch).ToString() + " mins";
            dgvPreviousResults.Rows.Add(truckQuantitySim1, TruncateToFour(percentageInactivyTimeSim1));
            this.txtInactivityTimeSim1.Text = previousSim1.Stat3.ToString();

            double percentageInactivyTimeSim2 = ((previousSim2.Stat3 * 100) / previousSim2.Watch);
            this.txtInactivityPercentageSim2.Text = TruncateToFour(percentageInactivyTimeSim2).ToString();
            this.txtTravelsSim2.Text    = previousSim2.Stat1.ToString();
            this.lblFinalWatchSim2.Text = "en " + TruncateToFour(previousSim2.Watch).ToString() + " mins";
            dgvPreviousResults.Rows.Add(truckQuantitySim2, TruncateToFour(percentageInactivyTimeSim2));
            this.txtInactivityTimeSim2.Text = previousSim2.Stat3.ToString();

            double percentageInactivyTimeSim3 = ((previousSim3.Stat3 * 100) / previousSim3.Watch);
            this.txtInactivityPercentageSim3.Text = TruncateToFour(percentageInactivyTimeSim3).ToString();
            this.txtTravelsSim3.Text    = previousSim3.Stat1.ToString();
            this.lblFinalWatchSim3.Text = "en " + TruncateToFour(previousSim3.Watch).ToString() + " mins";
            dgvPreviousResults.Rows.Add(truckQuantitySim3, TruncateToFour(percentageInactivyTimeSim3));
            this.txtInactivityTimeSim3.Text = previousSim3.Stat3.ToString();

            List <StateRow> results = new List <StateRow>();
            results.Add(previousSim1);
            results.Add(previousSim2);
            results.Add(previousSim3);
            results = results.OrderBy(sr => sr.Stat3).ThenBy(sr => sr.Trucks.Count).ToList();
            if (results.First() == previousSim1)
            {
                this.txtBestResult.Text = "Simulación 1";
            }
            else if (results.First() == previousSim2)
            {
                this.txtBestResult.Text = "Simulación 2";
            }
            else if (results.First() == previousSim3)
            {
                this.txtBestResult.Text = "Simulación 3";
            }
        }
Exemplo n.º 10
0
        private void BtnSimulate_Click(object sender, EventArgs e)
        {
            if (!validateInputs())
            {
                MessageBox.Show("Debe completar todos los campos antes de continuar", "Datos incompletos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            this.dgvResults.Rows.Clear();
            Avion.count = 0;

            int quantity = Convert.ToInt32(this.txtQuantity.Text);
            int from     = Convert.ToInt32(this.txtFrom.Text);
            int to       = from + 100;

            if (to > quantity)
            {
                to = quantity;
            }
            this.txtTo.Text = to.ToString();
            double proxAvion = Convert.ToDouble(this.txtFirstPlaneArrival.Text);

            Simulator simulator = new Simulator();

            simulator.clientes = this.getAvionesEstacionados();

            Generator generator = new Generator();

            double rndInesI = generator.NextRnd();
            double tiempoInesI;

            if (rndInesI < 0.2)
            {
                tiempoInesI = 320.7000;
            }
            else if (rndInesI < 0.5)
            {
                tiempoInesI = 367.5000;
            }
            else
            {
                tiempoInesI = 417.2000;
            }

            StateRow anterior = new StateRow()
            {
                tiempoProximaLlegada = proxAvion,
                pista = new Pista()
                {
                    state = "Libre", colaEET = new Queue <Avion>(), colaEEV = new Queue <Avion>()
                },
                evento              = "Inicializacion",
                reloj               = 0,
                iterationNum        = 0,
                rndInestable        = rndInesI,
                tiempoInestabilidad = tiempoInesI
            };

            // Se imprimen por única vez las columnas fijas del vector de estado
            #region columnas fijas
            this.dgvResults.ColumnCount = 27;

            this.dgvResults.Columns[0].HeaderText = "n°";
            this.dgvResults.Columns[1].HeaderText = "Evento";
            this.dgvResults.Columns[2].HeaderText = "Reloj";
            this.dgvResults.Columns[0].SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[1].SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[2].SortMode   = DataGridViewColumnSortMode.NotSortable;

            this.dgvResults.Columns[3].HeaderText = "RND";
            this.dgvResults.Columns[4].HeaderText = "T. entre llegadas";
            this.dgvResults.Columns[5].HeaderText = "T. prox. llegada";
            this.dgvResults.Columns[3].DefaultCellStyle.BackColor = Color.LightSkyBlue;
            this.dgvResults.Columns[4].DefaultCellStyle.BackColor = Color.LightSkyBlue;
            this.dgvResults.Columns[5].DefaultCellStyle.BackColor = Color.LightSkyBlue;
            this.dgvResults.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;

            this.dgvResults.Columns[6].HeaderText = "RND";
            this.dgvResults.Columns[7].HeaderText = "T. aterrizaje";
            this.dgvResults.Columns[8].HeaderText = "T. fin aterrizaje";
            this.dgvResults.Columns[6].DefaultCellStyle.BackColor = Color.LightPink;
            this.dgvResults.Columns[7].DefaultCellStyle.BackColor = Color.LightPink;
            this.dgvResults.Columns[8].DefaultCellStyle.BackColor = Color.LightPink;
            this.dgvResults.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[8].SortMode = DataGridViewColumnSortMode.NotSortable;

            this.dgvResults.Columns[9].HeaderText  = "SUM RND";
            this.dgvResults.Columns[10].HeaderText = "T. permanencia";
            this.dgvResults.Columns[11].HeaderText = "T. fin permanencia";
            this.dgvResults.Columns[9].DefaultCellStyle.BackColor  = Color.Turquoise;
            this.dgvResults.Columns[10].DefaultCellStyle.BackColor = Color.Turquoise;
            this.dgvResults.Columns[11].DefaultCellStyle.BackColor = Color.Turquoise;
            this.dgvResults.Columns[9].SortMode  = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[10].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[11].SortMode = DataGridViewColumnSortMode.NotSortable;

            this.dgvResults.Columns[12].HeaderText = "RND";
            this.dgvResults.Columns[13].HeaderText = "T. despegue";
            this.dgvResults.Columns[14].HeaderText = "T. fin despegue";
            this.dgvResults.Columns[12].DefaultCellStyle.BackColor = Color.SandyBrown;
            this.dgvResults.Columns[13].DefaultCellStyle.BackColor = Color.SandyBrown;
            this.dgvResults.Columns[14].DefaultCellStyle.BackColor = Color.SandyBrown;
            this.dgvResults.Columns[12].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[13].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[14].SortMode = DataGridViewColumnSortMode.NotSortable;

            this.dgvResults.Columns[15].HeaderText = "RND";
            this.dgvResults.Columns[16].HeaderText = "T. sig. interrupción";
            this.dgvResults.Columns[17].HeaderText = "T. fin purga";
            this.dgvResults.Columns[15].DefaultCellStyle.BackColor = Color.LightGreen;
            this.dgvResults.Columns[16].DefaultCellStyle.BackColor = Color.LightGreen;
            this.dgvResults.Columns[17].DefaultCellStyle.BackColor = Color.LightGreen;
            this.dgvResults.Columns[15].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[16].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[17].SortMode = DataGridViewColumnSortMode.NotSortable;

            this.dgvResults.Columns[18].HeaderText = "Estado pista";
            this.dgvResults.Columns[19].HeaderText = "Cola EET";
            this.dgvResults.Columns[20].HeaderText = "Cola EEV";
            this.dgvResults.Columns[21].HeaderText = "T. restante suspensión";
            this.dgvResults.Columns[18].SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[19].SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[20].SortMode   = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[21].SortMode   = DataGridViewColumnSortMode.NotSortable;


            this.dgvResults.Columns[22].HeaderText = "% aviones sin espera";
            this.dgvResults.Columns[23].HeaderText = "Máx. T. EET";
            this.dgvResults.Columns[24].HeaderText = "Prom. T. EET";
            this.dgvResults.Columns[25].HeaderText = "Máx. T. EEV";
            this.dgvResults.Columns[26].HeaderText = "Prom. T. EEV";
            this.dgvResults.Columns[22].DefaultCellStyle.BackColor = Color.MediumAquamarine;
            this.dgvResults.Columns[23].DefaultCellStyle.BackColor = Color.DarkSalmon;
            this.dgvResults.Columns[24].DefaultCellStyle.BackColor = Color.DarkSalmon;
            this.dgvResults.Columns[25].DefaultCellStyle.BackColor = Color.LightSteelBlue;
            this.dgvResults.Columns[26].DefaultCellStyle.BackColor = Color.LightSteelBlue;
            this.dgvResults.Columns[22].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[23].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[24].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[25].SortMode = DataGridViewColumnSortMode.NotSortable;
            this.dgvResults.Columns[26].SortMode = DataGridViewColumnSortMode.NotSortable;
            #endregion columnas fijas

            if (from == 0)
            {
                this.dgvResults.Rows.Add();
                this.dgvResults.Rows[0].Cells[0].Value  = anterior.iterationNum;
                this.dgvResults.Rows[0].Cells[1].Value  = anterior.evento;
                this.dgvResults.Rows[0].Cells[2].Value  = truncar(anterior.reloj);
                this.dgvResults.Rows[0].Cells[3].Value  = diferenteDeCero(anterior.rndLlegada);
                this.dgvResults.Rows[0].Cells[4].Value  = diferenteDeCero(anterior.tiempoEntreLlegadas);
                this.dgvResults.Rows[0].Cells[5].Value  = diferenteDeCero(anterior.tiempoProximaLlegada);
                this.dgvResults.Rows[0].Cells[6].Value  = diferenteDeCero(anterior.rndAterrizaje);
                this.dgvResults.Rows[0].Cells[7].Value  = diferenteDeCero(anterior.tiempoAterrizaje);
                this.dgvResults.Rows[0].Cells[8].Value  = diferenteDeCero(anterior.tiempoFinAterrizaje);
                this.dgvResults.Rows[0].Cells[9].Value  = diferenteDeCero(anterior.rndPermanencia);
                this.dgvResults.Rows[0].Cells[10].Value = diferenteDeCero(anterior.tiempoDePermanencia);
                this.dgvResults.Rows[0].Cells[11].Value = diferenteDeCero(anterior.tiempoFinPermanencia);
                this.dgvResults.Rows[0].Cells[12].Value = diferenteDeCero(anterior.rndDespegue);
                this.dgvResults.Rows[0].Cells[13].Value = diferenteDeCero(anterior.tiempoDeDespegue);
                this.dgvResults.Rows[0].Cells[14].Value = diferenteDeCero(anterior.tiempoFinDeDespegue);
                this.dgvResults.Rows[0].Cells[15].Value = diferenteDeCero(anterior.rndInestable);
                this.dgvResults.Rows[0].Cells[16].Value = diferenteDeCero(anterior.tiempoInestabilidad);
                this.dgvResults.Rows[0].Cells[17].Value = diferenteDeCero(anterior.tiempoFinPurga);
                this.dgvResults.Rows[0].Cells[18].Value = anterior.pista.state;
                this.dgvResults.Rows[0].Cells[19].Value = anterior.pista.colaEET.Count;
                this.dgvResults.Rows[0].Cells[20].Value = anterior.pista.colaEEV.Count;
                this.dgvResults.Rows[0].Cells[21].Value = diferenteDeCero(anterior.pista.tiempoRestanteAoD);
                this.dgvResults.Rows[0].Cells[22].Value = truncar(anterior.porcAvionesAyDInst);
                this.dgvResults.Rows[0].Cells[23].Value = truncar(anterior.maxEETTime);
                this.dgvResults.Rows[0].Cells[24].Value = truncar(anterior.avgEETTime);
                this.dgvResults.Rows[0].Cells[25].Value = truncar(anterior.maxEEVTime);
                this.dgvResults.Rows[0].Cells[26].Value = truncar(anterior.avgEEVTime);

                int cont = 0;
                for (int j = 0; j < simulator.clientes.Count; j++)
                {
                    if (simulator.clientes[j].disabled)
                    {
                        this.dgvResults.Rows[0].Cells[27 + cont].Value     = simulator.clientes[j].estado;
                        this.dgvResults.Rows[0].Cells[27 + cont + 1].Value = diferenteDeCero(simulator.clientes[j].tiempoPermanencia);
                    }
                    else
                    {
                        this.dgvResults.ColumnCount += 2;

                        this.dgvResults.Columns[27 + cont].HeaderText     = "Estado cliente " + simulator.clientes[j].id.ToString();
                        this.dgvResults.Columns[27 + cont + 1].HeaderText = "T. permanencia " + simulator.clientes[j].id.ToString();
                        this.dgvResults.Columns[27 + cont].SortMode       = DataGridViewColumnSortMode.NotSortable;
                        this.dgvResults.Columns[27 + cont + 1].SortMode   = DataGridViewColumnSortMode.NotSortable;

                        this.dgvResults.Rows[0].Cells[27 + cont].Value     = simulator.clientes[j].estado;
                        this.dgvResults.Rows[0].Cells[27 + cont + 1].Value = diferenteDeCero(simulator.clientes[j].tiempoPermanencia);

                        simulator.clientes[j].disabled = true;
                    }
                    cont += 2;
                }
            }

            int filas = 0;
            if (from == 0)
            {
                filas = 1;
            }
            var columnaInicial = 0;
            for (int i = 0; i < quantity; i++)
            {
                StateRow actual = simulator.NextStateRow(anterior, i);

                if (i >= from - 1 && i < to)
                {
                    this.dgvResults.Rows.Add();
                    this.dgvResults.Rows[filas].Cells[0].Value  = actual.iterationNum;
                    this.dgvResults.Rows[filas].Cells[1].Value  = actual.evento;
                    this.dgvResults.Rows[filas].Cells[2].Value  = truncar(actual.reloj);
                    this.dgvResults.Rows[filas].Cells[3].Value  = diferenteDeCero(actual.rndLlegada);
                    this.dgvResults.Rows[filas].Cells[4].Value  = diferenteDeCero(actual.tiempoEntreLlegadas);
                    this.dgvResults.Rows[filas].Cells[5].Value  = diferenteDeCero(actual.tiempoProximaLlegada);
                    this.dgvResults.Rows[filas].Cells[6].Value  = diferenteDeCero(actual.rndAterrizaje);
                    this.dgvResults.Rows[filas].Cells[7].Value  = diferenteDeCero(actual.tiempoAterrizaje);
                    this.dgvResults.Rows[filas].Cells[8].Value  = diferenteDeCero(actual.tiempoFinAterrizaje);
                    this.dgvResults.Rows[filas].Cells[9].Value  = diferenteDeCero(actual.rndPermanencia);
                    this.dgvResults.Rows[filas].Cells[10].Value = diferenteDeCero(actual.tiempoDePermanencia);
                    this.dgvResults.Rows[filas].Cells[11].Value = diferenteDeCero(actual.tiempoFinPermanencia);
                    this.dgvResults.Rows[filas].Cells[12].Value = diferenteDeCero(actual.rndDespegue);
                    this.dgvResults.Rows[filas].Cells[13].Value = diferenteDeCero(actual.tiempoDeDespegue);
                    this.dgvResults.Rows[filas].Cells[14].Value = diferenteDeCero(actual.tiempoFinDeDespegue);
                    this.dgvResults.Rows[filas].Cells[15].Value = diferenteDeCero(actual.rndInestable);
                    this.dgvResults.Rows[filas].Cells[16].Value = diferenteDeCero(actual.tiempoInestabilidad);
                    this.dgvResults.Rows[filas].Cells[17].Value = diferenteDeCero(actual.tiempoFinPurga);
                    this.dgvResults.Rows[filas].Cells[18].Value = actual.pista.state;
                    this.dgvResults.Rows[filas].Cells[19].Value = actual.pista.colaEET.Count;
                    this.dgvResults.Rows[filas].Cells[20].Value = actual.pista.colaEEV.Count;
                    this.dgvResults.Rows[filas].Cells[21].Value = diferenteDeCero(actual.pista.tiempoRestanteAoD);
                    this.dgvResults.Rows[filas].Cells[22].Value = truncar(actual.porcAvionesAyDInst);
                    this.dgvResults.Rows[filas].Cells[23].Value = truncar(actual.maxEETTime);
                    this.dgvResults.Rows[filas].Cells[24].Value = truncar(actual.avgEETTime);
                    this.dgvResults.Rows[filas].Cells[25].Value = truncar(actual.maxEEVTime);
                    this.dgvResults.Rows[filas].Cells[26].Value = truncar(actual.avgEEVTime);

                    if (i == from - 1)
                    {
                        for (int j = 0; j < simulator.clientes.Count; j++)
                        {
                            if (simulator.clientes[j].estado != "")
                            {
                                columnaInicial = j;
                                break;
                            }
                        }
                    }

                    int cont = 0;
                    for (int j = columnaInicial; j < simulator.clientes.Count; j++)
                    {
                        if (simulator.clientes[j].disabled)
                        {
                            this.dgvResults.Rows[filas].Cells[27 + cont].Value     = simulator.clientes[j].estado;
                            this.dgvResults.Rows[filas].Cells[27 + cont + 1].Value = diferenteDeCero(simulator.clientes[j].tiempoPermanencia);
                        }
                        else
                        {
                            this.dgvResults.ColumnCount += 2;

                            this.dgvResults.Columns[27 + cont].HeaderText     = "Estado cliente " + simulator.clientes[j].id.ToString();
                            this.dgvResults.Columns[27 + cont + 1].HeaderText = "T. permanencia " + simulator.clientes[j].id.ToString();
                            this.dgvResults.Columns[27 + cont].SortMode       = DataGridViewColumnSortMode.NotSortable;
                            this.dgvResults.Columns[27 + cont + 1].SortMode   = DataGridViewColumnSortMode.NotSortable;

                            this.dgvResults.Rows[filas].Cells[27 + cont].Value     = simulator.clientes[j].estado;
                            this.dgvResults.Rows[filas].Cells[27 + cont + 1].Value = diferenteDeCero(simulator.clientes[j].tiempoPermanencia);

                            simulator.clientes[j].disabled = true;
                        }
                        cont += 2;
                    }

                    filas += 1;
                }

                // Muestro estadísticas
                if (i == quantity - 1)
                {
                    this.txtMaxTimeEET.Text     = truncar(actual.maxEETTime).ToString();
                    this.txtMaxTimeEEV.Text     = truncar(actual.maxEEVTime).ToString();
                    this.txtAvgTimeEET.Text     = truncar(actual.avgEETTime).ToString();
                    this.txtAvgTimeEEV.Text     = truncar(actual.avgEEVTime).ToString();
                    this.txtPorcAyDInstant.Text = truncar(actual.porcAvionesAyDInst).ToString();
                }

                anterior = actual;
            }

            this.dgvResults.AllowUserToOrderColumns = false;
        }
Exemplo n.º 11
0
 public void AddStateRow(StateRow row) {
     this.Rows.Add(row);
 }
Exemplo n.º 12
0
 public StateRowChangeEvent(StateRow row, System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
Exemplo n.º 13
0
 public CityRow AddCityRow(StateRow parentStateRowByFK_State_City_State_ID, TimezoneRow parentTimezoneRowByFK_Timezone_City_Timezone_ID, string Name, bool Is_Country_Capital, string Phone_Code, string Weather_Code) {
     CityRow rowCityRow = ((CityRow)(this.NewRow()));
     rowCityRow.ItemArray = new object[] {
             null,
             parentStateRowByFK_State_City_State_ID[0],
             parentTimezoneRowByFK_Timezone_City_Timezone_ID[0],
             Name,
             Is_Country_Capital,
             Phone_Code,
             Weather_Code};
     this.Rows.Add(rowCityRow);
     return rowCityRow;
 }
Exemplo n.º 14
0
        private void UpdateSelectedTeam(IState state)
        {
            using (var context = new Cm93Context())
            {
                var stateRow = new StateRow
                {
                    LastSaved = DateTime.Now,
                    Name      = state.Name,
                    Created   = state.Created,
                    StateGuid = state.Key.ToString(),
                    Season    = Configuration.Season,

                    TeamId = context.Teams.
                             Single(t => t.TeamName == Configuration.PlayerTeamName).
                             TeamId
                };

                context.States.Add(stateRow);

                var players = ((IPlayersModule)state.Modules[ModuleType.Players]).Players;

                context.Players.AddRange(players.
                                         Select(p => new PlayerRow
                {
                    Goals        = 0,
                    LocationX    = (float)p.Location.X,
                    LocationY    = (float)p.Location.Y,
                    Number       = p.Number,
                    NumericValue = p.NumericValue,
                    PlayerStatId = p.Id,
                    ReleaseValue = p.ReleaseValue,
                    StateId      = stateRow.StateId,
                    TeamId       = context.Teams.Single(t => t.TeamName == p.TeamName).TeamId,
                    Formation    = p.Formation
                }
                                                )
                                         );

                var competitions = ((IMatchModule)state.Modules[ModuleType.Match]).Competitions;

                foreach (var competition in competitions.OfType <Division>())
                {
                    context.Divisions.AddRange(competition.Places.
                                               Select(p => new DivisionRow
                    {
                        StateId        = stateRow.StateId,
                        CompetitionId  = context.Competitions.Single(c => c.CompetitionName == competition.CompetitionName).CompetitionId,
                        TeamId         = context.Teams.Single(t => t.TeamName == p.Key.TeamName).TeamId,
                        Draws          = p.Value.Draws,
                        GoalDifference = p.Value.GoalDifference,
                        GoalsAgainst   = p.Value.Against,
                        GoalsFor       = p.Value.For,
                        Losses         = p.Value.Losses,
                        Points         = p.Value.Points,
                        Wins           = p.Value.Wins
                    }));
                }

                context.SaveChangesAsync();
            }
        }
Exemplo n.º 15
0
        private KeyValuePair <string, double> GetNextEvent(Dictionary <string, double> times, StateRow previous)
        {
            if (previous.NextEndLoad != 0)
            {
                times.Add("EndLoad", previous.NextEndLoad);
            }

            for (int i = 0; i < previous.Trucks.Count; i++)
            {
                if (previous.Trucks[i].TimeTravel != 0)
                {
                    times.Add("EndTravel_" + previous.Trucks[i].Id, previous.Trucks[i].TimeTravel);
                }
            }

            var orderedTimes = times.OrderBy(obj => obj.Value).ToDictionary(obj => obj.Key, obj => obj.Value);
            KeyValuePair <string, double> nextEvent = orderedTimes.First();

            return(nextEvent);
        }
Exemplo n.º 16
0
        private StateRow CreateStateRowEndLoad(StateRow previous, double time)
        {
            StateRow newStateRow = new StateRow();

            newStateRow.Event = "Fin carga";
            newStateRow.Watch = time;

            if (previous.Shovel.TruckQueue.Count > 0)
            {
                newStateRow.Shovel        = new Shovel();
                newStateRow.Shovel.Status = ShovelStatus.Busy;
                Truck truck = previous.Shovel.TruckQueue.Dequeue();
                newStateRow.Shovel.TruckQueue = new Queue <Truck>(previous.Shovel.TruckQueue);

                // Load
                newStateRow.LoadRnd     = GetRandom();
                newStateRow.TimeEndLoad = this.UniformGeneratorLoad.Generate(newStateRow.LoadRnd);
                newStateRow.NextEndLoad = newStateRow.TimeEndLoad + newStateRow.Watch;

                // Travel
                newStateRow.TravelRnd     = GetRandom();
                newStateRow.TimeEndTravel = this.ExponentialGeneratorTravel.Generate(newStateRow.TravelRnd);
                newStateRow.NextEndTravel = newStateRow.TimeEndTravel + newStateRow.Watch;

                newStateRow.Trucks = new List <Truck>();
                foreach (Truck t in previous.Trucks)
                {
                    if (t.Status == TruckStatus.InLoad)
                    {
                        t.Status     = TruckStatus.InTravel;
                        t.TimeTravel = newStateRow.NextEndTravel;
                    }

                    if (t.Id == truck.Id)
                    {
                        t.Status     = TruckStatus.InLoad;
                        t.TimeTravel = 0;
                    }
                    newStateRow.Trucks.Add(t);
                }
            }
            else
            {
                newStateRow.Shovel            = new Shovel();
                newStateRow.Shovel.Status     = ShovelStatus.Free;
                newStateRow.Shovel.TruckQueue = new Queue <Truck>();

                // Travel
                newStateRow.TravelRnd     = GetRandom();
                newStateRow.TimeEndTravel = this.ExponentialGeneratorTravel.Generate(newStateRow.TravelRnd);
                newStateRow.NextEndTravel = newStateRow.TimeEndTravel + newStateRow.Watch;

                newStateRow.Trucks = new List <Truck>();
                foreach (Truck t in previous.Trucks)
                {
                    if (t.Status == TruckStatus.InLoad)
                    {
                        t.Status     = TruckStatus.InTravel;
                        t.TimeTravel = newStateRow.NextEndTravel;
                    }
                    newStateRow.Trucks.Add(t);
                }
            }

            newStateRow.Stat1 = previous.Stat1;
            if (previous.Shovel.Status == ShovelStatus.Free)
            {
                newStateRow.Stat2 = newStateRow.Watch - previous.Watch;
                newStateRow.Stat3 = previous.Stat3 + newStateRow.Stat2;
            }
            else
            {
                newStateRow.Stat2 = 0;
                newStateRow.Stat3 = previous.Stat3;
            }

            return(newStateRow);
        }
Exemplo n.º 17
0
 public void RemoveStateRow(StateRow row) {
     this.Rows.Remove(row);
 }