IMsCalculationHistory.CalculationLog

Syntax

CalculationLog: IMsCalculationLog;

Description

The CalculationLog property returns calculation log.

Example

Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. This container must have a problem with the PROBLEM_NON_LINEAR identifier.

Add links to the Metabase and Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    ModelCont, Descript,DepObj: IMetabaseObjectDescriptor;
    Obj: IMetabaseObject;
    Problem: IMsProblem;
    Calculation: IMsProblemCalculation;
    CalcSettings: IMsProblemCalculationSettings;
    Deps: IMetabaseObjectDescriptors;
    i: Integer;
    CalcHist: IMsCalculationHistory;
    Log: IMsCalculationLog;
    s: String;
    LogRecord: IMsCalculationLogRecord;
    Attributes:IMsMetaAttributeValueList;
Begin
    MB := MetabaseClass.Active;
    ModelCont := MB.ItemById("CONT_MODEL");
    Descript := MB.ItemByIdNamespace("PROBLEM_NON_LINEAR",ModelCont.Key);
    Obj := Descript.Bind;
    Problem := Obj As IMsProblem;
    CalcSettings := Problem.CreateCalculationSettings;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.SaveHistoryMask:= MsCalculationHistorySet.Full;
    Calculation.Run;
    Deps := Obj.Children;
    Debug.WriteLine("Total calculations - " + Deps.Count.ToString);
    Debug.WriteLine("Calculation log #" + Deps.Count.ToString);
    i := Deps.Count - 1;
    DepObj := Deps.Item(i);
    CalcHist := DepObj.Bind As IMsCalculationHistory;
    Log := CalcHist.CalculationLog;
    Debug.WriteLine("Number of records in log - " + Log.Count.ToString);
    Debug.WriteLine("--------");
    For i := 0 To Log.Count - 1 Do
        LogRecord := Log.Item(i);
        Debug.WriteLine("Record " + (i + 1).ToString);
        Select Case LogRecord.Type.ToString
            Case "0": s := "Information:";
            Case "1": s := "Error:";
            Case "2": s := "Warning:";
            Case "3": s := "Constraint violation:";
        End Select;
        Debug.WriteLine(s);
        Debug.WriteLine(LogRecord.Text);
        Debug.WriteLine("Event date: " + LogRecord.RecordDate.ToString);
        If LogRecord.Model <> Null Then
            Debug.WriteLine("Model '" + LogRecord.Model.Name + "'");
            Debug.WriteLine("Calendar point '" + LogRecord.CalendarPoint.ToString + "'");
        End If;
        Attributes := LogRecord.Attributes;
        If Attributes <> Null Then
            Debug.WriteLine("Number of attributes: '" + Attributes.Count.ToString);
        End If;
        Debug.WriteLine("Scenario:'" + LogRecord.Scenario.ToString + "'");
        Debug.WriteLine("--------");
    End For;
End Sub;

After executing the example the console window displays the log of last problem calculation.

The example of log that is displayed in the console window:

Module execution started

Total calculations - 3

Calculation log #3

Quantity of notes in the log - 11

--------

Note 1

Information

Loading of variable data "w1 -  lrx"

Event date: 23.12.2008 15:47:41

script: '-1'

--------

Note 2

Information

Loading of variable data "w2- lrx"

Event date: 23.12.2008 15:47:42

script: '-1'

--------

Note 3

Information

Loading of variable data InVar - lrx

Event date: 23.12.2008 15:47:42

script: '-1'

--------

Note 4

Information

Problem calculation by script Sc_Param, current date 01.01.2009

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2009 00:00:00

script: 3681

--------

Note 5

Information

Problem calculation by script Sc_Param, current date 01.01.2010

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2010 00:00:00

script: 3681

--------

Note 6

Information

Problem calculation by script Sc_Param, current date 01.01.2011

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2011 00:00:00

script: 3681

--------

Note 7

Information

Problem calculation by script Sc_Param, current data 01.01.2012

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2012 00:00:00

script: 3681

--------

Note 8

Information

Loading of variable data InVar - lrx

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2012 00:00:00

script: 3681

--------

Note 9

Information

Loading of variable data "w1 -  lrx"

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2012 00:00:00

script: 3681

--------

Note 10

Information

Loading of variable data w2- lrx

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2012 00:00:00

script: 3681

--------

Note 11

Information

Saving of calculation history

Event date: 23.12.2008 15:47:42

Model NON_LINEAR_1

Calendar point 01.01.2012 00:00:00

script: 3681

--------

Module execution finished

See also:

IMsCalculationHistory