Author Topic: Creating a separate thread to constantly read/Compute values?  (Read 999 times)

Zeppelin1007

  • Newbie
  • *
  • Posts: 2
    • View Profile
Creating a separate thread to constantly read/Compute values?
« on: December 17, 2014, 10:51:53 AM »
Hi guys.

First off, being a long time FactoryTalk developer, advanceHMI is FANTASTIC. it is now my go-to solution when i need something that FT cannot provide.

Such as my current project, opening an excel file, reading data out of a user selectable table, and dumping it into a PLC. I got this to work perfectly, but I'm a bit stuck on creating another thread to continuously update to my program. I'm talking using the  EthernetIPforCLXCom1.Read constantly at a set interval.

Reason being is Id like to check the progress of a process and compare it to recipe data, then throw up a popup when complete. This, and populate the standard windows progress bar control.

I had something working for a bit, but it seemed to crash and/or blast the network. Any insight guys?

Thanks in advance!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: Creating a separate thread to constantly read/Compute values?
« Reply #1 on: December 17, 2014, 11:19:25 AM »
You may want to try this using the DataSubscriber. Once you add a DataSubscriber and set the PLCAddressValue property, you can double click it to get back to the ValueChanged event handler. This event handler will also be synchronized with the UI thread.

The DataSubscriber is a wrapper around the driver subscribing mechanism, so it runs on it's own thread and will optimize with other reads than can be grouped together.
« Last Edit: December 17, 2014, 11:43:17 AM by Archie »

Zeppelin1007

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Creating a separate thread to constantly read/Compute values?
« Reply #2 on: December 17, 2014, 02:37:08 PM »
Hi Archie,


I was going with this:
Code: [Select]

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Control.CheckForIllegalCrossThreadCalls = False             'Eliminates some errors when multithreading
           Backgrounder = New Thread(AddressOf Me.BoxUPdate)           'Declaires Backgrounder as a new thread subroutine
          Backgrounder.Start()
    End Sub

with Backgrounder literally just reading and sleeping. But, this made something angry.

SO i will give your suggestion a shot.