Files
OmagCUT/Machine/ChooseToolWD.xaml.vb
Dario Sassi 97836125a7 OmagCUT 2.7k1 :
- in tastatura utensile corretta assegnazione flag CMD.ISSAW
- in trasmissione part-program a Fanuc non si eliminano più le linee con M98<...>
- all'avvio programma non si scrivono più nelle note della lama corrente i valori appena letti da queste.
2025-11-04 13:26:06 +01:00

158 lines
6.8 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.Security.Cryptography.X509Certificates
Imports EgtUILib
Public Class ChooseToolWD
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
Private m_SetUpToolList As New ObservableCollection(Of ToolPos)
Sub New(Owner As Window)
Me.Owner = Owner
InitializeComponent()
End Sub
Private Sub OpenFile_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Posizione finestra
Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2
' Definizione del collegamento tra ItemList e ListBox1
SetUpToolListBox.ItemsSource = m_SetUpToolList
FilePathTxBl.Text = EgtMsg(90945) ' Selezionare l'utensile da tastare
End Sub
Private Sub OpenFile_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
' carico direttorio
LoadSetUpTool()
' se presente seleziono il primo elemento
If m_SetUpToolList.Count > 0 Then
SetUpToolListBox.SelectedItem = m_SetUpToolList(0)
OkBtn.IsEnabled = True
Else
OkBtn.IsEnabled = False
End If
End Sub
Private Function LoadSetUpTool() As Boolean
Select Case m_MainWindow.m_CurrentMachine.MountedToolConfig
Case CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL
m_SetUpToolList.Add(New ToolPos(m_MainWindow.m_CurrentMachine.sCurrSaw, "T100", True))
If Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrMill) Then
m_SetUpToolList.Add(New ToolPos(m_MainWindow.m_CurrentMachine.sCurrMill, "T100", False))
End If
If Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrDrill) Then
m_SetUpToolList.Add(New ToolPos(m_MainWindow.m_CurrentMachine.sCurrDrill, "T100", False))
End If
Return True
Case CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER
If m_MainWindow.m_CurrentMachine.bSaw And Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrSaw) Then
EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw)
Dim sToolPos As String = String.Empty
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sToolPos)
m_SetUpToolList.Add(New ToolPos(m_MainWindow.m_CurrentMachine.sCurrSaw, sToolPos, True))
End If
' Recupero tutti gli utensili attrezzati (nel ToolChanger e nel ManualToolChanger)
For Each ToolChangerPos As ToolChangerPos In m_MainWindow.m_CurrentMachine.ManualToolChanger
m_SetUpToolList.Add(New ToolPos(ToolChangerPos.sTool, ToolChangerPos.sName, False))
Next
Return True
Case CurrentMachine.MountedToolConfigs.TOOLCHANGER
' Recupero tutti gli utensili attrezzati (nel ToolChanger e nel ManualToolChanger)
If m_MainWindow.m_CurrentMachine.bSaw And Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrSaw) Then
EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw)
Dim sToolPos As String = String.Empty
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sToolPos)
m_SetUpToolList.Add(New ToolPos(m_MainWindow.m_CurrentMachine.sCurrSaw, sToolPos, True))
End If
For Each ToolChangerPos As ToolChangerPos In m_MainWindow.m_CurrentMachine.ToolChanger
If Not String.IsNullOrWhiteSpace(ToolChangerPos.sTool) Then
m_SetUpToolList.Add(New ToolPos(ToolChangerPos.sTool, ToolChangerPos.sName, False))
End If
Next
For Each ToolChangerPos As ToolChangerPos In m_MainWindow.m_CurrentMachine.ManualToolChanger
If Not String.IsNullOrWhiteSpace(ToolChangerPos.sTool) Then
m_SetUpToolList.Add(New ToolPos(ToolChangerPos.sTool, ToolChangerPos.sName, False))
End If
Next
Return True
Case CurrentMachine.MountedToolConfigs.TOOLCHANGERWITHSAW
For Each ToolChangerPos As ToolChangerPos In m_MainWindow.m_CurrentMachine.ToolChanger
If Not String.IsNullOrWhiteSpace(ToolChangerPos.sTool) Then
Dim bIsSaw As Boolean = ToolIsSaw( ToolChangerPos.sTool)
m_SetUpToolList.Add(New ToolPos(ToolChangerPos.sTool, ToolChangerPos.sName, bIsSaw))
End If
Next
For Each ToolChangerPos As ToolChangerPos In m_MainWindow.m_CurrentMachine.ManualToolChanger
If Not String.IsNullOrWhiteSpace(ToolChangerPos.sTool) Then
Dim bIsSaw As Boolean = ToolIsSaw( ToolChangerPos.sTool)
m_SetUpToolList.Add(New ToolPos(ToolChangerPos.sTool, ToolChangerPos.sName, bIsSaw))
End If
Next
Return True
Case Else
Return False
End Select
End Function
Private Function ToolIsSaw( sToolName As String) As Boolean
If Not EgtTdbSetCurrTool( sToolName) Then Return False
Dim nType As Integer = MCH_TY.NONE
EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType)
Return ((nType And MCH_TF.SAWBLADE) <> 0)
End Function
Private Sub SetUpToolListBox_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) Handles SetUpToolListBox.PreviewMouseUp
' Disabilito Ok
OkBtn.IsEnabled = False
' Recupero item selezionato
If SetUpToolListBox.SelectedItems.Count() = 0 Then
Return
End If
' A seconda del tipo
OkBtn.IsEnabled = True
End Sub
Private Sub SetUpToolListBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles SetUpToolListBox.SelectionChanged
' Disabilito Ok
OkBtn.IsEnabled = False
' Recupero item selezionato
If SetUpToolListBox.SelectedItems.Count() = 0 Then
Return
Else
OkBtn.IsEnabled = True
End If
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
DialogResult = True
End Sub
Friend Function GetSelectedTool() As ToolPos
Return DirectCast(SetUpToolListBox.SelectedItem, ToolPos)
End Function
End Class
Public Class ToolPos
Friend m_ToolName As String
Public Property ToolName As String
Get
Return m_ToolName
End Get
Set(value As String)
m_ToolName = value
End Set
End Property
Friend m_ToolPos As String
Friend m_IsSaw As Boolean
Sub New(sToolName As String, sToolPos As String, bIsSaw As Boolean)
m_ToolName = sToolName
m_ToolPos = sToolPos
m_IsSaw = bIsSaw
End Sub
End Class