示例#1
0
        private void Simulacion()
        {
            int accion, t_siguiente, t_timeout, t1, t2;

            //1ms de reloj equivalen a 12s simulados,
            //luego 2ms -> 24s, 10ms -> 2min, ...
            while (reloj.getTiempo() * 12 < 24 * 60 * 60)
            { // 24*60*60/12 = 7200ms después termina
                t1          = (int)(t1_sig * 60 / 12);
                t2          = (int)(t2_sig * 60 / 12);
                t_siguiente = A.RandomNumber(t1, t2);
                Thread.Sleep(t_siguiente);
                accion = this.accion(reloj.getTiempo() * 12 / 60);
                if (accion == 1)//APARCAR
                {
                    t1        = (int)(t1_out * 60 / 12);
                    t2        = (int)(t2_out * 60 / 12);
                    t_timeout = A.RandomNumber(t1, t2);
                    parking.Aparcar(tipo, t_timeout);
                }
                else if (accion == -1)//SALIR
                {
                    parking.Salir(tipo);
                }
                //0 NADA
            }
        }
示例#2
0
 public void Salir(char tipo)
 {
     lock (bloqueo)
     {
         if (count > 0)
         {
             for (int i = 0; i < size; i++)
             {
                 if (plazas[i] == tipo)
                 {
                     plazas[i] = '_';
                     count--;
                     Log.msg(reloj.getTiempo(), this, tipo, "- sale");
                     Monitor.Pulse(bloqueo);
                     break;
                 }
             }
         }
     }
 }