[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?
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.