Esempio n. 1
0
        /// <summary>
        /// Method called when the add-in is run.
        /// </summary>
        public void Execute(IDesignContext context)
        {
            // This example code places some new objects from the Standard Library into the active model of the project.
            if (context.ActiveModel != null)
            {
                // Example of how to place some new fixed objects into the active model.
                // This example code places three new fixed objects: a Source, a Server, and a Sink.
                IIntelligentObjects intelligentObjects = context.ActiveModel.Facility.IntelligentObjects;
                IFixedObject        sourceObject       = intelligentObjects.CreateObject("Source", new FacilityLocation(-10, 0, -10)) as IFixedObject;
                IFixedObject        serverObject       = intelligentObjects.CreateObject("Server", new FacilityLocation(0, 0, 0)) as IFixedObject;
                IFixedObject        sinkObject         = intelligentObjects.CreateObject("Sink", new FacilityLocation(10, 0, 10)) as IFixedObject;

                // Example of how to place some new link objects into the active model (to add network paths between nodes).
                // This example code places two new link objects: a Path connecting the Source 'output' node to the Server 'input' node,
                // and a Path connecting the Server 'output' node to the Sink 'input' node.
                INodeObject sourceOutputNode = sourceObject.Nodes[0];
                INodeObject serverInputNode  = serverObject.Nodes[0];
                INodeObject serverOutputNode = serverObject.Nodes[1];
                INodeObject sinkInputNode    = sinkObject.Nodes[0];
                ILinkObject pathObject1      = intelligentObjects.CreateLink("Path", sourceOutputNode, serverInputNode, null) as ILinkObject;
                ILinkObject pathObject2      = intelligentObjects.CreateLink("Path", serverOutputNode, sinkInputNode, null) as ILinkObject;

                // Example of how to edit the property of an object.
                // This example code edits the 'ProcessingTime' property of the added Server object.
                serverObject.Properties["ProcessingTime"].Value = "100";
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Method called when the add-in is run.
        /// </summary>
        public void Execute(IDesignContext context)
        {
            var warnings = new List <String>();

            // This example code places some new objects from the Standard Library into the active model of the project.
            if (context.ActiveModel != null)
            {
                IIntelligentObjects intelligentObjects = context.ActiveModel.Facility.IntelligentObjects;
                IFixedObject        bed          = intelligentObjects.CreateObject("Bed", new FacilityLocation(0, 0, 0)) as IFixedObject;
                IFixedObject        sourceObject = intelligentObjects.CreateObject("Source", new FacilityLocation(-10, 0, -10)) as IFixedObject;
                IFixedObject        serverObject = intelligentObjects.CreateObject("Server", new FacilityLocation(0, 0, 0)) as IFixedObject;
                IFixedObject        sinkObject   = intelligentObjects.CreateObject("Sink", new FacilityLocation(10, 0, 10)) as IFixedObject;
                IEntityInstanceReferencePropertyDefinition modelentitiy = intelligentObjects.CreateObject("Patient", new FacilityLocation(-20, 0, -10))
                                                                          as IEntityInstanceReferencePropertyDefinition;
                ITransporterInstanceReferencePropertyDefinition regnurse = intelligentObjects.CreateObject("Worker", new FacilityLocation(-30, 0, -30))
                                                                           as ITransporterInstanceReferencePropertyDefinition;
                //var RNurseName = context.ActiveModel.Facility.IntelligentObjects["Worker1"];
                //RNurseName.Properties["Name"].Value = "RegularNurse";
                //var modelentitiy = context.ActiveModel.Facility.IntelligentObjects["Patient"];
                // Example of how to place some new link objects into the active model (to add network paths between nodes).
                // This example code places two new link objects: a Path connecting the Source 'output' node to the Server 'input' node,
                // and a Path connecting the Server 'output' node to the Sink 'input' node.
                INodeObject sourceOutputNode = sourceObject.Nodes[0];
                INodeObject serverInputNode  = serverObject.Nodes[0];
                INodeObject serverOutputNode = serverObject.Nodes[1];
                INodeObject sinkInputNode    = sinkObject.Nodes[0];
                INodeObject bedinputnode     = bed.Nodes[0];
                INodeObject bedoutputnode    = bed.Nodes[1];
                ILinkObject pathObject1      = intelligentObjects.CreateLink("Path", sourceOutputNode, serverInputNode, null) as ILinkObject;
                ILinkObject pathObject2      = intelligentObjects.CreateLink("Path", serverOutputNode, bedinputnode, null) as ILinkObject;
                ILinkObject pathObject3      = intelligentObjects.CreateLink("Path", bedoutputnode, sinkInputNode, null) as ILinkObject;

                // Example of how to edit the property of an object.
                // This example code edits the 'ProcessingTime' property of the added Server object.
                serverObject.Properties["ProcessingTime"].Value = "0";
                sourceObject.Properties["EntityType"].Value     = "Patient1";
                var defaultEntity = context.ActiveModel.Facility.IntelligentObjects["Patient1"];

                defaultEntity.Properties["RegNurseCheckTime"].Value       = "HospitalData.RNRounding";
                defaultEntity.Properties["TherapistCheckTime"].Value      = "HospitalData.TherapistRounding";
                defaultEntity.Properties["AssistantNurseCheckTime"].Value = "HospitalData.ANRounding";
                defaultEntity.Properties["BedStayTime"].Value             = "HospitalData.BedStayTime";
                defaultEntity.Properties["TherapistVisitTime"].Value      = "HospitalData.TherapistVisitTime";
                defaultEntity.Properties["RegNurseVisitTime"].Value       = "HospitalData.RegNurseVisitTime";
                defaultEntity.Properties["AssistantNurseNextVisit"].Value = "HospitalData.AssistantNurseNextVisit";
                ITable entitydatatable = context.ActiveModel.Tables.Create("HospitalData");
                var    i            = entitydatatable.Columns.AddEntityReferenceColumn("PatientTypes");
                var    mix          = entitydatatable.Columns.AddRealColumn("Mix", 0.0);
                var    admisiontime = entitydatatable.Columns.AddExpressionColumn("AdmissionTime", "0.0");
                (admisiontime as IUnitizedTableColumn).UnitType = SimioUnitType.Time;
                var rnrounding        = entitydatatable.Columns.AddExpressionColumn("RNRounding", "0.0");
                var nurserounding     = entitydatatable.Columns.AddExpressionColumn("ANRounding", "0.0");
                var therapistrounding = entitydatatable.Columns.AddExpressionColumn("TherapistRounding", "0.0");
                var bedtime           = entitydatatable.Columns.AddExpressionColumn("BedStayTime", "0.0");
                var RVisitTime        = entitydatatable.Columns.AddExpressionColumn("RegNurseVisitTime", "0.0");
                var TVisitTime        = entitydatatable.Columns.AddExpressionColumn("TherapistVisitTime", "0.0");
                var AVisitTime        = entitydatatable.Columns.AddExpressionColumn("AssistantNurseNextVisit", "0.0");
                //Add Resource Type List

                var resourceType = context.ActiveModel.NamedLists["ResourceType"];
                if (resourceType != null)
                {
                    warnings.Add(string.Format(FormatListMessage(resourceType.Name)));
                }
                else
                {
                    resourceType = context.ActiveModel.NamedLists.AddObjectList("ResourceType");
                    var firstRow = resourceType.Rows.Create();
                    firstRow.Properties[0].Value = "Source";
                    var secondRow = resourceType.Rows.Create();
                    secondRow.Properties[0].Value = "Server";
                    var thirdRow = resourceType.Rows.Create();
                    thirdRow.Properties[0].Value = "Patient";
                    var fourthRow = resourceType.Rows.Create();
                    fourthRow.Properties[0].Value = "RegNurse";
                    var fifthRow = resourceType.Rows.Create();
                    fifthRow.Properties[0].Value = "Therapist";
                    var sixthrow = resourceType.Rows.Create();
                    sixthrow.Properties[0].Value = "Ass.Nurse";
                    var seventhRow = resourceType.Rows.Create();
                    seventhRow.Properties[0].Value = "Sink";
                    var eigthRow = resourceType.Rows.Create();
                    eigthRow.Properties[0].Value = "Bed";
                    var ninthRow = resourceType.Rows.Create();
                    ninthRow.Properties[0].Value = "Worker";
                }
                //Adding Resource Table
                ITable resourceTable = context.ActiveModel.Tables["Resources"];
                if (resourceTable != null)
                {
                    warnings.Add(string.Format(FormatListMessage(resourceTable.Name)));
                }
                else
                {
                    resourceTable = context.ActiveModel.Tables.Create("Resources");
                    var j = resourceTable.Columns.AddObjectReferenceColumn("ResourceName");
                    j.FilterToResources = false;
                    j.IsKey             = true;
                    var resourceTypes = resourceTable.Columns.AddListReferenceColumn("ResourceType");
                    resourceTypes.ListName      = ("ResourceType");
                    resourceTypes.DefaultString = ("Bed");
                }
                ITable link = context.ActiveModel.Tables["LinkBetweenResources"];
                if (link != null)
                {
                    warnings.Add(string.Format(FormatLinkMessage(link.Name)));
                }
                else
                {
                }
                //var modelentity1 = context.ActiveModel.Facility.IntelligentObjects["Patient"];

                //modelentity1.Properties["BedStayTime"].Value = "5";
            }

            #endregion
        }
Esempio n. 3
0
        public void analizar()
        {
            if (listaAeropuertos.Count > 0 && listaVuelos.Count > 0)
            {
                // ISimioProject _simioproject;
                string _projectPathAndFile = getPathActual();
                //MessageBox.Show(_projectPathAndFile);
                string[] warnings;
                currentProject = SimioProjectFactory.LoadProject("Model.spfx", out warnings);

                //ISimioProject project = SimioProjectFactory.LoadProject("Test.spfx", out warnings);
                IModel model = currentProject.Models["Model"];

                IExperiment experiment = model.Experiments.Create("Experiment");

                // Setup the experiment (optional)
                // Specify run times.
                //string experiment_ScenarioEnded = "2";
                double    runtime = 2;
                IRunSetup setup   = experiment.RunSetup;
                setup.StartingTime         = new DateTime(2010, 10, 01);
                setup.WarmupPeriod         = TimeSpan.FromHours(0);
                setup.EndingTime           = experiment.RunSetup.StartingTime + TimeSpan.FromDays(runtime);
                experiment.ConfidenceLevel = ExperimentConfidenceLevelType.Point90;
                experiment.LowerPercentile = 5;
                experiment.UpperPercentile = 95;
                //model.Facility.IntelligentObjects["aeropuerto"].Properties["InitialCapacity"].Value = "69";
                int          contador = 0;
                Random       rnd      = new Random();
                IFixedObject source   = model.Facility.IntelligentObjects["fuente"] as IFixedObject;
                source.Properties["InterarrivalTime"].Value = "Random.Poisson(60/300)";
                foreach (var air in listaAeropuertos)
                {
                    TiempoServicioGeneral = rnd.Next(1, 3);

                    IFixedObject aeropuerto = model.Facility.IntelligentObjects.CreateObject("Server", new FacilityLocation(air.x, air.y, air.z)) as IFixedObject;
                    aeropuerto.ObjectName = air.nombre;
                    switch (TiempoServicioGeneral)
                    {
                    case 1:
                        aeropuerto.Properties["ProcessingTime"].Value = "Random.Triangular(35,45,60)";
                        break;

                    case 2:
                        aeropuerto.Properties["ProcessingTime"].Value = "Random.Triangular(30,40,50)";
                        break;

                    case 3:
                        aeropuerto.Properties["ProcessingTime"].Value = "Random.Uniform(30,50)";
                        break;
                    }
                    aeropuerto.Properties["FailureType"].Value          = air.tipoFalla;
                    aeropuerto.Properties["OffShiftRule"].Value         = "FinishWorkAlreadyStarted";
                    aeropuerto.Properties["CountBetweenFailures"].Value = air.cantEntreFallas.ToString();
                    aeropuerto.Properties["TimeToRepair"].Value         = air.tiempoReparacion.ToString();

                    IFixedObject mezclador = model.Facility.IntelligentObjects.CreateObject("Combiner", new FacilityLocation(air.x, air.y + 30, air.z)) as IFixedObject;
                    String       n         = air.nombre + "C";
                    mezclador.ObjectName = n;

                    IFixedObject sourceAviones = model.Facility.IntelligentObjects.CreateObject("Source", new FacilityLocation(air.x, air.y + 30, air.z)) as IFixedObject;
                    n = air.nombre + "S";
                    sourceAviones.ObjectName = n;
                    sourceAviones.Properties["InitialCapacity"].Value = "100";

                    IIntelligentObject pista = model.Facility.IntelligentObjects.CreateObject("Server", new FacilityLocation(air.x, air.y + 30, air.z));
                    n = air.nombre + "P";
                    pista.ObjectName = n;

                    pista.Properties["InitialCapacity"].Value = air.capacidadPista.ToString();
                    ILinkObject path1 = model.Facility.IntelligentObjects.CreateLink("TimePath", source.Nodes[0], aeropuerto.Nodes[0], null) as ILinkObject;
                    path1.Properties["TravelTime"].Value = air.tiempoAbordajeDespegue.ToString();
                    ILinkObject path  = model.Facility.IntelligentObjects.CreateLink("Path", sourceAviones.Nodes[0], mezclador.Nodes[0], null) as ILinkObject;
                    ILinkObject path3 = model.Facility.IntelligentObjects.CreateLink("Path", aeropuerto.Nodes[0], mezclador.Nodes[1], null) as ILinkObject;



                    //nuevo.Properties[""].Value = air.tiempoPersonas;
                    //nuevo.Properties[""].Value = air.tiempoAbordajeDespegue;
                    //nuevo.Properties[""].Value = air.id;



                    //if (contador == 0)
                    //{

                    //    model.Facility.IntelligentObjects["DefaultEntity"].Properties["Name"].Value = air.nombre;

                    //}
                    //else
                    //{
                    //    model.Facility.IntelligentObjects["Server"+(contador+1)].Properties["Name"].Value = air.nombre;
                    //}

                    //model.Facility.IntelligentObjects[2].Properties["name"].Value = air.nombre;
                    contador = contador + 1;
                }

                //model.Facility.IntelligentObjects.CreateObject("Server", new FacilityLocation(0, 0, 0));


                /*
                 * // Add event handler for events from experiment
                 * experiment.ScenarioEnded += new EventHandler<ScenarioEndedEventArgs>(experiment_ScenarioEnded);
                 * experiment.RunCompleted += new EventHandler<RunCompletedEventArgs>(experiment_RunCompleted);
                 * experiment.RunProgressChanged += new EventHandler<RunProgressChangedEventArgs>(experiment_RunProgressChanged);
                 * experiment.ReplicationEnded += new EventHandler<ReplicationEndedEventArgs>(experiment_ReplicationEnded);
                 */
                // Run Experiment, will call event handler methods when finished etc.
                SimioProjectFactory.SaveProject(currentProject, "Nuevo.spfx", out warnings);
            }
            else
            {
                MessageBox.Show("Debe cargar ambos archivos.");
            }
        }