Hello Guest it is March 29, 2024, 08:58:11 AM

Author Topic: loading and running 2 files  (Read 4671 times)

0 Members and 1 Guest are viewing this topic.

Offline Bill_O

*
  •  563 563
    • View Profile
loading and running 2 files
« on: March 19, 2009, 05:52:36 PM »
Below is my code for opening then running 2 g-code files. The Run Button code will run either 2 or 1 depending on led#1110. I hope someone can find it useful.
Bill

Load Button

If GetUserLED (1110) = 1 Then
DoOEMButton (216)
While IsLoading()
Wend
cutfile = (FileName())
SetUserLabel (2,cutfile)
DoOEMButton (216)
While IsLoading()
Wend
camerafile = (FileName())
SetUserLabel (1,camerafile)
Else
DoOEMButton (216)
While IsLoading()
Wend
cutfile = (FileName())
SetUserLabel (2,cutfile)
camerafile = "None"
SetUserLabel (1,camerafile)
End If 



Run Button

If GetUserLED (1110) = 1 Then
If GetUserLED (1112) = 0 Then
SetUserLED (1111,1)
camerafile = GetUserLabel(1)
LoadFile (camerafile)
While IsLoading()
Wend
Sleep (1000)
DoButton (0)
While IsMoving()
Sleep (2000)
Wend
Sleep (5000)
SetUserLED (1111,0)
SetUserLED (1112,1)
Sleep (100)
End If
If GetUserLED (1112) = 1 Then
cutfile = GetUserLabel(2)
LoadFile (cutfile)
While IsLoading()
Wend
Sleep (1000)
DoButton (0)
While IsMoving()
Sleep (2000)
Wend
Sleep (5000)
SetUserLED (1112,0)
Sleep (100)
End If
Else
SetUserLED (1112,1)
Sleep (1000)
DoButton (0)
While IsMoving()
Sleep (2000)
Wend
Sleep (5000)
SetUserLED (1112,0)
End If

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: loading and running 2 files
« Reply #1 on: March 20, 2009, 09:52:29 AM »
Hey Bill thank you for sharing this. May I ask a favor? could you also document
or explain your code and what it is doing so others may learn new stuff?
I did an example using your code below, please correct if you dont mind.

If GetUserLED (1110) = 1 Then           'The I wanna use a dual Gcode LED
   If GetUserLED (1112) = 0 Then      'If I am not running the 2cd file LED
      SetUserLED (1111,1)      'I am running the 1st file LED
      camerafile = GetUserLabel(1)   'file name from load code
      LoadFile (camerafile)      'load the camera file
      While IsLoading()
      Wend
      Sleep (1000)
      DoButton (0)      'Cycle Start
      While IsMoving()
      Sleep (2000)
      Wend
      Sleep (5000)
      SetUserLED (1111,0)      '1st file finished LED off
      SetUserLED (1112,1)      '2cd file to run LED
      Sleep (100)
   End If
   If GetUserLED (1112) = 1 Then      'if run 2cd file LED is on
      cutfile = GetUserLabel(2)   'file name from load code
      LoadFile (cutfile)      'load 2cd file cut file
      While IsLoading()
      Wend
      Sleep (1000)
      DoButton (0)      'Cycle Start
      While IsMoving()
      Sleep (2000)
      Wend
      Sleep (5000)
      SetUserLED (1112,0)      '2cd file done turn off LED
      Sleep (100)
   End If
Else
   SetUserLED (1112,1)          'only running the cut file
   Sleep (1000)
   DoButton (0)         'Cycle Start
   While IsMoving()
   Sleep (2000)
   Wend
   Sleep (5000)
   SetUserLED (1112,0)         'done running the cut file
End If

'scott
fun times

Offline Bill_O

*
  •  563 563
    • View Profile
Re: loading and running 2 files
« Reply #2 on: March 20, 2009, 12:21:18 PM »
Scott,
Just a couple of small corrections. Very good figuring it all out. The sleep times may be able to be shortened but if they are to short it will not work. Of course  the buttons, leds, dros and the userlabels need to be in the screenset.

Load Button

If GetUserLED (1110) = 1 Then       'The I wanna use a dual Gcode LED I have a button that turns this on and off
DoOEMButton (216)                       ' Opens window to select file to 1st file to load - second file that will be cut
While IsLoading()
Wend
cutfile = (FileName())                     
SetUserLabel (2,cutfile)                   'Sets second userlabel to file just opened
DoOEMButton (216)                       ' Opens window to select file to 2nd file to load - first file that will be cut
While IsLoading()
Wend
camerafile = (FileName())
SetUserLabel (1,camerafile)              'Sets first userlabel to file just opened
Else                                              'only opening the cut file This is so you can run normally
DoOEMButton (216)
While IsLoading()
Wend
cutfile = (FileName())
SetUserLabel (2,cutfile)                   'Sets second userlabel to file just opened
camerafile = "None"
SetUserLabel (1,camerafile)              'Sets first userlabel to read None
End If

Run Button

If GetUserLED (1110) = 1 Then           'The I wanna use a dual Gcode LED I have a button that turns this on and off
   If GetUserLED (1112) = 0 Then      'If I am not running the 2nd file LED
      SetUserLED (1111,1)      'I am running the 1st file LED
      camerafile = GetUserLabel(1)   'file name from load code
      LoadFile (camerafile)      'load the camera file
      While IsLoading()
      Wend
      Sleep (1000)
      DoButton (0)      'Cycle Start
      While IsMoving()
      Sleep (2000)
      Wend
      Sleep (5000)
      SetUserLED (1111,0)      '1st file finished LED off
      SetUserLED (1112,1)      '2nd file to run LED
      Sleep (100)
   End If
   If GetUserLED (1112) = 1 Then      'if run 2nd file LED is on
      cutfile = GetUserLabel(2)   'file name from load code
      LoadFile (cutfile)      'load 2nd file cut file
      While IsLoading()
      Wend
      Sleep (1000)
      DoButton (0)      'Cycle Start
      While IsMoving()
      Sleep (2000)
      Wend
      Sleep (5000)
      SetUserLED (1112,0)      '2nd file done turn off LED
      Sleep (100)
   End If
Else
   SetUserLED (1112,1)          'only running the cut file This is so you can run normally
   Sleep (1000)
   DoButton (0)         'Cycle Start
   While IsMoving()
   Sleep (2000)
   Wend
   Sleep (5000)
   SetUserLED (1112,0)         'done running the cut file
End If