Matrix(Stub: IVariableStub): IMatrixDataSource;
Stub. Abstract data source.
The Matrix property returns the abstract multidimensional data source to get intermediate calculation results for calculation block.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. The calculation algorithm should contain two calculation blocks and one control block. It is also assumed that there is an empty regular report with the REPORT identifier.
Add links to the Algo, Dimensions, Matrix, Metabase, Report system assemblies. Add links to the assemblies required for working with calculation algorithms.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObjectDescriptor;
Algo: ICalcObject;
CalcList: ICalcObjectsList;
CalcAlgo: ICalcAlgorithm;
CalcDebug: IAlgorithmCalculationDebug;
i: Integer;
Report, Report1: IPrxReport;
Result: IAlgorithmCalculationResult;
Load: IAlgorithmTimeResults;
TimeResult: IAlgorithmTimeResult;
Sec: Double;
Matrix, ValidationMatrix: IMatrixDataSource;
DimSS: IDimSelectionSet;
Matr, ValidationMatr: IMatrix;
Coord: IMatrixCoord;
Begin
MB := MetabaseClass.Active;
// Get calculation algorithm
MObj := MB.ItemById("ALGORITHM");
// Regular report for subtotals
Report := MB.ItemByID("REPORT").Edit As IPrxReport;
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
CalcAlgo := Algo As ICalcAlgorithm;
// Create a list of algorithm objects
CalcList := CalcAlgo.Items.Clone;
// Start algorithm debugging
CalcDebug := CalcAlgo.Debug(CalcList);
// Go to the next
CalcDebug.NextStep;
// Calculation result of the first block is written to regular report
Report1 := CalcDebug.PrxReport(CalcAlgo, CalcAlgo.Items.Item(0));
Report.CopyFrom(Report1);
(Report As IMetabaseObject).Save;
// Go to the specified calculation algorithm object
CalcDebug.StepToObject(CalcDebug.Objects.Item(0));
// View intermediate data
Matrix := CalcDebug.Matrix((CalcAlgo.Items.Item(1) As ICalcBlock).StubOut);
DimSS := Matrix.CreateDimSelectionSet;
Matr := Matrix.Execute(DimSS);
Coord := Matr.CreateCoord;
For i := 0 To Matr.DimensionCount - 1 Do
Coord.Item(i) := 0;
End For;
Debug.WriteLine(Matr.Item(Coord));
// Go to the next calculation object
CalcDebug.NextStep;
//View intermediate data
ValidationMatrix := CalcDebug.ValidationMatrix((CalcAlgo.Items.Item(2) As ICalcValidationBlock).StubOut);
DimSS := ValidationMatrix.CreateDimSelectionSet;
For i := 0 To DimSS.Count - 1 Do
DimSS.Item(i).SelectAll;
End For;
ValidationMatr := ValidationMatrix.Execute(DimSS);
Coord := ValidationMatr.CreateCoord;
For i := 0 To ValidationMatr.DimensionCount - 1 Do
Coord.Item(i) := 0;
End For;
Debug.WriteLine(ValidationMatr.Item(Coord));
// Go to saving data to database.
CalcDebug.StepToSaveData;
// Check if calculation is finished and display information about data loading
If CalcDebug.IsFinished = True Then
Debug.WriteLine("Calculation is finished:");
// data about calculation results
Result := CalcDebug.Result;
Load := Result.Load;
Debug.WriteLine("Result of loading data sources:");
TimeResult := Load.Item(0);
Debug.WriteLine(" Name: " + TimeResult.Name);
Debug.WriteLine(" Identifier: " + TimeResult.Id);
Sec := TimeResult.ExecuteMilisecods / 1000;
Debug.WriteLine(" Loading time: " + Sec.ToString + " sec.");
Debug.WriteLine("");
End If;
End Sub UserProc;
After executing the example the algorithm calculation, in which the calculation blocks and the control block are to be executed, will be debugged. The result of the first calculation block will be saved to the regular report. The result of the second calculation block will be obtained as a matrix, the first matrix value will be displayed in the development environment console. A matrix of intermediate results will be obtained for the control block, and one value will be displayed in the development environment console.
See also: