The Reaction Matrices are the most sophisticated way to deal with stati.
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
States of a REMA:
Binary Reaction Matrix state
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
Analog Reaction Matrix state
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
This is a migrated post! Originally posted on 16.08.2007 by user robertf. Please be aware that information can be outdated.