Author Topic: Reusable popups & multiple tag values in captions  (Read 2103 times)

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Reusable popups & multiple tag values in captions
« on: December 30, 2016, 08:38:29 PM »
Hi all,

A couple more newbie questions. My SCADA background is mostly FTView, so I'm trying to figure out the AdvancedHMI way of doing a couple of things.

First, on FTView I can create reusable popups by using placeholder tags. So, for a Motor popup, my start buttons is set to operate on #1.Start, my Stop button is set to operate on #1.Stop, and so on. Then, at runtime, I call the popup and specify which PLC tag to use in place of #1 by either parameter files or just defining the tag directly when I call the popup. So I specify Motor_1, and then #1.Start becomes Motor_1.Start and so on. Can I create reusable popups somehow in AdvancedHMI?

Second thing I can do in FTView is to display multiple tag values in one text object. This would be useful in one particular example where I'm using a Click Koyo PLC and want to display a date-and-time stamp. Ideally, I'd just use system data values to concatenate a string of the date and time within the PLC, and just display that string on the HMI, but the Click Koyo is pretty limited in it's string handling, and I can't find a nice neat way to do it. So, what I'd do to get around this in FTView is just create some text, where the caption was:

"Time of Event: [year_tag]-[month_tag]-[day_tag] at [hour_tag]:[minute_tag]:[second_tag]"

So I only need one text object, not one for each value and another for each separator. Can I do something similar in AdvancedHMI?

Thanks!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Reusable popups & multiple tag values in captions
« Reply #1 on: December 30, 2016, 09:12:20 PM »
Second thing I can do in FTView is to display multiple tag values in one text object. This would be useful in one particular example where I'm using a Click Koyo PLC and want to display a date-and-time stamp. Ideally, I'd just use system data values to concatenate a string of the date and time within the PLC, and just display that string on the HMI, but the Click Koyo is pretty limited in it's string handling, and I can't find a nice neat way to do it. So, what I'd do to get around this in FTView is just create some text, where the caption was:

"Time of Event: [year_tag]-[month_tag]-[day_tag] at [hour_tag]:[minute_tag]:[second_tag]"

So I only need one text object, not one for each value and another for each separator. Can I do something similar in AdvancedHMI?
The easiest method is probably to use 6 BasicLabels, but I will describe one possible method of doing this with a single Label:

- From the All Windows Forms group in the Toolbox, add a Label to the form
- From the ToolBox, add A DataSubscriber2 to the form
- In the PLCAddressValueItems property, click the ellipsis button to get the pop up window for adding addresses
- Add an item and enter the address for each of your 6 items
- Close that dialog
- Double the DataSubscriber2 in the component tray below your form and this will take you back to the code
- Enter this code:
Code: [Select]
        If e.ErrorId = 0 Then
            Label1.Text = DataSubscriber21.PLCAddressValueItems(0).LastValue & "-" & DataSubscriber21.PLCAddressValueItems(1).LastValue & "-" & DataSubscriber21.PLCAddressValueItems(2).LastValue
        End If

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Reusable popups & multiple tag values in captions
« Reply #2 on: December 30, 2016, 09:46:15 PM »
Thanks Archie, I'll give that a try. I'm guessing the "e.ErrorID" should be "Me.ErrorID"?

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Reusable popups & multiple tag values in captions
« Reply #3 on: December 30, 2016, 10:20:53 PM »
Double click the DataSubscriber2 and then enter the code in the sub that will show (then e.ErrorId will make sense).

Visual Studio should always let you know if e.ErrorId is actually an error (at any time).


Related to your question about reusable popups, would the button right-click menu work for you? Similar to the picture in this topic:

http://advancedhmi.com/forum/index.php?topic=1562.0
« Last Edit: December 30, 2016, 10:35:29 PM by Godra »

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Reusable popups & multiple tag values in captions
« Reply #4 on: December 31, 2016, 01:15:05 AM »
Ah yes, I see where the "e" comes from now. That's working well, the only annoyance being that when the minute or second are in single digits range, it doesn't pad it with a zero - so if it's one second past 10am, the time will read as 10:0:1 instead of 10:00:01. Any ways you can think of off the top of your head to fix that? If it's a problem I'll just go back to using 6 labels, but I like the neat and tidy one-label solution.

As to the reusable popups, right clicking and selecting from a list is probably not what I'm after. Generally, the way I have it set up is so that you can click on each motor graphic and it brings up it's own popup. It's also possible (in FTView) to have two of these popups open at once. I'll look a little deeper into how that list selector works though, and see if I can use some of its tricks to do what I want, once I've got my head a little more around how all of the rest works.


Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Reusable popups & multiple tag values in captions
« Reply #5 on: December 31, 2016, 02:50:36 AM »
You can try this code:

Code: [Select]
    Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged
        If e.ErrorId = 0 Then
            Label1.Text = DataSubscriber21.PLCAddressValueItems(0).LastValue.ToString.PadLeft(2, "0") & ":" & DataSubscriber21.PLCAddressValueItems(1).LastValue.ToString.PadLeft(2, "0") & ":" & DataSubscriber21.PLCAddressValueItems(2).LastValue.ToString.PadLeft(2, "0")
        End If
    End Sub

ASF

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Reusable popups & multiple tag values in captions
« Reply #6 on: December 31, 2016, 07:27:40 AM »
Thanks, that's working perfectly! Guess it's all just a matter of getting more familiar with VB.

Happy New Year to you both!

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Reusable popups & multiple tag values in captions
« Reply #7 on: December 31, 2016, 09:34:36 AM »
Happy New Year to you and everybody else.

As for your reusable popups question, you could create a popup form control with all other controls on it and then call it from within the click events of your graphics.

The creation of this form would be somewhat similar to the first 7 posts in this topic:

http://advancedhmi.com/forum/index.php?topic=1295.0

or to this control:

http://advancedhmi.com/forum/index.php?topic=1368.0

« Last Edit: December 31, 2016, 09:39:24 AM by Godra »