Esempio n. 1
0
 protected internal BinaryFormula(NodeType nodeType, IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
     : base(nodeType, type, parent)
 {
     Left = left;
     Method = method;
     Right = right;
 }
Esempio n. 2
0
 protected internal ConditionalFormula(IFormula test, IFormula ifTrue, IFormula ifFalse, ITypeDeclaration type, IFormula parent)
     : base(NodeType.Conditional, type, parent)
 {
     Test = test;
     IfTrue = ifTrue;
     IfFalse = ifFalse;
 }
        public void TestSerialization()
        {
            ApplicationBuilder x1 = CreateObject <ApplicationBuilder>().WithName("App.Builder");

            IFormula f1 = CreateObject <ConstantFormula>().WithValue(2.3);
            IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(3.4);

            IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1);
            IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2);

            x1.Add(p1);
            x1.Add(p2);

            EventBuilder eb1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength).WithFormula(f1);
            EventBuilder eb2 = CreateObject <EventBuilder>().WithName("Eva.Builder").WithDimension(DimensionLength).WithFormula(f2);

            eb2.OneTime = true;

            x1.Add(eb1);
            x1.Add(eb2);

            var applicationMoleculeBuilder = CreateObject <ApplicationMoleculeBuilder>().WithName("AppMolecule");

            applicationMoleculeBuilder.Formula = f2;
            applicationMoleculeBuilder.RelativeContainerPath = new ObjectPath(new[] { "A", "B" });
            x1.AddMolecule(applicationMoleculeBuilder);

            x1.AddTransport(CreateObject <TransportBuilder>().WithName("PassiveTranport").WithFormula(f1));


            ApplicationBuilder x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualApplicationBuilder(x1, x2);
        }
        public void TestSerialization()
        {
            EventBuilder x1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength);

            x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);
            x1.OneTime = true;

            IFormula           f1  = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty");
            IFormulaUsablePath fup = new FormulaUsablePath(new string[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength);

            f1.AddObjectPath(fup);
            IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);

            IParameter p1 = WithExtensions.WithValue <Parameter>(CreateObject <Parameter>().WithName("Patricia").WithFormula(f1), 3.1);
            IParameter p2 = WithExtensions.WithValue <Parameter>(CreateObject <Parameter>().WithName("Pascal").WithFormula(f1), 3.2);

            x1.AddParameter(p1);
            x1.AddParameter(p2);

            IEventAssignmentBuilder eab1 = CreateObject <EventAssignmentBuilder>().WithDimension(DimensionLength).WithFormula(f1).WithName("eab1");
            IEventAssignmentBuilder eab2 = CreateObject <EventAssignmentBuilder>().WithFormula(f2).WithName("eab2");

            x1.AddAssignment(eab1);
            x1.AddAssignment(eab2);

            var x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualEventBuilder(x1, x2);
        }
Esempio n. 5
0
 protected override void Context()
 {
     base.Context();
     _explicitFormula = new ExplicitFormula();
     //another path
     _explicitFormula.AddObjectPath(new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, ObjectPath.PARENT_CONTAINER, Constants.Parameters.VOLUME, Constants.Parameters.VOLUME).WithAlias(Constants.VOLUME_ALIAS));
 }
Esempio n. 6
0
        protected override void Context()
        {
            _containerTask        = A.Fake <IContainerTask>();
            _objectBaseFactory    = A.Fake <IObjectBaseFactory>();
            _projectRetriever     = A.Fake <IMoBiProjectRetriever>();
            _eventPublisher       = A.Fake <IEventPublisher>();
            _cloneManagerForModel = A.Fake <ICloneManagerForModel>();
            _formulaTask          = A.Fake <IFormulaTask>();

            sut = new PassiveTransportConverter(_objectBaseFactory, _projectRetriever, _containerTask, _eventPublisher, _cloneManagerForModel, _formulaTask);

            A.CallTo(() => _containerTask.CreateUniqueName(A <IEnumerable <IWithName> > ._, A <string> ._, true))
            .ReturnsLazily(x => x.Arguments[1].ToString());

            _passiveTransportKinetic      = new ExplicitFormula("1+2");
            _moleculeWithPassiveTransport = new MoleculeBuilder().WithName("MOLECULE");
            _passiveTransport             = new TransportBuilder().WithName("PASSIVE TRANSPORT").WithFormula(_passiveTransportKinetic);
            _moleculeWithPassiveTransport.Add(_passiveTransport);
            _passiveTransports = new PassiveTransportBuildingBlock();
            _molecules         = new MoleculeBuildingBlock {
                _moleculeWithPassiveTransport
            }.WithName("MBB");
            _project = new MoBiProject();
            A.CallTo(() => _projectRetriever.Current).Returns(_project);
            A.CallTo(() => _eventPublisher.PublishEvent(A <ShowNotificationsEvent> ._))
            .Invokes(x => _showNotificationEvent = x.GetArgument <ShowNotificationsEvent>(0));
        }
