7b4f8529c3
-cambiato gestione SetVisibility -aggiunto su veriifica singolo pezzo disabilita intera riga
394 lines
12 KiB
VB.net
394 lines
12 KiB
VB.net
Imports System.IO
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Google.Protobuf.WellKnownTypes
|
|
|
|
Public Class MachinePanelVM
|
|
Inherits EgtWPFLib5.MachinePanelVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend Enum ConfigTabs As Integer
|
|
EMPTY = 0
|
|
STRATEGYMANAGER = 1
|
|
MACHINEPARAMS = 2
|
|
End Enum
|
|
|
|
' Radice del direttorio delle macchine
|
|
Private m_sMachinesRoot As String
|
|
|
|
' Macchina correntemente selezionata e quindi attiva
|
|
Private m_SelectedMachine As Machine = Nothing
|
|
Public Shadows Property SelectedMachine As MyMachine
|
|
Get
|
|
Return m_SelectedMachine
|
|
End Get
|
|
Set(value As MyMachine)
|
|
If value IsNot m_SelectedMachine Then
|
|
' imposto macchina in DbGeometrico
|
|
If Not IsNothing(value) AndAlso EgtSetCurrMachine(value.Name) Then
|
|
m_SelectedMachine = value
|
|
ProjectManagerVM.CurrProd.SetMachine(SelectedMachine.Name)
|
|
' crea l'elenco dei parametri della macchina corrente
|
|
SelectedMachine.CreateMachParams()
|
|
' aggiorno lista strategie
|
|
Map.refStrategyManagerVM.Update()
|
|
End If
|
|
NotifyPropertyChanged(NameOf(SelectedMachine))
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nSelTab As ConfigTabs
|
|
Public Property nSelTab As Integer
|
|
Get
|
|
Return m_nSelTab
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nSelTab = value
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelTab(nValue As ConfigTabs)
|
|
m_nSelTab = nValue
|
|
NotifyPropertyChanged(NameOf(nSelTab))
|
|
End Sub
|
|
|
|
Private m_MachPanel_IsEnabled As Boolean = True
|
|
Public Property MachPanel_IsEnabled As Boolean
|
|
Get
|
|
Return m_MachPanel_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_MachPanel_IsEnabled = value
|
|
NotifyPropertyChanged(NameOf(MachPanel_IsEnabled))
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property SetUp_Visibility As Visibility
|
|
Get
|
|
Return If(Map.refMainWindowVM.MainWindowM.bModifySetup, Visibility.Visible, Visibility.Collapsed)
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ChooseMachine_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property ChooseMachine_Visibility As Visibility
|
|
Get
|
|
Return m_ChooseMachine_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetChooseMachine_Visibility(IsVisible As Boolean)
|
|
m_ChooseMachine_Visibility = If(IsVisible, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(ChooseMachine_Visibility))
|
|
End Sub
|
|
|
|
Private m_SelMachineName As String = String.Empty
|
|
Public ReadOnly Property SelMachineName As String
|
|
Get
|
|
Return m_SelMachineName
|
|
End Get
|
|
End Property
|
|
Friend Sub SetSelMachineName(value As String)
|
|
m_SelMachineName = value
|
|
NotifyPropertyChanged(NameOf(SelMachineName))
|
|
End Sub
|
|
|
|
Private m_bStrategyManagerIsChecked As Boolean = False
|
|
Public Property StrategyManagerIsChecked As Boolean
|
|
Get
|
|
Return m_bStrategyManagerIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bStrategyManagerIsChecked = value
|
|
SetStrategyManagerIsChecked(m_bStrategyManagerIsChecked)
|
|
End Set
|
|
End Property
|
|
Friend Sub SetStrategyManagerIsChecked(value As Boolean)
|
|
m_bStrategyManagerIsChecked = value
|
|
m_bMachineParamsIsChecked = False
|
|
SetSelTab(ConfigTabs.STRATEGYMANAGER)
|
|
NotifyPropertyChanged(NameOf(StrategyManagerIsChecked))
|
|
NotifyPropertyChanged(NameOf(MachineParamsIsChecked))
|
|
End Sub
|
|
|
|
Private m_bMachineParamsIsChecked As Boolean = False
|
|
Public Property MachineParamsIsChecked As Boolean
|
|
Get
|
|
Return m_bMachineParamsIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bMachineParamsIsChecked = value
|
|
SetMachineParamsIsChecked(m_bMachineParamsIsChecked)
|
|
End Set
|
|
End Property
|
|
Friend Sub SetMachineParamsIsChecked(value As Boolean)
|
|
m_bMachineParamsIsChecked = value
|
|
m_bStrategyManagerIsChecked = False
|
|
SetSelTab(ConfigTabs.MACHINEPARAMS)
|
|
NotifyPropertyChanged(NameOf(MachineParamsIsChecked))
|
|
NotifyPropertyChanged(NameOf(StrategyManagerIsChecked))
|
|
End Sub
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property ToolDBMsg As String
|
|
Get
|
|
Return EgtMsg(90706)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MachiningDbMsg As String
|
|
Get
|
|
Return EgtMsg(90707)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SetUpMsg As String
|
|
Get
|
|
Return EgtMsg(90933)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property MachineParamsMsg As String
|
|
Get
|
|
Return EgtMsg(61778)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StrategyManagerMsg As String
|
|
Get
|
|
Return EgtMsg(62569)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CurrentMachineMsg As String
|
|
Get
|
|
Return EgtMsg(6565)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ChooseMachine_ToolTip As String
|
|
Get
|
|
Return EgtMsg(61941)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property ToolDBToolTip As String
|
|
Get
|
|
Return EgtMsg(5003)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MachiningDbToolTip As String
|
|
Get
|
|
Return EgtMsg(5004)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SetUpToolTip As String
|
|
Get
|
|
Return EgtMsg(31501)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SaveToolTip As String
|
|
Get
|
|
Return EgtMsg(30503)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
' Definizione comandi
|
|
Private m_cmdChooseMachine As ICommand
|
|
Private m_cmdOk As ICommand
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMachinePanelVM(Me)
|
|
' recupero cartella radice delle macchine
|
|
m_sMachinesRoot = Map.refMainWindowVM.MainWindowM.sMachinesRoot
|
|
' Carica macchine da cartella delle macchine
|
|
MyMachine.MachineListInit(m_sMachinesRoot, MachineList)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub LoadCurrentMachine()
|
|
If MachineList.Count = 0 Then Return
|
|
Dim CurrMachine As Machine = Nothing
|
|
Dim CurrMachineName As String = String.Empty
|
|
GetMainPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMachineName)
|
|
Dim bFound As Boolean = False
|
|
If Not String.IsNullOrEmpty(CurrMachineName) Then
|
|
For Each Mach In MachineList
|
|
If Mach.Name = CurrMachineName Then
|
|
bFound = True
|
|
CurrMachine = Mach
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
If Not bFound And MachineList.Count > 0 Then
|
|
CurrMachine = MachineList(0)
|
|
End If
|
|
If Not IsNothing(CurrMachine) Then
|
|
If EgtSetCurrMachine(CurrMachine.Name) Then
|
|
SelectedMachine = CurrMachine
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub SaveCurrentMachine()
|
|
If IsNothing(m_SelectedMachine) Then Return
|
|
WriteMainPrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name)
|
|
End Sub
|
|
|
|
Friend Sub UpdateCurrentMachine()
|
|
Dim sMachName As String = String.Empty
|
|
If EgtGetCurrMachineName(sMachName) Then
|
|
For Each Mach In MachineList
|
|
If Mach.Name = sMachName Then
|
|
SelectedMachine = Mach
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub ToolDb(ByVal param As Object)
|
|
SetSelTab(ConfigTabs.EMPTY)
|
|
If Not VerifyMachinesDir(m_sMachinesRoot) 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")
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31130), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
|
|
Dim ToolDbWindowVM As New MyToolDbWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Beam")
|
|
Dim ToolDbWindowV = New ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM)
|
|
|
|
If ToolDbWindowVM.MatType <> 0 Then
|
|
ToolDbWindowV.Height = 640
|
|
ToolDbWindowV.Width = 1024
|
|
ToolDbWindowV.ShowDialog()
|
|
Else
|
|
Exit Sub
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub MachDb(ByVal param As Object)
|
|
SetSelTab(ConfigTabs.EMPTY)
|
|
If Not VerifyMachinesDir(m_sMachinesRoot) 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")
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31408), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Stone")
|
|
Dim MachDbWindowV = New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM)
|
|
|
|
If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then
|
|
MachDbWindowV.Height = 768
|
|
MachDbWindowV.Width = 1024
|
|
MachDbWindowV.ShowDialog()
|
|
Else
|
|
Exit Sub
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub SetUp(ByVal param As Object)
|
|
SetSelTab(ConfigTabs.EMPTY)
|
|
' verifico che il file di configurazione attrezzaggio (lua) della macchina esista
|
|
If Not File.Exists(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) Then
|
|
EgtOutLog("SetUp error: SetUp configuration file doesn't exist ")
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(6477), EgtMsg(6471), 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(CurrentMachine.sMachDir & "\Scripts\" & 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
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(6478), EgtMsg(6471), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("STU")
|
|
|
|
Dim SetUpWindow As New SetUpWindowV(Application.Current.MainWindow, New SetUpWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachineName)) With {
|
|
.Height = 614,
|
|
.Width = 1024
|
|
}
|
|
|
|
SetUpWindow.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ChooseMachine"
|
|
|
|
Public ReadOnly Property ChooseMachine_Command As ICommand
|
|
Get
|
|
If m_cmdChooseMachine Is Nothing Then
|
|
m_cmdChooseMachine = New Command(AddressOf ChooseMachine)
|
|
End If
|
|
Return m_cmdChooseMachine
|
|
End Get
|
|
End Property
|
|
|
|
Friend Sub ChooseMachine()
|
|
SetChooseMachine_Visibility(True)
|
|
End Sub
|
|
|
|
#End Region ' ChooseMachine
|
|
|
|
#Region "Ok"
|
|
|
|
Public ReadOnly Property Ok_Command As ICommand
|
|
Get
|
|
If m_cmdOk Is Nothing Then
|
|
m_cmdOk = New Command(AddressOf Ok)
|
|
End If
|
|
Return m_cmdOk
|
|
End Get
|
|
End Property
|
|
|
|
Friend Sub Ok()
|
|
SetSelMachineName(m_SelectedMachine.Name)
|
|
SetChooseMachine_Visibility(False)
|
|
End Sub
|
|
|
|
#End Region ' Ok
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|