Author Topic: Make Global object  (Read 4499 times)

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Make Global object
« Reply #15 on: April 02, 2018, 10:04:35 AM »
Thanks James and Godra your help is greatly appreciated ! Everything is clear for the alarm :) And nice work James for this build !! Fire  8)

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Make Global object
« Reply #16 on: April 02, 2018, 11:58:12 AM »
Still having hard time to figured out how to fix that error in the GroupedObject, I'm newbie in vb  :-[
So it work great on launch , change page and came back and throw this exeption ;

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=La collection a été modifiée ; l'opération d'énumération peut ne pas s'exécuter.
  Source=mscorlib
  StackTrace:
       à System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       à System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       à System.Collections.Generic.List`1.Enumerator.MoveNext()
       à AdvancedHMIControls.SubscriptionHandler.SubscribedDataReturned(Object sender, PlcComEventArgs e) dans C:\Apps\Test\AdvancedHMIControls\SubscriptionHandler.vb:ligne 325
       à AdvancedHMIDrivers.EthernetIPforCLXCom.DataRecSync(Object e) dans C:\Apps\Test\AdvancedHMIDrivers\AllenBradley\EthernetIPforCLXCom.vb:ligne 291
  InnerException:

 ???
And sometimes no exeption but Invalid arguement everywhere ..!

Phrog30

  • Guest
Re: Make Global object
« Reply #17 on: April 02, 2018, 12:21:13 PM »
There are many ways to do this.  Personally, I would go the simple route which is create a new user control.  Place a basiclabel, then go to the code.  All you want to do is be able to define the PLC items, which is what this code should do.  This is an example, you will need to use your addressing.  Tagname is the base tag.  That is the property you will define in design mode.  The members are something you will hard code.

Code: [Select]
Public Class UserControl1

    Public Tagname As String

    Private Sub UserControl1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        BasicLabel1.PLCAddressValue = "" & Tagname & ".something"

    End Sub
End Class

I didn't test this, but I don't see why it wouldn't work.  It's similar to what I've done for popups, except those are forms.

James

Phrog30

  • Guest
Re: Make Global object
« Reply #18 on: April 02, 2018, 12:24:31 PM »
Make sure to ignore during design mode, unless you like that feature.  Most will want to ignore...

Code: [Select]
If Not DesignMode Then
            BasicLabel1.PLCAddressValue = "" & Tagname & ".something"
End If

Phrog30

  • Guest
Re: Make Global object
« Reply #19 on: April 02, 2018, 01:08:35 PM »
I tested and it works fine, here's the code I used:

Code: [Select]
Public Class Global_Objects_Test

    Private m_Tagname As String
    Public Property Tagname As String
        Get
            Return m_Tagname
        End Get
        Set(value As String)
            If m_Tagname <> value Then
                m_Tagname = value
            End If
        End Set
    End Property

    Private Sub Global_Objects_Test_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        If Not DesignMode AndAlso Tagname IsNot Nothing Then
            BasicLabel1.PLCAddressValue = "" & Tagname & ".Item1"
            BasicLabel2.PLCAddressValue = "" & Tagname & ".Item2"
            BasicLabel3.PLCAddressValue = "" & Tagname & ".Item3"
            BasicLabel1.PLCAddressKeypad = "" & Tagname & ".Item1"
            BasicLabel2.PLCAddressKeypad = "" & Tagname & ".Item2"
            BasicLabel3.PLCAddressKeypad = "" & Tagname & ".Item3"
        End If

    End Sub
End Class

I created a UDT with 3 strings, Item1, Item2, Item3.  Then created 3 different tags of that data type.  I was able to read the tags and use keypad to write.  Remember that if you don't use full strings (82) you will need to do something a little different.  I could have used integers or bools as well.

James

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Make Global object
« Reply #20 on: April 02, 2018, 04:40:31 PM »
Well .. I've tried that with no succes .. like I said i'm new to vb , it gave me a bunch of error  :-[
The solution of Archie is exactly what i'm looking for and straight forward ! Easy to change and build ..!

Phrog30

  • Guest
Re: Make Global object
« Reply #21 on: April 02, 2018, 05:34:13 PM »
Well .. I've tried that with no succes .. like I said i'm new to vb , it gave me a bunch of error  :-[
The solution of Archie is exactly what i'm looking for and straight forward ! Easy to change and build ..!
What errors? I'm confused, I thought you said you were getting exceptions from the code Archie gave you. That's why I showed you another way. It's the simplest approach. All you are doing in the code is dynamic plc property setting. You are letting the controls do the rest, which has already been tested thoroughly.

Maybe take screenshots of the errors or post your code, or wait on Archie, assuming you were getting exceptions and I didn't misread your post.

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Make Global object
« Reply #22 on: April 13, 2018, 08:14:04 AM »
Sorry mate ! Finaly I’ve been able..! You’re right that work perfecly !! Thank you so much :)

patrick.n

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Make Global object
« Reply #23 on: April 15, 2021, 10:19:34 AM »
NOTES ON USAGE:  Seems you can't put AHMI Controls within a container such as a TableLayoutPanel as part of your GroupObject design. 

Doing this breaks the code which concatenates the PLCAddressUDT and the PLCAddressxxx within AHMI Controls placed in the GroupObject.

I other words, seems AHMI Controls need to be "contained" by the Form or GroupObject (class) directly. They cannot be buried deeper into a hierarchy of other containers such as TableLayoutPanel.......I think this is the right terminology to use.

OTHERWISE: to use layout containers in GroupObjects, the AHMI Controls must directly reference the PLCAddress and you forget about using the PLCAddressUDT mechanism.

This renders the GroupObject less usedful - better than Cut&Pasting (at least you can still do global modification by altering just one object) - but not as flexible as RA GlobalObjects with their tag placeholders.

« Last Edit: April 15, 2021, 10:22:29 AM by patrick.n »

zach_a_ary

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Make Global object
« Reply #24 on: February 16, 2024, 03:26:21 AM »
I got up to step 10 of Archies instructions but "GroupObject" was not in my toolbox. I tried putting the downloaded file under "Controls" and then it did pop up in my toolbox but it wouldnt let me drag it down to my form.