Esempio n. 7
0
 protected override void Context()
 {
     base.Context();
     _concentrationFormula = A.Fake <IFormula>();
     _formulaCache         = new FormulaCache();
     A.CallTo(() => _formulaFactory.ConcentrationFormulaFor(_formulaCache)).Returns(_concentrationFormula);
 }
        private void convertExplicitFormula(IFormula formula, IDimension targetDimension)
        {
            if (Equals(formula.Dimension, targetDimension))
            {
                return;
            }

            var explicitFormula = formula as ExplicitFormula;

            if (explicitFormula == null)
            {
                return;
            }

            explicitFormula.Dimension = targetDimension;
            if (_amoutToConcentrationFormulaMapper.HasMappingFor(explicitFormula))
            {
                explicitFormula.FormulaString = _amoutToConcentrationFormulaMapper.MappedFormulaFor(explicitFormula);
                return;
            }

            var volumeAlias = _formulaTask.AddParentVolumeReferenceToFormula(explicitFormula);

            explicitFormula.FormulaString = string.Format("({0})/{1}", explicitFormula.FormulaString, volumeAlias);
        }
Esempio n. 9
0
    /// <summary>
    /// 获取行为节点
    /// </summary>
    /// <param name="paramsPacker"></param>
    /// <returns>暂停行为节点</returns>
    public override IFormula GetFormula(FormulaParamsPacker paramsPacker)
    {
        IFormula result = null;
        // 数据本地化
        var myCheckTime = CheckTime;

        result = new Formula((callback, scope) =>
        {
            //Debug.Log("Pause");
            var timer = new Timer(myCheckTime);
            Action completeCallback = () => { };

            completeCallback = () =>
            {
                if (SkillManager.isPause)
                {
                    // 继续暂停
                    timer = new Timer(myCheckTime);
                    timer.OnCompleteCallback(completeCallback).Start();
                }
                else
                {
                    // 暂停结束
                    callback();
                }
            };

            timer.OnCompleteCallback(completeCallback);
            timer.Start();
        }, FormulaType);

        return(result);
    }
Esempio n. 10
0
 protected override void Context()
 {
     base.Context();
     _cachedFormula = MvExplicitFormula();
     _buildingBlock.FormulaCache.Add(_cachedFormula);
     A.CallTo(() => _formulaTask.FormulasAreTheSame(_cachedFormula, _usingFormulaObject.Formula)).Returns(true);
 }
 protected override void Context()
 {
     base.Context();
     _parameter            = A.Fake <IParameter>();
     _formula              = A.Fake <IFormula>();
     _dimension            = A.Fake <IDimension>();
     _group                = A.Fake <IGroup>();
     _parameter.Formula    = _formula;
     _parameter.RHSFormula = null;
     _name                  = "Para";
     _parameter.Name        = _name;
     _parameter.GroupName   = "TOTO";
     _parameter.Persistable = true;
     _parameter.Visible     = true;
     _parameter.Dimension   = _dimension;
     _parameterBuildMode    = ParameterBuildMode.Global;
     _parameter.BuildMode   = _parameterBuildMode;
     _tag      = new Tag("Unsinn");
     _otherTag = new Tag("Quatsch");
     _parameter.CanBeVariedInPopulation = true;
     _pathElements = new PathElements();
     A.CallTo(() => _pathToPathElementsMapper.MapFrom(_parameter)).Returns(_pathElements);
     A.CallTo(() => _parameter.Tags).Returns(new Tags(new[] { _tag, _otherTag }));
     A.CallTo(() => _groupRepository.GroupByName(_parameter.GroupName)).Returns(_group);
 }
