Author Topic: Alarms messages display of different bits  (Read 1627 times)

06/25/1992

  • Newbie
  • *
  • Posts: 3
    • View Profile
Alarms messages display of different bits
« on: November 18, 2019, 03:28:03 PM »
Hi all,
I've been using AdvancedHMI for a while now and I quite like it, however, I've been struggling with finding the best way of displaying a list of Active/previously-active alarms that are triggered via Boolean bits (could be independent bools or bits of ints ex: someInt[5].4).
I've looked into DisplayListByBit and MessageListByBit but they both use a single integer and my current program has about 252 alarms (more than what a single integer can hold (16-bits)). I would appreciate your help!

Yours,
Basel

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Alarms messages display of different bits
« Reply #1 on: November 18, 2019, 05:58:42 PM »
You should try to pass your bits as integer numbers from 1 to 252.

Or just perform a single read to get all 252 bits, providing those are consecutive bits, and iterate through those bit values to see which one is True (this doesn't seem to be applicable in your case but will be left here as a suggestion for others).

For your alarming, there is a solution posted by Phrog30 which you might consider:

https://www.advancedhmi.com/forum/index.php?topic=1813.0
« Last Edit: November 19, 2019, 12:03:39 AM by Godra »

06/25/1992

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Alarms messages display of different bits
« Reply #2 on: November 19, 2019, 10:11:35 AM »
Hello, Thanks for the reply.
I looked at his example but it seems way too complicated for what I intend to do. What I have is let's say an array of bool of size 300 that represents the faults and want to display a message for every bit that is 1 with a timestamp and a number.

On another note, I found MessageListByBit has a parameter "MaxMessagesInList" which can be set to maximum of 50. Also, under "Messages", I can add lots of messages with bit numbers assigned to them accordingly and go as high as I want (I stopped at 100 messages). Doesn't that mean that I can go over DINT which is 32-bits in my case?

If I create an array of Booleans of size 300 in the PLC (let's call it "alarms[]")and use that array variable in my "PLCAddressValue" with or without the square bracket, would it work?

Phrog30

  • Guest
Re: Alarms messages display of different bits
« Reply #3 on: November 19, 2019, 03:51:36 PM »
Do you want the alarms to be retentive, maintained through power outage?  If so, I don't believe any of the native controls will work for you.

I think the best option is to use a datasubscriber2.  Then on data change add to the list and possibly text file to ride through a power outage.

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Alarms messages display of different bits
« Reply #4 on: November 19, 2019, 10:01:59 PM »
Add DataSubscriber2 to the form, add a new item to its PLCAddressValueItems collection, set this items PLCAddress to alarms[0], set the NumberOfElements to 320 (or whatever other number but remember that a byte is 8 bits). Double-click the DataSubscriber2 to get to its DataChanged event and possibly use this code:

Code: [Select]
    Private previousValue As System.Collections.ObjectModel.Collection(Of String)
    Private previousValueSet As Boolean
    Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged
        If e.ErrorId = 0 Then
            '320 Values returned for address alarms[0]
            If e.PlcAddress = "alarms[0]" Then
                If previousValueSet Then
                    For i As Integer = 0 To e.Values.Count - 1
                        If previousValue(i) <> e.Values(i) Then
                            Label14.Text = "Value of address alarms[" & i & "] has changed from " & previousValue(i) & " to " & e.Values(i)
                            'Do something that this change triggers
                            If e.Values(i) = "True" Then
                                MessageListByValue1.Value = i + 1
                            Else
                                MessageListByValue1.Value = 0
                            End If

                            previousValue(i) = e.Values(i)
                        End If
                    Next
                Else
                    'Initial read
                    previousValue = e.Values
                    previousValueSet = True
                End If
            End If
        End If
    End Sub

In this example, I have used MessageListByValue component and also a label to confirm of what bit has changed.


06/25/1992

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Alarms messages display of different bits
« Reply #5 on: December 06, 2019, 10:13:34 AM »
UPDATE: I tried adding a timer to the form and every tick it reads my variables and maps them into some vb variables so I can manipulate them and use them etc... I can say that it works fine for my application. Thanks all!