Esempio n. 1
0
                                                       } }                                           // event adapter

        /**********************************************************/
        /* All internal events shall be private,                  */
        /* and inherite from InternalEvent as defined above       */
        /**********************************************************/
        //private class InitEvent : InternalEvent
        //{
        //    public override void Invoke()
        //    {
        //        Schedule(This.Queueing1.Enqueue(), TimeSpan.FromMinutes(5));
        //    }
        //}

        //private class FinishEvent : InternalEvent
        //{
        //    public override void Invoke()
        //    {
        //        This.TotalNCompleted++;
        //    }
        //}
        #endregion

        #region Input Events - Getters
        /***************************************************************/
        /* Methods returning an InternalEvent as O2DESNet.Event,       */
        /* with parameters for the objects to be passed in.            */
        /* Note that the InternalEvent shall always carry This = this. */
        /***************************************************************/
        //public Event Input(TLoad load) { return new InternalEvent { This = this, Load = load }; }
        #endregion

        #region Output Events - Reference to Getters
        /***********************************************************************/
        /* List of functions that maps outgoing objects to an external event.  */
        /* Note that the mapping is specified only in external structure.      */
        /***********************************************************************/
        //public List<Func<TLoad, Event>> OnOutput { get; private set; } = new List<Func<TLoad, Event>>();
        #endregion

        public Modular_TandemQ(Statics config, int seed, string tag = null) : base(config, seed, tag)
        {
            // 子模块(动态属性)的初始化
            Generator = new Generator(Config.Generator, DefaultRS.Next());
            Queueing1 = new Queueing(Config.Queueing1, DefaultRS.Next());
            Server1   = new Server(Config.Server1, DefaultRS.Next());
            Queueing2 = new Queueing(Config.Queueing2, DefaultRS.Next());
            Server2   = new Server(Config.Server2, DefaultRS.Next());

            // 连接子模块之间的输出和输入事件
            Generator.OnArrive.Add(Queueing1.Enqueue);
            //Generator.OnArrive.Add(() => Queueing.Enqueue());
            Queueing1.OnDequeue.Add(Server1.Start);
            Server1.OnDepart.Add(Queueing2.Enqueue);
            Queueing2.OnDequeue.Add(Server2.Start);

            Server2.OnStateChg.Add(() => Queueing2.UpdToDequeue(Server2.Vacancy > 0));
            Queueing2.OnStateChg.Add(() => Server1.UpdToDepart(Queueing2.Vacancy > 0));
            Server1.OnStateChg.Add(() => Queueing1.UpdToDequeue(Server1.Vacancy > 0));
            //Server1.OnDepart.Add(() => new FinishEvent { This = this });

            // 初始化事件
            InitEvents.AddRange(Generator.InitEvents);
            //InitEvents.Add(new InitEvent { This = this });
        }
Esempio n. 2
0
    private bool _startUp()
    {
        _curSceneName = ScenesName.LOGIN;

        InitHandlers initHandlers = new InitHandlers();

        initHandlers.init();
//		SocketHelper.GetInstance ().setHandlers (initHandlers.getHandlers ());

        InitEvents initEvents = new InitEvents();

        initEvents.init();

        InitConfigs initCfgs = new InitConfigs();

        initCfgs.init();
        _cfgs = initCfgs.getCfgs();

        InitMgrs initMgr = new InitMgrs();

        initMgr.init();
        _mgrs = initMgr.getMgrs();
        initMgr.inited();

        SolaSaver  saver = SolaSaver.getInstance();
        JsonObject data  = saver.load();

        foreach (BaseMgr mgr in _mgrs.Values)
        {
            mgr.loadData(data);
        }

        return(true);
    }
Esempio n. 3
0
        /***************************************************************/
        /* Methods returning an InternalEvent as O2DESNet.Event,       */
        /* with parameters for the objects to be passed in.            */
        /* Note that the InternalEvent shall always carry This = this. */
        /***************************************************************/
        //public Event Arrive(TLoad load, int procedureIndex) { return new ArriveEvent { This = this, Load = load, ProcedureIndex = procedureIndex }; }
        #endregion

        #region Output Events - Reference to Getters
        /***********************************************************************/
        /* List of functions that maps outgoing objects to an external event.  */
        /* Note that the mapping is specified only in external structure.      */
        /***********************************************************************/
        //public List<Func<TLoad, Event>> OnOutput { get; private set; } = new List<Func<TLoad, Event>>();
        #endregion

        public Model(Statics config, int seed, string tag = null) : base(config, seed, tag)
        {
            Name = "Model";
            Init();
            InitEvents.Add(new ArriveEvent {
                This = this
            });
        }
Esempio n. 4
0
                                                       } }                                        // event adapter

        /**********************************************************/
        /* All internal events shall be private,                  */
        /* and inherite from InternalEvent as defined above       */
        /**********************************************************/
        //private class InitEvent : InternalEvent
        //{
        //    public override void Invoke()
        //    {
        //        throw new NotImplementedException();
        //    }
        //}
        #endregion

        #region Input Events - Getters
        /***************************************************************/
        /* Methods returning an InternalEvent as O2DESNet.Event,       */
        /* with parameters for the objects to be passed in.            */
        /* Note that the InternalEvent shall always carry This = this. */
        /***************************************************************/
        //public Event Input(TLoad load) { return new InternalEvent { This = this, Load = load }; }
        #endregion

        #region Output Events - Reference to Getters
        /***********************************************************************/
        /* List of functions that maps outgoing objects to an external event.  */
        /* Note that the mapping is specified only in external structure.      */
        /***********************************************************************/
        //public List<Func<TLoad, Event>> OnOutput { get; private set; } = new List<Func<TLoad, Event>>();
        #endregion

        public Modular_MMnQ(Statics config, int seed, string tag = null) : base(config, seed, tag)
        {
            // 子模块(动态属性)的初始化
            Generator = new Generator(Config.Generator, DefaultRS.Next());
            Queueing  = new Queueing(Config.Queueing, DefaultRS.Next());
            Server    = new Server(Config.Server, DefaultRS.Next());

            // 连接子模块之间的输出和输入事件
            Generator.OnArrive.Add(Queueing.Enqueue);
            //Generator.OnArrive.Add(() => Queueing.Enqueue());
            Queueing.OnDequeue.Add(Server.Start);
            Server.OnStateChg.Add(() => Queueing.UpdToDequeue(Server.Vacancy > 0));

            // 初始化事件
            InitEvents.AddRange(Generator.InitEvents);
        }
