a8dc3d2642
- aggiunto log dei comandi diretti 3assi e 5assi - aggiunta rimozione manuale sfridi anche con movimento pezzi con ventose - aggiunta possibilità di eliminare home finale nei tagli diretti - con NUOVO progetto e pezzi parcheggiati si chiede se conservarli - spessore pezzo con 3 decimali (per inches) - migliorata visualizzazione coordinate assi in simulazione - in lista lavorazioni aggiunto flag sui tagli inclinati - corretta visualizzazione famiglie utensili da Ini.
197 lines
7.4 KiB
VB.net
197 lines
7.4 KiB
VB.net
Imports System.Windows.Threading
|
|
Imports EgtUILib
|
|
|
|
Public Class ManualAxesMoveUC
|
|
|
|
' Dichiarazione delle Page UserControl
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
Friend m_CN As CN_generico
|
|
|
|
' Modalità di movimento (G0 o G1)
|
|
Private m_bG0Active As Boolean
|
|
|
|
' Timer per aggiornamento nomi assi
|
|
Private m_Timer As New DispatcherTimer
|
|
|
|
Private Sub ManualAxesMove_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
AddHandler m_Timer.Tick, AddressOf Timer_tick
|
|
End Sub
|
|
|
|
Private Sub ManualAxesMove_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Nomi feed e speed
|
|
FeedTxBl.Text = "F"
|
|
SpeedTxBl.Text = "S"
|
|
' Valori feed e speed da lama corrente
|
|
Dim dTemp As Double = 0
|
|
EgtTdbSetCurrTool(m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text)
|
|
EgtTdbGetCurrToolParam(MCH_TP.FEED, dTemp)
|
|
FeedTxBx.Text = LenToString(dTemp, 2)
|
|
EgtTdbGetCurrToolParam(MCH_TP.SPEED, dTemp)
|
|
SpeedTxBx.Text = DoubleToString(dTemp, 0)
|
|
' Nomi assi
|
|
UpdateAxesNames()
|
|
' Valori assi lineari : assegno '0' perchè incrementali
|
|
L1TxBx.Text = "0"
|
|
L2TxBx.Text = "0"
|
|
L3TxBx.Text = "0"
|
|
' Valori assi rotanti : assegno i valori macchina
|
|
Dim dL1, dL2, dL3, dR1, dR2 As Double
|
|
m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2)
|
|
R1TxBx.Text = DoubleToString(dR1, 3)
|
|
R2TxBx.Text = DoubleToString(dR2, 3)
|
|
' Lancio timer per aggiornamento interfaccia
|
|
m_Timer.Interval = TimeSpan.FromMilliseconds(200)
|
|
m_Timer.Start()
|
|
' Imposto movimenti in rapido
|
|
G0Btn.IsChecked = True
|
|
End Sub
|
|
|
|
Private Sub ManualAxesMove_UnLoaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
|
|
m_Timer.Stop()
|
|
End Sub
|
|
|
|
Private Sub UpdateAxesNames()
|
|
Dim sL1 As String = String.Empty
|
|
Dim sL2 As String = String.Empty
|
|
Dim sL3 As String = String.Empty
|
|
Dim sR1 As String = String.Empty
|
|
Dim sR2 As String = String.Empty
|
|
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
|
|
If Not m_CN.Is_G24_active() Then
|
|
L1Btn.Content = sL1 ' X
|
|
L2Btn.Content = sL2 ' Y
|
|
L3Btn.Content = sL3 ' Z
|
|
Else
|
|
L1Btn.Content = "P" ' perpendicular
|
|
L2Btn.Content = "H" ' horizontal
|
|
L3Btn.Content = "V" ' vertical
|
|
End If
|
|
R1Btn.Content = sR1 ' C
|
|
R2Btn.Content = sR2 ' B
|
|
End Sub
|
|
|
|
Private Sub Timer_tick()
|
|
UpdateAxesNames()
|
|
End Sub
|
|
|
|
Private Sub XXBtn_Click(sender As Object, e As RoutedEventArgs) Handles L1Btn.Click, L2Btn.Click, L3Btn.Click, R1Btn.Click, R2Btn.Click
|
|
Dim CurrentBtn As Button = e.Source
|
|
Dim nTemp As Integer = 0
|
|
Dim dTemp As Double = 0
|
|
Dim CmdString As String = String.Empty
|
|
EgtLuaExecFile(m_MainWindow.GetMachinesRootDir() & "\" & m_MainWindow.GetCurrMachine() & "\DirectCmd\AxesMove.lua")
|
|
EgtLuaSetGlobBoolVar("CMD.G0", m_bG0Active)
|
|
StringToLen(FeedTxBx.Text, dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.F", dTemp)
|
|
StringToDouble(SpeedTxBx.Text, dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.S", dTemp)
|
|
' Leggo gli assi rispetto allo 0 macchina
|
|
m_CN.set_OP_OM(0)
|
|
System.Threading.Thread.Sleep(100)
|
|
Dim dL1o, dL2o, dL3o As Double
|
|
m_MainWindow.m_CNCommunication.GetLinearAxesPositions(dL1o, dL2o, dL3o)
|
|
Dim dR1, dR2 As Double
|
|
m_MainWindow.m_CNCommunication.GetRotaryAxesPositions(dR1, dR2)
|
|
EgtLuaSetGlobNumVar("CMD.L1o", dL1o)
|
|
EgtLuaSetGlobNumVar("CMD.L2o", dL2o)
|
|
EgtLuaSetGlobNumVar("CMD.L3o", dL3o)
|
|
EgtLuaSetGlobNumVar("CMD.R1", dR1)
|
|
EgtLuaSetGlobNumVar("CMD.R2", dR2)
|
|
' Leggo gli assi lineari rispetto allo 0 pezzo (per essere compatibile con G150)
|
|
m_CN.set_OP_OM(1)
|
|
System.Threading.Thread.Sleep(1000)
|
|
Dim dL1, dL2, dL3 As Double
|
|
m_MainWindow.m_CNCommunication.GetLinearAxesPositions(dL1, dL2, dL3)
|
|
EgtLuaSetGlobNumVar("CMD.L1", dL1)
|
|
EgtLuaSetGlobNumVar("CMD.L2", dL2)
|
|
EgtLuaSetGlobNumVar("CMD.L3", dL3)
|
|
' Ripristino lettura rispetto a 0 macchina
|
|
m_CN.set_OP_OM(0)
|
|
System.Threading.Thread.Sleep(100)
|
|
' Leggo se in modalità 3a o 5a
|
|
Dim bG24On As Boolean = m_CN.Is_G24_active()
|
|
EgtLuaSetGlobBoolVar("CMD.G24", bG24On)
|
|
' Assegno nome e valore asse da muovere
|
|
EgtLuaSetGlobStringVar("CMD.AXISNAME", GetAxisName(CurrentBtn))
|
|
EgtLuaSetGlobNumVar("CMD.AXISMOVE", GetAxisMove(CurrentBtn))
|
|
' Calcolo stringa di comando risultante
|
|
EgtLuaExecLine("CmdString()")
|
|
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("CmdString")
|
|
EgtLuaResetGlobVar("CMD")
|
|
' Log del comando
|
|
EgtOutLog("CmdString=" & CmdString)
|
|
' Eseguo in MDI
|
|
m_CN.DGeneralFunctions_WriteCncMode(2) ' Modalità MDI
|
|
System.Threading.Thread.Sleep(150)
|
|
m_CN.sz_ManualDataInput = CmdString
|
|
m_CN.MDI_command()
|
|
System.Threading.Thread.Sleep(150)
|
|
m_CN.DGeneralFunctions_CycleStart()
|
|
m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale
|
|
End Sub
|
|
|
|
Private Function GetAxisName(ByVal nBtnName As Button) As String
|
|
Dim sL1 As String = String.Empty
|
|
Dim sL2 As String = String.Empty
|
|
Dim sL3 As String = String.Empty
|
|
Dim sR1 As String = String.Empty
|
|
Dim sR2 As String = String.Empty
|
|
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
|
|
Select Case nBtnName.Name
|
|
Case L1Btn.Name
|
|
Return sL1
|
|
Case L2Btn.Name
|
|
Return sL2
|
|
Case L3Btn.Name
|
|
Return sL3
|
|
Case R1Btn.Name
|
|
Return sR1
|
|
Case R2Btn.Name
|
|
Return sR2
|
|
End Select
|
|
Return String.Empty
|
|
End Function
|
|
|
|
Private Function GetAxisMove(ByVal nBtnName As Button) As Double
|
|
Dim dVal As Double = 0
|
|
Select Case nBtnName.Name
|
|
Case L1Btn.Name
|
|
StringToLen(L1TxBx.Text, dVal)
|
|
Case L2Btn.Name
|
|
StringToLen(L2TxBx.Text, dVal)
|
|
Case L3Btn.Name
|
|
StringToLen(L3TxBx.Text, dVal)
|
|
Case R1Btn.Name
|
|
StringToDouble(R1TxBx.Text, dVal)
|
|
Case R2Btn.Name
|
|
StringToDouble(R2TxBx.Text, dVal)
|
|
End Select
|
|
Return dVal
|
|
End Function
|
|
|
|
Private Sub BackBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackBtn.Click
|
|
m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me)
|
|
End Sub
|
|
|
|
Private Sub G0Btn_Checked(sender As Object, e As RoutedEventArgs) Handles G0Btn.Checked
|
|
m_bG0Active = True
|
|
G0TxBl.Foreground = Application.Current.FindResource("OmagCut_Blue")
|
|
FeedTxBl.Foreground = Application.Current.FindResource("OmagCut_Gray")
|
|
FeedTxBx.IsEnabled = False
|
|
SpeedTxBl.Foreground = Application.Current.FindResource("OmagCut_Gray")
|
|
SpeedTxBx.IsEnabled = False
|
|
End Sub
|
|
|
|
Private Sub G0Btn_Unchecked(sender As Object, e As RoutedEventArgs) Handles G0Btn.Unchecked
|
|
m_bG0Active = False
|
|
G0TxBl.Foreground = Application.Current.FindResource("OmagCut_Gray")
|
|
FeedTxBl.Foreground = Brushes.Black
|
|
FeedTxBx.IsEnabled = True
|
|
SpeedTxBl.Foreground = Brushes.Black
|
|
SpeedTxBx.IsEnabled = True
|
|
End Sub
|
|
|
|
End Class
|