Showing results 1 to 2 of 2

Thread: Working with REMAs

  1. #1
    robertf Gast

    Default Working with REMAs

    The Reaction Matrices are the most sophisticated way to deal with stati.

    [highlight=vb]Public Sub zenOn_RemasExample()

    'Declarations
    Dim zRemas As Remas
    Dim zBinRema As Rema
    Dim zAnaRema As Rema
    Dim i As Integer

    'Initialization of zRemas
    Set zRemas = MyWorkspace.ActiveDocument.Remas
    'Intialization of zBinRema by creating a new binary rema
    Set zBinRema = zRemas.Create(tpBinaer, "zenOn_BinaryRema")
    'Intialization of zAnaRema by creating a new analog rema
    Set zAnaRema = zRemas.Create(tpAnalog, "zenOn_AnalogRema")

    'Output some details on the remas
    For i = 0 To zRemas.Count - 1
    'Display name
    Debug.Print "Name: " & zRemas.Item(i).Name
    'Show type of Reaction Matrix
    Select Case zRemas.Item(i).Type
    Case Is = 1
    Debug.Print "Type: Binary"
    Case Is = 2
    Debug.Print "Type: Analog"
    Case Is = 3
    Debug.Print "Type: MultiBinary"
    Case Is = 4
    Debug.Print "Type: MultiAnalog"
    Case Is = 5
    Debug.Print "Type: String"
    End Select
    Next i

    'Delete the binary rema by its position
    Debug.Print zRemas.Delete(1)
    'Delete the analog rema by its name
    Debug.Print zRemas.Delete("zenOn_AnalogRema")

    End Sub
    [highlight]

    States of a REMA:

    Binary Reaction Matrix state
    [highlight=vb]
    Sub zenOn_SetStateForBinaryRema(ByRef zRema As Rema)

    'Declaration zState
    Dim zState As State

    'Intialize zState with the first state inside the passed binary rema
    Set zState = zRema.StateItem(1)

    'Defines the matching bit combination
    zState.ReaWert = &H89 'Sets Bit0, Bit3 and Bit7 TRUE
    zState.ReaWertMaske = &H81 'Defines that Bit0 and Bit7 will be checked (Bit3 is ignored)

    'User message that will be displayed when the event occurs
    zState.Text = "Bit combination is matched!"

    'Moreover, the first defined function will be called when the event occurs
    zState.Function = MyWorkspace.ActiveDocument.RtFunctions.Item(0)
    'The function will only be executed when the tpBitFkt is set. Additionaly the tpBitAlarm flag is set too.
    zState.Status = tpBitFkt Or tpBitAlarm

    End Sub
    [highlight]

    Analog Reaction Matrix state
    [highlight=vb]
    Private Sub zenOn_SetStateForAnalogRema(ByRef zRema As rema)

    'Declaration zState
    Dim zState As State

    'Intialize zState with the first state inside the passed analog rema
    Set zState = zRema.StateItem(1)

    'Sets the comparision mode to "greater"
    zState.CheckArt = 1

    'This definition constitutes the threshold value, where the alarm will be triggered
    zState.ReaAlarm = 11

    'This definition means that the system will be set back to its normal configuration, when "ReaAlarm" goes below 10 (hysteresis)
    zState.Hysterese = 1

    'User message that will be displayed when the event occurs
    zState.Text = "Limit is reached!"

    'Moreover, the first defined function will be called when the event occurs
    zState.Function = MyWorkspace.ActiveDocument.RtFunctions.Item(0)
    'The function will only be executed when the tpBitFkt is set. Additionaly the tpBitAlarm flag is set too.
    zState.Status = tpBitFkt Or tpBitAlarm

    End Sub
    [highlight]

  2. #2

    Default set variable to use Rema and link Rema by ID

    Sub rema_ID()
    
    Dim myRema As Rema
    Dim myVar As Variable
        'create a binary Rema
        Set myRema = MyWorkspace.ActiveDocument.Remas.Create(1, "myRema" & Now)
            
            If Not myRema Is Nothing Then
                'output the name and the ID
                Debug.Print myRema.DynProperties("ID")
                Debug.Print myRema.Name
                Debug.Print MyWorkspace.ActiveDocument.Remas.ItemById(myRema.DynProperties("ID")).Name
                
                Set myVar = MyWorkspace.ActiveDocument.Variables.Item(0)
                    
                    If Not myVar Is Nothing Then
                        'set "use reaction matrix" at the first variable in the project
                        myVar.DynProperties("IsRemaActiv") = True
                        'link the created reaction matrix at the variable
                        myVar.DynProperties("Rema") = myRema.DynProperties("ID")
                    End If
            End If
    
    End Sub

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •