Save / Log "Print Message" to file

More
4 years 11 months ago #226112 by +Jan+
Thank you for your effort. I have implemented the changes and tried them out. Everything works fine as long as no macro calls are in game.Unfortunately, since I use the remap command with macro call for my manual tool change, the current solution does not work: 
If the required tool (Tool 9) is not in the spindle at cycle start, only the file name of the tool change macro with timestamp appears in the log file. The success is not logged.
If the tool (tool 9) is already in the spindle, the start is logged with the actual file name. At the first tool change (tool 11) success is logged and then nothing more.

Here the G Code file I used for evaluation:
Code:
N0010 (Filename: probekreis.ngc) N0020 (Post processor: EMC_G64_REV00_dyn_wmsg.scpost) N0030 (Date: 10/11/2021) N0040 G21 (Units: Metric) N0050 G40 G90 N0060 F1 N0070 (Part: probekreis) N0080 (Operation: Outside Offset, STANDARD, T9: Fraeser, 6 mm, 0 mm Deep) N0090 G64P0.025 N0100 M6 T9  (Fraeser, 6 mm) N0110 G00 Z6.0000 N0120 M03 S24000 N0130 X19.7990 Y19.7990 N0140 Z1.5000 N0150 G01 Z1.0000 F2000 N0160 G03 X19.7990 Y19.7990 I-19.7990 J-19.7990 F3800.0 N0170 G00 Z6.0000 N0100 M6 T11  (Fraeser, 6 mm) N0110 G00 Z6.0000 N0120 M03 S24000 N0130 X19.7990 Y19.7990 N0140 Z1.5000 N0150 G01 Z1.0000 F2000 N0160 G03 X19.7990 Y19.7990 I-19.7990 J-19.7990 F3800.0 N0170 G00 Z6.0000 N0100 M6 T9  (Fraeser, 6 mm) N0110 G00 Z6.0000 N0120 M03 S24000 N0130 X19.7990 Y19.7990 N0140 Z1.5000 N0150 G01 Z1.0000 F2000 N0160 G03 X19.7990 Y19.7990 I-19.7990 J-19.7990 F3800.0 N0170 G00 Z6.0000 N0180 M05 N0190 M05 M30

Best wishes

Jan

Please Log in to join the conversation.

More
4 years 11 months ago #226124 by nkp
need your file remap

Please Log in to join the conversation.

More
4 years 11 months ago #226126 by nkp
instead of the file currently loaded into task(s.file),
we must take the file loaded only initially (loaded_file)
 
so

        try:
            count = 0
            for line in open(loaded_file).xreadlines(): count += 1
            vars.len_program.set(count)

            fl = open('/home/nkp/emc2/logfile', "a")
            lnf = len(os.path.basename(loaded_file))
            fl.write(os.path.basename(loaded_file) + (28-lnf)*' ' + time.ctime() + "\n")       
            fl.close()        
        except :
            print "nkplogerror"
ps
probably this does not solve the problem

Please Log in to join the conversation.

More
4 years 11 months ago #226133 by +Jan+
Gave it a try, the result is following:
Code:
probekreis.ngc              Thu Nov 11 20:38:36 2021 # Logged on Cycle Start successful                  Thu Nov 11 20:39:22 2021 #Logged after end of first Tool Change

Than there is nothing more logged. Attached you can find my remap code (i can translate to english if neccesary)

Best wishes

Jan 

Attachment not found

Please Log in to join the conversation.

More
4 years 11 months ago #226135 by nkp
Warning: Spoiler!

Please Log in to join the conversation.

More
4 years 11 months ago #226136 by +Jan+
Haha so german is ok?!

Please Log in to join the conversation.

More
4 years 11 months ago #226137 by nkp
the translator doesn't care =)

Please Log in to join the conversation.

More
4 years 11 months ago #226141 by nkp
do not read line number while subroutine
================================

o<messen> sub
m64p0
#1700=44            (Wechsel X Position)
#1701=0        (Wechsel Y Position)
...
...
m65p0
o<messen> endsub
M2
===============================================
    def update(self):


        if vars.len_program.get() and not self.stat.dout[0]:
            if self.stat.motion_line > (vars.len_program.get() - 4):
                vars.len_program.set(0)
                try:
                    fl = open('/home/nkp/emc2/logfile', "a")
                    fl.write("successful" + 18*' ' + time.ctime() + "\n")       
                    fl.close()        
                except :
                    print "nkplogerror"

==================
 it work for me with your gcode

Please Log in to join the conversation.

More
4 years 11 months ago #226160 by +Jan+
Very creative approach. I put the M64Pxx on an output that I don't use. Seems to work fine so far. Thanks a lot!

I left "user_live_update() " in the code:
Code:
def update(self): if not self.running.get(): return try: self.stat.poll() except linuxcnc.error, detail: print "error", detail del self.stat return if ( (self.stat.motion_mode == linuxcnc.TRAJ_MODE_COORD) and (self.stat.task_mode == linuxcnc.MODE_MANUAL) ): set_motion_teleop(1) if ( (self.stat.motion_mode == linuxcnc.TRAJ_MODE_TELEOP) and not vars.teleop_mode.get() ): vars.teleop_mode.set(1) # CHANGES FOR LOGFILE if vars.len_program.get() and not self.stat.dout[10]: if self.stat.motion_line > (vars.len_program.get() - 4): vars.len_program.set(0) try: fl = open('/home/cnc/linuxcnc/logfile', "a") fl.write("successful" + 18*' ' + time.ctime() + "\n") fl.close() except : print "nkplogerror" user_live_update() # CHANGES FOR LOGFILE

Is this correct? Dangerous copy and paste...

Best regards

Jan

Please Log in to join the conversation.

More
4 years 11 months ago #226191 by nkp
This will not work  user_live_update()
This is for the file .axisrc
===================
Code:
 
Warning: Spoiler!

Please Log in to join the conversation.

Time to create page: 0.069 seconds
Powered by Kunena Forum