Author Topic: DataSubscriber1 and BeginRead DINTArray  (Read 2604 times)

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
DataSubscriber1 and BeginRead DINTArray
« on: September 09, 2015, 05:32:14 PM »
I have a DataSubscriber1 and I set a boolean triggerbit in its PLCAddressvalue. Then in DataChanged i set BeginRead of a DINTArray[10], but it only show the first value is being read. Nothing show up on label4 and 5. TIA.


Code: [Select]
    Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged       

        EthernetIPforCLXCom1.BeginRead("TempDINTArray[0]", 3)

    End Sub

    Private MyValue As String
    Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived
       
        If e.PlcAddress = "TempDINTArray[0]" Then
            MyValue = e.Values(0)
            Label3.Text = e.Values(0)
        End If
        If e.PlcAddress = "TempDINTArray[1]" Then
            Label4.Text = e.Values(0)
        End If
        If e.PlcAddress = "TempDINTArray[2]" Then
            Label5.Text = e.Values(0)
        End If
    End Sub
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: DataSubscriber1 and BeginRead DINTArray
« Reply #1 on: September 09, 2015, 05:49:23 PM »
Since all 3 values are read with a single read, they should all return on the same call. Your code will need to be like this:
Code: [Select]
Private Sub EthernetIPforCLXCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforCLXCom1.DataReceived
       
        If e.PlcAddress = "TempDINTArray[0]" Then
            MyValue = e.Values(0)
            Label3.Text = e.Values(0)
            Label4.Text = e.Values(1)
            Label5.Text = e.Values(2)
        End If
    End Sub

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: DataSubscriber1 and BeginRead DINTArray
« Reply #2 on: September 10, 2015, 07:44:13 AM »
Make logical sense. Thank You again!
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: DataSubscriber1 and BeginRead DINTArray
« Reply #3 on: September 23, 2015, 06:03:22 PM »
Need help again, Archie.

I have everything working normal, that is a trigger bit to trigger my DataSubscriber,  then in DataSubscriber1_DataChanged I do a BeginRead and received values in EthernetIPforCLXCom1_DataReceived.  Then I sent data SQL server. Everything is working up to that point.

Then I changed the PollrateOveride to 250ms. Save and Rebuild it. Then run my app again, did not see data send to SQL server.
I look around and saw that Datasubscriber1 icon no longer there, it dissappeared.

I repeat the process with my backup copy. Again Datasubscriber1 icon dissappeared.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: DataSubscriber1 and BeginRead DINTArray
« Reply #4 on: September 23, 2015, 07:14:30 PM »
Then I changed the PollrateOveride to 250ms. Save and Rebuild it. Then run my app again, did not see data send to SQL server.
I look around and saw that Datasubscriber1 icon no longer there, it dissappeared.

I repeat the process with my backup copy. Again Datasubscriber1 icon dissappeared.
This sounds like it might be one of the quirks of the Visual Studio designer. After the DataSubscriber disappears, try this:

- In Solution Explorer, select the AdvancedHMI project
- At the top of Solution Explorer click the Show All Files icon
- Expand down the form with the DataSubscriber
- You should now see a file with designer.vb on the end of the name
- Right click that file and select View Code
- Scroll down through that code and see if you still see the DataSubscriber referenced that disappeared from the form

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: DataSubscriber1 and BeginRead DINTArray
« Reply #5 on: September 24, 2015, 08:29:03 AM »

In the MainForm.Designer.vb , I still seeing references for DataSubscriber. If using Build Solution from the menu then it's OK, only when Rebuild , then DataSubscriber will disappear.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: DataSubscriber1 and BeginRead DINTArray
« Reply #6 on: September 24, 2015, 11:21:02 AM »
Visual Studio doesn't like a Rebuild All if you have any forms open in design view. During a rebuild, since it is a source code project, all of the controls are deleted therefore they do not exist for a short period of time. During that time the designer doesn't know how to handle things since the form is populated with controls that don't exist.