Esempio n. 12
0
        public void Create_Formula_That_Not_Exist()
        {
            List <FormulaName> formulaNames = CalculationFormulaFactory.GetAll();
            IFormula           formula      = CalculationFormulaFactory.Create(FormulaType.AreaBased);

            Assert.IsNotNull(formula, "formala is created");
        }
        private IFormula checkFormula(IFormulaCache formulaCache, IFormula formula)
        {
            if (formula.IsExplicit())
            {
                return(checkFormulaByType(formulaCache, (ExplicitFormula)formula, AreEqualExplicitFormula));
            }

            if (formula.IsBlackBox())
            {
                return(checkFormulaByType(formulaCache, (BlackBoxFormula)formula, AreEqualBalckBoxFormula));
            }

            if (formula.IsTable())
            {
                return(checkFormulaByType(formulaCache, (TableFormula)formula, AreEqualTableFormula));
            }

            if (formula.IsTableWithOffSet())
            {
                return(checkFormulaByType(formulaCache, (TableFormulaWithOffset)formula, AreEqualTableFormulaWithOffset));
            }

            if (formula.IsDynamic())
            {
                return(checkFormulaByType(formulaCache, (SumFormula)formula, AreEqualSumFormula));
            }

            return(formula);
        }
Esempio n. 14
0
 protected override void Visit(IFormula formula)
 {
     if (formula.IsCachable())
     {
         return;
     }
     unregister(formula);
 }
Esempio n. 15
0
 protected override void Context()
 {
     base.Context();
     _validFormula   = A.Fake <IFormula>().WithId("VALID");
     _invalidFormula = A.Fake <IFormula>().WithId("INVALID");
     sut.Handle(new FormulaInvalidEvent(_validFormula, _buildingBlock, "VALID_MESSAGE"));
     sut.Handle(new FormulaInvalidEvent(_invalidFormula, _buildingBlock, "INVALID_MESSAGE"));
 }
Esempio n. 16
0
 private void reportFormulaObjectPaths(IFormula formula, int noOfTabs)
 {
     foreach (var path in formula.ObjectPaths)
     {
         _report.AppendFormat("{0}{1}: {2}", tabs(noOfTabs), path.Alias, path);
         _report.AppendLine();
     }
 }
Esempio n. 17
0
 private bool formulaIsBeingEdited(IFormula formula)
 {
     if (_editPresenter == null)
     {
         return(false);
     }
     return(Equals(_editPresenter.Subject, formula));
 }
Esempio n. 18
0
        public static void ReplaceKeywordInObjectPaths(
            this IFormula formula,
            string keyword,
            string replacementValue)

        {
            ReplaceKeywordsInObjectPaths(formula, new [] { keyword }, new [] { replacementValue });
        }
Esempio n. 19
0
 protected override void Context()
 {
     base.Context();
     _formula = A.Fake <IFormula>();
     A.CallTo(() => _formula.ObjectPaths).Returns(new List <IFormulaUsablePath> {
         A.Fake <IFormulaUsablePath>()
     });
 }
 public void RemoveFormulaFromCache(IFormula formula)
 {
     if (!Formulas.Contains(formula))
     {
         return;
     }
     Formulas.Remove(formula);
 }
Esempio n. 21
0
 protected override void Context()
 {
     base.Context();
     _formula         = new ExplicitFormula("TOTO");
     _reactionBuilder = A.Fake <IReactionBuilder>();
     A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.ConcentrationBased);
     A.CallTo(() => _moBiFormulaTask.GetFormulaCaption(_reactionBuilder, ReactionDimensionMode.ConcentrationBased, false)).Returns("THE_RHS_CAPTION");
 }
Esempio n. 22
0
        public DpllAlgorithm(Formula formula)
        {
            Contract.Requires(formula != null);

            _logger = LogManager.GetCurrentClassLogger();
            _logger.Info("Hallo");
            _formula = formula;
        }
Esempio n. 23
0
 protected override void Context()
 {
     base.Context();
     _exisitingFormula = A.Fake <IFormula>().WithId(CoreConstants.Formula.Concentration);
     _formulaCache     = new FormulaCache {
         _exisitingFormula
     };
 }
Esempio n. 24
0
 protected override void Context()
 {
     base.Context();
     _formula   = new ExplicitFormula("TOTO");
     _parameter = A.Fake <IParameter>().WithName("PARA");
     sut.IsRHS  = true;
     A.CallTo(() => _moBiFormulaTask.GetFormulaCaption(_parameter, A <ReactionDimensionMode> ._, true)).Returns("THE_RHS_CAPTION");
 }
