PointPassed: Integer;
The PointPassed property returns the number of passed steps on modeling problem calculation.
Public Class MCallback: Object, IMsProblemCalculationCallback
Public Calculation: IMsProblemCalculation;
Public Sub OnError(Message: String);
Begin
Debug.WriteLine(Message);
End Sub OnError;
Public Sub OnFinish;
Begin
Debug.WriteLine(The calculation of problem is finished);
Calculation := Null;
End Sub OnFinish;
Public Sub OnMessage(Message: String);
Begin
Debug.Write(DateTime.Now);
Debug.WriteLine(": " + Message);
End Sub OnMessage;
Public Sub OnModelCalculation(Model: IMsModel);
Begin
Debug.WriteLine(Model calculation: + (Model As IMetabaseObject).Id);
End Sub OnModelCalculation;
Public Sub OnStep;
Begin
Debug.WriteLine(Executed steps: + Calculation.PointPassed.ToString + from + Calculation.PointCount.ToString);
End Sub OnStep;
End Class MCallback;
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Problem: IMsProblem;
CallBack: MCallback;
CalcSett: IMsProblemCalculationSettings;
Calculation: IMsProblemCalculation;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("PROBLEM_1", MB.ItemById("KONT_MODEL").Key).Edit;
Problem := MObj As IMsProblem;
CallBack := New MCallback.Create;
CalcSett := Problem.CreateCalculationSettings;
CalcSett.Callback := CallBack;
Calculation := Problem.Calculate(CalcSett);
CallBack.Calculation := Calculation;
Calculation.Run;
MObj.Save;
End Sub Main;
After executing the example the problem with the PROBLEM_1 identifier will be calculated. To track the events that occur during calculation, an object of the MCallback custom class is used. On handling the OnStep event the number of passed calculation steps is displayed in the console.
See also: