示例#1
0
        public void TestServerBasics()
        {
            m_noAdmitCount = 0;
            m_admitCount   = 0;

            m_model = new Model();
            ((Model)m_model).RandomServer = new Randoms.RandomServer(54321, 100);

            ItemSource patientFactory  = CreatePatientGenerator("Patient_", 500, 5.0, 3.0);
            IServer    receiving       = CreateProcessStep("Receiving", 3.0, 5.0, 8.0);
            ISplitter  evaluation      = CreateBranch("Evaluation", 0.20);
            IServer    admit           = CreateProcessStep("Admit", 3.0, 5.0, 9.0);
            IServer    inPatientTreat  = CreateProcessStep("InPatientTreat", 300.0, 2160.0, 7200.0);
            IServer    discharge       = CreateProcessStep("Discharge", 3.0, 5.0, 8.0);
            IServer    outPatientTreat = CreateProcessStep("OutPatientTreat", 300.0, 2160.0, 7200.0);
            IJoiner    toStreet        = new PushJoiner(m_model, "Push Joiner", Guid.NewGuid(), 2);
            ItemSink   street          = new ItemSink(m_model, "Street", Guid.NewGuid());


            ConnectorFactory.Connect(patientFactory.Output, receiving.Input);
            ConnectorFactory.Connect(receiving.Output, evaluation.Input);
            ConnectorFactory.Connect(evaluation.Outputs[0], admit.Input);
            ConnectorFactory.Connect(admit.Output, inPatientTreat.Input);
            ConnectorFactory.Connect(inPatientTreat.Output, discharge.Input);
            ConnectorFactory.Connect(discharge.Output, toStreet.Inputs[0]);
            ConnectorFactory.Connect(evaluation.Outputs[1], outPatientTreat.Input);
            ConnectorFactory.Connect(outPatientTreat.Output, toStreet.Inputs[1]);
            ConnectorFactory.Connect(toStreet.Output, street.Input);


            evaluation.Outputs[0].PortDataPresented += new PortDataEvent(Admit_Patient);           // Count admitted.
            evaluation.Outputs[1].PortDataPresented += new PortDataEvent(NoAdmit_Patient);         // Count not-admitted.

            inPatientTreat.ServiceBeginning += new ServiceEvent(Server_ServiceBeginning);
            inPatientTreat.ServiceCompleted += new ServiceEvent(Server_ServiceCompleted);

            outPatientTreat.ServiceBeginning += new ServiceEvent(Server_ServiceBeginning);
            outPatientTreat.ServiceCompleted += new ServiceEvent(Server_ServiceCompleted);

            m_model.Start();

            Console.WriteLine("NoAdmit = " + m_noAdmitCount + ", and admitted = " + m_admitCount);
        }
示例#2
0
        public void TestJoiner()
        {
            Model model = new Model();

            model.RandomServer = new Randoms.RandomServer(12345, 100);

            PushJoiner pj = new PushJoiner(model, "PushJoiner", Guid.NewGuid(), 6);

            foreach (IPort port in pj.Ports)
            {
                port.PortDataPresented += new PortDataEvent(OnPortDataPresented);
            }

            foreach (IPort port in pj.Ports)
            {
                if (port is IInputPort)
                {
                    ((IInputPort)port).Put(new object());
                }
            }
            Assert.IsTrue(m_lastResult == m_nPorts * 2, "Not all output ports reported arrival of the pushed object.");
        }