Imports System.ComponentModel
Imports System.IO
Imports EgtUILib
Public Module MachineModel
#Region "Machining"
'''
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
'''
Friend Function ReadActiveMachiningsFamilies() As MachiningsType()
Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType)
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.DRILLING, .TypeName = EgtMsg(6201)}) ' Foratura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWING, .TypeName = EgtMsg(6202)}) ' Taglio di lama
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MILLING, .TypeName = EgtMsg(6203)}) ' Fresatura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.POCKETING, .TypeName = EgtMsg(6204)}) ' Svuotatura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MORTISING, .TypeName = EgtMsg(6205)}) ' Mortasatura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWROUGHING, .TypeName = EgtMsg(6206)}) ' Sgrossatura con lama
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWFINISHING, .TypeName = EgtMsg(6207)}) ' Finitura con lama
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_GENMACHINING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.GENMACHINING, .TypeName = EgtMsg(6208)}) ' Lav. generica
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_CHISELING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.CHISELING, .TypeName = EgtMsg(6209)}) ' Scalpellatura
End If
If IniFile.IsKeyEnabledAdvancedMachining() AndAlso EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SURFROUGHING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SURFROUGHING, .TypeName = EgtMsg(31212)})
End If
If IniFile.IsKeyEnabledAdvancedMachining() AndAlso EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SURFFINISHING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SURFFINISHING, .TypeName = EgtMsg(31211)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_WATERJETTING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.WATERJETTING, .TypeName = EgtMsg(6212)}) ' WaterJet
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_5AXMILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.FIVEAXISMILLING, .TypeName = EgtMsg(31213)})
End If
Return ActiveMachiningsFamiliesList.ToArray
End Function
Friend Function ReadMachiningsFamilies(sMachineName As String) As MachiningsType()
Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType)
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.DRILLING, .TypeName = EgtMsg(6201)}) ' Foratura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWING, .TypeName = EgtMsg(6202)}) ' Taglio di lama
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MILLING, .TypeName = EgtMsg(6203)}) ' Fresatura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.POCKETING, .TypeName = EgtMsg(6204)}) ' Svuotatura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MORTISING, .TypeName = EgtMsg(6205)}) ' Mortasatura
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWROUGHING, .TypeName = EgtMsg(6206)}) ' Sgrossatura con lama
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWFINISHING, .TypeName = EgtMsg(6207)}) ' Finitura con lama
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_GENMACHINING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.GENMACHINING, .TypeName = EgtMsg(6208)}) ' Lav. generica
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_CHISELING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.CHISELING, .TypeName = EgtMsg(6209)}) ' Scalpellatura
End If
If IniFile.IsKeyEnabledAdvancedMachining() AndAlso EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SURFROUGHING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SURFROUGHING, .TypeName = EgtMsg(31212)}) ' Sgrossatura superfici
End If
If IniFile.IsKeyEnabledAdvancedMachining() AndAlso EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SURFFINISHING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SURFFINISHING, .TypeName = EgtMsg(31211)}) ' Finitura superfici
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_WATERJETTING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.WATERJETTING, .TypeName = EgtMsg(6212)}) ' WaterJet
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_5AXMILLING, 0, sMachineName) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.FIVEAXISMILLING, .TypeName = EgtMsg(31213)}) ' Lav. 5 assi
End If
Return ActiveMachiningsFamiliesList.ToArray
End Function
' Funzione che imposta la macchina corrente se la trova, altrimenti chiede se ricaricarla o annullare
Friend Function EgtTrySettingCurrMachine(sMachineName As String) As Boolean
If EgtSetCurrMachine(sMachineName) Then
Return True
End If
'If MessageBox.Show(String.Format(EgtMsg(MSG_DOORSERRORS + 13) & Environment.NewLine & EgtMsg(MSG_DOORSERRORS + 14), sMachineName), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then
If EgtMessageBoxV.Show(Application.Current.MainWindow, String.Format(EgtMsg(8113) & Environment.NewLine & EgtMsg(8114), sMachineName), EgtMsg(15001), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then ' Impossibile trovare la cartella delle macchine {0}. Se la cartella delle macchine è su un server, verificare che la connessione sia attiva. Provare a ricaricare la macchina?
Return EgtTrySettingCurrMachine(sMachineName)
End If
Return False
End Function
' Funzione che verifica l'esistenza e la connessione della cartella Machines
Friend Function EgtVerifyMachinesDir() As Boolean
' verifico l'esistenza della cartella Machines
If String.IsNullOrWhiteSpace(IniFile.m_sMachinesRoot) Then
Return False
End If
Return VerifyMachinesDir()
End Function
Private Function VerifyMachinesDir() As Boolean
If Directory.Exists(IniFile.m_sMachinesRoot) Then
Return True
Else
'If MessageBox.Show(String.Format(EgtMsg(MSG_DOORSERRORS + 13) & Environment.NewLine & EgtMsg(MSG_DOORSERRORS + 14), IniFile.m_sMachinesRoot), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then
If EgtMessageBoxV.Show(Application.Current.MainWindow, String.Format(EgtMsg(8113) & Environment.NewLine & EgtMsg(8114), IniFile.m_sMachinesRoot), EgtMsg(15001), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then ' Impossibile trovare la cartella delle macchine {0}. Se la cartella delle macchine è su un server, verificare che la connessione sia attiva. Provare a ricaricare la macchina?
Return VerifyMachinesDir()
End If
Return False
End If
End Function
'''
''' Structure that represent a tool's family, containing family type and family name
'''
Public Class MachiningsType
Implements INotifyPropertyChanged
Friend TypeId As MCH_MY
Private m_TypeName As String
Public Property TypeName As String
Get
Return m_TypeName
End Get
Set(value As String)
m_TypeName = value
End Set
End Property
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class
#End Region ' Machining
#Region "Tool"
'''
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
'''
Friend Function ReadActiveToolsFamilies() As ToolsFamily()
Dim ActiveToolsFamiliesList As New List(Of ToolsFamily)
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_DRILLBIT, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.DRILLBIT, EgtMsg(6001))) ' Punta
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_SAWBLADE, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.SAWBLADE, EgtMsg(6002))) ' Lama
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MILL, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.MILL, EgtMsg(6003))) ' Fresa
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MORTISE, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.MORTISE, EgtMsg(6004))) ' Mortasatrice
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_CHISEL, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.CHISEL, EgtMsg(6009))) ' Scalpello
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_WATERJET, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.WATERJET, EgtMsg(6010))) ' WaterJet
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_COMPO, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.COMPO, EgtMsg(6005))) ' Composito
End If
Return ActiveToolsFamiliesList.ToArray
End Function
'''
''' Structure that represent a tool's family, containing family type and family name
'''
Friend Class ToolsFamily
Private m_FamilyId As MCH_TF
Public ReadOnly Property FamilyId As MCH_TF
Get
Return m_FamilyId
End Get
End Property
Private m_FamilyName As String
Public ReadOnly Property FamilyName As String
Get
Return m_FamilyName
End Get
End Property
Sub New(nFamilyId As MCH_TF, sFamilyName As String)
m_FamilyId = nFamilyId
m_FamilyName = sFamilyName
End Sub
End Class
#End Region ' Tool
End Module