Prevent one macro from starting while another runs ??

If you have a question about the software please ask it here.

Re: Prevent one macro from starting while another runs ??

Postby ger21 » Sun May 06, 2018 8:08 pm

Lets say there are 3 macros running each macro signals teh flag on. Easy so far.

NOW macro 2 ends . HOW does it know that a macro is still running and to NOT turn off teh flag.

NEXT , macro 3 ends. Same problem

Next finally Macro1 ends how will it know it is teh last macro running and to turn off teh flag??

Maybe use a table or list and each macro adds its name to teh list and when it ends remove its name from teh list. Then each macro when it ends checks teh list to see if it is teh last macro running then turns off teh flag.


You're assuming that any macro should block all other macros. I wouldn't expect that to be the case when you factor in thousands of users with different needs. They could add a single flag that meets your needs, but not someone else's.

At some point in time UCCNC has to provide a way for macro writters to able to identify when a possble confict may occur and be able to at LEAST warn users of it.


That's just not going to be possible. How is every macro, every macroloop, every plugin, and every screen going to be checked for conflicts with each other. If a user wants to use the power they are given, they have to be responsiblefor whatever may occur.
Gerry
UCCNC 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 1032
Joined: Sat Sep 03, 2016 2:17 am

Re: Prevent one macro from starting while another runs ??

Postby cncdrive » Sun May 06, 2018 9:07 pm

I knew this is a complicated problem. :)
We could easily disable button macro calls while one other is running, but this could be a problem for tasks where one macro starts something and another macro button is used to tell that to stop or to do something else, because in this case 2 buttons with 2 macros has to be able to run the same time, othewise the second button can't do an action to tell the first to stop or to do something else.
So I think that simply letting one macro to run on button calls is not a good solution because it will limit what the programmer can do with the button macros.

My idea is that we could make a boolean array with one item for each button macro codes 20000 to 21999.
When one macro starts running it could set it's own boolean variable, e.g. macrorunning[20000] is set to true when the macro starts running and set to false when it stops running.
The programmer could then check this variable for example at the beginning of the macro, that if the variable is true then return and not run the macro if the task is to keep only one of these macros running.
Also the variable of the other macros could be checked from a macro, e.g. if the requirement for macro 20000 is that when it is running then macro 20001 should not start running then in macro 20001 code the macrorunning[20000] could be checked. The programmer could then have a freedom to make checks on whichever macro or macros running state they want and need to check and then decide in the code what to do when a macro is running when the user tries to run it.
What do you guys think about this idea? Any issues you see about it?
cncdrive
Site Admin
 
Posts: 2104
Joined: Tue Aug 12, 2014 11:17 pm

Re: Prevent one macro from starting while another runs ??

Postby Vmax549 » Sun May 06, 2018 9:24 pm

Will UCCNC automatically register teh macro to teh array or will teh users have to register it by scripting??

It UCNC does teh work then it would be fine from what I see at this time. IF teh programers has to do the work Most won't bother so the feature is of little value.

Can you exclude MacroLoops?? As a soft PLC they must run reguardless.

(;-) TP
Vmax549
 
Posts: 1102
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Prevent one macro from starting while another runs ??

Postby cncdrive » Sun May 06, 2018 9:33 pm

Terry, yes I thought to make the UCCNC to set/reset the variables based on if the macro is running or not.
I will think this through a bit more in depth soon. But if you guys have ideas about it then please post it.
cncdrive
Site Admin
 
Posts: 2104
Joined: Tue Aug 12, 2014 11:17 pm

Re: Prevent one macro from starting while another runs ??

Postby Vmax549 » Sun May 06, 2018 9:43 pm

Balazs, Can you exclude Plugins and MacroLoops as they can be background apps and run all teh time.

Other than that it sounds fine.

(;-) TP
Vmax549
 
Posts: 1102
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Prevent one macro from starting while another runs ??

Postby Vmax549 » Sun May 06, 2018 9:46 pm

HI Gerry,
You're assuming that any macro should block all other macros. I wouldn't expect that to be the case when you factor in thousands of users with different needs. They could add a single flag that meets your needs, but not someone else's.


I am not assuming anything. As a macro writer you have ZERO information as to what else may be running and YOU have to make teh choice as to IF you allow YOUR macro to run if there is a posibililty of conflict. OR at least warn the user that a conflict exists.

That's just not going to be possible. How is every macro, every macroloop, every plugin, and every screen going to be checked for conflicts with each other. If a user wants to use the power they are given, they have to be responsible for whatever may occur.


Plugins and macro loops SHOULD be excluded as they are run in teh background for teh most part.
How is teh macro creator going to know of a possible problem IF they have no way of knowing there MAY be a conflict.

At least this way you stand a snowballs chance of avoiding a possible conflict of macros. It is much better than stumbling around in a dark room and ONLY realizing that you have hit teh wall with your head AFTER teh bump on your head starts hurting.

(;-) TP
Vmax549
 
Posts: 1102
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Prevent one macro from starting while another runs ??

Postby cncdrive » Sun May 06, 2018 9:47 pm

Yes, I can exclude those. I think it could be useful only if the calls from buttons and I/O triggers would set those variables.
Or maybe make 2 arrays one for only the buttons and I/O triggers and one for all calls and runs.
I will think this through in more depts though, because maybe I forgot to think about something now. And if you guys have any ideas about it please let me know.
cncdrive
Site Admin
 
Posts: 2104
Joined: Tue Aug 12, 2014 11:17 pm

Re: Prevent one macro from starting while another runs ??

Postby Vmax549 » Mon May 07, 2018 2:30 am

The only other thing I can think of is to be able to read teh array and write a debug file and save it.

(;-) TP
Vmax549
 
Posts: 1102
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: Prevent one macro from starting while another runs ??

Postby dezsoe » Mon May 07, 2018 5:08 am

The needs are soooooooo different! :)

I've never missed the state of general macros but the state of macroloops. So, this is the difference: you all want to exclude the state of macroloops from that array and I need only them! :) (A simple example: I have some controls on the screen for my test VFD. All these controls should know if the macroloop which transfers data to/from Modbus plugin is running.)
dezsoe
 
Posts: 492
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Prevent one macro from starting while another runs ??

Postby Vmax549 » Mon May 07, 2018 11:08 am

HI Dezsoe IF you have a need then yes lets include macroloops and plugins as well. I can certainly work around that.

That is why we have these discussions.

(;-)TP
Vmax549
 
Posts: 1102
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

PreviousNext

Return to Ask a question from support here

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron