Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. This container should include a problem with the PROBLEM_1 identifier.
Add links to the Metabase, Ms system assemblies.
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(Problem calculation is completed);
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: " + (Modelnbsp;Asnbsp;IMetabaseObject).Id);
End Sub OnModelCalculation;
Public Sub OnStep;
Begin
Debug.WriteLine(Steps executed: + Calculation.PointPassed.ToString +
from + Calculation.PointCount.ToString);
End Sub OnStep;
Public Sub OnBreak(Breakpoint: IMsBreakpoint);
Begin
Debug.WriteLine(Breakpoint.Name);
End Sub OnBreak;
Public Sub OnWarning(Message: string);
Begin
Debug.WriteLine("Warning: "nbsp;+nbsp;Message);
End Sub OnWarning;
End Class MCallback;
Sub UserProc;
Var
MB: IMetabase;
Ms: IMetabaseObjectDescriptor;
Problem: IMsProblem;
CallBack: MCallback;
CalcSett: IMsProblemCalculationSettings;
Scens: IMsProblemScenarios;
Calculation: IMsProblemCalculation;
i: Integer;
Begin
MB := MetabaseClass.Active;
Ms := MB.ItemById("CONT_MODEL");
Problem := MB.ItemByIdNamespace("PROBLEM_1", Ms.Key).Bind As IMsProblem;
CallBack := New MCallback.Create;
CalcSett := Problem.CreateCalculationSettings;
CalcSett.Callback := CallBack;
Scens := Problem.Scenarios;
For i := 0 To Scens.Count - 1 Do
CalcSett.ScenarioIncluded(Scens.Item(i)) := True;
End For;
Calculation := Problem.Calculate(CalcSett);
Calculation.SaveHistory := True;
CallBack.Calculation := Calculation;
Calculation.Run;
End Sub UserProc;
See also: