Hello Guest it is March 28, 2024, 09:56:52 PM

Author Topic: How to get the current subroutine file name?  (Read 14045 times)

0 Members and 1 Guest are viewing this topic.

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: How to get the current subroutine file name?
« Reply #20 on: July 19, 2010, 07:27:00 PM »
I don't mean to hijack this topic but "LoadRun" has been freezing up Mach for me...is this happening to anyone else?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to get the current subroutine file name?
« Reply #21 on: July 19, 2010, 08:22:57 PM »
Sometimes it runs sometimes it does not run. IF it freezes it is during the REGEN on load.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to get the current subroutine file name?
« Reply #22 on: July 19, 2010, 08:34:29 PM »
Jason, I looked back through some old trouble notes, try this

Loadrun"C:\mach3\Gcode\Filename.tap"
While Isloading()
Sleep(1000)
Wend

IT seems that mach tries to hop out of VB before the fileload is complete.

Just a thought
Re: How to get the current subroutine file name?
« Reply #23 on: July 19, 2010, 08:45:41 PM »
Terry, Jason,

This is related to the LoadRun topic - below is a little routine I've been using to sync up with the regen operation.
You may find this useful.
DoOEMButton(MachSimRoutine)
call WaitForSimFinish()   


Const RegenInProcessLED          = 179   ' On during regen & Sim process

Sub WaitForSimFinish()
   ' the call to start the mach SimRoutine is not synchrounous - in V3 it starts off a separate process that does the mach sim
   ' this routine attempts to wait until the sim routine is finished.
   '
   ' ok this is an imperfect routine in that there is a potential timing hole.
   ' not much we can do since mach does not provide semaphores or locks for async operations.
   
   ' the "RegenLED" is supposed to be on while the regen (and Sim) operation is in process and then
   ' it goes off when the process finishes.
   ' we wait for the LED to come on - that should mean that either
   ' a) the sim process is in progress, or
   ' b) the sim process finished before we had a chance to see it was in progress
   ' then we wait for the LED to go off - that should mean the process is completed.
   
   'message "starting sim wait"
   While not CBool(GetOEMLED(RegenInProcessLED))
      ' process is not running, wait for it to start
      sleep(10)   ' we want at tighter loop here
      'message "waiting for led to go ON"
   Wend
   
   'sleep 10
   'message "waiting for end transition"
   'sleep 10
   
   ' ok the process started, wait for it to end
   While cBool(GetOEMLED(RegenInProcessLED)) 
      ' wait for process to finish
      'message "waiting for sim to end"
      sleep(100)
   Wend
   Sleep (100)   ' add a bit of pad time
   'message "sim ended"
   
   ' ok, best we can tell, the process started and then ended, let's return to the caller
   Exit Sub
End sub
Author of the MachStdMill Extensions for Mach3
www.CalypsoVentures.com
Re: How to get the current subroutine file name?
« Reply #24 on: July 19, 2010, 09:17:05 PM »
This was my first attempt but it did work in a dry run.( Note: haven't tried to cut anything yet)

Dim fname1,fname2,fname3,fname4,fname5 As String

fname1 ="c:\mach3\gcode\roadrunner.tap"
fname2 ="c:\mach3\gcode\airfoil.tap"
fname3 ="c:\mach3\gcode\test55.tap"
fname4 ="c:\mach3\gcode\tt.txt"
fname5 ="c:\mach3\gcode\signA1.tap"

For x = 1 To 5

If x = 1 Then loadfile(fname1)
If x = 2 Then loadfile(fname2)
If x = 3 Then loadfile(fname3)
If x = 4 Then loadfile(fname3)
If x = 5 Then loadfile(fname3)
message(filename)

While Isloading()
Sleep(5000)
Wend

runfile()

Sleep(2000)

While IsMoving()
Sleep(2000)
Wend

Next x
message("thats all folks")

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to get the current subroutine file name?
« Reply #25 on: July 19, 2010, 09:18:23 PM »
Thanks Dave I will give it a spin,(;-)

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to get the current subroutine file name?
« Reply #26 on: July 19, 2010, 09:49:03 PM »
That is a really good idea YA-NVR. It just needs alittle more work.

Perhaps  use teh question as a front end to load the filenames on the fly

Fname1= Question"File1 name?"
etc
etc

Next how are you going to deal with the fixture offsets between files?

Maybe another question session?

File1OFFSET = Question"FIle1 Fixture#?"


NOTE: You also need to plan on a way to break OUT of the routine in the event you need to STOP IT. I just tried and it was NOT pretty Crashed mach to get out.


Make a screen button to start the process.  VERY GOOD idea. (;-)

 I think there is a spot available over in the MACH Tool Box for a good AUTO BATCH LOADER (;-)

Might want to start a new thread to continue

« Last Edit: July 19, 2010, 10:00:16 PM by BR549 »

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: How to get the current subroutine file name?
« Reply #27 on: July 21, 2010, 03:15:09 AM »
Thank you Dave, Terry,  Ya-Nvr-No  and everyone

This seems to work... the reason I took out wait for the regen LED to come on is in some cases the file is aready loaded and that would cause the script to get stuck.

Ya-Nvr-No code looks good cept for if the user Feedholds the current loaded file or other cases that the machine is not moving could cause some issues.

Code: [Select]
LoadFile"c:\mach3\gcode\roadrunner.tap"

DoOEMButton(MachSimRoutine)

Call WaitForSimFinish()  

Const RegenInProcessLED          = 179   ' On during regen & Sim process

Sub WaitForSimFinish()

      sleep(10)   ' we want at tighter loop here

  
   'sleep 10
   'message "waiting for end transition"
   'sleep 10
  
   ' ok the process started, wait for it to end
   While CBool(GetOEMLED(RegenInProcessLED))  
      ' wait for process to finish
      'message "waiting for sim to end"
      sleep(100)
   Wend
   Sleep (100)   ' add a bit of pad time
   'message "sim ended"
  
   ' ok, best we can tell, the process started and then ended, let's return to the caller
  
     runfile()
   Exit Sub

End Sub

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to get the current subroutine file name?
« Reply #28 on: July 21, 2010, 06:43:38 PM »
HIya Jason glad you got it working, I think the auto loader was meant for unatended use where you load up a batch of programs and walk away.  Any interaction beyound that is TRICKY. Even just stopping the routine can be tricky(;-) Working on that part. I ran another long test today and it is due to finish about 8am tommorrow. So far so good.

The next test will be to see IF it can handle programs with SUBs. Then test for Users macros  That ought to be interesting

(;-)