9b836645ff
- Gestione dei parametri da visualizzare per ciascun utensile del DB Utensile ora è spostata sulla libreria EgtWPFLib5 (come già fatto per Db Lavorazioni) - Cancellati file non più necessari grazie alla nuova gestione
283 lines
9.2 KiB
VB.net
283 lines
9.2 KiB
VB.net
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class MachinePanelVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Definizione comandi
|
|
Private m_cmdToolDb As ICommand
|
|
Private m_cmdMachDb As ICommand
|
|
Private m_cmdSetUpDb As ICommand
|
|
Private m_cmdMachOptions As ICommand
|
|
|
|
Private m_ToolDb_IsEnabled As Boolean = True
|
|
Public ReadOnly Property ToolDb_IsEnabled As Boolean
|
|
Get
|
|
Return m_ToolDb_IsEnabled
|
|
End Get
|
|
End Property
|
|
|
|
Private m_MachDb_IsEnabled As Boolean = True
|
|
Public ReadOnly Property MachDb_IsEnabled As Boolean
|
|
Get
|
|
Return m_MachDb_IsEnabled
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SetUpDb_IsEnabled As Boolean = True
|
|
Public ReadOnly Property SetUpDb_IsEnabled As Boolean
|
|
Get
|
|
Return m_SetUpDb_IsEnabled
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property ToolDBMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 6)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property MachiningDbMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 7)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SetUpDbMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 9)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property ToolDBToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 3)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property MachiningDbToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 4)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SetUpDbToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 10)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property MachOptionsToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_MAINWINDOW + 8)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
#End Region 'FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMachinePanelVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub ToolMachSetUpIsEnabled(ToolDb_IsEnabled As Boolean, MachDb_IsEnabled As Boolean, SetUpDb_IsEnabled As Boolean)
|
|
m_ToolDb_IsEnabled = ToolDb_IsEnabled
|
|
m_MachDb_IsEnabled = MachDb_IsEnabled
|
|
m_SetUpDb_IsEnabled = SetUpDb_IsEnabled
|
|
NotifyPropertyChanged("ToolDb_IsEnabled")
|
|
NotifyPropertyChanged("MachDb_IsEnabled")
|
|
NotifyPropertyChanged("SetUpDb_IsEnabled")
|
|
End Sub
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ToolDbCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property ToolDbCommand As ICommand
|
|
Get
|
|
If m_cmdToolDb Is Nothing Then
|
|
m_cmdToolDb = New RelayCommand(AddressOf ToolDb)
|
|
End If
|
|
Return m_cmdToolDb
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Shared Sub ToolDb()
|
|
If Not EgtVerifyMachinesDir() Then Return
|
|
' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa)
|
|
If Not EgtTdbReload() Then
|
|
EgtOutLog("Impossible reloading tool Db")
|
|
MessageBox.Show(EgtMsg(MSG_TOOLSERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
'Dim ToolDbWindow As New ToolsDbV
|
|
'ToolDbWindow.Height = 640
|
|
'ToolDbWindow.Width = 1024
|
|
'ToolDbWindow.DataContext = New ToolsDbVM
|
|
'ToolDbWindow.Owner = Application.Current.MainWindow
|
|
'ToolDbWindow.ShowDialog()
|
|
|
|
Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName
|
|
Dim ToolDbWindowVM As New MyToolDbWindowVM(sMachineDir, IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood")
|
|
Dim ToolDbWindowV As New EgtWPFLib5.ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM)
|
|
If ToolDbWindowVM.MatType <> 0 Then
|
|
ToolDbWindowV.Height = 674
|
|
ToolDbWindowV.Width = 1024
|
|
ToolDbWindowV.Owner = Application.Current.MainWindow
|
|
ToolDbWindowV.ShowDialog()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region ' ToolDbCommand
|
|
|
|
#Region "MachDbCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property MachDbCommand As ICommand
|
|
Get
|
|
If m_cmdMachDb Is Nothing Then
|
|
m_cmdMachDb = New RelayCommand(AddressOf MachDb)
|
|
End If
|
|
Return m_cmdMachDb
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Shared Sub MachDb()
|
|
If Not EgtVerifyMachinesDir() Then Return
|
|
' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa)
|
|
If Not EgtMdbReload() Then
|
|
EgtOutLog("Impossible reloading machining Db")
|
|
MessageBox.Show(EgtMsg(MSG_MACHININGSERRORS + 7), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood")
|
|
Dim MachDbWindowV As New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM)
|
|
If MachDbWindowVM.MatType <> 0 Then
|
|
MachDbWindowV.Height = 674
|
|
MachDbWindowV.Width = 1024
|
|
MachDbWindowV.Owner = Application.Current.MainWindow
|
|
MachDbWindowV.ShowDialog()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' MachDbCommand
|
|
|
|
#Region "SetUpDb"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property SetUpDb_Command As ICommand
|
|
Get
|
|
If m_cmdSetUpDb Is Nothing Then
|
|
m_cmdSetUpDb = New RelayCommand(AddressOf SetUpDb)
|
|
End If
|
|
Return m_cmdSetUpDb
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Shared Sub SetUpDb()
|
|
' verifico che il file di configurazione attrezzaggio (lua) della macchina esista
|
|
If Not File.Exists(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) Then
|
|
EgtOutLog("SetUp error: SetUp configuration file doesn't exist ")
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato,
|
|
' e testa e uscita dell'utensile attrezzato
|
|
EgtLuaExecFile(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA)
|
|
' verifico che le teste riportate in configurazione esistano
|
|
Dim Index As Integer = 1
|
|
Dim nErr As Integer = 0
|
|
While nErr = 0
|
|
Dim sHead As String = String.Empty
|
|
nErr = 999
|
|
EgtLuaSetGlobIntVar("STU.INDEX", Index)
|
|
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
EgtLuaGetGlobIntVar("STU.ERR", nErr)
|
|
If nErr = 0 Then
|
|
If EgtGetHeadExitCount(sHead) = 0 Then
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
' Verifico esistenza direttorio per attrezzaggi
|
|
Dim sDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp"
|
|
If Not Directory.Exists(sDir) Then
|
|
Try
|
|
Directory.CreateDirectory(sDir)
|
|
Catch ex As Exception
|
|
EgtOutLog("Error in SetupDir creation " & ex.ToString())
|
|
Return
|
|
End Try
|
|
End If
|
|
' creo ed apro finestra SetUp
|
|
Dim SetUpDbWindow As New SetUpDbV(Application.Current.MainWindow, New SetUpDbVM)
|
|
SetUpDbWindow.ShowDialog()
|
|
Application.Msn.NotifyColleagues(Application.EMITTITLE)
|
|
End Sub
|
|
|
|
#End Region ' SetUpDb
|
|
|
|
#Region "MachOptionsCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property MachOptionsCommand As ICommand
|
|
Get
|
|
If m_cmdMachOptions Is Nothing Then
|
|
m_cmdMachOptions = New RelayCommand(AddressOf MachOptions)
|
|
End If
|
|
Return m_cmdMachOptions
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub MachOptions(ByVal param As Object)
|
|
Dim MachOptionWindow As New MachOptionV
|
|
'MachOptionWindow.Height = 614
|
|
'MachOptionWindow.Width = 256
|
|
MachOptionWindow.DataContext = New MachOptionVM
|
|
MachOptionWindow.Owner = Application.Current.MainWindow
|
|
MachOptionWindow.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' MachOptionsCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class |