2f0e33d598
- aggiunto campo CMD.HEAD per script lua SawProbing - migliorato calcolo tagli diretti per macchine multitesta.
336 lines
14 KiB
VB.net
336 lines
14 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class DirectCutPageUC
|
|
|
|
' Dichiarazione delle Page UserControl
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Friend m_MachineButtons As MachineButtonsUC
|
|
Friend m_ManualAxesMove As ManualAxesMoveUC
|
|
Friend m_SingleCut As SingleCutUC
|
|
Friend m_MultipleCut As MultipleCut
|
|
Friend m_GridCut As GridCut
|
|
Friend m_CopyTemplate As CopyTemplateUC
|
|
Friend m_FlatteningCut As FlatteningCut
|
|
Friend m_SawTest As SawTestUC
|
|
' Stato di visualizzazione della macchina
|
|
Friend m_bShowMachine As Boolean = False
|
|
Friend m_nMachLook As Integer = MCH_LOOK.ALL
|
|
' Dati generali CN
|
|
Friend m_CN As CN_generico
|
|
Private m_bFirst As Boolean = True
|
|
' Riferimento alla pagina correntemente attiva
|
|
Friend m_ActiveDirectCutPage As DirectCutPages
|
|
|
|
' Oggetto di gestione della macchina fotografica
|
|
Friend m_Camera As New Camera
|
|
|
|
Enum DirectCutPages
|
|
DirectCut
|
|
SingleCut
|
|
MultipleCut
|
|
GridCut
|
|
FlatteningCut
|
|
CopyTemplate
|
|
SawTest
|
|
End Enum
|
|
|
|
Private Sub DirectCutPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
|
|
'Creazione delle Page UserControl
|
|
m_MachineButtons = New MachineButtonsUC
|
|
m_ManualAxesMove = New ManualAxesMoveUC
|
|
m_SingleCut = New SingleCutUC
|
|
m_MultipleCut = New MultipleCut
|
|
m_GridCut = New GridCut
|
|
m_FlatteningCut = New FlatteningCut
|
|
m_CopyTemplate = New CopyTemplateUC
|
|
m_SawTest = New SawTestUC
|
|
|
|
'Posizionemento nella griglia delle Page UserControl
|
|
m_MachineButtons.SetValue(Grid.RowProperty, 2)
|
|
m_ManualAxesMove.SetValue(Grid.RowProperty, 1)
|
|
m_SingleCut.SetValue(Grid.RowProperty, 1)
|
|
m_MultipleCut.SetValue(Grid.RowProperty, 1)
|
|
m_GridCut.SetValue(Grid.RowProperty, 1)
|
|
m_FlatteningCut.SetValue(Grid.RowProperty, 1)
|
|
m_CopyTemplate.SetValue(Grid.RowProperty, 1)
|
|
m_SawTest.SetValue(Grid.RowProperty, 1)
|
|
|
|
'Assegno MachineButtons alla pagina
|
|
LowerButtonGrid.Children.Add(m_MachineButtons)
|
|
|
|
ManualBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 1)
|
|
SingleCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 2)
|
|
MultipleCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 3)
|
|
GridCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 4)
|
|
FlatteningCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 6)
|
|
CopyTemplateBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 9)
|
|
SawTestBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 7)
|
|
End Sub
|
|
|
|
Private Sub DirectCutPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
m_ActiveDirectCutPage = DirectCutPages.DirectCut
|
|
|
|
' Se macchina fotografica abilitata
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_PHOTO) Then
|
|
PhotoBtn.IsEnabled = True
|
|
' Inizializzo gestore macchina fotografica
|
|
m_Camera.Init()
|
|
Else
|
|
PhotoBtn.IsEnabled = False
|
|
End If
|
|
|
|
' Attivo le lavorazioni solo se esiste il grezzo
|
|
Dim bRawOk As Boolean = (GetRawHeight() > EPS_SMALL)
|
|
SingleCutBtn.IsEnabled = bRawOk
|
|
MultipleCutBtn.IsEnabled = bRawOk
|
|
GridCutBtn.IsEnabled = bRawOk
|
|
FlatteningCutBtn.IsEnabled = bRawOk
|
|
SawTestBtn.IsEnabled = bRawOk
|
|
|
|
' Nascondo i pezzi in parcheggio
|
|
HideParkedParts()
|
|
EgtZoom(ZM.ALL)
|
|
|
|
End Sub
|
|
|
|
Private Sub PhotoBtn_Click(sender As Object, e As RoutedEventArgs) Handles PhotoBtn.Click
|
|
' Se macchina fotografica abilitata, faccio una foto
|
|
If m_Camera.GetCameraLink() Then
|
|
If Not m_Camera.CameraClick() Then
|
|
m_MainWindow.m_CurrentProjectPageUC.SetErrorMessage(EgtMsg(90313)) 'Fotografia non riuscita
|
|
End If
|
|
' Altrimenti lancio browser di immagini
|
|
Else
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_PhotoPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Photo
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RawPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RawPartBtn.Click
|
|
m_MainWindow.m_CurrentProjectPageUC.CurrProjGrid.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(Me)
|
|
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_RawPartPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.RawPart
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut
|
|
End Sub
|
|
|
|
Private Sub ManualBtn_Click(sender As Object, e As RoutedEventArgs) Handles ManualBtn.Click
|
|
LeftButtonGrid.Children.Add(m_ManualAxesMove)
|
|
End Sub
|
|
|
|
Private Sub SingleCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles SingleCutBtn.Click
|
|
LeftButtonGrid.Children.Add(m_SingleCut)
|
|
m_ActiveDirectCutPage = DirectCutPages.SingleCut
|
|
End Sub
|
|
|
|
Private Sub MultipleCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles MultipleCutBtn.Click
|
|
LeftButtonGrid.Children.Add(m_MultipleCut)
|
|
m_ActiveDirectCutPage = DirectCutPages.MultipleCut
|
|
End Sub
|
|
|
|
Private Sub GridCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles GridCutBtn.Click
|
|
LeftButtonGrid.Children.Add(m_GridCut)
|
|
m_ActiveDirectCutPage = DirectCutPages.GridCut
|
|
End Sub
|
|
|
|
Private Sub FlatteningCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles FlatteningCutBtn.Click
|
|
LeftButtonGrid.Children.Add(m_FlatteningCut)
|
|
m_ActiveDirectCutPage = DirectCutPages.FlatteningCut
|
|
End Sub
|
|
|
|
Private Sub CopyTemplateBtn_Click(sender As Object, e As RoutedEventArgs) Handles CopyTemplateBtn.Click
|
|
LeftButtonGrid.Children.Add(m_CopyTemplate)
|
|
m_ActiveDirectCutPage = DirectCutPages.CopyTemplate
|
|
End Sub
|
|
|
|
Private Sub SawTestBtn_Click(sender As Object, e As RoutedEventArgs) Handles SawTestBtn.Click
|
|
LeftButtonGrid.Children.Add(m_SawTest)
|
|
m_ActiveDirectCutPage = DirectCutPages.SawTest
|
|
End Sub
|
|
|
|
Private Sub MachViewModeBtn_Click(sender As Object, e As RoutedEventArgs) Handles MachViewModeBtn.Click
|
|
If m_bShowMachine Then
|
|
' aggiorno lo stato
|
|
Select Case m_nMachLook
|
|
Case MCH_LOOK.ALL
|
|
m_nMachLook = MCH_LOOK.TAB_HEAD
|
|
Case MCH_LOOK.TAB_HEAD
|
|
m_nMachLook = MCH_LOOK.TAB_TOOL
|
|
Case Else
|
|
m_nMachLook = MCH_LOOK.ALL
|
|
End Select
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(m_nMachLook)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub DirectCutPage_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
|
|
Select Case m_ActiveDirectCutPage
|
|
Case DirectCutPages.DirectCut
|
|
' Non è necessario fare alcunché
|
|
Case DirectCutPages.SingleCut
|
|
LeftButtonGrid.Children.Remove(m_SingleCut)
|
|
Case DirectCutPages.MultipleCut
|
|
LeftButtonGrid.Children.Remove(m_MultipleCut)
|
|
Case DirectCutPages.GridCut
|
|
LeftButtonGrid.Children.Remove(m_GridCut)
|
|
Case DirectCutPages.FlatteningCut
|
|
LeftButtonGrid.Children.Remove(m_FlatteningCut)
|
|
Case DirectCutPages.CopyTemplate
|
|
LeftButtonGrid.Children.Remove(m_CopyTemplate)
|
|
Case DirectCutPages.SawTest
|
|
LeftButtonGrid.Children.Remove(m_SawTest)
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub SawProbingBtn_Click(sender As Object, e As RoutedEventArgs) Handles SawProbingBtn.Click
|
|
' Recupero file LUA
|
|
EgtLuaExecFile(m_MainWindow.m_CurrentMachine.sMachDir() & "\DirectCmd\SawProbing.lua")
|
|
' Recupero lama montata dal Db utensili
|
|
EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw)
|
|
' Imposto parametri
|
|
Dim dToolParam As Double = 0
|
|
Dim sToolParam As String = String.Empty
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, sToolParam)
|
|
EgtLuaSetGlobStringVar("CMD.HEAD", sToolParam)
|
|
EgtLuaSetGlobNumVar("CMD.TCPOS", 100)
|
|
'Per ora fisso 100 per le macchine senza ToolChanger, ma da modificare per poterle gestire!!!!!!
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolParam)
|
|
EgtLuaSetGlobNumVar("CMD.DIAM", dToolParam * 1000)
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, dToolParam)
|
|
EgtLuaSetGlobNumVar("CMD.THICK", dToolParam * 1000)
|
|
EgtTdbGetCurrToolParam(MCH_TP.LEN, dToolParam)
|
|
EgtLuaSetGlobNumVar("CMD.LENGTH", dToolParam * 1000)
|
|
EgtLuaSetGlobBoolVar("CMD.INCHES", m_MainWindow.m_CNCommunication.GetMachineInInches())
|
|
EgtLuaCallFunction("CMD.CmdString")
|
|
' Leggo variabili
|
|
Dim CmdString As String = String.Empty
|
|
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("CMD")
|
|
' Modifico stringa per inserire i newline
|
|
CmdString = CmdString.Replace("<br/>", Environment.NewLine)
|
|
' Creo file...
|
|
Dim FilePath As String = m_MainWindow.GetCncDir() & "\SawProbing" & m_MainWindow.m_CurrentMachine.sIsoFileExt
|
|
' ...e ci scrivo
|
|
Dim Writer As New IO.StreamWriter(FilePath, False)
|
|
Writer.Write(CmdString)
|
|
Writer.Close()
|
|
' Verifico se sono connesso alla macchina prima di continuare
|
|
If Not m_MainWindow.m_bNCLink Then
|
|
Exit Sub
|
|
End If
|
|
' Mando file al CN
|
|
If Not m_MainWindow.m_CNCommunication.SendProgram(FilePath, 900) Then
|
|
Exit Sub
|
|
End If
|
|
' Aspetto e lo avvio
|
|
System.Threading.Thread.Sleep(300)
|
|
m_MainWindow.m_CNCommunication.m_CN.DGeneralFunctions_CycleStart()
|
|
' Creo MsgBox di attesa
|
|
Dim MsgBoxStateInfo As New EgtMsgBox(m_MainWindow, EgtMsg(MSG_DIRECTCUTPAGEUC + 41), EgtMsg(MSG_DIRECTCUTPAGEUC + 42), True, EgtMsgBox.Buttons.CANCEL, EgtMsgBox.Icons.NULL)
|
|
Dim ProbingStateNameVar As String = String.Empty
|
|
GetPrivateProfileString(S_MACH_PROBING, K_PROBINGSTATEVAR, "", ProbingStateNameVar, m_MainWindow.GetMachIniFile())
|
|
m_MainWindow.m_CNCommunication.m_CN.n_DReadELS_handle = 0
|
|
m_MainWindow.m_CNCommunication.m_CN.ReadEls_Add_Parameter(ProbingStateNameVar, 1)
|
|
' Definisco flag tastatura
|
|
Dim bProbingOk As Boolean = False
|
|
For I = 0 To 120
|
|
' Se NUM Axium o Siemens devo rileggere la variabile ad ogni ciclo
|
|
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or
|
|
m_MainWindow.m_CNCommunication.m_nNCType = 3 Then
|
|
m_MainWindow.m_CNCommunication.m_CN.ReadEls_Add_Parameter(ProbingStateNameVar, 1)
|
|
End If
|
|
If m_MainWindow.m_CNCommunication.m_CN.n_DReadELS_handle = 1 Then
|
|
Dim L108Val As Integer = CInt(m_MainWindow.m_CNCommunication.m_CN.d_DReadELS_value)
|
|
Select Case L108Val
|
|
Case 0
|
|
' Non faccio alcunchè perchè sta tastando
|
|
Case 1
|
|
' Tastatura completata
|
|
bProbingOk = True
|
|
Exit For
|
|
Case 2
|
|
' Errore
|
|
bProbingOk = False
|
|
Exit For
|
|
End Select
|
|
End If
|
|
System.Threading.Thread.Sleep(1000)
|
|
' Incremento progressbar
|
|
MsgBoxStateInfo.LoadingPrBr_Value += 100 / 120
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Verifico se interrotto dall'utente
|
|
If MsgBoxStateInfo.DialogResult = 0 Then
|
|
bProbingOk = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
' Se tastatura riuscita
|
|
If bProbingOk Then
|
|
' Leggo spessore misurato
|
|
Dim SawDiameterNameVar As String = String.Empty
|
|
GetPrivateProfileString(S_MACH_PROBING, K_SAWDIAMETER, "", SawDiameterNameVar, m_MainWindow.GetMachIniFile())
|
|
m_MainWindow.m_CNCommunication.m_CN.n_DReadELS_handle = 0
|
|
m_MainWindow.m_CNCommunication.m_CN.ReadEls_Add_Parameter(SawDiameterNameVar, 1)
|
|
Dim SawDiam As Double = 0
|
|
For I = 0 To 20
|
|
' Se NUM Axium o Siemens devo rileggere la variabile ad ogni ciclo
|
|
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or
|
|
m_MainWindow.m_CNCommunication.m_nNCType = 3 Then
|
|
m_MainWindow.m_CNCommunication.m_CN.ReadEls_Add_Parameter(SawDiameterNameVar, 1)
|
|
End If
|
|
If m_MainWindow.m_CNCommunication.m_CN.n_DReadELS_handle = 1 Then
|
|
SawDiam = m_MainWindow.m_CNCommunication.m_CN.d_DReadELS_value
|
|
MsgBoxStateInfo.LoadingPrBr_Value = 100
|
|
MsgBoxStateInfo.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 43)
|
|
EgtOutLog("SawDiam=" & SawDiam.ToString())
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
System.Threading.Thread.Sleep(1500)
|
|
' Trasformo misura rilevata in mm
|
|
If m_MainWindow.m_CNCommunication.GetMachineInInches() Then
|
|
SawDiam *= ONEINCH / 1000
|
|
Else
|
|
SawDiam *= ONEMM / 1000
|
|
End If
|
|
' Imposto spessore misurato come diametro lama
|
|
If SawDiam > -EPS_ZERO Then
|
|
' Recupero lama montata dal Db utensili
|
|
EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw)
|
|
EgtTdbSetCurrToolParam(MCH_TP.DIAM, SawDiam)
|
|
EgtTdbSaveCurrTool()
|
|
EgtTdbSave()
|
|
End If
|
|
' Chiudo msgbox
|
|
MsgBoxStateInfo.Close()
|
|
Exit For
|
|
End If
|
|
System.Threading.Thread.Sleep(100)
|
|
Next
|
|
' Altrimenti tastatura non riuscita o interrotta dall'utente
|
|
Else
|
|
m_MainWindow.m_CurrentProjectPageUC.SetErrorMessage(EgtMsg(MSG_DIRECTCUTPAGEUC + 44))
|
|
MsgBoxStateInfo.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 44) ' Errore in tastatura lama
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
System.Threading.Thread.Sleep(1500)
|
|
MsgBoxStateInfo.Close()
|
|
End If
|
|
' Cancello messaggio
|
|
m_MainWindow.m_CurrentProjectPageUC.ClearMessage()
|
|
End Sub
|
|
|
|
Private Sub ManualModeBtn_Click(sender As Object, e As RoutedEventArgs) Handles ManualModeBtn.Click
|
|
' Imposto modalità manuale della macchina
|
|
Dim nResult As Short = m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale
|
|
End Sub
|
|
|
|
End Class
|