/// <summary> /// Creates a MoBi Parameter from a given SBML Parameter. /// </summary> public IFormulaUsable CreateParameter(Parameter sbmlParameter) { var value = 0.0; if (sbmlParameter.isSetValue()) { value = sbmlParameter.getValue(); } IFormula formula = ObjectBaseFactory.Create <ConstantFormula>().WithValue(value); var parameter = ObjectBaseFactory.Create <IParameter>() .WithName(sbmlParameter.getId()) .WithFormula(formula); if (!sbmlParameter.isSetUnits()) { return(parameter); } if (_sbmlInformation.MobiDimension.ContainsKey(sbmlParameter.getUnits())) { parameter.Dimension = _sbmlInformation.MobiDimension[sbmlParameter.getUnits()]; } return(parameter); }
protected override void Because() { var parameter = new Parameter(3, 1); parameter.setName("Param"); parameter.setId("p1"); parameter.setValue(5); _res = sut.CreateParameter(parameter); }
/// <summary> /// Creates a MoBi Parameter from a given SBML Parameter. /// </summary> public IFormulaUsable CreateParameter(Parameter sbmlParameter) { var value = 0.0; if (sbmlParameter.isSetValue()) { value = sbmlParameter.getValue(); } if (!sbmlParameter.isSetUnits()) { return(ObjectBaseFactory.Create <IParameter>() .WithName(sbmlParameter.getId()) .WithFormula(ObjectBaseFactory.Create <ConstantFormula>().WithValue(value))); } var sbmlUnit = sbmlParameter.getUnits(); var baseValue = _unitDefinitionImporter.ToMobiBaseUnit(sbmlUnit, value); return(ObjectBaseFactory.Create <IParameter>() .WithName(sbmlParameter.getId()) .WithFormula(_formulaFactory.ConstantFormula(baseValue.value, baseValue.dimension)) .WithDimension(baseValue.dimension)); }