These modules can be put in the Modules directory. So I would suggest implementing these state machines in LUA modules. Now, your PLC script is going to get hairy looking real fast. Loop mcCntlGetState() until no longer idle. Here is a pseudo code representation of a simple state machine Then determine the completion by looking at the sate of the machine with mcCntlGetState(). do not use mcCntlGcodeExecuteWait() but rather use mcCntlGcodeExecute(), which return immediately. Do not wait on the G code to finish in the script, but rather let the G code interpreter launch the movement asynchronously. Then the PLC script should watch that and launch the LUA co-routine or start a state machine that is implemented in the PLC script.Īlso, use the G code interpreter as a means to offload script duties that require movement. Instead of doing the whole long running code in a button script, just use the button script to set a flag. How do you know it is done? The machine state will become idle. The end result will be a script that is launched from a new thread and return control immediately to the Windows event loop. I would suggest developing and debugging the script first before adding the -PRIVATE line. To make a script "private", simply put -PRIVATE as the first line of the script. It will NOT have access to any of the global function in the screen scripts! However, you can load a module and run module code in them. A private script basically launches a thread to run the script. I won't go into LUA co-routines, as that is a subject all of its' own.ĭepending on how complex the operation that you want to do it, you may be able to do the complete operation in a private script. So how do you do that? Typically, is it implemented as a state machine in the PLC script. So long running code WILL prevent screen refreshes (DRO updates) etc. If you click a button, that is an event that needs to run to completion before another event is processed. Windows only supports ONE event loop for a program. Don't do long running code in the event scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |