• Introducción
  • Software de Graficacion
  • Software Driver
  • Electrónica
  • Mecánica
  • Código
  • Fotos
  • +
CODIGO FUENTE (GAMBAS 3)

Fmain.Class v2.1



'(clase principal sosftware de graficacion)


Public Enable As Boolean
Public pointsArr_x As New Float[]
Public pointsArr_y As New Float[]
Public simular As Boolean
Public pause As Boolean
Public posx As Float
Public posy As Float
Public a As Integer
Public radio As Float
Public maxx As Integer
Public num_mas As Integer
Public num_menos As Integer
Public XAXB As Integer
Public YAYB As Integer
Public x1x2 As Integer
Public y1y2 As Integer
Public cx As Integer
Public maxpoin As Boolean
Public ti As Integer
Public lxizq As Boolean
Public lxdercha As Boolean
Public lyup As Boolean
Public lydown As Boolean
Public miCaptura As New Picture
Public puntoselect As Integer

Public Sub dwgGrapharea_Draw()
Dim i As Integer
Dim g As Integer
Dim a As Integer
Dim b As Integer
Dim L As Integer
If button1.Border = False Then
   Button1.Border = True
    Button17.Enabled = True
 dwgGrapharea.Mouse = Mouse.Pointing
Endif

Paint.LineWidth = 0.2
paint.Brush = paint.Color(Color.DarkGreen)

For g = 1 To 33 Step 1
 Paint.MoveTo(0, a)
Paint.LineTo(1100, a)
a = a + 20
Next
Paint.Stroke
For g = 1 To 56 Step 1
 Paint.MoveTo(b, 0)
Paint.LineTo(b, 640)
b = b + 20
Next
Paint.Stroke


If CheckBox1.Value = False Then
    paint.Brush = paint.Color(Color.White)
   
   Paint.LineWidth = 1
   paint.Font.Size = 10
  For i = 0 To pointsArr_x.Max
     If i = 0 Then
     Paint.MoveTo(pointsArr_x[i], pointsArr_y[i])
Endif

  If pointsArr_x[i] = 00 And pointsArr_y[i] = 00 Then
  i = i + 1

  Try Paint.MoveTo(pointsArr_x[i], pointsArr_y[i])
  End If
 
  Try Paint.LineTo(pointsArr_x[i], pointsArr_y[i])

   Next

  paint.Stroke

If CheckBox2.Value = True Then
   'numeros
   For i = 0 To pointsArr_x.Max
     If pointsArr_x[i] = 0 And pointsArr_y[i] = 0 Then
      L = L + 1
          Else
         paint.Text(i + 1 - L, pointsArr_x[i], pointsArr_y[i] - 8)
    Endif
   Next
  paint.Fill
 
   Endif

End If

 PaintObj.PUNTOS_RED()
If simular = True Then
 PaintObj.cncsimulator
 End If
PaintObj.regla1
PaintObj.regla2
PaintObj.simular
End

Public Sub Button1_Click()

Dim cero As Integer
cero = 00
If (pointsArr_x.Max <> 00 And pointsArr_y.Max <> 00) And Button1.Border = True Then
    If pointsArr_x[pointsArr_x.Max] <> 0 And pointsArr_y[pointsArr_y.Max] <> 0 Then
    pointsArr_x.Add(00)
    pointsArr_y.Add(00)
    Button1.Border = False
    dwgGrapharea.Mouse = Mouse.Cross
    Button17.Enabled = False
    Else
      dwgGrapharea.Mouse = Mouse.Pointing
    Endif
Else
pointsArr_x.Remove(pointsArr_y.Max)
pointsArr_y.Remove(pointsArr_y.Max)
 Button1.Border = True
Button17.Enabled = True
dwgGrapharea.Mouse = Mouse.Pointing
Endif
 Catch
End



Public Sub btnClear_Click()
 pointsArr_x.Clear
   pointsArr_y.Clear
 
  ' ListBox1.Clear
 bdArray.BorrarTodo
   dwgGrapharea.Refresh
a Timerx.Enabled = False
Timery.Enabled = False
PaintObj.ix = 0
PaintObj.iy = 0
ti = 0
cx = 0
FMain.maxpoin = False

End

Public Sub btnClose_Click()

  Me.Close

End

Public Sub Form_Open()
Label9.Text = Mysql.softwareandvercion
a = 0
simular = False
'bdArray.BorrarTodo
  Button8.Enabled = False
Button9.Enabled = False
dwgGrapharea.Margin = True
dwgGrapharea.Refresh
DrawingArea1.Refresh
Label8.Text = Mysql.Proyectonombre
Label11.Text = Mysql.Usuarionombre
Enable = True
Try CtrlManual.puerto = Open "/dev/port" For Write
CtrlManual.Timer1_Timer()
Variables.cmv = 7
DrawingArea1.SetFocus
End


Public Sub Button9_Click()
Timerx.Enabled = False
Timery.Enabled = False
PaintObj.ix = 0
PaintObj.iy = 0
ti = 0
cx = 0
btnClear.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button8.Enabled = False
Button9.Enabled = False
End

Public Sub Guardar_Click()
bdArray.save
End

Public Sub Button4_Click()
  bdArray.contartemp
If bdArray.selecttemp.Count < pointsArr_x.Count Or bdArray.selecttemp.Count = pointsArr_x.Count Then
 bdArray.cargartemp()
Endif

If bdArray.selecttemp.Count = 0 Then
  Else
  bdArray.IR_ATRAS
Endif
End

Public Sub Button5_Click()
bdArray.contartemp
If bdArray.selecttemp.Count = 0 Then
  Else
bdArray.IR_ADELANTE
Endif
End

Public Sub Slider1_Change()
dwgGrapharea.Refresh
DrawingArea1.Refresh
End

Public Sub Slider2_Change()
dwgGrapharea.Refresh
DrawingArea2.Refresh
End

Public Sub Button7_Click()
Button8.Enabled = True
Button9.Enabled = True
 If ti <> pointsArr_x.Max And FMain.pointsArr_y.Count <> 1 Then
  Button4.Enabled = False
  Button5.Enabled = False
  btnClear.Enabled = False
   If FMain.pointsArr_x[ti + 1] = 00 Then ti = ti + 2
PaintObj.ix = 0
PaintObj.iy = 0
cx = 0
'---------------------------------------------------------------------------------------------------------------------
If FMain.pointsArr_x[ti] = FMain.pointsArr_x[ti + 1] And FMain.pointsArr_y[ti] <> FMain.pointsArr_y[ti + 1] Then
  If FMain.pointsArr_y[ti] > FMain.pointsArr_y[ti + 1] Then
  Message.Info("vamos bien esto es una linea vertical hacia arriba ")
  Else
  Message.Info("vamos bien esto es una linea vertical hacia la abajo ")
  lydown = True
  Endif
Endif
'---------------------------------------------------------------------------------------------------------------------
If FMain.pointsArr_y[ti] = FMain.pointsArr_y[ti + 1] And FMain.pointsArr_x[ti] <> FMain.pointsArr_x[ti + 1] Then
    If FMain.pointsArr_x[ti] > FMain.pointsArr_x[ti + 1] Then
  Message.Info("vamos bien esto es una linea horizontal hacia izquierda ")
  Else
  Message.Info("vamos bien esto es una linea horizontal hacia la derecha ")
Endif
Endif
 If FMain.pointsArr_x[ti] < FMain.pointsArr_x[ti + 1] Then
    XAXB = FMain.pointsArr_x[ti + 1] - FMain.pointsArr_x[ti]
    x1x2 = FMain.pointsArr_x[ti + 1] - FMain.pointsArr_x[ti]
    Else
     XAXB = FMain.pointsArr_x[ti] - FMain.pointsArr_x[ti + 1]
      x1x2 = FMain.pointsArr_x[ti + 1] - FMain.pointsArr_x[ti]
Endif
If FMain.pointsArr_y[ti] < FMain.pointsArr_y[ti + 1] Then
    YAYB = FMain.pointsArr_y[ti + 1] - FMain.pointsArr_y[ti]
    y1y2 = FMain.pointsArr_y[ti + 1] - FMain.pointsArr_y[ti]
    Else
    YAYB = FMain.pointsArr_y[ti] - FMain.pointsArr_y[ti + 1]
    y1y2 = FMain.pointsArr_y[ti + 1] - FMain.pointsArr_y[ti]
Endif
If XAXB > YAYB Then
Timerx.Delay = 50
Try Timery.Delay = (50 * XAXB) / YAYB
Timerx.Enabled = True
Timery.Enabled = True
Else
Timery.Delay = 50
Try Timerx.Delay = (50 * YAYB) / XAXB
Timerx.Enabled = True
Timery.Enabled = True
Endif
'///////////////////////////////
ti = ti + 1
If Error Then
Button7_Click()
Else
maxpoin = False
Endif
Else
Endif
'Catch
End



Public Sub Timerx_Timer()
cx = cx + 1
If cx = XAXB Then
Timerx.Enabled = False
Timery.Enabled = False   
PaintObj.ix = 0
PaintObj.iy = 0
 Button4.Enabled = True
  Button5.Enabled = True
    btnClear.Enabled = True
     Button8.Enabled = False
'Button9.Enabled = False
If ti <> FMain.pointsArr_x.Max Then
 Button7_Click
 Else
 Button9_Click
Endif
If ti = FMain.pointsArr_x.Max + 1 Then
ti = 0

Endif
Else
PaintObj.ix = PaintObj.ix + 1
dwgGrapharea.Refresh
Endif
pause = False
End
Public Sub Timery_Timer()
PaintObj.iy = PaintObj.iy + 1
dwgGrapharea.Refresh
End


Public Sub Button8_Click()

Timerx.Enabled = False
TimerY.Enabled = False

End

Public Sub Button3_Click()
bdArray.save
End

Public Sub DrawingArea2_Draw()
Dim i As Integer
Dim a As Integer

paint.Brush = paint.Color(Color.White)

For i = 0 To 55 Step 1
  a = a + 20
 paint.Text(i + 1, 0 + a, 15)
Next
Paint.fill
PaintObj.reglax
End

Public Sub DrawingArea1_Draw()
Dim i As Integer
Dim a As Integer
paint.Brush = paint.Color(Color.White)
For i = 0 To 55 Step 1
  a = a + 20
 paint.Text(i + 1, 5, 0 + a)
Next
Paint.fill
  PaintObj.reglay
End



Public Sub Panel5_MouseMove()

FMain.X = (Mouse.ScreenX)
 Wait 0.002
FMain.Y = (Mouse.ScreenY)
End


Public Sub ToggleButton2_Click()
  Me.Minimized = True
End

Public Sub ToggleButton3_Click()
If FMain.FullScreen = False Then
FMain.Border = False
Else
FMain.Border = True
FMain.FullScreen = False
Endif
End

Public Sub Button6_Click()
If Enable = False Then
  Enable = True
  look.Visible = False
  Button17.Enabled = True
  Button4.Enabled = True
  Button5.Enabled = True
  Else
      Button4.Enabled = False
      Button5.Enabled = False
    Enable = False
    look.Visible = True
    Button17.Enabled = False
Endif

End
Public Sub dwgGrapharea_MouseUp()


Dim actualizartemp As Result
If Enable = True Then


Try actualizartemp = Mysql.Conexion.Exec("Update Graficos_temp SET x= '" & pointsArr_x[pointsArr_x.Max] & "', y= '" & pointsArr_y[pointsArr_y.Max] & "'  where  nombre = '" & FMain.Label8.text & "' ORDER BY id DESC LIMIT 1 ")

   If (Mouse.X > 0 And Mouse.X < 1100) And (Mouse.Y > 0 And Mouse.Y < 640) Then

 If FMain.solopunto.Value = True And pointsArr_x.Max <> -1 Then
       FMain.Button1_Click()
       Endif
   If pointsArr_x.Count <> 0 Then
       If Mouse.X <> pointsArr_x[pointsArr_x.Max] Or Mouse.Y <> pointsArr_y[pointsArr_y.Max] Then
          pointsArr_x.Add(Mouse.X)
          pointsArr_y.Add(Mouse.Y)
        
          xText.Text = ((Mouse.X / 2) / 10)
          yText.Text = ((Mouse.y / 2) / 10)
          dwgGrapharea.Refresh
          Endif
   Else
       pointsArr_x.Add(Mouse.X)
       pointsArr_y.Add(Mouse.Y)
       bdArray.cargartemp()
       xText.Text = ((Mouse.X / 2) / 10)
       yText.Text = ((Mouse.y / 2) / 10)
       dwgGrapharea.Refresh

   Endif

   Endif

Endif

End

Public Sub Button2_Click()
PaintObj.lineas_rectas()
End
Public Sub Button10_Click()
  CtrlManual.ShowDialog
End


Public Sub Timer3_Timer()
PaintObj.iy = PaintObj.iy - 1
dwgGrapharea.Refresh
End

Public Sub Button13_Click()
bdArray.save
Calcular.CNCBEGIN()
End


Public Sub CheckBox2_Click()
dwgGrapharea.Refresh

End

Public Sub CheckBox1_Click()
dwgGrapharea.Refresh
End

Public Sub Button16_Click()
If Panel1.Visible = True Then
  Panel1.Visible = False
  Panel2.X = 0
  Button16.Text = "Contraer"
  Else
  Panel1.Visible = True
   Panel2.X = 120
     Button16.Text = "Expandir"
Endif
End


Public Sub Button14_Click()
bdArray.save
MonitorizarCalc.ShowDialog
End


Public Sub Guardar_como_Click()
Dim i As Integer
Dim datos As New String[]
Dim proyecto As String
Dim dirr As String

proyecto = ""
datos.Clear
datos.Add(Mysql.Usuarionombre)
datos.Add(Mysql.Proyectonombre)
proyecto = datos.Join("/")
Dialog.Title = "Seleccionar directorio"
AbrirProyect.xx.Clear
AbrirProyect.yy.Clear
AbrirProyect.contenidox = ""
AbrirProyect.contenidox = ""
For i = 0 To FMain.pointsArr_x.Max
  AbrirProyect.xx.Add(CStr(FMain.pointsArr_x[i]))
  AbrirProyect.yy.Add(CStr(FMain.pointsArr_y[i]))
Next

AbrirProyect.contenidox = AbrirProyect.xx.Join("-")
 AbrirProyect.contenidoy = AbrirProyect.yy.Join("-")
Dialog.Filter = ["*.cnc", "Archivo CNCAD"]
  If Dialog.SaveFile() Then Return
  dirr = Replace$(Dialog.Path, ".cnc", "")

 
File.Save(dirr & ".cnc", proyecto)
File.Save(dirr & ".cncx", AbrirProyect.contenidox)
 File.Save(dirr & ".cncy", AbrirProyect.contenidoy)

Catch
  Message.Warning(ERROR.Text)


End

Public Sub Abrir_Click()

  AbrirProyect.ShowDialog

End

Public Sub Control_Click()

 CtrlManual.ShowDialog

End

Public Sub Salir_Click()

Select Message.Question("¿ Desea guardar los cambios ? ", " Sí", "No", "Cancelar")
Case 1
bdArray.save
Me.Close
Case 2
CtrlManual.offtodos_Click()
CtrlManual.stop_Click()
    Me.CLOSE
Case 3
   End Select

End

Public Sub Button17_Click()
If Enable = False Then
   dwgGrapharea.Mouse = Mouse.Pointing
 Enable = True
 button1.Enabled = True
 Button2.Enabled = True
 Button17.Border = True
 Else
  Enable = False
  button1.Enabled = False
   Button17.Border = False
    Button2.Enabled = False
  dwgGrapharea.Mouse = Mouse.Vertical
Endif

End

Public Sub TextBox1_Change()

 Slider2.Value = ((TextBox1.Text * 10) * 2)
Catch
Slider2.Value = 0
End


Public Sub TextBox2_Change()

 Slider1.Value = ((TextBox2.Text * 10) * 2)
 Catch
Slider1.Value = 0
End

Public Sub Button18_Click()

  PaintObj.lineas_rectas()

End

Public Sub Iniciar_Click()

  bdArray.save
Calcular.CNCBEGIN()

End

Public Sub Iniciar2_Click()

bdArray.save
MonitorizarCalc.ShowDialog

End

Public Sub Agregar_Click()

  CuentasUser.ShowDialog

End

Public Sub dwgGrapharea_MouseMove()

 If Enable = True Then
 If pointsArr_x[pointsArr_x.Max] <> 0 And pointsArr_y[pointsArr_y.Max] <> 0 Then
 If (Mouse.X > 0 And Mouse.X < 1100) And (Mouse.Y > 0 And Mouse.Y < 640) Then
pointsArr_x[pointsArr_x.Max] = Mouse.x
pointsArr_y[pointsArr_y.Max] = Mouse.y
dwgGrapharea.Refresh
DrawingArea1.Refresh
xText.Text = ((Mouse.X / 2) / 10)
 yText.Text = ((Mouse.y / 2) / 10)
 Endif
 
Endif

 Else If Button17.Enabled = True And Enable = False Then

 If (Mouse.X > 0 And Mouse.X < 1100) And (Mouse.Y > 0 And Mouse.Y < 640) Then
      pointsArr_x[puntoselect] = Mouse.x
      pointsArr_y[puntoselect] = Mouse.y
      dwgGrapharea.Refresh
      DrawingArea1.Refresh
      xText.Text = ((Mouse.X / 2) / 10)
      yText.Text = ((Mouse.y / 2) / 10)
      TextBox1.Text = pointsArr_x[puntoselect] / 20
      TextBox2.Text = pointsArr_y[puntoselect] / 20
      Endif
Endif
Catch
End



Public Sub dwgGrapharea_KeyPress()
  If Key.Code = Key.Enter Then
   dwgGrapharea_MouseUp()
  End If
End

Public Sub dwgGrapharea_MouseDown()
Dim I As Integer
 If Button17.Enabled = True And Enable = False Then

For I = 0 To pointsArr_x.Max

 If (pointsArr_x[I] < Mouse.X + 10 And pointsArr_x[I] > Mouse.X - 10) And (pointsArr_y[I] < Mouse.y + 10 And pointsArr_y[I] > Mouse.y - 10) Then
 puntoselect = i
 TextBox1.Text = pointsArr_x[I] / 20
 TextBox2.Text = pointsArr_y[I] / 20
 Endif
 Next
 Endif
End

PaintObj.Module v2.3


'(Modulo software de graficacion )

Public ix As Integer
Public iy As Integer
Public endredx As Integer
Public endredy As Integer

Public Sub PUNTOS_RED()
Dim i As Integer
Dim p As Integer
Paint.Begin(FMain.dwgGrapharea)
For i = 0 To FMain.pointsArr_x.Max

 If FMain.pointsArr_x[i] <> 0 And FMain.pointsArr_y[i] <> 0 Then
    
      paint.Brush = paint.Color(Color.Cyan)
       p = 1

If i = 0 Then
         p = 2
         paint.Brush = paint.Color(Color.yellow)
         
        Else If i = FMain.pointsArr_x.Max Then
               p = 2
               paint.Brush = paint.Color(Color.red)

               Else If FMain.pointsArr_x[i - 1] = 0 And FMain.pointsArr_y[i - 1] = 0 Then
                     p = 2
                     paint.Brush = paint.Color(Color.yellow)
                     
                 Else If FMain.pointsArr_x[i + 1] = 0 And FMain.pointsArr_y[i + 1] = 0 Then
                     p = 2
                     paint.Brush = paint.Color(Color.Green)     
                     
                     Endif
 
    Paint.Arc(FMain.pointsArr_x[i], FMain.pointsArr_y[i], p)
   Paint.Fill
  Endif
 
  Next

Paint.end
End

Public Sub regla1()

Paint.Begin(FMain.dwgGrapharea)
 paint.Brush = paint.Color(Color.red)
  Paint.MoveTo(0, FMain.Slider1.Value)
Paint.LineTo(1100, FMain.Slider1.Value)
Paint.stroke
Paint.end
End
Public Sub regla2()
Paint.Begin(FMain.dwgGrapharea)
 paint.Brush = paint.Color(Color.blue)
 Paint.MoveTo(FMain.Slider2.Value, 0)
Paint.LineTo(FMain.Slider2.Value, 1100)
Paint.stroke
Paint.end
End

Public Sub simular()
If FMain.Timerx.Enabled = True Then
Paint.Begin(FMain.dwgGrapharea)
 paint.Brush = paint.Color(Color.Green)
   Try Paint.MoveTo(FMain.pointsArr_x[FMain.ti - 1], FMain.pointsArr_y[FMain.ti - 1])
If FMain.x1x2 > 0 And FMain.y1y2 > 0 Then
Try Paint.Arc(FMain.pointsArr_x[FMain.ti - 1] + ix, FMain.pointsArr_y[FMain.ti - 1] + iy, 8)
Endif
If FMain.x1x2 < 0 And FMain.y1y2 > 0 Then
Try Paint.Arc(FMain.pointsArr_x[FMain.ti - 1] - ix, FMain.pointsArr_y[FMain.ti - 1] + iy, 8)
Endif
If FMain.x1x2 > 0 And FMain.y1y2 < 0 Then
Try Paint.Arc(FMain.pointsArr_x[FMain.ti - 1] + ix, FMain.pointsArr_y[FMain.ti - 1] - iy, 8)
Endif
If FMain.x1x2 < 0 And FMain.y1y2 < 0 Then
Try Paint.Arc(FMain.pointsArr_x[FMain.ti - 1] - ix, FMain.pointsArr_y[FMain.ti - 1] - iy, 8)
If Error Then FMain.error.Text = "Se recomienda verificar el diseño"
Endif
If FMain.lyup = True Then
Try Paint.Arc(FMain.pointsArr_y[FMain.ti - 1] - iy, 8)
FMain.lyup = False
Endif
Paint.Fill
Paint.end
End If
End


Public Sub reglax()
Paint.Begin(FMain.DrawingArea2)
 paint.Brush = paint.Color(Color.blue)
 Paint.MoveTo(FMain.Slider2.Value, 0)
Paint.LineTo(FMain.Slider2.Value, 1700)
Paint.stroke
Paint.end
End
Public Sub reglay()
Paint.Begin(FMain.DrawingArea1)
 paint.Brush = paint.Color(Color.red)
 Paint.MoveTo(0, FMain.Slider1.Value)
Paint.LineTo(1700, FMain.Slider1.Value)
Paint.stroke
Paint.end
End
Public Sub lineas_rectas()
 Dim insertxy As Result
 If FMain.Slider2.Value = 0 And FMain.Slider1.Value = 0 Then
 Else
      If FMain.Enable = True Then
       If FMain.solopunto.Value = True And FMain.pointsArr_x.Max <> -1 Then
       FMain.Button1_Click()
       Endif

          If FMain.pointsArr_x.Count <> 0 Then
            If FMain.Slider2.Value <> FMain.pointsArr_x[FMain.pointsArr_x.Max] Or FMain.Slider1.Value <> FMain.pointsArr_y[FMain.pointsArr_y.Max] Then
               FMain.pointsArr_x.Add(FMain.Slider2.Value)
               FMain.pointsArr_y.Add(FMain.Slider1.Value)
               FMain.xText.Text = ((FMain.Slider2.Value / 2) / 10)
               FMain.ytext.Text = ((FMain.Slider1.Value / 2) / 10)
               insertxy = Mysql.Conexion.Exec("Insert into Graficos_temp(x, y,nombre) values ('" & FMain.Slider2.Value & "','" & FMain.Slider1.Value & "', '" & FMain.Label8.text & "')")
               FMain.dwgGrapharea.Refresh
               Endif
      Else
           FMain.pointsArr_x.Add(FMain.Slider2.Value)
           FMain.pointsArr_y.Add(FMain.Slider1.Value)
           FMain.xText.Text = ((FMain.Slider2.Value / 2) / 10)
           FMain.ytext.Text = ((FMain.Slider1.Value / 2) / 10)
           insertxy = Mysql.Conexion.Exec("Insert into Graficos_temp(x, y,nombre) values ('" & FMain.Slider2.Value & "','" & FMain.Slider1.Value & "', '" & FMain.Label8.text & "')")
           FMain.dwgGrapharea.Refresh
        Endif
     
      Endif
 Endif
End

Login.class v1.1


'(Clace, control de acceso de Usuario)


Public Sub Form_Open()
CtrlManual.puerto = Open "/dev/port" For Write
CtrlManual.Timer1_Timer()
CtrlManual.offtodos_Click()
CtrlManual.stop_Click()
  Me.Center
Mysql.CONECTAR_BD()
Label2.Text = Mysql.softwareandvercion
End
Public Sub Button1_Click()
Me.Close
End

Public Sub Button2_Click()
Me.Minimized = True
End

Public Sub TextBox1_Change()
Dim verificar As Result
 verificar = Mysql.Conexion.Exec("Select NOMBRE from Usuario where NOMBRE = '" & TextBox1.Text & "'")
 If verificar.Count <> 0 Then
 Label1.Text = "CONTRASEÑA"
 TextBox2.Visible = True
TextBox2.SetFocus
passview.Visible = True
  nombre.Text = verificar[0]
Mysql.Usuarionombre = verificar[0]
   Endif
 End
 Public Sub TextBox2_Change()
Dim verificarP As Result
If TextBox2.Text = "" Then
passview.Enabled = False
Else
  passview.Enabled = True
Endif
  verificarP = Mysql.Conexion.Exec("Select PASS from Usuario where PASS = '" & TextBox2.Text & "'")
   If verificarP.Count <> 0 Then
     Mysql.Cerrar_BD
 AbrirProyect.Show
 Me.Close
 Endif
 End

Public Sub passview_Click()
If passview.Value = True Then
  TextBox2.Password = False
  Else
    TextBox2.Password = True
Endif
End

CuenstasUser.Class v1.0


'(Clase de controlo de cuentas de usuario)

Public Sub TextBox1_KeyPress()
If Key.Code = 16777220 Then
If CuentasUser.TextBox1.text = "" Then
info.Text = "Ingrese un nombre de usuario "
Else
  ComboBox1.SetFocus
  End If
  End If
End

Public Sub ComboBox1_KeyPress()
  If Key.Code = 16777220 Then
  TextBox2.SetFocus
  End If
End

Public Sub TextBox2_KeyPress()
  If Key.Code = 16777220 Then
If CuentasUser.TextBox1.text = "" Then
info.Text = "Ingrese una contraseña "
Else
  TextBox3.SetFocus
  End If
  End If
End
Public Sub TextBox3_KeyPress()
  If Key.Code = 16777220 Then
If CuentasUser.TextBox3.text = "" Then
info.Text = "Repita la Contraseña "
Else
  Button1_Click
  End If
  End If
End


Public Sub Button1_Click()
Dim Nupdate As Result
  Me.Center
  Panel2.Y = -60
Panel3.Y = -60
Panel4.Y = -60
Panel5.Y = -60
  Timer2.Enabled = True
If TextBox1.text = "" Then
info.Text = "Ingrese un nombre de usuario"
Else If TextBox2.text <> TextBox3.Text Then
info.Text = "Las contraseñas no coinciden "
Else
Nupdate = Mysql.Conexion.Exec("Insert into Usuario(NOMBRE, CARGO, PASS) values ('" & TextBox1.Text & "','" & ComboBox1.text & "','" & Textbox2.text & "' )")
Message.Info("Cuenta Agregada con exito ")
Catch
Message.Info("Ya hay otra cuenta con ese nombre de Usuario ")
CuentasUser.Close
CuentasUser.Show
End If
End


Public Sub Form_Open()
Panel2.Y = -60
Panel3.Y = -60
Panel4.Y = -60
Panel5.Y = -60
 Timer2.Enabled = True
 COMBOCARGAR()
End

Public Sub Button2_Click()
Dim varresult As Result
Dim varresultt As Result
Dim li As String
Try Mysql.CONECTAR_BD
If TextBox4.Text = "" Or DataComboView1.Text = "" Then
info2.Text = "Complete todos los campos "
Else
varresultt = Mysql.Conexion.Exec("Select CARGO From Usuario where PASS =  '" & TextBox4.Text & "'")
If varresultt.Count = 0 Then
info2.Text = "Contraseña incorrecta"
Else
li = varresultt[0]
If li = "Administrador" Or li = "Root" Then
   varresult = Mysql.Conexion.Exec("DELETE FROM Usuario WHERE NOMBRE =  '" & DataComboView1.Text & "' ")
   COMBOCARGAR
   info2.Text = "Ok"
Else If li = "Limitado" Then
   info2.Text = "No posee permiso parar Eliminar CuentasUser "
Endif
Endif
Endif
Catch
Me.Close
CuentasUser.Show
End


Public Sub TabStrip1_Click()
End

Public Sub Button4_Click()
Me.Minimized = True

End


Public Sub Label1_MouseMove()

Me.X = (Mouse.ScreenX)
 Wait 0.002
Me.Y = (Mouse.ScreenY)

End

Public Sub Timer2_Timer()

If Panel2.Y < 8 Then
  Panel2.Y = Panel2.Y + 4
End If
If Panel3.Y < 72 Then
  Panel3.Y = Panel3.Y + 4
End If
If Panel4.Y < 136 Then
  Panel4.Y = Panel4.Y + 4
End If
If Panel5.Y < 200 Then
  Panel5.Y = Panel5.Y + 4
End If
If Panel5.Y = 200 Or Panel5.Y > 200 Then Timer2.Enabled = False
End

Public Sub COMBOCARGAR()
Dim i As Integer
Dim varresult As Result
Mysql.CONECTAR_BD()
  varresult = Mysql.Conexion.Exec("select NOMBRE from Usuario")
For i = 0 To varresult.Count Step 1
varresult.MoveNext
Try DataComboView1.Add(varresult[0])
Next
Me.Center
Mysql.Cerrar_BD
End

Public Sub Cerrar_Click()
  Me.Close
End

Public Sub Minimizar_Click()
  Me.Minimized = True
End

bdArray.Module v1.2


'(Modulo Guarda las coodenadas de un proyecto en la base de datos, software de graficacion )

Public selecttemp As Result
Public AT As Integer

Public Sub Borrar()
FMain.pointsArr_x.Clear
FMain.pointsArr_y.Clear
End
Public Sub BorrarTodo()

Dim borrartemp As Result
FMain.pointsArr_x.Clear
FMain.pointsArr_y.Clear
 borrartemp = Mysql.Conexion.Exec("truncate table Graficos_temp")

End

Public Sub IR_ADELANTE()
Dim selecttx As Result
Dim selectty As Result
Dim MatrisCOUNT As Integer
Dim i As Integer

MatrisCOUNT = FMain.pointsArr_x.Count
Borrar
selecttx = Mysql.Conexion.Exec("select x from Graficos_temp where nombre ='" & FMain.Label8.text & "' ")
selectty = Mysql.Conexion.Exec("select y from Graficos_temp where nombre ='" & FMain.Label8.text & "' ")
If MatrisCOUNT < selecttx.Count Then
For i = 1 To MatrisCOUNT + 1 Step 1
 FMain.pointsArr_x.Add(selecttx[0])
 FMain.pointsArr_y.Add(selectty[0])
selecttx.MoveNext
selectty.MoveNext
   Next
Else
  For i = 1 To MatrisCOUNT Step 1
 FMain.pointsArr_x.Add(selecttx[0])
 FMain.pointsArr_y.Add(selectty[0])
selecttx.MoveNext
selectty.MoveNext
   Next
Endif
FMain.dwgGrapharea.Refresh

End

Public Sub IR_ATRAS()
Dim selecttx As Result
Dim selectty As Result
Dim MatrisCOUNT As Integer
Dim i As Integer

MatrisCOUNT = FMain.pointsArr_x.Count
Borrar
selecttx = Mysql.Conexion.Exec("select x from Graficos_temp where nombre ='" & FMain.Label8.text & "' ")
selectty = Mysql.Conexion.Exec("select y from Graficos_temp where nombre ='" & FMain.Label8.text & "' ")

For i = 1 To MatrisCOUNT - 1 Step 1
 FMain.pointsArr_x.Add(selecttx[0])
 FMain.pointsArr_y.Add(selectty[0])
selecttx.MoveNext
selectty.MoveNext
   Next
   

FMain.dwgGrapharea.Refresh

End
Public Sub save()
Dim saveproyecto As Result
Dim vaciar As Result
Dim actualizarf As Result
Dim i As Integer
vaciar = Mysql.Conexion.Exec("delete from Graficos where nombre = '" & FMain.Label8.text & "'")
For i = 0 To FMain.pointsArr_x.Max Step 1
   saveproyecto = Mysql.Conexion.Exec("Insert into Graficos(x, y,fecha,usuario,nombre) values ('" & FMain.pointsArr_x[i] & "','" & FMain.pointsArr_y[i] & "', Date(Now()),'" & Mysql.Usuarionombre & "','" & FMain.Label8.text & "' )")
   actualizarf = Mysql.Conexion.Exec("Update Proyecto SET fecha_f=  Date(Now()) where Proyecto_nombre = '" & Mysql.Proyectonombre & "'")
     Next
End
Public Sub borrar_temp()
  Dim borrartempbd As Result
  borrartempbd = Mysql.Conexion.Exec("delete from Graficos_temp where nombre = '" & FMain.Label8.text & "'")
  End
Public Sub contartemp()

 selecttemp = Mysql.Conexion.Exec("select x from Graficos_temp where nombre = '" & FMain.Label8.text & "' ")

End
Public Sub cargartemp()
Dim insertxy As Result
Dim f As Integer
borrar_temp()

 For f = 0 To FMain.pointsArr_x.Count
insertxy = Mysql.Conexion.Exec("Insert into Graficos_temp(x, y,nombre) values ('" & FMain.pointsArr_x[f] & "','" & FMain.pointsArr_y[f] & "', '" & FMain.Label8.text & "')")
Next
Catch
End

Mysql.Module v1.1



'(Modulo, conexion con Mysql server)

Public Usuarionombre As String
Public Proyectonombre As String
Public Conexion As New Connection
Public software As String
Public vercion As String
Public softwareandvercion As String
Public Sub CONECTAR_BD()
'----------------------------------
software = "OPTIMUS CNCAD "
vercion = "V:1.01"
softwareandvercion = software & vercion
'----------------------------------
Conexion.Close 
Conexion.User = "root"
Conexion.Password = "funckoffx"
Conexion.Name = "RouterCnc"
Conexion.Type = "Mysql"
Conexion.host = "localhost"
Conexion.Open
AbrirProyect.DataSource1.Connection = Conexion
AbrirProyect.DataSource1.Table = ("Proyecto")
NuevoProyect.DataSource2.Connection = Conexion
NuevoProyect.DataSource2.Table = ("Proyecto")

End
Public Sub Cerrar_BD()
Conexion.Close 
  End

NuevoProyect.Class v1.2


'(Clase crear un nuevo proyecto, Software de graficacion)

Public Selectt As Result
Public Sub Form_Open()
Try Mysql.CONECTAR_BD
Nuevo.SetFocus
Me.Center
P1.Y = -180
P4.Y = -60
DataBrowser1_MouseDown
Label1.Text = Mysql.Usuarionombre
                    
End

Public Sub TextBox1_GotFocus()
TextBox1.Text = ""
TextBox1.Foreground = Color.White
End

Public Sub TextBox1_LostFocus()
If TextBox1.Text = "" Then
TextBox1.Text = "Buscar"
TextBox1.Foreground = Color.Gray
Endif
End




Public Sub DataBrowser1_MouseDown()
P1.Y = -180
P4.Y = -60

Timer1.Enabled = True
Timer2.Enabled = True
TextBox2.Text = DataControl1.value
 L1.Visible = True
C1.Visible = True
If DataControl4.Value = 1 Then
c1.Value = True
Else
C1.Value = False
Endif
End








Public Sub Label2_MouseMove()

Me.X = (Mouse.ScreenX)
 Wait 0.002
Me.Y = (Mouse.ScreenY)

End




Public Sub Button1_Click()
Me.Close
End


Public Sub Button2_Click()

Me.Minimized = True

End

Public Sub Timer1_Timer()
If PictureBox1.X <> 1700 Then
PictureBox1.X = PictureBox1.X + 10
Else
Timer1.Enabled = False
Endif

End

Public Sub Timer2_Timer()

If P1.Y < 72 Then
  P1.Y = P1.Y + 6
End If
If P4.Y < 208 Then
  P4.Y = P4.Y + 6
End If
If P4.Y = 208 Or P4.Y > 208 Then Timer2.Enabled = False

End

Public Sub Nuevo_Click()
Dim seleccionar As Result
Dim selecttx As Result
Dim selectty As Result
Dim borrartemp As Result
Dim i As Integer
Dim nuevo As Result
Selectt = Mysql.Conexion.Exec("Select * From Proyecto where Proyecto_nombre='" & TextBox2.Text & "'")
If TextBox2.Text = "" Then
Message.Warning("Escriba un nombre para el nuevo proyecto")
Else
If Selectt.Count = 1 Then
 Message.Warning("Ya existe un proyecto con este nombre")
Else
If TextBox2.Text <> "" And Selectt.Max <> 1 Then
   borrartemp = Mysql.Conexion.Exec("truncate table Graficos_temp")
nuevo = Mysql.Conexion.Exec("Insert into Proyecto(Proyecto_nombre, fecha_i, fecha_f, Usuario) values ('" & TextBox2.Text & "', Date(Now()), Date(Now()),'" & label1.Text & "')")
DataSource2.Table = "Proyecto"
DataSource2.Refresh
seleccionar = Mysql.Conexion.Exec("select nombre from Graficos where nombre = '" & TextBox2.Text & "' ")
Mysql.Proyectonombre = TextBox2.Text
FMain.Show
FMain.num_menos = FMain.num_menos + 1
FMain.num_mas = 0
bdArray.Borrar
selecttx = Mysql.Conexion.Exec("select x from Graficos where nombre = '" & TextBox2.Text & "' ")
selectty = Mysql.Conexion.Exec("select y from Graficos  where nombre = '" & TextBox2.Text & "' ")
FMain.maxx = selecttx.Count
FMain.maxx = FMain.maxx - FMain.num_menos
For i = 1 To FMain.maxx Step 1
 FMain.pointsArr_x.Add(selecttx[0])
 FMain.pointsArr_y.Add(selectty[0])
selecttx.MoveNext
selectty.MoveNext
   Next
   Me.Close
Else
Endif
Endif
Endif
End



Public Sub cerrar_Click()
Me.Close
End


Public Sub Nuevo2_Click()
Me.Close
Mysql.Cerrar_BD
AbrirProyect.Show

End

Public Sub Borrar_Click()
Dim borrarProyecto As Result
If TextBox2.Text = "" Then
Message.Info("No se seleciono ningun proyecto")
Else
Select Message.Question("¿ Desea borrar completamente el Proyecto " & TextBox2.Text & "  ? ", " Sí", "No")
Case 1
borrarProyecto = Mysql.Conexion.Exec("delete from Proyecto where Proyecto_nombre = '" & TextBox2.Text & "' ")
borrarProyecto = Mysql.Conexion.Exec("delete from Graficos where nombre = '" & TextBox2.Text & "' ")
borrarProyecto = Mysql.Conexion.Exec("delete from Graficos_temp where nombre = '" & TextBox2.Text & "' ")
DataBrowser1.Refresh
Catch
Case 2
  End Select
Endif
End

Public Sub ToggleButton2_Click()

DataSource2.Filter = ("Usuario = '" & Label1.Text & "' ")

End

Public Sub ToggleButton1_Click()

DataSource2.Filter = ("")
End

Public Sub TextBox1_KeyRelease()
  DataSource2.Filter = ("match(Proyecto_nombre)against('" & TextBox1.Text & "') ")

  If TextBox1.Text = "" Then
   DataSource2.Filter = ("")
   Endif

End

AbrirProyect.Class v1.8


'(Clase abrir un proyecto desde la base de datos, o desde archivo )

Public xx As New String[]
Public yy As New String[]
Public contenidox As String
 Public contenidoy As String

Public Sub Form_Open()
Mysql.CONECTAR_BD
abrir.SetFocus
P1.Y = -60
P2.Y = -60
P3.Y = -60
P4.Y = -60
Me.Center
Label5.Text = Mysql.Usuarionombre
End

Public Sub buss_GotFocus()
buss.Text = ""
buss.Foreground = Color.White
End

Public Sub buss_LostFocus()
If buss.Text = "" Then
buss.Text = "Buscar"
buss.Foreground = Color.Gray
Endif
End

Public Sub DataBrowser1_MouseDown()
P1.Y = -60
P2.Y = -60
P3.Y = -60
P4.Y = -60

Timer1.Enabled = True
Timer2.Enabled = True

 L1.Visible = True
L2.Visible = True
L3.Visible = True
L4.Visible = True
L5.Visible = True
L6.Visible = True
C1.Visible = True
L2.Text = DataControl1.Value
L4.Text = DataControl2.Value
l6.Text = DataControl3.Value
If DataControl4.Value = 1 Then
c1.Value = True
Else
C1.Value = False
Endif
End

Public Sub Label2_MouseMove()

AbrirProyect.X = (Mouse.ScreenX)
 Wait 0.002
AbrirProyect.Y = (Mouse.ScreenY)

End

Public Sub Button1_Click()
Me.Close
End

Public Sub Button2_Click()
Me.Minimized = True
End

Public Sub Timer1_Timer()
If PictureBox1.X <> 1700 Then
PictureBox1.X = PictureBox1.X + 10
Else
Timer1.Enabled = False
Endif
End

Public Sub Timer2_Timer()
If P1.Y < 72 Then
  P1.Y = P1.Y + 4
End If
If P2.Y < 128 Then
  P2.Y = P2.Y + 4
End If
If P3.Y < 184 Then
  P3.Y = P3.Y + 4
End If
If P4.Y < 240 Then
  P4.Y = P4.Y + 4
End If
If P4.Y = 240 Or P4.Y > 240 Then Timer2.Enabled = False
End

Public Sub abrir_Click()
Dim selecttx As Result
Dim selectty As Result
Dim loadtemp As Result
Dim borrartemp As Result
Dim i As Integer
If DataControl1.value = "" Then
Message.Info("Selecione un proyecto")
Else
Mysql.Proyectonombre = L2.Text

FMain.Show
FMain.num_menos = FMain.num_menos + 1
FMain.num_mas = 0
bdArray.Borrar
selecttx = Mysql.Conexion.Exec("select x from Graficos where nombre = '" & DataControl1.value & "' ")
selectty = Mysql.Conexion.Exec("select y from Graficos  where nombre = '" & DataControl1.value & "' ")
borrartemp = Mysql.Conexion.Exec("truncate table Graficos_temp")
loadtemp = Mysql.Conexion.Exec("INSERT INTO Graficos_temp (x,y,id,fecha,usuario,nombre )Select x, y, id,fecha,usuario,nombre From Graficos WHERE nombre ='" & DataControl1.value & "'")
FMain.maxx = selecttx.Count
FMain.maxx = FMain.maxx - FMain.num_menos
For i = 1 To FMain.maxx + 1 Step 1
 FMain.pointsArr_x.Add(selecttx[0])
 FMain.pointsArr_y.Add(selectty[0])
selecttx.MoveNext
selectty.MoveNext
   Next
  FMain.Form_Open
  FMain.num_menos = 0
   Me.Close
Endif
End

Public Sub cerrar_Click()
Me.Close
Mysql.Cerrar_BD
End



Public Sub cerrar2_Click()
Me.Close
Mysql.Cerrar_BD
NuevoProyect.Show
End



Public Sub ToggleButton2_Click()
  DataSource1.Filter = ("Usuario = '" & Label5.Text & "' ")
End

Public Sub ToggleButton1_Click()
  DataSource1.Filter = ("")
End

Public Sub buss_KeyRelease()
  DataSource1.Filter = ("match(Proyecto_nombre)against('" & buss.Text & "') ")
  If buss.Text = "" Then
   DataSource1.Filter = ("")
   Endif
End
 
Public Sub abrir2_Click()
Dim i As Integer
Dim datos As New String[]
Dim proyecto As String

 FMain.pointsArr_x.Clear
 FMain.pointsArr_y.Clear
 
Dialog.Filter = ["*.cnc", "Archivo CNCAD"]


 If Dialog.OpenFile() Then Return
 

proyecto = File.Load(Dialog.Path)
contenidox = File.load(Dialog.Path & "x")
 contenidoy = File.load(Dialog.Path & "y")
xx.Clear
 yy.Clear
datos = Split(proyecto, "/")
  xx = Split(contenidox, "-")
    yy = Split(contenidoy, "-")
   
Mysql.Proyectonombre = (datos[1])
  For i = 0 To xx.Max
  FMain.pointsArr_x.Add(CFloat(xx[i]))
  Next
 
     For i = 0 To yy.Max
    FMain.pointsArr_y.Add(CFloat(yy[i]))
    Next
 FMain.Form_Open
    FMain.Show

End

.

Stepper.Module v1.0


(Modulo secuecias para Motor eje X e Y,  driver)

Public timeM0 As Float
  Public ciclosM0 As Integer
  Public timeM1 As Float
  Public ciclosM1 As Integer
  Public a As Integer
   Public b As Integer
  Public timex As Float
  Public timey As Float
  Public progres As Float
    Public progrest As Float
  Public tiempo As Float
 
Public Sub derechax()
ciclosM0 = Val(CtrlManual.TextBox1.text)
timeM0 = Val(CtrlManual.TextBox2.text)
timex = Val(CtrlManual.TextBox5.text)

While a <> ciclosM0
    If CtrlManual.Stopp1 = True Then
  offcanal0()
  CtrlManual.Stopp1 = False
Return
    Endif
 
  Wait timeM0

 
  offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 8
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Seek #CtrlManual.puerto, &H378
CtrlManual.salida = CtrlManual.salida Or 2
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM0
 
  offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 8
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 1
 Write #CtrlManual.puerto, CtrlManual.salida As Byte 
 
  Wait timeM0
 
  offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 4
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 1
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM0
 
  offcanal0()
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 4
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
 Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 2
 Write #CtrlManual.puerto, CtrlManual.salida As Byte

  a = a + 1
Wend
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 0
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 a = 0

End
Public Sub izquierdax()
ciclosM0 = Val(CtrlManual.TextBox1.text)
timeM0 = Val(CtrlManual.TextBox2.text)
timex = Val(CtrlManual.TextBox5.text)

While a <> ciclosM0
  If CtrlManual.Stopp1 = True Then
  offcanal0()
  CtrlManual.Stopp1 = False
Return
    Endif
 
  Wait timeM0

   offcanal0()
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 4
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
 Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 2
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM0
 
   offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 4
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 1
 Write #CtrlManual.puerto, CtrlManual.salida As Byte

  Wait timeM0
 
  offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 8
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 1
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM0
 
   offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 8
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Seek #CtrlManual.puerto, &H378
CtrlManual.salida = CtrlManual.salida Or 2
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
  a = a + 1
Wend
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 0
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 a = 0
End

Public Sub derechay()

ciclosM1 = Val(CtrlManual.TextBox3.text)
timeM1 = Val(CtrlManual.TextBox4.text)
timey = Val(CtrlManual.TextBox6.text)

While b <> ciclosM1
  If CtrlManual.Stopp = True Then
  offcanal1()
  CtrlManual.Stopp = False
Return
    Endif
 
  Wait timeM1
 
  offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 128
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Seek #CtrlManual.puerto, &H378
CtrlManual.salida = CtrlManual.salida Or 32
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM1
 
  offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 128
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 16
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
 
  Wait timeM1
 
  offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 64
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 16
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM1
 
  offcanal1()
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 64
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
 Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 32
 Write #CtrlManual.puerto, CtrlManual.salida As Byte

  b = b + 1
Wend
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 0
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 b = 0

End

Public Sub izquierday()
ciclosM1 = Val(CtrlManual.TextBox3.text)
timeM1 = Val(CtrlManual.TextBox4.text)
timey = Val(CtrlManual.TextBox6.text)

While b <> ciclosM1
   If CtrlManual.Stopp = True Then
  offcanal1()
  CtrlManual.Stopp = False
Return
    Endif
 
  Wait timeM1
   offcanal1()
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 64
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
 Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 32
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM1
 
  offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 64
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 16
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
 
  Wait timeM1
 
  offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 128
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 16
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait timeM1
 

 
  offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida Or 128
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Seek #CtrlManual.puerto, &H378
CtrlManual.salida = CtrlManual.salida Or 32
 Write #CtrlManual.puerto, CtrlManual.salida As Byte

  b = b + 1
Wend
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 0
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 b = 0
End

Public Sub offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 8)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 4)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 2)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
     Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 1)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
End
Public Sub offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 128)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 64)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 32)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
     Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = CtrlManual.salida And (255 - 16)
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
End
Public Sub XHY()
Dim p As Integer
Calcular.autocalculo
'/////////////////////////////////////////
Calcular.monitorV
'////////////////////////////////////////
Wait 1
Calcular.ASIGNARXANDY
Calcular.ProcessInX
Calcular.ProcessInY
If CtrlManual.Chk2.Value = True Or CtrlManual.Chk1.Value = False Then
Calcular.sumarXHY
Else
Calcular.sumarXandY
Endif
tiempo = (Calcular.SteperXandY.Max / 1000)
 For p = 0 To Calcular.SteperXandY.Max
Seek #CtrlManual.puerto, &H378
CtrlManual.salida = Calcular.SteperXandY[p]
Wait 0.001
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 'progrest = (p / 1000)
 progres = progres + (1 / Calcular.SteperXandY.Max)
  Next
   progres = 0
  ' progrest = 0
   tiempo = 0
 'MonitorizarCalc.ProgressBar1.Value = MonitorizarCalc.ProgressBar1.Value + (1 / ((MonitorizarCalc.pasos[0] / 2) + 2))
End

CtrlManual.Class v1.1


(Clase del formulario control manual, sensores y manejo del eje Z, Driver)

Public endOrden As String
Public arriba As String
Public abajo As String
Public puerto As File
Public salida As Byte
Public PuertoEstado As File
Public Entrada As Byte
Const bit3 As Byte = 8
Const bit4 As Byte = 16
Const bit5 As Byte = 32
Const bit6 As Byte = 64
Const bit7 As Byte = 128
Public sennal As Boolean
Public sennal1 As Boolean
Public Stopp As Boolean
Public Stopp1 As Boolean
Public HASTA0X As Boolean
Public HASTA0Y As Boolean

'
Public Sub Form_Open()
Label9.Text = Mysql.softwareandvercion
Me.center
Timer1.Enabled = True
 puerto = Open "/dev/port" For Write
End
Public Sub up_Click()
 Seek #puerto, &H37A
  Write #puerto, 201 As Byte
  sennal1 = True
End
Public Sub down_Click()
 Seek #puerto, &H37A
  Write #puerto, 202 As Byte
   sennal = True
End
'
Public Sub Timer1_Timer()
puertoEstado = Open "/dev/port" For Read
Seek #puertoEstado, &H379
Read #puertoEstado, Entrada
Close puertoEstado
If (Entrada And bit3) = bit3 Then
SA.Value = 0
A.Visible = False
PictureBox3.X = 176
Else
SA.Value = 1
A.Visible = True
PictureBox3.X = 48

End If
If (Entrada And bit4) = bit4 Then
Chk1.Value = 0
Sdown.Visible = False
Else
Chk1.Value = 1
Sdown.Visible = True

End If
If (Entrada And bit5) = bit5 Then
Chk2.Value = 1
Sup.Visible = True
Else
Chk2.Value = 0
Sup.Visible = False
End If
If (Entrada And bit6) = bit6 Then
SC.Value = 1
C.Visible = True
Else
SC.Value = 0
C.Visible = False
End If

If (Entrada And bit7) = bit7 Then
SB.Value = 1
B.Visible = True
Else
SB.Value = 0
B.Visible = False
End If
If Sdown.Visible = False And Sup.Visible = False Then
 center.Visible = True
 Else
 center.Visible = False
Endif

If Sdown.Visible = True And sennal = True Then
  stop_Click()
  sennal = False
Endif
If Sup.Visible = True And sennal1 = True Then
  stop_Click()
  sennal1 = False
Endif
End


Public Sub stop_Click()
 Seek #puerto, &H37A
  Write #puerto, 203 As Byte
  Catch
End

Public Sub Iniciar_Click()
 Seek #puerto, &H37A
  Write #puerto, 203 As Byte
  up_Click
  offtodos_Click()

Do While sb.Value = False Or SA.Value = False
 '--------------------------------------------------------------------------- 
  If sb.Value = False And SA.Value = True Then
 Wait 0.002
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 96
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
  Wait 0.002
  Stepper.offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 80
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
  Wait 0.002
  Stepper.offcanal1()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 144
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
   Wait 0.002
  Seek #CtrlManual.puerto, &H378
CtrlManual.salida = 160
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
'***********************************************
 '---------------------------------------------------------------------------
 Else If sb.Value = True And SA.Value = False Then
  Wait 0.002
  Seek #CtrlManual.puerto, &H378
CtrlManual.salida = 10
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait 0.002
 
  Stepper.offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 9
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 
  Wait 0.002
 
  Stepper.offcanal0()
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 5
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
  Wait 0.002
 
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 6
 Write #CtrlManual.puerto, CtrlManual.salida As Byte

  Else
  '---------------------------------------------------------------------------
 Wait 0.002
    Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 106
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 Wait 0.002
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 89
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 Wait 0.002
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 149
 Write #CtrlManual.puerto, CtrlManual.salida As Byte
 Wait 0.002
   Seek #CtrlManual.puerto, &H378
 CtrlManual.salida = 166
 Write #CtrlManual.puerto, CtrlManual.salida As Byte

   Endif
   Loop
   offtodos_Click()
End
 

Public Sub ontodos_Click()
 Seek #puerto, &H378
  Write #puerto, 255 As Byte
End

Public Sub offtodos_Click()
 Seek #puerto, &H378
 Write #puerto, 0 As Byte
 Catch
End

Public Sub salir_Click()
 Seek #puerto, &H378
 Write #puerto, 0 As Byte
Close #puerto
Me.Close
End

Public Sub d0_Click()
If d0.Value = True Then
Seek #puerto, &H378
salida = salida Or 128
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 128)
  Write #puerto, salida As Byte
Endif

End

Public Sub d1_Click()
If d1.Value = True Then
Seek #puerto, &H378
salida = salida Or 64
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 64)
  Write #puerto, salida As Byte
Endif
End

Public Sub d2_Click()
If d2.Value = True Then
Seek #puerto, &H378
salida = salida Or 32
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 32)
  Write #puerto, salida As Byte
Endif
End

Public Sub d3_Click()
If d3.Value = True Then
Seek #puerto, &H378
salida = salida Or 16
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 16)
  Write #puerto, salida As Byte
Endif
 

End

Public Sub d4_Click()
If d4.Value = True Then
Seek #puerto, &H378
salida = salida Or 8
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 8)
  Write #puerto, salida As Byte
Endif

End

Public Sub d5_Click()
If d5.Value = True Then
Seek #puerto, &H378
salida = salida Or 4
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 4)
  Write #puerto, salida As Byte
Endif
End

Public Sub d6_Click()
If d6.Value = True Then
Seek #puerto, &H378
salida = salida Or 2
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 2)
  Write #puerto, salida As Byte
Endif
End

Public Sub d7_Click()
If d7.Value = True Then
Seek #puerto, &H378
salida = salida Or 1
 Write #puerto, salida As Byte
  Else
 Seek #puerto, &H378
salida = salida And (255 - 1)
  Write #puerto, salida As Byte
Endif
End

Public Sub Button1_Click()
If RadioButton1.Value = True Then
Stepper.derechax
Else
Stepper.izquierdax
End If
End
 
Public Sub Button2_Click()
If RadioButton3.Value = True Then
Stepper.derechay
Else
Stepper.izquierday
End If
End
Public Sub Button5_Click()
If Stopp1 = True Then
  Stopp1 = False
  Else
  Stopp1 = True
    Endif
  End

Public Sub Cerrar_Click()
Me.Close
End

Public Sub Minimizar_Click()
 Me.Minimized = True
FMain.ShowDialog
End

Variable.Module v1.1


(Modulo de las principales variables utilizadas en el Driver.)

Public TpMin As Integer
Public Px As Float
Public Py As Float
Public Xcm As Float
Public Ycm As Float
Public Tpx As Float
Public Tpy As Float
Public STpx As Float
Public STpy As Float
Public Spx As Float
Public Spy As Float
Public Gmx As Float
Public Gmy As Float
Public SFracX As Float
Public SFracY As Float
Public Errorr As Float
Public MError As New Float[]
Public MTpMin As New Integer[]
Public FX1 As New Float[]
Public FX2 As New Float[]
Public FY1 As New Float[]
Public FY2 As New Float[]
Public FX12 As New Float[]
Public FY12 As New Float[]
Public SENTIDOX As String
Public SENTIDOY As String
Public a As Integer
Public i As Integer
Public ii As Integer

'Constantes

Public cmv As Float
Public PG As Float

Public Sub MULTIPLICAR()
Px = Xcm * cmv * PG
Py = Ycm * cmv * PG
Gmx = Px / PG
GmY = Py / PG
End

Public Sub Asignar()
If px > py Then
Tpx = TpMin
STpx = Tpx * Px
Try Tpy = STpx / Py
STpy = Int(Tpy) * Py
Else
Tpy = TpMin
STpy = Tpy * Py
Try Tpx = STpy / Px
STpx = Int(Tpx) * Px

Endif
MTpMin.Add(TpMin)
MonitorizarCalc.GridView1[i, 0].Text = TpMin
i = i + 1
Catch
End

Public Sub Sumatorias()
SFracY = Frac(Tpy) * Py
SFracX = Frac(Tpx) * Px
End

Public Sub MargError()
If SFracX <> 0 Then
Errorr = ((SFracX / Tpx) / PG) / cmv
Else If SFracY <> 0 Then
Errorr = ((SFracY / TpY) / PG) / cmv
Endif
If Errorr = Null Then
Errorr = 0
Endif
MError.Add(Errorr)
MonitorizarCalc.GridView1[ii, 1].Text = Errorr
ii = ii + 1
Catch
End


Public Sub limpiar()
Px = 0
PY = 0
Tpx = 0
tpy = 0
STpy = 0
STpx = 0
SFracY = 0
SFracX = 0
 Errorr = 0
 Calcular.SteperXN.Clear
 Calcular.SteperYN.Clear
 Calcular.SteperXandY.Clear
End
Public Sub MargError2()
If SFracX <> 0 Then
Errorr = ((SFracX / Tpx) / PG) / cmv
Else If SFracY <> 0 Then
Errorr = ((SFracY / TpY) / PG) / cmv
Endif
End
Public Sub Asignar2()
If px = 0 Then
  Tpx = 0
  STpx = 0
  Tpy = 2
 STpy = Int(Tpy) * Py
 Else If py = 0 Then
   Tpy = 0
   Tpx = 2
   STpx = Int(Tpx) * Px
Else If px > py Then
Tpx = TpMin
STpx = Tpx * Px
Tpy = STpx / Py
STpy = Int(Tpy) * Py
Else
Tpy = TpMin
STpy = Tpy * Py
Tpx = STpy / Px
STpx = Int(Tpx) * Px
Endif
End

Calcular.Module v.1.5


(Modulo que se encarga en generar los arrelglos para los motores X e Y, Driver)

Public Ey As Integer
Public Ex As Integer
''''''''''''''''''''''''
Public Ax As Byte
Public Bx As Byte
Public Cx As Byte
Public Dx As Byte
''''''''''''''''''''''''
Public Ay As Byte
Public By As Byte
Public Cy As Byte
Public Dy As Byte
Public SteperXN As New Byte[]
Public SteperYN As New Byte[]
Public SteperXandY As New Byte[]


Public Sub autocalculo()
   Dim i As Integer

Dim menor As Float
Variables.limpiar
menor = 10000000
Variables.i = 0
Variables.ii = 0
Try MonitorizarCalc.GridView1.Clear
For i = 2 To 10 Step 1
 Variables.TpMin = i
Variables.limpiar
Variables.PG = 200

'MULTIPLICAR
Variables.MULTIPLICAR
Variables.Asignar
Variables.Sumatorias
Variables.MargError
Next

For i = 0 To Variables.MError.Max Step 1
  If menor > Variables.MError[i] Then
 menor = Variables.MError[i]
 Variables.TpMin = Variables.MTpMin[i]
Variables.limpiar
Variables.PG = 200
'MULTIPLICAR
Variables.MULTIPLICAR
Variables.Asignar2
Variables.Sumatorias
Variables.MargError2
 Endif
Next

Variables.MError.Clear
Variables.MTpMin.Clear   
End

Public Sub ASIGNARXANDY()
If CtrlManual.Chk2.Value = True Or CtrlManual.Chk1.Value = False Then
Ex = 2
Ey = 2
Variables.Tpx = 2
Variables.Tpy = 2
Else
Ex = Variables.Tpx
Ey = Variables.Tpy 
Endif

