protected override void Context()
        {
            base.Context();
            _eventGroupBuilder1        = new EventGroupBuilder().WithName("EG1");
            _eventGroupBuilder2        = new EventGroupBuilder().WithName("EG2");
            _eventBuildingBlockCreator = new EventGroupBuildingBlock {
                _eventGroupBuilder1, _eventGroupBuilder2
            };

            _startTime1        = DomainHelperForSpecs.ConstantParameterWithValue().WithName(Constants.Parameters.START_TIME);
            _startTime2        = DomainHelperForSpecs.ConstantParameterWithValue().WithName(Constants.Parameters.START_TIME);
            _dose              = DomainHelperForSpecs.ConstantParameterWithValue().WithName(CoreConstants.Parameters.DOSE);
            _dosePerBodyWeight = DomainHelperForSpecs.ConstantParameterWithValue().WithName(CoreConstants.Parameters.DOSE_PER_BODY_WEIGHT);

            _p1 = DomainHelperForSpecs.ConstantParameterWithValue().WithName("P1");
            _p2 = DomainHelperForSpecs.ConstantParameterWithValue().WithName("P2");

            _eventBuilder1 = new EventBuilder().WithName("E1");
            _eventBuilder2 = new EventBuilder().WithName("E2");

            _eventGroupBuilder1.Add(_eventBuilder1);
            _eventGroupBuilder2.Add(_eventBuilder2);

            _eventBuilder1.Add(_startTime1);
            _eventBuilder1.Add(_p1);
            _eventBuilder2.Add(_startTime2);
            _eventBuilder1.Add(_dosePerBodyWeight);
            _eventBuilder2.Add(_dose);
            _eventBuilder2.Add(_p2);
        }
        private void addApplication(IEventGroupBuilder protocolGroupBuilder, ISchemaItem schemaItem, string applicationName, CompoundProperties compoundProperties, Protocol protocol)
        {
            IContainer applicationParentContainer;
            string     formulationType;

            IEnumerable <IParameter> formulationParameters;

            if (schemaItem.NeedsFormulation)
            {
                var formulation = _formulationFromMappingRetriever.FormulationUsedBy(_simulation, compoundProperties.ProtocolProperties.MappingWith(schemaItem.FormulationKey));
                if (formulation == null)
                {
                    throw new NoFormulationFoundForRouteException(protocol, schemaItem.ApplicationType);
                }

                //check if used formulation container is already created and create if needed
                if (protocolGroupBuilder.ContainsName(formulation.Name))
                {
                    applicationParentContainer = protocolGroupBuilder.GetSingleChildByName <IEventGroupBuilder>(formulation.Name);
                }
                else
                {
                    applicationParentContainer = createFormulationAsEventGroupBuilderFrom(formulation);
                }

                protocolGroupBuilder.Add(applicationParentContainer);
                formulationType = formulation.FormulationType;

                formulationParameters = applicationParentContainer.GetChildren <IParameter>();
            }
            else
            {
                applicationParentContainer = protocolGroupBuilder;
                formulationType            = CoreConstants.Formulation.EmptyFormulation;
                formulationParameters      = new List <IParameter>();
            }

            applicationParentContainer.Add(
                _applicationFactory.CreateFor(schemaItem, formulationType, applicationName, compoundProperties.Compound.Name, formulationParameters, _eventGroupBuildingBlock.FormulaCache));
        }
Esempio n. 3
0
        protected override void Context()
        {
            base.Context();
            _eventGroupBuildingBlock = new EventGroupBuildingBlock();
            var eventGroup = new EventGroupBuilder().WithName("EG");

            _eventGroupBuildingBlock.Add(eventGroup);
            var ehcStartEvent = new EventBuilder().WithName(Converter321To331.EHCStartEvent);

            eventGroup.Add(ehcStartEvent);
            var eabOldStart = new EventAssignmentBuilder().WithName("EAB1").WithFormula(new ExplicitFormula("ln(2) / EHC_Halftime * M * EHC_EjectionFraction"));

            eabOldStart.UseAsValue = false;
            eabOldStart.ObjectPath = new ObjectPath(new[] { "Organism", "Gallbladder", "Gallbladder emptying rate" });
            ehcStartEvent.AddAssignment(eabOldStart);
            var assignmentBuilder = new EventAssignmentBuilder().WithName("EAB2").WithFormula(new ExplicitFormula("DontChange"));

            assignmentBuilder.ObjectPath = new ObjectPath(new[] { "PATH" });
            ehcStartEvent.AddAssignment(assignmentBuilder);
            var ehcStopEvent = new EventBuilder().WithName(Converter321To331.EHCStopEvent);
            var eabOldStop   = new EventAssignmentBuilder().WithName("EAB1").WithFormula(new ConstantFormula(0));

            eabOldStop.UseAsValue = false;
            eabOldStop.ObjectPath = new ObjectPath(new[] { "Organism", "Gallbladder", "Gallbladder emptying rate" });
            ehcStopEvent.AddAssignment(eabOldStop);
            assignmentBuilder            = new EventAssignmentBuilder().WithName("EAB2").WithFormula(new ExplicitFormula("DontChange"));
            assignmentBuilder.ObjectPath = new ObjectPath(new[] { "PATH" });
            ehcStopEvent.AddAssignment(assignmentBuilder);
            eventGroup.Add(ehcStopEvent);

            var protocolSchemaItem = new Container().WithName("ProtocolSchemaItem").WithParentContainer(eventGroup);

            _drugMassParameter = new Parameter().WithName("DrugMass").WithParentContainer(protocolSchemaItem).WithValue(1);

            applications = new EventGroupBuilder().WithName("Applications");
            applications.Add(new Parameter().WithName("TotalDrugMass"));
            _eventGroupBuildingBlock.Add(applications);
        }
 protected override void AddTo(TChild child, IEventGroupBuilder parent, IMoBiContext context)
 {
     parent.Add(child);
 }