Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cws

Pages: [1] 2
1
Support Questions / Data Subscriber Question
« on: March 11, 2014, 05:17:39 PM »
Hi,

I'm trying to setup a data subscription using something like:

mSubscriptionIDs(DataSubscriberCount) = EthernetIPforCLXCom1.Subscribe("Fault[0]", 1, 1000, AddressOf SubscribedDataReturned2)

I can read from Fault[0] through Fault[15] but after that, the SubscribedDataReturned2 event doesn't get called.  I'm trying to just subscribe to one value at "Fault[93]" but can't seem to get the event to fire after "Fault[15]".

Thanks,
Chris

2
Support Questions / Re: Data Subscriber Question
« on: November 05, 2013, 01:42:03 PM »
Also, if I have to manage all of that information, should I just use the read method on a timer every 1 second like this?

values1 = EthernetIPforCLXCom1.Read("EStop_1501.O1", 1)

I know these are probably very basic questions, but it's still not clear to me when to use what methods in the software.

Thanks,
Chris

3
Support Questions / Re: Data Subscriber Question
« on: November 05, 2013, 01:29:57 PM »
You mentioned previously that using EthernetIPforCLXCom1.Subscribe was more efficient than using the DataSubscriber component but it seems I have to write a lot more code dealing with tracking the data returned to see when the values really changed, keeping track of subscription id's and then having to unsubscribe them.  It seems a lot easier to use the other component since a lot of that complexity is taken care of for you.  Other than having the issue with the event fire multiple times, is there a compelling reason to not use that one?

Thanks,
Chris

4
Support Questions / Re: Data Subscriber Question
« on: November 05, 2013, 12:11:15 PM »
Thanks for the fast reply Archie...

If I try to subscribe using something like:

SubscriptionID = EthernetIPforCLXCom1.Subscribe("Program:MainProgram.E_Stop_PB[1])", 1, 1000, AddressOf SubscribedDataReturned)

The SubscribedDataReturned continuously fires at the poll rate instead of when the data changes?  Is that right?  And I need to unsubscribe each one when the form closes?  Is there a public subscriber list to loop through or do I have to manage that?

Thanks,
Chris

5
Support Questions / Re: Data Subscriber Question
« on: November 05, 2013, 10:32:05 AM »
Sorry, didn't finish writing question before it posted.

Hi,

I'm using version 3.5.9.  If I add several Data Subscribers using code that looks something like:

For i = 1 To 8
    mobjDataSubscribers(DataSubscriberCount) = New MfgControl.AdvancedHMI.DataSubscriber
    mobjDataSubscribers(DataSubscriberCount).CommComponent = EthernetIPforCLXCom1
    mobjDataSubscribers(DataSubscriberCount).SynchronizingObject = Me
    mobjDataSubscribers(DataSubscriberCount).PLCAddressValue = "AndOn_Call_Sta." & i.ToString   '(i + 1).ToString("D2")
    AddHandler mobjDataSubscribers(DataSubscriberCount).DataChanged, AddressOf DataSubscriber_DataChanged
    DataSubscriberCount += 1
Next

The DataSubscriber_DataChanged event seems to fire twice for each change when a button is pressed.  I'm logging info to a file and doing Debug.Print and the data looks like:

PLCAddress: AndOn_Line_Stop_Sta.6 - True 11/05/2013 10:05:03 AM
PLCAddress: AndOn_Line_Stop_Sta.6 - True 11/05/2013 10:05:03 AM
PLCAddress: CONV_T2.S_RUN - False 11/05/2013 10:05:04 AM
PLCAddress: CONV_T2.S_RUN - False 11/05/2013 10:05:05 AM
PLCAddress: AndOn_Call_Sta.6 - True 11/05/2013 10:05:06 AM
PLCAddress: AndOn_Call_Sta.6 - True 11/05/2013 10:05:06 AM
PLCAddress: AndOn_Line_Stop_Sta.6 - False 11/05/2013 10:05:08 AM
PLCAddress: AndOn_Line_Stop_Sta.6 - False 11/05/2013 10:05:08 AM
PLCAddress: AndOn_Call_Sta.6 - False 11/05/2013 10:05:10 AM
PLCAddress: AndOn_Call_Sta.6 - False 11/05/2013 10:05:10 AM
PLCAddress: CONV_T2.S_RUN - True 11/05/2013 10:05:16 AM
PLCAddress: CONV_T2.S_RUN - True 11/05/2013 10:05:17 AM

When I walk through the code, it looks like the DataSubscriber_DataChanged gets fired twice for each change.

I'm I doing something wrong on my side? 

I'm watching 3 sets of data (3 x 12) and using the same DataSubscriber_DataChanged event for all of them and just distinguishing the different sets by looking at the e.PlcAddress property.  Should I be using different DataSubscriber_DataChanged events for each set?

Also, when subscribing to data, what are the pros/cons for using MfgControl.AdvancedHMI.DataSubscriber like above versus doing something like:

SubscriptionID = EthernetIPforCLXCom1.Subscribe("Program:MainProgram.E_Stop_PB[1])", 1, 14, AddressOf SubscribedDataReturned)

Is it just having to keep track of SubscriptionID's and doing "EthernetIPforCLXCom1.UnSubscribe(SubscriptionID)" in the Form Closing event?

Thanks,
Chris

6
Support Questions / Data Subscriber Question
« on: November 05, 2013, 10:13:18 AM »
I'm using version 3.5.9.  If I add several Data Subscribers using code that looks something like:

For i = 1 To 8
mobjDataSubscribers(DataSubscriberCount) = New MfgControl.AdvancedHMI.DataSubscriber
         mobjDataSubscribers(DataSubscriberCount).CommComponent = EthernetIPforCLXCom1
         mobjDataSubscribers(DataSubscriberCount).SynchronizingObject = Me
         mobjDataSubscribers(DataSubscriberCount).PLCAddressValue = "AndOn_Call_Sta." & i.ToString   '(i + 1).ToString("D2")
         AddHandler mobjDataSubscribers(DataSubscriberCount).DataChanged, AddressOf DataSubscriber_DataChanged
         DataSubscriberCount += 1
      Next

7
Support Questions / Re: Reading Bool Arrays
« on: October 10, 2013, 01:25:09 PM »
I can put "FAULT[231]" into a BasicLabel now and it seems to work.  I'll try and do some other testing with DataSubscribers and let you know.

Thanks for all of your help,
Chris

8
Support Questions / Re: Reading Bool Arrays
« on: October 10, 2013, 11:28:44 AM »
Forgot to mention that I'm using version 359.

I tried doing the DataSubcribers in code using:

For i = 231 To 238
    objDataSubscribers(DataSubscriberCount) = New MfgControl.AdvancedHMI.DataSubscriber
    objDataSubscribers(DataSubscriberCount).CommComponent = EthernetIPforCLXCom1
    objDataSubscribers(DataSubscriberCount).SynchronizingObject = Me
    objDataSubscribers(DataSubscriberCount).PLCAddressValue = "FAULT[" & i.ToString & "]"
    AddHandler objDataSubscribers(DataSubscriberCount).DataChanged, AddressOf DataSubscriber_DataChanged
    DataSubscriberCount += 1
Next

But in the DataSubscriber_DataChanged event I get the error:

Read Failed.  The particular item referenced (usually instance) could not be found, Status Code=5

Thanks,
Chris

9
Support Questions / Re: Reading Bool Arrays
« on: October 10, 2013, 10:32:42 AM »
Hi Archie,

Thanks for the quick response.

If I try to put "FAULT[231]" into a BasicLabel, it displays an error:

Read Failed.  The particular item referenced (usually instance) could not be found, Status Code=5

If I put "FAULT[0]", the label shows "False".  If I try any other values like 100 and 200, I'll get the same error as above.  If I try doing "FAULT[1]", it gets an error on this line in the EthernetIPforCLXCom.vb file saying "Arithmetic operation resulted in an overflow".

BitResult(0) = CStr((CInt(2 ^ SubscriptionList(i).PLCAddress.BitNumber) And CInt(BitResult(0))) > 0)

If I try to read doing this, it seems to work.  I can stop the program and see that values has 320 items in it with True/False:

Dim values(320) As String
values = EthernetIPforCLXCom1.Read("FAULT[0]", 320)
Dim x As String = values(0)

If I do this, it gets an error in the Read Function in EthernetIPforCLXCom.vb .

Read Failed.  The particular item referenced (usually instance) could not be found, Status Code=5

Dim valuesy(7) As String
values = EthernetIPforCLXCom1.Read("FAULT[231]", 8)
Dim y As String = values(0)

If I'm trying to do DataSubscribers in code, using something like this:

For i = 231 To 238
    objDataSubscribers(DataSubscriberCount) = New MfgControl.AdvancedHMI.DataSubscriber
    objDataSubscribers(DataSubscriberCount).CommComponent = EthernetIPforCLXCom1
    objDataSubscribers(DataSubscriberCount).SynchronizingObject = Me
    objDataSubscribers(DataSubscriberCount).PLCAddressValue = "FAULT[" & i.ToString & "]"
    AddHandler objDataSubscribers(DataSubscriberCount).DataChanged, AddressOf DataSubscriber_DataChanged
    DataSubscriberCount += 1
Next

How should I reference the PLCAddressValue?
 
Thanks,
Chris


10
Support Questions / Reading Bool Arrays
« on: October 09, 2013, 05:24:11 PM »
Hi,

I'm trying to read values that were defined as Bool Array (320).  It seems like I can do something like this in code:

Dim values(320) As String
values = EthernetIPforCLXCom1.Read("FAULT[0]", 320)
Dim x As String = values(0)

I really want to see just see 8 values, 231 - 238.  I tried using a BasicLabel control but not sure what I put in for the PLCAddress?  If I use "FAULT[0]", the label shows as "False".  If I use something like "FAULT[0].231", I get an error.  How do I reference the values for setting up DataSubcribers in code and also in controls like the BasicLabel?  I understand .NET but not much with PLC's.

