Frequencies: DimCalendarLevelSet;
Frequencies: Prognoz.Platform.Interop.Dimensions.DimCalendarLevelSet;
The Frequencies property determines calendar frequency of iterations.
It is forbidden to use the Frequencies and IMsCalculationChainIterator.UseDates properties at the same time.
Executing the example requires that repository contains modeling container with the MS identifier containing metamodel with the METAMODEL_ITERATOR identifier and model with the MODEL_ITERATOR identifier.
Add links to the Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
MetaModel: IMsMetaModel;
Param: IMsModelParam;
CalcChain: IMsCalculationChainEntries;
Iterator: IMsCalculationChainIterator;
Model: IMsModel;
Formula: IMsFormula;
Expr: IExpression;
Begin
// Get current
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
MetaModel := mb.ItemByIdNamespace("METAMODEL_ITERATOR", MsKey).Edit As IMsMetaModel;
// Clear metamodel parameters collection
MetaModel.Params.Clear;
// Add parameter which will be responsible for cycle calculation
Param := MetaModel.Params.Add;
Param.DefaultValue := 0;
Param.Id := "THRESHOLD";
Param.Name := "Threshold";
// Get and clear metamodel calculation chain
CalcChain := MetaModel.CalculationChain;
CalcChain.Clear;
// Create cycle in metamodel calculation chain
Iterator := CalcChain.AddIterator("Cycle");
// Set cycle execution conditions
Iterator.PostCondition := True;
Iterator.MaxIterations := 600;
Expr := Iterator.Expression;
Expr.AsString := "{THRESHOLD}<5";
// Get the model
Model := mb.ItemByIdNamespace("MODEL_ITERATOR", MsKey).Edit As IMsModel;
// Clear model calculation dynamics
Formula := Model.Transform.FormulaItem(0);
Formula.Level := DimCalendarLevel.Root;
// Save changes in the model
(Model As IMetabaseObject).Save;
// Add this model to the cycle
Iterator.Contents.AddModel(model);
// Determine that cycle will perform iteration by frequency
Iterator.Frequencies := DimCalendarLevelSet.Year Or DimCalendarLevelSet.Quarter;
// Set step of dates for iterations using parameter
Iterator.StepParam := "STEP";
// Save changes
(MetaModel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example calculation dynamics will be set for the cycle.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
MetaModel: IMsMetaModel;
Param: IMsModelParam;
CalcChain: IMsCalculationChainEntries;
Iterator: IMsCalculationChainIterator;
Model: IMsModel;
Formula: IMsFormula;
Expr: IExpression;
Begin
// Get current
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
MetaModel := mb.ItemByIdNamespace["METAMODEL_ITERATOR", MsKey].Edit() As IMsMetaModel;
// Clear metamodel parameters collection
MetaModel.Params.Clear();
// Add parameter which will be responsible for cycle calculation
Param := MetaModel.Params.Add();
Param.DefaultValue := 0;
Param.Id := "THRESHOLD";
Param.Name := "Threshold";
// Get and clear metamodel calculation chain
CalcChain := MetaModel.CalculationChain;
CalcChain.Clear();
// Create cycle in metamodel calculation chain
Iterator := CalcChain.AddIterator("Cycle");
// Set cycle execution conditions
Iterator.PostCondition := True;
Iterator.MaxIterations := 600;
Expr := Iterator.Expression;
Expr.AsString := "{THRESHOLD}<5";
// Get the model
Model := mb.ItemByIdNamespace["MODEL_ITERATOR", MsKey].Edit() As IMsModel;
// Clear model calculation dynamics
Formula := Model.Transform.FormulaItem[0];
Formula.Level := DimCalendarLevel.dclRoot;
// Save changes in the model
(Model As IMetabaseObject).Save();
// Add this model to the cycle
Iterator.Contents.AddModel(model);
// Determine that cycle will perform iteration by frequency
Iterator.Frequencies := DimCalendarLevelSet.dclsYear Or DimCalendarLevelSet.dclsQuarter;
// Set step of dates for iterations using parameter
Iterator.StepParam := "STEP";
// Save changes
(MetaModel As IMetabaseObject).Save();
End Sub;
See also: