Results 1 to 2 of 2

Thread: [need help] simulate PLC process

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Posts
    24

    Question [need help] simulate PLC process

    Hi,

    I need help for my project.
    I want to simulate a PLC process in VB.net which the process is running in a big loop.
    What I try to make is calling 'Subroutines' and 'Functions' in a while loop after button 'Run' is pressed and stop after button 'Stop' is pressed.

    in general, this is what I have done so far and it seems very heavy during the process. I guess that the Application.DoEvents() is the one that makes the program runs heavy.

    HTML Code:
    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
    
    btnStart.Enabled = False
    While btnStart.Enabled = False 'chkG_bUnitAuto.Checked
                SubRoutines1()                          
                Application.DoEvents()
                SubRoutines2()                   
                Application.DoEvents()
                Functions1(nValue1)            
                Application.DoEvents()
                Functions2(nValue2)                            
                Application.DoEvents()
            End While
    End Sub
    
    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
            btnStart.Enabled = True
            StopAll()
        End Sub
    Do you guys maybe know what can I do to make it simple or maybe some ideas?

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [need help] simulate PLC process

    When you say "program runs heavy", do you mean that your program uses a lot of system resources (CPU time, memory...) when running?
    Application.DoEvents does not make your program runs heavy. What makes it run heavy is Subroutine1, Subroutine2, Function1, Function2 and you need to show us the code in those methods before we can give any suggestions.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width