Thanks,
Chris

11
Open Discussion / Re: Basic Label Question
« on: October 01, 2013, 04:30:09 PM »
With the new file, the method is back but it doesn't seem like the DataSubscriber.DataChanged event is firing now.  I was experimenting with something like:

Public objDataSubscribers(17) As MfgControl.AdvancedHMI.DataSubscriber
Private Sub ATAddOnBoard_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim i As Integer
        For i = 0 To 17
            objDataSubscribers(i) = New MfgControl.AdvancedHMI.DataSubscriber
            objDataSubscribers(i).CommComponent = EthernetIPforCLXCom1
            objDataSubscribers(i).SynchronizingObject = Me
            objDataSubscribers(i).PLCAddressValue = "WS" & (i + 1).ToString("D2") & "LineStop"
            AddHandler objDataSubscribers(i).DataChanged, AddressOf DataSubscriber_DataChanged
        Next

End Sub

Nothing was firing and then tried to just add the datasubscribers from the toolbox to the form but still couldn't get them to fire.  I put the original 358 DataSubscriber.vb file back and got the Invoke errors again but once past those, it worked.

Chris

12
Open Discussion / Re: Basic Label Question
« on: October 01, 2013, 03:41:26 PM »
Has the SynchronizingObject method changed.  It seems to be commented out in the code that you sent.

Chris

13
Open Discussion / Re: Basic Label Question
« on: October 01, 2013, 01:46:50 PM »
Thanks for the fast responses Archie.

I'm trying to use the DataSubscribers which looks like it would work.  Since I have 18 values to track, I'm trying to use one routine to manage colors and text changes for the labels sine they are basically the same except a different number being displayed.  I added an AddHandler line for each DataSubscriber in the "Form New" event so that I could manage the code from one event like this:

AddHandler DataSubscriber1.DataChanged, AddressOf DataSubscriber_DataChanged
AddHandler DataSubscriber2.DataChanged, AddressOf DataSubscriber_DataChanged
AddHandler DataSubscriber3.DataChanged, AddressOf DataSubscriber_DataChanged
...

When the form first loads I get "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." errors for each DataSubscribers.  If I go past all of the errors, it seems to work.  The DataSubscriber_DataChanged looks something like this:

  Private Sub DataSubscriber_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs)

        Dim ctl As MfgControl.AdvancedHMI.DataSubscriber = DirectCast(sender, MfgControl.AdvancedHMI.DataSubscriber)

        Try

            Dim strSection As String = ctl.PLCAddressValue.Substring(2, 2)
            Dim lbl() As Control = Me.Controls.Find("lblORASection_" & strSection, False)

            If lbl.Length = 1 Then
                If e.Values(0) = "True" Then
                    lbl(0).BackColor = Color.Red
                    lbl(0).Text = strSection & vbCrLf & "Stopped"
                Else
                    lbl(0).BackColor = Color.LimeGreen
                    lbl(0).Text = strSection & vbCrLf & "Running"
                End If
            End If
       
        Catch ex As Exception

            MessageBox.Show(ex.ToString, "HMI Error - DataSubscriber_DataChanged", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try

    End Sub

Should the AddHandler be done differently?

Thanks,
Chris

14
Open Discussion / Re: Basic Label Question
« on: October 01, 2013, 10:22:41 AM »
I tried to use DisplayMessageByValue or DisplayMessageByBit  but must be doing something wrong.  I'm getting 'Invalid Value Returned!" on both of them.  I had it working with the BasicLabel control and controlled the color through the TextChanged event but I need to show a static number on each of them and just change the color.  It seems like DisplayMessageByValue or DisplayMessageByBit should work.  I tried setting up messages for 0 = Running, 1 = Stopped in the messages collection for each control.  Right now the DisplayMessageByValue flips between "False - Invalid Value Returned!" and "(0) Running".  The DisplayMessageByBit control flips between "False - Invalid Value Returned!" and "No Messages".  In the messages collection should I be using 1 and 0 or True and False or something else?  Also, what is the difference between the TextChanged event and the ValueChanged event and when would I use one over the other?   

I'm familiar with .NET programming but not PLC's.  I'm using 3.58 of AdvancedHMI and trying to use the EthernetIPforCLXCom driver.

Thanks,
Chris

15
Open Discussion / Basic Label Question
« on: September 30, 2013, 12:59:47 PM »
Hi,

I'm trying to use the BasicLabel control to show bit flags from the PLC.  I want to be able to show each section as a number like "1", "2", "3" etc.. and just set the color based on the "0" or "1" coming from the PLC.   When a value comes back from the PLC, it shows as True or False on the label and overwrites the "1", "2", etc...  I'm I supposed to hook into the TextChanged event and put the numbers back into the Value property or have a different set of number labels overlaying the Basiclabel control?  Also, when I change the BooleanDisplay to "On/Off" or "Yes/No" it still shows "True/False".    Should I be using the BasicLabel control or something else?

Thanks,
Chris

Pages: [1] 2