End

Public Sub ProcessInX()
Dim i As Integer
Dim e As Integer
If Variables.SENTIDOX = "A" Then
Ax = 10
Bx = 9
Cx = 5
Dx = 6
 Else If Variables.SENTIDOX = "D" Then
Ax = 6
Bx = 5
Cx = 9
Dx = 10
Endif

If Variables.Px = 0 Then
Variables.Px = Variables.Py
Ex = Variables.Tpy
Ax = 0
Bx = 0
Cx = 0
Dx = 0
Endif

For e = 1 To (Variables.Px / 4)
 
For i = 1 To Ex
  If i > 15 Then
   SteperXN.Add(0)
  Else
  SteperXN.Add(Ax)
  Endif
Next
For i = 1 To Ex
   If i > 15 Then
   SteperXN.Add(0)
  Else
  SteperXN.Add(Bx)
  Endif
Next
For i = 1 To Ex
  If i > 15 Then
   SteperXN.Add(0)
  Else
  SteperXN.Add(Cx)
  Endif
Next
For i = 1 To Ex
  If i > 15 Then
   SteperXN.Add(0)
  Else
  SteperXN.Add(Dx)
  Endif
Next
Next
End


Public Sub ProcessInY()
  Dim i As Integer
  Dim e As Integer
If Variables.SENTIDOY = "C" Then
Ay = 160
By = 144
Cy = 80
Dy = 96
Else If Variables.SENTIDOY = "B" Then
Ay = 96
By = 80
Cy = 144
Dy = 160
Endif

If Variables.Py = 0 Then
Variables.Py = Variables.Px
Ey = Variables.Tpx
Ay = 0
By = 0
Cy = 0
Dy = 0
Endif

For e = 1 To (Variables.Py / 4)
 
For i = 1 To Ey
    If i > 15 Then
   SteperYN.Add(0)
  Else
  SteperYN.Add(Ay)
  Endif
Next

For i = 1 To Ey
     If i > 15 Then
   SteperYN.Add(0)
  Else
  SteperYN.Add(By)
  Endif
Next
For i = 1 To Ey
     If i > 15 Then
   SteperYN.Add(0)
  Else
  SteperYN.Add(Cy)
  Endif
Next
For i = 1 To Ey
     If i > 15 Then
   SteperYN.Add(0)
  Else
  SteperYN.Add(Dy)
  Endif
Next
 
Next

End

Public Sub sumarXandY()
Dim I As Integer
Dim determint As Integer
If SteperXN.Count = SteperYN.Count Then
  determint = SteperXN.Count
Endif
If SteperXN.Count < SteperYN.Count Then
 determint = SteperXN.Count
 Else
 determint = SteperYN.Count
Endif

For I = 0 To determint - 1
SteperXandY.Add(SteperXN[I] + SteperYN[I])
Next

End
Public Sub sumarXHY()
Dim I As Integer
Dim determint As Integer

If SteperXN.Count = SteperYN.Count Then
  determint = SteperXN.Count
Endif
If SteperYN.Count < SteperXN.Count Then
 determint = SteperXN.Count
 For I = 0 To determint - 1
SteperXandY.Add(SteperXN[I])
Next
For I = 0 To SteperYN.Count - 2
SteperXandY[I] = (SteperXandY[I] + SteperYN[I])
Next
 '----------------------------------------------------------
 Else 
 determint = SteperYN.Count - 1
 For I = 0 To determint - 1
SteperXandY.Add(SteperYN[I])
Next
For I = 0 To SteperXN.Count - 2
SteperXandY[I] = (SteperXandY[I] + SteperXN[I])
Next
Endif
End
Public Sub CNCBEGIN()
Dim G As Boolean
Dim i As Integer
Dim tempp As Float
Dim back As Integer
CtrlManual.Iniciar_Click()
Variables.FX1.Clear
Variables.FX2.Clear
Variables.FY1.Clear
Variables.FY2.Clear
Variables.FY12.Clear
Variables.FY12.Clear
back = -15
MonitorizarCalc.cargar_Click()

For i = 0 To Variables.FX2.Count - 1
If Variables.FX2[i] = 0 And Variables.FY2[i] = 0 Then
back = back + 1
Endif

Next

 CtrlManual.up_Click()
Wait 1
Variables.FX12.Add(Variables.FX1[0])
Variables.Xcm = (Variables.FX1[0])
Variables.SENTIDOX = "D"
 Variables.SENTIDOY = "C"
 Variables.Ycm = 0
Stepper.XHY

 Variables.FY12.Add(Variables.FY1[0])

 Variables.SENTIDOY = "C"
 Variables.Ycm = (Variables.FY12[0])
 Variables.Xcm = 0
Variables.SENTIDOX = "D"

Stepper.XHY

 CtrlManual.down_Click()

  Wait 2

For i = 0 To Variables.FX2.Count - back
CtrlManual.offtodos_Click()

If Variables.FX2[i] = 0 And Variables.FY2[i] = 0 Then

G = True
CtrlManual.up_Click()
  Wait 1

Variables.a = 1
i = i + 1
Else
G = False
Variables.a = 0
Endif

''----------------------------------------------------------------------------------------

tempp = ((Variables.FX2[i]) - (Variables.FX1[i - Variables.a]))
If tempp < 0 Then

Variables.SENTIDOX = "A"
Else

Variables.SENTIDOX = "D"
Endif
Variables.Xcm = Abs(Tempp)
Variables.FY12.Add(Abs(Tempp))

'----------------------------------------------------------------------------------------
Tempp = (Variables.FY2[i] - Variables.FY1[i - Variables.a])
If tempp < 0 Then
 Variables.SENTIDOY = "B"
 Else
 Tempp = (Variables.FY1[i - Variables.a] - Variables.FY2[i])
  Variables.SENTIDOY = "C"
 Endif
  Variables.Ycm = Abs(Tempp)
  Variables.FY12.Add(Abs(Tempp))

'----------------------------------------------------------------------------------------
Stepper.XHY
If G = True Then
 CtrlManual.down_Click()

  Wait 3
Variables.a = 0
G = False
Endif
Next
CtrlManual.offtodos_Click()
Catch
CtrlManual.up_Click()

End

Public Sub monitorV()
MonitorizarCalc.Xcm.Text = Variables.Xcm
MonitorizarCalc.Ycm.Text = Variables.Ycm
MonitorizarCalc.TEX.Text = Variables.SENTIDOX
MonitorizarCalc.TEY.Text = Variables.SENTIDOY
MonitorizarCalc.TpMin.Text = Variables.TpMin
MonitorizarCalc.Tpx.Text = Variables.Tpx
MonitorizarCalc.Tpy.Text = Variables.Tpy
MonitorizarCalc.Px.Text = Variables.Px
MonitorizarCalc.Py.Text = Variables.Py
MonitorizarCalc.SfracX.Text = Variables.SFracX
MonitorizarCalc.SfracY.Text = Variables.SFracY
MonitorizarCalc.STpx.Text = Variables.STpx
MonitorizarCalc.STpy.Text = Variables.stpy
MonitorizarCalc.GMx.Text = Variables.Gmx
MonitorizarCalc.GMy.Text = Variables.Gmy
MonitorizarCalc.Error.Text = Variables.Errorr 

End

MonitorizarCalc.Class v.1.7


 (Clase del formulario donde de puede monitorizar el proceso de corte,y  se realiza las lectura de las coordenadas del proyecto a graficar, Driver )

Public selecttx As Result
Public selectty As Result
Public pasos As Result
Public pasosz As Result
Public ii As Integer
Public s As Integer
Public d As Integer
Public ProyectoName As String

Public Sub Calcular_Click()
Variables.limpiar
Variables.Xcm = Xcm.Text
Variables.Ycm = Ycm.Text
Variables.TpMin = TpMin.Text
Variables.PG = 200
'MULTIPLICAR
Variables.MULTIPLICAR
Variables.Asignar
Variables.Sumatorias
Variables.MargError
'LLAMAR
Px.Text = Variables.Px
Py.Text = Variables.Py
Tpx.Text = Variables.Tpx
Tpy.Text = Variables.Tpy
GMx.Text = Variables.Gmx
GMy.Text = Variables.Gmy
SfracX.Text = Variables.SFracX
SfracY.Text = Variables.SFracY
STpx.Text = Variables.STpx
STpy.Text = Variables.STpy
Error.Text = Variables.Errorr
End

Public Sub calcularAuto_Click()

Dim i As Integer
Dim menor As Float
Variables.limpiar
menor = 10000000
Variables.i = 0
Variables.ii = 0
GridView1.Clear
Variables.SENTIDOX = TEX.Text
Variables.SENTIDOY = TEY.Text
For i = 2 To 10
 Variables.TpMin = i
Variables.limpiar
Variables.Xcm = Xcm.Text
Variables.Ycm = Ycm.Text
Variables.PG = 200


'MULTIPLICAR
Variables.MULTIPLICAR
Variables.Asignar
Variables.Sumatorias
Variables.MargError
'LLAMAR
Px.Text = Variables.Px
Py.Text = Variables.Py
Tpx.Text = Variables.Tpx
Tpy.Text = Variables.Tpy
GMx.Text = Variables.Gmx
GMy.Text = Variables.Gmy
SfracX.Text = Variables.SFracX
SfracY.Text = Variables.SFracY
STpx.Text = Variables.STpx
STpy.Text = Variables.STpy
Error.Text = Variables.Errorr
Next

For i = 0 To Variables.MError.Max Step 1
  If menor > Variables.MError[i] Then
 menor = Variables.MError[i]
 Variables.TpMin = Variables.MTpMin[i]
TpMin.Text = Variables.MTpMin[i]
Variables.limpiar
Variables.Xcm = Xcm.Text
Variables.Ycm = Ycm.Text
Variables.PG = 200
'MULTIPLICAR
Variables.MULTIPLICAR
Variables.Asignar2
Variables.Sumatorias
Variables.MargError2
'LLAMAR
Px.Text = Variables.Px
Py.Text = Variables.Py
Tpx.Text = Variables.Tpx
Tpy.Text = Variables.Tpy
GMx.Text = Variables.Gmx
GMy.Text = Variables.Gmy
SfracX.Text = Variables.SFracX
SfracY.Text = Variables.SFracY
STpx.Text = Variables.STpx
STpy.Text = Variables.STpy
Error.Text = Variables.Errorr
 Endif
