Showing results 1 to 5 of 5

Thread: Set variable alarm group

  1. #1
    Join Date
    19.05.2010
    Posts
    17

    Default Set variable alarm group

    It's possible to set variable alarm group using vba?
    I've tried the solution below, but with no result.

    obVarAlarm.SubItem(jj).EdLimitItem(cc).Group = MyWorkspace.ActiveDocument.DynProperties("AlarmGroups[PLC1].Id")

    Here is the entire code:

    Set obVarAlarm = MyWorkspace.ActiveDocument.Variables.CreateVar(tbName.Text & "_Alarm", zDrivers.Item(1), 17, m_obVarType)
                If (Not obVarAlarm Is Nothing) Then
                    Dim jj As Integer
                    'Activate subitem and set identification
                    For jj = 0 To obVarAlarm.SubItemCount - 1
                        obVarAlarm.ActivateSubItem (jj)
                        obVarAlarm.SubItem(jj).Tagname = Replace(obVarAlarm.SubItem(jj).name, ".", " ")
                        'Set alarm formula for every attribute different from Running Status
                        If (InStr(1, obVarAlarm.SubItem(jj).name, "Running Status") = 0) Then
                            obVarAlarm.SubItem(jj).CreateDynProperty ("MathInfo[0].SourceVars")
                            obVarAlarm.SubItem(jj).DynProperties("MathInfo[0].SourceVars[0].Title") = obVar.SubItem(jj).name
                            obVarAlarm.SubItem(jj).CreateDynProperty ("MathInfo[0].SourceVars")
                            obVarAlarm.SubItem(jj).DynProperties("MathInfo[0].SourceVars[1].Title") = obVarEnable.name
                            'define type of formular (6208 = Statistik)
                            obVarAlarm.SubItem(jj).DynProperties("MathInfo[0].Type") = 6208
                            'insert formular
                            obVarAlarm.SubItem(jj).DynProperties("MathInfo[0].Formula") = "NOT(X01) AND X02"
                            Dim cc As Integer
                            'Set Limit param
                            For cc = 0 To obVarAlarm.SubItem(jj).EdLimitCount - 1
                                If obVarAlarm.SubItem(jj).EdLimitItem(cc).LimitValue = 1 Then
                                    obVarAlarm.SubItem(jj).EdLimitItem(cc).Alarm = 1
                                    obVarAlarm.SubItem(jj).EdLimitItem(cc).AlarmAck = 1
                                    obVarAlarm.SubItem(jj).EdLimitItem(cc).Color = 255
                                    obVarAlarm.SubItem(jj).EdLimitItem(cc).Blinking = 1
                                    Debug.Print MyWorkspace.ActiveDocument.DynProperties("AlarmGroups[PLC1].Id")
                                    obVarAlarm.SubItem(jj).EdLimitItem(cc).Group = MyWorkspace.ActiveDocument.DynProperties("AlarmGroups[PLC1].Id")
                                End If
                            Next cc
                        End If
                    Next jj
                End If

  2. #2
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default Re: Set variable alarm group

    it works like this:

    MyWorkspace.ActiveDocument.Variables.Item("MyVar").EdLimitItem(0).DynProperties("GroupName") = "YourAlarmgroupName"

    regards,
    herbert

  3. #3
    Join Date
    19.05.2010
    Posts
    17

    Default Re: Set variable alarm group

    Thank you very much for you replay. For you information I've seen that also my solution works.
    I made a mistake watching limit number. I checked the wrong limit number with no alarm flag active.

  4. #4
    Join Date
    04.04.2011
    Posts
    5

    Default AW: Re: Set variable alarm group

    Quote Originally Posted by herberto View Post
    it works like this:

    MyWorkspace.ActiveDocument.Variables.Item("MyVar").EdLimitItem(0).DynProperties("GroupName") = "YourAlarmgroupName"

    regards,
    herbert
    Hello.
    I using your example in my code, but it isn't work in runtime. Runtime close with error message. Version 6.51

    Public Sub ChangeLimitStatus()
        For i = 1 To 2
            Status = thisProject.Variables.Item("limitstatus[" & i & "]").Value
            If Status = 0 Then
                Tagname = thisProject.Variables.Item("limitstatus[" & i & "]").Tagname
                'thisProject.Variables.Item("" & Tagname).EdLimitItem(0).DynProperties("GroupName") = "OffGroup"
                'thisProject.Variables.Item("" & Tagname).EdLimitItem(1).DynProperties("GroupName") = "OffGroup"
                MsgBox (thisProject.Variables.Item("" & Tagname).EdLimitItem(1).DynProperties("GroupName"))
            ElseIf Status = 1 Then
                Tagname = thisProject.Variables.Item("limitstatus[" & i & "]").Tagname
                thisProject.Variables.Item("" & Tagname).EdLimitItem(0).DynProperties("GroupName") = "OnGroup"
                thisProject.Variables.Item("" & Tagname).EdLimitItem(1).DynProperties("GroupName") = "OnGroup"
                MsgBox (thisProject.Variables.Item("" & Tagname).EdLimitItem(1).DynProperties("GroupName"))
            End If
        Next i
    End Sub

  5. #5

    Default Re: Set variable alarm group

    Hi maryanp,

    This code is for execution in the zenon editor only.

    Best regards,
    Mark

Similar Threads

  1. Replies: 1
    Last Post: 2nd August 2011, 10:21
  2. Recipe Group Manager (RGM)
    By robertf in forum VBA
    Replies: 2
    Last Post: 2nd March 2010, 16:21
  3. alarm status from variable
    By westbaaam in forum VBA
    Replies: 5
    Last Post: 7th October 2009, 05:43
  4. Status variable for alarm areas
    By hicom in forum zenon Supervisor
    Replies: 2
    Last Post: 24th February 2009, 09:56
  5. Alarm Status Line and Alarm List
    By tomaslipa in forum zenon Supervisor
    Replies: 1
    Last Post: 21st January 2009, 12:02

Posting Rules

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