Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            var smpl = new SmplModel();

            var MuDev = smpl.CreateMultiDevice("eq", 4);
            var queue = smpl.CreateQueue("qu");

            smpl.EventCaused += smpl_EventCaused;

            smpl.Schedule((int)ModelEvents.PZ, smpl.IRandom(5, 10));
            smpl.Schedule((int)ModelEvents.ZM, MaxTime); //10000);

            //while (smpl.Cause()) ;
            Model = smpl;
            Viewer = new SmplModelViewer(smpl);

            DataContext = this;

            /*// Initialize model
            var smpl = new SmplModel();

            var vs = smpl.CreateDevice("re");
            var qu = smpl.CreateQueue("er");

            smpl.Schedule((int)ModelEvents.PZ, smpl.IRandom(1, 2));
            smpl.Schedule((int)ModelEvents.ZM, 10000);

            smpl.EventCaused += smpl_EventCaused;

            // Launch model
            while (smpl.Cause()) ;

            // Report
            smpl.Report();*/
        }
Example #2
0
        static void Main(string[] args)
        {
            /*var gen = new SMPLSharp.Utils.SmplRandomGenerator();
            for (var i = 0; i < 50; i++)
            {
                Console.WriteLine(gen.IRandom(12, 24));
                Console.WriteLine(gen.IRandom(12, 20));
            }
            Console.Read();*/

            // Initialize model
            var smpl = new SmplModel();

            var MuDev = smpl.CreateMultiDevice("eq", 4);
            var queue = smpl.CreateQueue("qu");

            smpl.EventCaused += smpl_EventCaused;

            smpl.Schedule((int)ModelEvents.PZ, smpl.IRandom(5, 10));
            smpl.Schedule((int)ModelEvents.ZM, 100); //10000);

            //while (smpl.Cause()) ;
            var viewer = new SmplModelViewer(smpl);
            viewer.Play(1000, false);

            /*
            // Launch model
            int e = 0;
            object j;
            while (e != (int)ModelEvents.ZM)
            {
                smpl.Cause(out e, out j);

                // Hande model events
                switch ((ModelEvents)e)
                {
                    case ModelEvents.PZ:
                        smpl.Schedule((int)ModelEvents.PZ, smpl.IRandom(2, 8));
                        if (!MuDev.IsBusy)
                        {
                            int id = MuDev.Reserve();
                            smpl.Schedule((int)ModelEvents.ZO, smpl.IRandom(12, 30), id);
                        }
                        else queue.Enqueue();
                        break;

                    case ModelEvents.ZO:
                        MuDev.Release( (int)j);
                        if (!queue.IsEmpty)
                        {
                            int id = MuDev.Reserve();
                            smpl.Schedule((int)ModelEvents.ZO, smpl.IRandom(12, 30), id);
                        }
                        break;
                }
            }

             */
            // Report
            Console.Write(smpl.Report());
        }