Next
Variables.MError.Clear
Variables.MTpMin.Clear

End


Public Sub Button1_Click()
  Me.Close
End



Public Sub Button2_Click()
Me.Minimized = True
End


Public Sub Button4_Click()
 MatrisXY.Show
End


Public Sub Form_Open()
Label22.Text = Mysql.softwareandvercion
CtrlManual.puerto = Open "/dev/port" For Write
CtrlManual.Timer1_Timer()
Variables.cmv = 7
' s = 2
' d = 10
GridView1.Columns.Count = 2
GridView1.Rows.Count = 9
GridView1.Columns.Width = GridView1.Width / 2

GridView2.Columns.Count = 5
GridView2.Rows.Count = 500
GridView2.Columns.Width = GridView2.Width / 5
 MonitorizarCalc.Nombres.text = Mysql.Proyectonombre
Mysql.CONECTAR_BD
Catch
End

Public Sub cargar_Click()
Dim i As Integer
s = 2
d = 10
ProyectoName = Mysql.Proyectonombre
If ProyectoName = "" Then
 ProyectoName = MonitorizarCalc.Nombres.text
Endif
selecttx = Mysql.Conexion.Exec("select x from Graficos where nombre ='" & ProyectoName & "' ")
selectty = Mysql.Conexion.Exec("select y from Graficos where nombre ='" & ProyectoName & "' ")
pasos = Mysql.Conexion.Exec("select COUNT(*)from Graficos where nombre ='" & ProyectoName & "'")

'-------------------------------------------------------------------------------------

For i = 0 To selecttx.Count - 1 Step 1

If selecttx[0] = 0 Then

 Variables.FX1.Add(0)
Else
 Variables.FX1.Add(((selecttx[0] / s) / d))
 Endif
 

If selectty[0] = 0 Then
 Variables.FY1.Add(0)
Else
 Variables.FY1.Add(((selectty[0] / s) / d))
 Endif

'-------------------------------------------------------------------------------------
 
 selecttx.MoveNext

If selecttx[0] = 0 Then
 Variables.FX2.Add(0)
Else
 Variables.FX2.Add(((selecttx[0] / s) / d))
Endif

selectty.MoveNext

If selectty[0] = 0
 Variables.FY2.Add(0)
Else
 Variables.FY2.Add(((selectty[0] / s) / d))
Endif
Next
Catch
End

'-------------------------------------------------------------------------------------

Public Sub Button5_Click()
Dim G As Boolean
Dim i As Integer
Dim tempp As Float
Dim back As Integer
Dim t As Integer
GridView2.Clear
GridView2[0, 0].Text = "Hata 0"
GridView2[0, 1].Text = "A"
GridView2[0, 2].Text = "Hasta 0"
GridView2[0, 3].Text = "B"
GridView2[0, 4].Text = "UP"
 CtrlManual.Iniciar_Click()
Variables.FX1.Clear
Variables.FX2.Clear
Variables.FY1.Clear
Variables.FY2.Clear
Variables.FY12.Clear
Variables.FY12.Clear
back = -15
cargar_Click()
For i = 0 To Variables.FX2.Count - 1
If Variables.FX2[i] = 0 And Variables.FY2[i] = 0 Then
back = back + 1
Endif
Next
 CtrlManual.up_Click()
 
Wait 1
GridView2[1, 0].Foreground = Color.Green
GridView2[1, 1].Foreground = Color.Green
GridView2[1, 4].Foreground = Color.Green
GridView2[1, 2].Foreground = Color.Green
GridView2[1, 3].Foreground = Color.Green

GridView2[1, 0].Text = Variables.FX1[0]
GridView2[1, 1].Text = "D"
GridView2[1, 4].Text = "----"
GridView2[1, 2].Text = "----"
GridView2[1, 3].Text = "----"

Variables.FX12.Add(Variables.FX1[0])
Variables.Xcm = (Variables.FX1[0])
Variables.SENTIDOX = "D"
 Variables.SENTIDOY = "C"
 Variables.Ycm = 0


Stepper.XHY


Variables.FY12.Add(Variables.FY1[0])
GridView2[2, 1].Text = "----"
GridView2[2, 2].Text = Variables.FY1[0]
GridView2[2, 3].Text = "C"
GridView2[2, 4].Text = "----"
GridView2[2, 0].Text = "----"
GridView2[2, 4].Text = "----"
GridView2[2, 0].Foreground = Color.Green
GridView2[2, 1].Foreground = Color.Green
GridView2[2, 4].Foreground = Color.Green
GridView2[2, 2].Foreground = Color.Green
GridView2[2, 3].Foreground = Color.Green

 Variables.SENTIDOY = "C"
 Variables.Ycm = (Variables.FY12[0])
 Variables.Xcm = 0
Variables.SENTIDOX = "D"

Stepper.XHY

CtrlManual.down_Click()
 GridView2[3, 0].Text = "----"
GridView2[3, 1].Text = "----"
GridView2[3, 2].Text = "----"
GridView2[3, 3].Text = "----"
GridView2[3, 4].Text = "DOWN"


  Wait 2
For i = 0 To Variables.FX2.Count - back
CtrlManual.offtodos_Click()


If Variables.FX2[i] = 0 And Variables.FY2[i] = 0 Then

G = True
CtrlManual.up_Click()

  Wait 1
Variables.a = 1
If GridView2[I + 4 + t, 0].Text <> "" Then
t = t + 1
GridView2[I + 4 + t, 0].Text = "----"
GridView2[I + 4 + t, 1].Text = "----"
GridView2[I + 4 + t, 2].Text = "----"
GridView2[I + 4 + t, 3].Text = "----"
GridView2[I + 4 + t, 4].Text = "UP"
t = t - 1
Else
GridView2[I + 4 + t, 0].Text = "----"
GridView2[I + 4 + t, 1].Text = "----"
GridView2[I + 4 + t, 2].Text = "----"
GridView2[I + 4 + t, 3].Text = "----"
GridView2[I + 4 + t, 4].Text = "UP" 
Endif
 
i = i + 1

Else
G = False
Variables.a = 0
Endif
'/////////////////////////////////

'-------------------------------------------------------------------------------------

tempp = ((Variables.FX2[i]) - (Variables.FX1[i - Variables.a]))
If tempp < 0 Then

Variables.SENTIDOX = "A"
GridView2[I + 4 + t, 1].Text = "A"
' TEX.Text = "A"
Else

Variables.SENTIDOX = "D"
GridView2[I + 4 + t, 1].Text = "D"
' TEX.Text = "D"
Endif
Variables.Xcm = Abs(Tempp)
Variables.FY12.Add(Abs(Tempp))
' Xcm.Text = Abs(Tempp)
 GridView2[I + 4 + t, 0].Text = Abs(Tempp)
   GridView2[I + 4 + t, 4].Text = "----"

'-------------------------------------------------------------------------------------

Tempp = (Variables.FY2[i] - Variables.FY1[i - Variables.a])
If tempp < 0 Then
 Variables.SENTIDOY = "B"
 GridView2[I + 4 + t, 3].Text = "B"
' TEY.Text = "B"
 Else
 Tempp = (Variables.FY1[i - Variables.a] - Variables.FY2[i])
 
  Variables.SENTIDOY = "C"
  GridView2[I + 4 + t, 3].Text = "C"
'   TEY.Text = "C"
 Endif
  Variables.Ycm = Abs(Tempp)
  Variables.FY12.Add(Abs(Tempp))

'  Ycm.Text = Abs(Tempp)
If GridView2[I + 3 + t, 4].Text = "UP" Then
GridView2[I + 4 + t, 0].Foreground = Color.Green
GridView2[I + 4 + t, 1].Foreground = Color.Green
GridView2[I + 4 + t, 2].Foreground = Color.Green
GridView2[I + 4 + t, 3].Foreground = Color.Green
GridView2[I + 4 + t, 4].Foreground = Color.Green
 
Endif

  GridView2[I + 4 + t, 2].Text = Abs(Tempp)

  GridView2[I + 4 + t, 4].Text = "----"
 
'-------------------------------------------------------------------------------------

Stepper.XHY
If G = True Then
 CtrlManual.down_Click()
t = t + 1
GridView2[I + 4 + t, 0].Text = "----"
GridView2[I + 4 + t, 1].Text = "----"
GridView2[I + 4 + t, 2].Text = "----"
GridView2[I + 4 + t, 3].Text = "----"
GridView2[I + 4 + t, 4].Text = "DOWN"


  Wait 3
Variables.a = 0
G = False
Endif

Next
CtrlManual.offtodos_Click()
Catch
CtrlManual.up_Click()
GridView2[I + 4 + t, 0].Text = "----"
GridView2[I + 4 + t, 1].Text = "----"
GridView2[I + 4 + t, 2].Text = "----"
GridView2[I + 4 + t, 3].Text = "----"
GridView2[I + 4 + t, 4].Text = "UP"
GridView2[I + 4 + t, 0].Foreground = Color.red
GridView2[I + 4 + t, 1].Foreground = Color.red
GridView2[I + 4 + t, 2].Foreground = Color.red
GridView2[I + 4 + t, 3].Foreground = Color.red
GridView2[I + 4 + t, 4].Foreground = Color.red

End


Public Sub Timer1_Timer()
Dim segundos As String
Dim Minutos As String
segundos = Format$((Stepper.tiempo) - (Stepper.progrest), "00.#")
Minutos = Format$((Stepper.tiempo / 60) - (Stepper.progrest / 60), "00.##")
  ProgressBar2.Value = Stepper.progres
  If ((Stepper.tiempo) - (Stepper.progrest)) < 60 Then
    Label9.Text = ((segundos) & " Seg")
    Else
    Label9.Text = ((Minutos) & " Min")
  Endif
End

Public Sub Button3_Click()
  MatrisXY.Show
End

Public Sub Cerrar_Click()
Dim respuesta As Integer
  respuesta = Message.Question("¿Deseas Cerrar la Ventana Actual?", "Cerrar", "Cancelar")
  If respuesta = 1 Then
Me.Close
  Endif
End

Public Sub Minimizar_Click()
 Me.Minimized = True
 FMain.ShowDialog
End

.


2013 - 2014 © Autor : Denis German Gimenez

CADCNC V: 1.0