Hello Guest it is April 18, 2024, 11:46:06 AM

Author Topic: I want to make a runtime time counter  (Read 398 times)

0 Members and 1 Guest are viewing this topic.

I want to make a runtime time counter
« on: July 21, 2023, 09:28:59 PM »
Hi,
Since release 5000, the timer value that is returned by mc.mcCntlGetRunTime no longer stops with Feedhold.  I'm using it to track Gcode progress and predict time remaining, so I would like it to stop on feedhold.

So I figured it would be easy to make my own timer with either the scr.timer or wxTimer.  I have watched Dazthegas's videos and read all the example I can find, but it seems everyone is using them to count down and generate an event.  I just want to start a timer and pause it, and be able to read its current value out.  This seems so simple yet I haven't been able to get it working.  I'm trying to avoid putting some kind of clock tracking time accumulator in the PLC script.

Can anyone point me in the right direction?

Thanks
Re: I want to make a runtime time counter
« Reply #1 on: July 21, 2023, 11:15:53 PM »
Ok, I just realized timers are indeed for counting a period of time and taking action.  I just need to create and elapsed timer function to replace the one that was built in before.
Re: I want to make a runtime time counter
« Reply #2 on: July 23, 2023, 06:20:02 AM »
Hi, you can use wxStopWatch for this. It allows you to pause and resume

https://docs.wxwidgets.org/3.0/classwx_stop_watch.html
Re: I want to make a runtime time counter
« Reply #3 on: July 23, 2023, 06:37:41 PM »
That is exactly what I needed, thank you.

Sometimes my biggest problem is just using the wrong keyword for a search.  :-)

thanks,
Jim