Ejemplo n.º 1
0
        public void TestEventTimeHistorian()
        {
            IRandomChannel     irc         = m_rs.GetRandomChannel();
            IExecutive         exec        = ExecFactory.Instance.CreateExecutive();
            EventTimeHistorian myHistorian = new EventTimeHistorian(exec, 256);
            DateTime           when        = m_startDate;

            // We set up NUM_SAMPLES events with random (0->50) minute intervals.
            TimeSpan totalTimeSpan = TimeSpan.Zero;

            for (int i = 0; i < NUM_SAMPLES; i++)
            {
                exec.RequestEvent(DoEvent, when, 0.0, myHistorian, ExecEventType.Synchronous);
                double   d     = irc.NextDouble();
                TimeSpan delta = TimeSpan.FromMinutes(d * 50.0);
                totalTimeSpan += delta;
                if (i < 30)
                {
                    Console.WriteLine("Delta #" + i + ", " + delta.ToString());
                }
                when += delta;
            }

            m_actualAverage = TimeSpan.FromTicks(totalTimeSpan.Ticks / NUM_SAMPLES);
            Console.WriteLine("Average timeSpan was " + m_actualAverage + ".");

            exec.Start();

            Console.WriteLine("After {0} events, the average interval was {1}.", myHistorian.PastEventsReceived, myHistorian.GetAverageIntraEventDuration());
        }
Ejemplo n.º 2
0
 public StateAwareDemoObject(IModel model, string name, int howManyCycles)
     : base(model, name, System.Guid.NewGuid())
 {
     m_howManyCycles = howManyCycles;
     m_state         = new EnumStateMachine <SADO_States>(model.Executive, SADO_States.Idle, true);
     m_rc            = model.RandomServer.GetRandomChannel();
     model.Starting += WaitAndRun;
 }
Ejemplo n.º 3
0
 public Activity(string name, int numIterations, IExecutive executive, RandomServer rs, ulong seed)
 {
     m_name                      = name;
     m_numIterations             = numIterations;
     m_rc                        = rs.GetRandomChannel(seed, m_defaultBufferSize);
     executive.ExecutiveStarted += delegate(IExecutive exec) {
         exec.RequestEvent(Run, exec.Now, 0.0, null, ExecEventType.Detachable);
     };
 }
Ejemplo n.º 4
0
        public static void Run()
        {
            DateTime now = DateTime.Parse("Fri, 15 Jul 2016 00:00:00");

            // More about this one later.
            IRandomChannel rc = GlobalRandomServer.Instance.GetRandomChannel();

            IExecutive exec = ExecFactory.Instance.CreateExecutive();

            for (int i = 0; i < 100; i++)
            {
                State state = new State {
                    Who = string.Format("Token_{0}", i), Duration = TimeSpan.FromMinutes(1000.0 * rc.NextDouble())
                };
                DateTime startWhen = now + TimeSpan.FromMinutes(100.0 * rc.NextDouble());
                exec.RequestEvent(StartProcessToken, startWhen, state);
            }

            exec.Start();
        }
Ejemplo n.º 5
0
        public static void Run()
        {
            ulong[][] testValues = new ulong[][] {
                new ulong[] { 12345, 100 },
                new ulong[] { 54321, 100 },
                new ulong[] { 12345, 200 },
                new ulong[] { 51903, 200 }
            };

            foreach (ulong[] ula in testValues)
            {
                ulong          seed       = ula[0];
                int            bufferSize = (int)ula[1];
                IRandomChannel irc        = GlobalRandomServer.Instance.GetRandomChannel(seed, bufferSize);

                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine("RandomChannel[seed={0}][{1}] = {2}", seed, i, irc.NextDouble());
                }
            }
        }
Ejemplo n.º 6
0
 public SimpleStochasticTwoChoiceBranchBlock(IModel model, string name, Guid guid, double percentageOut0) : base(model, name, guid)
 {
     m_percentageOut0 = percentageOut0;
     m_randomChannel  = model.RandomServer.GetRandomChannel();
 }