Exemple #1
0
        public IEventBuilder MapFrom(FlatContainer flatEventContainer)
        {
            var eventBuilder = _objectBaseFactory.Create <IEventBuilder>();

            eventBuilder.Name = flatEventContainer.Name;

            var flatEventCondition = _flatEventConditionRepo.EventConditionFor(flatEventContainer.Id);

            eventBuilder.OneTime = flatEventCondition.IsOneTime;
            eventBuilder.Formula =
                _formulaFactory.RateFor(flatEventCondition, _formulaCache);

            //add time reference to event condition formula
            if (!eventBuilder.Formula.ContainsTimePath())
            {
                eventBuilder.Formula.AddObjectPath(_objectPathFactory.CreateTimePath(_dimensionRepository.Time));
            }

            // fill event assignments
            foreach (var flatEventAssignment in _flatEventChangedObjectRepo.ChangedObjectsFor(flatEventContainer.Id))
            {
                var eventAssignment = _eventAssignmentBuilderMapper.MapFrom(flatEventAssignment);
                eventAssignment.Name = $"Assignment_{eventBuilder.Assignments.Count() + 1}";

                eventBuilder.AddAssignment(eventAssignment);
            }

            return(eventBuilder);
        }
Exemple #2
0
 /// <summary>
 ///     Gets the "Time" attribute of the MoBi simulation.
 /// </summary>
 private string parseTime()
 {
     if (!_objectPaths.Exists(x => x.Alias == Constants.Dimension.TIME))
     {
         _objectPaths.Add(
             _objectPathFactory.CreateTimePath(_moBiDimensionFactory.Dimension(Constants.Dimension.TIME)));
     }
     return(Constants.Dimension.TIME);
 }
Exemple #3
0
        /// <summary>
        ///    Checks if formula equation is time dependent and add reference to
        ///    <para></para>
        ///    Time (if not already done)
        /// </summary>
        private void addTimeReferenceIfNeeded(FormulaWithFormulaString formula)
        {
            if (string.IsNullOrEmpty(formula.FormulaString))
            {
                return;
            }

            // check if formula string contains "Time" as a substring
            if (!formula.FormulaString.Contains(Constants.TIME))
            {
                return;
            }

            // check if time reference is already created
            if (formula.ContainsTimePath())
            {
                return;
            }

            // add time reference
            formula.AddObjectPath(_objectPathFactory.CreateTimePath(_dimensionRepository.Time));
        }