Create new Named Parameter

More
25 Nov 2019 17:08 #151236 by Vmax549
I am working to create a new Named Parameter #<dt> which will be the current date and time.

I can create a new Param with this script with return as a number, That part works
def _dt(self, *args):
return 123456
(DEBUG, #<_dt>) prints out as 123456

BUT what I need is for return to be DateTime +"%m%d%y%h%m%s" which would be something like 11252019122930

The value I get for datetime is a modual not an int or str so the RETURN will not except that part.

ANY ideas on how to make that work ?

(;-) TP
The following user(s) said Thank You: Clive S, Leon82

Please Log in or Create an account to join the conversation.

More
26 Nov 2019 00:28 #151263 by Vmax549
Replied by Vmax549 on topic Create new Named Parameter
OK I finally was able to get teh Datetime to ouput a number string such as 11252019180526 which is correct . BUT I am not sure what type of number it is string? int ? float? double?

The new parameter feature displays it as ###### when I send it to teh status line with (DEBUG, #<dt>)

I am ssuming teh number format is not correct for teh application ??

(;-) TP

Please Log in or Create an account to join the conversation.

More
28 Nov 2019 20:01 #151451 by andypugh
Replied by andypugh on topic Create new Named Parameter
A parameter must be numeric. They are actually double-precision float, but it is likely to be OK to set the value to an int.

Python ought to be happy to convert your date string to an int. using int()

Please Log in or Create an account to join the conversation.

More
28 Nov 2019 23:55 #151464 by Vmax549
Replied by Vmax549 on topic Create new Named Parameter
Actually PP does have a problem somewhere converting teh String to and INT().

It seems that LinuxCNC only understands a float value. I can convert teh string to float just fine but that leaves a number like 11282019.00000. IF I then try to conver that to INT() it boggs down PP to a crawl. It takes 10 secs to exit teh MDI and 30 secounds to exit PP. Remove the INT() conversion and it goes back to normal response to commands.

The idea for this function was to be able to engrave teh manf date on a part . The number would look like this 112820191805. Then use teh G47 engrave function to cut it. BUT any way I have been able to get the datetime value out of python and into PP it has been like 112820191805.00000 and that will not work with theG47 function or be exceptable as a DateTime value.

I am still working on it but do not see a light at the end of the tunnel.

(;-) TP

PP already has a sequential S/N G47 fucntion that works ok. For QA tracking I needed teh Manf date time

Please Log in or Create an account to join the conversation.

More
29 Nov 2019 00:15 #151465 by smgvbest
Replied by smgvbest on topic Create new Named Parameter
As I’ve stated many times pay attention to where you’re doing calls like this. If you’re doing it in the 50 ms timing loop things are very critical in there that it completes within 50 ms. Path pilot already has a bunch of stuff that takes a lot of that time. It’s possible the int conversion is pushing it over 50 ms so the service routine is unable to complete. That would cause the issue you’re saying.
Look through the code and make sure you’re not in that 50 ms timing loop. That would be my advice to you

That int conversion is a python thing not a path pilot thing

Please Log in or Create an account to join the conversation.

More
29 Nov 2019 00:57 #151468 by Vmax549
Replied by Vmax549 on topic Create new Named Parameter
Here is the section in PP I am working in. Create named parameter.

def _dt(self, *args):
import datetime
dt = float(datetime.datetime.now().strftime( "%m%d%Y%H%M"))
return dt

There are no signs in that section telling me it is a 50ms section (;-) I have no idea what sections are. And yes I understand that the INT() is a Python thing. I also read in the LinuxCNC and PathPilot manual that both only understand a float value. That seems to imply that they may not understand what a Integer or string is ??

(;-) TP

Please Log in or Create an account to join the conversation.

More
29 Nov 2019 00:59 #151469 by Vmax549
Replied by Vmax549 on topic Create new Named Parameter
OOPS I forgot to tell you it is in namedparams.py.

(;-) TP

Please Log in or Create an account to join the conversation.

More
29 Nov 2019 01:06 #151470 by smgvbest
Replied by smgvbest on topic Create new Named Parameter
which PP source file has that definition been added and where in that file?

first thing if PP is calling that definition, don't do a import within the definition. you'r importing it every time its call, that's disk IO and is the slowest thing you can do.

LinuxCNC specification decides how the named parameter should pass data. you have to adhere to the specification. PP also has to adhere to same specification.

In the program flow in the PP gui is a section names 50ms_timer of similar. many things are called from it. so you have to trace your program to find out if your in that loop.

Please Log in or Create an account to join the conversation.

More
29 Nov 2019 01:46 #151471 by Vmax549
Replied by Vmax549 on topic Create new Named Parameter
That would be well outside my paygrade (;-).

BUT I did solve teh problem. Reading back in teh manual PP has NO idea what an int() is it ONLY understands float values SO I had to inject the datetime value BEFORE it got to teh Gcode side of teh script and from there it works fine.

It can engrave the Date Time from a G47 call now.

ManfDate: 112820192045
S/N: 0000012345

Thanks for all the insight on LinuxCNC, It is a big help.

(;-) TP

Please Log in or Create an account to join the conversation.

More
29 Nov 2019 14:38 #151505 by andypugh
Replied by andypugh on topic Create new Named Parameter
I can't help feeling that you might be doing this the wrong way.

A one-time call to a User M-code that returned the date/time/serial would be a lot more efficient.

Have you considered what happens is the time changes during the engraving?

For interest you might want to look at some G-code I wrote that engraves numbers without using any external fonts or CAM:

forum.linuxcnc.org/20-g-code/27169-g-cod...numbers-on-cylinders

It's not directly usable in your case, I suspect, as it uses a rotary axis.

Please Log in or Create an account to join the conversation.

Moderators: cncbasher
Time to create page: 0.090 seconds
Powered by Kunena Forum