IMsProblemCalculationSettings.ValueFlag

Syntax

ValueFlag: Integer;

ValueFlag: Integer;

Description

The ValueFlag property determines value of the flag that is used to select changed values.

Comments

By default, the value specified in IMsProblem.ValueFlag is put as a property value. The saving algorithm determined in IMsProblem.ValueFlag is used in this case.

If a proper value that is greater than 0 is set for the ValueFlag current property, the data is saved, for which the sent flag of changed values is set. The available value of the property is in the range [0; 255].

Flag value is available in the IMsProblemCalculationCallback.OnBeforeSaveData and IMsProblemCalculationCallback.OnSaveData events.

Example

Executing the example requires a time series database with the TSDB identifier. The modeling container that is a child object of the database has a modeling problem with the TSDB_PROBLEM identifier.

Add links to the Cubes, Matrix, Metabase, Ms system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Rub: IRubricator;
    Problem: IMsProblem;
    Calculation: IMsProblemCalculation;
    CalcSettings: IMsProblemCalculationSettings;
Begin
    Mb := MetabaseClass.Active;
    Rub := MB.ItemById(
"TSDB").Bind As IRubricator;
    
// Get problem in TSDB modeling container
    Problem := Mb.ItemByIdNamespace("TSDB_PROBLEM", Rub.ModelSpace.Key).Edit As IMsProblem;
    
// Flag that will be assigned to changed data
    // Set problem calculation parameters
    CalcSettings := Problem.CreateCalculationSettings;
    CalcSettings.FactIncluded := 
True;
    CalcSettings.BreakOnError := 
True;
    // Execute problem with ValueFlag=2
    //...
    //Specify in CalcSettings the first set of parameters for calculation
    //...
    CalcSettings.ValueFlag := 2;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.Callback := 
New MCallback.Create;
    Calculation.Run;
    // Execute problem with ValueFlag=3
    //...
    //Specify in CalcSettings the second set of parameters for calculation
    //...
    CalcSettings.ValueFlag := 3;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.Callback := 
New MCallback.Create;
    Calculation.Run;
End Sub UserProc;

Public Class MCallback: ProblemCalculationCallback
    
Public Sub OnBeforeSaveData(Stub: IVariableStub; Matrix: IMatrix; Var ValueFlag: Integer; Var Cancel: Boolean);
    
Begin
        Debug.WriteLine(ValueFlag);
        
Select Case ValueFlag
            
Case 2:
                
//...
                //Process data that must be saved if ValueFlag = 2
                //...
            Case 3:
                
//...
                //Process data that must be saved if ValueFlag = 3
                //...
        End Select;
    
End Sub OnBeforeSaveData;

    
Public Sub OnSaveData(Stub: IVariableStub; Matrix: IMatrix; ValueFlag: Integer; AuditRecordKey: Variant);
    
Var
        Iter: IMatrixIterator;
        RecordCount: Integer;
    
Begin
        Iter := Matrix.CreateIterator;
        Iter.Move(IteratorDirection.First);
        
While Iter.Valid Do
            
If Iter.ValueFlag = ValueFlag Then
                RecordCount := RecordCount + 
1;
            
End If;
            Iter.Move(IteratorDirection.Next);
        
End While;
        Debug.WriteLine(
"Data is saved on ValueFlag: " + ValueFlag.ToString + #13 + #10 +
            
"Number of saved values: " + RecordCount.ToString + #13 + #10 +
            
"Key of record in access protocol: " + AuditRecordKey);
    
End Sub OnSaveData;
End Class MCallback;

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Rub: IRubricator;
    Problem: IMsProblem;
    Calculation: IMsProblemCalculation;
    CalcSettings: IMsProblemCalculationSettings;
Begin
    Mb := Params.Metabase;
    Rub := MB.ItemById[
"TSDB"].Bind() As IRubricator;
    
// Get problem in TSDB modeling container
    Problem := Mb.ItemByIdNamespace["TSDB_PROBLEM", Rub.ModelSpace.Key].Bind() As IMsProblem;
    
// Flag that will be assigned to changed data
    // Set problem calculation parameters
    CalcSettings := Problem.CreateCalculationSettings();
    CalcSettings.FactIncluded := 
True;
    CalcSettings.BreakOnError := 
True;
    // Execute problem with ValueFlag=2
    //...
    //Specify in CalcSettings the first set of parameters for calculation
    //...
    CalcSettings.ValueFlag := 2;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.Callback := 
New MCallback();
    Calculation.Run();
    // Execute problem with ValueFlag=3
    //...
    //Specify in CalcSettings the second set of parameters for calculation
    //...
    CalcSettings.ValueFlag := 3;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.Callback := 
New MCallback();
    Calculation.Run();
End Sub;

Public Class MCallback: IMsProblemCalculationCallback
    
Public Sub OnBeforeSaveData(Stub: IVariableStub; Matrix: IMatrix; Var ValueFlag: Integer; Var Cancel: Boolean);
    
Begin
        
Select Case ValueFlag
            
Case 2:
                
//...
                //Process data that must be saved if ValueFlag = 2
                //...
            Case 3:
                
//...
                //Process data that must be saved if ValueFlag = 3
                //...
        End Select;
    
End Sub;

    
Public Sub OnSaveData(Stub: IVariableStub; Matrix: IMatrix; ValueFlag: Integer; AuditRecordKey: Object);
    
Var
        Iter: IMatrixIterator;
        RecordCount: Integer;
    
Begin
        Iter := Matrix.CreateIterator();
        Iter.Move(IteratorDirection.itdFirst);
        
While Iter.Valid Do
            
If Iter.ValueFlag = ValueFlag Then
                RecordCount := RecordCount + 
1;
            
End If;
            Iter.Move(IteratorDirection.itdNext);
        
End While;
        System.Diagnostics.Debug.WriteLine(
"Data is saved on ValueFlag: " + ValueFlag.ToString() + char.ConvertFromUtf32(13) + char.ConvertFromUtf32(10) +
            
"Number of saved values: " + RecordCount.ToString() + char.ConvertFromUtf32(13) + char.ConvertFromUtf32(10) +
            
"Key of record in access protocol: " + AuditRecordKey);
    
End Sub;

    
Public Sub OnBreak(Breakp: IMsBreakpoint);
    
Begin
    
End Sub;
    
    
Public Sub OnMessage(Message: String);
    
Begin
    
End Sub;
    
    
Public Sub OnError(Message: String);
    
Begin
    
End Sub;
    
    
Public Sub OnFinish();
    
Begin
    
End Sub;
    
    
Public Sub OnModelCalculation(Model: IMsModel);
    
Begin
    
End Sub;
    
    
Public Sub OnStep();
    
Begin
    
End Sub;
    
    
Public Sub OnWarning(Message: string);
    
Begin
    
End Sub;
    
    
Public Sub OnStageStart(Stage: MsProblemCalculationStage; Data: object);
    
Begin
    
End Sub;
    
    
Public Sub OnStageFinish(Stage: MsProblemCalculationStage; Duration: Integer; Data: object);
    
Begin
    
End Sub;
    
    
Public Function OnGetActiveEvents(): MsProblemCalculationCallbackEvents;
    
Begin
        
Return MsProblemCalculationCallbackEvents.mspceAll
    
End Function;
End Class;

After executing the example the modeling problem is calculated with two different sets of parameters. Different flags of changed values will be set for calculated data. Additional data processing can be executed in the OnBeforeSaveData event by flag. After the data is saved, the development environment console displays information about the number of saved values and key of the record in access protocol that corresponds to data saving.

See also:

IMsProblemCalculationSettings