Esempio n. 5
0
        public Network(Statics config, int seed, string tag = null) : base(config, seed, tag)
        {
            Name    = "Network";
            Display = true;

            for (int i = 0; i < Config.NNodes; i++)
            {
                for (int j = 0; j < Config.NNodes; j++)
                {
                    if (i != j && Config.DemandRates[i, j] > 0)
                    {
                        int o = i, d = j;
                        var g = new Generator <Order>(
                            new Generator <Order> .Statics
                        {
                            Create = rs => new Order(new Order.Statics
                            {
                                Origin      = o,
                                Destination = d,
                            }, rs.Next()),
                            InterArrivalTime = rs => TimeSpan.FromDays(
                                Exponential.Sample(rs, 1 / Config.DemandRates[o, d])),
                            SkipFirst = true,
                        }, DefaultRS.Next());
                        g.OnArrive.Add(order => new DemandArriveEvent {
                            This = this, Order = order
                        });
                        Generators.Add(new Tuple <int, int>(i, j), g);
                        InitEvents.Add(g.Start());
                    }
                }
            }
            Transporters.AddRange(Enumerable.Range(0, Config.NTransporters)
                                  .Select(i => new Transporter(new Transporter.Statics(), DefaultRS.Next())
            {
                Display = Display,
                Tag     = "Transporter#" + i,
            }));
            foreach (var t in Transporters)
            {
                t.OnFinishTransport.Add(order => new DeliverEvent {
                    This = this, Order = order
                });
            }
            InitEvents.AddRange(Transporters.Select(t => t.Init(this)));
        }
Esempio n. 6
0
        /***************************************************************/
        /* Methods returning an InternalEvent as O2DESNet.Event,       */
        /* with parameters for the objects to be passed in.            */
        /* Note that the InternalEvent shall always carry This = this. */
        /***************************************************************/
        //public Event Input(TLoad load) { return new InternalEvent { This = this, Load = load }; }
        #endregion

        #region Output Events - Reference to Getters
        /***********************************************************************/
        /* List of functions that maps outgoing objects to an external event.  */
        /* Note that the mapping is specified only in external structure.      */
        /***********************************************************************/
        //public List<Func<TLoad, Event>> OnOutput { get; private set; } = new List<Func<TLoad, Event>>();
        #endregion

        public MultiServers(Statics config, int seed, string tag = null) : base(config, seed, tag)
        {
            int nTypes   = Config.HourlyArrivalRates.Length;
            int nServers = Config.HourlyServiceRates.GetLength(0);

            // 根据每一种类型客户的到达率创建随即发生器
            Generators = Enumerable.Range(0, nTypes)
                         .Select(type => new Generator <Customer>(
                                     new Generator <Customer> .Statics {
                Create           = rs => new Customer(type),
                InterArrivalTime = rs => TimeSpan.FromHours(
                    Exponential.Sample(rs, Config.HourlyArrivalRates[type])),
                SkipFirst = true
            }, DefaultRS.Next())).ToArray();
            // 创建服务器,并根据不同类型的客户设置服务事件
            Servers = Enumerable.Range(0, nServers)
                      .Select(i => new Server <Customer>(
                                  new Server <Customer> .Statics {
                Capacity    = Config.Capacities[i],
                ServiceTime = (cstm, rs) => TimeSpan.FromHours(
                    Exponential.Sample(rs, Config.HourlyServiceRates[i, cstm.Config.Type])),
            }, DefaultRS.Next())).ToArray();
            // 将发生器输出事件连接至内部事件
            foreach (var g in Generators)
            {
                g.OnArrive.Add(c => new ArriveEvent {
                    This = this, Customer = c
                });
            }
            // 将服务器输出事件连接至内部事件
            foreach (var s in Servers)
            {
                s.OnDepart.Add(c => new DepartEvent {
                    This = this, Customer = c
                });
            }
            // 初始化事件
            InitEvents.AddRange(Generators.Select(g => g.Start()));
        }
Esempio n. 7
0
 public Server(Statics config, int seed, string tag = null) : base(config, seed, tag)
 {
     InitEvents.Add(new TestEvent {
         This = this
     });
 }
Esempio n. 8
0
        /***************************************************************/
        /* Methods returning an InternalEvent as O2DESNet.Event,       */
        /* with parameters for the objects to be passed in.            */
        /* Note that the InternalEvent shall always carry This = this. */
        /***************************************************************/
        //public Event Input(TLoad load) { return new InternalEvent { This = this, Load = load }; }
        #endregion

        #region Output Events - Reference to Getters
        /***********************************************************************/
        /* List of functions that maps outgoing objects to an external event.  */
        /* Note that the mapping is specified only in external structure.      */
        /***********************************************************************/
        //public List<Func<TLoad, Event>> OnOutput { get; private set; } = new List<Func<TLoad, Event>>();
        #endregion

        public MMnQueue(Statics config, int seed, string tag = null) : base(config, seed, tag)
        {
            InitEvents.Add(new ArriveEvent {
                This = this
            });
        }