Esempio n. 25
0
 private void renameAbsolutePathIn(IFormula formula)
 {
     if (formula == null || !formula.IsExplicit())
     {
         return;
     }
     formula.ObjectPaths.Where(isAbsolutePath).Each(renameObjectPath);
 }
Esempio n. 26
0
 protected override void Context()
 {
     base.Context();
     _formula = new ExplicitFormula();
     _passiveTransportBuildingBlock = new PassiveTransportBuildingBlock();
     _passiveTransportBuildingBlock.AddFormula(_formula);
     sut.Edit(_passiveTransportBuildingBlock);
 }
Esempio n. 27
0
 protected override void Context()
 {
     base.Context();
     _existingFormula          = A.Fake <IFormula>().WithId("existingId");
     _anotherFormulaWithSameId = A.Fake <IFormula>().WithId(_existingFormula.Id);
     _aDifferentFormula        = A.Fake <IFormula>().WithId("toto");
     sut.Add(_existingFormula);
 }
Esempio n. 28
0
        private FormulaExport mapFormula(IUsingFormula usingFormula, IFormula formula)
        {
            var formulaExport = createFormulaExport(usingFormula, formula);

            _modelExport.FormulaList.Add(formulaExport);
            formulaExport.Id = _modelExport.NewId();
            return(formulaExport);
        }
 public override void RestoreExecutionData(IMoBiContext context)
 {
     base.RestoreExecutionData(context);
     _startValuesBuildingBlock = context.Get <IStartValuesBuildingBlock <T> >(_objectBaseId);
     _changedStartValue        = _startValuesBuildingBlock.Single(startValue => startValue.Path.Equals(Path));
     _oldFormula = GetFormula(_oldFormulaId, context);
     _newFormula = GetFormula(_newFormulaId, context);
 }
 protected override void ClearReferences()
 {
     base.ClearReferences();
     _changedStartValue        = null;
     _startValuesBuildingBlock = null;
     _newFormula = null;
     _oldFormula = null;
 }
Esempio n. 31
0
 public bool EditNewFormula(IFormula formula, ICommandCollector command, IBuildingBlock buildingBlock, IParameter parameter)
 {
     using (var presenter = _applicationController.Start <INewFormulaPresenter>())
     {
         presenter.InitializeWith(command);
         return(presenter.Edit(formula, buildingBlock, parameter));
     }
 }
 protected override void Context()
 {
     base.Context();
     _displayUnit     = A.Fake <Unit>();
     _constantFormula = new ConstantFormula(5);
     A.CallTo(() => _formulaFactory.ConstantFormula(5, _dimensionFactory.NoDimension)).Returns(_constantFormula);
     A.CallTo(() => _displayUnitRetriever.PreferredUnitFor(_dimensionFactory.NoDimension)).Returns(_displayUnit);
 }
Esempio n. 33
0
 public static IBlockFormula Block(
     IBlockFormula parentBlock,
     ReadOnlyCollection<IBlockFormula> childBlocks,
     ReadOnlyCollection<IFormula> variables,
     ReadOnlyCollection<IFormula> formulas,
     IFormula result,
     ITypeDeclaration type,
     IFormula parent)
 {
     return new BlockFormula(parentBlock, childBlocks, variables, formulas, result, type, parent);
 }
Esempio n. 34
0
 protected internal MethodCallFormula(
     IFormula instance,
     IMethodDeclaration method,
     ReadOnlyCollection<IFormula> arguments,
     ITypeDeclaration type,
     IFormula parent)
     : base(NodeType.Call, type, parent)
 {
     Instance = instance;
     Method = method;
     Arguments = arguments;
 }
Esempio n. 35
0
        static long IterateCalcuations(double[] args, IFormula formula, long iterations)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            for (long i = 0; i <= iterations; i++)
            {
                formula.calculate(args);
            }
            stopwatch.Stop();

            return stopwatch.ElapsedMilliseconds;
        }
Esempio n. 36
0
 protected internal ConstantFormula(object value, ITypeDeclaration type, IFormula parent)
     : base(NodeType.Constant, type, parent)
 {
     Value = value;
 }
