Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 12:37:06 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  How to get the current subroutine file name?
Pages: « 1 2 3   Go Down
Print
Author Topic: How to get the current subroutine file name?  (Read 1302 times)
0 Members and 2 Guests are viewing this topic.
zealous
Active Member

Offline Offline

Posts: 486



View Profile WWW
« Reply #20 on: July 19, 2010, 06: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?
Logged

Regards, Jason Blake

www.Fusioncnc.com
BR549
Active Member

Offline Offline

Posts: 2,553


View Profile
« Reply #21 on: July 19, 2010, 07:22:57 PM »

Sometimes it runs sometimes it does not run. IF it freezes it is during the REGEN on load.
Logged
BR549
Active Member

Offline Offline

Posts: 2,553


View Profile
« Reply #22 on: July 19, 2010, 07: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
Logged
DaveCVI
V4 Screen Contributor

Offline Offline

Posts: 532



View Profile WWW
« Reply #23 on: July 19, 2010, 07: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
Logged

Author of the MachStdMill Extensions for Mach3
www.CalypsoVentures.com
Ya-Nvr-No
Active Member

Offline Offline

Posts: 268


Scuptris 3D


View Profile
« Reply #24 on: July 19, 2010, 08: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")
Logged
BR549
Active Member

Offline Offline

Posts: 2,553


View Profile
« Reply #25 on: July 19, 2010, 08:18:23 PM »

Thanks Dave I will give it a spin,(;-)
Logged
BR549
Active Member

Offline Offline

Posts: 2,553


View Profile
« Reply #26 on: July 19, 2010, 08: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, 09:00:16 PM by BR549 » Logged
zealous
Active Member

Offline Offline

Posts: 486



View Profile WWW
« Reply #27 on: July 21, 2010, 02: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:
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
Logged

Regards, Jason Blake

www.Fusioncnc.com
BR549
Active Member

Offline Offline

Posts: 2,553


View Profile
« Reply #28 on: July 21, 2010, 05: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

(;-)
Logged
Pages: « 1 2 3   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!