Exemple #1
0
        public static void smpl_EventCaused(object sender, EventCausedEventArgs e)
        {
            var smpl = (SmplModel)sender;
            var e_id = (ModelEvents)e.Event.EventID;
            var MuDev = smpl.MultiDevice("eq");
            var queue = smpl.Queue("qu");
            Console.WriteLine("Event: " + e_id + " - Time: " + smpl.Time);
            switch (e_id)
            {
                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)e.Event.Param);
                    if (!queue.IsEmpty)
                    {
                        int id = MuDev.Reserve();
                        queue.Head();
                        smpl.Schedule((int)ModelEvents.ZO, smpl.IRandom(12, 30), id);
                    }
                    break;

                case ModelEvents.ZM:
                    e.StopModel = true;
                    break;
            }
        }
Exemple #2
0
 /// <summary>
 /// Событие возникновения события модели. Возникает при вызове Cause
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 protected virtual bool OnEventCaused(EventCausedEventArgs e)
 {
     if (EventCaused != null)
         {
             EventCaused(this, e);
             return e.StopModel;
         }
         else return false;
 }