Esempio n. 37
0
 protected internal AndAlsoFormula(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
     : base(NodeType.AndAlso, left, right, type, method, parent)
 {
 }
Esempio n. 38
0
 //protected internal Formula(IConstantNode<NodeType> nodeType, string name, IConstantNode<ITypeDeclaration> type, IFormula parent)
 //    : this(nodeType, name, type, parent, new INode[] { })
 //{
 //}
 protected internal Formula(IConstantNode<NodeType> nodeType, string name, IConstantNode<ITypeDeclaration> type, IFormula parent, params INode[] properties)
     : this(parent, name, new INode[] { type, parent }.Concat(properties).ToArray())
 {
 }
Esempio n. 39
0
 public static IEqualFormula Equal(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
 {
     return new EqualFormula(left, right, type, method, parent);
 }
Esempio n. 40
0
 public static IConvertFormula Convert(ITypeDeclaration type, IFormula operand, IMethodDeclaration method, IFormula parent)
 {
     return new ConvertFormula(type, operand, method, parent);
 }
Esempio n. 41
0
 protected internal ConvertFormula(ITypeDeclaration type, IFormula operand, IMethodDeclaration method, IFormula parent)
     : base(NodeType.Convert, type, operand, method, parent)
 {
 }
Esempio n. 42
0
 Formula(IFormula parent, string name, IList<INode> properties)
     : base(parent, name, new NodeCollection<INode>(properties, parent))
 {
     NodeType = (IConstantNode<NodeType>)properties[0];
     Type = (IConstantNode<ITypeDeclaration>)properties[1];
 }
Esempio n. 43
0
 public static IMethodCallFormula Call(IFormula instance, IMethodDeclaration method, ReadOnlyCollection<IFormula> arguments, ITypeDeclaration type, IFormula parent)
 {
     return new MethodCallFormula(instance, method, arguments, type, parent);
 }
Esempio n. 44
0
 protected Formula(NodeType nodeType, ITypeDeclaration type, IFormula parent)
 {
     NodeType = nodeType;
     Type = type;
     Parent = parent;
 }
Esempio n. 45
0
 public static IAssignFormula Assign(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
 {
     return new AssignFormula(left, right, type, method, parent);
 }
Esempio n. 46
0
 public static IVariableFormula Variable(ITypeDeclaration type, string name, IFormula parent)
 {
     return new VariableFormula(type, name, parent);
 }
Esempio n. 47
0
 protected internal ExclusiveOrFormula(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
     : base(NodeType.ExclusiveOr, left, right, type, method, parent)
 {
 }
Esempio n. 48
0
 public NeighbourFinder(IFormula formula)
 {
     currentFormula = formula;
 }
Esempio n. 49
0
 protected internal VariableFormula(ITypeDeclaration type, string name, IFormula parent)
     : base(NodeType.Variable, type, parent)
 {
     Name = name;
 }
Esempio n. 50
0
 public static IConditionalFormula Condition(IFormula test, IFormula ifTrue, IFormula ifFalse, ITypeDeclaration type, IFormula parent)
 {
     return new ConditionalFormula(test, ifTrue, ifFalse, type, parent);
 }
Esempio n. 51
0
 protected internal ReturnFormula(IFormula @object, ITypeDeclaration type, IFormula parent)
     : base(NodeType.Return, type, parent)
 {
     Object = @object;
 }
Esempio n. 52
0
 public static IConstantFormula Constant(object value, ITypeDeclaration type, IFormula parent)
 {
     return new ConstantFormula(value, type, parent);
 }
Esempio n. 53
0
 public static IMultiplyFormula Multiply(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
 {
     return new MultiplyFormula(left, right, type, method, parent);
 }
Esempio n. 54
0
 public static IExclusiveOrFormula ExclusiveOr(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
 {
     return new ExclusiveOrFormula(left, right, type, method, parent);
 }
Esempio n. 55
0
 protected internal MultiplyFormula(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent)
     : base(NodeType.Multiply, left, right, type, method, parent)
 {
 }
Esempio n. 56
0
 public static IReturnFormula Return(IFormula formula, ITypeDeclaration type, IFormula parent)
 {
     return new ReturnFormula(formula, type, parent);
 }
Esempio n. 57
0
 protected abstract IFormula Pin(IFormula parent, IList<INode> properties);
Esempio n. 58
0
 public static ITypeAsFormula TypeAs(ITypeDeclaration type, IFormula operand, IMethodDeclaration method, IFormula parent)
 {
     return new TypeAsFormula(type, operand, method, parent);
 }